From 8f166742ab91772a6cb356a48111f450e9ee8338 Mon Sep 17 00:00:00 2001 From: xianny Date: Thu, 7 Nov 2019 18:01:09 -0800 Subject: [PATCH 01/20] update abi-gen with new method interfaces --- .../generated-wrappers/asset_proxy_owner.ts | 4756 ++--- .../src/generated-wrappers/coordinator.ts | 1371 +- .../coordinator_registry.ts | 445 +- .../src/generated-wrappers/dev_utils.ts | 5596 +++--- .../generated-wrappers/dummy_erc20_token.ts | 2621 ++- .../generated-wrappers/dummy_erc721_token.ts | 3332 ++-- .../src/generated-wrappers/dutch_auction.ts | 1097 +- .../generated-wrappers/erc1155_mintable.ts | 3631 ++-- .../src/generated-wrappers/erc1155_proxy.ts | 2021 +- .../src/generated-wrappers/erc20_proxy.ts | 1645 +- .../src/generated-wrappers/erc20_token.ts | 1334 +- .../src/generated-wrappers/erc721_proxy.ts | 1645 +- .../src/generated-wrappers/erc721_token.ts | 2201 +-- .../generated-wrappers/eth_balance_checker.ts | 160 +- .../src/generated-wrappers/exchange.ts | 16449 +++++++--------- .../src/generated-wrappers/forwarder.ts | 1967 +- .../src/generated-wrappers/i_asset_proxy.ts | 498 +- .../src/generated-wrappers/i_validator.ts | 181 +- .../src/generated-wrappers/i_wallet.ts | 168 +- .../generated-wrappers/multi_asset_proxy.ts | 2125 +- .../src/generated-wrappers/order_validator.ts | 1201 +- .../src/generated-wrappers/staking.ts | 8825 ++++----- .../src/generated-wrappers/staking_proxy.ts | 3885 ++-- .../generated-wrappers/static_call_proxy.ts | 268 +- .../src/generated-wrappers/weth9.ts | 1986 +- .../src/generated-wrappers/zrx_token.ts | 1543 +- packages/abi-gen/src/index.ts | 8 +- packages/abi-gen/src/types.ts | 1 - .../templates/TypeScript/contract.handlebars | 109 +- .../partials/method_abi_helper.handlebars | 86 - .../partials/method_call.handlebars | 28 +- .../partials/method_call_pure.handlebars | 44 - .../TypeScript/partials/method_tx.handlebars | 51 +- .../output/typescript/abi_gen_dummy.ts | 4603 ++--- .../test-cli/output/typescript/lib_dummy.ts | 53 +- .../output/typescript/test_lib_dummy.ts | 290 +- .../test/abi_gen_dummy_test.ts | 75 +- packages/base-contract/src/index.ts | 2 + packages/base-contract/src/types.ts | 37 +- packages/base-contract/src/utils.ts | 21 +- packages/types/src/index.ts | 24 - 41 files changed, 33510 insertions(+), 42873 deletions(-) delete mode 100644 packages/abi-gen/templates/TypeScript/partials/method_abi_helper.handlebars delete mode 100644 packages/abi-gen/templates/TypeScript/partials/method_call_pure.handlebars diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/asset_proxy_owner.ts b/packages/abi-gen-wrappers/src/generated-wrappers/asset_proxy_owner.ts index 20e56f1633..95ea9c4cf9 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/asset_proxy_owner.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/asset_proxy_owner.ts @@ -1,7 +1,16 @@ // tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma enum-naming // tslint:disable:whitespace no-unbound-method no-trailing-whitespace // tslint:disable:no-unused-variable -import { BaseContract, SubscriptionManager, PromiseWithTransactionHash } from '@0x/base-contract'; +import { + AwaitTransactionSuccessOpts, + ContractFunctionObj, + ContractTxFunctionObj, + SendTransactionOpts, + BaseContract, + SubscriptionManager, + PromiseWithTransactionHash, + methodAbiToFunctionSignature, +} from '@0x/base-contract'; import { schemas } from '@0x/json-schemas'; import { BlockParam, @@ -19,13 +28,7 @@ import { SupportedProvider, } from 'ethereum-types'; import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils'; -import { - AwaitTransactionSuccessOpts, - EventCallback, - IndexedFilterValues, - SendTransactionOpts, - SimpleContractArtifact, -} from '@0x/types'; +import { EventCallback, IndexedFilterValues, SimpleContractArtifact } from '@0x/types'; import { Web3Wrapper } from '@0x/web3-wrapper'; import { assert } from '@0x/assert'; import * as ethers from 'ethers'; @@ -123,2585 +126,7 @@ export class AssetProxyOwnerContract extends BaseContract { * @ignore */ public static deployedBytecode: string | undefined; - public MAX_OWNER_COUNT = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as AssetProxyOwnerContract; - const encodedData = self._strictEncodeArguments('MAX_OWNER_COUNT()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('MAX_OWNER_COUNT()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Allows to add a new owner. Transaction has to be sent by wallet. - */ - public addOwner = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param owner Address of new owner. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - owner: string, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('owner', owner); - const self = (this as any) as AssetProxyOwnerContract; - const encodedData = self._strictEncodeArguments('addOwner(address)', [owner.toLowerCase()]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.addOwner.callAsync(owner, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param owner Address of new owner. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - owner: string, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('owner', owner); - const self = (this as any) as AssetProxyOwnerContract; - const txHashPromise = self.addOwner.sendTransactionAsync(owner.toLowerCase(), txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param owner Address of new owner. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync(owner: string, txData?: Partial | undefined): Promise { - assert.isString('owner', owner); - const self = (this as any) as AssetProxyOwnerContract; - const encodedData = self._strictEncodeArguments('addOwner(address)', [owner.toLowerCase()]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param owner Address of new owner. - */ - async callAsync(owner: string, callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.isString('owner', owner); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as AssetProxyOwnerContract; - const encodedData = self._strictEncodeArguments('addOwner(address)', [owner.toLowerCase()]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('addOwner(address)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param owner Address of new owner. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(owner: string): string { - assert.isString('owner', owner); - const self = (this as any) as AssetProxyOwnerContract; - const abiEncodedTransactionData = self._strictEncodeArguments('addOwner(address)', [owner.toLowerCase()]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as AssetProxyOwnerContract; - const abiEncoder = self._lookupAbiEncoder('addOwner(address)'); - return abiEncoder.getSelector(); - }, - }; - /** - * Allows to change the number of required confirmations. Transaction has to be sent by wallet. - */ - public changeRequirement = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param _required Number of required confirmations. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - _required: BigNumber, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isBigNumber('_required', _required); - const self = (this as any) as AssetProxyOwnerContract; - const encodedData = self._strictEncodeArguments('changeRequirement(uint256)', [_required]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.changeRequirement.callAsync(_required, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param _required Number of required confirmations. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - _required: BigNumber, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isBigNumber('_required', _required); - const self = (this as any) as AssetProxyOwnerContract; - const txHashPromise = self.changeRequirement.sendTransactionAsync(_required, txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param _required Number of required confirmations. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync(_required: BigNumber, txData?: Partial | undefined): Promise { - assert.isBigNumber('_required', _required); - const self = (this as any) as AssetProxyOwnerContract; - const encodedData = self._strictEncodeArguments('changeRequirement(uint256)', [_required]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param _required Number of required confirmations. - */ - async callAsync( - _required: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isBigNumber('_required', _required); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as AssetProxyOwnerContract; - const encodedData = self._strictEncodeArguments('changeRequirement(uint256)', [_required]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('changeRequirement(uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param _required Number of required confirmations. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(_required: BigNumber): string { - assert.isBigNumber('_required', _required); - const self = (this as any) as AssetProxyOwnerContract; - const abiEncodedTransactionData = self._strictEncodeArguments('changeRequirement(uint256)', [_required]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as AssetProxyOwnerContract; - const abiEncoder = self._lookupAbiEncoder('changeRequirement(uint256)'); - return abiEncoder.getSelector(); - }, - }; - /** - * Changes the duration of the time lock for transactions. - */ - public changeTimeLock = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param _secondsTimeLocked Duration needed after a transaction is confirmed - * and before it becomes executable, in seconds. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - _secondsTimeLocked: BigNumber, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isBigNumber('_secondsTimeLocked', _secondsTimeLocked); - const self = (this as any) as AssetProxyOwnerContract; - const encodedData = self._strictEncodeArguments('changeTimeLock(uint256)', [_secondsTimeLocked]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.changeTimeLock.callAsync(_secondsTimeLocked, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param _secondsTimeLocked Duration needed after a transaction is confirmed - * and before it becomes executable, in seconds. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - _secondsTimeLocked: BigNumber, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isBigNumber('_secondsTimeLocked', _secondsTimeLocked); - const self = (this as any) as AssetProxyOwnerContract; - const txHashPromise = self.changeTimeLock.sendTransactionAsync(_secondsTimeLocked, txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param _secondsTimeLocked Duration needed after a transaction is confirmed - * and before it becomes executable, in seconds. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync(_secondsTimeLocked: BigNumber, txData?: Partial | undefined): Promise { - assert.isBigNumber('_secondsTimeLocked', _secondsTimeLocked); - const self = (this as any) as AssetProxyOwnerContract; - const encodedData = self._strictEncodeArguments('changeTimeLock(uint256)', [_secondsTimeLocked]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param _secondsTimeLocked Duration needed after a transaction is confirmed - * and before it becomes executable, in seconds. - */ - async callAsync( - _secondsTimeLocked: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isBigNumber('_secondsTimeLocked', _secondsTimeLocked); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as AssetProxyOwnerContract; - const encodedData = self._strictEncodeArguments('changeTimeLock(uint256)', [_secondsTimeLocked]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('changeTimeLock(uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param _secondsTimeLocked Duration needed after a transaction is confirmed - * and before it becomes executable, in seconds. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(_secondsTimeLocked: BigNumber): string { - assert.isBigNumber('_secondsTimeLocked', _secondsTimeLocked); - const self = (this as any) as AssetProxyOwnerContract; - const abiEncodedTransactionData = self._strictEncodeArguments('changeTimeLock(uint256)', [ - _secondsTimeLocked, - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as AssetProxyOwnerContract; - const abiEncoder = self._lookupAbiEncoder('changeTimeLock(uint256)'); - return abiEncoder.getSelector(); - }, - }; - /** - * Allows an owner to confirm a transaction. - */ - public confirmTransaction = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param transactionId Transaction ID. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - transactionId: BigNumber, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isBigNumber('transactionId', transactionId); - const self = (this as any) as AssetProxyOwnerContract; - const encodedData = self._strictEncodeArguments('confirmTransaction(uint256)', [transactionId]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.confirmTransaction.callAsync(transactionId, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param transactionId Transaction ID. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - transactionId: BigNumber, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isBigNumber('transactionId', transactionId); - const self = (this as any) as AssetProxyOwnerContract; - const txHashPromise = self.confirmTransaction.sendTransactionAsync(transactionId, txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param transactionId Transaction ID. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync(transactionId: BigNumber, txData?: Partial | undefined): Promise { - assert.isBigNumber('transactionId', transactionId); - const self = (this as any) as AssetProxyOwnerContract; - const encodedData = self._strictEncodeArguments('confirmTransaction(uint256)', [transactionId]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param transactionId Transaction ID. - */ - async callAsync( - transactionId: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isBigNumber('transactionId', transactionId); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as AssetProxyOwnerContract; - const encodedData = self._strictEncodeArguments('confirmTransaction(uint256)', [transactionId]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('confirmTransaction(uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param transactionId Transaction ID. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(transactionId: BigNumber): string { - assert.isBigNumber('transactionId', transactionId); - const self = (this as any) as AssetProxyOwnerContract; - const abiEncodedTransactionData = self._strictEncodeArguments('confirmTransaction(uint256)', [ - transactionId, - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as AssetProxyOwnerContract; - const abiEncoder = self._lookupAbiEncoder('confirmTransaction(uint256)'); - return abiEncoder.getSelector(); - }, - }; - public confirmationTimes = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync( - index_0: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isBigNumber('index_0', index_0); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as AssetProxyOwnerContract; - const encodedData = self._strictEncodeArguments('confirmationTimes(uint256)', [index_0]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('confirmationTimes(uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public confirmations = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync( - index_0: BigNumber, - index_1: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isBigNumber('index_0', index_0); - assert.isString('index_1', index_1); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as AssetProxyOwnerContract; - const encodedData = self._strictEncodeArguments('confirmations(uint256,address)', [ - index_0, - index_1.toLowerCase(), - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('confirmations(uint256,address)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Allows anyone to execute a confirmed transaction. - * Transactions *must* encode the values with the signature "bytes[] data, address[] destinations, uint256[] values" - * The `destination` and `value` fields of the transaction in storage are ignored. - * All function calls must be successful or the entire call will revert. - */ - public executeTransaction = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param transactionId Transaction ID. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - transactionId: BigNumber, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isBigNumber('transactionId', transactionId); - const self = (this as any) as AssetProxyOwnerContract; - const encodedData = self._strictEncodeArguments('executeTransaction(uint256)', [transactionId]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.executeTransaction.callAsync(transactionId, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param transactionId Transaction ID. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - transactionId: BigNumber, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isBigNumber('transactionId', transactionId); - const self = (this as any) as AssetProxyOwnerContract; - const txHashPromise = self.executeTransaction.sendTransactionAsync(transactionId, txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param transactionId Transaction ID. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync(transactionId: BigNumber, txData?: Partial | undefined): Promise { - assert.isBigNumber('transactionId', transactionId); - const self = (this as any) as AssetProxyOwnerContract; - const encodedData = self._strictEncodeArguments('executeTransaction(uint256)', [transactionId]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param transactionId Transaction ID. - */ - async callAsync( - transactionId: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isBigNumber('transactionId', transactionId); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as AssetProxyOwnerContract; - const encodedData = self._strictEncodeArguments('executeTransaction(uint256)', [transactionId]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('executeTransaction(uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param transactionId Transaction ID. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(transactionId: BigNumber): string { - assert.isBigNumber('transactionId', transactionId); - const self = (this as any) as AssetProxyOwnerContract; - const abiEncodedTransactionData = self._strictEncodeArguments('executeTransaction(uint256)', [ - transactionId, - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as AssetProxyOwnerContract; - const abiEncoder = self._lookupAbiEncoder('executeTransaction(uint256)'); - return abiEncoder.getSelector(); - }, - }; - public functionCallTimeLocks = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync( - index_0: string, - index_1: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise<[boolean, BigNumber]> { - assert.isString('index_0', index_0); - assert.isString('index_1', index_1); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as AssetProxyOwnerContract; - const encodedData = self._strictEncodeArguments('functionCallTimeLocks(bytes4,address)', [ - index_0, - index_1.toLowerCase(), - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('functionCallTimeLocks(bytes4,address)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue<[boolean, BigNumber]>(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Returns number of confirmations of a transaction. - */ - public getConfirmationCount = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param transactionId Transaction ID. - * @returns Number of confirmations. - */ - async callAsync( - transactionId: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isBigNumber('transactionId', transactionId); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as AssetProxyOwnerContract; - const encodedData = self._strictEncodeArguments('getConfirmationCount(uint256)', [transactionId]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('getConfirmationCount(uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Returns array with owner addresses, which confirmed transaction. - */ - public getConfirmations = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param transactionId Transaction ID. - * @returns Returns array of owner addresses. - */ - async callAsync( - transactionId: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isBigNumber('transactionId', transactionId); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as AssetProxyOwnerContract; - const encodedData = self._strictEncodeArguments('getConfirmations(uint256)', [transactionId]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('getConfirmations(uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Returns list of owners. - */ - public getOwners = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @returns List of owner addresses. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as AssetProxyOwnerContract; - const encodedData = self._strictEncodeArguments('getOwners()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('getOwners()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Returns total number of transactions after filers are applied. - */ - public getTransactionCount = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param pending Include pending transactions. - * @param executed Include executed transactions. - * @returns Total number of transactions after filters are applied. - */ - async callAsync( - pending: boolean, - executed: boolean, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isBoolean('pending', pending); - assert.isBoolean('executed', executed); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as AssetProxyOwnerContract; - const encodedData = self._strictEncodeArguments('getTransactionCount(bool,bool)', [pending, executed]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('getTransactionCount(bool,bool)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Returns list of transaction IDs in defined range. - */ - public getTransactionIds = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param from Index start position of transaction array. - * @param to Index end position of transaction array. - * @param pending Include pending transactions. - * @param executed Include executed transactions. - * @returns Returns array of transaction IDs. - */ - async callAsync( - from: BigNumber, - to: BigNumber, - pending: boolean, - executed: boolean, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isBigNumber('from', from); - assert.isBigNumber('to', to); - assert.isBoolean('pending', pending); - assert.isBoolean('executed', executed); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as AssetProxyOwnerContract; - const encodedData = self._strictEncodeArguments('getTransactionIds(uint256,uint256,bool,bool)', [ - from, - to, - pending, - executed, - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('getTransactionIds(uint256,uint256,bool,bool)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Returns the confirmation status of a transaction. - */ - public isConfirmed = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param transactionId Transaction ID. - * @returns Confirmation status. - */ - async callAsync( - transactionId: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isBigNumber('transactionId', transactionId); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as AssetProxyOwnerContract; - const encodedData = self._strictEncodeArguments('isConfirmed(uint256)', [transactionId]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('isConfirmed(uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public isOwner = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync( - index_0: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('index_0', index_0); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as AssetProxyOwnerContract; - const encodedData = self._strictEncodeArguments('isOwner(address)', [index_0.toLowerCase()]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('isOwner(address)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public owners = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync( - index_0: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isBigNumber('index_0', index_0); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as AssetProxyOwnerContract; - const encodedData = self._strictEncodeArguments('owners(uint256)', [index_0]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('owners(uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Registers a custom timelock to a specific function selector / destination combo - */ - public registerFunctionCall = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param hasCustomTimeLock True if timelock is custom. - * @param functionSelector 4 byte selector of registered function. - * @param destination Address of destination where function will be called. - * @param newSecondsTimeLocked Duration in seconds needed after a transaction - * is confirmed to become executable. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - hasCustomTimeLock: boolean, - functionSelector: string, - destination: string, - newSecondsTimeLocked: BigNumber, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isBoolean('hasCustomTimeLock', hasCustomTimeLock); - assert.isString('functionSelector', functionSelector); - assert.isString('destination', destination); - assert.isBigNumber('newSecondsTimeLocked', newSecondsTimeLocked); - const self = (this as any) as AssetProxyOwnerContract; - const encodedData = self._strictEncodeArguments('registerFunctionCall(bool,bytes4,address,uint128)', [ - hasCustomTimeLock, - functionSelector, - destination.toLowerCase(), - newSecondsTimeLocked, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.registerFunctionCall.callAsync( - hasCustomTimeLock, - functionSelector, - destination, - newSecondsTimeLocked, - txDataWithDefaults, - ); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param hasCustomTimeLock True if timelock is custom. - * @param functionSelector 4 byte selector of registered function. - * @param destination Address of destination where function will be called. - * @param newSecondsTimeLocked Duration in seconds needed after a transaction - * is confirmed to become executable. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - hasCustomTimeLock: boolean, - functionSelector: string, - destination: string, - newSecondsTimeLocked: BigNumber, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isBoolean('hasCustomTimeLock', hasCustomTimeLock); - assert.isString('functionSelector', functionSelector); - assert.isString('destination', destination); - assert.isBigNumber('newSecondsTimeLocked', newSecondsTimeLocked); - const self = (this as any) as AssetProxyOwnerContract; - const txHashPromise = self.registerFunctionCall.sendTransactionAsync( - hasCustomTimeLock, - functionSelector, - destination.toLowerCase(), - newSecondsTimeLocked, - txData, - opts, - ); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param hasCustomTimeLock True if timelock is custom. - * @param functionSelector 4 byte selector of registered function. - * @param destination Address of destination where function will be called. - * @param newSecondsTimeLocked Duration in seconds needed after a transaction - * is confirmed to become executable. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - hasCustomTimeLock: boolean, - functionSelector: string, - destination: string, - newSecondsTimeLocked: BigNumber, - txData?: Partial | undefined, - ): Promise { - assert.isBoolean('hasCustomTimeLock', hasCustomTimeLock); - assert.isString('functionSelector', functionSelector); - assert.isString('destination', destination); - assert.isBigNumber('newSecondsTimeLocked', newSecondsTimeLocked); - const self = (this as any) as AssetProxyOwnerContract; - const encodedData = self._strictEncodeArguments('registerFunctionCall(bool,bytes4,address,uint128)', [ - hasCustomTimeLock, - functionSelector, - destination.toLowerCase(), - newSecondsTimeLocked, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param hasCustomTimeLock True if timelock is custom. - * @param functionSelector 4 byte selector of registered function. - * @param destination Address of destination where function will be called. - * @param newSecondsTimeLocked Duration in seconds needed after a transaction - * is confirmed to become executable. - */ - async callAsync( - hasCustomTimeLock: boolean, - functionSelector: string, - destination: string, - newSecondsTimeLocked: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isBoolean('hasCustomTimeLock', hasCustomTimeLock); - assert.isString('functionSelector', functionSelector); - assert.isString('destination', destination); - assert.isBigNumber('newSecondsTimeLocked', newSecondsTimeLocked); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as AssetProxyOwnerContract; - const encodedData = self._strictEncodeArguments('registerFunctionCall(bool,bytes4,address,uint128)', [ - hasCustomTimeLock, - functionSelector, - destination.toLowerCase(), - newSecondsTimeLocked, - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('registerFunctionCall(bool,bytes4,address,uint128)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param hasCustomTimeLock True if timelock is custom. - * @param functionSelector 4 byte selector of registered function. - * @param destination Address of destination where function will be called. - * @param newSecondsTimeLocked Duration in seconds needed after a transaction - * is confirmed to become executable. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData( - hasCustomTimeLock: boolean, - functionSelector: string, - destination: string, - newSecondsTimeLocked: BigNumber, - ): string { - assert.isBoolean('hasCustomTimeLock', hasCustomTimeLock); - assert.isString('functionSelector', functionSelector); - assert.isString('destination', destination); - assert.isBigNumber('newSecondsTimeLocked', newSecondsTimeLocked); - const self = (this as any) as AssetProxyOwnerContract; - const abiEncodedTransactionData = self._strictEncodeArguments( - 'registerFunctionCall(bool,bytes4,address,uint128)', - [hasCustomTimeLock, functionSelector, destination.toLowerCase(), newSecondsTimeLocked], - ); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as AssetProxyOwnerContract; - const abiEncoder = self._lookupAbiEncoder('registerFunctionCall(bool,bytes4,address,uint128)'); - return abiEncoder.getSelector(); - }, - }; - /** - * Allows to remove an owner. Transaction has to be sent by wallet. - */ - public removeOwner = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param owner Address of owner. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - owner: string, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('owner', owner); - const self = (this as any) as AssetProxyOwnerContract; - const encodedData = self._strictEncodeArguments('removeOwner(address)', [owner.toLowerCase()]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.removeOwner.callAsync(owner, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param owner Address of owner. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - owner: string, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('owner', owner); - const self = (this as any) as AssetProxyOwnerContract; - const txHashPromise = self.removeOwner.sendTransactionAsync(owner.toLowerCase(), txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param owner Address of owner. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync(owner: string, txData?: Partial | undefined): Promise { - assert.isString('owner', owner); - const self = (this as any) as AssetProxyOwnerContract; - const encodedData = self._strictEncodeArguments('removeOwner(address)', [owner.toLowerCase()]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param owner Address of owner. - */ - async callAsync(owner: string, callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.isString('owner', owner); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as AssetProxyOwnerContract; - const encodedData = self._strictEncodeArguments('removeOwner(address)', [owner.toLowerCase()]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('removeOwner(address)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param owner Address of owner. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(owner: string): string { - assert.isString('owner', owner); - const self = (this as any) as AssetProxyOwnerContract; - const abiEncodedTransactionData = self._strictEncodeArguments('removeOwner(address)', [ - owner.toLowerCase(), - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as AssetProxyOwnerContract; - const abiEncoder = self._lookupAbiEncoder('removeOwner(address)'); - return abiEncoder.getSelector(); - }, - }; - /** - * Allows to replace an owner with a new owner. Transaction has to be sent by wallet. - */ - public replaceOwner = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param owner Address of owner to be replaced. - * @param newOwner Address of new owner. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - owner: string, - newOwner: string, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('owner', owner); - assert.isString('newOwner', newOwner); - const self = (this as any) as AssetProxyOwnerContract; - const encodedData = self._strictEncodeArguments('replaceOwner(address,address)', [ - owner.toLowerCase(), - newOwner.toLowerCase(), - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.replaceOwner.callAsync(owner, newOwner, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param owner Address of owner to be replaced. - * @param newOwner Address of new owner. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - owner: string, - newOwner: string, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('owner', owner); - assert.isString('newOwner', newOwner); - const self = (this as any) as AssetProxyOwnerContract; - const txHashPromise = self.replaceOwner.sendTransactionAsync( - owner.toLowerCase(), - newOwner.toLowerCase(), - txData, - opts, - ); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param owner Address of owner to be replaced. - * @param newOwner Address of new owner. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync(owner: string, newOwner: string, txData?: Partial | undefined): Promise { - assert.isString('owner', owner); - assert.isString('newOwner', newOwner); - const self = (this as any) as AssetProxyOwnerContract; - const encodedData = self._strictEncodeArguments('replaceOwner(address,address)', [ - owner.toLowerCase(), - newOwner.toLowerCase(), - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param owner Address of owner to be replaced. - * @param newOwner Address of new owner. - */ - async callAsync( - owner: string, - newOwner: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('owner', owner); - assert.isString('newOwner', newOwner); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as AssetProxyOwnerContract; - const encodedData = self._strictEncodeArguments('replaceOwner(address,address)', [ - owner.toLowerCase(), - newOwner.toLowerCase(), - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('replaceOwner(address,address)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param owner Address of owner to be replaced. - * @param newOwner Address of new owner. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(owner: string, newOwner: string): string { - assert.isString('owner', owner); - assert.isString('newOwner', newOwner); - const self = (this as any) as AssetProxyOwnerContract; - const abiEncodedTransactionData = self._strictEncodeArguments('replaceOwner(address,address)', [ - owner.toLowerCase(), - newOwner.toLowerCase(), - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as AssetProxyOwnerContract; - const abiEncoder = self._lookupAbiEncoder('replaceOwner(address,address)'); - return abiEncoder.getSelector(); - }, - }; - public required = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as AssetProxyOwnerContract; - const encodedData = self._strictEncodeArguments('required()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('required()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Allows an owner to revoke a confirmation for a transaction. - */ - public revokeConfirmation = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param transactionId Transaction ID. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - transactionId: BigNumber, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isBigNumber('transactionId', transactionId); - const self = (this as any) as AssetProxyOwnerContract; - const encodedData = self._strictEncodeArguments('revokeConfirmation(uint256)', [transactionId]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.revokeConfirmation.callAsync(transactionId, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param transactionId Transaction ID. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - transactionId: BigNumber, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isBigNumber('transactionId', transactionId); - const self = (this as any) as AssetProxyOwnerContract; - const txHashPromise = self.revokeConfirmation.sendTransactionAsync(transactionId, txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param transactionId Transaction ID. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync(transactionId: BigNumber, txData?: Partial | undefined): Promise { - assert.isBigNumber('transactionId', transactionId); - const self = (this as any) as AssetProxyOwnerContract; - const encodedData = self._strictEncodeArguments('revokeConfirmation(uint256)', [transactionId]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param transactionId Transaction ID. - */ - async callAsync( - transactionId: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isBigNumber('transactionId', transactionId); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as AssetProxyOwnerContract; - const encodedData = self._strictEncodeArguments('revokeConfirmation(uint256)', [transactionId]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('revokeConfirmation(uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param transactionId Transaction ID. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(transactionId: BigNumber): string { - assert.isBigNumber('transactionId', transactionId); - const self = (this as any) as AssetProxyOwnerContract; - const abiEncodedTransactionData = self._strictEncodeArguments('revokeConfirmation(uint256)', [ - transactionId, - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as AssetProxyOwnerContract; - const abiEncoder = self._lookupAbiEncoder('revokeConfirmation(uint256)'); - return abiEncoder.getSelector(); - }, - }; - public secondsTimeLocked = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as AssetProxyOwnerContract; - const encodedData = self._strictEncodeArguments('secondsTimeLocked()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('secondsTimeLocked()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Allows an owner to submit and confirm a transaction. - */ - public submitTransaction = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param destination Transaction target address. - * @param value Transaction ether value. - * @param data Transaction data payload. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - destination: string, - value: BigNumber, - data: string, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('destination', destination); - assert.isBigNumber('value', value); - assert.isString('data', data); - const self = (this as any) as AssetProxyOwnerContract; - const encodedData = self._strictEncodeArguments('submitTransaction(address,uint256,bytes)', [ - destination.toLowerCase(), - value, - data, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.submitTransaction.callAsync(destination, value, data, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param destination Transaction target address. - * @param value Transaction ether value. - * @param data Transaction data payload. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - destination: string, - value: BigNumber, - data: string, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('destination', destination); - assert.isBigNumber('value', value); - assert.isString('data', data); - const self = (this as any) as AssetProxyOwnerContract; - const txHashPromise = self.submitTransaction.sendTransactionAsync( - destination.toLowerCase(), - value, - data, - txData, - opts, - ); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param destination Transaction target address. - * @param value Transaction ether value. - * @param data Transaction data payload. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - destination: string, - value: BigNumber, - data: string, - txData?: Partial | undefined, - ): Promise { - assert.isString('destination', destination); - assert.isBigNumber('value', value); - assert.isString('data', data); - const self = (this as any) as AssetProxyOwnerContract; - const encodedData = self._strictEncodeArguments('submitTransaction(address,uint256,bytes)', [ - destination.toLowerCase(), - value, - data, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param destination Transaction target address. - * @param value Transaction ether value. - * @param data Transaction data payload. - * @returns Returns transaction ID. - */ - async callAsync( - destination: string, - value: BigNumber, - data: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('destination', destination); - assert.isBigNumber('value', value); - assert.isString('data', data); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as AssetProxyOwnerContract; - const encodedData = self._strictEncodeArguments('submitTransaction(address,uint256,bytes)', [ - destination.toLowerCase(), - value, - data, - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('submitTransaction(address,uint256,bytes)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param destination Transaction target address. - * @param value Transaction ether value. - * @param data Transaction data payload. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(destination: string, value: BigNumber, data: string): string { - assert.isString('destination', destination); - assert.isBigNumber('value', value); - assert.isString('data', data); - const self = (this as any) as AssetProxyOwnerContract; - const abiEncodedTransactionData = self._strictEncodeArguments('submitTransaction(address,uint256,bytes)', [ - destination.toLowerCase(), - value, - data, - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as AssetProxyOwnerContract; - const abiEncoder = self._lookupAbiEncoder('submitTransaction(address,uint256,bytes)'); - return abiEncoder.getSelector(); - }, - }; - public transactionCount = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as AssetProxyOwnerContract; - const encodedData = self._strictEncodeArguments('transactionCount()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('transactionCount()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public transactions = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync( - index_0: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise<[string, BigNumber, string, boolean]> { - assert.isBigNumber('index_0', index_0); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as AssetProxyOwnerContract; - const encodedData = self._strictEncodeArguments('transactions(uint256)', [index_0]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('transactions(uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue<[string, BigNumber, string, boolean]>(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; + private _methodABIIndex: { [name: string]: number } = {}; private readonly _subscriptionManager: SubscriptionManager; public static async deployFrom0xArtifactAsync( artifact: ContractArtifact | SimpleContractArtifact, @@ -3549,62 +974,2115 @@ export class AssetProxyOwnerContract extends BaseContract { ] as ContractAbi; return abi; } - /** - * Subscribe to an event type emitted by the AssetProxyOwner contract. - * @param eventName The AssetProxyOwner contract event you would like to subscribe to. - * @param indexFilterValues An object where the keys are indexed args returned by the event and - * the value is the value you are interested in. E.g `{maker: aUserAddressHex}` - * @param callback Callback that gets called when a log is added/removed - * @param isVerbose Enable verbose subscription warnings (e.g recoverable network issues encountered) - * @return Subscription token used later to unsubscribe - */ - public subscribe( - eventName: AssetProxyOwnerEvents, - indexFilterValues: IndexedFilterValues, - callback: EventCallback, - isVerbose: boolean = false, - blockPollingIntervalMs?: number, - ): string { - assert.doesBelongToStringEnum('eventName', eventName, AssetProxyOwnerEvents); - assert.doesConformToSchema('indexFilterValues', indexFilterValues, schemas.indexFilterValuesSchema); - assert.isFunction('callback', callback); - const subscriptionToken = this._subscriptionManager.subscribe( - this.address, - eventName, - indexFilterValues, - AssetProxyOwnerContract.ABI(), - callback, - isVerbose, - blockPollingIntervalMs, - ); - return subscriptionToken; + + public getFunctionSignature(methodName: string): string { + const index = this._methodABIIndex[methodName]; + const methodAbi = AssetProxyOwnerContract.ABI()[index] as MethodAbi; + const functionSignature = methodAbiToFunctionSignature(methodAbi); + return functionSignature; } - /** - * Cancel a subscription - * @param subscriptionToken Subscription token returned by `subscribe()` - */ - public unsubscribe(subscriptionToken: string): void { - this._subscriptionManager.unsubscribe(subscriptionToken); + public getABIDecodedTransactionData(methodName: string, callData: string): T { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as AssetProxyOwnerContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + const abiDecodedCallData = abiEncoder.strictDecode(callData); + return abiDecodedCallData; + } + public getABIDecodedReturnData(methodName: string, callData: string): T { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as AssetProxyOwnerContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + const abiDecodedCallData = abiEncoder.strictDecodeReturnValue(callData); + return abiDecodedCallData; + } + public getSelector(methodName: string): string { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as AssetProxyOwnerContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + return abiEncoder.getSelector(); + } + + public MAX_OWNER_COUNT(): ContractFunctionObj { + const self = (this as any) as AssetProxyOwnerContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('MAX_OWNER_COUNT()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('MAX_OWNER_COUNT()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('MAX_OWNER_COUNT()', []); + return abiEncodedTransactionData; + }, + }; } /** - * Cancels all existing subscriptions + * Allows to add a new owner. Transaction has to be sent by wallet. + * @param owner Address of new owner. */ - public unsubscribeAll(): void { - this._subscriptionManager.unsubscribeAll(); + public addOwner(owner: string): ContractTxFunctionObj { + const self = (this as any) as AssetProxyOwnerContract; + assert.isString('owner', owner); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('addOwner(address)', [owner.toLowerCase()]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('addOwner(address)', [owner.toLowerCase()]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('addOwner(address)', [owner.toLowerCase()]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('addOwner(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('addOwner(address)', [ + owner.toLowerCase(), + ]); + return abiEncodedTransactionData; + }, + }; } /** - * Gets historical logs without creating a subscription - * @param eventName The AssetProxyOwner contract event you would like to subscribe to. - * @param blockRange Block range to get logs from. - * @param indexFilterValues An object where the keys are indexed args returned by the event and - * the value is the value you are interested in. E.g `{_from: aUserAddressHex}` - * @return Array of logs that match the parameters + * Allows to change the number of required confirmations. Transaction has to be sent by wallet. + * @param _required Number of required confirmations. */ - public async getLogsAsync( - eventName: AssetProxyOwnerEvents, - blockRange: BlockRange, - indexFilterValues: IndexedFilterValues, - ): Promise>> { + public changeRequirement(_required: BigNumber): ContractTxFunctionObj { + const self = (this as any) as AssetProxyOwnerContract; + assert.isBigNumber('_required', _required); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('changeRequirement(uint256)', [_required]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('changeRequirement(uint256)', [_required]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('changeRequirement(uint256)', [_required]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('changeRequirement(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('changeRequirement(uint256)', [ + _required, + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Changes the duration of the time lock for transactions. + * @param _secondsTimeLocked Duration needed after a transaction is confirmed + * and before it becomes executable, in seconds. + */ + public changeTimeLock(_secondsTimeLocked: BigNumber): ContractTxFunctionObj { + const self = (this as any) as AssetProxyOwnerContract; + assert.isBigNumber('_secondsTimeLocked', _secondsTimeLocked); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('changeTimeLock(uint256)', [_secondsTimeLocked]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('changeTimeLock(uint256)', [_secondsTimeLocked]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('changeTimeLock(uint256)', [_secondsTimeLocked]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('changeTimeLock(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('changeTimeLock(uint256)', [ + _secondsTimeLocked, + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Allows an owner to confirm a transaction. + * @param transactionId Transaction ID. + */ + public confirmTransaction(transactionId: BigNumber): ContractTxFunctionObj { + const self = (this as any) as AssetProxyOwnerContract; + assert.isBigNumber('transactionId', transactionId); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('confirmTransaction(uint256)', [transactionId]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('confirmTransaction(uint256)', [transactionId]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('confirmTransaction(uint256)', [transactionId]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('confirmTransaction(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('confirmTransaction(uint256)', [ + transactionId, + ]); + return abiEncodedTransactionData; + }, + }; + } + public confirmationTimes(index_0: BigNumber): ContractFunctionObj { + const self = (this as any) as AssetProxyOwnerContract; + assert.isBigNumber('index_0', index_0); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('confirmationTimes(uint256)', [index_0]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('confirmationTimes(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('confirmationTimes(uint256)', [index_0]); + return abiEncodedTransactionData; + }, + }; + } + public confirmations(index_0: BigNumber, index_1: string): ContractFunctionObj { + const self = (this as any) as AssetProxyOwnerContract; + assert.isBigNumber('index_0', index_0); + assert.isString('index_1', index_1); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('confirmations(uint256,address)', [ + index_0, + index_1.toLowerCase(), + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('confirmations(uint256,address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('confirmations(uint256,address)', [ + index_0, + index_1.toLowerCase(), + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Allows anyone to execute a confirmed transaction. + * Transactions *must* encode the values with the signature "bytes[] data, address[] destinations, uint256[] values" + * The `destination` and `value` fields of the transaction in storage are ignored. + * All function calls must be successful or the entire call will revert. + * @param transactionId Transaction ID. + */ + public executeTransaction(transactionId: BigNumber): ContractTxFunctionObj { + const self = (this as any) as AssetProxyOwnerContract; + assert.isBigNumber('transactionId', transactionId); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('executeTransaction(uint256)', [transactionId]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('executeTransaction(uint256)', [transactionId]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('executeTransaction(uint256)', [transactionId]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('executeTransaction(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('executeTransaction(uint256)', [ + transactionId, + ]); + return abiEncodedTransactionData; + }, + }; + } + public functionCallTimeLocks(index_0: string, index_1: string): ContractFunctionObj<[boolean, BigNumber]> { + const self = (this as any) as AssetProxyOwnerContract; + assert.isString('index_0', index_0); + assert.isString('index_1', index_1); + + return { + async callAsync( + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise<[boolean, BigNumber]> { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('functionCallTimeLocks(bytes4,address)', [ + index_0, + index_1.toLowerCase(), + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('functionCallTimeLocks(bytes4,address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<[boolean, BigNumber]>(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('functionCallTimeLocks(bytes4,address)', [ + index_0, + index_1.toLowerCase(), + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Returns number of confirmations of a transaction. + * @param transactionId Transaction ID. + * @returns Number of confirmations. + */ + public getConfirmationCount(transactionId: BigNumber): ContractFunctionObj { + const self = (this as any) as AssetProxyOwnerContract; + assert.isBigNumber('transactionId', transactionId); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('getConfirmationCount(uint256)', [transactionId]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('getConfirmationCount(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('getConfirmationCount(uint256)', [ + transactionId, + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Returns array with owner addresses, which confirmed transaction. + * @param transactionId Transaction ID. + * @returns Returns array of owner addresses. + */ + public getConfirmations(transactionId: BigNumber): ContractFunctionObj { + const self = (this as any) as AssetProxyOwnerContract; + assert.isBigNumber('transactionId', transactionId); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('getConfirmations(uint256)', [transactionId]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('getConfirmations(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('getConfirmations(uint256)', [ + transactionId, + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Returns list of owners. + * @returns List of owner addresses. + */ + public getOwners(): ContractFunctionObj { + const self = (this as any) as AssetProxyOwnerContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('getOwners()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('getOwners()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('getOwners()', []); + return abiEncodedTransactionData; + }, + }; + } + /** + * Returns total number of transactions after filers are applied. + * @param pending Include pending transactions. + * @param executed Include executed transactions. + * @returns Total number of transactions after filters are applied. + */ + public getTransactionCount(pending: boolean, executed: boolean): ContractFunctionObj { + const self = (this as any) as AssetProxyOwnerContract; + assert.isBoolean('pending', pending); + assert.isBoolean('executed', executed); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('getTransactionCount(bool,bool)', [pending, executed]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('getTransactionCount(bool,bool)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('getTransactionCount(bool,bool)', [ + pending, + executed, + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Returns list of transaction IDs in defined range. + * @param from Index start position of transaction array. + * @param to Index end position of transaction array. + * @param pending Include pending transactions. + * @param executed Include executed transactions. + * @returns Returns array of transaction IDs. + */ + public getTransactionIds( + from: BigNumber, + to: BigNumber, + pending: boolean, + executed: boolean, + ): ContractFunctionObj { + const self = (this as any) as AssetProxyOwnerContract; + assert.isBigNumber('from', from); + assert.isBigNumber('to', to); + assert.isBoolean('pending', pending); + assert.isBoolean('executed', executed); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('getTransactionIds(uint256,uint256,bool,bool)', [ + from, + to, + pending, + executed, + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('getTransactionIds(uint256,uint256,bool,bool)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'getTransactionIds(uint256,uint256,bool,bool)', + [from, to, pending, executed], + ); + return abiEncodedTransactionData; + }, + }; + } + /** + * Returns the confirmation status of a transaction. + * @param transactionId Transaction ID. + * @returns Confirmation status. + */ + public isConfirmed(transactionId: BigNumber): ContractFunctionObj { + const self = (this as any) as AssetProxyOwnerContract; + assert.isBigNumber('transactionId', transactionId); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('isConfirmed(uint256)', [transactionId]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('isConfirmed(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('isConfirmed(uint256)', [transactionId]); + return abiEncodedTransactionData; + }, + }; + } + public isOwner(index_0: string): ContractFunctionObj { + const self = (this as any) as AssetProxyOwnerContract; + assert.isString('index_0', index_0); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('isOwner(address)', [index_0.toLowerCase()]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('isOwner(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('isOwner(address)', [ + index_0.toLowerCase(), + ]); + return abiEncodedTransactionData; + }, + }; + } + public owners(index_0: BigNumber): ContractFunctionObj { + const self = (this as any) as AssetProxyOwnerContract; + assert.isBigNumber('index_0', index_0); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('owners(uint256)', [index_0]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('owners(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('owners(uint256)', [index_0]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Registers a custom timelock to a specific function selector / destination combo + * @param hasCustomTimeLock True if timelock is custom. + * @param functionSelector 4 byte selector of registered function. + * @param destination Address of destination where function will be called. + * @param newSecondsTimeLocked Duration in seconds needed after a transaction + * is confirmed to become executable. + */ + public registerFunctionCall( + hasCustomTimeLock: boolean, + functionSelector: string, + destination: string, + newSecondsTimeLocked: BigNumber, + ): ContractTxFunctionObj { + const self = (this as any) as AssetProxyOwnerContract; + assert.isBoolean('hasCustomTimeLock', hasCustomTimeLock); + assert.isString('functionSelector', functionSelector); + assert.isString('destination', destination); + assert.isBigNumber('newSecondsTimeLocked', newSecondsTimeLocked); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('registerFunctionCall(bool,bytes4,address,uint128)', [ + hasCustomTimeLock, + functionSelector, + destination.toLowerCase(), + newSecondsTimeLocked, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('registerFunctionCall(bool,bytes4,address,uint128)', [ + hasCustomTimeLock, + functionSelector, + destination.toLowerCase(), + newSecondsTimeLocked, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('registerFunctionCall(bool,bytes4,address,uint128)', [ + hasCustomTimeLock, + functionSelector, + destination.toLowerCase(), + newSecondsTimeLocked, + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('registerFunctionCall(bool,bytes4,address,uint128)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'registerFunctionCall(bool,bytes4,address,uint128)', + [hasCustomTimeLock, functionSelector, destination.toLowerCase(), newSecondsTimeLocked], + ); + return abiEncodedTransactionData; + }, + }; + } + /** + * Allows to remove an owner. Transaction has to be sent by wallet. + * @param owner Address of owner. + */ + public removeOwner(owner: string): ContractTxFunctionObj { + const self = (this as any) as AssetProxyOwnerContract; + assert.isString('owner', owner); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('removeOwner(address)', [owner.toLowerCase()]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('removeOwner(address)', [owner.toLowerCase()]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('removeOwner(address)', [owner.toLowerCase()]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('removeOwner(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('removeOwner(address)', [ + owner.toLowerCase(), + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Allows to replace an owner with a new owner. Transaction has to be sent by wallet. + * @param owner Address of owner to be replaced. + * @param newOwner Address of new owner. + */ + public replaceOwner(owner: string, newOwner: string): ContractTxFunctionObj { + const self = (this as any) as AssetProxyOwnerContract; + assert.isString('owner', owner); + assert.isString('newOwner', newOwner); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('replaceOwner(address,address)', [ + owner.toLowerCase(), + newOwner.toLowerCase(), + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('replaceOwner(address,address)', [ + owner.toLowerCase(), + newOwner.toLowerCase(), + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('replaceOwner(address,address)', [ + owner.toLowerCase(), + newOwner.toLowerCase(), + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('replaceOwner(address,address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('replaceOwner(address,address)', [ + owner.toLowerCase(), + newOwner.toLowerCase(), + ]); + return abiEncodedTransactionData; + }, + }; + } + public required(): ContractFunctionObj { + const self = (this as any) as AssetProxyOwnerContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('required()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('required()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('required()', []); + return abiEncodedTransactionData; + }, + }; + } + /** + * Allows an owner to revoke a confirmation for a transaction. + * @param transactionId Transaction ID. + */ + public revokeConfirmation(transactionId: BigNumber): ContractTxFunctionObj { + const self = (this as any) as AssetProxyOwnerContract; + assert.isBigNumber('transactionId', transactionId); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('revokeConfirmation(uint256)', [transactionId]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('revokeConfirmation(uint256)', [transactionId]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('revokeConfirmation(uint256)', [transactionId]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('revokeConfirmation(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('revokeConfirmation(uint256)', [ + transactionId, + ]); + return abiEncodedTransactionData; + }, + }; + } + public secondsTimeLocked(): ContractFunctionObj { + const self = (this as any) as AssetProxyOwnerContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('secondsTimeLocked()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('secondsTimeLocked()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('secondsTimeLocked()', []); + return abiEncodedTransactionData; + }, + }; + } + /** + * Allows an owner to submit and confirm a transaction. + * @param destination Transaction target address. + * @param value Transaction ether value. + * @param data Transaction data payload. + * @returns Returns transaction ID. + */ + public submitTransaction(destination: string, value: BigNumber, data: string): ContractTxFunctionObj { + const self = (this as any) as AssetProxyOwnerContract; + assert.isString('destination', destination); + assert.isBigNumber('value', value); + assert.isString('data', data); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('submitTransaction(address,uint256,bytes)', [ + destination.toLowerCase(), + value, + data, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('submitTransaction(address,uint256,bytes)', [ + destination.toLowerCase(), + value, + data, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('submitTransaction(address,uint256,bytes)', [ + destination.toLowerCase(), + value, + data, + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('submitTransaction(address,uint256,bytes)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'submitTransaction(address,uint256,bytes)', + [destination.toLowerCase(), value, data], + ); + return abiEncodedTransactionData; + }, + }; + } + public transactionCount(): ContractFunctionObj { + const self = (this as any) as AssetProxyOwnerContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('transactionCount()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('transactionCount()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('transactionCount()', []); + return abiEncodedTransactionData; + }, + }; + } + public transactions(index_0: BigNumber): ContractFunctionObj<[string, BigNumber, string, boolean]> { + const self = (this as any) as AssetProxyOwnerContract; + assert.isBigNumber('index_0', index_0); + + return { + async callAsync( + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise<[string, BigNumber, string, boolean]> { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('transactions(uint256)', [index_0]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('transactions(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<[string, BigNumber, string, boolean]>(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('transactions(uint256)', [index_0]); + return abiEncodedTransactionData; + }, + }; + } + + /** + * Subscribe to an event type emitted by the AssetProxyOwner contract. + * @param eventName The AssetProxyOwner contract event you would like to subscribe to. + * @param indexFilterValues An object where the keys are indexed args returned by the event and + * the value is the value you are interested in. E.g `{maker: aUserAddressHex}` + * @param callback Callback that gets called when a log is added/removed + * @param isVerbose Enable verbose subscription warnings (e.g recoverable network issues encountered) + * @return Subscription token used later to unsubscribe + */ + public subscribe( + eventName: AssetProxyOwnerEvents, + indexFilterValues: IndexedFilterValues, + callback: EventCallback, + isVerbose: boolean = false, + blockPollingIntervalMs?: number, + ): string { + assert.doesBelongToStringEnum('eventName', eventName, AssetProxyOwnerEvents); + assert.doesConformToSchema('indexFilterValues', indexFilterValues, schemas.indexFilterValuesSchema); + assert.isFunction('callback', callback); + const subscriptionToken = this._subscriptionManager.subscribe( + this.address, + eventName, + indexFilterValues, + AssetProxyOwnerContract.ABI(), + callback, + isVerbose, + blockPollingIntervalMs, + ); + return subscriptionToken; + } + /** + * Cancel a subscription + * @param subscriptionToken Subscription token returned by `subscribe()` + */ + public unsubscribe(subscriptionToken: string): void { + this._subscriptionManager.unsubscribe(subscriptionToken); + } + /** + * Cancels all existing subscriptions + */ + public unsubscribeAll(): void { + this._subscriptionManager.unsubscribeAll(); + } + /** + * Gets historical logs without creating a subscription + * @param eventName The AssetProxyOwner contract event you would like to subscribe to. + * @param blockRange Block range to get logs from. + * @param indexFilterValues An object where the keys are indexed args returned by the event and + * the value is the value you are interested in. E.g `{_from: aUserAddressHex}` + * @return Array of logs that match the parameters + */ + public async getLogsAsync( + eventName: AssetProxyOwnerEvents, + blockRange: BlockRange, + indexFilterValues: IndexedFilterValues, + ): Promise>> { assert.doesBelongToStringEnum('eventName', eventName, AssetProxyOwnerEvents); assert.doesConformToSchema('blockRange', blockRange, schemas.blockRangeSchema); assert.doesConformToSchema('indexFilterValues', indexFilterValues, schemas.indexFilterValuesSchema); @@ -3638,6 +3116,12 @@ export class AssetProxyOwnerContract extends BaseContract { AssetProxyOwnerContract.ABI(), this._web3Wrapper, ); + AssetProxyOwnerContract.ABI().forEach((item, index) => { + if (item.type === 'function') { + const methodAbi = item as MethodAbi; + this._methodABIIndex[methodAbi.name] = index; + } + }); } } diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/coordinator.ts b/packages/abi-gen-wrappers/src/generated-wrappers/coordinator.ts index 238bc768c9..34342cdc5a 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/coordinator.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/coordinator.ts @@ -1,7 +1,15 @@ // tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma enum-naming // tslint:disable:whitespace no-unbound-method no-trailing-whitespace // tslint:disable:no-unused-variable -import { BaseContract, PromiseWithTransactionHash } from '@0x/base-contract'; +import { + AwaitTransactionSuccessOpts, + ContractFunctionObj, + ContractTxFunctionObj, + SendTransactionOpts, + BaseContract, + PromiseWithTransactionHash, + methodAbiToFunctionSignature, +} from '@0x/base-contract'; import { schemas } from '@0x/json-schemas'; import { BlockParam, @@ -18,13 +26,7 @@ import { SupportedProvider, } from 'ethereum-types'; import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils'; -import { - AwaitTransactionSuccessOpts, - EventCallback, - IndexedFilterValues, - SendTransactionOpts, - SimpleContractArtifact, -} from '@0x/types'; +import { EventCallback, IndexedFilterValues, SimpleContractArtifact } from '@0x/types'; import { Web3Wrapper } from '@0x/web3-wrapper'; import { assert } from '@0x/assert'; import * as ethers from 'ethers'; @@ -38,703 +40,7 @@ export class CoordinatorContract extends BaseContract { * @ignore */ public static deployedBytecode: string | undefined; - /** - * Recovers the address of a signer given a hash and signature. - */ - public getSignerAddress = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param hash Any 32 byte hash. - * @param signature Proof that the hash has been signed by signer. - */ - async callAsync( - hash: string, - signature: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('hash', hash); - assert.isString('signature', signature); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as CoordinatorContract; - const encodedData = self._strictEncodeArguments('getSignerAddress(bytes32,bytes)', [hash, signature]); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('getSignerAddress(bytes32,bytes)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Calculates the EIP712 hash of a 0x transaction using the domain separator of the Exchange contract. - */ - public getTransactionHash = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param transaction 0x transaction containing salt, signerAddress, and data. - * @returns EIP712 hash of the transaction with the domain separator of this contract. - */ - async callAsync( - transaction: { salt: BigNumber; signerAddress: string; data: string }, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as CoordinatorContract; - const encodedData = self._strictEncodeArguments('getTransactionHash((uint256,address,bytes))', [ - transaction, - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('getTransactionHash((uint256,address,bytes))'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Calculated the EIP712 hash of the Coordinator approval mesasage using the domain separator of this contract. - */ - public getCoordinatorApprovalHash = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param approval Coordinator approval message containing the transaction - * hash, transaction signature, and expiration of the approval. - * @returns EIP712 hash of the Coordinator approval message with the domain separator of this contract. - */ - async callAsync( - approval: { - txOrigin: string; - transactionHash: string; - transactionSignature: string; - approvalExpirationTimeSeconds: BigNumber; - }, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as CoordinatorContract; - const encodedData = self._strictEncodeArguments( - 'getCoordinatorApprovalHash((address,bytes32,bytes,uint256))', - [approval], - ); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('getCoordinatorApprovalHash((address,bytes32,bytes,uint256))'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Executes a 0x transaction that has been signed by the feeRecipients that correspond to each order in the transaction's Exchange calldata. - */ - public executeTransaction = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param transaction 0x transaction containing salt, signerAddress, and data. - * @param txOrigin Required signer of Ethereum transaction calling this - * function. - * @param transactionSignature Proof that the transaction has been signed by - * the signer. - * @param approvalExpirationTimeSeconds Array of expiration times in seconds - * for which each corresponding approval signature expires. - * @param approvalSignatures Array of signatures that correspond to the - * feeRecipients of each order in the transaction's Exchange calldata. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - transaction: { salt: BigNumber; signerAddress: string; data: string }, - txOrigin: string, - transactionSignature: string, - approvalExpirationTimeSeconds: BigNumber[], - approvalSignatures: string[], - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('txOrigin', txOrigin); - assert.isString('transactionSignature', transactionSignature); - assert.isArray('approvalExpirationTimeSeconds', approvalExpirationTimeSeconds); - assert.isArray('approvalSignatures', approvalSignatures); - const self = (this as any) as CoordinatorContract; - const encodedData = self._strictEncodeArguments( - 'executeTransaction((uint256,address,bytes),address,bytes,uint256[],bytes[])', - [ - transaction, - txOrigin.toLowerCase(), - transactionSignature, - approvalExpirationTimeSeconds, - approvalSignatures, - ], - ); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.executeTransaction.callAsync( - transaction, - txOrigin, - transactionSignature, - approvalExpirationTimeSeconds, - approvalSignatures, - txDataWithDefaults, - ); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param transaction 0x transaction containing salt, signerAddress, and data. - * @param txOrigin Required signer of Ethereum transaction calling this - * function. - * @param transactionSignature Proof that the transaction has been signed by - * the signer. - * @param approvalExpirationTimeSeconds Array of expiration times in seconds - * for which each corresponding approval signature expires. - * @param approvalSignatures Array of signatures that correspond to the - * feeRecipients of each order in the transaction's Exchange calldata. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - transaction: { salt: BigNumber; signerAddress: string; data: string }, - txOrigin: string, - transactionSignature: string, - approvalExpirationTimeSeconds: BigNumber[], - approvalSignatures: string[], - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('txOrigin', txOrigin); - assert.isString('transactionSignature', transactionSignature); - assert.isArray('approvalExpirationTimeSeconds', approvalExpirationTimeSeconds); - assert.isArray('approvalSignatures', approvalSignatures); - const self = (this as any) as CoordinatorContract; - const txHashPromise = self.executeTransaction.sendTransactionAsync( - transaction, - txOrigin.toLowerCase(), - transactionSignature, - approvalExpirationTimeSeconds, - approvalSignatures, - txData, - opts, - ); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param transaction 0x transaction containing salt, signerAddress, and data. - * @param txOrigin Required signer of Ethereum transaction calling this - * function. - * @param transactionSignature Proof that the transaction has been signed by - * the signer. - * @param approvalExpirationTimeSeconds Array of expiration times in seconds - * for which each corresponding approval signature expires. - * @param approvalSignatures Array of signatures that correspond to the - * feeRecipients of each order in the transaction's Exchange calldata. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - transaction: { salt: BigNumber; signerAddress: string; data: string }, - txOrigin: string, - transactionSignature: string, - approvalExpirationTimeSeconds: BigNumber[], - approvalSignatures: string[], - txData?: Partial | undefined, - ): Promise { - assert.isString('txOrigin', txOrigin); - assert.isString('transactionSignature', transactionSignature); - assert.isArray('approvalExpirationTimeSeconds', approvalExpirationTimeSeconds); - assert.isArray('approvalSignatures', approvalSignatures); - const self = (this as any) as CoordinatorContract; - const encodedData = self._strictEncodeArguments( - 'executeTransaction((uint256,address,bytes),address,bytes,uint256[],bytes[])', - [ - transaction, - txOrigin.toLowerCase(), - transactionSignature, - approvalExpirationTimeSeconds, - approvalSignatures, - ], - ); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param transaction 0x transaction containing salt, signerAddress, and data. - * @param txOrigin Required signer of Ethereum transaction calling this - * function. - * @param transactionSignature Proof that the transaction has been signed by - * the signer. - * @param approvalExpirationTimeSeconds Array of expiration times in seconds - * for which each corresponding approval signature expires. - * @param approvalSignatures Array of signatures that correspond to the - * feeRecipients of each order in the transaction's Exchange calldata. - */ - async callAsync( - transaction: { salt: BigNumber; signerAddress: string; data: string }, - txOrigin: string, - transactionSignature: string, - approvalExpirationTimeSeconds: BigNumber[], - approvalSignatures: string[], - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('txOrigin', txOrigin); - assert.isString('transactionSignature', transactionSignature); - assert.isArray('approvalExpirationTimeSeconds', approvalExpirationTimeSeconds); - assert.isArray('approvalSignatures', approvalSignatures); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as CoordinatorContract; - const encodedData = self._strictEncodeArguments( - 'executeTransaction((uint256,address,bytes),address,bytes,uint256[],bytes[])', - [ - transaction, - txOrigin.toLowerCase(), - transactionSignature, - approvalExpirationTimeSeconds, - approvalSignatures, - ], - ); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder( - 'executeTransaction((uint256,address,bytes),address,bytes,uint256[],bytes[])', - ); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param transaction 0x transaction containing salt, signerAddress, and data. - * @param txOrigin Required signer of Ethereum transaction calling this - * function. - * @param transactionSignature Proof that the transaction has been signed by - * the signer. - * @param approvalExpirationTimeSeconds Array of expiration times in seconds - * for which each corresponding approval signature expires. - * @param approvalSignatures Array of signatures that correspond to the - * feeRecipients of each order in the transaction's Exchange calldata. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData( - transaction: { salt: BigNumber; signerAddress: string; data: string }, - txOrigin: string, - transactionSignature: string, - approvalExpirationTimeSeconds: BigNumber[], - approvalSignatures: string[], - ): string { - assert.isString('txOrigin', txOrigin); - assert.isString('transactionSignature', transactionSignature); - assert.isArray('approvalExpirationTimeSeconds', approvalExpirationTimeSeconds); - assert.isArray('approvalSignatures', approvalSignatures); - const self = (this as any) as CoordinatorContract; - const abiEncodedTransactionData = self._strictEncodeArguments( - 'executeTransaction((uint256,address,bytes),address,bytes,uint256[],bytes[])', - [ - transaction, - txOrigin.toLowerCase(), - transactionSignature, - approvalExpirationTimeSeconds, - approvalSignatures, - ], - ); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as CoordinatorContract; - const abiEncoder = self._lookupAbiEncoder( - 'executeTransaction((uint256,address,bytes),address,bytes,uint256[],bytes[])', - ); - return abiEncoder.getSelector(); - }, - }; - public EIP712_EXCHANGE_DOMAIN_HASH = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as CoordinatorContract; - const encodedData = self._strictEncodeArguments('EIP712_EXCHANGE_DOMAIN_HASH()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('EIP712_EXCHANGE_DOMAIN_HASH()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Validates that the 0x transaction has been approved by all of the feeRecipients - * that correspond to each order in the transaction's Exchange calldata. - */ - public assertValidCoordinatorApprovals = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param transaction 0x transaction containing salt, signerAddress, and data. - * @param txOrigin Required signer of Ethereum transaction calling this - * function. - * @param transactionSignature Proof that the transaction has been signed by - * the signer. - * @param approvalExpirationTimeSeconds Array of expiration times in seconds - * for which each corresponding approval signature expires. - * @param approvalSignatures Array of signatures that correspond to the - * feeRecipients of each order in the transaction's Exchange calldata. - */ - async callAsync( - transaction: { salt: BigNumber; signerAddress: string; data: string }, - txOrigin: string, - transactionSignature: string, - approvalExpirationTimeSeconds: BigNumber[], - approvalSignatures: string[], - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('txOrigin', txOrigin); - assert.isString('transactionSignature', transactionSignature); - assert.isArray('approvalExpirationTimeSeconds', approvalExpirationTimeSeconds); - assert.isArray('approvalSignatures', approvalSignatures); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as CoordinatorContract; - const encodedData = self._strictEncodeArguments( - 'assertValidCoordinatorApprovals((uint256,address,bytes),address,bytes,uint256[],bytes[])', - [ - transaction, - txOrigin.toLowerCase(), - transactionSignature, - approvalExpirationTimeSeconds, - approvalSignatures, - ], - ); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder( - 'assertValidCoordinatorApprovals((uint256,address,bytes),address,bytes,uint256[],bytes[])', - ); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Decodes the orders from Exchange calldata representing any fill method. - */ - public decodeOrdersFromFillData = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param data Exchange calldata representing a fill method. - * @returns The orders from the Exchange calldata. - */ - async callAsync( - data: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise< - Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - }> - > { - assert.isString('data', data); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as CoordinatorContract; - const encodedData = self._strictEncodeArguments('decodeOrdersFromFillData(bytes)', [data]); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('decodeOrdersFromFillData(bytes)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue< - Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - }> - >(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public EIP712_COORDINATOR_DOMAIN_HASH = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as CoordinatorContract; - const encodedData = self._strictEncodeArguments('EIP712_COORDINATOR_DOMAIN_HASH()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('EIP712_COORDINATOR_DOMAIN_HASH()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; + private _methodABIIndex: { [name: string]: number } = {}; public static async deployFrom0xArtifactAsync( artifact: ContractArtifact | SimpleContractArtifact, supportedProvider: SupportedProvider, @@ -1110,6 +416,655 @@ export class CoordinatorContract extends BaseContract { ] as ContractAbi; return abi; } + + public getFunctionSignature(methodName: string): string { + const index = this._methodABIIndex[methodName]; + const methodAbi = CoordinatorContract.ABI()[index] as MethodAbi; + const functionSignature = methodAbiToFunctionSignature(methodAbi); + return functionSignature; + } + public getABIDecodedTransactionData(methodName: string, callData: string): T { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as CoordinatorContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + const abiDecodedCallData = abiEncoder.strictDecode(callData); + return abiDecodedCallData; + } + public getABIDecodedReturnData(methodName: string, callData: string): T { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as CoordinatorContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + const abiDecodedCallData = abiEncoder.strictDecodeReturnValue(callData); + return abiDecodedCallData; + } + public getSelector(methodName: string): string { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as CoordinatorContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + return abiEncoder.getSelector(); + } + + /** + * Recovers the address of a signer given a hash and signature. + * @param hash Any 32 byte hash. + * @param signature Proof that the hash has been signed by signer. + */ + public getSignerAddress(hash: string, signature: string): ContractFunctionObj { + const self = (this as any) as CoordinatorContract; + assert.isString('hash', hash); + assert.isString('signature', signature); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('getSignerAddress(bytes32,bytes)', [hash, signature]); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('getSignerAddress(bytes32,bytes)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('getSignerAddress(bytes32,bytes)', [ + hash, + signature, + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Calculates the EIP712 hash of a 0x transaction using the domain separator of the Exchange contract. + * @param transaction 0x transaction containing salt, signerAddress, and data. + * @returns EIP712 hash of the transaction with the domain separator of this contract. + */ + public getTransactionHash(transaction: { + salt: BigNumber; + signerAddress: string; + data: string; + }): ContractFunctionObj { + const self = (this as any) as CoordinatorContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('getTransactionHash((uint256,address,bytes))', [ + transaction, + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('getTransactionHash((uint256,address,bytes))'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'getTransactionHash((uint256,address,bytes))', + [transaction], + ); + return abiEncodedTransactionData; + }, + }; + } + /** + * Calculated the EIP712 hash of the Coordinator approval mesasage using the domain separator of this contract. + * @param approval Coordinator approval message containing the transaction + * hash, transaction signature, and expiration of the approval. + * @returns EIP712 hash of the Coordinator approval message with the domain separator of this contract. + */ + public getCoordinatorApprovalHash(approval: { + txOrigin: string; + transactionHash: string; + transactionSignature: string; + approvalExpirationTimeSeconds: BigNumber; + }): ContractFunctionObj { + const self = (this as any) as CoordinatorContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments( + 'getCoordinatorApprovalHash((address,bytes32,bytes,uint256))', + [approval], + ); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder( + 'getCoordinatorApprovalHash((address,bytes32,bytes,uint256))', + ); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'getCoordinatorApprovalHash((address,bytes32,bytes,uint256))', + [approval], + ); + return abiEncodedTransactionData; + }, + }; + } + /** + * Executes a 0x transaction that has been signed by the feeRecipients that correspond to each order in the transaction's Exchange calldata. + * @param transaction 0x transaction containing salt, signerAddress, and data. + * @param txOrigin Required signer of Ethereum transaction calling this + * function. + * @param transactionSignature Proof that the transaction has been signed by + * the signer. + * @param approvalExpirationTimeSeconds Array of expiration times in seconds + * for which each corresponding approval signature expires. + * @param approvalSignatures Array of signatures that correspond to the + * feeRecipients of each order in the transaction's Exchange calldata. + */ + public executeTransaction( + transaction: { salt: BigNumber; signerAddress: string; data: string }, + txOrigin: string, + transactionSignature: string, + approvalExpirationTimeSeconds: BigNumber[], + approvalSignatures: string[], + ): ContractTxFunctionObj { + const self = (this as any) as CoordinatorContract; + + assert.isString('txOrigin', txOrigin); + assert.isString('transactionSignature', transactionSignature); + assert.isArray('approvalExpirationTimeSeconds', approvalExpirationTimeSeconds); + assert.isArray('approvalSignatures', approvalSignatures); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments( + 'executeTransaction((uint256,address,bytes),address,bytes,uint256[],bytes[])', + [ + transaction, + txOrigin.toLowerCase(), + transactionSignature, + approvalExpirationTimeSeconds, + approvalSignatures, + ], + ); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments( + 'executeTransaction((uint256,address,bytes),address,bytes,uint256[],bytes[])', + [ + transaction, + txOrigin.toLowerCase(), + transactionSignature, + approvalExpirationTimeSeconds, + approvalSignatures, + ], + ); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments( + 'executeTransaction((uint256,address,bytes),address,bytes,uint256[],bytes[])', + [ + transaction, + txOrigin.toLowerCase(), + transactionSignature, + approvalExpirationTimeSeconds, + approvalSignatures, + ], + ); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder( + 'executeTransaction((uint256,address,bytes),address,bytes,uint256[],bytes[])', + ); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'executeTransaction((uint256,address,bytes),address,bytes,uint256[],bytes[])', + [ + transaction, + txOrigin.toLowerCase(), + transactionSignature, + approvalExpirationTimeSeconds, + approvalSignatures, + ], + ); + return abiEncodedTransactionData; + }, + }; + } + public EIP712_EXCHANGE_DOMAIN_HASH(): ContractFunctionObj { + const self = (this as any) as CoordinatorContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('EIP712_EXCHANGE_DOMAIN_HASH()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('EIP712_EXCHANGE_DOMAIN_HASH()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('EIP712_EXCHANGE_DOMAIN_HASH()', []); + return abiEncodedTransactionData; + }, + }; + } + /** + * Validates that the 0x transaction has been approved by all of the feeRecipients + * that correspond to each order in the transaction's Exchange calldata. + * @param transaction 0x transaction containing salt, signerAddress, and data. + * @param txOrigin Required signer of Ethereum transaction calling this + * function. + * @param transactionSignature Proof that the transaction has been signed by + * the signer. + * @param approvalExpirationTimeSeconds Array of expiration times in seconds + * for which each corresponding approval signature expires. + * @param approvalSignatures Array of signatures that correspond to the + * feeRecipients of each order in the transaction's Exchange calldata. + */ + public assertValidCoordinatorApprovals( + transaction: { salt: BigNumber; signerAddress: string; data: string }, + txOrigin: string, + transactionSignature: string, + approvalExpirationTimeSeconds: BigNumber[], + approvalSignatures: string[], + ): ContractFunctionObj { + const self = (this as any) as CoordinatorContract; + + assert.isString('txOrigin', txOrigin); + assert.isString('transactionSignature', transactionSignature); + assert.isArray('approvalExpirationTimeSeconds', approvalExpirationTimeSeconds); + assert.isArray('approvalSignatures', approvalSignatures); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments( + 'assertValidCoordinatorApprovals((uint256,address,bytes),address,bytes,uint256[],bytes[])', + [ + transaction, + txOrigin.toLowerCase(), + transactionSignature, + approvalExpirationTimeSeconds, + approvalSignatures, + ], + ); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder( + 'assertValidCoordinatorApprovals((uint256,address,bytes),address,bytes,uint256[],bytes[])', + ); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'assertValidCoordinatorApprovals((uint256,address,bytes),address,bytes,uint256[],bytes[])', + [ + transaction, + txOrigin.toLowerCase(), + transactionSignature, + approvalExpirationTimeSeconds, + approvalSignatures, + ], + ); + return abiEncodedTransactionData; + }, + }; + } + /** + * Decodes the orders from Exchange calldata representing any fill method. + * @param data Exchange calldata representing a fill method. + * @returns The orders from the Exchange calldata. + */ + public decodeOrdersFromFillData( + data: string, + ): ContractFunctionObj< + Array<{ + makerAddress: string; + takerAddress: string; + feeRecipientAddress: string; + senderAddress: string; + makerAssetAmount: BigNumber; + takerAssetAmount: BigNumber; + makerFee: BigNumber; + takerFee: BigNumber; + expirationTimeSeconds: BigNumber; + salt: BigNumber; + makerAssetData: string; + takerAssetData: string; + }> + > { + const self = (this as any) as CoordinatorContract; + assert.isString('data', data); + + return { + async callAsync( + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise< + Array<{ + makerAddress: string; + takerAddress: string; + feeRecipientAddress: string; + senderAddress: string; + makerAssetAmount: BigNumber; + takerAssetAmount: BigNumber; + makerFee: BigNumber; + takerFee: BigNumber; + expirationTimeSeconds: BigNumber; + salt: BigNumber; + makerAssetData: string; + takerAssetData: string; + }> + > { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('decodeOrdersFromFillData(bytes)', [data]); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('decodeOrdersFromFillData(bytes)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue< + Array<{ + makerAddress: string; + takerAddress: string; + feeRecipientAddress: string; + senderAddress: string; + makerAssetAmount: BigNumber; + takerAssetAmount: BigNumber; + makerFee: BigNumber; + takerFee: BigNumber; + expirationTimeSeconds: BigNumber; + salt: BigNumber; + makerAssetData: string; + takerAssetData: string; + }> + >(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('decodeOrdersFromFillData(bytes)', [ + data, + ]); + return abiEncodedTransactionData; + }, + }; + } + public EIP712_COORDINATOR_DOMAIN_HASH(): ContractFunctionObj { + const self = (this as any) as CoordinatorContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('EIP712_COORDINATOR_DOMAIN_HASH()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('EIP712_COORDINATOR_DOMAIN_HASH()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('EIP712_COORDINATOR_DOMAIN_HASH()', []); + return abiEncodedTransactionData; + }, + }; + } + constructor( address: string, supportedProvider: SupportedProvider, @@ -1127,6 +1082,12 @@ export class CoordinatorContract extends BaseContract { deployedBytecode, ); classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']); + CoordinatorContract.ABI().forEach((item, index) => { + if (item.type === 'function') { + const methodAbi = item as MethodAbi; + this._methodABIIndex[methodAbi.name] = index; + } + }); } } diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts b/packages/abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts index 57abe22dc0..77fce885f6 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts @@ -1,7 +1,16 @@ // tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma enum-naming // tslint:disable:whitespace no-unbound-method no-trailing-whitespace // tslint:disable:no-unused-variable -import { BaseContract, SubscriptionManager, PromiseWithTransactionHash } from '@0x/base-contract'; +import { + AwaitTransactionSuccessOpts, + ContractFunctionObj, + ContractTxFunctionObj, + SendTransactionOpts, + BaseContract, + SubscriptionManager, + PromiseWithTransactionHash, + methodAbiToFunctionSignature, +} from '@0x/base-contract'; import { schemas } from '@0x/json-schemas'; import { BlockParam, @@ -19,13 +28,7 @@ import { SupportedProvider, } from 'ethereum-types'; import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils'; -import { - AwaitTransactionSuccessOpts, - EventCallback, - IndexedFilterValues, - SendTransactionOpts, - SimpleContractArtifact, -} from '@0x/types'; +import { EventCallback, IndexedFilterValues, SimpleContractArtifact } from '@0x/types'; import { Web3Wrapper } from '@0x/web3-wrapper'; import { assert } from '@0x/assert'; import * as ethers from 'ethers'; @@ -50,222 +53,7 @@ export class CoordinatorRegistryContract extends BaseContract { * @ignore */ public static deployedBytecode: string | undefined; - /** - * Called by a Coordinator operator to set the endpoint of their Coordinator. - */ - public setCoordinatorEndpoint = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param coordinatorEndpoint endpoint of the Coordinator. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - coordinatorEndpoint: string, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('coordinatorEndpoint', coordinatorEndpoint); - const self = (this as any) as CoordinatorRegistryContract; - const encodedData = self._strictEncodeArguments('setCoordinatorEndpoint(string)', [coordinatorEndpoint]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.setCoordinatorEndpoint.callAsync(coordinatorEndpoint, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param coordinatorEndpoint endpoint of the Coordinator. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - coordinatorEndpoint: string, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('coordinatorEndpoint', coordinatorEndpoint); - const self = (this as any) as CoordinatorRegistryContract; - const txHashPromise = self.setCoordinatorEndpoint.sendTransactionAsync(coordinatorEndpoint, txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param coordinatorEndpoint endpoint of the Coordinator. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync(coordinatorEndpoint: string, txData?: Partial | undefined): Promise { - assert.isString('coordinatorEndpoint', coordinatorEndpoint); - const self = (this as any) as CoordinatorRegistryContract; - const encodedData = self._strictEncodeArguments('setCoordinatorEndpoint(string)', [coordinatorEndpoint]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param coordinatorEndpoint endpoint of the Coordinator. - */ - async callAsync( - coordinatorEndpoint: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('coordinatorEndpoint', coordinatorEndpoint); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as CoordinatorRegistryContract; - const encodedData = self._strictEncodeArguments('setCoordinatorEndpoint(string)', [coordinatorEndpoint]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('setCoordinatorEndpoint(string)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param coordinatorEndpoint endpoint of the Coordinator. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(coordinatorEndpoint: string): string { - assert.isString('coordinatorEndpoint', coordinatorEndpoint); - const self = (this as any) as CoordinatorRegistryContract; - const abiEncodedTransactionData = self._strictEncodeArguments('setCoordinatorEndpoint(string)', [ - coordinatorEndpoint, - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as CoordinatorRegistryContract; - const abiEncoder = self._lookupAbiEncoder('setCoordinatorEndpoint(string)'); - return abiEncoder.getSelector(); - }, - }; - /** - * Gets the endpoint for a Coordinator. - */ - public getCoordinatorEndpoint = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param coordinatorOperator operator of the Coordinator endpoint. - */ - async callAsync( - coordinatorOperator: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('coordinatorOperator', coordinatorOperator); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as CoordinatorRegistryContract; - const encodedData = self._strictEncodeArguments('getCoordinatorEndpoint(address)', [ - coordinatorOperator.toLowerCase(), - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('getCoordinatorEndpoint(address)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; + private _methodABIIndex: { [name: string]: number } = {}; private readonly _subscriptionManager: SubscriptionManager; public static async deployFrom0xArtifactAsync( artifact: ContractArtifact | SimpleContractArtifact, @@ -403,6 +191,209 @@ export class CoordinatorRegistryContract extends BaseContract { ] as ContractAbi; return abi; } + + public getFunctionSignature(methodName: string): string { + const index = this._methodABIIndex[methodName]; + const methodAbi = CoordinatorRegistryContract.ABI()[index] as MethodAbi; + const functionSignature = methodAbiToFunctionSignature(methodAbi); + return functionSignature; + } + public getABIDecodedTransactionData(methodName: string, callData: string): T { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as CoordinatorRegistryContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + const abiDecodedCallData = abiEncoder.strictDecode(callData); + return abiDecodedCallData; + } + public getABIDecodedReturnData(methodName: string, callData: string): T { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as CoordinatorRegistryContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + const abiDecodedCallData = abiEncoder.strictDecodeReturnValue(callData); + return abiDecodedCallData; + } + public getSelector(methodName: string): string { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as CoordinatorRegistryContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + return abiEncoder.getSelector(); + } + + /** + * Called by a Coordinator operator to set the endpoint of their Coordinator. + * @param coordinatorEndpoint endpoint of the Coordinator. + */ + public setCoordinatorEndpoint(coordinatorEndpoint: string): ContractTxFunctionObj { + const self = (this as any) as CoordinatorRegistryContract; + assert.isString('coordinatorEndpoint', coordinatorEndpoint); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('setCoordinatorEndpoint(string)', [ + coordinatorEndpoint, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('setCoordinatorEndpoint(string)', [ + coordinatorEndpoint, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('setCoordinatorEndpoint(string)', [ + coordinatorEndpoint, + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('setCoordinatorEndpoint(string)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('setCoordinatorEndpoint(string)', [ + coordinatorEndpoint, + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Gets the endpoint for a Coordinator. + * @param coordinatorOperator operator of the Coordinator endpoint. + */ + public getCoordinatorEndpoint(coordinatorOperator: string): ContractFunctionObj { + const self = (this as any) as CoordinatorRegistryContract; + assert.isString('coordinatorOperator', coordinatorOperator); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('getCoordinatorEndpoint(address)', [ + coordinatorOperator.toLowerCase(), + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('getCoordinatorEndpoint(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('getCoordinatorEndpoint(address)', [ + coordinatorOperator.toLowerCase(), + ]); + return abiEncodedTransactionData; + }, + }; + } + /** * Subscribe to an event type emitted by the CoordinatorRegistry contract. * @param eventName The CoordinatorRegistry contract event you would like to subscribe to. @@ -492,6 +483,12 @@ export class CoordinatorRegistryContract extends BaseContract { CoordinatorRegistryContract.ABI(), this._web3Wrapper, ); + CoordinatorRegistryContract.ABI().forEach((item, index) => { + if (item.type === 'function') { + const methodAbi = item as MethodAbi; + this._methodABIIndex[methodAbi.name] = index; + } + }); } } diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts b/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts index 70bd9bed76..fcf60dbf0c 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts @@ -1,7 +1,15 @@ // tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma enum-naming // tslint:disable:whitespace no-unbound-method no-trailing-whitespace // tslint:disable:no-unused-variable -import { BaseContract, PromiseWithTransactionHash } from '@0x/base-contract'; +import { + AwaitTransactionSuccessOpts, + ContractFunctionObj, + ContractTxFunctionObj, + SendTransactionOpts, + BaseContract, + PromiseWithTransactionHash, + methodAbiToFunctionSignature, +} from '@0x/base-contract'; import { schemas } from '@0x/json-schemas'; import { BlockParam, @@ -18,13 +26,7 @@ import { SupportedProvider, } from 'ethereum-types'; import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils'; -import { - AwaitTransactionSuccessOpts, - EventCallback, - IndexedFilterValues, - SendTransactionOpts, - SimpleContractArtifact, -} from '@0x/types'; +import { EventCallback, IndexedFilterValues, SimpleContractArtifact } from '@0x/types'; import { Web3Wrapper } from '@0x/web3-wrapper'; import { assert } from '@0x/assert'; import * as ethers from 'ethers'; @@ -39,2497 +41,86 @@ export class DevUtilsContract extends BaseContract { */ public static deployedBytecode = '0x608060405234801561001057600080fd5b506004361061025c5760003560e01c80639a7e752611610145578063cafd3a07116100bd578063d3d862d11161008c578063e4e6e7da11610071578063e4e6e7da1461063a578063e77286eb1461065b578063ee4f5a941461067d5761025c565b8063d3d862d114610605578063e25cabf7146106185761025c565b8063cafd3a071461059e578063d001c5dc146105bf578063d186037f146105d2578063d3637905146105e55761025c565b8063a6627e9f11610114578063b43cffe1116100f9578063b43cffe114610548578063bbb2dcf61461055b578063bc03f9641461057d5761025c565b8063a6627e9f14610512578063acaedc74146105255761025c565b80639a7e7526146104985780639eadc835146104bb578063a0901e51146104df578063a5cd62ba146104f25761025c565b8063459be5e2116101d85780636f83188e116101a75780637b66ad341161018c5780637b66ad34146104515780637d727512146104725780638f4ce479146104855761025c565b80636f83188e1461040d5780637914b2ec146104305761025c565b8063459be5e21461038a5780634dfdac20146103ab578063590aa875146103cb57806365129042146103eb5761025c565b80632322cf761161022f578063327d305411610214578063327d30541461033257806332aae3ad146103455780633db6dc61146103675761025c565b80632322cf76146102f0578063314853ff146103105761025c565b806302d0aec31461026157806304a5618a1461028b5780630d7b7d76146102ad578063165979e1146102ce575b600080fd5b61027461026f3660046149dd565b61069f565b6040516102829291906152e4565b60405180910390f35b61029e6102993660046149dd565b6106fb565b60405161028293929190615387565b6102c06102bb366004614565565b6107a9565b604051610282929190615292565b6102e16102dc3660046149dd565b6107cb565b604051610282939291906154c2565b6103036102fe366004614565565b610828565b6040516102829190615731565b61032361031e3660046149dd565b610850565b604051610282939291906152b9565b6102c06103403660046149dd565b610897565b6103586103533660046149dd565b6108d9565b60405161028293929190615438565b61037a6103753660046149dd565b61092c565b6040516102829493929190615258565b61039d6103983660046149dd565b610976565b6040516102829291906154ab565b6103be6103b936600461448c565b6109cc565b60405161028291906151f2565b6103de6103d936600461435d565b610a4f565b60405161028291906153e7565b6103fe6103f93660046149dd565b610ad3565b60405161028293929190614fdf565b61042061041b3660046149dd565b610b0d565b6040516102829493929190615535565b61044361043e3660046149dd565b61164e565b604051610282929190615301565b61046461045f3660046149dd565b611686565b604051610282929190614fc5565b610303610480366004614565565b6116be565b6104436104933660046149dd565b611dd3565b6104ab6104a63660046149dd565b611e63565b60405161028294939291906154f1565b6104ce6104c93660046149dd565b611ec4565b604051610282959493929190615324565b6103be6104ed3660046145d4565b611f6f565b61050561050036600461463a565b611fe8565b60405161028291906150f9565b6103de6105203660046145a9565b6120ac565b6105386105333660046149dd565b612133565b6040516102829493929190615055565b6103de6105563660046144da565b61216f565b61056e6105693660046149dd565b6121fc565b604051610282939291906153b2565b61059061058b3660046149dd565b6122a9565b6040516102829291906152a0565b6105b16105ac3660046149dd565b6122e2565b604051610282929190615528565b6103be6105cd36600461448c565b612330565b6103036105e0366004614565565b61239e565b6105f86105f3366004614a94565b6129e1565b60405161028291906154dd565b6103de6106133660046147e2565b612f7e565b61062b6106263660046146be565b612fb6565b60405161028293929190615146565b61064d61064836600461448c565b6130ee565b604051610282929190615233565b61066e610669366004614aec565b613107565b604051610282939291906156d5565b61069061068b3660046149dd565b613341565b60405161028293929190615481565b6000806106b3836106ae61337e565b6133a2565b60006106cc60048551866133fc9092919063ffffffff16565b8060200190516106df9190810190614990565b909350905060ff811660068111156106f357fe5b915050915091565b6000808061070f848263ffffffff61343f16565b92506001600160e01b031983167f02571792000000000000000000000000000000000000000000000000000000001461077d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107749061569e565b60405180910390fd5b61078e84601063ffffffff61347316565b91506107a184602463ffffffff6134a616565b929491935050565b6000806107b684846116be565b91506107c2848461239e565b90509250929050565b60008060006107dc846106ae6134b2565b60006107f560048651876133fc9092919063ffffffff16565b8060200190516108089190810190614d20565b9094509250905060ff8116600281111561081e57fe5b9350509193909250565b600080600061083785856107a9565b9150915061084582826134d6565b925050505b92915050565b6000606080610861846106ae6134ec565b835161087790859060049063ffffffff6133fc16565b80602001905161088a9190810190614930565b9196909550909350915050565b6000806108a6836106ae613510565b82516108bc90849060049063ffffffff6133fc16565b8060200190516108cf91908101906148d2565b9094909350915050565b60008060606108ea846106ae613534565b600061090360048651876133fc9092919063ffffffff16565b8060200190516109169190810190614cd4565b9094509250905060ff8116600181111561081e57fe5b60008060608061093e856106ae613558565b845161095490869060049063ffffffff6133fc16565b806020019051610967919081019061488e565b92989197509550909350915050565b600080610985836106ae61357c565b600061099e60048551866133fc9092919063ffffffff16565b8060200190516109b19190810190614c07565b9250905060ff811660038111156109c457fe5b925050915091565b6060600082519050806040519080825280602002602001820160405280156109fe578160200160208202803883390190505b50915060005b818114610a4757610a2885858381518110610a1b57fe5b602002602001015161239e565b838281518110610a3457fe5b6020908102919091010152600101610a04565b505092915050565b6040516060907ff47261b00000000000000000000000000000000000000000000000000000000090610a85908490602401614fb1565b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff166001600160e01b0319909316929092179091529050919050565b6000806000610ae4846106ae6135a0565b8351610afa90859060049063ffffffff6133fc16565b80602001905161088a91908101906143b2565b60608080806000610b24868263ffffffff61343f16565b90506001600160e01b031981167fdedfc1f1000000000000000000000000000000000000000000000000000000001415610b95576040518060400160405280601181526020017f626174636843616e63656c4f72646572730000000000000000000000000000008152509450611124565b6001600160e01b031981167f9694a402000000000000000000000000000000000000000000000000000000001415610c04576040518060400160405280600f81526020017f626174636846696c6c4f726465727300000000000000000000000000000000008152509450611124565b6001600160e01b031981167f8ea8dfe4000000000000000000000000000000000000000000000000000000001415610c73576040518060400160405280601681526020017f626174636846696c6c4f72646572734e6f5468726f77000000000000000000008152509450611124565b6001600160e01b031981167fbeee2e14000000000000000000000000000000000000000000000000000000001415610ce2576040518060400160405280601581526020017f626174636846696c6c4f724b696c6c4f726465727300000000000000000000008152509450611124565b6001600160e01b031981167f2da62987000000000000000000000000000000000000000000000000000000001415610d51576040518060400160405280600b81526020017f63616e63656c4f726465720000000000000000000000000000000000000000008152509450611124565b6001600160e01b031981167f9b44d556000000000000000000000000000000000000000000000000000000001415610dc0576040518060400160405280600981526020017f66696c6c4f7264657200000000000000000000000000000000000000000000008152509450611124565b6001600160e01b031981167fe14b58c4000000000000000000000000000000000000000000000000000000001415610e2f576040518060400160405280600f81526020017f66696c6c4f724b696c6c4f7264657200000000000000000000000000000000008152509450611124565b6001600160e01b031981167f78d29ac1000000000000000000000000000000000000000000000000000000001415610e9e576040518060400160405280601681526020017f6d61726b65744275794f72646572734e6f5468726f77000000000000000000008152509450611124565b6001600160e01b031981167f369da099000000000000000000000000000000000000000000000000000000001415610f0d576040518060400160405280601781526020017f6d61726b657453656c6c4f72646572734e6f5468726f770000000000000000008152509450611124565b6001600160e01b031981167f8bc8efb3000000000000000000000000000000000000000000000000000000001415610f7c576040518060400160405280601981526020017f6d61726b65744275794f726465727346696c6c4f724b696c6c000000000000008152509450611124565b6001600160e01b031981167fa6c3bf33000000000000000000000000000000000000000000000000000000001415610feb576040518060400160405280601a81526020017f6d61726b657453656c6c4f726465727346696c6c4f724b696c6c0000000000008152509450611124565b6001600160e01b031981167f88ec79fb00000000000000000000000000000000000000000000000000000000141561105a576040518060400160405280600b81526020017f6d617463684f72646572730000000000000000000000000000000000000000008152509450611124565b6001600160e01b031981167f4f9559b10000000000000000000000000000000000000000000000000000000014806110bb57506001600160e01b031981167f2280c91000000000000000000000000000000000000000000000000000000000145b156110f2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161077490615630565b6040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610774906155f9565b6001600160e01b031981167fdedfc1f10000000000000000000000000000000000000000000000000000000014156111c957855161116c90879060049063ffffffff6135c416565b80602001905161117f9190810190614607565b604080516000808252602082019092529195505b50604080516000808252602082019092529194506111c1565b60608152602001906001900390816111ac5790505b509150611646565b6001600160e01b031981167fbeee2e1400000000000000000000000000000000000000000000000000000000148061122a57506001600160e01b031981167f9694a40200000000000000000000000000000000000000000000000000000000145b8061125e57506001600160e01b031981167f8ea8dfe400000000000000000000000000000000000000000000000000000000145b156112785761126c86613644565b91955093509150611646565b6001600160e01b031981167f2da629870000000000000000000000000000000000000000000000000000000014156113605760408051600180825281830190925290816020015b6112c7613c90565b8152602001906001900390816112bf57505086519094506112f290879060049063ffffffff6135c416565b8060200190516113059190810190614a61565b8460008151811061131257fe5b602002602001018190525060006040519080825280602002602001820160405280156111935781602001602082028038833901905050604080516000808252602082019092529194506111c1565b6001600160e01b031981167fe14b58c40000000000000000000000000000000000000000000000000000000014806113c157506001600160e01b031981167f9b44d55600000000000000000000000000000000000000000000000000000000145b156113cf5761126c86613673565b6001600160e01b031981167f78d29ac100000000000000000000000000000000000000000000000000000000148061143057506001600160e01b031981167f369da09900000000000000000000000000000000000000000000000000000000145b8061146457506001600160e01b031981167f8bc8efb300000000000000000000000000000000000000000000000000000000145b8061149857506001600160e01b031981167fa6c3bf3300000000000000000000000000000000000000000000000000000000145b156114a65761126c8661376d565b6001600160e01b031981167f88ec79fb000000000000000000000000000000000000000000000000000000001415611646576114e0613c90565b6114e8613c90565b60608061150260048b518c6135c49092919063ffffffff16565b8060200190516115159190810190614b43565b604080516002808252606082019092529498509296509094509250816020015b61153d613c90565b815260200190600190039081611535579050509750838860008151811061156057fe5b6020026020010181905250828860018151811061157957fe5b602090810291909101015260408051600280825260608201909252908160200160208202803883390190505096508360a00151876000815181106115b957fe5b6020026020010181815250508260a00151876001815181106115d757fe5b60209081029190910101526040805160028082526060820190925290816020015b60608152602001906001900390816115f8579050509550818660008151811061161d57fe5b6020026020010181905250808660018151811061163657fe5b6020026020010181905250505050505b509193509193565b60008061165d836106ae6137e1565b825161167390849060049063ffffffff6133fc16565b8060200190516108cf91908101906149b4565b600080611695836106ae613805565b82516116ab90849060049063ffffffff6133fc16565b8060200190516108cf9190810190614379565b6000806116d1838263ffffffff61343f16565b90506001600160e01b031981167ff47261b000000000000000000000000000000000000000000000000000000000141561184657600061171884601063ffffffff61347316565b6040519091506060907f70a082310000000000000000000000000000000000000000000000000000000090611751908890602401614fb1565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050905060006060836001600160a01b0316836040516117cc9190614f95565b600060405180830381855afa9150503d8060008114611807576040519150601f19603f3d011682016040523d82523d6000602084013e61180c565b606091505b509150915081801561181f575080516020145b61182a57600061183b565b61183b81600063ffffffff6134a616565b955050505050611dcc565b6001600160e01b031981167f025717920000000000000000000000000000000000000000000000000000000014156119e157600080611884856106fb565b6040519194509250606091507f6352211e00000000000000000000000000000000000000000000000000000000906118c0908490602401615731565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050905060006060846001600160a01b03168360405161193b9190614f95565b600060405180830381855afa9150503d8060008114611976576040519150601f19603f3d011682016040523d82523d6000602084013e61197b565b606091505b50915091506000828015611990575081516020145b61199b5760006119ac565b6119ac82600c63ffffffff61347316565b9050896001600160a01b0316816001600160a01b0316146119ce5760006119d1565b60015b60ff169750505050505050611dcc565b6001600160e01b031981167fa7cb5fb7000000000000000000000000000000000000000000000000000000001415611bc4576000606080611a2186611ec4565b5081519296509094509250905060005b818114611bba5783516060907efdd58e00000000000000000000000000000000000000000000000000000000908b90879085908110611a6c57fe5b6020026020010151604051602401611a85929190615089565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050905060006060876001600160a01b031683604051611b009190614f95565b600060405180830381855afa9150503d8060008114611b3b576040519150601f19603f3d011682016040523d82523d6000602084013e611b40565b606091505b50915091506000828015611b55575081516020145b611b60576000611b71565b611b7182600063ffffffff6134a616565b90506000878681518110611b8157fe5b60200260200101518281611b9157fe5b0490508b811080611ba057508b155b15611ba957809b505b505060019093019250611a31915050565b5050505050611dcc565b6001600160e01b031981167fc339d10a000000000000000000000000000000000000000000000000000000001415611d15576040516060907fa85e59e40000000000000000000000000000000000000000000000000000000090611c33908690600090819081906024016153fa565b60408051601f198184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff166001600160e01b03199094169390931790925260045491519092506000916001600160a01b031690611c9a908490614f95565b600060405180830381855afa9150503d8060008114611cd5576040519150601f19603f3d011682016040523d82523d6000602084013e611cda565b606091505b5050905080611cea576000611d0c565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff5b93505050611dcc565b6001600160e01b031981167f94cfcdd7000000000000000000000000000000000000000000000000000000001415611dcc57606080611d53856121fc565b80519194509250905060005b818114611dc7576000611d8589858481518110611d7857fe5b60200260200101516116be565b90506000858381518110611d9557fe5b60200260200101518281611da557fe5b04905087811080611db4575087155b15611dbd578097505b5050600101611d5f565b505050505b5092915050565b600080611de6838263ffffffff61343f16565b91506001600160e01b031982167ff47261b00000000000000000000000000000000000000000000000000000000014611e4b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107749061569e565b611e5c83601063ffffffff61347316565b9050915091565b60008060006060611e76856106ae613829565b6000611e8f60048751886133fc9092919063ffffffff16565b806020019051611ea29190810190614c76565b91965094509250905060ff81166006811115611eba57fe5b9450509193509193565b60008060608080611edb868563ffffffff61343f16565b94506001600160e01b031985167fa7cb5fb70000000000000000000000000000000000000000000000000000000014611f40576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107749061569e565b505050506024828101516044840151606485015160848601519496929591820184019490820184019391010190565b6060808251604051908082528060200260200182016040528015611f9d578160200160208202803883390190505b50905060005b83518114611dcc57838181518110611fb757fe5b60200260200101516001600160a01b031631828281518110611fd557fe5b6020908102919091010152600101611fa3565b60606000845190508060405190808252806020026020018201604052801561201a578160200160208202803883390190505b50915060005b8181146120a25761206b86828151811061203657fe5b602002602001015186838151811061204a57fe5b602002602001015186848151811061205e57fe5b60200260200101516129e1565b83828151811061207757fe5b6020026020010190600481111561208a57fe5b9081600481111561209757fe5b905250600101612020565b50505b9392505050565b6040516060907f0257179200000000000000000000000000000000000000000000000000000000906120e49085908590602401615089565b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff166001600160e01b031990931692909217909152905092915050565b60006060806060612146856106ae61384d565b845161215c90869060049063ffffffff6133fc16565b80602001905161096791908101906143f4565b6040516060907fa7cb5fb700000000000000000000000000000000000000000000000000000000906121ab908790879087908790602401615003565b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff166001600160e01b0319909316929092179091529050949350505050565b6000606080612211848463ffffffff61343f16565b92506001600160e01b031983167f94cfcdd70000000000000000000000000000000000000000000000000000000014612276576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107749061569e565b835161228c90859060049063ffffffff6135c416565b80602001905161229f9190810190614817565b9395909450915050565b600060606122b9836106ae613871565b82516122cf90849060049063ffffffff6133fc16565b8060200190516108cf91908101906148f5565b6000806122f1836106ae613895565b600061230a60048551866133fc9092919063ffffffff16565b80602001905161231d9190810190614c07565b9250905060ff811660018111156109c457fe5b606060008251905080604051908082528060200260200182016040528015612362578160200160208202803883390190505b50915060005b818114610a475761237f85858381518110611d7857fe5b83828151811061238b57fe5b6020908102919091010152600101612368565b6000806123b1838263ffffffff61343f16565b90506001600160e01b031981167f94cfcdd7000000000000000000000000000000000000000000000000000000001415612463576060806123f1856121fc565b80519194509250905060005b81811461245857600061241689858481518110610a1b57fe5b9050600085838151811061242657fe5b6020026020010151828161243657fe5b04905087811080612445575087155b1561244e578097505b50506001016123fd565b5061084a9350505050565b6001600160e01b031981167ff47261b00000000000000000000000000000000000000000000000000000000014156124ee5760006124a884601063ffffffff61347316565b6001546040519192506060917fdd62ed3e00000000000000000000000000000000000000000000000000000000916117519189916001600160a01b031690602401614fc5565b6001600160e01b031981167f025717920000000000000000000000000000000000000000000000000000000014156127de5760008061252c856106fb565b600254604051929550909350606092507fe985e9c50000000000000000000000000000000000000000000000000000000091612578918a916001600160a01b0390911690602401614fc5565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050905060006060846001600160a01b0316836040516125f39190614f95565b600060405180830381855afa9150503d806000811461262e576040519150601f19603f3d011682016040523d82523d6000602084013e612633565b606091505b509150915081158061264757508051602014155b80612663575061265e81600063ffffffff6134a616565b600114155b156127b1576040516060907f081812fc000000000000000000000000000000000000000000000000000000009061269e908790602401615731565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050509050856001600160a01b0316816040516127159190614f95565b600060405180830381855afa9150503d8060008114612750576040519150601f19603f3d011682016040523d82523d6000602084013e612755565b606091505b509093509150828015612769575081516020145b801561279857506002546001600160a01b031661278d83600c63ffffffff61347316565b6001600160a01b0316145b6127a35760006127a6565b60015b60ff16975050611bba565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff96505050505050611dcc565b6001600160e01b031981167fa7cb5fb700000000000000000000000000000000000000000000000000000000141561298657600061281b84611ec4565b5050600354604051929450606093507fe985e9c50000000000000000000000000000000000000000000000000000000092612865925089916001600160a01b031690602401614fc5565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050905060006060836001600160a01b0316836040516128e09190614f95565b600060405180830381855afa9150503d806000811461291b576040519150601f19603f3d011682016040523d82523d6000602084013e612920565b606091505b5091509150818015612933575080516020145b801561294f575061294b81600063ffffffff6134a616565b6001145b61295a57600061183b565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff955050505050611dcc565b6001600160e01b031981167fc339d10a000000000000000000000000000000000000000000000000000000001415611dcc57507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9392505050565b60006129eb613d23565b612a7c8584600560009054906101000a90046001600160a01b03166001600160a01b0316631ce4c78b6040518163ffffffff1660e01b815260040160206040518083038186803b158015612a3e57600080fd5b505afa158015612a52573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250612a769190810190614bef565b3a6138b9565b60408051600480825260a0820190925291925060609190816020015b6060815260200190600190039081612a9857505060408051600480825260a082019092529192506060919060208201608080388339505060408051600480825260a08201909252929350606092915060208201608080388339505060408051600480825260a0820190925292935060609291506020820160808038833901905050905088610160015184600081518110612b2e57fe5b60200260200101819052508783600081518110612b4757fe5b60200260200101906001600160a01b031690816001600160a01b031681525050886000015182600081518110612b7957fe5b60200260200101906001600160a01b031690816001600160a01b0316815250508681600081518110612ba757fe5b60200260200101818152505088610140015184600181518110612bc657fe5b6020026020010181905250886000015183600181518110612be357fe5b60200260200101906001600160a01b031690816001600160a01b0316815250508782600181518110612c1157fe5b60200260200101906001600160a01b031690816001600160a01b031681525050846000015181600181518110612c4357fe5b602002602001018181525050886101a0015184600281518110612c6257fe5b60200260200101819052508783600281518110612c7b57fe5b60200260200101906001600160a01b031690816001600160a01b031681525050886040015182600281518110612cad57fe5b60200260200101906001600160a01b031690816001600160a01b031681525050846060015181600281518110612cdf57fe5b60200260200101818152505088610180015184600381518110612cfe57fe5b6020026020010181905250886000015183600381518110612d1b57fe5b60200260200101906001600160a01b031690816001600160a01b031681525050886040015182600381518110612d4d57fe5b60200260200101906001600160a01b031690816001600160a01b031681525050846040015181600381518110612d7f57fe5b60209081029190910101526040516060907fb04fbddd0000000000000000000000000000000000000000000000000000000090612dc69087908790879087906024016150a2565b60408051601f198184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff166001600160e01b03199094169390931790925260055491519092506060916001600160a01b031690612e2d908490614f95565b6000604051808303816000865af19150503d8060008114612e6a576040519150601f19603f3d011682016040523d82523d6000602084013e612e6f565b606091505b50915060009050612e86828263ffffffff61343f16565b9050612e90613534565b6001600160e01b031982811691161415612ed2576000612eaf836108d9565b5091505060ff81166004811115612ec257fe5b99505050505050505050506120a5565b612eda6134ec565b6001600160e01b031982811691161415612f0d576000612ef983610850565b509091505060ff81166004811115612ec257fe5b815160208301207ff43f26ea5a94b478394a975e856464913dc1a8a1ca70939d974aa7c238aa0ce01415612f4c576004985050505050505050506120a5565b6040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610774906155c2565b6040516060907f94cfcdd700000000000000000000000000000000000000000000000000000000906120e49085908590602401615205565b606080606060008551905080604051908082528060200260200182016040528015612ffb57816020015b612fe8613d52565b815260200190600190039081612fe05790505b50935080604051908082528060200260200182016040528015613028578160200160208202803883390190505b50925080604051908082528060200260200182016040528015613055578160200160208202803883390190505b50915060005b8181146130e55761309287828151811061307157fe5b602002602001015187838151811061308557fe5b6020026020010151613107565b87518890859081106130a057fe5b602002602001018785815181106130b357fe5b602002602001018786815181106130c657fe5b931515602094850291909101909301929092529190525260010161305b565b50509250925092565b6060806130fb8484612330565b91506107c284846109cc565b61310f613d52565b600080546040517f9d3fa4b900000000000000000000000000000000000000000000000000000000815282916001600160a01b031690639d3fa4b9906131599088906004016156f9565b60606040518083038186803b15801561317157600080fd5b505afa158015613185573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506131a99190810190614a10565b85516000546040517fa12dcc6f00000000000000000000000000000000000000000000000000000000815292955090916001600160a01b039091169063a12dcc6f906131fb908990899060040161570c565b60206040518083038186803b15801561321357600080fd5b505afa158015613227573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061324b919081019061486e565b9150600061325e82886101400151610828565b60a088015160c08901516101808a01516101408b01519394509192909160009161328d9163ffffffff61393016565b156132ba576132b3846132ad848d6080015161395590919063ffffffff16565b85613971565b9050613313565b816132ce576132b3848b6080015185613971565b60006132df868c6101800151610828565b905060006132f2868d6080015187613971565b90506000613301838688613971565b905061330d82826134d6565b93505050505b61333361332d89604001518561399b90919063ffffffff16565b826134d6565b965050505050509250925092565b6000806000613352846106ae6139ba565b600061336b60048651876133fc9092919063ffffffff16565b8060200190516108089190810190614c34565b7ffdb6ca8d0000000000000000000000000000000000000000000000000000000090565b60006133af83600061343f565b90506001600160e01b0319808216908316146133f7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161077490615667565b505050565b60608183111561341a5761341a613415600085856139de565b613a4d565b83518211156134335761343361341560018487516139de565b50819003910190815290565b600081600401835110156134605761346061341560038551856004016139de565b5001602001516001600160e01b03191690565b600081601401835110156134945761349461341560048551856014016139de565b5001601401516001600160a01b031690565b60006120a58383613a55565b7f18e4b1410000000000000000000000000000000000000000000000000000000090565b60008183106134e557816120a5565b5090919050565b7f4678472b0000000000000000000000000000000000000000000000000000000090565b7fb6555d6f0000000000000000000000000000000000000000000000000000000090565b7f488219a60000000000000000000000000000000000000000000000000000000090565b7f1b8388f70000000000000000000000000000000000000000000000000000000090565b7fe94a7ed00000000000000000000000000000000000000000000000000000000090565b7f4ad312750000000000000000000000000000000000000000000000000000000090565b6060818311156135dd576135dd613415600085856139de565b83518211156135f6576135f661341560018487516139de565b8282036040519080825280601f01601f191660200182016040528015613623576020820181803883390190505b5090506120a561363282613a7f565b8461363c87613a7f565b018351613a85565b606080606061366060048551866135c49092919063ffffffff16565b80602001905161088a9190810190614715565b60408051600180825281830190925260609182918291816020015b613696613c90565b81526020019060019003908161368e5750506040805160018082528183019092529194506020808301908038833901905050604080516001808252818301909252919350816020015b60608152602001906001900390816136df575050845190915061370c90859060049063ffffffff6135c416565b80602001905161371f9190810190614b9c565b8560008151811061372c57fe5b602002602001018560008151811061374057fe5b602002602001018560008151811061375457fe5b6020908102919091010192909252919052529193909250565b6040805160018082528183019092526060918291829160208083019080388339505085519193506137a99186915060049063ffffffff6135c416565b8060200190516137bc919081019061478f565b845185906000906137c957fe5b60209081029190910101919091529095929450925050565b7f11c7b7200000000000000000000000000000000000000000000000000000000090565b7fa15c0d060000000000000000000000000000000000000000000000000000000090565b7f7e5a23180000000000000000000000000000000000000000000000000000000090565b7f5bd0428d0000000000000000000000000000000000000000000000000000000090565b7f20d11f610000000000000000000000000000000000000000000000000000000090565b7ff59851840000000000000000000000000000000000000000000000000000000090565b6138c1613d23565b6020810184905260a085015160808601516138dd918691613b2a565b815260a085015160c08601516138f4918691613b2a565b604082015260a085015160e086015161390e918691613b2a565b6060820152613923828463ffffffff613b5e16565b6080820152949350505050565b6000815183511480156120a55750508051602091820120825192909101919091201490565b6000828201838110156120a5576120a561341560008686613b8b565b600061399383613987868563ffffffff613b5e16565b9063ffffffff613baa16565b949350505050565b6000828211156139b4576139b461341560028585613b8b565b50900390565b7fe53c76c80000000000000000000000000000000000000000000000000000000090565b6060632800659560e01b8484846040516024016139fd939291906154cf565b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff166001600160e01b03199093169290921790915290509392505050565b805160208201fd5b60008160200183511015613a7657613a7661341560058551856020016139de565b50016020015190565b60200190565b6020811015613aaf576001816020036101000a0380198351168185511680821786525050506133f7565b82821415613abc576133f7565b82821115613af65760208103905080820181840181515b82851015613aee578451865260209586019590940193613ad3565b9052506133f7565b60208103905080820181840183515b81861215613b215782518252601f199283019290910190613b05565b85525050505050565b6000613b37848484613bd4565b15613b4a57613b4a613415858585613c3a565b61399383613987868563ffffffff613b5e16565b600082613b6d5750600061084a565b82820282848281613b7a57fe5b04146120a5576120a5613415600186865b606063e946c1bb60e01b8484846040516024016139fd93929190615460565b600081613bc057613bc061341560038585613b8b565b6000828481613bcb57fe5b04949350505050565b600082613be657613be6613415613c59565b811580613bf1575083155b15613bfe575060006120a5565b60008380613c0857fe5b8584099050613c1d858463ffffffff613b5e16565b613c2f826103e863ffffffff613b5e16565b101595945050505050565b606063339f3de260e01b8484846040516024016139fd9392919061573a565b60408051808201909152600481527fa791837c00000000000000000000000000000000000000000000000000000000602082015290565b604051806101c0016040528060006001600160a01b0316815260200160006001600160a01b0316815260200160006001600160a01b0316815260200160006001600160a01b03168152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001606081526020016060815260200160608152602001606081525090565b6040518060a0016040528060008152602001600081526020016000815260200160008152602001600081525090565b604080516060810182526000808252602082018190529181019190915290565b803561084a81615816565b805161084a81615816565b600082601f830112613d98578081fd5b8135613dab613da682615777565b615750565b818152915060208083019084810181840286018201871015613dcc57600080fd5b60005b84811015611dc7578135613de281615816565b84529282019290820190600101613dcf565b600082601f830112613e04578081fd5b8151613e12613da682615777565b8181529150602080830190840160005b83811015613e4f57613e3a8760208451890101614074565b83526020928301929190910190600101613e22565b5050505092915050565b600082601f830112613e69578081fd5b8135613e77613da682615777565b8181529150602080830190840160005b83811015613e4f57613e9f8760208435890101614026565b83526020928301929190910190600101613e87565b600082601f830112613ec4578081fd5b8151613ed2613da682615777565b8181529150602080830190840160005b83811015613e4f57613efa8760208451890101614209565b83526020928301929190910190600101613ee2565b600082601f830112613f1f578081fd5b8135613f2d613da682615777565b8181529150602080830190840160005b83811015613e4f57613f5587602084358901016140ba565b83526020928301929190910190600101613f3d565b600082601f830112613f7a578081fd5b8151613f88613da682615777565b818152915060208083019084810181840286018201871015613fa957600080fd5b60005b84811015611dc757815184529282019290820190600101613fac565b600082601f830112613fd8578081fd5b8135613fe6613da682615777565b81815291506020808301908481018184028601820187101561400757600080fd5b60005b84811015611dc75781358452928201929082019060010161400a565b600082601f830112614036578081fd5b8135614044613da682615797565b915080825283602082850101111561405b57600080fd5b8060208401602084013760009082016020015292915050565b600082601f830112614084578081fd5b8151614092613da682615797565b91508082528360208285010111156140a957600080fd5b611dcc8160208401602086016157bb565b60006101c08083850312156140cd578182fd5b6140d681615750565b9150506140e38383613d72565b81526140f28360208401613d72565b60208201526141048360408401613d72565b60408201526141168360608401613d72565b60608201526080820135608082015260a082013560a082015260c082013560c082015260e082013560e08201526101008083013581830152506101208083013581830152506101408083013567ffffffffffffffff8082111561417857600080fd5b61418486838701614026565b838501526101609250828501359150808211156141a057600080fd5b6141ac86838701614026565b838501526101809250828501359150808211156141c857600080fd5b6141d486838701614026565b838501526101a09250828501359150808211156141f057600080fd5b506141fd85828601614026565b82840152505092915050565b60006101c080838503121561421c578182fd5b61422581615750565b9150506142328383613d7d565b81526142418360208401613d7d565b60208201526142538360408401613d7d565b60408201526142658360608401613d7d565b60608201526080820151608082015260a082015160a082015260c082015160c082015260e082015160e08201526101008083015181830152506101208083015181830152506101408083015167ffffffffffffffff808211156142c757600080fd5b6142d386838701614074565b838501526101609250828501519150808211156142ef57600080fd5b6142fb86838701614074565b8385015261018092508285015191508082111561431757600080fd5b61432386838701614074565b838501526101a092508285015191508082111561433f57600080fd5b506141fd85828601614074565b805160ff8116811461084a57600080fd5b60006020828403121561436e578081fd5b81356120a581615816565b6000806040838503121561438b578081fd5b825161439681615816565b60208401519092506143a781615816565b809150509250929050565b6000806000606084860312156143c6578081fd5b83516143d181615816565b60208501519093506143e281615816565b80925050604084015190509250925092565b60008060008060808587031215614409578182fd5b845161441481615816565b602086015190945067ffffffffffffffff80821115614431578384fd5b61443d88838901614074565b94506040870151915080821115614452578384fd5b61445e88838901614074565b93506060870151915080821115614473578283fd5b5061448087828801614074565b91505092959194509250565b6000806040838503121561449e578182fd5b82356144a981615816565b9150602083013567ffffffffffffffff8111156144c4578182fd5b6144d085828601613e59565b9150509250929050565b600080600080608085870312156144ef578182fd5b84356144fa81615816565b9350602085013567ffffffffffffffff80821115614516578384fd5b61452288838901613fc8565b94506040870135915080821115614537578384fd5b61454388838901613fc8565b93506060870135915080821115614558578283fd5b5061448087828801614026565b60008060408385031215614577578182fd5b823561458281615816565b9150602083013567ffffffffffffffff81111561459d578182fd5b6144d085828601614026565b600080604083850312156145bb578182fd5b82356145c681615816565b946020939093013593505050565b6000602082840312156145e5578081fd5b813567ffffffffffffffff8111156145fb578182fd5b61399384828501613d88565b600060208284031215614618578081fd5b815167ffffffffffffffff81111561462e578182fd5b61399384828501613eb4565b60008060006060848603121561464e578081fd5b833567ffffffffffffffff80821115614665578283fd5b61467187838801613f0f565b94506020860135915080821115614686578283fd5b61469287838801613d88565b935060408601359150808211156146a7578283fd5b506146b486828701613fc8565b9150509250925092565b600080604083850312156146d0578182fd5b823567ffffffffffffffff808211156146e7578384fd5b6146f386838701613f0f565b93506020850135915080821115614708578283fd5b506144d085828601613e59565b600080600060608486031215614729578081fd5b835167ffffffffffffffff80821115614740578283fd5b61474c87838801613eb4565b94506020860151915080821115614761578283fd5b61476d87838801613f6a565b93506040860151915080821115614782578283fd5b506146b486828701613df4565b6000806000606084860312156147a3578081fd5b835167ffffffffffffffff808211156147ba578283fd5b6147c687838801613eb4565b9450602086015193506040860151915080821115614782578283fd5b600080604083850312156147f4578182fd5b823567ffffffffffffffff8082111561480b578384fd5b6146f386838701613fc8565b60008060408385031215614829578182fd5b825167ffffffffffffffff80821115614840578384fd5b61484c86838701613f6a565b93506020850151915080821115614861578283fd5b506144d085828601613df4565b60006020828403121561487f578081fd5b815180151581146120a5578182fd5b600080600080608085870312156148a3578182fd5b8451935060208501516148b581615816565b604086015190935067ffffffffffffffff80821115614452578384fd5b600080604083850312156148e4578182fd5b505080516020909101519092909150565b60008060408385031215614907578182fd5b82519150602083015167ffffffffffffffff811115614924578182fd5b6144d085828601614074565b600080600060608486031215614944578081fd5b83519250602084015167ffffffffffffffff80821115614962578283fd5b61496e87838801614074565b93506040860151915080821115614983578283fd5b506146b486828701614074565b600080604083850312156149a2578182fd5b8251915060208301516143a78161582b565b600080604083850312156149c6578182fd5b82516001600160e01b031981168114614396578283fd5b6000602082840312156149ee578081fd5b813567ffffffffffffffff811115614a04578182fd5b61399384828501614026565b60006060828403128015614a22578182fd5b8015614a2c578182fd5b50614a376060615750565b8251614a428161582b565b8152602083810151908201526040928301519281019290925250919050565b600060208284031215614a72578081fd5b815167ffffffffffffffff811115614a88578182fd5b61399384828501614209565b600080600060608486031215614aa8578081fd5b833567ffffffffffffffff811115614abe578182fd5b614aca868287016140ba565b9350506020840135614adb81615816565b929592945050506040919091013590565b60008060408385031215614afe578182fd5b823567ffffffffffffffff80821115614b15578384fd5b614b21868387016140ba565b93506020850135915080821115614b36578283fd5b506144d085828601614026565b60008060008060808587031215614b58578182fd5b845167ffffffffffffffff80821115614b6f578384fd5b614b7b88838901614209565b95506020870151915080821115614b90578384fd5b61443d88838901614209565b600080600060608486031215614bb0578081fd5b835167ffffffffffffffff80821115614bc7578283fd5b614bd387838801614209565b9450602086015193506040860151915080821115614983578283fd5b600060208284031215614c00578081fd5b5051919050565b60008060408385031215614c19578182fd5b8251614c248161582b565b6020939093015192949293505050565b600080600060608486031215614c48578081fd5b8351614c538161582b565b602085015160408601519194509250614c6b81615816565b809150509250925092565b60008060008060808587031215614c8b578182fd5b614c95868661434c565b9350602085015192506040850151614cac81615816565b606086015190925067ffffffffffffffff811115614cc8578182fd5b61448087828801614074565b600080600060608486031215614ce8578081fd5b614cf2858561434c565b925060208401519150604084015167ffffffffffffffff811115614d14578182fd5b6146b486828701614074565b600080600060608486031215614d34578081fd5b614d3e858561434c565b925060208401519150604084015190509250925092565b1515815260200190565b6000614d6b8383614e78565b505060600190565b6001600160a01b03169052565b6000815180845260208401935060208301825b82811015614dba5781516001600160a01b0316865260209586019590910190600101614d93565b5093949350505050565b600081518084526020840180819550602083028101915060208501845b84811015614e0f578284038852614df9848351614e4c565b6020988901989094509190910190600101614de1565b50919695505050505050565b6000815180845260208401935060208301825b82811015614dba578151865260209586019590910190600101614e2e565b60008151808452614e648160208601602086016157bb565b601f01601f19169290920160200192915050565b805160ff16825260208082015190830152604090810151910152565b60006101c0614ea4848451614d73565b6020830151614eb66020860182614d73565b506040830151614ec96040860182614d73565b506060830151614edc6060860182614d73565b506080830151608085015260a083015160a085015260c083015160c085015260e083015160e0850152610100808401518186015250610120808401518186015250610140808401518282870152614f3583870182614e4c565b91505061016091508184015185820383870152614f528282614e4c565b925050506101808084015185830382870152614f6e8382614e4c565b9150506101a091508184015185820383870152614f8b8282614e4c565b9695505050505050565b60008251614fa78184602087016157bb565b9190910192915050565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b60006001600160a01b0386168252608060208301526150256080830186614e1b565b82810360408401526150378186614e1b565b83810360608501526150498186614e4c565b98975050505050505050565b60006001600160a01b0386168252608060208301526150776080830186614e4c565b82810360408401526150378186614e4c565b6001600160a01b03929092168252602082015260400190565b6000608082526150b56080830187614dc4565b82810360208401526150c78187614d80565b83810360408501526150d98187614d80565b91505082810360608401526150ee8185614e1b565b979650505050505050565b602080825282518282018190526000918401906040840190835b8181101561513b5783516005811061512757fe5b835260209384019390920191600101615113565b509095945050505050565b6000606082016060835280865161515d8184615731565b9150602088019250835b8181101561518b5761517a838551614d5f565b602094909401939250600101615167565b5050838103602085015261519f8187614e1b565b91505082810360408401528084516151b78184615731565b9150602086019250835b818110156151e5576151d4838551614d55565b6020949094019392506001016151c1565b5090979650505050505050565b6000602082526120a56020830184614e1b565b6000604082526152186040830185614e1b565b828103602084015261522a8185614dc4565b95945050505050565b6000604082526152466040830185614e1b565b828103602084015261522a8185614e1b565b60008582526001600160a01b0385166020830152608060408301526152806080830185614e4c565b82810360608401526150ee8185614e4c565b918252602082015260400190565b6000838252604060208301526139936040830184614e4c565b6000848252606060208301526152d26060830185614e4c565b8281036040840152614f8b8185614e4c565b828152604081016152f48361580c565b8260208301529392505050565b6001600160e01b03199290921682526001600160a01b0316602082015260400190565b60006001600160e01b0319871682526001600160a01b038616602083015260a0604083015261535660a0830186614e1b565b82810360608401526153688186614e1b565b838103608085015261537a8186614e4c565b9998505050505050505050565b6001600160e01b03199390931683526001600160a01b03919091166020830152604082015260600190565b60006001600160e01b031985168252606060208301526153d56060830185614e1b565b8281036040840152614f8b8185614dc4565b6000602082526120a56020830184614e4c565b60006080825261540d6080830187614e4c565b6001600160a01b03958616602084015293909416604082015260ff9190911660609091015292915050565b6000615443856157eb565b8482528360208301526060604083015261522a6060830184614e4c565b6060810161546d856157f8565b938152602081019290925260409091015290565b6060810161548e85615802565b93815260208101929092526001600160a01b031660409091015290565b604081016154b8846157f8565b9281526020015290565b6060810161546d85615802565b606081016008851061546d57fe5b60208101600583106154eb57fe5b91905290565b60006154fc8661580c565b8582528460208301526001600160a01b038416604083015260806060830152614f8b6080830184614e4c565b604081016154b8846157eb565b6000608082526155486080830187614e4c565b602083820381850152818751808452828401915082838202850101838a01865b8381101561559657601f19878403018552615584838351614e94565b94860194925090850190600101615568565b505086810360408801526155aa818a614e1b565b94505050505082810360608401526150ee8185614dc4565b60208082526013908201527f554e4b4e4f574e5f52455455524e5f4441544100000000000000000000000000604082015260600190565b60208082526019908201527f554e4b4e4f574e5f46554e4354494f4e5f53454c4543544f5200000000000000604082015260600190565b6020808252600d908201527f554e494d504c454d454e54454400000000000000000000000000000000000000604082015260600190565b6020808252600c908201527f4241445f53454c4543544f520000000000000000000000000000000000000000604082015260600190565b6020808252600e908201527f57524f4e475f50524f58595f4944000000000000000000000000000000000000604082015260600190565b60a081016156e38286614e78565b8360608301528215156080830152949350505050565b6000602082526120a56020830184614e94565b60006040825261571f6040830185614e94565b828103602084015261522a8185614e4c565b90815260200190565b9283526020830191909152604082015260600190565b60405181810167ffffffffffffffff8111828210171561576f57600080fd5b604052919050565b600067ffffffffffffffff82111561578d578081fd5b5060209081020190565b600067ffffffffffffffff8211156157ad578081fd5b50601f01601f191660200190565b60005b838110156157d65781810151838201526020016157be565b838111156157e5576000848401525b50505050565b600281106157f557fe5b50565b600481106157f557fe5b600381106157f557fe5b600781106157f557fe5b6001600160a01b03811681146157f557600080fd5b60ff811681146157f557600080fdfea365627a7a723158200ea049525ebc74d73f3bf7858c601bd21168267b0dfb4abbdb7787cfd7233a2c6c6578706572696d656e74616cf564736f6c634300050c0040'; - /** - * Decompose an ABI-encoded AssetProxyDispatchError. - */ - public decodeAssetProxyDispatchError = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param encoded ABI-encoded revert error. - * @returns errorCode The error code.orderHash Hash of the order being dispatched.assetData Asset data of the order being dispatched. - */ - async callAsync( - encoded: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise<[number, string, string]> { - assert.isString('encoded', encoded); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DevUtilsContract; - const encodedData = self._strictEncodeArguments('decodeAssetProxyDispatchError(bytes)', [encoded]); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('decodeAssetProxyDispatchError(bytes)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue<[number, string, string]>(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Decompose an ABI-encoded AssetProxyExistsError. - */ - public decodeAssetProxyExistsError = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param encoded ABI-encoded revert error. - * @returns assetProxyId Id of asset proxy.assetProxyAddress The address of the asset proxy. - */ - async callAsync( - encoded: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise<[string, string]> { - assert.isString('encoded', encoded); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DevUtilsContract; - const encodedData = self._strictEncodeArguments('decodeAssetProxyExistsError(bytes)', [encoded]); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('decodeAssetProxyExistsError(bytes)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue<[string, string]>(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Decompose an ABI-encoded AssetProxyTransferError. - */ - public decodeAssetProxyTransferError = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param encoded ABI-encoded revert error. - * @returns orderHash Hash of the order being dispatched.assetData Asset data of the order being dispatched.errorData ABI-encoded revert data from the asset proxy. - */ - async callAsync( - encoded: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise<[string, string, string]> { - assert.isString('encoded', encoded); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DevUtilsContract; - const encodedData = self._strictEncodeArguments('decodeAssetProxyTransferError(bytes)', [encoded]); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('decodeAssetProxyTransferError(bytes)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue<[string, string, string]>(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Decompose an ABI-encoded SignatureValidatorError. - */ - public decodeEIP1271SignatureError = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param encoded ABI-encoded revert error. - * @returns signerAddress The expected signer of the hash.signature The full signature bytes.errorData The revert data thrown by the validator contract. - */ - async callAsync( - encoded: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise<[string, string, string, string]> { - assert.isString('encoded', encoded); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DevUtilsContract; - const encodedData = self._strictEncodeArguments('decodeEIP1271SignatureError(bytes)', [encoded]); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('decodeEIP1271SignatureError(bytes)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue<[string, string, string, string]>(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Decode ERC-1155 asset data from the format described in the AssetProxy contract specification. - */ - public decodeERC1155AssetData = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param assetData AssetProxy-compliant asset data describing an ERC-1155 set - * of assets. - * @returns The ERC-1155 AssetProxy identifier, the address of the ERC-1155 contract hosting the assets, an array of the identifiers of the assets to be traded, an array of asset amounts to be traded, and callback data. Each element of the arrays corresponds to the same-indexed element of the other array. Return values specified as `memory` are returned as pointers to locations within the memory of the input parameter `assetData`. - */ - async callAsync( - assetData: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise<[string, string, BigNumber[], BigNumber[], string]> { - assert.isString('assetData', assetData); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DevUtilsContract; - const encodedData = self._strictEncodeArguments('decodeERC1155AssetData(bytes)', [assetData]); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('decodeERC1155AssetData(bytes)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue<[string, string, BigNumber[], BigNumber[], string]>( - rawCallResult, - ); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Decode ERC-20 asset data from the format described in the AssetProxy contract specification. - */ - public decodeERC20AssetData = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param assetData AssetProxy-compliant asset data describing an ERC-20 asset. - * @returns The ERC-20 AssetProxy identifier, and the address of the ERC-20 contract hosting this asset. - */ - async callAsync( - assetData: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise<[string, string]> { - assert.isString('assetData', assetData); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DevUtilsContract; - const encodedData = self._strictEncodeArguments('decodeERC20AssetData(bytes)', [assetData]); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('decodeERC20AssetData(bytes)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue<[string, string]>(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Decode ERC-721 asset data from the format described in the AssetProxy contract specification. - */ - public decodeERC721AssetData = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param assetData AssetProxy-compliant asset data describing an ERC-721 - * asset. - * @returns The ERC-721 AssetProxy identifier, the address of the ERC-721 contract hosting this asset, and the identifier of the specific asset to be traded. - */ - async callAsync( - assetData: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise<[string, string, BigNumber]> { - assert.isString('assetData', assetData); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DevUtilsContract; - const encodedData = self._strictEncodeArguments('decodeERC721AssetData(bytes)', [assetData]); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('decodeERC721AssetData(bytes)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue<[string, string, BigNumber]>(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Decompose an ABI-encoded OrderStatusError. - */ - public decodeExchangeInvalidContextError = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param encoded ABI-encoded revert error. - * @returns errorCode Error code that corresponds to invalid maker, taker, or sender.orderHash The order hash.contextAddress The maker, taker, or sender address - */ - async callAsync( - encoded: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise<[number, string, string]> { - assert.isString('encoded', encoded); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DevUtilsContract; - const encodedData = self._strictEncodeArguments('decodeExchangeInvalidContextError(bytes)', [encoded]); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('decodeExchangeInvalidContextError(bytes)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue<[number, string, string]>(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Decompose an ABI-encoded FillError. - */ - public decodeFillError = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param encoded ABI-encoded revert error. - * @returns errorCode The error code.orderHash The order hash. - */ - async callAsync( - encoded: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise<[number, string]> { - assert.isString('encoded', encoded); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DevUtilsContract; - const encodedData = self._strictEncodeArguments('decodeFillError(bytes)', [encoded]); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('decodeFillError(bytes)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue<[number, string]>(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Decompose an ABI-encoded IncompleteFillError. - */ - public decodeIncompleteFillError = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param encoded ABI-encoded revert error. - * @returns orderHash Hash of the order being filled. - */ - async callAsync( - encoded: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise<[number, BigNumber, BigNumber]> { - assert.isString('encoded', encoded); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DevUtilsContract; - const encodedData = self._strictEncodeArguments('decodeIncompleteFillError(bytes)', [encoded]); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('decodeIncompleteFillError(bytes)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue<[number, BigNumber, BigNumber]>(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Decode multi-asset data from the format described in the AssetProxy contract specification. - */ - public decodeMultiAssetData = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param assetData AssetProxy-compliant data describing a multi-asset basket. - * @returns The Multi-Asset AssetProxy identifier, an array of the amounts of the assets to be traded, and an array of the AssetProxy-compliant data describing each asset to be traded. Each element of the arrays corresponds to the same-indexed element of the other array. - */ - async callAsync( - assetData: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise<[string, BigNumber[], string[]]> { - assert.isString('assetData', assetData); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DevUtilsContract; - const encodedData = self._strictEncodeArguments('decodeMultiAssetData(bytes)', [assetData]); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('decodeMultiAssetData(bytes)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue<[string, BigNumber[], string[]]>(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Decompose an ABI-encoded NegativeSpreadError. - */ - public decodeNegativeSpreadError = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param encoded ABI-encoded revert error. - * @returns leftOrderHash Hash of the left order being matched.rightOrderHash Hash of the right order being matched. - */ - async callAsync( - encoded: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise<[string, string]> { - assert.isString('encoded', encoded); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DevUtilsContract; - const encodedData = self._strictEncodeArguments('decodeNegativeSpreadError(bytes)', [encoded]); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('decodeNegativeSpreadError(bytes)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue<[string, string]>(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Decompose an ABI-encoded OrderEpochError. - */ - public decodeOrderEpochError = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param encoded ABI-encoded revert error. - * @returns makerAddress The order maker.orderSenderAddress The order sender.currentEpoch The current epoch for the maker. - */ - async callAsync( - encoded: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise<[string, string, BigNumber]> { - assert.isString('encoded', encoded); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DevUtilsContract; - const encodedData = self._strictEncodeArguments('decodeOrderEpochError(bytes)', [encoded]); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('decodeOrderEpochError(bytes)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue<[string, string, BigNumber]>(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Decompose an ABI-encoded OrderStatusError. - */ - public decodeOrderStatusError = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param encoded ABI-encoded revert error. - * @returns orderHash The order hash.orderStatus The order status. - */ - async callAsync( - encoded: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise<[string, number]> { - assert.isString('encoded', encoded); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DevUtilsContract; - const encodedData = self._strictEncodeArguments('decodeOrderStatusError(bytes)', [encoded]); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('decodeOrderStatusError(bytes)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue<[string, number]>(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Decompose an ABI-encoded SignatureError. - */ - public decodeSignatureError = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param encoded ABI-encoded revert error. - * @returns errorCode The error code.signerAddress The expected signer of the hash.signature The full signature. - */ - async callAsync( - encoded: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise<[number, string, string, string]> { - assert.isString('encoded', encoded); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DevUtilsContract; - const encodedData = self._strictEncodeArguments('decodeSignatureError(bytes)', [encoded]); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('decodeSignatureError(bytes)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue<[number, string, string, string]>(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Decompose an ABI-encoded SignatureValidatorNotApprovedError. - */ - public decodeSignatureValidatorNotApprovedError = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param encoded ABI-encoded revert error. - * @returns signerAddress The expected signer of the hash.validatorAddress The expected validator. - */ - async callAsync( - encoded: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise<[string, string]> { - assert.isString('encoded', encoded); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DevUtilsContract; - const encodedData = self._strictEncodeArguments('decodeSignatureValidatorNotApprovedError(bytes)', [ - encoded, - ]); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('decodeSignatureValidatorNotApprovedError(bytes)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue<[string, string]>(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Decompose an ABI-encoded SignatureWalletError. - */ - public decodeSignatureWalletError = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param encoded ABI-encoded revert error. - * @returns errorCode The error code.signerAddress The expected signer of the hash.signature The full signature bytes.errorData The revert data thrown by the validator contract. - */ - async callAsync( - encoded: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise<[string, string, string, string]> { - assert.isString('encoded', encoded); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DevUtilsContract; - const encodedData = self._strictEncodeArguments('decodeSignatureWalletError(bytes)', [encoded]); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('decodeSignatureWalletError(bytes)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue<[string, string, string, string]>(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Decompose an ABI-encoded TransactionError. - */ - public decodeTransactionError = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param encoded ABI-encoded revert error. - * @returns errorCode The error code.transactionHash Hash of the transaction. - */ - async callAsync( - encoded: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise<[number, string]> { - assert.isString('encoded', encoded); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DevUtilsContract; - const encodedData = self._strictEncodeArguments('decodeTransactionError(bytes)', [encoded]); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('decodeTransactionError(bytes)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue<[number, string]>(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Decompose an ABI-encoded TransactionExecutionError. - */ - public decodeTransactionExecutionError = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param encoded ABI-encoded revert error. - * @returns transactionHash Hash of the transaction.errorData Error thrown by exeucteTransaction(). - */ - async callAsync( - encoded: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise<[string, string]> { - assert.isString('encoded', encoded); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DevUtilsContract; - const encodedData = self._strictEncodeArguments('decodeTransactionExecutionError(bytes)', [encoded]); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('decodeTransactionExecutionError(bytes)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue<[string, string]>(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Decodes the call data for an Exchange contract method call. - */ - public decodeZeroExTransactionData = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param transactionData ABI-encoded calldata for an Exchange contract - * method call. - * @returns The name of the function called, and the parameters it was given. For single-order fills and cancels, the arrays will have just one element. - */ - async callAsync( - transactionData: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise< - [ - string, - Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - BigNumber[], - string[] - ] - > { - assert.isString('transactionData', transactionData); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DevUtilsContract; - const encodedData = self._strictEncodeArguments('decodeZeroExTransactionData(bytes)', [transactionData]); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('decodeZeroExTransactionData(bytes)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue< - [ - string, - Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - BigNumber[], - string[] - ] - >(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Encode ERC-1155 asset data into the format described in the AssetProxy contract specification. - */ - public encodeERC1155AssetData = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param tokenAddress The address of the ERC-1155 contract hosting the - * asset(s) to be traded. - * @param tokenIds The identifiers of the specific assets to be traded. - * @param tokenValues The amounts of each asset to be traded. - * @param callbackData Data to be passed to receiving contracts when a transfer - * is performed. - * @returns AssetProxy-compliant asset data describing the set of assets. - */ - async callAsync( - tokenAddress: string, - tokenIds: BigNumber[], - tokenValues: BigNumber[], - callbackData: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('tokenAddress', tokenAddress); - assert.isArray('tokenIds', tokenIds); - assert.isArray('tokenValues', tokenValues); - assert.isString('callbackData', callbackData); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DevUtilsContract; - const encodedData = self._strictEncodeArguments( - 'encodeERC1155AssetData(address,uint256[],uint256[],bytes)', - [tokenAddress.toLowerCase(), tokenIds, tokenValues, callbackData], - ); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('encodeERC1155AssetData(address,uint256[],uint256[],bytes)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Encode ERC-20 asset data into the format described in the AssetProxy contract specification. - */ - public encodeERC20AssetData = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param tokenAddress The address of the ERC-20 contract hosting the asset to - * be traded. - * @returns AssetProxy-compliant data describing the asset. - */ - async callAsync( - tokenAddress: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('tokenAddress', tokenAddress); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DevUtilsContract; - const encodedData = self._strictEncodeArguments('encodeERC20AssetData(address)', [ - tokenAddress.toLowerCase(), - ]); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; + private _methodABIIndex: { [name: string]: number } = {}; + public static async deployFrom0xArtifactAsync( + artifact: ContractArtifact | SimpleContractArtifact, + supportedProvider: SupportedProvider, + txDefaults: Partial, + logDecodeDependencies: { [contractName: string]: ContractArtifact | SimpleContractArtifact }, + _exchange: string, + ): Promise { + assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (artifact.compilerOutput === undefined) { + throw new Error('Compiler output not found in the artifact file'); + } + const provider = providerUtils.standardizeOrThrow(supportedProvider); + const bytecode = artifact.compilerOutput.evm.bytecode.object; + const abi = artifact.compilerOutput.abi; + const logDecodeDependenciesAbiOnly: { [contractName: string]: ContractAbi } = {}; + if (Object.keys(logDecodeDependencies) !== undefined) { + for (const key of Object.keys(logDecodeDependencies)) { + logDecodeDependenciesAbiOnly[key] = logDecodeDependencies[key].compilerOutput.abi; } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); + } + return DevUtilsContract.deployAsync( + bytecode, + abi, + provider, + txDefaults, + logDecodeDependenciesAbiOnly, + _exchange, + ); + } + public static async deployAsync( + bytecode: string, + abi: ContractAbi, + supportedProvider: SupportedProvider, + txDefaults: Partial, + logDecodeDependencies: { [contractName: string]: ContractAbi }, + _exchange: string, + ): Promise { + assert.isHexString('bytecode', bytecode); + assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + const provider = providerUtils.standardizeOrThrow(supportedProvider); + const constructorAbi = BaseContract._lookupConstructorAbi(abi); + [_exchange] = BaseContract._formatABIDataItemList( + constructorAbi.inputs, + [_exchange], + BaseContract._bigNumberToString, + ); + const iface = new ethers.utils.Interface(abi); + const deployInfo = iface.deployFunction; + const txData = deployInfo.encode(bytecode, [_exchange]); + const web3Wrapper = new Web3Wrapper(provider); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { data: txData }, + txDefaults, + web3Wrapper.estimateGasAsync.bind(web3Wrapper), + ); + const txHash = await web3Wrapper.sendTransactionAsync(txDataWithDefaults); + logUtils.log(`transactionHash: ${txHash}`); + const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash); + logUtils.log(`DevUtils successfully deployed at ${txReceipt.contractAddress}`); + const contractInstance = new DevUtilsContract( + txReceipt.contractAddress as string, + provider, + txDefaults, + logDecodeDependencies, + ); + contractInstance.constructorArgs = [_exchange]; + return contractInstance; + } - const abiEncoder = self._lookupAbiEncoder('encodeERC20AssetData(address)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; /** - * Encode ERC-721 asset data into the format described in the AssetProxy specification. - */ - public encodeERC721AssetData = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param tokenAddress The address of the ERC-721 contract hosting the asset to - * be traded. - * @param tokenId The identifier of the specific asset to be traded. - * @returns AssetProxy-compliant asset data describing the asset. - */ - async callAsync( - tokenAddress: string, - tokenId: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('tokenAddress', tokenAddress); - assert.isBigNumber('tokenId', tokenId); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DevUtilsContract; - const encodedData = self._strictEncodeArguments('encodeERC721AssetData(address,uint256)', [ - tokenAddress.toLowerCase(), - tokenId, - ]); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('encodeERC721AssetData(address,uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Encode data for multiple assets, per the AssetProxy contract specification. - */ - public encodeMultiAssetData = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param amounts The amounts of each asset to be traded. - * @param nestedAssetData AssetProxy-compliant data describing each asset to be - * traded. - * @returns AssetProxy-compliant data describing the set of assets. - */ - async callAsync( - amounts: BigNumber[], - nestedAssetData: string[], - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isArray('amounts', amounts); - assert.isArray('nestedAssetData', nestedAssetData); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DevUtilsContract; - const encodedData = self._strictEncodeArguments('encodeMultiAssetData(uint256[],bytes[])', [ - amounts, - nestedAssetData, - ]); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('encodeMultiAssetData(uint256[],bytes[])'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Returns the number of asset(s) (described by assetData) that the corresponding AssetProxy contract is authorized to spend. When the asset data contains multiple assets (eg for Multi-Asset), the return value indicates how many complete "baskets" of those assets may be spent by all of the corresponding AssetProxy contracts. - */ - public getAssetProxyAllowance = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param ownerAddress Owner of the assets specified by assetData. - * @param assetData Details of asset, encoded per the AssetProxy contract - * specification. - * @returns Number of assets (or asset baskets) that the corresponding AssetProxy is authorized to spend. - */ - async callAsync( - ownerAddress: string, - assetData: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('ownerAddress', ownerAddress); - assert.isString('assetData', assetData); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DevUtilsContract; - const encodedData = self._strictEncodeArguments('getAssetProxyAllowance(address,bytes)', [ - ownerAddress.toLowerCase(), - assetData, - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('getAssetProxyAllowance(address,bytes)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Returns the owner's balance of the assets(s) specified in assetData. When the asset data contains multiple assets (eg in ERC1155 or Multi-Asset), the return value indicates how many complete "baskets" of those assets are owned by owner. - */ - public getBalance = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param ownerAddress Owner of the assets specified by assetData. - * @param assetData Details of asset, encoded per the AssetProxy contract - * specification. - * @returns Number of assets (or asset baskets) held by owner. - */ - async callAsync( - ownerAddress: string, - assetData: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('ownerAddress', ownerAddress); - assert.isString('assetData', assetData); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DevUtilsContract; - const encodedData = self._strictEncodeArguments('getBalance(address,bytes)', [ - ownerAddress.toLowerCase(), - assetData, - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('getBalance(address,bytes)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Calls getBalance() and getAllowance() for assetData. - */ - public getBalanceAndAssetProxyAllowance = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param ownerAddress Owner of the assets specified by assetData. - * @param assetData Details of asset, encoded per the AssetProxy contract - * specification. - * @returns Number of assets (or asset baskets) held by owner, and number of assets (or asset baskets) that the corresponding AssetProxy is authorized to spend. - */ - async callAsync( - ownerAddress: string, - assetData: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise<[BigNumber, BigNumber]> { - assert.isString('ownerAddress', ownerAddress); - assert.isString('assetData', assetData); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DevUtilsContract; - const encodedData = self._strictEncodeArguments('getBalanceAndAssetProxyAllowance(address,bytes)', [ - ownerAddress.toLowerCase(), - assetData, - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('getBalanceAndAssetProxyAllowance(address,bytes)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue<[BigNumber, BigNumber]>(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Calls getAssetProxyAllowance() for each element of assetData. - */ - public getBatchAssetProxyAllowances = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param ownerAddress Owner of the assets specified by assetData. - * @param assetData Array of asset details, each encoded per the AssetProxy - * contract specification. - * @returns An array of asset allowances from getAllowance(), with each element corresponding to the same-indexed element in the assetData input. - */ - async callAsync( - ownerAddress: string, - assetData: string[], - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('ownerAddress', ownerAddress); - assert.isArray('assetData', assetData); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DevUtilsContract; - const encodedData = self._strictEncodeArguments('getBatchAssetProxyAllowances(address,bytes[])', [ - ownerAddress.toLowerCase(), - assetData, - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('getBatchAssetProxyAllowances(address,bytes[])'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Calls getBalance() for each element of assetData. - */ - public getBatchBalances = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param ownerAddress Owner of the assets specified by assetData. - * @param assetData Array of asset details, each encoded per the AssetProxy - * contract specification. - * @returns Array of asset balances from getBalance(), with each element corresponding to the same-indexed element in the assetData input. - */ - async callAsync( - ownerAddress: string, - assetData: string[], - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('ownerAddress', ownerAddress); - assert.isArray('assetData', assetData); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DevUtilsContract; - const encodedData = self._strictEncodeArguments('getBatchBalances(address,bytes[])', [ - ownerAddress.toLowerCase(), - assetData, - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('getBatchBalances(address,bytes[])'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Calls getBatchBalances() and getBatchAllowances() for each element of assetData. - */ - public getBatchBalancesAndAssetProxyAllowances = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param ownerAddress Owner of the assets specified by assetData. - * @param assetData Array of asset details, each encoded per the AssetProxy - * contract specification. - * @returns An array of asset balances from getBalance(), and an array of asset allowances from getAllowance(), with each element corresponding to the same-indexed element in the assetData input. - */ - async callAsync( - ownerAddress: string, - assetData: string[], - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise<[BigNumber[], BigNumber[]]> { - assert.isString('ownerAddress', ownerAddress); - assert.isArray('assetData', assetData); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DevUtilsContract; - const encodedData = self._strictEncodeArguments( - 'getBatchBalancesAndAssetProxyAllowances(address,bytes[])', - [ownerAddress.toLowerCase(), assetData], - ); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('getBatchBalancesAndAssetProxyAllowances(address,bytes[])'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue<[BigNumber[], BigNumber[]]>(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Batch fetches ETH balances - */ - public getEthBalances = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param addresses Array of addresses. - * @returns Array of ETH balances. - */ - async callAsync( - addresses: string[], - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isArray('addresses', addresses); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DevUtilsContract; - const encodedData = self._strictEncodeArguments('getEthBalances(address[])', [addresses]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('getEthBalances(address[])'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Fetches all order-relevant information needed to validate if the supplied order is fillable. - */ - public getOrderRelevantState = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param order The order structure. - * @param signature Signature provided by maker that proves the order's - * authenticity. `0x01` can always be provided if the signature does not - * need to be validated. - * @returns The orderInfo (hash, status, and `takerAssetAmount` already filled for the given order), fillableTakerAssetAmount (amount of the order's `takerAssetAmount` that is fillable given all on-chain state), and isValidSignature (validity of the provided signature). NOTE: If the `takerAssetData` encodes data for multiple assets, `fillableTakerAssetAmount` will represent a "scaled" amount, meaning it must be multiplied by all the individual asset amounts within the `takerAssetData` to get the final amount of each asset that can be filled. - */ - async callAsync( - order: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }, - signature: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise< - [{ orderStatus: number; orderHash: string; orderTakerAssetFilledAmount: BigNumber }, BigNumber, boolean] - > { - assert.isString('signature', signature); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DevUtilsContract; - const encodedData = self._strictEncodeArguments( - 'getOrderRelevantState((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),bytes)', - [order, signature], - ); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder( - 'getOrderRelevantState((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),bytes)', - ); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue< - [{ orderStatus: number; orderHash: string; orderTakerAssetFilledAmount: BigNumber }, BigNumber, boolean] - >(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Fetches all order-relevant information needed to validate if the supplied orders are fillable. - */ - public getOrderRelevantStates = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param orders Array of order structures. - * @param signatures Array of signatures provided by makers that prove the - * authenticity of the orders. `0x01` can always be provided if a signature - * does not need to be validated. - * @returns The ordersInfo (array of the hash, status, and `takerAssetAmount` already filled for each order), fillableTakerAssetAmounts (array of amounts for each order's `takerAssetAmount` that is fillable given all on-chain state), and isValidSignature (array containing the validity of each provided signature). NOTE: If the `takerAssetData` encodes data for multiple assets, each element of `fillableTakerAssetAmounts` will represent a "scaled" amount, meaning it must be multiplied by all the individual asset amounts within the `takerAssetData` to get the final amount of each asset that can be filled. - */ - async callAsync( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - signatures: string[], - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise< - [ - Array<{ orderStatus: number; orderHash: string; orderTakerAssetFilledAmount: BigNumber }>, - BigNumber[], - boolean[] - ] - > { - assert.isArray('orders', orders); - assert.isArray('signatures', signatures); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DevUtilsContract; - const encodedData = self._strictEncodeArguments( - 'getOrderRelevantStates((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],bytes[])', - [orders, signatures], - ); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder( - 'getOrderRelevantStates((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],bytes[])', - ); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue< - [ - Array<{ orderStatus: number; orderHash: string; orderTakerAssetFilledAmount: BigNumber }>, - BigNumber[], - boolean[] - ] - >(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Simulates all of the transfers within an order and returns the index of the first failed transfer. - */ - public getSimulatedOrderTransferResults = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param order The order to simulate transfers for. - * @param takerAddress The address of the taker that will fill the order. - * @param takerAssetFillAmount The amount of takerAsset that the taker wished - * to fill. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - order: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }, - takerAddress: string, - takerAssetFillAmount: BigNumber, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('takerAddress', takerAddress); - assert.isBigNumber('takerAssetFillAmount', takerAssetFillAmount); - const self = (this as any) as DevUtilsContract; - const encodedData = self._strictEncodeArguments( - 'getSimulatedOrderTransferResults((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),address,uint256)', - [order, takerAddress.toLowerCase(), takerAssetFillAmount], - ); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.getSimulatedOrderTransferResults.callAsync( - order, - takerAddress, - takerAssetFillAmount, - txDataWithDefaults, - ); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param order The order to simulate transfers for. - * @param takerAddress The address of the taker that will fill the order. - * @param takerAssetFillAmount The amount of takerAsset that the taker wished - * to fill. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - order: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }, - takerAddress: string, - takerAssetFillAmount: BigNumber, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('takerAddress', takerAddress); - assert.isBigNumber('takerAssetFillAmount', takerAssetFillAmount); - const self = (this as any) as DevUtilsContract; - const txHashPromise = self.getSimulatedOrderTransferResults.sendTransactionAsync( - order, - takerAddress.toLowerCase(), - takerAssetFillAmount, - txData, - opts, - ); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param order The order to simulate transfers for. - * @param takerAddress The address of the taker that will fill the order. - * @param takerAssetFillAmount The amount of takerAsset that the taker wished - * to fill. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - order: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }, - takerAddress: string, - takerAssetFillAmount: BigNumber, - txData?: Partial | undefined, - ): Promise { - assert.isString('takerAddress', takerAddress); - assert.isBigNumber('takerAssetFillAmount', takerAssetFillAmount); - const self = (this as any) as DevUtilsContract; - const encodedData = self._strictEncodeArguments( - 'getSimulatedOrderTransferResults((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),address,uint256)', - [order, takerAddress.toLowerCase(), takerAssetFillAmount], - ); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param order The order to simulate transfers for. - * @param takerAddress The address of the taker that will fill the order. - * @param takerAssetFillAmount The amount of takerAsset that the taker wished - * to fill. - * @returns The index of the first failed transfer (or 4 if all transfers are successful). - */ - async callAsync( - order: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }, - takerAddress: string, - takerAssetFillAmount: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('takerAddress', takerAddress); - assert.isBigNumber('takerAssetFillAmount', takerAssetFillAmount); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DevUtilsContract; - const encodedData = self._strictEncodeArguments( - 'getSimulatedOrderTransferResults((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),address,uint256)', - [order, takerAddress.toLowerCase(), takerAssetFillAmount], - ); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder( - 'getSimulatedOrderTransferResults((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),address,uint256)', - ); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param order The order to simulate transfers for. - * @param takerAddress The address of the taker that will fill the order. - * @param takerAssetFillAmount The amount of takerAsset that the taker wished - * to fill. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData( - order: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }, - takerAddress: string, - takerAssetFillAmount: BigNumber, - ): string { - assert.isString('takerAddress', takerAddress); - assert.isBigNumber('takerAssetFillAmount', takerAssetFillAmount); - const self = (this as any) as DevUtilsContract; - const abiEncodedTransactionData = self._strictEncodeArguments( - 'getSimulatedOrderTransferResults((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),address,uint256)', - [order, takerAddress.toLowerCase(), takerAssetFillAmount], - ); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as DevUtilsContract; - const abiEncoder = self._lookupAbiEncoder( - 'getSimulatedOrderTransferResults((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),address,uint256)', - ); - return abiEncoder.getSelector(); - }, - }; - /** - * Simulates all of the transfers for each given order and returns the indices of each first failed transfer. - */ - public getSimulatedOrdersTransferResults = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param orders Array of orders to individually simulate transfers for. - * @param takerAddresses Array of addresses of takers that will fill each - * order. - * @param takerAssetFillAmounts Array of amounts of takerAsset that will be - * filled for each order. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - takerAddresses: string[], - takerAssetFillAmounts: BigNumber[], - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isArray('orders', orders); - assert.isArray('takerAddresses', takerAddresses); - assert.isArray('takerAssetFillAmounts', takerAssetFillAmounts); - const self = (this as any) as DevUtilsContract; - const encodedData = self._strictEncodeArguments( - 'getSimulatedOrdersTransferResults((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],address[],uint256[])', - [orders, takerAddresses, takerAssetFillAmounts], - ); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.getSimulatedOrdersTransferResults.callAsync( - orders, - takerAddresses, - takerAssetFillAmounts, - txDataWithDefaults, - ); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param orders Array of orders to individually simulate transfers for. - * @param takerAddresses Array of addresses of takers that will fill each - * order. - * @param takerAssetFillAmounts Array of amounts of takerAsset that will be - * filled for each order. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - takerAddresses: string[], - takerAssetFillAmounts: BigNumber[], - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isArray('orders', orders); - assert.isArray('takerAddresses', takerAddresses); - assert.isArray('takerAssetFillAmounts', takerAssetFillAmounts); - const self = (this as any) as DevUtilsContract; - const txHashPromise = self.getSimulatedOrdersTransferResults.sendTransactionAsync( - orders, - takerAddresses, - takerAssetFillAmounts, - txData, - opts, - ); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param orders Array of orders to individually simulate transfers for. - * @param takerAddresses Array of addresses of takers that will fill each - * order. - * @param takerAssetFillAmounts Array of amounts of takerAsset that will be - * filled for each order. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - takerAddresses: string[], - takerAssetFillAmounts: BigNumber[], - txData?: Partial | undefined, - ): Promise { - assert.isArray('orders', orders); - assert.isArray('takerAddresses', takerAddresses); - assert.isArray('takerAssetFillAmounts', takerAssetFillAmounts); - const self = (this as any) as DevUtilsContract; - const encodedData = self._strictEncodeArguments( - 'getSimulatedOrdersTransferResults((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],address[],uint256[])', - [orders, takerAddresses, takerAssetFillAmounts], - ); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param orders Array of orders to individually simulate transfers for. - * @param takerAddresses Array of addresses of takers that will fill each - * order. - * @param takerAssetFillAmounts Array of amounts of takerAsset that will be - * filled for each order. - * @returns The indices of the first failed transfer (or 4 if all transfers are successful) for each order. - */ - async callAsync( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - takerAddresses: string[], - takerAssetFillAmounts: BigNumber[], - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isArray('orders', orders); - assert.isArray('takerAddresses', takerAddresses); - assert.isArray('takerAssetFillAmounts', takerAssetFillAmounts); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DevUtilsContract; - const encodedData = self._strictEncodeArguments( - 'getSimulatedOrdersTransferResults((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],address[],uint256[])', - [orders, takerAddresses, takerAssetFillAmounts], - ); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder( - 'getSimulatedOrdersTransferResults((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],address[],uint256[])', - ); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param orders Array of orders to individually simulate transfers for. - * @param takerAddresses Array of addresses of takers that will fill each - * order. - * @param takerAssetFillAmounts Array of amounts of takerAsset that will be - * filled for each order. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - takerAddresses: string[], - takerAssetFillAmounts: BigNumber[], - ): string { - assert.isArray('orders', orders); - assert.isArray('takerAddresses', takerAddresses); - assert.isArray('takerAssetFillAmounts', takerAssetFillAmounts); - const self = (this as any) as DevUtilsContract; - const abiEncodedTransactionData = self._strictEncodeArguments( - 'getSimulatedOrdersTransferResults((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],address[],uint256[])', - [orders, takerAddresses, takerAssetFillAmounts], - ); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as DevUtilsContract; - const abiEncoder = self._lookupAbiEncoder( - 'getSimulatedOrdersTransferResults((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],address[],uint256[])', - ); - return abiEncoder.getSelector(); - }, - }; - /** - * Gets the amount of an asset transferable by the owner. - */ - public getTransferableAssetAmount = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param ownerAddress Address of the owner of the asset. - * @param assetData Description of tokens, per the AssetProxy contract - * specification. - * @returns The amount of the asset tranferable by the owner. NOTE: If the `assetData` encodes data for multiple assets, the `transferableAssetAmount` will represent the amount of times the entire `assetData` can be transferred. To calculate the total individual transferable amounts, this scaled `transferableAmount` must be multiplied by the individual asset amounts located within the `assetData`. - */ - async callAsync( - ownerAddress: string, - assetData: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('ownerAddress', ownerAddress); - assert.isString('assetData', assetData); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DevUtilsContract; - const encodedData = self._strictEncodeArguments('getTransferableAssetAmount(address,bytes)', [ - ownerAddress.toLowerCase(), - assetData, - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('getTransferableAssetAmount(address,bytes)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public static async deployFrom0xArtifactAsync( - artifact: ContractArtifact | SimpleContractArtifact, - supportedProvider: SupportedProvider, - txDefaults: Partial, - logDecodeDependencies: { [contractName: string]: ContractArtifact | SimpleContractArtifact }, - _exchange: string, - ): Promise { - assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (artifact.compilerOutput === undefined) { - throw new Error('Compiler output not found in the artifact file'); - } - const provider = providerUtils.standardizeOrThrow(supportedProvider); - const bytecode = artifact.compilerOutput.evm.bytecode.object; - const abi = artifact.compilerOutput.abi; - const logDecodeDependenciesAbiOnly: { [contractName: string]: ContractAbi } = {}; - if (Object.keys(logDecodeDependencies) !== undefined) { - for (const key of Object.keys(logDecodeDependencies)) { - logDecodeDependenciesAbiOnly[key] = logDecodeDependencies[key].compilerOutput.abi; - } - } - return DevUtilsContract.deployAsync( - bytecode, - abi, - provider, - txDefaults, - logDecodeDependenciesAbiOnly, - _exchange, - ); - } - public static async deployAsync( - bytecode: string, - abi: ContractAbi, - supportedProvider: SupportedProvider, - txDefaults: Partial, - logDecodeDependencies: { [contractName: string]: ContractAbi }, - _exchange: string, - ): Promise { - assert.isHexString('bytecode', bytecode); - assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - const provider = providerUtils.standardizeOrThrow(supportedProvider); - const constructorAbi = BaseContract._lookupConstructorAbi(abi); - [_exchange] = BaseContract._formatABIDataItemList( - constructorAbi.inputs, - [_exchange], - BaseContract._bigNumberToString, - ); - const iface = new ethers.utils.Interface(abi); - const deployInfo = iface.deployFunction; - const txData = deployInfo.encode(bytecode, [_exchange]); - const web3Wrapper = new Web3Wrapper(provider); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { data: txData }, - txDefaults, - web3Wrapper.estimateGasAsync.bind(web3Wrapper), - ); - const txHash = await web3Wrapper.sendTransactionAsync(txDataWithDefaults); - logUtils.log(`transactionHash: ${txHash}`); - const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash); - logUtils.log(`DevUtils successfully deployed at ${txReceipt.contractAddress}`); - const contractInstance = new DevUtilsContract( - txReceipt.contractAddress as string, - provider, - txDefaults, - logDecodeDependencies, - ); - contractInstance.constructorArgs = [_exchange]; - return contractInstance; - } - - /** - * @returns The contract ABI + * @returns The contract ABI */ public static ABI(): ContractAbi { const abi = [ @@ -3262,42 +853,237 @@ export class DevUtilsContract extends BaseContract { type: 'address', }, { - name: 'assetData', + name: 'assetData', + type: 'bytes', + }, + ], + name: 'getBalance', + outputs: [ + { + name: 'balance', + type: 'uint256', + }, + ], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: true, + inputs: [ + { + name: 'ownerAddress', + type: 'address', + }, + { + name: 'assetData', + type: 'bytes', + }, + ], + name: 'getBalanceAndAssetProxyAllowance', + outputs: [ + { + name: 'balance', + type: 'uint256', + }, + { + name: 'allowance', + type: 'uint256', + }, + ], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: true, + inputs: [ + { + name: 'ownerAddress', + type: 'address', + }, + { + name: 'assetData', + type: 'bytes[]', + }, + ], + name: 'getBatchAssetProxyAllowances', + outputs: [ + { + name: 'allowances', + type: 'uint256[]', + }, + ], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: true, + inputs: [ + { + name: 'ownerAddress', + type: 'address', + }, + { + name: 'assetData', + type: 'bytes[]', + }, + ], + name: 'getBatchBalances', + outputs: [ + { + name: 'balances', + type: 'uint256[]', + }, + ], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: true, + inputs: [ + { + name: 'ownerAddress', + type: 'address', + }, + { + name: 'assetData', + type: 'bytes[]', + }, + ], + name: 'getBatchBalancesAndAssetProxyAllowances', + outputs: [ + { + name: 'balances', + type: 'uint256[]', + }, + { + name: 'allowances', + type: 'uint256[]', + }, + ], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: true, + inputs: [ + { + name: 'addresses', + type: 'address[]', + }, + ], + name: 'getEthBalances', + outputs: [ + { + name: '', + type: 'uint256[]', + }, + ], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: true, + inputs: [ + { + name: 'order', + type: 'tuple', + components: [ + { + name: 'makerAddress', + type: 'address', + }, + { + name: 'takerAddress', + type: 'address', + }, + { + name: 'feeRecipientAddress', + type: 'address', + }, + { + name: 'senderAddress', + type: 'address', + }, + { + name: 'makerAssetAmount', + type: 'uint256', + }, + { + name: 'takerAssetAmount', + type: 'uint256', + }, + { + name: 'makerFee', + type: 'uint256', + }, + { + name: 'takerFee', + type: 'uint256', + }, + { + name: 'expirationTimeSeconds', + type: 'uint256', + }, + { + name: 'salt', + type: 'uint256', + }, + { + name: 'makerAssetData', + type: 'bytes', + }, + { + name: 'takerAssetData', + type: 'bytes', + }, + { + name: 'makerFeeAssetData', + type: 'bytes', + }, + { + name: 'takerFeeAssetData', + type: 'bytes', + }, + ], + }, + { + name: 'signature', type: 'bytes', }, ], - name: 'getBalance', + name: 'getOrderRelevantState', outputs: [ { - name: 'balance', - type: 'uint256', - }, - ], - payable: false, - stateMutability: 'view', - type: 'function', - }, - { - constant: true, - inputs: [ - { - name: 'ownerAddress', - type: 'address', - }, - { - name: 'assetData', - type: 'bytes', + name: 'orderInfo', + type: 'tuple', + components: [ + { + name: 'orderStatus', + type: 'uint8', + }, + { + name: 'orderHash', + type: 'bytes32', + }, + { + name: 'orderTakerAssetFilledAmount', + type: 'uint256', + }, + ], }, - ], - name: 'getBalanceAndAssetProxyAllowance', - outputs: [ { - name: 'balance', + name: 'fillableTakerAssetAmount', type: 'uint256', }, { - name: 'allowance', - type: 'uint256', + name: 'isValidSignature', + type: 'bool', }, ], payable: false, @@ -3308,42 +1094,99 @@ export class DevUtilsContract extends BaseContract { constant: true, inputs: [ { - name: 'ownerAddress', - type: 'address', + name: 'orders', + type: 'tuple[]', + components: [ + { + name: 'makerAddress', + type: 'address', + }, + { + name: 'takerAddress', + type: 'address', + }, + { + name: 'feeRecipientAddress', + type: 'address', + }, + { + name: 'senderAddress', + type: 'address', + }, + { + name: 'makerAssetAmount', + type: 'uint256', + }, + { + name: 'takerAssetAmount', + type: 'uint256', + }, + { + name: 'makerFee', + type: 'uint256', + }, + { + name: 'takerFee', + type: 'uint256', + }, + { + name: 'expirationTimeSeconds', + type: 'uint256', + }, + { + name: 'salt', + type: 'uint256', + }, + { + name: 'makerAssetData', + type: 'bytes', + }, + { + name: 'takerAssetData', + type: 'bytes', + }, + { + name: 'makerFeeAssetData', + type: 'bytes', + }, + { + name: 'takerFeeAssetData', + type: 'bytes', + }, + ], }, { - name: 'assetData', + name: 'signatures', type: 'bytes[]', }, ], - name: 'getBatchAssetProxyAllowances', + name: 'getOrderRelevantStates', outputs: [ { - name: 'allowances', - type: 'uint256[]', - }, - ], - payable: false, - stateMutability: 'view', - type: 'function', - }, - { - constant: true, - inputs: [ - { - name: 'ownerAddress', - type: 'address', + name: 'ordersInfo', + type: 'tuple[]', + components: [ + { + name: 'orderStatus', + type: 'uint8', + }, + { + name: 'orderHash', + type: 'bytes32', + }, + { + name: 'orderTakerAssetFilledAmount', + type: 'uint256', + }, + ], }, { - name: 'assetData', - type: 'bytes[]', + name: 'fillableTakerAssetAmounts', + type: 'uint256[]', }, - ], - name: 'getBatchBalances', - outputs: [ { - name: 'balances', - type: 'uint256[]', + name: 'isValidSignature', + type: 'bool[]', }, ], payable: false, @@ -3351,57 +1194,96 @@ export class DevUtilsContract extends BaseContract { type: 'function', }, { - constant: true, + constant: false, inputs: [ { - name: 'ownerAddress', - type: 'address', - }, - { - name: 'assetData', - type: 'bytes[]', - }, - ], - name: 'getBatchBalancesAndAssetProxyAllowances', - outputs: [ - { - name: 'balances', - type: 'uint256[]', + name: 'order', + type: 'tuple', + components: [ + { + name: 'makerAddress', + type: 'address', + }, + { + name: 'takerAddress', + type: 'address', + }, + { + name: 'feeRecipientAddress', + type: 'address', + }, + { + name: 'senderAddress', + type: 'address', + }, + { + name: 'makerAssetAmount', + type: 'uint256', + }, + { + name: 'takerAssetAmount', + type: 'uint256', + }, + { + name: 'makerFee', + type: 'uint256', + }, + { + name: 'takerFee', + type: 'uint256', + }, + { + name: 'expirationTimeSeconds', + type: 'uint256', + }, + { + name: 'salt', + type: 'uint256', + }, + { + name: 'makerAssetData', + type: 'bytes', + }, + { + name: 'takerAssetData', + type: 'bytes', + }, + { + name: 'makerFeeAssetData', + type: 'bytes', + }, + { + name: 'takerFeeAssetData', + type: 'bytes', + }, + ], }, { - name: 'allowances', - type: 'uint256[]', + name: 'takerAddress', + type: 'address', }, - ], - payable: false, - stateMutability: 'view', - type: 'function', - }, - { - constant: true, - inputs: [ { - name: 'addresses', - type: 'address[]', + name: 'takerAssetFillAmount', + type: 'uint256', }, ], - name: 'getEthBalances', + name: 'getSimulatedOrderTransferResults', outputs: [ { - name: '', - type: 'uint256[]', + name: 'orderTransferResults', + type: 'uint8', }, ], payable: false, - stateMutability: 'view', + stateMutability: 'nonpayable', type: 'function', }, { - constant: true, + constant: false, inputs: [ { - name: 'order', - type: 'tuple', + name: 'orders', + type: 'tuple[]', components: [ { name: 'makerAddress', @@ -3462,342 +1344,2306 @@ export class DevUtilsContract extends BaseContract { ], }, { - name: 'signature', - type: 'bytes', + name: 'takerAddresses', + type: 'address[]', + }, + { + name: 'takerAssetFillAmounts', + type: 'uint256[]', }, ], - name: 'getOrderRelevantState', + name: 'getSimulatedOrdersTransferResults', outputs: [ { - name: 'orderInfo', - type: 'tuple', - components: [ - { - name: 'orderStatus', - type: 'uint8', - }, - { - name: 'orderHash', - type: 'bytes32', - }, - { - name: 'orderTakerAssetFilledAmount', - type: 'uint256', - }, - ], + name: 'orderTransferResults', + type: 'uint8[]', }, + ], + payable: false, + stateMutability: 'nonpayable', + type: 'function', + }, + { + constant: true, + inputs: [ { - name: 'fillableTakerAssetAmount', - type: 'uint256', + name: 'ownerAddress', + type: 'address', }, { - name: 'isValidSignature', - type: 'bool', + name: 'assetData', + type: 'bytes', + }, + ], + name: 'getTransferableAssetAmount', + outputs: [ + { + name: 'transferableAssetAmount', + type: 'uint256', }, ], payable: false, stateMutability: 'view', type: 'function', }, - { - constant: true, - inputs: [ - { - name: 'orders', - type: 'tuple[]', - components: [ - { - name: 'makerAddress', - type: 'address', - }, - { - name: 'takerAddress', - type: 'address', - }, - { - name: 'feeRecipientAddress', - type: 'address', - }, - { - name: 'senderAddress', - type: 'address', - }, - { - name: 'makerAssetAmount', - type: 'uint256', - }, - { - name: 'takerAssetAmount', - type: 'uint256', - }, - { - name: 'makerFee', - type: 'uint256', - }, - { - name: 'takerFee', - type: 'uint256', - }, - { - name: 'expirationTimeSeconds', - type: 'uint256', - }, - { - name: 'salt', - type: 'uint256', - }, - { - name: 'makerAssetData', - type: 'bytes', - }, - { - name: 'takerAssetData', - type: 'bytes', - }, - { - name: 'makerFeeAssetData', - type: 'bytes', - }, - { - name: 'takerFeeAssetData', - type: 'bytes', - }, - ], - }, - { - name: 'signatures', - type: 'bytes[]', - }, - ], - name: 'getOrderRelevantStates', - outputs: [ - { - name: 'ordersInfo', - type: 'tuple[]', - components: [ - { - name: 'orderStatus', - type: 'uint8', - }, - { - name: 'orderHash', - type: 'bytes32', - }, - { - name: 'orderTakerAssetFilledAmount', - type: 'uint256', - }, - ], - }, + ] as ContractAbi; + return abi; + } + + public getFunctionSignature(methodName: string): string { + const index = this._methodABIIndex[methodName]; + const methodAbi = DevUtilsContract.ABI()[index] as MethodAbi; + const functionSignature = methodAbiToFunctionSignature(methodAbi); + return functionSignature; + } + public getABIDecodedTransactionData(methodName: string, callData: string): T { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as DevUtilsContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + const abiDecodedCallData = abiEncoder.strictDecode(callData); + return abiDecodedCallData; + } + public getABIDecodedReturnData(methodName: string, callData: string): T { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as DevUtilsContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + const abiDecodedCallData = abiEncoder.strictDecodeReturnValue(callData); + return abiDecodedCallData; + } + public getSelector(methodName: string): string { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as DevUtilsContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + return abiEncoder.getSelector(); + } + + /** + * Decompose an ABI-encoded AssetProxyDispatchError. + * @param encoded ABI-encoded revert error. + * @returns errorCode The error code.orderHash Hash of the order being dispatched.assetData Asset data of the order being dispatched. + */ + public decodeAssetProxyDispatchError(encoded: string): ContractFunctionObj<[number, string, string]> { + const self = (this as any) as DevUtilsContract; + assert.isString('encoded', encoded); + + return { + async callAsync( + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise<[number, string, string]> { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('decodeAssetProxyDispatchError(bytes)', [encoded]); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('decodeAssetProxyDispatchError(bytes)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<[number, string, string]>(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('decodeAssetProxyDispatchError(bytes)', [ + encoded, + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Decompose an ABI-encoded AssetProxyExistsError. + * @param encoded ABI-encoded revert error. + * @returns assetProxyId Id of asset proxy.assetProxyAddress The address of the asset proxy. + */ + public decodeAssetProxyExistsError(encoded: string): ContractFunctionObj<[string, string]> { + const self = (this as any) as DevUtilsContract; + assert.isString('encoded', encoded); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise<[string, string]> { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('decodeAssetProxyExistsError(bytes)', [encoded]); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('decodeAssetProxyExistsError(bytes)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<[string, string]>(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('decodeAssetProxyExistsError(bytes)', [ + encoded, + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Decompose an ABI-encoded AssetProxyTransferError. + * @param encoded ABI-encoded revert error. + * @returns orderHash Hash of the order being dispatched.assetData Asset data of the order being dispatched.errorData ABI-encoded revert data from the asset proxy. + */ + public decodeAssetProxyTransferError(encoded: string): ContractFunctionObj<[string, string, string]> { + const self = (this as any) as DevUtilsContract; + assert.isString('encoded', encoded); + + return { + async callAsync( + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise<[string, string, string]> { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('decodeAssetProxyTransferError(bytes)', [encoded]); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('decodeAssetProxyTransferError(bytes)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<[string, string, string]>(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('decodeAssetProxyTransferError(bytes)', [ + encoded, + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Decompose an ABI-encoded SignatureValidatorError. + * @param encoded ABI-encoded revert error. + * @returns signerAddress The expected signer of the hash.signature The full signature bytes.errorData The revert data thrown by the validator contract. + */ + public decodeEIP1271SignatureError(encoded: string): ContractFunctionObj<[string, string, string, string]> { + const self = (this as any) as DevUtilsContract; + assert.isString('encoded', encoded); + + return { + async callAsync( + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise<[string, string, string, string]> { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('decodeEIP1271SignatureError(bytes)', [encoded]); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('decodeEIP1271SignatureError(bytes)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<[string, string, string, string]>(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('decodeEIP1271SignatureError(bytes)', [ + encoded, + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Decode ERC-1155 asset data from the format described in the AssetProxy contract specification. + * @param assetData AssetProxy-compliant asset data describing an ERC-1155 set + * of assets. + * @returns The ERC-1155 AssetProxy identifier, the address of the ERC-1155 contract hosting the assets, an array of the identifiers of the assets to be traded, an array of asset amounts to be traded, and callback data. Each element of the arrays corresponds to the same-indexed element of the other array. Return values specified as `memory` are returned as pointers to locations within the memory of the input parameter `assetData`. + */ + public decodeERC1155AssetData( + assetData: string, + ): ContractFunctionObj<[string, string, BigNumber[], BigNumber[], string]> { + const self = (this as any) as DevUtilsContract; + assert.isString('assetData', assetData); + + return { + async callAsync( + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise<[string, string, BigNumber[], BigNumber[], string]> { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('decodeERC1155AssetData(bytes)', [assetData]); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('decodeERC1155AssetData(bytes)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<[string, string, BigNumber[], BigNumber[], string]>( + rawCallResult, + ); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('decodeERC1155AssetData(bytes)', [ + assetData, + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Decode ERC-20 asset data from the format described in the AssetProxy contract specification. + * @param assetData AssetProxy-compliant asset data describing an ERC-20 asset. + * @returns The ERC-20 AssetProxy identifier, and the address of the ERC-20 contract hosting this asset. + */ + public decodeERC20AssetData(assetData: string): ContractFunctionObj<[string, string]> { + const self = (this as any) as DevUtilsContract; + assert.isString('assetData', assetData); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise<[string, string]> { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('decodeERC20AssetData(bytes)', [assetData]); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('decodeERC20AssetData(bytes)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<[string, string]>(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('decodeERC20AssetData(bytes)', [ + assetData, + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Decode ERC-721 asset data from the format described in the AssetProxy contract specification. + * @param assetData AssetProxy-compliant asset data describing an ERC-721 + * asset. + * @returns The ERC-721 AssetProxy identifier, the address of the ERC-721 contract hosting this asset, and the identifier of the specific asset to be traded. + */ + public decodeERC721AssetData(assetData: string): ContractFunctionObj<[string, string, BigNumber]> { + const self = (this as any) as DevUtilsContract; + assert.isString('assetData', assetData); + + return { + async callAsync( + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise<[string, string, BigNumber]> { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('decodeERC721AssetData(bytes)', [assetData]); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('decodeERC721AssetData(bytes)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<[string, string, BigNumber]>(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('decodeERC721AssetData(bytes)', [ + assetData, + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Decompose an ABI-encoded OrderStatusError. + * @param encoded ABI-encoded revert error. + * @returns errorCode Error code that corresponds to invalid maker, taker, or sender.orderHash The order hash.contextAddress The maker, taker, or sender address + */ + public decodeExchangeInvalidContextError(encoded: string): ContractFunctionObj<[number, string, string]> { + const self = (this as any) as DevUtilsContract; + assert.isString('encoded', encoded); + + return { + async callAsync( + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise<[number, string, string]> { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('decodeExchangeInvalidContextError(bytes)', [encoded]); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('decodeExchangeInvalidContextError(bytes)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<[number, string, string]>(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'decodeExchangeInvalidContextError(bytes)', + [encoded], + ); + return abiEncodedTransactionData; + }, + }; + } + /** + * Decompose an ABI-encoded FillError. + * @param encoded ABI-encoded revert error. + * @returns errorCode The error code.orderHash The order hash. + */ + public decodeFillError(encoded: string): ContractFunctionObj<[number, string]> { + const self = (this as any) as DevUtilsContract; + assert.isString('encoded', encoded); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise<[number, string]> { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('decodeFillError(bytes)', [encoded]); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('decodeFillError(bytes)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<[number, string]>(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('decodeFillError(bytes)', [encoded]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Decompose an ABI-encoded IncompleteFillError. + * @param encoded ABI-encoded revert error. + * @returns orderHash Hash of the order being filled. + */ + public decodeIncompleteFillError(encoded: string): ContractFunctionObj<[number, BigNumber, BigNumber]> { + const self = (this as any) as DevUtilsContract; + assert.isString('encoded', encoded); + + return { + async callAsync( + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise<[number, BigNumber, BigNumber]> { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('decodeIncompleteFillError(bytes)', [encoded]); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('decodeIncompleteFillError(bytes)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<[number, BigNumber, BigNumber]>(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('decodeIncompleteFillError(bytes)', [ + encoded, + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Decode multi-asset data from the format described in the AssetProxy contract specification. + * @param assetData AssetProxy-compliant data describing a multi-asset basket. + * @returns The Multi-Asset AssetProxy identifier, an array of the amounts of the assets to be traded, and an array of the AssetProxy-compliant data describing each asset to be traded. Each element of the arrays corresponds to the same-indexed element of the other array. + */ + public decodeMultiAssetData(assetData: string): ContractFunctionObj<[string, BigNumber[], string[]]> { + const self = (this as any) as DevUtilsContract; + assert.isString('assetData', assetData); + + return { + async callAsync( + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise<[string, BigNumber[], string[]]> { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('decodeMultiAssetData(bytes)', [assetData]); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('decodeMultiAssetData(bytes)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<[string, BigNumber[], string[]]>(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('decodeMultiAssetData(bytes)', [ + assetData, + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Decompose an ABI-encoded NegativeSpreadError. + * @param encoded ABI-encoded revert error. + * @returns leftOrderHash Hash of the left order being matched.rightOrderHash Hash of the right order being matched. + */ + public decodeNegativeSpreadError(encoded: string): ContractFunctionObj<[string, string]> { + const self = (this as any) as DevUtilsContract; + assert.isString('encoded', encoded); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise<[string, string]> { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('decodeNegativeSpreadError(bytes)', [encoded]); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('decodeNegativeSpreadError(bytes)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<[string, string]>(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('decodeNegativeSpreadError(bytes)', [ + encoded, + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Decompose an ABI-encoded OrderEpochError. + * @param encoded ABI-encoded revert error. + * @returns makerAddress The order maker.orderSenderAddress The order sender.currentEpoch The current epoch for the maker. + */ + public decodeOrderEpochError(encoded: string): ContractFunctionObj<[string, string, BigNumber]> { + const self = (this as any) as DevUtilsContract; + assert.isString('encoded', encoded); + + return { + async callAsync( + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise<[string, string, BigNumber]> { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('decodeOrderEpochError(bytes)', [encoded]); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('decodeOrderEpochError(bytes)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<[string, string, BigNumber]>(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('decodeOrderEpochError(bytes)', [ + encoded, + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Decompose an ABI-encoded OrderStatusError. + * @param encoded ABI-encoded revert error. + * @returns orderHash The order hash.orderStatus The order status. + */ + public decodeOrderStatusError(encoded: string): ContractFunctionObj<[string, number]> { + const self = (this as any) as DevUtilsContract; + assert.isString('encoded', encoded); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise<[string, number]> { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('decodeOrderStatusError(bytes)', [encoded]); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('decodeOrderStatusError(bytes)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<[string, number]>(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('decodeOrderStatusError(bytes)', [ + encoded, + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Decompose an ABI-encoded SignatureError. + * @param encoded ABI-encoded revert error. + * @returns errorCode The error code.signerAddress The expected signer of the hash.signature The full signature. + */ + public decodeSignatureError(encoded: string): ContractFunctionObj<[number, string, string, string]> { + const self = (this as any) as DevUtilsContract; + assert.isString('encoded', encoded); + + return { + async callAsync( + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise<[number, string, string, string]> { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('decodeSignatureError(bytes)', [encoded]); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('decodeSignatureError(bytes)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<[number, string, string, string]>(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('decodeSignatureError(bytes)', [encoded]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Decompose an ABI-encoded SignatureValidatorNotApprovedError. + * @param encoded ABI-encoded revert error. + * @returns signerAddress The expected signer of the hash.validatorAddress The expected validator. + */ + public decodeSignatureValidatorNotApprovedError(encoded: string): ContractFunctionObj<[string, string]> { + const self = (this as any) as DevUtilsContract; + assert.isString('encoded', encoded); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise<[string, string]> { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('decodeSignatureValidatorNotApprovedError(bytes)', [ + encoded, + ]); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('decodeSignatureValidatorNotApprovedError(bytes)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<[string, string]>(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'decodeSignatureValidatorNotApprovedError(bytes)', + [encoded], + ); + return abiEncodedTransactionData; + }, + }; + } + /** + * Decompose an ABI-encoded SignatureWalletError. + * @param encoded ABI-encoded revert error. + * @returns errorCode The error code.signerAddress The expected signer of the hash.signature The full signature bytes.errorData The revert data thrown by the validator contract. + */ + public decodeSignatureWalletError(encoded: string): ContractFunctionObj<[string, string, string, string]> { + const self = (this as any) as DevUtilsContract; + assert.isString('encoded', encoded); + + return { + async callAsync( + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise<[string, string, string, string]> { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('decodeSignatureWalletError(bytes)', [encoded]); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('decodeSignatureWalletError(bytes)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<[string, string, string, string]>(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('decodeSignatureWalletError(bytes)', [ + encoded, + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Decompose an ABI-encoded TransactionError. + * @param encoded ABI-encoded revert error. + * @returns errorCode The error code.transactionHash Hash of the transaction. + */ + public decodeTransactionError(encoded: string): ContractFunctionObj<[number, string]> { + const self = (this as any) as DevUtilsContract; + assert.isString('encoded', encoded); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise<[number, string]> { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('decodeTransactionError(bytes)', [encoded]); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('decodeTransactionError(bytes)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<[number, string]>(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('decodeTransactionError(bytes)', [ + encoded, + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Decompose an ABI-encoded TransactionExecutionError. + * @param encoded ABI-encoded revert error. + * @returns transactionHash Hash of the transaction.errorData Error thrown by exeucteTransaction(). + */ + public decodeTransactionExecutionError(encoded: string): ContractFunctionObj<[string, string]> { + const self = (this as any) as DevUtilsContract; + assert.isString('encoded', encoded); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise<[string, string]> { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('decodeTransactionExecutionError(bytes)', [encoded]); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('decodeTransactionExecutionError(bytes)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<[string, string]>(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'decodeTransactionExecutionError(bytes)', + [encoded], + ); + return abiEncodedTransactionData; + }, + }; + } + /** + * Decodes the call data for an Exchange contract method call. + * @param transactionData ABI-encoded calldata for an Exchange contract + * method call. + * @returns The name of the function called, and the parameters it was given. For single-order fills and cancels, the arrays will have just one element. + */ + public decodeZeroExTransactionData( + transactionData: string, + ): ContractFunctionObj< + [ + string, + Array<{ + makerAddress: string; + takerAddress: string; + feeRecipientAddress: string; + senderAddress: string; + makerAssetAmount: BigNumber; + takerAssetAmount: BigNumber; + makerFee: BigNumber; + takerFee: BigNumber; + expirationTimeSeconds: BigNumber; + salt: BigNumber; + makerAssetData: string; + takerAssetData: string; + makerFeeAssetData: string; + takerFeeAssetData: string; + }>, + BigNumber[], + string[] + ] + > { + const self = (this as any) as DevUtilsContract; + assert.isString('transactionData', transactionData); + + return { + async callAsync( + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise< + [ + string, + Array<{ + makerAddress: string; + takerAddress: string; + feeRecipientAddress: string; + senderAddress: string; + makerAssetAmount: BigNumber; + takerAssetAmount: BigNumber; + makerFee: BigNumber; + takerFee: BigNumber; + expirationTimeSeconds: BigNumber; + salt: BigNumber; + makerAssetData: string; + takerAssetData: string; + makerFeeAssetData: string; + takerFeeAssetData: string; + }>, + BigNumber[], + string[] + ] + > { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('decodeZeroExTransactionData(bytes)', [ + transactionData, + ]); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('decodeZeroExTransactionData(bytes)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue< + [ + string, + Array<{ + makerAddress: string; + takerAddress: string; + feeRecipientAddress: string; + senderAddress: string; + makerAssetAmount: BigNumber; + takerAssetAmount: BigNumber; + makerFee: BigNumber; + takerFee: BigNumber; + expirationTimeSeconds: BigNumber; + salt: BigNumber; + makerAssetData: string; + takerAssetData: string; + makerFeeAssetData: string; + takerFeeAssetData: string; + }>, + BigNumber[], + string[] + ] + >(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('decodeZeroExTransactionData(bytes)', [ + transactionData, + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Encode ERC-1155 asset data into the format described in the AssetProxy contract specification. + * @param tokenAddress The address of the ERC-1155 contract hosting the + * asset(s) to be traded. + * @param tokenIds The identifiers of the specific assets to be traded. + * @param tokenValues The amounts of each asset to be traded. + * @param callbackData Data to be passed to receiving contracts when a transfer + * is performed. + * @returns AssetProxy-compliant asset data describing the set of assets. + */ + public encodeERC1155AssetData( + tokenAddress: string, + tokenIds: BigNumber[], + tokenValues: BigNumber[], + callbackData: string, + ): ContractFunctionObj { + const self = (this as any) as DevUtilsContract; + assert.isString('tokenAddress', tokenAddress); + assert.isArray('tokenIds', tokenIds); + assert.isArray('tokenValues', tokenValues); + assert.isString('callbackData', callbackData); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments( + 'encodeERC1155AssetData(address,uint256[],uint256[],bytes)', + [tokenAddress.toLowerCase(), tokenIds, tokenValues, callbackData], + ); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('encodeERC1155AssetData(address,uint256[],uint256[],bytes)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'encodeERC1155AssetData(address,uint256[],uint256[],bytes)', + [tokenAddress.toLowerCase(), tokenIds, tokenValues, callbackData], + ); + return abiEncodedTransactionData; + }, + }; + } + /** + * Encode ERC-20 asset data into the format described in the AssetProxy contract specification. + * @param tokenAddress The address of the ERC-20 contract hosting the asset to + * be traded. + * @returns AssetProxy-compliant data describing the asset. + */ + public encodeERC20AssetData(tokenAddress: string): ContractFunctionObj { + const self = (this as any) as DevUtilsContract; + assert.isString('tokenAddress', tokenAddress); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('encodeERC20AssetData(address)', [ + tokenAddress.toLowerCase(), + ]); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('encodeERC20AssetData(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('encodeERC20AssetData(address)', [ + tokenAddress.toLowerCase(), + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Encode ERC-721 asset data into the format described in the AssetProxy specification. + * @param tokenAddress The address of the ERC-721 contract hosting the asset to + * be traded. + * @param tokenId The identifier of the specific asset to be traded. + * @returns AssetProxy-compliant asset data describing the asset. + */ + public encodeERC721AssetData(tokenAddress: string, tokenId: BigNumber): ContractFunctionObj { + const self = (this as any) as DevUtilsContract; + assert.isString('tokenAddress', tokenAddress); + assert.isBigNumber('tokenId', tokenId); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('encodeERC721AssetData(address,uint256)', [ + tokenAddress.toLowerCase(), + tokenId, + ]); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('encodeERC721AssetData(address,uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'encodeERC721AssetData(address,uint256)', + [tokenAddress.toLowerCase(), tokenId], + ); + return abiEncodedTransactionData; + }, + }; + } + /** + * Encode data for multiple assets, per the AssetProxy contract specification. + * @param amounts The amounts of each asset to be traded. + * @param nestedAssetData AssetProxy-compliant data describing each asset to be + * traded. + * @returns AssetProxy-compliant data describing the set of assets. + */ + public encodeMultiAssetData(amounts: BigNumber[], nestedAssetData: string[]): ContractFunctionObj { + const self = (this as any) as DevUtilsContract; + assert.isArray('amounts', amounts); + assert.isArray('nestedAssetData', nestedAssetData); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('encodeMultiAssetData(uint256[],bytes[])', [ + amounts, + nestedAssetData, + ]); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('encodeMultiAssetData(uint256[],bytes[])'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'encodeMultiAssetData(uint256[],bytes[])', + [amounts, nestedAssetData], + ); + return abiEncodedTransactionData; + }, + }; + } + /** + * Returns the number of asset(s) (described by assetData) that the corresponding AssetProxy contract is authorized to spend. When the asset data contains multiple assets (eg for Multi-Asset), the return value indicates how many complete "baskets" of those assets may be spent by all of the corresponding AssetProxy contracts. + * @param ownerAddress Owner of the assets specified by assetData. + * @param assetData Details of asset, encoded per the AssetProxy contract + * specification. + * @returns Number of assets (or asset baskets) that the corresponding AssetProxy is authorized to spend. + */ + public getAssetProxyAllowance(ownerAddress: string, assetData: string): ContractFunctionObj { + const self = (this as any) as DevUtilsContract; + assert.isString('ownerAddress', ownerAddress); + assert.isString('assetData', assetData); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('getAssetProxyAllowance(address,bytes)', [ + ownerAddress.toLowerCase(), + assetData, + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'fillableTakerAssetAmounts', - type: 'uint256[]', + to: self.address, + ...callData, + data: encodedData, }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('getAssetProxyAllowance(address,bytes)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('getAssetProxyAllowance(address,bytes)', [ + ownerAddress.toLowerCase(), + assetData, + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Returns the owner's balance of the assets(s) specified in assetData. When the asset data contains multiple assets (eg in ERC1155 or Multi-Asset), the return value indicates how many complete "baskets" of those assets are owned by owner. + * @param ownerAddress Owner of the assets specified by assetData. + * @param assetData Details of asset, encoded per the AssetProxy contract + * specification. + * @returns Number of assets (or asset baskets) held by owner. + */ + public getBalance(ownerAddress: string, assetData: string): ContractFunctionObj { + const self = (this as any) as DevUtilsContract; + assert.isString('ownerAddress', ownerAddress); + assert.isString('assetData', assetData); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('getBalance(address,bytes)', [ + ownerAddress.toLowerCase(), + assetData, + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'isValidSignature', - type: 'bool[]', + to: self.address, + ...callData, + data: encodedData, }, - ], - payable: false, - stateMutability: 'view', - type: 'function', + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('getBalance(address,bytes)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; }, - { - constant: false, - inputs: [ - { - name: 'order', - type: 'tuple', - components: [ - { - name: 'makerAddress', - type: 'address', - }, - { - name: 'takerAddress', - type: 'address', - }, - { - name: 'feeRecipientAddress', - type: 'address', - }, - { - name: 'senderAddress', - type: 'address', - }, - { - name: 'makerAssetAmount', - type: 'uint256', - }, - { - name: 'takerAssetAmount', - type: 'uint256', - }, - { - name: 'makerFee', - type: 'uint256', - }, - { - name: 'takerFee', - type: 'uint256', - }, - { - name: 'expirationTimeSeconds', - type: 'uint256', - }, - { - name: 'salt', - type: 'uint256', - }, - { - name: 'makerAssetData', - type: 'bytes', - }, - { - name: 'takerAssetData', - type: 'bytes', - }, - { - name: 'makerFeeAssetData', - type: 'bytes', - }, - { - name: 'takerFeeAssetData', - type: 'bytes', - }, - ], + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('getBalance(address,bytes)', [ + ownerAddress.toLowerCase(), + assetData, + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Calls getBalance() and getAllowance() for assetData. + * @param ownerAddress Owner of the assets specified by assetData. + * @param assetData Details of asset, encoded per the AssetProxy contract + * specification. + * @returns Number of assets (or asset baskets) held by owner, and number of assets (or asset baskets) that the corresponding AssetProxy is authorized to spend. + */ + public getBalanceAndAssetProxyAllowance( + ownerAddress: string, + assetData: string, + ): ContractFunctionObj<[BigNumber, BigNumber]> { + const self = (this as any) as DevUtilsContract; + assert.isString('ownerAddress', ownerAddress); + assert.isString('assetData', assetData); + + return { + async callAsync( + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise<[BigNumber, BigNumber]> { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('getBalanceAndAssetProxyAllowance(address,bytes)', [ + ownerAddress.toLowerCase(), + assetData, + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('getBalanceAndAssetProxyAllowance(address,bytes)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<[BigNumber, BigNumber]>(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'getBalanceAndAssetProxyAllowance(address,bytes)', + [ownerAddress.toLowerCase(), assetData], + ); + return abiEncodedTransactionData; + }, + }; + } + /** + * Calls getAssetProxyAllowance() for each element of assetData. + * @param ownerAddress Owner of the assets specified by assetData. + * @param assetData Array of asset details, each encoded per the AssetProxy + * contract specification. + * @returns An array of asset allowances from getAllowance(), with each element corresponding to the same-indexed element in the assetData input. + */ + public getBatchAssetProxyAllowances(ownerAddress: string, assetData: string[]): ContractFunctionObj { + const self = (this as any) as DevUtilsContract; + assert.isString('ownerAddress', ownerAddress); + assert.isArray('assetData', assetData); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('getBatchAssetProxyAllowances(address,bytes[])', [ + ownerAddress.toLowerCase(), + assetData, + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'takerAddress', - type: 'address', + to: self.address, + ...callData, + data: encodedData, }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('getBatchAssetProxyAllowances(address,bytes[])'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'getBatchAssetProxyAllowances(address,bytes[])', + [ownerAddress.toLowerCase(), assetData], + ); + return abiEncodedTransactionData; + }, + }; + } + /** + * Calls getBalance() for each element of assetData. + * @param ownerAddress Owner of the assets specified by assetData. + * @param assetData Array of asset details, each encoded per the AssetProxy + * contract specification. + * @returns Array of asset balances from getBalance(), with each element corresponding to the same-indexed element in the assetData input. + */ + public getBatchBalances(ownerAddress: string, assetData: string[]): ContractFunctionObj { + const self = (this as any) as DevUtilsContract; + assert.isString('ownerAddress', ownerAddress); + assert.isArray('assetData', assetData); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('getBatchBalances(address,bytes[])', [ + ownerAddress.toLowerCase(), + assetData, + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'takerAssetFillAmount', - type: 'uint256', + to: self.address, + ...callData, + data: encodedData, }, - ], - name: 'getSimulatedOrderTransferResults', - outputs: [ + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('getBatchBalances(address,bytes[])'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('getBatchBalances(address,bytes[])', [ + ownerAddress.toLowerCase(), + assetData, + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Calls getBatchBalances() and getBatchAllowances() for each element of assetData. + * @param ownerAddress Owner of the assets specified by assetData. + * @param assetData Array of asset details, each encoded per the AssetProxy + * contract specification. + * @returns An array of asset balances from getBalance(), and an array of asset allowances from getAllowance(), with each element corresponding to the same-indexed element in the assetData input. + */ + public getBatchBalancesAndAssetProxyAllowances( + ownerAddress: string, + assetData: string[], + ): ContractFunctionObj<[BigNumber[], BigNumber[]]> { + const self = (this as any) as DevUtilsContract; + assert.isString('ownerAddress', ownerAddress); + assert.isArray('assetData', assetData); + + return { + async callAsync( + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise<[BigNumber[], BigNumber[]]> { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments( + 'getBatchBalancesAndAssetProxyAllowances(address,bytes[])', + [ownerAddress.toLowerCase(), assetData], + ); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'orderTransferResults', - type: 'uint8', + to: self.address, + ...callData, + data: encodedData, }, - ], - payable: false, - stateMutability: 'nonpayable', - type: 'function', + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('getBatchBalancesAndAssetProxyAllowances(address,bytes[])'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<[BigNumber[], BigNumber[]]>(rawCallResult); + // tslint:enable boolean-naming + return result; }, - { - constant: false, - inputs: [ + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'getBatchBalancesAndAssetProxyAllowances(address,bytes[])', + [ownerAddress.toLowerCase(), assetData], + ); + return abiEncodedTransactionData; + }, + }; + } + /** + * Batch fetches ETH balances + * @param addresses Array of addresses. + * @returns Array of ETH balances. + */ + public getEthBalances(addresses: string[]): ContractFunctionObj { + const self = (this as any) as DevUtilsContract; + assert.isArray('addresses', addresses); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('getEthBalances(address[])', [addresses]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'orders', - type: 'tuple[]', - components: [ - { - name: 'makerAddress', - type: 'address', - }, - { - name: 'takerAddress', - type: 'address', - }, - { - name: 'feeRecipientAddress', - type: 'address', - }, - { - name: 'senderAddress', - type: 'address', - }, - { - name: 'makerAssetAmount', - type: 'uint256', - }, - { - name: 'takerAssetAmount', - type: 'uint256', - }, - { - name: 'makerFee', - type: 'uint256', - }, - { - name: 'takerFee', - type: 'uint256', - }, - { - name: 'expirationTimeSeconds', - type: 'uint256', - }, - { - name: 'salt', - type: 'uint256', - }, - { - name: 'makerAssetData', - type: 'bytes', - }, - { - name: 'takerAssetData', - type: 'bytes', - }, - { - name: 'makerFeeAssetData', - type: 'bytes', - }, - { - name: 'takerFeeAssetData', - type: 'bytes', - }, - ], + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('getEthBalances(address[])'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('getEthBalances(address[])', [addresses]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Fetches all order-relevant information needed to validate if the supplied order is fillable. + * @param order The order structure. + * @param signature Signature provided by maker that proves the order's + * authenticity. `0x01` can always be provided if the signature does not + * need to be validated. + * @returns The orderInfo (hash, status, and `takerAssetAmount` already filled for the given order), fillableTakerAssetAmount (amount of the order's `takerAssetAmount` that is fillable given all on-chain state), and isValidSignature (validity of the provided signature). NOTE: If the `takerAssetData` encodes data for multiple assets, `fillableTakerAssetAmount` will represent a "scaled" amount, meaning it must be multiplied by all the individual asset amounts within the `takerAssetData` to get the final amount of each asset that can be filled. + */ + public getOrderRelevantState( + order: { + makerAddress: string; + takerAddress: string; + feeRecipientAddress: string; + senderAddress: string; + makerAssetAmount: BigNumber; + takerAssetAmount: BigNumber; + makerFee: BigNumber; + takerFee: BigNumber; + expirationTimeSeconds: BigNumber; + salt: BigNumber; + makerAssetData: string; + takerAssetData: string; + makerFeeAssetData: string; + takerFeeAssetData: string; + }, + signature: string, + ): ContractFunctionObj< + [{ orderStatus: number; orderHash: string; orderTakerAssetFilledAmount: BigNumber }, BigNumber, boolean] + > { + const self = (this as any) as DevUtilsContract; + + assert.isString('signature', signature); + + return { + async callAsync( + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise< + [{ orderStatus: number; orderHash: string; orderTakerAssetFilledAmount: BigNumber }, BigNumber, boolean] + > { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments( + 'getOrderRelevantState((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),bytes)', + [order, signature], + ); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder( + 'getOrderRelevantState((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),bytes)', + ); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue< + [ + { orderStatus: number; orderHash: string; orderTakerAssetFilledAmount: BigNumber }, + BigNumber, + boolean + ] + >(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'getOrderRelevantState((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),bytes)', + [order, signature], + ); + return abiEncodedTransactionData; + }, + }; + } + /** + * Fetches all order-relevant information needed to validate if the supplied orders are fillable. + * @param orders Array of order structures. + * @param signatures Array of signatures provided by makers that prove the + * authenticity of the orders. `0x01` can always be provided if a signature + * does not need to be validated. + * @returns The ordersInfo (array of the hash, status, and `takerAssetAmount` already filled for each order), fillableTakerAssetAmounts (array of amounts for each order's `takerAssetAmount` that is fillable given all on-chain state), and isValidSignature (array containing the validity of each provided signature). NOTE: If the `takerAssetData` encodes data for multiple assets, each element of `fillableTakerAssetAmounts` will represent a "scaled" amount, meaning it must be multiplied by all the individual asset amounts within the `takerAssetData` to get the final amount of each asset that can be filled. + */ + public getOrderRelevantStates( + orders: Array<{ + makerAddress: string; + takerAddress: string; + feeRecipientAddress: string; + senderAddress: string; + makerAssetAmount: BigNumber; + takerAssetAmount: BigNumber; + makerFee: BigNumber; + takerFee: BigNumber; + expirationTimeSeconds: BigNumber; + salt: BigNumber; + makerAssetData: string; + takerAssetData: string; + makerFeeAssetData: string; + takerFeeAssetData: string; + }>, + signatures: string[], + ): ContractFunctionObj< + [ + Array<{ orderStatus: number; orderHash: string; orderTakerAssetFilledAmount: BigNumber }>, + BigNumber[], + boolean[] + ] + > { + const self = (this as any) as DevUtilsContract; + assert.isArray('orders', orders); + assert.isArray('signatures', signatures); + + return { + async callAsync( + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise< + [ + Array<{ orderStatus: number; orderHash: string; orderTakerAssetFilledAmount: BigNumber }>, + BigNumber[], + boolean[] + ] + > { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments( + 'getOrderRelevantStates((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],bytes[])', + [orders, signatures], + ); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'takerAddresses', - type: 'address[]', + to: self.address, + ...callData, + data: encodedData, }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder( + 'getOrderRelevantStates((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],bytes[])', + ); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue< + [ + Array<{ orderStatus: number; orderHash: string; orderTakerAssetFilledAmount: BigNumber }>, + BigNumber[], + boolean[] + ] + >(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'getOrderRelevantStates((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],bytes[])', + [orders, signatures], + ); + return abiEncodedTransactionData; + }, + }; + } + /** + * Simulates all of the transfers within an order and returns the index of the first failed transfer. + * @param order The order to simulate transfers for. + * @param takerAddress The address of the taker that will fill the order. + * @param takerAssetFillAmount The amount of takerAsset that the taker wished + * to fill. + * @returns The index of the first failed transfer (or 4 if all transfers are successful). + */ + public getSimulatedOrderTransferResults( + order: { + makerAddress: string; + takerAddress: string; + feeRecipientAddress: string; + senderAddress: string; + makerAssetAmount: BigNumber; + takerAssetAmount: BigNumber; + makerFee: BigNumber; + takerFee: BigNumber; + expirationTimeSeconds: BigNumber; + salt: BigNumber; + makerAssetData: string; + takerAssetData: string; + makerFeeAssetData: string; + takerFeeAssetData: string; + }, + takerAddress: string, + takerAssetFillAmount: BigNumber, + ): ContractTxFunctionObj { + const self = (this as any) as DevUtilsContract; + + assert.isString('takerAddress', takerAddress); + assert.isBigNumber('takerAssetFillAmount', takerAssetFillAmount); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments( + 'getSimulatedOrderTransferResults((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),address,uint256)', + [order, takerAddress.toLowerCase(), takerAssetFillAmount], + ); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'takerAssetFillAmounts', - type: 'uint256[]', + to: self.address, + ...txData, + data: encodedData, }, - ], - name: 'getSimulatedOrdersTransferResults', - outputs: [ + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments( + 'getSimulatedOrderTransferResults((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),address,uint256)', + [order, takerAddress.toLowerCase(), takerAssetFillAmount], + ); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'orderTransferResults', - type: 'uint8[]', + to: self.address, + ...txData, + data: encodedData, }, - ], - payable: false, - stateMutability: 'nonpayable', - type: 'function', + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; }, - { - constant: true, - inputs: [ + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments( + 'getSimulatedOrderTransferResults((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),address,uint256)', + [order, takerAddress.toLowerCase(), takerAssetFillAmount], + ); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'ownerAddress', - type: 'address', + to: self.address, + ...callData, + data: encodedData, }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder( + 'getSimulatedOrderTransferResults((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),address,uint256)', + ); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'getSimulatedOrderTransferResults((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),address,uint256)', + [order, takerAddress.toLowerCase(), takerAssetFillAmount], + ); + return abiEncodedTransactionData; + }, + }; + } + /** + * Simulates all of the transfers for each given order and returns the indices of each first failed transfer. + * @param orders Array of orders to individually simulate transfers for. + * @param takerAddresses Array of addresses of takers that will fill each + * order. + * @param takerAssetFillAmounts Array of amounts of takerAsset that will be + * filled for each order. + * @returns The indices of the first failed transfer (or 4 if all transfers are successful) for each order. + */ + public getSimulatedOrdersTransferResults( + orders: Array<{ + makerAddress: string; + takerAddress: string; + feeRecipientAddress: string; + senderAddress: string; + makerAssetAmount: BigNumber; + takerAssetAmount: BigNumber; + makerFee: BigNumber; + takerFee: BigNumber; + expirationTimeSeconds: BigNumber; + salt: BigNumber; + makerAssetData: string; + takerAssetData: string; + makerFeeAssetData: string; + takerFeeAssetData: string; + }>, + takerAddresses: string[], + takerAssetFillAmounts: BigNumber[], + ): ContractTxFunctionObj { + const self = (this as any) as DevUtilsContract; + assert.isArray('orders', orders); + assert.isArray('takerAddresses', takerAddresses); + assert.isArray('takerAssetFillAmounts', takerAssetFillAmounts); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments( + 'getSimulatedOrdersTransferResults((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],address[],uint256[])', + [orders, takerAddresses, takerAssetFillAmounts], + ); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'assetData', - type: 'bytes', + to: self.address, + ...txData, + data: encodedData, }, - ], - name: 'getTransferableAssetAmount', - outputs: [ + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments( + 'getSimulatedOrdersTransferResults((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],address[],uint256[])', + [orders, takerAddresses, takerAssetFillAmounts], + ); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'transferableAssetAmount', - type: 'uint256', + to: self.address, + ...txData, + data: encodedData, }, - ], - payable: false, - stateMutability: 'view', - type: 'function', + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; }, - ] as ContractAbi; - return abi; + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments( + 'getSimulatedOrdersTransferResults((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],address[],uint256[])', + [orders, takerAddresses, takerAssetFillAmounts], + ); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder( + 'getSimulatedOrdersTransferResults((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],address[],uint256[])', + ); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'getSimulatedOrdersTransferResults((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],address[],uint256[])', + [orders, takerAddresses, takerAssetFillAmounts], + ); + return abiEncodedTransactionData; + }, + }; + } + /** + * Gets the amount of an asset transferable by the owner. + * @param ownerAddress Address of the owner of the asset. + * @param assetData Description of tokens, per the AssetProxy contract + * specification. + * @returns The amount of the asset tranferable by the owner. NOTE: If the `assetData` encodes data for multiple assets, the `transferableAssetAmount` will represent the amount of times the entire `assetData` can be transferred. To calculate the total individual transferable amounts, this scaled `transferableAmount` must be multiplied by the individual asset amounts located within the `assetData`. + */ + public getTransferableAssetAmount(ownerAddress: string, assetData: string): ContractFunctionObj { + const self = (this as any) as DevUtilsContract; + assert.isString('ownerAddress', ownerAddress); + assert.isString('assetData', assetData); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('getTransferableAssetAmount(address,bytes)', [ + ownerAddress.toLowerCase(), + assetData, + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('getTransferableAssetAmount(address,bytes)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'getTransferableAssetAmount(address,bytes)', + [ownerAddress.toLowerCase(), assetData], + ); + return abiEncodedTransactionData; + }, + }; } + constructor( address: string, supportedProvider: SupportedProvider, @@ -3815,6 +3661,12 @@ export class DevUtilsContract extends BaseContract { deployedBytecode, ); classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']); + DevUtilsContract.ABI().forEach((item, index) => { + if (item.type === 'function') { + const methodAbi = item as MethodAbi; + this._methodABIIndex[methodAbi.name] = index; + } + }); } } diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts b/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts index 304044c949..36d219d183 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts @@ -1,7 +1,16 @@ // tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma enum-naming // tslint:disable:whitespace no-unbound-method no-trailing-whitespace // tslint:disable:no-unused-variable -import { BaseContract, SubscriptionManager, PromiseWithTransactionHash } from '@0x/base-contract'; +import { + AwaitTransactionSuccessOpts, + ContractFunctionObj, + ContractTxFunctionObj, + SendTransactionOpts, + BaseContract, + SubscriptionManager, + PromiseWithTransactionHash, + methodAbiToFunctionSignature, +} from '@0x/base-contract'; import { schemas } from '@0x/json-schemas'; import { BlockParam, @@ -19,13 +28,7 @@ import { SupportedProvider, } from 'ethereum-types'; import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils'; -import { - AwaitTransactionSuccessOpts, - EventCallback, - IndexedFilterValues, - SendTransactionOpts, - SimpleContractArtifact, -} from '@0x/types'; +import { EventCallback, IndexedFilterValues, SimpleContractArtifact } from '@0x/types'; import { Web3Wrapper } from '@0x/web3-wrapper'; import { assert } from '@0x/assert'; import * as ethers from 'ethers'; @@ -58,1453 +61,7 @@ export class DummyERC20TokenContract extends BaseContract { * @ignore */ public static deployedBytecode: string | undefined; - public MAX_MINT_AMOUNT = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DummyERC20TokenContract; - const encodedData = self._strictEncodeArguments('MAX_MINT_AMOUNT()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('MAX_MINT_AMOUNT()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public allowance = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param _owner The address of the account owning tokens - * @param _spender The address of the account able to transfer the tokens - * @returns Amount of remaining tokens allowed to spent - */ - async callAsync( - _owner: string, - _spender: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('_owner', _owner); - assert.isString('_spender', _spender); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DummyERC20TokenContract; - const encodedData = self._strictEncodeArguments('allowance(address,address)', [ - _owner.toLowerCase(), - _spender.toLowerCase(), - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('allowance(address,address)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * `msg.sender` approves `_spender` to spend `_value` tokens - */ - public approve = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param _spender The address of the account able to transfer the tokens - * @param _value The amount of wei to be approved for transfer - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - _spender: string, - _value: BigNumber, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('_spender', _spender); - assert.isBigNumber('_value', _value); - const self = (this as any) as DummyERC20TokenContract; - const encodedData = self._strictEncodeArguments('approve(address,uint256)', [ - _spender.toLowerCase(), - _value, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.approve.callAsync(_spender, _value, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param _spender The address of the account able to transfer the tokens - * @param _value The amount of wei to be approved for transfer - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - _spender: string, - _value: BigNumber, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('_spender', _spender); - assert.isBigNumber('_value', _value); - const self = (this as any) as DummyERC20TokenContract; - const txHashPromise = self.approve.sendTransactionAsync(_spender.toLowerCase(), _value, txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param _spender The address of the account able to transfer the tokens - * @param _value The amount of wei to be approved for transfer - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - _spender: string, - _value: BigNumber, - txData?: Partial | undefined, - ): Promise { - assert.isString('_spender', _spender); - assert.isBigNumber('_value', _value); - const self = (this as any) as DummyERC20TokenContract; - const encodedData = self._strictEncodeArguments('approve(address,uint256)', [ - _spender.toLowerCase(), - _value, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param _spender The address of the account able to transfer the tokens - * @param _value The amount of wei to be approved for transfer - * @returns Always true if the call has enough gas to complete execution - */ - async callAsync( - _spender: string, - _value: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('_spender', _spender); - assert.isBigNumber('_value', _value); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DummyERC20TokenContract; - const encodedData = self._strictEncodeArguments('approve(address,uint256)', [ - _spender.toLowerCase(), - _value, - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('approve(address,uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param _spender The address of the account able to transfer the tokens - * @param _value The amount of wei to be approved for transfer - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(_spender: string, _value: BigNumber): string { - assert.isString('_spender', _spender); - assert.isBigNumber('_value', _value); - const self = (this as any) as DummyERC20TokenContract; - const abiEncodedTransactionData = self._strictEncodeArguments('approve(address,uint256)', [ - _spender.toLowerCase(), - _value, - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as DummyERC20TokenContract; - const abiEncoder = self._lookupAbiEncoder('approve(address,uint256)'); - return abiEncoder.getSelector(); - }, - }; - /** - * Query the balance of owner - */ - public balanceOf = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param _owner The address from which the balance will be retrieved - * @returns Balance of owner - */ - async callAsync( - _owner: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('_owner', _owner); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DummyERC20TokenContract; - const encodedData = self._strictEncodeArguments('balanceOf(address)', [_owner.toLowerCase()]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('balanceOf(address)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public decimals = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DummyERC20TokenContract; - const encodedData = self._strictEncodeArguments('decimals()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('decimals()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Mints new tokens for sender - */ - public mint = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param _value Amount of tokens to mint - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - _value: BigNumber, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isBigNumber('_value', _value); - const self = (this as any) as DummyERC20TokenContract; - const encodedData = self._strictEncodeArguments('mint(uint256)', [_value]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.mint.callAsync(_value, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param _value Amount of tokens to mint - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - _value: BigNumber, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isBigNumber('_value', _value); - const self = (this as any) as DummyERC20TokenContract; - const txHashPromise = self.mint.sendTransactionAsync(_value, txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param _value Amount of tokens to mint - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync(_value: BigNumber, txData?: Partial | undefined): Promise { - assert.isBigNumber('_value', _value); - const self = (this as any) as DummyERC20TokenContract; - const encodedData = self._strictEncodeArguments('mint(uint256)', [_value]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param _value Amount of tokens to mint - */ - async callAsync(_value: BigNumber, callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.isBigNumber('_value', _value); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DummyERC20TokenContract; - const encodedData = self._strictEncodeArguments('mint(uint256)', [_value]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('mint(uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param _value Amount of tokens to mint - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(_value: BigNumber): string { - assert.isBigNumber('_value', _value); - const self = (this as any) as DummyERC20TokenContract; - const abiEncodedTransactionData = self._strictEncodeArguments('mint(uint256)', [_value]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as DummyERC20TokenContract; - const abiEncoder = self._lookupAbiEncoder('mint(uint256)'); - return abiEncoder.getSelector(); - }, - }; - public name = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DummyERC20TokenContract; - const encodedData = self._strictEncodeArguments('name()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('name()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public owner = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DummyERC20TokenContract; - const encodedData = self._strictEncodeArguments('owner()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('owner()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Sets the balance of target address - */ - public setBalance = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param _target Address or which balance will be updated - * @param _value New balance of target address - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - _target: string, - _value: BigNumber, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('_target', _target); - assert.isBigNumber('_value', _value); - const self = (this as any) as DummyERC20TokenContract; - const encodedData = self._strictEncodeArguments('setBalance(address,uint256)', [ - _target.toLowerCase(), - _value, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.setBalance.callAsync(_target, _value, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param _target Address or which balance will be updated - * @param _value New balance of target address - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - _target: string, - _value: BigNumber, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('_target', _target); - assert.isBigNumber('_value', _value); - const self = (this as any) as DummyERC20TokenContract; - const txHashPromise = self.setBalance.sendTransactionAsync(_target.toLowerCase(), _value, txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param _target Address or which balance will be updated - * @param _value New balance of target address - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - _target: string, - _value: BigNumber, - txData?: Partial | undefined, - ): Promise { - assert.isString('_target', _target); - assert.isBigNumber('_value', _value); - const self = (this as any) as DummyERC20TokenContract; - const encodedData = self._strictEncodeArguments('setBalance(address,uint256)', [ - _target.toLowerCase(), - _value, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param _target Address or which balance will be updated - * @param _value New balance of target address - */ - async callAsync( - _target: string, - _value: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('_target', _target); - assert.isBigNumber('_value', _value); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DummyERC20TokenContract; - const encodedData = self._strictEncodeArguments('setBalance(address,uint256)', [ - _target.toLowerCase(), - _value, - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('setBalance(address,uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param _target Address or which balance will be updated - * @param _value New balance of target address - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(_target: string, _value: BigNumber): string { - assert.isString('_target', _target); - assert.isBigNumber('_value', _value); - const self = (this as any) as DummyERC20TokenContract; - const abiEncodedTransactionData = self._strictEncodeArguments('setBalance(address,uint256)', [ - _target.toLowerCase(), - _value, - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as DummyERC20TokenContract; - const abiEncoder = self._lookupAbiEncoder('setBalance(address,uint256)'); - return abiEncoder.getSelector(); - }, - }; - public symbol = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DummyERC20TokenContract; - const encodedData = self._strictEncodeArguments('symbol()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('symbol()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Query total supply of token - */ - public totalSupply = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @returns Total supply of token - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DummyERC20TokenContract; - const encodedData = self._strictEncodeArguments('totalSupply()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('totalSupply()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * send `value` token to `to` from `msg.sender` - */ - public transfer = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param _to The address of the recipient - * @param _value The amount of token to be transferred - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - _to: string, - _value: BigNumber, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('_to', _to); - assert.isBigNumber('_value', _value); - const self = (this as any) as DummyERC20TokenContract; - const encodedData = self._strictEncodeArguments('transfer(address,uint256)', [_to.toLowerCase(), _value]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.transfer.callAsync(_to, _value, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param _to The address of the recipient - * @param _value The amount of token to be transferred - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - _to: string, - _value: BigNumber, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('_to', _to); - assert.isBigNumber('_value', _value); - const self = (this as any) as DummyERC20TokenContract; - const txHashPromise = self.transfer.sendTransactionAsync(_to.toLowerCase(), _value, txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param _to The address of the recipient - * @param _value The amount of token to be transferred - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync(_to: string, _value: BigNumber, txData?: Partial | undefined): Promise { - assert.isString('_to', _to); - assert.isBigNumber('_value', _value); - const self = (this as any) as DummyERC20TokenContract; - const encodedData = self._strictEncodeArguments('transfer(address,uint256)', [_to.toLowerCase(), _value]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param _to The address of the recipient - * @param _value The amount of token to be transferred - * @returns True if transfer was successful - */ - async callAsync( - _to: string, - _value: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('_to', _to); - assert.isBigNumber('_value', _value); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DummyERC20TokenContract; - const encodedData = self._strictEncodeArguments('transfer(address,uint256)', [_to.toLowerCase(), _value]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('transfer(address,uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param _to The address of the recipient - * @param _value The amount of token to be transferred - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(_to: string, _value: BigNumber): string { - assert.isString('_to', _to); - assert.isBigNumber('_value', _value); - const self = (this as any) as DummyERC20TokenContract; - const abiEncodedTransactionData = self._strictEncodeArguments('transfer(address,uint256)', [ - _to.toLowerCase(), - _value, - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as DummyERC20TokenContract; - const abiEncoder = self._lookupAbiEncoder('transfer(address,uint256)'); - return abiEncoder.getSelector(); - }, - }; - /** - * ERC20 transferFrom, modified such that an allowance of MAX_UINT represents an unlimited allowance. See https://github.com/ethereum/EIPs/issues/717 - */ - public transferFrom = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param _from Address to transfer from. - * @param _to Address to transfer to. - * @param _value Amount to transfer. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - _from: string, - _to: string, - _value: BigNumber, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('_from', _from); - assert.isString('_to', _to); - assert.isBigNumber('_value', _value); - const self = (this as any) as DummyERC20TokenContract; - const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [ - _from.toLowerCase(), - _to.toLowerCase(), - _value, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.transferFrom.callAsync(_from, _to, _value, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param _from Address to transfer from. - * @param _to Address to transfer to. - * @param _value Amount to transfer. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - _from: string, - _to: string, - _value: BigNumber, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('_from', _from); - assert.isString('_to', _to); - assert.isBigNumber('_value', _value); - const self = (this as any) as DummyERC20TokenContract; - const txHashPromise = self.transferFrom.sendTransactionAsync( - _from.toLowerCase(), - _to.toLowerCase(), - _value, - txData, - opts, - ); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param _from Address to transfer from. - * @param _to Address to transfer to. - * @param _value Amount to transfer. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - _from: string, - _to: string, - _value: BigNumber, - txData?: Partial | undefined, - ): Promise { - assert.isString('_from', _from); - assert.isString('_to', _to); - assert.isBigNumber('_value', _value); - const self = (this as any) as DummyERC20TokenContract; - const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [ - _from.toLowerCase(), - _to.toLowerCase(), - _value, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param _from Address to transfer from. - * @param _to Address to transfer to. - * @param _value Amount to transfer. - * @returns Success of transfer. - */ - async callAsync( - _from: string, - _to: string, - _value: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('_from', _from); - assert.isString('_to', _to); - assert.isBigNumber('_value', _value); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DummyERC20TokenContract; - const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [ - _from.toLowerCase(), - _to.toLowerCase(), - _value, - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('transferFrom(address,address,uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param _from Address to transfer from. - * @param _to Address to transfer to. - * @param _value Amount to transfer. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(_from: string, _to: string, _value: BigNumber): string { - assert.isString('_from', _from); - assert.isString('_to', _to); - assert.isBigNumber('_value', _value); - const self = (this as any) as DummyERC20TokenContract; - const abiEncodedTransactionData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [ - _from.toLowerCase(), - _to.toLowerCase(), - _value, - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as DummyERC20TokenContract; - const abiEncoder = self._lookupAbiEncoder('transferFrom(address,address,uint256)'); - return abiEncoder.getSelector(); - }, - }; - public transferOwnership = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - newOwner: string, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('newOwner', newOwner); - const self = (this as any) as DummyERC20TokenContract; - const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.transferOwnership.callAsync(newOwner, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - newOwner: string, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('newOwner', newOwner); - const self = (this as any) as DummyERC20TokenContract; - const txHashPromise = self.transferOwnership.sendTransactionAsync(newOwner.toLowerCase(), txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync(newOwner: string, txData?: Partial | undefined): Promise { - assert.isString('newOwner', newOwner); - const self = (this as any) as DummyERC20TokenContract; - const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(newOwner: string, callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.isString('newOwner', newOwner); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DummyERC20TokenContract; - const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('transferOwnership(address)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(newOwner: string): string { - assert.isString('newOwner', newOwner); - const self = (this as any) as DummyERC20TokenContract; - const abiEncodedTransactionData = self._strictEncodeArguments('transferOwnership(address)', [ - newOwner.toLowerCase(), - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as DummyERC20TokenContract; - const abiEncoder = self._lookupAbiEncoder('transferOwnership(address)'); - return abiEncoder.getSelector(); - }, - }; + private _methodABIIndex: { [name: string]: number } = {}; private readonly _subscriptionManager: SubscriptionManager; public static async deployFrom0xArtifactAsync( artifact: ContractArtifact | SimpleContractArtifact, @@ -1915,6 +472,1154 @@ export class DummyERC20TokenContract extends BaseContract { ] as ContractAbi; return abi; } + + public getFunctionSignature(methodName: string): string { + const index = this._methodABIIndex[methodName]; + const methodAbi = DummyERC20TokenContract.ABI()[index] as MethodAbi; + const functionSignature = methodAbiToFunctionSignature(methodAbi); + return functionSignature; + } + public getABIDecodedTransactionData(methodName: string, callData: string): T { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as DummyERC20TokenContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + const abiDecodedCallData = abiEncoder.strictDecode(callData); + return abiDecodedCallData; + } + public getABIDecodedReturnData(methodName: string, callData: string): T { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as DummyERC20TokenContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + const abiDecodedCallData = abiEncoder.strictDecodeReturnValue(callData); + return abiDecodedCallData; + } + public getSelector(methodName: string): string { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as DummyERC20TokenContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + return abiEncoder.getSelector(); + } + + public MAX_MINT_AMOUNT(): ContractFunctionObj { + const self = (this as any) as DummyERC20TokenContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('MAX_MINT_AMOUNT()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('MAX_MINT_AMOUNT()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('MAX_MINT_AMOUNT()', []); + return abiEncodedTransactionData; + }, + }; + } + public allowance(_owner: string, _spender: string): ContractFunctionObj { + const self = (this as any) as DummyERC20TokenContract; + assert.isString('_owner', _owner); + assert.isString('_spender', _spender); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('allowance(address,address)', [ + _owner.toLowerCase(), + _spender.toLowerCase(), + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('allowance(address,address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('allowance(address,address)', [ + _owner.toLowerCase(), + _spender.toLowerCase(), + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * `msg.sender` approves `_spender` to spend `_value` tokens + * @param _spender The address of the account able to transfer the tokens + * @param _value The amount of wei to be approved for transfer + * @returns Always true if the call has enough gas to complete execution + */ + public approve(_spender: string, _value: BigNumber): ContractTxFunctionObj { + const self = (this as any) as DummyERC20TokenContract; + assert.isString('_spender', _spender); + assert.isBigNumber('_value', _value); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('approve(address,uint256)', [ + _spender.toLowerCase(), + _value, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('approve(address,uint256)', [ + _spender.toLowerCase(), + _value, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('approve(address,uint256)', [ + _spender.toLowerCase(), + _value, + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('approve(address,uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('approve(address,uint256)', [ + _spender.toLowerCase(), + _value, + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Query the balance of owner + * @param _owner The address from which the balance will be retrieved + * @returns Balance of owner + */ + public balanceOf(_owner: string): ContractFunctionObj { + const self = (this as any) as DummyERC20TokenContract; + assert.isString('_owner', _owner); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('balanceOf(address)', [_owner.toLowerCase()]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('balanceOf(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('balanceOf(address)', [ + _owner.toLowerCase(), + ]); + return abiEncodedTransactionData; + }, + }; + } + public decimals(): ContractFunctionObj { + const self = (this as any) as DummyERC20TokenContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('decimals()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('decimals()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('decimals()', []); + return abiEncodedTransactionData; + }, + }; + } + /** + * Mints new tokens for sender + * @param _value Amount of tokens to mint + */ + public mint(_value: BigNumber): ContractTxFunctionObj { + const self = (this as any) as DummyERC20TokenContract; + assert.isBigNumber('_value', _value); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('mint(uint256)', [_value]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('mint(uint256)', [_value]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('mint(uint256)', [_value]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('mint(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('mint(uint256)', [_value]); + return abiEncodedTransactionData; + }, + }; + } + public name(): ContractFunctionObj { + const self = (this as any) as DummyERC20TokenContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('name()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('name()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('name()', []); + return abiEncodedTransactionData; + }, + }; + } + public owner(): ContractFunctionObj { + const self = (this as any) as DummyERC20TokenContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('owner()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('owner()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('owner()', []); + return abiEncodedTransactionData; + }, + }; + } + /** + * Sets the balance of target address + * @param _target Address or which balance will be updated + * @param _value New balance of target address + */ + public setBalance(_target: string, _value: BigNumber): ContractTxFunctionObj { + const self = (this as any) as DummyERC20TokenContract; + assert.isString('_target', _target); + assert.isBigNumber('_value', _value); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('setBalance(address,uint256)', [ + _target.toLowerCase(), + _value, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('setBalance(address,uint256)', [ + _target.toLowerCase(), + _value, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('setBalance(address,uint256)', [ + _target.toLowerCase(), + _value, + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('setBalance(address,uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('setBalance(address,uint256)', [ + _target.toLowerCase(), + _value, + ]); + return abiEncodedTransactionData; + }, + }; + } + public symbol(): ContractFunctionObj { + const self = (this as any) as DummyERC20TokenContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('symbol()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('symbol()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('symbol()', []); + return abiEncodedTransactionData; + }, + }; + } + /** + * Query total supply of token + * @returns Total supply of token + */ + public totalSupply(): ContractFunctionObj { + const self = (this as any) as DummyERC20TokenContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('totalSupply()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('totalSupply()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('totalSupply()', []); + return abiEncodedTransactionData; + }, + }; + } + /** + * send `value` token to `to` from `msg.sender` + * @param _to The address of the recipient + * @param _value The amount of token to be transferred + * @returns True if transfer was successful + */ + public transfer(_to: string, _value: BigNumber): ContractTxFunctionObj { + const self = (this as any) as DummyERC20TokenContract; + assert.isString('_to', _to); + assert.isBigNumber('_value', _value); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('transfer(address,uint256)', [ + _to.toLowerCase(), + _value, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('transfer(address,uint256)', [ + _to.toLowerCase(), + _value, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('transfer(address,uint256)', [ + _to.toLowerCase(), + _value, + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('transfer(address,uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('transfer(address,uint256)', [ + _to.toLowerCase(), + _value, + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * ERC20 transferFrom, modified such that an allowance of MAX_UINT represents an unlimited allowance. See https://github.com/ethereum/EIPs/issues/717 + * @param _from Address to transfer from. + * @param _to Address to transfer to. + * @param _value Amount to transfer. + * @returns Success of transfer. + */ + public transferFrom(_from: string, _to: string, _value: BigNumber): ContractTxFunctionObj { + const self = (this as any) as DummyERC20TokenContract; + assert.isString('_from', _from); + assert.isString('_to', _to); + assert.isBigNumber('_value', _value); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [ + _from.toLowerCase(), + _to.toLowerCase(), + _value, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [ + _from.toLowerCase(), + _to.toLowerCase(), + _value, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [ + _from.toLowerCase(), + _to.toLowerCase(), + _value, + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('transferFrom(address,address,uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [ + _from.toLowerCase(), + _to.toLowerCase(), + _value, + ]); + return abiEncodedTransactionData; + }, + }; + } + public transferOwnership(newOwner: string): ContractTxFunctionObj { + const self = (this as any) as DummyERC20TokenContract; + assert.isString('newOwner', newOwner); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('transferOwnership(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('transferOwnership(address)', [ + newOwner.toLowerCase(), + ]); + return abiEncodedTransactionData; + }, + }; + } + /** * Subscribe to an event type emitted by the DummyERC20Token contract. * @param eventName The DummyERC20Token contract event you would like to subscribe to. @@ -2004,6 +1709,12 @@ export class DummyERC20TokenContract extends BaseContract { DummyERC20TokenContract.ABI(), this._web3Wrapper, ); + DummyERC20TokenContract.ABI().forEach((item, index) => { + if (item.type === 'function') { + const methodAbi = item as MethodAbi; + this._methodABIIndex[methodAbi.name] = index; + } + }); } } diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts b/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts index 5fb1cf8f24..73dee8cb7d 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts @@ -1,7 +1,16 @@ // tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma enum-naming // tslint:disable:whitespace no-unbound-method no-trailing-whitespace // tslint:disable:no-unused-variable -import { BaseContract, SubscriptionManager, PromiseWithTransactionHash } from '@0x/base-contract'; +import { + AwaitTransactionSuccessOpts, + ContractFunctionObj, + ContractTxFunctionObj, + SendTransactionOpts, + BaseContract, + SubscriptionManager, + PromiseWithTransactionHash, + methodAbiToFunctionSignature, +} from '@0x/base-contract'; import { schemas } from '@0x/json-schemas'; import { BlockParam, @@ -19,13 +28,7 @@ import { SupportedProvider, } from 'ethereum-types'; import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils'; -import { - AwaitTransactionSuccessOpts, - EventCallback, - IndexedFilterValues, - SendTransactionOpts, - SimpleContractArtifact, -} from '@0x/types'; +import { EventCallback, IndexedFilterValues, SimpleContractArtifact } from '@0x/types'; import { Web3Wrapper } from '@0x/web3-wrapper'; import { assert } from '@0x/assert'; import * as ethers from 'ethers'; @@ -68,1916 +71,7 @@ export class DummyERC721TokenContract extends BaseContract { * @ignore */ public static deployedBytecode: string | undefined; - /** - * The zero address indicates there is no approved address. - * Throws unless `msg.sender` is the current NFT owner, or an authorized - * operator of the current owner. - */ - public approve = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param _approved The new approved NFT controller - * @param _tokenId The NFT to approve - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - _approved: string, - _tokenId: BigNumber, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('_approved', _approved); - assert.isBigNumber('_tokenId', _tokenId); - const self = (this as any) as DummyERC721TokenContract; - const encodedData = self._strictEncodeArguments('approve(address,uint256)', [ - _approved.toLowerCase(), - _tokenId, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.approve.callAsync(_approved, _tokenId, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param _approved The new approved NFT controller - * @param _tokenId The NFT to approve - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - _approved: string, - _tokenId: BigNumber, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('_approved', _approved); - assert.isBigNumber('_tokenId', _tokenId); - const self = (this as any) as DummyERC721TokenContract; - const txHashPromise = self.approve.sendTransactionAsync(_approved.toLowerCase(), _tokenId, txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param _approved The new approved NFT controller - * @param _tokenId The NFT to approve - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - _approved: string, - _tokenId: BigNumber, - txData?: Partial | undefined, - ): Promise { - assert.isString('_approved', _approved); - assert.isBigNumber('_tokenId', _tokenId); - const self = (this as any) as DummyERC721TokenContract; - const encodedData = self._strictEncodeArguments('approve(address,uint256)', [ - _approved.toLowerCase(), - _tokenId, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param _approved The new approved NFT controller - * @param _tokenId The NFT to approve - */ - async callAsync( - _approved: string, - _tokenId: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('_approved', _approved); - assert.isBigNumber('_tokenId', _tokenId); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DummyERC721TokenContract; - const encodedData = self._strictEncodeArguments('approve(address,uint256)', [ - _approved.toLowerCase(), - _tokenId, - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('approve(address,uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param _approved The new approved NFT controller - * @param _tokenId The NFT to approve - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(_approved: string, _tokenId: BigNumber): string { - assert.isString('_approved', _approved); - assert.isBigNumber('_tokenId', _tokenId); - const self = (this as any) as DummyERC721TokenContract; - const abiEncodedTransactionData = self._strictEncodeArguments('approve(address,uint256)', [ - _approved.toLowerCase(), - _tokenId, - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as DummyERC721TokenContract; - const abiEncoder = self._lookupAbiEncoder('approve(address,uint256)'); - return abiEncoder.getSelector(); - }, - }; - /** - * NFTs assigned to the zero address are considered invalid, and this - * function throws for queries about the zero address. - */ - public balanceOf = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param _owner An address for whom to query the balance - * @returns The number of NFTs owned by `_owner`, possibly zero - */ - async callAsync( - _owner: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('_owner', _owner); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DummyERC721TokenContract; - const encodedData = self._strictEncodeArguments('balanceOf(address)', [_owner.toLowerCase()]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('balanceOf(address)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Function to burn a token - * Reverts if the given token ID doesn't exist or not called by contract owner - */ - public burn = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param _owner Owner of token with given token ID - * @param _tokenId ID of the token to be burned by the msg.sender - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - _owner: string, - _tokenId: BigNumber, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('_owner', _owner); - assert.isBigNumber('_tokenId', _tokenId); - const self = (this as any) as DummyERC721TokenContract; - const encodedData = self._strictEncodeArguments('burn(address,uint256)', [_owner.toLowerCase(), _tokenId]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.burn.callAsync(_owner, _tokenId, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param _owner Owner of token with given token ID - * @param _tokenId ID of the token to be burned by the msg.sender - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - _owner: string, - _tokenId: BigNumber, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('_owner', _owner); - assert.isBigNumber('_tokenId', _tokenId); - const self = (this as any) as DummyERC721TokenContract; - const txHashPromise = self.burn.sendTransactionAsync(_owner.toLowerCase(), _tokenId, txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param _owner Owner of token with given token ID - * @param _tokenId ID of the token to be burned by the msg.sender - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - _owner: string, - _tokenId: BigNumber, - txData?: Partial | undefined, - ): Promise { - assert.isString('_owner', _owner); - assert.isBigNumber('_tokenId', _tokenId); - const self = (this as any) as DummyERC721TokenContract; - const encodedData = self._strictEncodeArguments('burn(address,uint256)', [_owner.toLowerCase(), _tokenId]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param _owner Owner of token with given token ID - * @param _tokenId ID of the token to be burned by the msg.sender - */ - async callAsync( - _owner: string, - _tokenId: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('_owner', _owner); - assert.isBigNumber('_tokenId', _tokenId); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DummyERC721TokenContract; - const encodedData = self._strictEncodeArguments('burn(address,uint256)', [_owner.toLowerCase(), _tokenId]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('burn(address,uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param _owner Owner of token with given token ID - * @param _tokenId ID of the token to be burned by the msg.sender - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(_owner: string, _tokenId: BigNumber): string { - assert.isString('_owner', _owner); - assert.isBigNumber('_tokenId', _tokenId); - const self = (this as any) as DummyERC721TokenContract; - const abiEncodedTransactionData = self._strictEncodeArguments('burn(address,uint256)', [ - _owner.toLowerCase(), - _tokenId, - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as DummyERC721TokenContract; - const abiEncoder = self._lookupAbiEncoder('burn(address,uint256)'); - return abiEncoder.getSelector(); - }, - }; - /** - * Throws if `_tokenId` is not a valid NFT. - */ - public getApproved = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param _tokenId The NFT to find the approved address for - * @returns The approved address for this NFT, or the zero address if there is none - */ - async callAsync( - _tokenId: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isBigNumber('_tokenId', _tokenId); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DummyERC721TokenContract; - const encodedData = self._strictEncodeArguments('getApproved(uint256)', [_tokenId]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('getApproved(uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public isApprovedForAll = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param _owner The address that owns the NFTs - * @param _operator The address that acts on behalf of the owner - * @returns True if `_operator` is an approved operator for `_owner`, false otherwise - */ - async callAsync( - _owner: string, - _operator: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('_owner', _owner); - assert.isString('_operator', _operator); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DummyERC721TokenContract; - const encodedData = self._strictEncodeArguments('isApprovedForAll(address,address)', [ - _owner.toLowerCase(), - _operator.toLowerCase(), - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('isApprovedForAll(address,address)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Function to mint a new token - * Reverts if the given token ID already exists - */ - public mint = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param _to Address of the beneficiary that will own the minted token - * @param _tokenId ID of the token to be minted by the msg.sender - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - _to: string, - _tokenId: BigNumber, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('_to', _to); - assert.isBigNumber('_tokenId', _tokenId); - const self = (this as any) as DummyERC721TokenContract; - const encodedData = self._strictEncodeArguments('mint(address,uint256)', [_to.toLowerCase(), _tokenId]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.mint.callAsync(_to, _tokenId, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param _to Address of the beneficiary that will own the minted token - * @param _tokenId ID of the token to be minted by the msg.sender - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - _to: string, - _tokenId: BigNumber, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('_to', _to); - assert.isBigNumber('_tokenId', _tokenId); - const self = (this as any) as DummyERC721TokenContract; - const txHashPromise = self.mint.sendTransactionAsync(_to.toLowerCase(), _tokenId, txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param _to Address of the beneficiary that will own the minted token - * @param _tokenId ID of the token to be minted by the msg.sender - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - _to: string, - _tokenId: BigNumber, - txData?: Partial | undefined, - ): Promise { - assert.isString('_to', _to); - assert.isBigNumber('_tokenId', _tokenId); - const self = (this as any) as DummyERC721TokenContract; - const encodedData = self._strictEncodeArguments('mint(address,uint256)', [_to.toLowerCase(), _tokenId]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param _to Address of the beneficiary that will own the minted token - * @param _tokenId ID of the token to be minted by the msg.sender - */ - async callAsync( - _to: string, - _tokenId: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('_to', _to); - assert.isBigNumber('_tokenId', _tokenId); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DummyERC721TokenContract; - const encodedData = self._strictEncodeArguments('mint(address,uint256)', [_to.toLowerCase(), _tokenId]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('mint(address,uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param _to Address of the beneficiary that will own the minted token - * @param _tokenId ID of the token to be minted by the msg.sender - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(_to: string, _tokenId: BigNumber): string { - assert.isString('_to', _to); - assert.isBigNumber('_tokenId', _tokenId); - const self = (this as any) as DummyERC721TokenContract; - const abiEncodedTransactionData = self._strictEncodeArguments('mint(address,uint256)', [ - _to.toLowerCase(), - _tokenId, - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as DummyERC721TokenContract; - const abiEncoder = self._lookupAbiEncoder('mint(address,uint256)'); - return abiEncoder.getSelector(); - }, - }; - public name = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DummyERC721TokenContract; - const encodedData = self._strictEncodeArguments('name()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('name()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public owner = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DummyERC721TokenContract; - const encodedData = self._strictEncodeArguments('owner()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('owner()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * NFTs assigned to zero address are considered invalid, and queries - * about them do throw. - */ - public ownerOf = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param _tokenId The identifier for an NFT - * @returns The address of the owner of the NFT - */ - async callAsync( - _tokenId: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isBigNumber('_tokenId', _tokenId); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DummyERC721TokenContract; - const encodedData = self._strictEncodeArguments('ownerOf(uint256)', [_tokenId]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('ownerOf(uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * This works identically to the other function with an extra data parameter, - * except this function just sets data to "". - */ - public safeTransferFrom1 = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param _from The current owner of the NFT - * @param _to The new owner - * @param _tokenId The NFT to transfer - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - _from: string, - _to: string, - _tokenId: BigNumber, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('_from', _from); - assert.isString('_to', _to); - assert.isBigNumber('_tokenId', _tokenId); - const self = (this as any) as DummyERC721TokenContract; - const encodedData = self._strictEncodeArguments('safeTransferFrom(address,address,uint256)', [ - _from.toLowerCase(), - _to.toLowerCase(), - _tokenId, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.safeTransferFrom1.callAsync(_from, _to, _tokenId, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param _from The current owner of the NFT - * @param _to The new owner - * @param _tokenId The NFT to transfer - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - _from: string, - _to: string, - _tokenId: BigNumber, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('_from', _from); - assert.isString('_to', _to); - assert.isBigNumber('_tokenId', _tokenId); - const self = (this as any) as DummyERC721TokenContract; - const txHashPromise = self.safeTransferFrom1.sendTransactionAsync( - _from.toLowerCase(), - _to.toLowerCase(), - _tokenId, - txData, - opts, - ); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param _from The current owner of the NFT - * @param _to The new owner - * @param _tokenId The NFT to transfer - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - _from: string, - _to: string, - _tokenId: BigNumber, - txData?: Partial | undefined, - ): Promise { - assert.isString('_from', _from); - assert.isString('_to', _to); - assert.isBigNumber('_tokenId', _tokenId); - const self = (this as any) as DummyERC721TokenContract; - const encodedData = self._strictEncodeArguments('safeTransferFrom(address,address,uint256)', [ - _from.toLowerCase(), - _to.toLowerCase(), - _tokenId, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param _from The current owner of the NFT - * @param _to The new owner - * @param _tokenId The NFT to transfer - */ - async callAsync( - _from: string, - _to: string, - _tokenId: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('_from', _from); - assert.isString('_to', _to); - assert.isBigNumber('_tokenId', _tokenId); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DummyERC721TokenContract; - const encodedData = self._strictEncodeArguments('safeTransferFrom(address,address,uint256)', [ - _from.toLowerCase(), - _to.toLowerCase(), - _tokenId, - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('safeTransferFrom(address,address,uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param _from The current owner of the NFT - * @param _to The new owner - * @param _tokenId The NFT to transfer - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(_from: string, _to: string, _tokenId: BigNumber): string { - assert.isString('_from', _from); - assert.isString('_to', _to); - assert.isBigNumber('_tokenId', _tokenId); - const self = (this as any) as DummyERC721TokenContract; - const abiEncodedTransactionData = self._strictEncodeArguments('safeTransferFrom(address,address,uint256)', [ - _from.toLowerCase(), - _to.toLowerCase(), - _tokenId, - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as DummyERC721TokenContract; - const abiEncoder = self._lookupAbiEncoder('safeTransferFrom(address,address,uint256)'); - return abiEncoder.getSelector(); - }, - }; - /** - * Throws unless `msg.sender` is the current owner, an authorized - * operator, or the approved address for this NFT. Throws if `_from` is - * not the current owner. Throws if `_to` is the zero address. Throws if - * `_tokenId` is not a valid NFT. When transfer is complete, this function - * checks if `_to` is a smart contract (code size > 0). If so, it calls - * `onERC721Received` on `_to` and throws if the return value is not - * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`. - */ - public safeTransferFrom2 = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param _from The current owner of the NFT - * @param _to The new owner - * @param _tokenId The NFT to transfer - * @param _data Additional data with no specified format, sent in call to `_to` - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - _from: string, - _to: string, - _tokenId: BigNumber, - _data: string, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('_from', _from); - assert.isString('_to', _to); - assert.isBigNumber('_tokenId', _tokenId); - assert.isString('_data', _data); - const self = (this as any) as DummyERC721TokenContract; - const encodedData = self._strictEncodeArguments('safeTransferFrom(address,address,uint256,bytes)', [ - _from.toLowerCase(), - _to.toLowerCase(), - _tokenId, - _data, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.safeTransferFrom2.callAsync(_from, _to, _tokenId, _data, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param _from The current owner of the NFT - * @param _to The new owner - * @param _tokenId The NFT to transfer - * @param _data Additional data with no specified format, sent in call to `_to` - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - _from: string, - _to: string, - _tokenId: BigNumber, - _data: string, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('_from', _from); - assert.isString('_to', _to); - assert.isBigNumber('_tokenId', _tokenId); - assert.isString('_data', _data); - const self = (this as any) as DummyERC721TokenContract; - const txHashPromise = self.safeTransferFrom2.sendTransactionAsync( - _from.toLowerCase(), - _to.toLowerCase(), - _tokenId, - _data, - txData, - opts, - ); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param _from The current owner of the NFT - * @param _to The new owner - * @param _tokenId The NFT to transfer - * @param _data Additional data with no specified format, sent in call to `_to` - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - _from: string, - _to: string, - _tokenId: BigNumber, - _data: string, - txData?: Partial | undefined, - ): Promise { - assert.isString('_from', _from); - assert.isString('_to', _to); - assert.isBigNumber('_tokenId', _tokenId); - assert.isString('_data', _data); - const self = (this as any) as DummyERC721TokenContract; - const encodedData = self._strictEncodeArguments('safeTransferFrom(address,address,uint256,bytes)', [ - _from.toLowerCase(), - _to.toLowerCase(), - _tokenId, - _data, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param _from The current owner of the NFT - * @param _to The new owner - * @param _tokenId The NFT to transfer - * @param _data Additional data with no specified format, sent in call to `_to` - */ - async callAsync( - _from: string, - _to: string, - _tokenId: BigNumber, - _data: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('_from', _from); - assert.isString('_to', _to); - assert.isBigNumber('_tokenId', _tokenId); - assert.isString('_data', _data); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DummyERC721TokenContract; - const encodedData = self._strictEncodeArguments('safeTransferFrom(address,address,uint256,bytes)', [ - _from.toLowerCase(), - _to.toLowerCase(), - _tokenId, - _data, - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('safeTransferFrom(address,address,uint256,bytes)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param _from The current owner of the NFT - * @param _to The new owner - * @param _tokenId The NFT to transfer - * @param _data Additional data with no specified format, sent in call to `_to` - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(_from: string, _to: string, _tokenId: BigNumber, _data: string): string { - assert.isString('_from', _from); - assert.isString('_to', _to); - assert.isBigNumber('_tokenId', _tokenId); - assert.isString('_data', _data); - const self = (this as any) as DummyERC721TokenContract; - const abiEncodedTransactionData = self._strictEncodeArguments( - 'safeTransferFrom(address,address,uint256,bytes)', - [_from.toLowerCase(), _to.toLowerCase(), _tokenId, _data], - ); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as DummyERC721TokenContract; - const abiEncoder = self._lookupAbiEncoder('safeTransferFrom(address,address,uint256,bytes)'); - return abiEncoder.getSelector(); - }, - }; - /** - * Emits the ApprovalForAll event. The contract MUST allow - * multiple operators per owner. - */ - public setApprovalForAll = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param _operator Address to add to the set of authorized operators - * @param _approved True if the operator is approved, false to revoke approval - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - _operator: string, - _approved: boolean, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('_operator', _operator); - assert.isBoolean('_approved', _approved); - const self = (this as any) as DummyERC721TokenContract; - const encodedData = self._strictEncodeArguments('setApprovalForAll(address,bool)', [ - _operator.toLowerCase(), - _approved, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.setApprovalForAll.callAsync(_operator, _approved, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param _operator Address to add to the set of authorized operators - * @param _approved True if the operator is approved, false to revoke approval - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - _operator: string, - _approved: boolean, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('_operator', _operator); - assert.isBoolean('_approved', _approved); - const self = (this as any) as DummyERC721TokenContract; - const txHashPromise = self.setApprovalForAll.sendTransactionAsync( - _operator.toLowerCase(), - _approved, - txData, - opts, - ); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param _operator Address to add to the set of authorized operators - * @param _approved True if the operator is approved, false to revoke approval - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - _operator: string, - _approved: boolean, - txData?: Partial | undefined, - ): Promise { - assert.isString('_operator', _operator); - assert.isBoolean('_approved', _approved); - const self = (this as any) as DummyERC721TokenContract; - const encodedData = self._strictEncodeArguments('setApprovalForAll(address,bool)', [ - _operator.toLowerCase(), - _approved, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param _operator Address to add to the set of authorized operators - * @param _approved True if the operator is approved, false to revoke approval - */ - async callAsync( - _operator: string, - _approved: boolean, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('_operator', _operator); - assert.isBoolean('_approved', _approved); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DummyERC721TokenContract; - const encodedData = self._strictEncodeArguments('setApprovalForAll(address,bool)', [ - _operator.toLowerCase(), - _approved, - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('setApprovalForAll(address,bool)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param _operator Address to add to the set of authorized operators - * @param _approved True if the operator is approved, false to revoke approval - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(_operator: string, _approved: boolean): string { - assert.isString('_operator', _operator); - assert.isBoolean('_approved', _approved); - const self = (this as any) as DummyERC721TokenContract; - const abiEncodedTransactionData = self._strictEncodeArguments('setApprovalForAll(address,bool)', [ - _operator.toLowerCase(), - _approved, - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as DummyERC721TokenContract; - const abiEncoder = self._lookupAbiEncoder('setApprovalForAll(address,bool)'); - return abiEncoder.getSelector(); - }, - }; - public symbol = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DummyERC721TokenContract; - const encodedData = self._strictEncodeArguments('symbol()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('symbol()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Throws unless `msg.sender` is the current owner, an authorized - * operator, or the approved address for this NFT. Throws if `_from` is - * not the current owner. Throws if `_to` is the zero address. Throws if - * `_tokenId` is not a valid NFT. - */ - public transferFrom = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param _from The current owner of the NFT - * @param _to The new owner - * @param _tokenId The NFT to transfer - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - _from: string, - _to: string, - _tokenId: BigNumber, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('_from', _from); - assert.isString('_to', _to); - assert.isBigNumber('_tokenId', _tokenId); - const self = (this as any) as DummyERC721TokenContract; - const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [ - _from.toLowerCase(), - _to.toLowerCase(), - _tokenId, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.transferFrom.callAsync(_from, _to, _tokenId, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param _from The current owner of the NFT - * @param _to The new owner - * @param _tokenId The NFT to transfer - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - _from: string, - _to: string, - _tokenId: BigNumber, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('_from', _from); - assert.isString('_to', _to); - assert.isBigNumber('_tokenId', _tokenId); - const self = (this as any) as DummyERC721TokenContract; - const txHashPromise = self.transferFrom.sendTransactionAsync( - _from.toLowerCase(), - _to.toLowerCase(), - _tokenId, - txData, - opts, - ); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param _from The current owner of the NFT - * @param _to The new owner - * @param _tokenId The NFT to transfer - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - _from: string, - _to: string, - _tokenId: BigNumber, - txData?: Partial | undefined, - ): Promise { - assert.isString('_from', _from); - assert.isString('_to', _to); - assert.isBigNumber('_tokenId', _tokenId); - const self = (this as any) as DummyERC721TokenContract; - const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [ - _from.toLowerCase(), - _to.toLowerCase(), - _tokenId, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param _from The current owner of the NFT - * @param _to The new owner - * @param _tokenId The NFT to transfer - */ - async callAsync( - _from: string, - _to: string, - _tokenId: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('_from', _from); - assert.isString('_to', _to); - assert.isBigNumber('_tokenId', _tokenId); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DummyERC721TokenContract; - const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [ - _from.toLowerCase(), - _to.toLowerCase(), - _tokenId, - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('transferFrom(address,address,uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param _from The current owner of the NFT - * @param _to The new owner - * @param _tokenId The NFT to transfer - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(_from: string, _to: string, _tokenId: BigNumber): string { - assert.isString('_from', _from); - assert.isString('_to', _to); - assert.isBigNumber('_tokenId', _tokenId); - const self = (this as any) as DummyERC721TokenContract; - const abiEncodedTransactionData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [ - _from.toLowerCase(), - _to.toLowerCase(), - _tokenId, - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as DummyERC721TokenContract; - const abiEncoder = self._lookupAbiEncoder('transferFrom(address,address,uint256)'); - return abiEncoder.getSelector(); - }, - }; - public transferOwnership = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - newOwner: string, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('newOwner', newOwner); - const self = (this as any) as DummyERC721TokenContract; - const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.transferOwnership.callAsync(newOwner, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - newOwner: string, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('newOwner', newOwner); - const self = (this as any) as DummyERC721TokenContract; - const txHashPromise = self.transferOwnership.sendTransactionAsync(newOwner.toLowerCase(), txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync(newOwner: string, txData?: Partial | undefined): Promise { - assert.isString('newOwner', newOwner); - const self = (this as any) as DummyERC721TokenContract; - const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(newOwner: string, callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.isString('newOwner', newOwner); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DummyERC721TokenContract; - const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('transferOwnership(address)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(newOwner: string): string { - assert.isString('newOwner', newOwner); - const self = (this as any) as DummyERC721TokenContract; - const abiEncodedTransactionData = self._strictEncodeArguments('transferOwnership(address)', [ - newOwner.toLowerCase(), - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as DummyERC721TokenContract; - const abiEncoder = self._lookupAbiEncoder('transferOwnership(address)'); - return abiEncoder.getSelector(); - }, - }; + private _methodABIIndex: { [name: string]: number } = {}; private readonly _subscriptionManager: SubscriptionManager; public static async deployFrom0xArtifactAsync( artifact: ContractArtifact | SimpleContractArtifact, @@ -2430,6 +524,1402 @@ export class DummyERC721TokenContract extends BaseContract { ] as ContractAbi; return abi; } + + public getFunctionSignature(methodName: string): string { + const index = this._methodABIIndex[methodName]; + const methodAbi = DummyERC721TokenContract.ABI()[index] as MethodAbi; + const functionSignature = methodAbiToFunctionSignature(methodAbi); + return functionSignature; + } + public getABIDecodedTransactionData(methodName: string, callData: string): T { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as DummyERC721TokenContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + const abiDecodedCallData = abiEncoder.strictDecode(callData); + return abiDecodedCallData; + } + public getABIDecodedReturnData(methodName: string, callData: string): T { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as DummyERC721TokenContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + const abiDecodedCallData = abiEncoder.strictDecodeReturnValue(callData); + return abiDecodedCallData; + } + public getSelector(methodName: string): string { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as DummyERC721TokenContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + return abiEncoder.getSelector(); + } + + /** + * The zero address indicates there is no approved address. + * Throws unless `msg.sender` is the current NFT owner, or an authorized + * operator of the current owner. + * @param _approved The new approved NFT controller + * @param _tokenId The NFT to approve + */ + public approve(_approved: string, _tokenId: BigNumber): ContractTxFunctionObj { + const self = (this as any) as DummyERC721TokenContract; + assert.isString('_approved', _approved); + assert.isBigNumber('_tokenId', _tokenId); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('approve(address,uint256)', [ + _approved.toLowerCase(), + _tokenId, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('approve(address,uint256)', [ + _approved.toLowerCase(), + _tokenId, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('approve(address,uint256)', [ + _approved.toLowerCase(), + _tokenId, + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('approve(address,uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('approve(address,uint256)', [ + _approved.toLowerCase(), + _tokenId, + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * NFTs assigned to the zero address are considered invalid, and this + * function throws for queries about the zero address. + * @param _owner An address for whom to query the balance + * @returns The number of NFTs owned by `_owner`, possibly zero + */ + public balanceOf(_owner: string): ContractFunctionObj { + const self = (this as any) as DummyERC721TokenContract; + assert.isString('_owner', _owner); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('balanceOf(address)', [_owner.toLowerCase()]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('balanceOf(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('balanceOf(address)', [ + _owner.toLowerCase(), + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Function to burn a token + * Reverts if the given token ID doesn't exist or not called by contract owner + * @param _owner Owner of token with given token ID + * @param _tokenId ID of the token to be burned by the msg.sender + */ + public burn(_owner: string, _tokenId: BigNumber): ContractTxFunctionObj { + const self = (this as any) as DummyERC721TokenContract; + assert.isString('_owner', _owner); + assert.isBigNumber('_tokenId', _tokenId); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('burn(address,uint256)', [ + _owner.toLowerCase(), + _tokenId, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('burn(address,uint256)', [ + _owner.toLowerCase(), + _tokenId, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('burn(address,uint256)', [ + _owner.toLowerCase(), + _tokenId, + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('burn(address,uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('burn(address,uint256)', [ + _owner.toLowerCase(), + _tokenId, + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Throws if `_tokenId` is not a valid NFT. + * @param _tokenId The NFT to find the approved address for + * @returns The approved address for this NFT, or the zero address if there is none + */ + public getApproved(_tokenId: BigNumber): ContractFunctionObj { + const self = (this as any) as DummyERC721TokenContract; + assert.isBigNumber('_tokenId', _tokenId); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('getApproved(uint256)', [_tokenId]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('getApproved(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('getApproved(uint256)', [_tokenId]); + return abiEncodedTransactionData; + }, + }; + } + public isApprovedForAll(_owner: string, _operator: string): ContractFunctionObj { + const self = (this as any) as DummyERC721TokenContract; + assert.isString('_owner', _owner); + assert.isString('_operator', _operator); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('isApprovedForAll(address,address)', [ + _owner.toLowerCase(), + _operator.toLowerCase(), + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('isApprovedForAll(address,address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('isApprovedForAll(address,address)', [ + _owner.toLowerCase(), + _operator.toLowerCase(), + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Function to mint a new token + * Reverts if the given token ID already exists + * @param _to Address of the beneficiary that will own the minted token + * @param _tokenId ID of the token to be minted by the msg.sender + */ + public mint(_to: string, _tokenId: BigNumber): ContractTxFunctionObj { + const self = (this as any) as DummyERC721TokenContract; + assert.isString('_to', _to); + assert.isBigNumber('_tokenId', _tokenId); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('mint(address,uint256)', [_to.toLowerCase(), _tokenId]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('mint(address,uint256)', [_to.toLowerCase(), _tokenId]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('mint(address,uint256)', [_to.toLowerCase(), _tokenId]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('mint(address,uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('mint(address,uint256)', [ + _to.toLowerCase(), + _tokenId, + ]); + return abiEncodedTransactionData; + }, + }; + } + public name(): ContractFunctionObj { + const self = (this as any) as DummyERC721TokenContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('name()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('name()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('name()', []); + return abiEncodedTransactionData; + }, + }; + } + public owner(): ContractFunctionObj { + const self = (this as any) as DummyERC721TokenContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('owner()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('owner()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('owner()', []); + return abiEncodedTransactionData; + }, + }; + } + /** + * NFTs assigned to zero address are considered invalid, and queries + * about them do throw. + * @param _tokenId The identifier for an NFT + * @returns The address of the owner of the NFT + */ + public ownerOf(_tokenId: BigNumber): ContractFunctionObj { + const self = (this as any) as DummyERC721TokenContract; + assert.isBigNumber('_tokenId', _tokenId); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('ownerOf(uint256)', [_tokenId]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('ownerOf(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('ownerOf(uint256)', [_tokenId]); + return abiEncodedTransactionData; + }, + }; + } + /** + * This works identically to the other function with an extra data parameter, + * except this function just sets data to "". + * @param _from The current owner of the NFT + * @param _to The new owner + * @param _tokenId The NFT to transfer + */ + public safeTransferFrom1(_from: string, _to: string, _tokenId: BigNumber): ContractTxFunctionObj { + const self = (this as any) as DummyERC721TokenContract; + assert.isString('_from', _from); + assert.isString('_to', _to); + assert.isBigNumber('_tokenId', _tokenId); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('safeTransferFrom(address,address,uint256)', [ + _from.toLowerCase(), + _to.toLowerCase(), + _tokenId, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('safeTransferFrom(address,address,uint256)', [ + _from.toLowerCase(), + _to.toLowerCase(), + _tokenId, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('safeTransferFrom(address,address,uint256)', [ + _from.toLowerCase(), + _to.toLowerCase(), + _tokenId, + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('safeTransferFrom(address,address,uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'safeTransferFrom(address,address,uint256)', + [_from.toLowerCase(), _to.toLowerCase(), _tokenId], + ); + return abiEncodedTransactionData; + }, + }; + } + /** + * Throws unless `msg.sender` is the current owner, an authorized + * operator, or the approved address for this NFT. Throws if `_from` is + * not the current owner. Throws if `_to` is the zero address. Throws if + * `_tokenId` is not a valid NFT. When transfer is complete, this function + * checks if `_to` is a smart contract (code size > 0). If so, it calls + * `onERC721Received` on `_to` and throws if the return value is not + * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`. + * @param _from The current owner of the NFT + * @param _to The new owner + * @param _tokenId The NFT to transfer + * @param _data Additional data with no specified format, sent in call to `_to` + */ + public safeTransferFrom2( + _from: string, + _to: string, + _tokenId: BigNumber, + _data: string, + ): ContractTxFunctionObj { + const self = (this as any) as DummyERC721TokenContract; + assert.isString('_from', _from); + assert.isString('_to', _to); + assert.isBigNumber('_tokenId', _tokenId); + assert.isString('_data', _data); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('safeTransferFrom(address,address,uint256,bytes)', [ + _from.toLowerCase(), + _to.toLowerCase(), + _tokenId, + _data, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('safeTransferFrom(address,address,uint256,bytes)', [ + _from.toLowerCase(), + _to.toLowerCase(), + _tokenId, + _data, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('safeTransferFrom(address,address,uint256,bytes)', [ + _from.toLowerCase(), + _to.toLowerCase(), + _tokenId, + _data, + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('safeTransferFrom(address,address,uint256,bytes)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'safeTransferFrom(address,address,uint256,bytes)', + [_from.toLowerCase(), _to.toLowerCase(), _tokenId, _data], + ); + return abiEncodedTransactionData; + }, + }; + } + /** + * Emits the ApprovalForAll event. The contract MUST allow + * multiple operators per owner. + * @param _operator Address to add to the set of authorized operators + * @param _approved True if the operator is approved, false to revoke approval + */ + public setApprovalForAll(_operator: string, _approved: boolean): ContractTxFunctionObj { + const self = (this as any) as DummyERC721TokenContract; + assert.isString('_operator', _operator); + assert.isBoolean('_approved', _approved); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('setApprovalForAll(address,bool)', [ + _operator.toLowerCase(), + _approved, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('setApprovalForAll(address,bool)', [ + _operator.toLowerCase(), + _approved, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('setApprovalForAll(address,bool)', [ + _operator.toLowerCase(), + _approved, + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('setApprovalForAll(address,bool)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('setApprovalForAll(address,bool)', [ + _operator.toLowerCase(), + _approved, + ]); + return abiEncodedTransactionData; + }, + }; + } + public symbol(): ContractFunctionObj { + const self = (this as any) as DummyERC721TokenContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('symbol()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('symbol()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('symbol()', []); + return abiEncodedTransactionData; + }, + }; + } + /** + * Throws unless `msg.sender` is the current owner, an authorized + * operator, or the approved address for this NFT. Throws if `_from` is + * not the current owner. Throws if `_to` is the zero address. Throws if + * `_tokenId` is not a valid NFT. + * @param _from The current owner of the NFT + * @param _to The new owner + * @param _tokenId The NFT to transfer + */ + public transferFrom(_from: string, _to: string, _tokenId: BigNumber): ContractTxFunctionObj { + const self = (this as any) as DummyERC721TokenContract; + assert.isString('_from', _from); + assert.isString('_to', _to); + assert.isBigNumber('_tokenId', _tokenId); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [ + _from.toLowerCase(), + _to.toLowerCase(), + _tokenId, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [ + _from.toLowerCase(), + _to.toLowerCase(), + _tokenId, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [ + _from.toLowerCase(), + _to.toLowerCase(), + _tokenId, + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('transferFrom(address,address,uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [ + _from.toLowerCase(), + _to.toLowerCase(), + _tokenId, + ]); + return abiEncodedTransactionData; + }, + }; + } + public transferOwnership(newOwner: string): ContractTxFunctionObj { + const self = (this as any) as DummyERC721TokenContract; + assert.isString('newOwner', newOwner); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('transferOwnership(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('transferOwnership(address)', [ + newOwner.toLowerCase(), + ]); + return abiEncodedTransactionData; + }, + }; + } + /** * Subscribe to an event type emitted by the DummyERC721Token contract. * @param eventName The DummyERC721Token contract event you would like to subscribe to. @@ -2519,6 +2009,12 @@ export class DummyERC721TokenContract extends BaseContract { DummyERC721TokenContract.ABI(), this._web3Wrapper, ); + DummyERC721TokenContract.ABI().forEach((item, index) => { + if (item.type === 'function') { + const methodAbi = item as MethodAbi; + this._methodABIIndex[methodAbi.name] = index; + } + }); } } diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/dutch_auction.ts b/packages/abi-gen-wrappers/src/generated-wrappers/dutch_auction.ts index 15a3297209..44b3af45b4 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/dutch_auction.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/dutch_auction.ts @@ -1,7 +1,15 @@ // tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma enum-naming // tslint:disable:whitespace no-unbound-method no-trailing-whitespace // tslint:disable:no-unused-variable -import { BaseContract, PromiseWithTransactionHash } from '@0x/base-contract'; +import { + AwaitTransactionSuccessOpts, + ContractFunctionObj, + ContractTxFunctionObj, + SendTransactionOpts, + BaseContract, + PromiseWithTransactionHash, + methodAbiToFunctionSignature, +} from '@0x/base-contract'; import { schemas } from '@0x/json-schemas'; import { BlockParam, @@ -18,13 +26,7 @@ import { SupportedProvider, } from 'ethereum-types'; import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils'; -import { - AwaitTransactionSuccessOpts, - EventCallback, - IndexedFilterValues, - SendTransactionOpts, - SimpleContractArtifact, -} from '@0x/types'; +import { EventCallback, IndexedFilterValues, SimpleContractArtifact } from '@0x/types'; import { Web3Wrapper } from '@0x/web3-wrapper'; import { assert } from '@0x/assert'; import * as ethers from 'ethers'; @@ -38,666 +40,7 @@ export class DutchAuctionContract extends BaseContract { * @ignore */ public static deployedBytecode: string | undefined; - /** - * Calculates the Auction Details for the given order - */ - public getAuctionDetails = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param order The sell order - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - order: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - }, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - const self = (this as any) as DutchAuctionContract; - const encodedData = self._strictEncodeArguments( - 'getAuctionDetails((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes))', - [order], - ); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.getAuctionDetails.callAsync(order, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param order The sell order - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - order: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - }, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - const self = (this as any) as DutchAuctionContract; - const txHashPromise = self.getAuctionDetails.sendTransactionAsync(order, txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param order The sell order - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - order: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - }, - txData?: Partial | undefined, - ): Promise { - const self = (this as any) as DutchAuctionContract; - const encodedData = self._strictEncodeArguments( - 'getAuctionDetails((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes))', - [order], - ); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param order The sell order - * @returns AuctionDetails - */ - async callAsync( - order: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - }, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise<{ - beginTimeSeconds: BigNumber; - endTimeSeconds: BigNumber; - beginAmount: BigNumber; - endAmount: BigNumber; - currentAmount: BigNumber; - currentTimeSeconds: BigNumber; - }> { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DutchAuctionContract; - const encodedData = self._strictEncodeArguments( - 'getAuctionDetails((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes))', - [order], - ); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder( - 'getAuctionDetails((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes))', - ); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue<{ - beginTimeSeconds: BigNumber; - endTimeSeconds: BigNumber; - beginAmount: BigNumber; - endAmount: BigNumber; - currentAmount: BigNumber; - currentTimeSeconds: BigNumber; - }>(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param order The sell order - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(order: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - }): string { - const self = (this as any) as DutchAuctionContract; - const abiEncodedTransactionData = self._strictEncodeArguments( - 'getAuctionDetails((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes))', - [order], - ); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as DutchAuctionContract; - const abiEncoder = self._lookupAbiEncoder( - 'getAuctionDetails((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes))', - ); - return abiEncoder.getSelector(); - }, - }; - /** - * Matches the buy and sell orders at an amount given the following: the current block time, the auction - * start time and the auction begin amount. The sell order is a an order at the lowest amount - * at the end of the auction. Excess from the match is transferred to the seller. - * Over time the price moves from beginAmount to endAmount given the current block.timestamp. - * sellOrder.expiryTimeSeconds is the end time of the auction. - * sellOrder.takerAssetAmount is the end amount of the auction (lowest possible amount). - * sellOrder.makerAssetData is the ABI encoded Asset Proxy data with the following data appended - * buyOrder.makerAssetData is the buyers bid on the auction, must meet the amount for the current block timestamp - * (uint256 beginTimeSeconds, uint256 beginAmount). - * This function reverts in the following scenarios: - * * Auction has not started (auctionDetails.currentTimeSeconds < auctionDetails.beginTimeSeconds) - * * Auction has expired (auctionDetails.endTimeSeconds < auctionDetails.currentTimeSeconds) - * * Amount is invalid: Buy order amount is too low (buyOrder.makerAssetAmount < auctionDetails.currentAmount) - * * Amount is invalid: Invalid begin amount (auctionDetails.beginAmount > auctionDetails.endAmount) - * * Any failure in the 0x Match Orders - */ - public matchOrders = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param buyOrder The Buyer's order. This order is for the current expected - * price of the auction. - * @param sellOrder The Seller's order. This order is for the lowest amount (at - * the end of the auction). - * @param buySignature Proof that order was created by the buyer. - * @param sellSignature Proof that order was created by the seller. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - buyOrder: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - }, - sellOrder: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - }, - buySignature: string, - sellSignature: string, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('buySignature', buySignature); - assert.isString('sellSignature', sellSignature); - const self = (this as any) as DutchAuctionContract; - const encodedData = self._strictEncodeArguments( - 'matchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),bytes,bytes)', - [buyOrder, sellOrder, buySignature, sellSignature], - ); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.matchOrders.callAsync(buyOrder, sellOrder, buySignature, sellSignature, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param buyOrder The Buyer's order. This order is for the current expected - * price of the auction. - * @param sellOrder The Seller's order. This order is for the lowest amount (at - * the end of the auction). - * @param buySignature Proof that order was created by the buyer. - * @param sellSignature Proof that order was created by the seller. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - buyOrder: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - }, - sellOrder: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - }, - buySignature: string, - sellSignature: string, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('buySignature', buySignature); - assert.isString('sellSignature', sellSignature); - const self = (this as any) as DutchAuctionContract; - const txHashPromise = self.matchOrders.sendTransactionAsync( - buyOrder, - sellOrder, - buySignature, - sellSignature, - txData, - opts, - ); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param buyOrder The Buyer's order. This order is for the current expected - * price of the auction. - * @param sellOrder The Seller's order. This order is for the lowest amount (at - * the end of the auction). - * @param buySignature Proof that order was created by the buyer. - * @param sellSignature Proof that order was created by the seller. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - buyOrder: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - }, - sellOrder: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - }, - buySignature: string, - sellSignature: string, - txData?: Partial | undefined, - ): Promise { - assert.isString('buySignature', buySignature); - assert.isString('sellSignature', sellSignature); - const self = (this as any) as DutchAuctionContract; - const encodedData = self._strictEncodeArguments( - 'matchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),bytes,bytes)', - [buyOrder, sellOrder, buySignature, sellSignature], - ); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param buyOrder The Buyer's order. This order is for the current expected - * price of the auction. - * @param sellOrder The Seller's order. This order is for the lowest amount (at - * the end of the auction). - * @param buySignature Proof that order was created by the buyer. - * @param sellSignature Proof that order was created by the seller. - * @returns matchedFillResults amounts filled and fees paid by maker and taker of matched orders. - */ - async callAsync( - buyOrder: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - }, - sellOrder: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - }, - buySignature: string, - sellSignature: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise<{ - left: { - makerAssetFilledAmount: BigNumber; - takerAssetFilledAmount: BigNumber; - makerFeePaid: BigNumber; - takerFeePaid: BigNumber; - }; - right: { - makerAssetFilledAmount: BigNumber; - takerAssetFilledAmount: BigNumber; - makerFeePaid: BigNumber; - takerFeePaid: BigNumber; - }; - leftMakerAssetSpreadAmount: BigNumber; - }> { - assert.isString('buySignature', buySignature); - assert.isString('sellSignature', sellSignature); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as DutchAuctionContract; - const encodedData = self._strictEncodeArguments( - 'matchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),bytes,bytes)', - [buyOrder, sellOrder, buySignature, sellSignature], - ); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder( - 'matchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),bytes,bytes)', - ); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue<{ - left: { - makerAssetFilledAmount: BigNumber; - takerAssetFilledAmount: BigNumber; - makerFeePaid: BigNumber; - takerFeePaid: BigNumber; - }; - right: { - makerAssetFilledAmount: BigNumber; - takerAssetFilledAmount: BigNumber; - makerFeePaid: BigNumber; - takerFeePaid: BigNumber; - }; - leftMakerAssetSpreadAmount: BigNumber; - }>(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param buyOrder The Buyer's order. This order is for the current expected - * price of the auction. - * @param sellOrder The Seller's order. This order is for the lowest amount (at - * the end of the auction). - * @param buySignature Proof that order was created by the buyer. - * @param sellSignature Proof that order was created by the seller. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData( - buyOrder: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - }, - sellOrder: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - }, - buySignature: string, - sellSignature: string, - ): string { - assert.isString('buySignature', buySignature); - assert.isString('sellSignature', sellSignature); - const self = (this as any) as DutchAuctionContract; - const abiEncodedTransactionData = self._strictEncodeArguments( - 'matchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),bytes,bytes)', - [buyOrder, sellOrder, buySignature, sellSignature], - ); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as DutchAuctionContract; - const abiEncoder = self._lookupAbiEncoder( - 'matchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),bytes,bytes)', - ); - return abiEncoder.getSelector(); - }, - }; + private _methodABIIndex: { [name: string]: number } = {}; public static async deployFrom0xArtifactAsync( artifact: ContractArtifact | SimpleContractArtifact, supportedProvider: SupportedProvider, @@ -1071,6 +414,418 @@ export class DutchAuctionContract extends BaseContract { ] as ContractAbi; return abi; } + + public getFunctionSignature(methodName: string): string { + const index = this._methodABIIndex[methodName]; + const methodAbi = DutchAuctionContract.ABI()[index] as MethodAbi; + const functionSignature = methodAbiToFunctionSignature(methodAbi); + return functionSignature; + } + public getABIDecodedTransactionData(methodName: string, callData: string): T { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as DutchAuctionContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + const abiDecodedCallData = abiEncoder.strictDecode(callData); + return abiDecodedCallData; + } + public getABIDecodedReturnData(methodName: string, callData: string): T { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as DutchAuctionContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + const abiDecodedCallData = abiEncoder.strictDecodeReturnValue(callData); + return abiDecodedCallData; + } + public getSelector(methodName: string): string { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as DutchAuctionContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + return abiEncoder.getSelector(); + } + + /** + * Calculates the Auction Details for the given order + * @param order The sell order + * @returns AuctionDetails + */ + public getAuctionDetails(order: { + makerAddress: string; + takerAddress: string; + feeRecipientAddress: string; + senderAddress: string; + makerAssetAmount: BigNumber; + takerAssetAmount: BigNumber; + makerFee: BigNumber; + takerFee: BigNumber; + expirationTimeSeconds: BigNumber; + salt: BigNumber; + makerAssetData: string; + takerAssetData: string; + }): ContractTxFunctionObj<{ + beginTimeSeconds: BigNumber; + endTimeSeconds: BigNumber; + beginAmount: BigNumber; + endAmount: BigNumber; + currentAmount: BigNumber; + currentTimeSeconds: BigNumber; + }> { + const self = (this as any) as DutchAuctionContract; + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments( + 'getAuctionDetails((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes))', + [order], + ); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments( + 'getAuctionDetails((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes))', + [order], + ); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync( + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise<{ + beginTimeSeconds: BigNumber; + endTimeSeconds: BigNumber; + beginAmount: BigNumber; + endAmount: BigNumber; + currentAmount: BigNumber; + currentTimeSeconds: BigNumber; + }> { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments( + 'getAuctionDetails((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes))', + [order], + ); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder( + 'getAuctionDetails((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes))', + ); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<{ + beginTimeSeconds: BigNumber; + endTimeSeconds: BigNumber; + beginAmount: BigNumber; + endAmount: BigNumber; + currentAmount: BigNumber; + currentTimeSeconds: BigNumber; + }>(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'getAuctionDetails((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes))', + [order], + ); + return abiEncodedTransactionData; + }, + }; + } + /** + * Matches the buy and sell orders at an amount given the following: the current block time, the auction + * start time and the auction begin amount. The sell order is a an order at the lowest amount + * at the end of the auction. Excess from the match is transferred to the seller. + * Over time the price moves from beginAmount to endAmount given the current block.timestamp. + * sellOrder.expiryTimeSeconds is the end time of the auction. + * sellOrder.takerAssetAmount is the end amount of the auction (lowest possible amount). + * sellOrder.makerAssetData is the ABI encoded Asset Proxy data with the following data appended + * buyOrder.makerAssetData is the buyers bid on the auction, must meet the amount for the current block timestamp + * (uint256 beginTimeSeconds, uint256 beginAmount). + * This function reverts in the following scenarios: + * * Auction has not started (auctionDetails.currentTimeSeconds < auctionDetails.beginTimeSeconds) + * * Auction has expired (auctionDetails.endTimeSeconds < auctionDetails.currentTimeSeconds) + * * Amount is invalid: Buy order amount is too low (buyOrder.makerAssetAmount < auctionDetails.currentAmount) + * * Amount is invalid: Invalid begin amount (auctionDetails.beginAmount > auctionDetails.endAmount) + * * Any failure in the 0x Match Orders + * @param buyOrder The Buyer's order. This order is for the current expected + * price of the auction. + * @param sellOrder The Seller's order. This order is for the lowest amount (at + * the end of the auction). + * @param buySignature Proof that order was created by the buyer. + * @param sellSignature Proof that order was created by the seller. + * @returns matchedFillResults amounts filled and fees paid by maker and taker of matched orders. + */ + public matchOrders( + buyOrder: { + makerAddress: string; + takerAddress: string; + feeRecipientAddress: string; + senderAddress: string; + makerAssetAmount: BigNumber; + takerAssetAmount: BigNumber; + makerFee: BigNumber; + takerFee: BigNumber; + expirationTimeSeconds: BigNumber; + salt: BigNumber; + makerAssetData: string; + takerAssetData: string; + }, + sellOrder: { + makerAddress: string; + takerAddress: string; + feeRecipientAddress: string; + senderAddress: string; + makerAssetAmount: BigNumber; + takerAssetAmount: BigNumber; + makerFee: BigNumber; + takerFee: BigNumber; + expirationTimeSeconds: BigNumber; + salt: BigNumber; + makerAssetData: string; + takerAssetData: string; + }, + buySignature: string, + sellSignature: string, + ): ContractTxFunctionObj<{ + left: { + makerAssetFilledAmount: BigNumber; + takerAssetFilledAmount: BigNumber; + makerFeePaid: BigNumber; + takerFeePaid: BigNumber; + }; + right: { + makerAssetFilledAmount: BigNumber; + takerAssetFilledAmount: BigNumber; + makerFeePaid: BigNumber; + takerFeePaid: BigNumber; + }; + leftMakerAssetSpreadAmount: BigNumber; + }> { + const self = (this as any) as DutchAuctionContract; + + assert.isString('buySignature', buySignature); + assert.isString('sellSignature', sellSignature); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments( + 'matchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),bytes,bytes)', + [buyOrder, sellOrder, buySignature, sellSignature], + ); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments( + 'matchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),bytes,bytes)', + [buyOrder, sellOrder, buySignature, sellSignature], + ); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync( + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise<{ + left: { + makerAssetFilledAmount: BigNumber; + takerAssetFilledAmount: BigNumber; + makerFeePaid: BigNumber; + takerFeePaid: BigNumber; + }; + right: { + makerAssetFilledAmount: BigNumber; + takerAssetFilledAmount: BigNumber; + makerFeePaid: BigNumber; + takerFeePaid: BigNumber; + }; + leftMakerAssetSpreadAmount: BigNumber; + }> { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments( + 'matchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),bytes,bytes)', + [buyOrder, sellOrder, buySignature, sellSignature], + ); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder( + 'matchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),bytes,bytes)', + ); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<{ + left: { + makerAssetFilledAmount: BigNumber; + takerAssetFilledAmount: BigNumber; + makerFeePaid: BigNumber; + takerFeePaid: BigNumber; + }; + right: { + makerAssetFilledAmount: BigNumber; + takerAssetFilledAmount: BigNumber; + makerFeePaid: BigNumber; + takerFeePaid: BigNumber; + }; + leftMakerAssetSpreadAmount: BigNumber; + }>(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'matchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),bytes,bytes)', + [buyOrder, sellOrder, buySignature, sellSignature], + ); + return abiEncodedTransactionData; + }, + }; + } + constructor( address: string, supportedProvider: SupportedProvider, @@ -1088,6 +843,12 @@ export class DutchAuctionContract extends BaseContract { deployedBytecode, ); classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']); + DutchAuctionContract.ABI().forEach((item, index) => { + if (item.type === 'function') { + const methodAbi = item as MethodAbi; + this._methodABIIndex[methodAbi.name] = index; + } + }); } } diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_mintable.ts b/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_mintable.ts index 9d8a0f0167..e0351a29b7 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_mintable.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_mintable.ts @@ -1,7 +1,16 @@ // tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma enum-naming // tslint:disable:whitespace no-unbound-method no-trailing-whitespace // tslint:disable:no-unused-variable -import { BaseContract, SubscriptionManager, PromiseWithTransactionHash } from '@0x/base-contract'; +import { + AwaitTransactionSuccessOpts, + ContractFunctionObj, + ContractTxFunctionObj, + SendTransactionOpts, + BaseContract, + SubscriptionManager, + PromiseWithTransactionHash, + methodAbiToFunctionSignature, +} from '@0x/base-contract'; import { schemas } from '@0x/json-schemas'; import { BlockParam, @@ -19,13 +28,7 @@ import { SupportedProvider, } from 'ethereum-types'; import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils'; -import { - AwaitTransactionSuccessOpts, - EventCallback, - IndexedFilterValues, - SendTransactionOpts, - SimpleContractArtifact, -} from '@0x/types'; +import { EventCallback, IndexedFilterValues, SimpleContractArtifact } from '@0x/types'; import { Web3Wrapper } from '@0x/web3-wrapper'; import { assert } from '@0x/assert'; import * as ethers from 'ethers'; @@ -80,2063 +83,7 @@ export class ERC1155MintableContract extends BaseContract { */ public static deployedBytecode = '0x608060405234801561001057600080fd5b50600436106101765760003560e01c80639f4b286a116100d8578063e0a5c9491161008c578063f242432a11610066578063f242432a146107bb578063f94190881461085d578063fc67bf1c146108d457610176565b8063e0a5c94914610726578063e44591f014610763578063e985e9c51461078057610176565b8063adebf6f2116100bd578063adebf6f21461067a578063cc10e40114610697578063cd53d08e1461070957610176565b80639f4b286a146105c8578063a22cb4651461063f57610176565b80636352211e1161012f5780637269a327116101145780637269a327146104c557806378b27221146104e25780639cca1c64146105ab57610176565b80636352211e146104625780636f969c2d146104a857610176565b80632eb2c2d6116101605780632eb2c2d6146101e35780634e1273f41461031f5780635e81b9581461043157610176565b8062fdd58e1461017b57806308d7d469146101c6575b600080fd5b6101b46004803603604081101561019157600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81351690602001356108dc565b60408051918252519081900360200190f35b6101b4600480360360208110156101dc57600080fd5b5035610966565b61031d600480360360a08110156101f957600080fd5b73ffffffffffffffffffffffffffffffffffffffff823581169260208101359091169181019060608101604082013564010000000081111561023a57600080fd5b82018360208201111561024c57600080fd5b8035906020019184602083028401116401000000008311171561026e57600080fd5b91939092909160208101903564010000000081111561028c57600080fd5b82018360208201111561029e57600080fd5b803590602001918460208302840111640100000000831117156102c057600080fd5b9193909290916020810190356401000000008111156102de57600080fd5b8201836020820111156102f057600080fd5b8035906020019184600183028401116401000000008311171561031257600080fd5b509092509050610978565b005b6103e16004803603604081101561033557600080fd5b81019060208101813564010000000081111561035057600080fd5b82018360208201111561036257600080fd5b8035906020019184602083028401116401000000008311171561038457600080fd5b9193909290916020810190356401000000008111156103a257600080fd5b8201836020820111156103b457600080fd5b803590602001918460208302840111640100000000831117156103d657600080fd5b509092509050611192565b60408051602080825283518183015283519192839290830191858101910280838360005b8381101561041d578181015183820152602001610405565b505050509050019250505060405180910390f35b61044e6004803603602081101561044757600080fd5b5035611357565b604080519115158252519081900360200190f35b61047f6004803603602081101561047857600080fd5b503561139d565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b6101b4600480360360208110156104be57600080fd5b50356113c5565b61044e600480360360208110156104db57600080fd5b50356113ea565b61031d600480360360608110156104f857600080fd5b8135919081019060408101602082013564010000000081111561051a57600080fd5b82018360208201111561052c57600080fd5b8035906020019184602083028401116401000000008311171561054e57600080fd5b91939092909160208101903564010000000081111561056c57600080fd5b82018360208201111561057e57600080fd5b803590602001918460208302840111640100000000831117156105a057600080fd5b50909250905061142f565b6101b4600480360360208110156105c157600080fd5b5035611760565b61031d600480360360408110156105de57600080fd5b8135919081019060408101602082013564010000000081111561060057600080fd5b82018360208201111561061257600080fd5b8035906020019184600183028401116401000000008311171561063457600080fd5b509092509050611775565b61031d6004803603604081101561065557600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81351690602001351515611875565b61044e6004803603602081101561069057600080fd5b503561190e565b6101b4600480360360408110156106ad57600080fd5b8101906020810181356401000000008111156106c857600080fd5b8201836020820111156106da57600080fd5b803590602001918460018302840111640100000000831117156106fc57600080fd5b9193509150351515611934565b61047f6004803603602081101561071f57600080fd5b5035611a6d565b61072e611a95565b604080517fffffffff000000000000000000000000000000000000000000000000000000009092168252519081900360200190f35b61044e6004803603602081101561077957600080fd5b5035611ab9565b61044e6004803603604081101561079657600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81358116916020013516611ae1565b61031d600480360360a08110156107d157600080fd5b73ffffffffffffffffffffffffffffffffffffffff823581169260208101359091169160408201359160608101359181019060a08101608082013564010000000081111561081e57600080fd5b82018360208201111561083057600080fd5b8035906020019184600183028401116401000000008311171561085257600080fd5b509092509050611b1c565b61031d6004803603604081101561087357600080fd5b8135919081019060408101602082013564010000000081111561089557600080fd5b8201836020820111156108a757600080fd5b803590602001918460208302840111640100000000831117156108c957600080fd5b5090925090506120fb565b61072e61242b565b60006108e782611357565b1561092e5760008281526020819052604090205473ffffffffffffffffffffffffffffffffffffffff848116911614610921576000610924565b60015b60ff169050610960565b50600081815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff861684529091529020545b92915050565b60056020526000908152604090205481565b73ffffffffffffffffffffffffffffffffffffffff87166109fa57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f43414e4e4f545f5452414e534645525f544f5f414444524553535f5a45524f00604482015290519081900360640190fd5b848314610a6857604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f544f4b454e5f414e445f56414c5545535f4c454e4754485f4d49534d41544348604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff8816331480610ac1575073ffffffffffffffffffffffffffffffffffffffff8816600090815260026020908152604080832033845290915290205460ff1615156001145b610b2c57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f494e53554646494349454e545f414c4c4f57414e434500000000000000000000604482015290519081900360640190fd5b60005b85811015610deb576000878783818110610b4557fe5b9050602002013590506000868684818110610b5c57fe5b905060200201359050610b6e82611ab9565b15610cc85780600114610be257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f414d4f554e545f455155414c5f544f5f4f4e455f524551554952454400000000604482015290519081900360640190fd5b60008281526020819052604090205473ffffffffffffffffffffffffffffffffffffffff8c8116911614610c7757604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f4e46545f4e4f545f4f574e45445f42595f46524f4d5f41444452455353000000604482015290519081900360640190fd5b600082815260208190526040902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff8c16179055610de1565b600082815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8f168452909152902054610d02908261244f565b6001600084815260200190815260200160002060008d73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610db06001600084815260200190815260200160002060008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482612473565b600083815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8f1684529091529020555b5050600101610b2f565b508673ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb898989896040518080602001806020018381038352878782818152602001925060200280828437600083820152601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169091018481038352858152602090810191508690860280828437600083820152604051601f9091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169092018290039850909650505050505050a4610f1f8773ffffffffffffffffffffffffffffffffffffffff1661248f565b156111885760008773ffffffffffffffffffffffffffffffffffffffff1663bc197c81338b8a8a8a8a8a8a6040518963ffffffff1660e01b8152600401808973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001806020018060200184810384528a8a82818152602001925060200280828437600083820152601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169091018581038452888152602090810191508990890280828437600083820152601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01690910185810383528681526020019050868680828437600081840152601f19601f8201169050808301925050509b505050505050505050505050602060405180830381600087803b1580156110a857600080fd5b505af11580156110bc573d6000803e3d6000fd5b505050506040513d60208110156110d257600080fd5b505190507fffffffff0000000000000000000000000000000000000000000000000000000081167fbc197c81000000000000000000000000000000000000000000000000000000001461118657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f4241445f52454345495645525f52455455524e5f56414c554500000000000000604482015290519081900360640190fd5b505b5050505050505050565b60608382146111ec576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602481526020018061256a6024913960400191505060405180910390fd5b604080518581526020808702820101909152848015611215578160200160208202803883390190505b50905060005b8481101561134e57600084848381811061123157fe5b90506020020135905061124381611357565b156112b95786868381811061125457fe5b600084815260208181526040909120549102929092013573ffffffffffffffffffffffffffffffffffffffff9081169216919091149050611296576000611299565b60015b60ff168383815181106112a857fe5b602002602001018181525050611345565b6000818152600160205260408120908888858181106112d457fe5b9050602002013573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483838151811061133857fe5b6020026020010181815250505b5060010161121b565b50949350505050565b60007f80000000000000000000000000000000000000000000000000000000000000008083161480156109605750506fffffffffffffffffffffffffffffffff16151590565b60009081526020819052604090205473ffffffffffffffffffffffffffffffffffffffff1690565b7fffffffffffffffffffffffffffffffff000000000000000000000000000000001690565b60007f80000000000000000000000000000000000000000000000000000000000000008083161480156109605750506fffffffffffffffffffffffffffffffff161590565b600085815260046020526040902054859073ffffffffffffffffffffffffffffffffffffffff16331461146157600080fd5b61146a8661190e565b6114bf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602d81526020018061258e602d913960400191505060405180910390fd5b60005b848110156117575760008686838181106114d857fe5b9050602002013573ffffffffffffffffffffffffffffffffffffffff169050600085858481811061150557fe5b60008c815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8916845282529091205491029290920135925061154a91839150612473565b60008a815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff87168085529083528184209490945580518d8152918201859052805133927fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f6292908290030190a46115d68273ffffffffffffffffffffffffffffffffffffffff1661248f565b1561174d57604080517ff23a6e6100000000000000000000000000000000000000000000000000000000815233600482018190526024820152604481018b90526064810183905260a06084820152600060a48201819052915173ffffffffffffffffffffffffffffffffffffffff85169163f23a6e619160e480830192602092919082900301818787803b15801561166d57600080fd5b505af1158015611681573d6000803e3d6000fd5b505050506040513d602081101561169757600080fd5b505190507fffffffff0000000000000000000000000000000000000000000000000000000081167ff23a6e61000000000000000000000000000000000000000000000000000000001461174b57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f4241445f52454345495645525f52455455524e5f56414c554500000000000000604482015290519081900360640190fd5b505b50506001016114c2565b50505050505050565b6fffffffffffffffffffffffffffffffff1690565b600083815260046020908152604080832080547fffffffffffffffffffffffff0000000000000000000000000000000000000000163390811790915581518781529283018490528151849391927fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62928290030190a4801561187057827f6bb7ff708619ba0610cba295a58592e0451dee2622938c8755667688daf3529b838360405180806020018281038252848482818152602001925080828437600083820152604051601f9091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169092018290039550909350505050a25b505050565b33600081815260026020908152604080832073ffffffffffffffffffffffffffffffffffffffff87168085529083529281902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016861515908117909155815190815290519293927f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31929181900390910190a35050565b7f8000000000000000000000000000000000000000000000000000000000000000161590565b600380546001019081905560801b811561196b577f8000000000000000000000000000000000000000000000000000000000000000175b600081815260046020908152604080832080547fffffffffffffffffffffffff0000000000000000000000000000000000000000163390811790915581518581529283018490528151849391927fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62928290030190a48215611a6657807f6bb7ff708619ba0610cba295a58592e0451dee2622938c8755667688daf3529b858560405180806020018281038252848482818152602001925080828437600083820152604051601f9091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169092018290039550909350505050a25b9392505050565b60046020526000908152604090205473ffffffffffffffffffffffffffffffffffffffff1681565b7ff23a6e610000000000000000000000000000000000000000000000000000000081565b7f80000000000000000000000000000000000000000000000000000000000000009081161490565b73ffffffffffffffffffffffffffffffffffffffff918216600090815260026020908152604080832093909416825291909152205460ff1690565b73ffffffffffffffffffffffffffffffffffffffff8516611b9e57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f43414e4e4f545f5452414e534645525f544f5f414444524553535f5a45524f00604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff8616331480611bf7575073ffffffffffffffffffffffffffffffffffffffff8616600090815260026020908152604080832033845290915290205460ff1615156001145b611c6257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f494e53554646494349454e545f414c4c4f57414e434500000000000000000000604482015290519081900360640190fd5b611c6b84611ab9565b15611dc55782600114611cdf57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f414d4f554e545f455155414c5f544f5f4f4e455f524551554952454400000000604482015290519081900360640190fd5b60008481526020819052604090205473ffffffffffffffffffffffffffffffffffffffff878116911614611d7457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f4e46545f4e4f545f4f574e45445f42595f46524f4d5f41444452455353000000604482015290519081900360640190fd5b600084815260208190526040902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff8716179055611e74565b600084815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8a168452909152902054611dff908461244f565b600085815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8b81168552925280832093909355871681522054611e439084612473565b600085815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8a1684529091529020555b8473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f628787604051808381526020018281526020019250505060405180910390a4611f178573ffffffffffffffffffffffffffffffffffffffff1661248f565b156120f35760008573ffffffffffffffffffffffffffffffffffffffff1663f23a6e613389888888886040518763ffffffff1660e01b8152600401808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001858152602001848152602001806020018281038252848482818152602001925080828437600081840152601f19601f820116905080830192505050975050505050505050602060405180830381600087803b15801561201557600080fd5b505af1158015612029573d6000803e3d6000fd5b505050506040513d602081101561203f57600080fd5b505190507fffffffff0000000000000000000000000000000000000000000000000000000081167ff23a6e61000000000000000000000000000000000000000000000000000000001461175757604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f4241445f52454345495645525f52455455524e5f56414c554500000000000000604482015290519081900360640190fd5b505050505050565b600083815260046020526040902054839073ffffffffffffffffffffffffffffffffffffffff16331461212d57600080fd5b61213684611ab9565b61218b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602d81526020018061253d602d913960400191505060405180910390fd5b600084815260056020526040812054600101905b838110156123f75760008585838181106121b557fe5b8486018a176000818152602081815260408083208054958302979097013573ffffffffffffffffffffffffffffffffffffffff167fffffffffffffffffffffffff00000000000000000000000000000000000000009095168517909655855183815260019181019190915285519396509194869450909233927fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f6292908290030190a46122768273ffffffffffffffffffffffffffffffffffffffff1661248f565b156123ed57604080517ff23a6e6100000000000000000000000000000000000000000000000000000000815233600482018190526024820152604481018390526001606482015260a06084820152600060a48201819052915173ffffffffffffffffffffffffffffffffffffffff85169163f23a6e619160e480830192602092919082900301818787803b15801561230d57600080fd5b505af1158015612321573d6000803e3d6000fd5b505050506040513d602081101561233757600080fd5b505190507fffffffff0000000000000000000000000000000000000000000000000000000081167ff23a6e6100000000000000000000000000000000000000000000000000000000146123eb57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f4241445f52454345495645525f52455455524e5f56414c554500000000000000604482015290519081900360640190fd5b505b505060010161219f565b50600085815260056020526040902054612412908490612473565b6000958652600560205260409095209490945550505050565b7fbc197c810000000000000000000000000000000000000000000000000000000081565b60008282111561246d5761246d61246860028585612495565b612534565b50900390565b600082820183811015611a6657611a6661246860008686612495565b3b151590565b606063e946c1bb60e01b848484604051602401808460038111156124b557fe5b60ff1681526020018381526020018281526020019350505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505090509392505050565b805160208201fdfe54524945445f544f5f4d494e545f4e4f4e5f46554e4749424c455f464f525f46554e4749424c455f544f4b454e4f574e4552535f414e445f4944535f4d5553545f484156455f53414d455f4c454e47544854524945445f544f5f4d494e545f46554e4749424c455f464f525f4e4f4e5f46554e4749424c455f544f4b454ea265627a7a723158205af7d187cbffb255b374d24e5838a04f6b3a3245622025907396b2a61f9d93da64736f6c634300050c0032'; - public ERC1155_BATCH_RECEIVED = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ERC1155MintableContract; - const encodedData = self._strictEncodeArguments('ERC1155_BATCH_RECEIVED()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('ERC1155_BATCH_RECEIVED()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public ERC1155_RECEIVED = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ERC1155MintableContract; - const encodedData = self._strictEncodeArguments('ERC1155_RECEIVED()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('ERC1155_RECEIVED()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public balanceOf = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param owner The address of the token holder - * @param id ID of the Token - * @returns The _owner's balance of the Token type requested - */ - async callAsync( - owner: string, - id: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('owner', owner); - assert.isBigNumber('id', id); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ERC1155MintableContract; - const encodedData = self._strictEncodeArguments('balanceOf(address,uint256)', [owner.toLowerCase(), id]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('balanceOf(address,uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public balanceOfBatch = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param owners The addresses of the token holders - * @param ids ID of the Tokens - * @returns The _owner's balance of the Token types requested - */ - async callAsync( - owners: string[], - ids: BigNumber[], - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isArray('owners', owners); - assert.isArray('ids', ids); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ERC1155MintableContract; - const encodedData = self._strictEncodeArguments('balanceOfBatch(address[],uint256[])', [owners, ids]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('balanceOfBatch(address[],uint256[])'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * creates a new token - */ - public create = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param uri URI of token - * @param isNF is non-fungible token - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - uri: string, - isNF: boolean, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('uri', uri); - assert.isBoolean('isNF', isNF); - const self = (this as any) as ERC1155MintableContract; - const encodedData = self._strictEncodeArguments('create(string,bool)', [uri, isNF]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.create.callAsync(uri, isNF, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param uri URI of token - * @param isNF is non-fungible token - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - uri: string, - isNF: boolean, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('uri', uri); - assert.isBoolean('isNF', isNF); - const self = (this as any) as ERC1155MintableContract; - const txHashPromise = self.create.sendTransactionAsync(uri, isNF, txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param uri URI of token - * @param isNF is non-fungible token - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync(uri: string, isNF: boolean, txData?: Partial | undefined): Promise { - assert.isString('uri', uri); - assert.isBoolean('isNF', isNF); - const self = (this as any) as ERC1155MintableContract; - const encodedData = self._strictEncodeArguments('create(string,bool)', [uri, isNF]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param uri URI of token - * @param isNF is non-fungible token - * @returns type_ of token (a unique identifier) - */ - async callAsync( - uri: string, - isNF: boolean, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('uri', uri); - assert.isBoolean('isNF', isNF); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ERC1155MintableContract; - const encodedData = self._strictEncodeArguments('create(string,bool)', [uri, isNF]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('create(string,bool)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param uri URI of token - * @param isNF is non-fungible token - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(uri: string, isNF: boolean): string { - assert.isString('uri', uri); - assert.isBoolean('isNF', isNF); - const self = (this as any) as ERC1155MintableContract; - const abiEncodedTransactionData = self._strictEncodeArguments('create(string,bool)', [uri, isNF]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as ERC1155MintableContract; - const abiEncoder = self._lookupAbiEncoder('create(string,bool)'); - return abiEncoder.getSelector(); - }, - }; - /** - * creates a new token - */ - public createWithType = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param type_ of token - * @param uri URI of token - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - type_: BigNumber, - uri: string, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isBigNumber('type_', type_); - assert.isString('uri', uri); - const self = (this as any) as ERC1155MintableContract; - const encodedData = self._strictEncodeArguments('createWithType(uint256,string)', [type_, uri]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.createWithType.callAsync(type_, uri, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param type_ of token - * @param uri URI of token - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - type_: BigNumber, - uri: string, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isBigNumber('type_', type_); - assert.isString('uri', uri); - const self = (this as any) as ERC1155MintableContract; - const txHashPromise = self.createWithType.sendTransactionAsync(type_, uri, txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param type_ of token - * @param uri URI of token - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync(type_: BigNumber, uri: string, txData?: Partial | undefined): Promise { - assert.isBigNumber('type_', type_); - assert.isString('uri', uri); - const self = (this as any) as ERC1155MintableContract; - const encodedData = self._strictEncodeArguments('createWithType(uint256,string)', [type_, uri]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param type_ of token - * @param uri URI of token - */ - async callAsync( - type_: BigNumber, - uri: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isBigNumber('type_', type_); - assert.isString('uri', uri); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ERC1155MintableContract; - const encodedData = self._strictEncodeArguments('createWithType(uint256,string)', [type_, uri]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('createWithType(uint256,string)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param type_ of token - * @param uri URI of token - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(type_: BigNumber, uri: string): string { - assert.isBigNumber('type_', type_); - assert.isString('uri', uri); - const self = (this as any) as ERC1155MintableContract; - const abiEncodedTransactionData = self._strictEncodeArguments('createWithType(uint256,string)', [ - type_, - uri, - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as ERC1155MintableContract; - const abiEncoder = self._lookupAbiEncoder('createWithType(uint256,string)'); - return abiEncoder.getSelector(); - }, - }; - public creators = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync( - index_0: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isBigNumber('index_0', index_0); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ERC1155MintableContract; - const encodedData = self._strictEncodeArguments('creators(uint256)', [index_0]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('creators(uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Returns base type of non-fungible token - */ - public getNonFungibleBaseType = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync( - id: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isBigNumber('id', id); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ERC1155MintableContract; - const encodedData = self._strictEncodeArguments('getNonFungibleBaseType(uint256)', [id]); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('getNonFungibleBaseType(uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Returns index of non-fungible token - */ - public getNonFungibleIndex = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync( - id: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isBigNumber('id', id); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ERC1155MintableContract; - const encodedData = self._strictEncodeArguments('getNonFungibleIndex(uint256)', [id]); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('getNonFungibleIndex(uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public isApprovedForAll = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param owner The owner of the Tokens - * @param operator Address of authorized operator - * @returns True if the operator is approved, false if not - */ - async callAsync( - owner: string, - operator: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('owner', owner); - assert.isString('operator', operator); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ERC1155MintableContract; - const encodedData = self._strictEncodeArguments('isApprovedForAll(address,address)', [ - owner.toLowerCase(), - operator.toLowerCase(), - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('isApprovedForAll(address,address)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Returns true if token is fungible - */ - public isFungible = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(id: BigNumber, callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.isBigNumber('id', id); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ERC1155MintableContract; - const encodedData = self._strictEncodeArguments('isFungible(uint256)', [id]); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('isFungible(uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Returns true if token is non-fungible - */ - public isNonFungible = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(id: BigNumber, callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.isBigNumber('id', id); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ERC1155MintableContract; - const encodedData = self._strictEncodeArguments('isNonFungible(uint256)', [id]); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('isNonFungible(uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Returns true if input is base-type of a non-fungible token - */ - public isNonFungibleBaseType = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(id: BigNumber, callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.isBigNumber('id', id); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ERC1155MintableContract; - const encodedData = self._strictEncodeArguments('isNonFungibleBaseType(uint256)', [id]); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('isNonFungibleBaseType(uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Returns true if input is a non-fungible token - */ - public isNonFungibleItem = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(id: BigNumber, callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.isBigNumber('id', id); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ERC1155MintableContract; - const encodedData = self._strictEncodeArguments('isNonFungibleItem(uint256)', [id]); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('isNonFungibleItem(uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public maxIndex = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync( - index_0: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isBigNumber('index_0', index_0); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ERC1155MintableContract; - const encodedData = self._strictEncodeArguments('maxIndex(uint256)', [index_0]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('maxIndex(uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * mints fungible tokens - */ - public mintFungible = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param id token type - * @param to beneficiaries of minted tokens - * @param quantities amounts of minted tokens - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - id: BigNumber, - to: string[], - quantities: BigNumber[], - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isBigNumber('id', id); - assert.isArray('to', to); - assert.isArray('quantities', quantities); - const self = (this as any) as ERC1155MintableContract; - const encodedData = self._strictEncodeArguments('mintFungible(uint256,address[],uint256[])', [ - id, - to, - quantities, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.mintFungible.callAsync(id, to, quantities, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param id token type - * @param to beneficiaries of minted tokens - * @param quantities amounts of minted tokens - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - id: BigNumber, - to: string[], - quantities: BigNumber[], - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isBigNumber('id', id); - assert.isArray('to', to); - assert.isArray('quantities', quantities); - const self = (this as any) as ERC1155MintableContract; - const txHashPromise = self.mintFungible.sendTransactionAsync(id, to, quantities, txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param id token type - * @param to beneficiaries of minted tokens - * @param quantities amounts of minted tokens - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - id: BigNumber, - to: string[], - quantities: BigNumber[], - txData?: Partial | undefined, - ): Promise { - assert.isBigNumber('id', id); - assert.isArray('to', to); - assert.isArray('quantities', quantities); - const self = (this as any) as ERC1155MintableContract; - const encodedData = self._strictEncodeArguments('mintFungible(uint256,address[],uint256[])', [ - id, - to, - quantities, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param id token type - * @param to beneficiaries of minted tokens - * @param quantities amounts of minted tokens - */ - async callAsync( - id: BigNumber, - to: string[], - quantities: BigNumber[], - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isBigNumber('id', id); - assert.isArray('to', to); - assert.isArray('quantities', quantities); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ERC1155MintableContract; - const encodedData = self._strictEncodeArguments('mintFungible(uint256,address[],uint256[])', [ - id, - to, - quantities, - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('mintFungible(uint256,address[],uint256[])'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param id token type - * @param to beneficiaries of minted tokens - * @param quantities amounts of minted tokens - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(id: BigNumber, to: string[], quantities: BigNumber[]): string { - assert.isBigNumber('id', id); - assert.isArray('to', to); - assert.isArray('quantities', quantities); - const self = (this as any) as ERC1155MintableContract; - const abiEncodedTransactionData = self._strictEncodeArguments('mintFungible(uint256,address[],uint256[])', [ - id, - to, - quantities, - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as ERC1155MintableContract; - const abiEncoder = self._lookupAbiEncoder('mintFungible(uint256,address[],uint256[])'); - return abiEncoder.getSelector(); - }, - }; - /** - * mints a non-fungible token - */ - public mintNonFungible = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param type_ token type - * @param to beneficiaries of minted tokens - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - type_: BigNumber, - to: string[], - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isBigNumber('type_', type_); - assert.isArray('to', to); - const self = (this as any) as ERC1155MintableContract; - const encodedData = self._strictEncodeArguments('mintNonFungible(uint256,address[])', [type_, to]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.mintNonFungible.callAsync(type_, to, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param type_ token type - * @param to beneficiaries of minted tokens - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - type_: BigNumber, - to: string[], - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isBigNumber('type_', type_); - assert.isArray('to', to); - const self = (this as any) as ERC1155MintableContract; - const txHashPromise = self.mintNonFungible.sendTransactionAsync(type_, to, txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param type_ token type - * @param to beneficiaries of minted tokens - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync(type_: BigNumber, to: string[], txData?: Partial | undefined): Promise { - assert.isBigNumber('type_', type_); - assert.isArray('to', to); - const self = (this as any) as ERC1155MintableContract; - const encodedData = self._strictEncodeArguments('mintNonFungible(uint256,address[])', [type_, to]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param type_ token type - * @param to beneficiaries of minted tokens - */ - async callAsync( - type_: BigNumber, - to: string[], - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isBigNumber('type_', type_); - assert.isArray('to', to); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ERC1155MintableContract; - const encodedData = self._strictEncodeArguments('mintNonFungible(uint256,address[])', [type_, to]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('mintNonFungible(uint256,address[])'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param type_ token type - * @param to beneficiaries of minted tokens - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(type_: BigNumber, to: string[]): string { - assert.isBigNumber('type_', type_); - assert.isArray('to', to); - const self = (this as any) as ERC1155MintableContract; - const abiEncodedTransactionData = self._strictEncodeArguments('mintNonFungible(uint256,address[])', [ - type_, - to, - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as ERC1155MintableContract; - const abiEncoder = self._lookupAbiEncoder('mintNonFungible(uint256,address[])'); - return abiEncoder.getSelector(); - }, - }; - /** - * returns owner of a non-fungible token - */ - public ownerOf = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(id: BigNumber, callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.isBigNumber('id', id); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ERC1155MintableContract; - const encodedData = self._strictEncodeArguments('ownerOf(uint256)', [id]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('ownerOf(uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * MUST emit TransferBatch event on success. Caller must be approved to manage the _from account's tokens (see isApprovedForAll). MUST throw if `_to` is the zero address. MUST throw if length of `_ids` is not the same as length of `_values`. MUST throw if any of the balance of sender for token `_ids` is lower than the respective `_values` sent. MUST throw on any other error. When transfer is complete, this function MUST check if `_to` is a smart contract (code size > 0). If so, it MUST call `onERC1155BatchReceived` on `_to` and revert if the return value is not `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))`. - */ - public safeBatchTransferFrom = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param from Source addresses - * @param to Target addresses - * @param ids IDs of each token type - * @param values Transfer amounts per token type - * @param data Additional data with no specified format, sent in call to `_to` - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - from: string, - to: string, - ids: BigNumber[], - values: BigNumber[], - data: string, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('from', from); - assert.isString('to', to); - assert.isArray('ids', ids); - assert.isArray('values', values); - assert.isString('data', data); - const self = (this as any) as ERC1155MintableContract; - const encodedData = self._strictEncodeArguments( - 'safeBatchTransferFrom(address,address,uint256[],uint256[],bytes)', - [from.toLowerCase(), to.toLowerCase(), ids, values, data], - ); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.safeBatchTransferFrom.callAsync(from, to, ids, values, data, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param from Source addresses - * @param to Target addresses - * @param ids IDs of each token type - * @param values Transfer amounts per token type - * @param data Additional data with no specified format, sent in call to `_to` - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - from: string, - to: string, - ids: BigNumber[], - values: BigNumber[], - data: string, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('from', from); - assert.isString('to', to); - assert.isArray('ids', ids); - assert.isArray('values', values); - assert.isString('data', data); - const self = (this as any) as ERC1155MintableContract; - const txHashPromise = self.safeBatchTransferFrom.sendTransactionAsync( - from.toLowerCase(), - to.toLowerCase(), - ids, - values, - data, - txData, - opts, - ); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param from Source addresses - * @param to Target addresses - * @param ids IDs of each token type - * @param values Transfer amounts per token type - * @param data Additional data with no specified format, sent in call to `_to` - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - from: string, - to: string, - ids: BigNumber[], - values: BigNumber[], - data: string, - txData?: Partial | undefined, - ): Promise { - assert.isString('from', from); - assert.isString('to', to); - assert.isArray('ids', ids); - assert.isArray('values', values); - assert.isString('data', data); - const self = (this as any) as ERC1155MintableContract; - const encodedData = self._strictEncodeArguments( - 'safeBatchTransferFrom(address,address,uint256[],uint256[],bytes)', - [from.toLowerCase(), to.toLowerCase(), ids, values, data], - ); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param from Source addresses - * @param to Target addresses - * @param ids IDs of each token type - * @param values Transfer amounts per token type - * @param data Additional data with no specified format, sent in call to `_to` - */ - async callAsync( - from: string, - to: string, - ids: BigNumber[], - values: BigNumber[], - data: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('from', from); - assert.isString('to', to); - assert.isArray('ids', ids); - assert.isArray('values', values); - assert.isString('data', data); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ERC1155MintableContract; - const encodedData = self._strictEncodeArguments( - 'safeBatchTransferFrom(address,address,uint256[],uint256[],bytes)', - [from.toLowerCase(), to.toLowerCase(), ids, values, data], - ); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder( - 'safeBatchTransferFrom(address,address,uint256[],uint256[],bytes)', - ); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param from Source addresses - * @param to Target addresses - * @param ids IDs of each token type - * @param values Transfer amounts per token type - * @param data Additional data with no specified format, sent in call to `_to` - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData( - from: string, - to: string, - ids: BigNumber[], - values: BigNumber[], - data: string, - ): string { - assert.isString('from', from); - assert.isString('to', to); - assert.isArray('ids', ids); - assert.isArray('values', values); - assert.isString('data', data); - const self = (this as any) as ERC1155MintableContract; - const abiEncodedTransactionData = self._strictEncodeArguments( - 'safeBatchTransferFrom(address,address,uint256[],uint256[],bytes)', - [from.toLowerCase(), to.toLowerCase(), ids, values, data], - ); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as ERC1155MintableContract; - const abiEncoder = self._lookupAbiEncoder( - 'safeBatchTransferFrom(address,address,uint256[],uint256[],bytes)', - ); - return abiEncoder.getSelector(); - }, - }; - /** - * MUST emit TransferSingle event on success. Caller must be approved to manage the _from account's tokens (see isApprovedForAll). MUST throw if `_to` is the zero address. MUST throw if balance of sender for token `_id` is lower than the `_value` sent. MUST throw on any other error. When transfer is complete, this function MUST check if `_to` is a smart contract (code size > 0). If so, it MUST call `onERC1155Received` on `_to` and revert if the return value is not `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))`. - */ - public safeTransferFrom = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param from Source address - * @param to Target address - * @param id ID of the token type - * @param value Transfer amount - * @param data Additional data with no specified format, sent in call to `_to` - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - from: string, - to: string, - id: BigNumber, - value: BigNumber, - data: string, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('from', from); - assert.isString('to', to); - assert.isBigNumber('id', id); - assert.isBigNumber('value', value); - assert.isString('data', data); - const self = (this as any) as ERC1155MintableContract; - const encodedData = self._strictEncodeArguments('safeTransferFrom(address,address,uint256,uint256,bytes)', [ - from.toLowerCase(), - to.toLowerCase(), - id, - value, - data, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.safeTransferFrom.callAsync(from, to, id, value, data, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param from Source address - * @param to Target address - * @param id ID of the token type - * @param value Transfer amount - * @param data Additional data with no specified format, sent in call to `_to` - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - from: string, - to: string, - id: BigNumber, - value: BigNumber, - data: string, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('from', from); - assert.isString('to', to); - assert.isBigNumber('id', id); - assert.isBigNumber('value', value); - assert.isString('data', data); - const self = (this as any) as ERC1155MintableContract; - const txHashPromise = self.safeTransferFrom.sendTransactionAsync( - from.toLowerCase(), - to.toLowerCase(), - id, - value, - data, - txData, - opts, - ); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param from Source address - * @param to Target address - * @param id ID of the token type - * @param value Transfer amount - * @param data Additional data with no specified format, sent in call to `_to` - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - from: string, - to: string, - id: BigNumber, - value: BigNumber, - data: string, - txData?: Partial | undefined, - ): Promise { - assert.isString('from', from); - assert.isString('to', to); - assert.isBigNumber('id', id); - assert.isBigNumber('value', value); - assert.isString('data', data); - const self = (this as any) as ERC1155MintableContract; - const encodedData = self._strictEncodeArguments('safeTransferFrom(address,address,uint256,uint256,bytes)', [ - from.toLowerCase(), - to.toLowerCase(), - id, - value, - data, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param from Source address - * @param to Target address - * @param id ID of the token type - * @param value Transfer amount - * @param data Additional data with no specified format, sent in call to `_to` - */ - async callAsync( - from: string, - to: string, - id: BigNumber, - value: BigNumber, - data: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('from', from); - assert.isString('to', to); - assert.isBigNumber('id', id); - assert.isBigNumber('value', value); - assert.isString('data', data); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ERC1155MintableContract; - const encodedData = self._strictEncodeArguments('safeTransferFrom(address,address,uint256,uint256,bytes)', [ - from.toLowerCase(), - to.toLowerCase(), - id, - value, - data, - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('safeTransferFrom(address,address,uint256,uint256,bytes)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param from Source address - * @param to Target address - * @param id ID of the token type - * @param value Transfer amount - * @param data Additional data with no specified format, sent in call to `_to` - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(from: string, to: string, id: BigNumber, value: BigNumber, data: string): string { - assert.isString('from', from); - assert.isString('to', to); - assert.isBigNumber('id', id); - assert.isBigNumber('value', value); - assert.isString('data', data); - const self = (this as any) as ERC1155MintableContract; - const abiEncodedTransactionData = self._strictEncodeArguments( - 'safeTransferFrom(address,address,uint256,uint256,bytes)', - [from.toLowerCase(), to.toLowerCase(), id, value, data], - ); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as ERC1155MintableContract; - const abiEncoder = self._lookupAbiEncoder('safeTransferFrom(address,address,uint256,uint256,bytes)'); - return abiEncoder.getSelector(); - }, - }; - /** - * MUST emit the ApprovalForAll event on success. - */ - public setApprovalForAll = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param operator Address to add to the set of authorized operators - * @param approved True if the operator is approved, false to revoke approval - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - operator: string, - approved: boolean, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('operator', operator); - assert.isBoolean('approved', approved); - const self = (this as any) as ERC1155MintableContract; - const encodedData = self._strictEncodeArguments('setApprovalForAll(address,bool)', [ - operator.toLowerCase(), - approved, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.setApprovalForAll.callAsync(operator, approved, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param operator Address to add to the set of authorized operators - * @param approved True if the operator is approved, false to revoke approval - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - operator: string, - approved: boolean, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('operator', operator); - assert.isBoolean('approved', approved); - const self = (this as any) as ERC1155MintableContract; - const txHashPromise = self.setApprovalForAll.sendTransactionAsync( - operator.toLowerCase(), - approved, - txData, - opts, - ); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param operator Address to add to the set of authorized operators - * @param approved True if the operator is approved, false to revoke approval - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - operator: string, - approved: boolean, - txData?: Partial | undefined, - ): Promise { - assert.isString('operator', operator); - assert.isBoolean('approved', approved); - const self = (this as any) as ERC1155MintableContract; - const encodedData = self._strictEncodeArguments('setApprovalForAll(address,bool)', [ - operator.toLowerCase(), - approved, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param operator Address to add to the set of authorized operators - * @param approved True if the operator is approved, false to revoke approval - */ - async callAsync( - operator: string, - approved: boolean, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('operator', operator); - assert.isBoolean('approved', approved); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ERC1155MintableContract; - const encodedData = self._strictEncodeArguments('setApprovalForAll(address,bool)', [ - operator.toLowerCase(), - approved, - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('setApprovalForAll(address,bool)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param operator Address to add to the set of authorized operators - * @param approved True if the operator is approved, false to revoke approval - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(operator: string, approved: boolean): string { - assert.isString('operator', operator); - assert.isBoolean('approved', approved); - const self = (this as any) as ERC1155MintableContract; - const abiEncodedTransactionData = self._strictEncodeArguments('setApprovalForAll(address,bool)', [ - operator.toLowerCase(), - approved, - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as ERC1155MintableContract; - const abiEncoder = self._lookupAbiEncoder('setApprovalForAll(address,bool)'); - return abiEncoder.getSelector(); - }, - }; + private _methodABIIndex: { [name: string]: number } = {}; private readonly _subscriptionManager: SubscriptionManager; public static async deployFrom0xArtifactAsync( artifact: ContractArtifact | SimpleContractArtifact, @@ -2744,6 +691,1554 @@ export class ERC1155MintableContract extends BaseContract { ] as ContractAbi; return abi; } + + public getFunctionSignature(methodName: string): string { + const index = this._methodABIIndex[methodName]; + const methodAbi = ERC1155MintableContract.ABI()[index] as MethodAbi; + const functionSignature = methodAbiToFunctionSignature(methodAbi); + return functionSignature; + } + public getABIDecodedTransactionData(methodName: string, callData: string): T { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as ERC1155MintableContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + const abiDecodedCallData = abiEncoder.strictDecode(callData); + return abiDecodedCallData; + } + public getABIDecodedReturnData(methodName: string, callData: string): T { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as ERC1155MintableContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + const abiDecodedCallData = abiEncoder.strictDecodeReturnValue(callData); + return abiDecodedCallData; + } + public getSelector(methodName: string): string { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as ERC1155MintableContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + return abiEncoder.getSelector(); + } + + public ERC1155_BATCH_RECEIVED(): ContractFunctionObj { + const self = (this as any) as ERC1155MintableContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('ERC1155_BATCH_RECEIVED()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('ERC1155_BATCH_RECEIVED()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('ERC1155_BATCH_RECEIVED()', []); + return abiEncodedTransactionData; + }, + }; + } + public ERC1155_RECEIVED(): ContractFunctionObj { + const self = (this as any) as ERC1155MintableContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('ERC1155_RECEIVED()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('ERC1155_RECEIVED()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('ERC1155_RECEIVED()', []); + return abiEncodedTransactionData; + }, + }; + } + public balanceOf(owner: string, id: BigNumber): ContractFunctionObj { + const self = (this as any) as ERC1155MintableContract; + assert.isString('owner', owner); + assert.isBigNumber('id', id); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('balanceOf(address,uint256)', [ + owner.toLowerCase(), + id, + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('balanceOf(address,uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('balanceOf(address,uint256)', [ + owner.toLowerCase(), + id, + ]); + return abiEncodedTransactionData; + }, + }; + } + public balanceOfBatch(owners: string[], ids: BigNumber[]): ContractFunctionObj { + const self = (this as any) as ERC1155MintableContract; + assert.isArray('owners', owners); + assert.isArray('ids', ids); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('balanceOfBatch(address[],uint256[])', [owners, ids]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('balanceOfBatch(address[],uint256[])'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('balanceOfBatch(address[],uint256[])', [ + owners, + ids, + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * creates a new token + * @param uri URI of token + * @param isNF is non-fungible token + * @returns type_ of token (a unique identifier) + */ + public create(uri: string, isNF: boolean): ContractTxFunctionObj { + const self = (this as any) as ERC1155MintableContract; + assert.isString('uri', uri); + assert.isBoolean('isNF', isNF); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('create(string,bool)', [uri, isNF]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('create(string,bool)', [uri, isNF]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('create(string,bool)', [uri, isNF]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('create(string,bool)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('create(string,bool)', [uri, isNF]); + return abiEncodedTransactionData; + }, + }; + } + /** + * creates a new token + * @param type_ of token + * @param uri URI of token + */ + public createWithType(type_: BigNumber, uri: string): ContractTxFunctionObj { + const self = (this as any) as ERC1155MintableContract; + assert.isBigNumber('type_', type_); + assert.isString('uri', uri); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('createWithType(uint256,string)', [type_, uri]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('createWithType(uint256,string)', [type_, uri]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('createWithType(uint256,string)', [type_, uri]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('createWithType(uint256,string)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('createWithType(uint256,string)', [ + type_, + uri, + ]); + return abiEncodedTransactionData; + }, + }; + } + public creators(index_0: BigNumber): ContractFunctionObj { + const self = (this as any) as ERC1155MintableContract; + assert.isBigNumber('index_0', index_0); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('creators(uint256)', [index_0]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('creators(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('creators(uint256)', [index_0]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Returns base type of non-fungible token + */ + public getNonFungibleBaseType(id: BigNumber): ContractFunctionObj { + const self = (this as any) as ERC1155MintableContract; + assert.isBigNumber('id', id); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('getNonFungibleBaseType(uint256)', [id]); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('getNonFungibleBaseType(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('getNonFungibleBaseType(uint256)', [id]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Returns index of non-fungible token + */ + public getNonFungibleIndex(id: BigNumber): ContractFunctionObj { + const self = (this as any) as ERC1155MintableContract; + assert.isBigNumber('id', id); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('getNonFungibleIndex(uint256)', [id]); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('getNonFungibleIndex(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('getNonFungibleIndex(uint256)', [id]); + return abiEncodedTransactionData; + }, + }; + } + public isApprovedForAll(owner: string, operator: string): ContractFunctionObj { + const self = (this as any) as ERC1155MintableContract; + assert.isString('owner', owner); + assert.isString('operator', operator); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('isApprovedForAll(address,address)', [ + owner.toLowerCase(), + operator.toLowerCase(), + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('isApprovedForAll(address,address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('isApprovedForAll(address,address)', [ + owner.toLowerCase(), + operator.toLowerCase(), + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Returns true if token is fungible + */ + public isFungible(id: BigNumber): ContractFunctionObj { + const self = (this as any) as ERC1155MintableContract; + assert.isBigNumber('id', id); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('isFungible(uint256)', [id]); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('isFungible(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('isFungible(uint256)', [id]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Returns true if token is non-fungible + */ + public isNonFungible(id: BigNumber): ContractFunctionObj { + const self = (this as any) as ERC1155MintableContract; + assert.isBigNumber('id', id); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('isNonFungible(uint256)', [id]); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('isNonFungible(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('isNonFungible(uint256)', [id]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Returns true if input is base-type of a non-fungible token + */ + public isNonFungibleBaseType(id: BigNumber): ContractFunctionObj { + const self = (this as any) as ERC1155MintableContract; + assert.isBigNumber('id', id); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('isNonFungibleBaseType(uint256)', [id]); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('isNonFungibleBaseType(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('isNonFungibleBaseType(uint256)', [id]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Returns true if input is a non-fungible token + */ + public isNonFungibleItem(id: BigNumber): ContractFunctionObj { + const self = (this as any) as ERC1155MintableContract; + assert.isBigNumber('id', id); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('isNonFungibleItem(uint256)', [id]); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('isNonFungibleItem(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('isNonFungibleItem(uint256)', [id]); + return abiEncodedTransactionData; + }, + }; + } + public maxIndex(index_0: BigNumber): ContractFunctionObj { + const self = (this as any) as ERC1155MintableContract; + assert.isBigNumber('index_0', index_0); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('maxIndex(uint256)', [index_0]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('maxIndex(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('maxIndex(uint256)', [index_0]); + return abiEncodedTransactionData; + }, + }; + } + /** + * mints fungible tokens + * @param id token type + * @param to beneficiaries of minted tokens + * @param quantities amounts of minted tokens + */ + public mintFungible(id: BigNumber, to: string[], quantities: BigNumber[]): ContractTxFunctionObj { + const self = (this as any) as ERC1155MintableContract; + assert.isBigNumber('id', id); + assert.isArray('to', to); + assert.isArray('quantities', quantities); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('mintFungible(uint256,address[],uint256[])', [ + id, + to, + quantities, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('mintFungible(uint256,address[],uint256[])', [ + id, + to, + quantities, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('mintFungible(uint256,address[],uint256[])', [ + id, + to, + quantities, + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('mintFungible(uint256,address[],uint256[])'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'mintFungible(uint256,address[],uint256[])', + [id, to, quantities], + ); + return abiEncodedTransactionData; + }, + }; + } + /** + * mints a non-fungible token + * @param type_ token type + * @param to beneficiaries of minted tokens + */ + public mintNonFungible(type_: BigNumber, to: string[]): ContractTxFunctionObj { + const self = (this as any) as ERC1155MintableContract; + assert.isBigNumber('type_', type_); + assert.isArray('to', to); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('mintNonFungible(uint256,address[])', [type_, to]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('mintNonFungible(uint256,address[])', [type_, to]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('mintNonFungible(uint256,address[])', [type_, to]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('mintNonFungible(uint256,address[])'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('mintNonFungible(uint256,address[])', [ + type_, + to, + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * returns owner of a non-fungible token + */ + public ownerOf(id: BigNumber): ContractFunctionObj { + const self = (this as any) as ERC1155MintableContract; + assert.isBigNumber('id', id); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('ownerOf(uint256)', [id]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('ownerOf(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('ownerOf(uint256)', [id]); + return abiEncodedTransactionData; + }, + }; + } + /** + * MUST emit TransferBatch event on success. Caller must be approved to manage the _from account's tokens (see isApprovedForAll). MUST throw if `_to` is the zero address. MUST throw if length of `_ids` is not the same as length of `_values`. MUST throw if any of the balance of sender for token `_ids` is lower than the respective `_values` sent. MUST throw on any other error. When transfer is complete, this function MUST check if `_to` is a smart contract (code size > 0). If so, it MUST call `onERC1155BatchReceived` on `_to` and revert if the return value is not `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))`. + * @param from Source addresses + * @param to Target addresses + * @param ids IDs of each token type + * @param values Transfer amounts per token type + * @param data Additional data with no specified format, sent in call to `_to` + */ + public safeBatchTransferFrom( + from: string, + to: string, + ids: BigNumber[], + values: BigNumber[], + data: string, + ): ContractTxFunctionObj { + const self = (this as any) as ERC1155MintableContract; + assert.isString('from', from); + assert.isString('to', to); + assert.isArray('ids', ids); + assert.isArray('values', values); + assert.isString('data', data); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments( + 'safeBatchTransferFrom(address,address,uint256[],uint256[],bytes)', + [from.toLowerCase(), to.toLowerCase(), ids, values, data], + ); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments( + 'safeBatchTransferFrom(address,address,uint256[],uint256[],bytes)', + [from.toLowerCase(), to.toLowerCase(), ids, values, data], + ); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments( + 'safeBatchTransferFrom(address,address,uint256[],uint256[],bytes)', + [from.toLowerCase(), to.toLowerCase(), ids, values, data], + ); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder( + 'safeBatchTransferFrom(address,address,uint256[],uint256[],bytes)', + ); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'safeBatchTransferFrom(address,address,uint256[],uint256[],bytes)', + [from.toLowerCase(), to.toLowerCase(), ids, values, data], + ); + return abiEncodedTransactionData; + }, + }; + } + /** + * MUST emit TransferSingle event on success. Caller must be approved to manage the _from account's tokens (see isApprovedForAll). MUST throw if `_to` is the zero address. MUST throw if balance of sender for token `_id` is lower than the `_value` sent. MUST throw on any other error. When transfer is complete, this function MUST check if `_to` is a smart contract (code size > 0). If so, it MUST call `onERC1155Received` on `_to` and revert if the return value is not `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))`. + * @param from Source address + * @param to Target address + * @param id ID of the token type + * @param value Transfer amount + * @param data Additional data with no specified format, sent in call to `_to` + */ + public safeTransferFrom( + from: string, + to: string, + id: BigNumber, + value: BigNumber, + data: string, + ): ContractTxFunctionObj { + const self = (this as any) as ERC1155MintableContract; + assert.isString('from', from); + assert.isString('to', to); + assert.isBigNumber('id', id); + assert.isBigNumber('value', value); + assert.isString('data', data); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments( + 'safeTransferFrom(address,address,uint256,uint256,bytes)', + [from.toLowerCase(), to.toLowerCase(), id, value, data], + ); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments( + 'safeTransferFrom(address,address,uint256,uint256,bytes)', + [from.toLowerCase(), to.toLowerCase(), id, value, data], + ); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments( + 'safeTransferFrom(address,address,uint256,uint256,bytes)', + [from.toLowerCase(), to.toLowerCase(), id, value, data], + ); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('safeTransferFrom(address,address,uint256,uint256,bytes)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'safeTransferFrom(address,address,uint256,uint256,bytes)', + [from.toLowerCase(), to.toLowerCase(), id, value, data], + ); + return abiEncodedTransactionData; + }, + }; + } + /** + * MUST emit the ApprovalForAll event on success. + * @param operator Address to add to the set of authorized operators + * @param approved True if the operator is approved, false to revoke approval + */ + public setApprovalForAll(operator: string, approved: boolean): ContractTxFunctionObj { + const self = (this as any) as ERC1155MintableContract; + assert.isString('operator', operator); + assert.isBoolean('approved', approved); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('setApprovalForAll(address,bool)', [ + operator.toLowerCase(), + approved, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('setApprovalForAll(address,bool)', [ + operator.toLowerCase(), + approved, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('setApprovalForAll(address,bool)', [ + operator.toLowerCase(), + approved, + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('setApprovalForAll(address,bool)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('setApprovalForAll(address,bool)', [ + operator.toLowerCase(), + approved, + ]); + return abiEncodedTransactionData; + }, + }; + } + /** * Subscribe to an event type emitted by the ERC1155Mintable contract. * @param eventName The ERC1155Mintable contract event you would like to subscribe to. @@ -2833,6 +2328,12 @@ export class ERC1155MintableContract extends BaseContract { ERC1155MintableContract.ABI(), this._web3Wrapper, ); + ERC1155MintableContract.ABI().forEach((item, index) => { + if (item.type === 'function') { + const methodAbi = item as MethodAbi; + this._methodABIIndex[methodAbi.name] = index; + } + }); } } diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts b/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts index d5c947103f..da2cb41209 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts @@ -1,7 +1,16 @@ // tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma enum-naming // tslint:disable:whitespace no-unbound-method no-trailing-whitespace // tslint:disable:no-unused-variable -import { BaseContract, SubscriptionManager, PromiseWithTransactionHash } from '@0x/base-contract'; +import { + AwaitTransactionSuccessOpts, + ContractFunctionObj, + ContractTxFunctionObj, + SendTransactionOpts, + BaseContract, + SubscriptionManager, + PromiseWithTransactionHash, + methodAbiToFunctionSignature, +} from '@0x/base-contract'; import { schemas } from '@0x/json-schemas'; import { BlockParam, @@ -19,13 +28,7 @@ import { SupportedProvider, } from 'ethereum-types'; import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils'; -import { - AwaitTransactionSuccessOpts, - EventCallback, - IndexedFilterValues, - SendTransactionOpts, - SimpleContractArtifact, -} from '@0x/types'; +import { EventCallback, IndexedFilterValues, SimpleContractArtifact } from '@0x/types'; import { Web3Wrapper } from '@0x/web3-wrapper'; import { assert } from '@0x/assert'; import * as ethers from 'ethers'; @@ -59,1131 +62,7 @@ export class ERC1155ProxyContract extends BaseContract { */ public static deployedBytecode = '0x608060405234801561001057600080fd5b50600436106100be5760003560e01c8063a85e59e411610076578063b91816111161005b578063b918161114610285578063d39de6e9146102cc578063f2fde38b14610324576100be565b8063a85e59e4146101b2578063ae25532e14610248576100be565b806370712939116100a7578063707129391461013e5780638da5cb5b146101715780639ad2674414610179576100be565b806342f1181e146100c3578063494503d4146100f8575b600080fd5b6100f6600480360360208110156100d957600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610357565b005b6101156004803603602081101561010e57600080fd5b5035610543565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b6100f66004803603602081101561015457600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610577565b61011561086a565b6100f66004803603604081101561018f57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135169060200135610886565b6100f6600480360360808110156101c857600080fd5b8101906020810181356401000000008111156101e357600080fd5b8201836020820111156101f557600080fd5b8035906020019184600183028401116401000000008311171561021757600080fd5b919350915073ffffffffffffffffffffffffffffffffffffffff813581169160208101359091169060400135610c37565b610250611138565b604080517fffffffff000000000000000000000000000000000000000000000000000000009092168252519081900360200190f35b6102b86004803603602081101561029b57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16611159565b604080519115158252519081900360200190f35b6102d461116e565b60408051602080825283518183015283519192839290830191858101910280838360005b838110156103105781810151838201526020016102f8565b505050509050019250505060405180910390f35b6100f66004803603602081101561033a57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166111dd565b60005473ffffffffffffffffffffffffffffffffffffffff1633146103dd57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f4f4e4c595f434f4e54524143545f4f574e455200000000000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff811660009081526001602052604090205460ff161561047257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f5441524745545f414c52454144595f415554484f52495a454400000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff8116600081815260016020819052604080832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00168317905560028054928301815583527f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace90910180547fffffffffffffffffffffffff00000000000000000000000000000000000000001684179055513392917f3147867c59d17e8fa9d522465651d44aae0a9e38f902f3475b97e58072f0ed4c91a350565b6002818154811061055057fe5b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff16905081565b60005473ffffffffffffffffffffffffffffffffffffffff1633146105fd57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f4f4e4c595f434f4e54524143545f4f574e455200000000000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff811660009081526001602052604090205460ff1661069157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f5441524745545f4e4f545f415554484f52495a45440000000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff8116600090815260016020526040812080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690555b600254811015610823578173ffffffffffffffffffffffffffffffffffffffff166002828154811061070b57fe5b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff16141561081b57600280547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff810190811061076357fe5b6000918252602090912001546002805473ffffffffffffffffffffffffffffffffffffffff909216918390811061079657fe5b600091825260209091200180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055600280547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01906108159082611407565b50610823565b6001016106dd565b50604051339073ffffffffffffffffffffffffffffffffffffffff8316907f1f32c1b084e2de0713b8fb16bd46bb9df710a3dbeae2f3ca93af46e016dcc6b090600090a350565b60005473ffffffffffffffffffffffffffffffffffffffff1681565b60005473ffffffffffffffffffffffffffffffffffffffff16331461090c57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f4f4e4c595f434f4e54524143545f4f574e455200000000000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff821660009081526001602052604090205460ff166109a057604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f5441524745545f4e4f545f415554484f52495a45440000000000000000000000604482015290519081900360640190fd5b6002548110610a1057604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f494e4445585f4f55545f4f465f424f554e445300000000000000000000000000604482015290519081900360640190fd5b8173ffffffffffffffffffffffffffffffffffffffff1660028281548110610a3457fe5b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff1614610ac257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f415554484f52495a45445f414444524553535f4d49534d415443480000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff8216600090815260016020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169055600280547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8101908110610b3d57fe5b6000918252602090912001546002805473ffffffffffffffffffffffffffffffffffffffff9092169183908110610b7057fe5b600091825260209091200180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055600280547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190610bef9082611407565b50604051339073ffffffffffffffffffffffffffffffffffffffff8416907f1f32c1b084e2de0713b8fb16bd46bb9df710a3dbeae2f3ca93af46e016dcc6b090600090a35050565b3360009081526001602052604090205460ff16610cb557604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f53454e4445525f4e4f545f415554484f52495a45440000000000000000000000604482015290519081900360640190fd5b60006060806060610d0b60048a8a90508b8b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525092949392505063ffffffff6112c3169050565b8060200190516080811015610d1f57600080fd5b815160208301805160405192949293830192919084640100000000821115610d4657600080fd5b908301906020820185811115610d5b57600080fd5b8251866020820283011164010000000082111715610d7857600080fd5b82525081516020918201928201910280838360005b83811015610da5578181015183820152602001610d8d565b5050505090500160405260200180516040519392919084640100000000821115610dce57600080fd5b908301906020820185811115610de357600080fd5b8251866020820283011164010000000082111715610e0057600080fd5b82525081516020918201928201910280838360005b83811015610e2d578181015183820152602001610e15565b5050505090500160405260200180516040519392919084640100000000821115610e5657600080fd5b908301906020820185811115610e6b57600080fd5b8251640100000000811182820188101715610e8557600080fd5b82525081516020918201929091019080838360005b83811015610eb2578181015183820152602001610e9a565b50505050905090810190601f168015610edf5780820380516001836020036101000a031916815260200191505b506040525050509350935093509350600082519050606081604051908082528060200260200182016040528015610f20578160200160208202803883390190505b50905060005b828114610f6957610f4a858281518110610f3c57fe5b602002602001015189611306565b828281518110610f5657fe5b6020908102919091010152600101610f26565b508573ffffffffffffffffffffffffffffffffffffffff16632eb2c2d68a8a8885886040518663ffffffff1660e01b8152600401808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001806020018060200180602001848103845287818151815260200191508051906020019060200280838360005b8381101561104657818101518382015260200161102e565b50505050905001848103835286818151815260200191508051906020019060200280838360005b8381101561108557818101518382015260200161106d565b50505050905001848103825285818151815260200191508051906020019080838360005b838110156110c15781810151838201526020016110a9565b50505050905090810190601f1680156110ee5780820380516001836020036101000a031916815260200191505b5098505050505050505050600060405180830381600087803b15801561111357600080fd5b505af1158015611127573d6000803e3d6000fd5b505050505050505050505050505050565b6000604051808061144f603091396030019050604051809103902090505b90565b60016020526000908152604090205460ff1681565b606060028054806020026020016040519081016040528092919081815260200182805480156111d357602002820191906000526020600020905b815473ffffffffffffffffffffffffffffffffffffffff1681526001909101906020018083116111a8575b5050505050905090565b60005473ffffffffffffffffffffffffffffffffffffffff16331461126357604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f4f4e4c595f434f4e54524143545f4f574e455200000000000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff8116156112c057600080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83161790555b50565b6060818311156112e1576112e16112dc60008585611340565b6113df565b83518211156112fa576112fa6112dc6001848751611340565b50819003910190815290565b6000826113155750600061133a565b8282028284828161132257fe5b0414611337576113376112dc600186866113e7565b90505b92915050565b6060632800659560e01b8484846040516024018084600781111561136057fe5b60ff1681526020018381526020018281526020019350505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505090509392505050565b805160208201fd5b606063e946c1bb60e01b8484846040516024018084600381111561136057fe5b81548183558181111561142b5760008381526020902061142b918101908301611430565b505050565b61115691905b8082111561144a5760008155600101611436565b509056fe4552433131353541737365747328616464726573732c75696e743235365b5d2c75696e743235365b5d2c627974657329a265627a7a72315820be5e6597d38133fd52aac17250498790f106d5d4d0e4ab30d0e854a2db1e2ffe64736f6c634300050c0032'; - /** - * Authorizes an address. - */ - public addAuthorizedAddress = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param target Address to authorize. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - target: string, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('target', target); - const self = (this as any) as ERC1155ProxyContract; - const encodedData = self._strictEncodeArguments('addAuthorizedAddress(address)', [target.toLowerCase()]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.addAuthorizedAddress.callAsync(target, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param target Address to authorize. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - target: string, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('target', target); - const self = (this as any) as ERC1155ProxyContract; - const txHashPromise = self.addAuthorizedAddress.sendTransactionAsync(target.toLowerCase(), txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param target Address to authorize. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync(target: string, txData?: Partial | undefined): Promise { - assert.isString('target', target); - const self = (this as any) as ERC1155ProxyContract; - const encodedData = self._strictEncodeArguments('addAuthorizedAddress(address)', [target.toLowerCase()]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param target Address to authorize. - */ - async callAsync(target: string, callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.isString('target', target); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ERC1155ProxyContract; - const encodedData = self._strictEncodeArguments('addAuthorizedAddress(address)', [target.toLowerCase()]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('addAuthorizedAddress(address)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param target Address to authorize. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(target: string): string { - assert.isString('target', target); - const self = (this as any) as ERC1155ProxyContract; - const abiEncodedTransactionData = self._strictEncodeArguments('addAuthorizedAddress(address)', [ - target.toLowerCase(), - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as ERC1155ProxyContract; - const abiEncoder = self._lookupAbiEncoder('addAuthorizedAddress(address)'); - return abiEncoder.getSelector(); - }, - }; - public authorities = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync( - index_0: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isBigNumber('index_0', index_0); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ERC1155ProxyContract; - const encodedData = self._strictEncodeArguments('authorities(uint256)', [index_0]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('authorities(uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public authorized = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync( - index_0: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('index_0', index_0); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ERC1155ProxyContract; - const encodedData = self._strictEncodeArguments('authorized(address)', [index_0.toLowerCase()]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('authorized(address)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Gets all authorized addresses. - */ - public getAuthorizedAddresses = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @returns Array of authorized addresses. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ERC1155ProxyContract; - const encodedData = self._strictEncodeArguments('getAuthorizedAddresses()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('getAuthorizedAddresses()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Gets the proxy id associated with the proxy address. - */ - public getProxyId = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @returns Proxy id. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ERC1155ProxyContract; - const encodedData = self._strictEncodeArguments('getProxyId()', []); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('getProxyId()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public owner = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ERC1155ProxyContract; - const encodedData = self._strictEncodeArguments('owner()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('owner()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Removes authorizion of an address. - */ - public removeAuthorizedAddress = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param target Address to remove authorization from. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - target: string, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('target', target); - const self = (this as any) as ERC1155ProxyContract; - const encodedData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [target.toLowerCase()]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.removeAuthorizedAddress.callAsync(target, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param target Address to remove authorization from. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - target: string, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('target', target); - const self = (this as any) as ERC1155ProxyContract; - const txHashPromise = self.removeAuthorizedAddress.sendTransactionAsync(target.toLowerCase(), txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param target Address to remove authorization from. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync(target: string, txData?: Partial | undefined): Promise { - assert.isString('target', target); - const self = (this as any) as ERC1155ProxyContract; - const encodedData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [target.toLowerCase()]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param target Address to remove authorization from. - */ - async callAsync(target: string, callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.isString('target', target); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ERC1155ProxyContract; - const encodedData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [target.toLowerCase()]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('removeAuthorizedAddress(address)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param target Address to remove authorization from. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(target: string): string { - assert.isString('target', target); - const self = (this as any) as ERC1155ProxyContract; - const abiEncodedTransactionData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [ - target.toLowerCase(), - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as ERC1155ProxyContract; - const abiEncoder = self._lookupAbiEncoder('removeAuthorizedAddress(address)'); - return abiEncoder.getSelector(); - }, - }; - /** - * Removes authorizion of an address. - */ - public removeAuthorizedAddressAtIndex = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param target Address to remove authorization from. - * @param index Index of target in authorities array. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - target: string, - index: BigNumber, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('target', target); - assert.isBigNumber('index', index); - const self = (this as any) as ERC1155ProxyContract; - const encodedData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [ - target.toLowerCase(), - index, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.removeAuthorizedAddressAtIndex.callAsync(target, index, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param target Address to remove authorization from. - * @param index Index of target in authorities array. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - target: string, - index: BigNumber, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('target', target); - assert.isBigNumber('index', index); - const self = (this as any) as ERC1155ProxyContract; - const txHashPromise = self.removeAuthorizedAddressAtIndex.sendTransactionAsync( - target.toLowerCase(), - index, - txData, - opts, - ); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param target Address to remove authorization from. - * @param index Index of target in authorities array. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - target: string, - index: BigNumber, - txData?: Partial | undefined, - ): Promise { - assert.isString('target', target); - assert.isBigNumber('index', index); - const self = (this as any) as ERC1155ProxyContract; - const encodedData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [ - target.toLowerCase(), - index, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param target Address to remove authorization from. - * @param index Index of target in authorities array. - */ - async callAsync( - target: string, - index: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('target', target); - assert.isBigNumber('index', index); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ERC1155ProxyContract; - const encodedData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [ - target.toLowerCase(), - index, - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('removeAuthorizedAddressAtIndex(address,uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param target Address to remove authorization from. - * @param index Index of target in authorities array. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(target: string, index: BigNumber): string { - assert.isString('target', target); - assert.isBigNumber('index', index); - const self = (this as any) as ERC1155ProxyContract; - const abiEncodedTransactionData = self._strictEncodeArguments( - 'removeAuthorizedAddressAtIndex(address,uint256)', - [target.toLowerCase(), index], - ); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as ERC1155ProxyContract; - const abiEncoder = self._lookupAbiEncoder('removeAuthorizedAddressAtIndex(address,uint256)'); - return abiEncoder.getSelector(); - }, - }; - /** - * Transfers batch of ERC1155 assets. Either succeeds or throws. - */ - public transferFrom = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param assetData Byte array encoded with ERC1155 token address, array of - * ids, array of values, and callback data. - * @param from Address to transfer assets from. - * @param to Address to transfer assets to. - * @param amount Amount that will be multiplied with each element of - * `assetData.values` to scale the values that will be transferred. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - assetData: string, - from: string, - to: string, - amount: BigNumber, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('assetData', assetData); - assert.isString('from', from); - assert.isString('to', to); - assert.isBigNumber('amount', amount); - const self = (this as any) as ERC1155ProxyContract; - const encodedData = self._strictEncodeArguments('transferFrom(bytes,address,address,uint256)', [ - assetData, - from.toLowerCase(), - to.toLowerCase(), - amount, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.transferFrom.callAsync(assetData, from, to, amount, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param assetData Byte array encoded with ERC1155 token address, array of - * ids, array of values, and callback data. - * @param from Address to transfer assets from. - * @param to Address to transfer assets to. - * @param amount Amount that will be multiplied with each element of - * `assetData.values` to scale the values that will be transferred. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - assetData: string, - from: string, - to: string, - amount: BigNumber, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('assetData', assetData); - assert.isString('from', from); - assert.isString('to', to); - assert.isBigNumber('amount', amount); - const self = (this as any) as ERC1155ProxyContract; - const txHashPromise = self.transferFrom.sendTransactionAsync( - assetData, - from.toLowerCase(), - to.toLowerCase(), - amount, - txData, - opts, - ); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param assetData Byte array encoded with ERC1155 token address, array of - * ids, array of values, and callback data. - * @param from Address to transfer assets from. - * @param to Address to transfer assets to. - * @param amount Amount that will be multiplied with each element of - * `assetData.values` to scale the values that will be transferred. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - assetData: string, - from: string, - to: string, - amount: BigNumber, - txData?: Partial | undefined, - ): Promise { - assert.isString('assetData', assetData); - assert.isString('from', from); - assert.isString('to', to); - assert.isBigNumber('amount', amount); - const self = (this as any) as ERC1155ProxyContract; - const encodedData = self._strictEncodeArguments('transferFrom(bytes,address,address,uint256)', [ - assetData, - from.toLowerCase(), - to.toLowerCase(), - amount, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param assetData Byte array encoded with ERC1155 token address, array of - * ids, array of values, and callback data. - * @param from Address to transfer assets from. - * @param to Address to transfer assets to. - * @param amount Amount that will be multiplied with each element of - * `assetData.values` to scale the values that will be transferred. - */ - async callAsync( - assetData: string, - from: string, - to: string, - amount: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('assetData', assetData); - assert.isString('from', from); - assert.isString('to', to); - assert.isBigNumber('amount', amount); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ERC1155ProxyContract; - const encodedData = self._strictEncodeArguments('transferFrom(bytes,address,address,uint256)', [ - assetData, - from.toLowerCase(), - to.toLowerCase(), - amount, - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('transferFrom(bytes,address,address,uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param assetData Byte array encoded with ERC1155 token address, array of - * ids, array of values, and callback data. - * @param from Address to transfer assets from. - * @param to Address to transfer assets to. - * @param amount Amount that will be multiplied with each element of - * `assetData.values` to scale the values that will be transferred. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(assetData: string, from: string, to: string, amount: BigNumber): string { - assert.isString('assetData', assetData); - assert.isString('from', from); - assert.isString('to', to); - assert.isBigNumber('amount', amount); - const self = (this as any) as ERC1155ProxyContract; - const abiEncodedTransactionData = self._strictEncodeArguments( - 'transferFrom(bytes,address,address,uint256)', - [assetData, from.toLowerCase(), to.toLowerCase(), amount], - ); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as ERC1155ProxyContract; - const abiEncoder = self._lookupAbiEncoder('transferFrom(bytes,address,address,uint256)'); - return abiEncoder.getSelector(); - }, - }; - public transferOwnership = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - newOwner: string, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('newOwner', newOwner); - const self = (this as any) as ERC1155ProxyContract; - const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.transferOwnership.callAsync(newOwner, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - newOwner: string, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('newOwner', newOwner); - const self = (this as any) as ERC1155ProxyContract; - const txHashPromise = self.transferOwnership.sendTransactionAsync(newOwner.toLowerCase(), txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync(newOwner: string, txData?: Partial | undefined): Promise { - assert.isString('newOwner', newOwner); - const self = (this as any) as ERC1155ProxyContract; - const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(newOwner: string, callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.isString('newOwner', newOwner); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ERC1155ProxyContract; - const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('transferOwnership(address)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(newOwner: string): string { - assert.isString('newOwner', newOwner); - const self = (this as any) as ERC1155ProxyContract; - const abiEncodedTransactionData = self._strictEncodeArguments('transferOwnership(address)', [ - newOwner.toLowerCase(), - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as ERC1155ProxyContract; - const abiEncoder = self._lookupAbiEncoder('transferOwnership(address)'); - return abiEncoder.getSelector(); - }, - }; + private _methodABIIndex: { [name: string]: number } = {}; private readonly _subscriptionManager: SubscriptionManager; public static async deployFrom0xArtifactAsync( artifact: ContractArtifact | SimpleContractArtifact, @@ -1459,6 +338,876 @@ export class ERC1155ProxyContract extends BaseContract { ] as ContractAbi; return abi; } + + public getFunctionSignature(methodName: string): string { + const index = this._methodABIIndex[methodName]; + const methodAbi = ERC1155ProxyContract.ABI()[index] as MethodAbi; + const functionSignature = methodAbiToFunctionSignature(methodAbi); + return functionSignature; + } + public getABIDecodedTransactionData(methodName: string, callData: string): T { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as ERC1155ProxyContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + const abiDecodedCallData = abiEncoder.strictDecode(callData); + return abiDecodedCallData; + } + public getABIDecodedReturnData(methodName: string, callData: string): T { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as ERC1155ProxyContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + const abiDecodedCallData = abiEncoder.strictDecodeReturnValue(callData); + return abiDecodedCallData; + } + public getSelector(methodName: string): string { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as ERC1155ProxyContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + return abiEncoder.getSelector(); + } + + /** + * Authorizes an address. + * @param target Address to authorize. + */ + public addAuthorizedAddress(target: string): ContractTxFunctionObj { + const self = (this as any) as ERC1155ProxyContract; + assert.isString('target', target); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('addAuthorizedAddress(address)', [ + target.toLowerCase(), + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('addAuthorizedAddress(address)', [ + target.toLowerCase(), + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('addAuthorizedAddress(address)', [ + target.toLowerCase(), + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('addAuthorizedAddress(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('addAuthorizedAddress(address)', [ + target.toLowerCase(), + ]); + return abiEncodedTransactionData; + }, + }; + } + public authorities(index_0: BigNumber): ContractFunctionObj { + const self = (this as any) as ERC1155ProxyContract; + assert.isBigNumber('index_0', index_0); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('authorities(uint256)', [index_0]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('authorities(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('authorities(uint256)', [index_0]); + return abiEncodedTransactionData; + }, + }; + } + public authorized(index_0: string): ContractFunctionObj { + const self = (this as any) as ERC1155ProxyContract; + assert.isString('index_0', index_0); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('authorized(address)', [index_0.toLowerCase()]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('authorized(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('authorized(address)', [ + index_0.toLowerCase(), + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Gets all authorized addresses. + * @returns Array of authorized addresses. + */ + public getAuthorizedAddresses(): ContractFunctionObj { + const self = (this as any) as ERC1155ProxyContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('getAuthorizedAddresses()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('getAuthorizedAddresses()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('getAuthorizedAddresses()', []); + return abiEncodedTransactionData; + }, + }; + } + /** + * Gets the proxy id associated with the proxy address. + * @returns Proxy id. + */ + public getProxyId(): ContractFunctionObj { + const self = (this as any) as ERC1155ProxyContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('getProxyId()', []); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('getProxyId()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('getProxyId()', []); + return abiEncodedTransactionData; + }, + }; + } + public owner(): ContractFunctionObj { + const self = (this as any) as ERC1155ProxyContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('owner()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('owner()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('owner()', []); + return abiEncodedTransactionData; + }, + }; + } + /** + * Removes authorizion of an address. + * @param target Address to remove authorization from. + */ + public removeAuthorizedAddress(target: string): ContractTxFunctionObj { + const self = (this as any) as ERC1155ProxyContract; + assert.isString('target', target); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [ + target.toLowerCase(), + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [ + target.toLowerCase(), + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [ + target.toLowerCase(), + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('removeAuthorizedAddress(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [ + target.toLowerCase(), + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Removes authorizion of an address. + * @param target Address to remove authorization from. + * @param index Index of target in authorities array. + */ + public removeAuthorizedAddressAtIndex(target: string, index: BigNumber): ContractTxFunctionObj { + const self = (this as any) as ERC1155ProxyContract; + assert.isString('target', target); + assert.isBigNumber('index', index); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [ + target.toLowerCase(), + index, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [ + target.toLowerCase(), + index, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [ + target.toLowerCase(), + index, + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('removeAuthorizedAddressAtIndex(address,uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'removeAuthorizedAddressAtIndex(address,uint256)', + [target.toLowerCase(), index], + ); + return abiEncodedTransactionData; + }, + }; + } + /** + * Transfers batch of ERC1155 assets. Either succeeds or throws. + * @param assetData Byte array encoded with ERC1155 token address, array of + * ids, array of values, and callback data. + * @param from Address to transfer assets from. + * @param to Address to transfer assets to. + * @param amount Amount that will be multiplied with each element of + * `assetData.values` to scale the values that will be transferred. + */ + public transferFrom(assetData: string, from: string, to: string, amount: BigNumber): ContractTxFunctionObj { + const self = (this as any) as ERC1155ProxyContract; + assert.isString('assetData', assetData); + assert.isString('from', from); + assert.isString('to', to); + assert.isBigNumber('amount', amount); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('transferFrom(bytes,address,address,uint256)', [ + assetData, + from.toLowerCase(), + to.toLowerCase(), + amount, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('transferFrom(bytes,address,address,uint256)', [ + assetData, + from.toLowerCase(), + to.toLowerCase(), + amount, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('transferFrom(bytes,address,address,uint256)', [ + assetData, + from.toLowerCase(), + to.toLowerCase(), + amount, + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('transferFrom(bytes,address,address,uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'transferFrom(bytes,address,address,uint256)', + [assetData, from.toLowerCase(), to.toLowerCase(), amount], + ); + return abiEncodedTransactionData; + }, + }; + } + public transferOwnership(newOwner: string): ContractTxFunctionObj { + const self = (this as any) as ERC1155ProxyContract; + assert.isString('newOwner', newOwner); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('transferOwnership(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('transferOwnership(address)', [ + newOwner.toLowerCase(), + ]); + return abiEncodedTransactionData; + }, + }; + } + /** * Subscribe to an event type emitted by the ERC1155Proxy contract. * @param eventName The ERC1155Proxy contract event you would like to subscribe to. @@ -1548,6 +1297,12 @@ export class ERC1155ProxyContract extends BaseContract { ERC1155ProxyContract.ABI(), this._web3Wrapper, ); + ERC1155ProxyContract.ABI().forEach((item, index) => { + if (item.type === 'function') { + const methodAbi = item as MethodAbi; + this._methodABIIndex[methodAbi.name] = index; + } + }); } } diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts b/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts index 5608cbf8e0..525e7b1101 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts @@ -1,7 +1,16 @@ // tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma enum-naming // tslint:disable:whitespace no-unbound-method no-trailing-whitespace // tslint:disable:no-unused-variable -import { BaseContract, SubscriptionManager, PromiseWithTransactionHash } from '@0x/base-contract'; +import { + AwaitTransactionSuccessOpts, + ContractFunctionObj, + ContractTxFunctionObj, + SendTransactionOpts, + BaseContract, + SubscriptionManager, + PromiseWithTransactionHash, + methodAbiToFunctionSignature, +} from '@0x/base-contract'; import { schemas } from '@0x/json-schemas'; import { BlockParam, @@ -19,13 +28,7 @@ import { SupportedProvider, } from 'ethereum-types'; import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils'; -import { - AwaitTransactionSuccessOpts, - EventCallback, - IndexedFilterValues, - SendTransactionOpts, - SimpleContractArtifact, -} from '@0x/types'; +import { EventCallback, IndexedFilterValues, SimpleContractArtifact } from '@0x/types'; import { Web3Wrapper } from '@0x/web3-wrapper'; import { assert } from '@0x/assert'; import * as ethers from 'ethers'; @@ -59,891 +62,7 @@ export class ERC20ProxyContract extends BaseContract { */ public static deployedBytecode = '0x608060405234801561001057600080fd5b50600436106100a35760003560e01c80639ad2674411610076578063b91816111161005b578063b918161114610374578063d39de6e9146103bb578063f2fde38b14610413576100a3565b80639ad26744146102fe578063ae25532e14610337576100a3565b806342f1181e14610248578063494503d41461027d57806370712939146102c35780638da5cb5b146102f6575b7fffffffff00000000000000000000000000000000000000000000000000000000600035167fa85e59e40000000000000000000000000000000000000000000000000000000081141561024257604080513381526001602082015290812054610177577f08c379a0000000000000000000000000000000000000000000000000000000006000527c20000000000000000000000000000000000000000000000000000000006020527c1553454e4445525f4e4f545f415554484f52495a454400000000000000604052600060605260646000fd5b50602860043501357f23b872dd0000000000000000000000000000000000000000000000000000000060005260606024600437602060006064600080855af1600080511160203d14163d15178116905080156101cf57005b50507f08c379a0000000000000000000000000000000000000000000000000000000006000527c20000000000000000000000000000000000000000000000000000000006020527c0f5452414e534645525f4641494c454400000000000000000000000000604052600060605260646000fd5b50600080fd5b61027b6004803603602081101561025e57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610446565b005b61029a6004803603602081101561029357600080fd5b5035610632565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b61027b600480360360208110156102d957600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610666565b61029a610959565b61027b6004803603604081101561031457600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135169060200135610975565b61033f610d26565b604080517fffffffff000000000000000000000000000000000000000000000000000000009092168252519081900360200190f35b6103a76004803603602081101561038a57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610d5c565b604080519115158252519081900360200190f35b6103c3610d71565b60408051602080825283518183015283519192839290830191858101910280838360005b838110156103ff5781810151838201526020016103e7565b505050509050019250505060405180910390f35b61027b6004803603602081101561042957600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610de0565b60005473ffffffffffffffffffffffffffffffffffffffff1633146104cc57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f4f4e4c595f434f4e54524143545f4f574e455200000000000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff811660009081526001602052604090205460ff161561056157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f5441524745545f414c52454144595f415554484f52495a454400000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff8116600081815260016020819052604080832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00168317905560028054928301815583527f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace90910180547fffffffffffffffffffffffff00000000000000000000000000000000000000001684179055513392917f3147867c59d17e8fa9d522465651d44aae0a9e38f902f3475b97e58072f0ed4c91a350565b6002818154811061063f57fe5b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff16905081565b60005473ffffffffffffffffffffffffffffffffffffffff1633146106ec57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f4f4e4c595f434f4e54524143545f4f574e455200000000000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff811660009081526001602052604090205460ff1661078057604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f5441524745545f4e4f545f415554484f52495a45440000000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff8116600090815260016020526040812080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690555b600254811015610912578173ffffffffffffffffffffffffffffffffffffffff16600282815481106107fa57fe5b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff16141561090a57600280547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff810190811061085257fe5b6000918252602090912001546002805473ffffffffffffffffffffffffffffffffffffffff909216918390811061088557fe5b600091825260209091200180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055600280547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01906109049082610ec6565b50610912565b6001016107cc565b50604051339073ffffffffffffffffffffffffffffffffffffffff8316907f1f32c1b084e2de0713b8fb16bd46bb9df710a3dbeae2f3ca93af46e016dcc6b090600090a350565b60005473ffffffffffffffffffffffffffffffffffffffff1681565b60005473ffffffffffffffffffffffffffffffffffffffff1633146109fb57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f4f4e4c595f434f4e54524143545f4f574e455200000000000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff821660009081526001602052604090205460ff16610a8f57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f5441524745545f4e4f545f415554484f52495a45440000000000000000000000604482015290519081900360640190fd5b6002548110610aff57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f494e4445585f4f55545f4f465f424f554e445300000000000000000000000000604482015290519081900360640190fd5b8173ffffffffffffffffffffffffffffffffffffffff1660028281548110610b2357fe5b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff1614610bb157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f415554484f52495a45445f414444524553535f4d49534d415443480000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff8216600090815260016020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169055600280547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8101908110610c2c57fe5b6000918252602090912001546002805473ffffffffffffffffffffffffffffffffffffffff9092169183908110610c5f57fe5b600091825260209091200180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055600280547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190610cde9082610ec6565b50604051339073ffffffffffffffffffffffffffffffffffffffff8416907f1f32c1b084e2de0713b8fb16bd46bb9df710a3dbeae2f3ca93af46e016dcc6b090600090a35050565b604080517f4552433230546f6b656e28616464726573732900000000000000000000000000815290519081900360130190205b90565b60016020526000908152604090205460ff1681565b60606002805480602002602001604051908101604052809291908181526020018280548015610dd657602002820191906000526020600020905b815473ffffffffffffffffffffffffffffffffffffffff168152600190910190602001808311610dab575b5050505050905090565b60005473ffffffffffffffffffffffffffffffffffffffff163314610e6657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f4f4e4c595f434f4e54524143545f4f574e455200000000000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff811615610ec357600080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83161790555b50565b815481835581811115610eea57600083815260209020610eea918101908301610eef565b505050565b610d5991905b80821115610f095760008155600101610ef5565b509056fea265627a7a72315820cb3312567959522bd12ea03b9812cab2bace85fe5f172b3ae8014b3eacc85fa864736f6c634300050b0032'; - /** - * Authorizes an address. - */ - public addAuthorizedAddress = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param target Address to authorize. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - target: string, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('target', target); - const self = (this as any) as ERC20ProxyContract; - const encodedData = self._strictEncodeArguments('addAuthorizedAddress(address)', [target.toLowerCase()]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.addAuthorizedAddress.callAsync(target, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param target Address to authorize. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - target: string, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('target', target); - const self = (this as any) as ERC20ProxyContract; - const txHashPromise = self.addAuthorizedAddress.sendTransactionAsync(target.toLowerCase(), txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param target Address to authorize. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync(target: string, txData?: Partial | undefined): Promise { - assert.isString('target', target); - const self = (this as any) as ERC20ProxyContract; - const encodedData = self._strictEncodeArguments('addAuthorizedAddress(address)', [target.toLowerCase()]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param target Address to authorize. - */ - async callAsync(target: string, callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.isString('target', target); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ERC20ProxyContract; - const encodedData = self._strictEncodeArguments('addAuthorizedAddress(address)', [target.toLowerCase()]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('addAuthorizedAddress(address)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param target Address to authorize. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(target: string): string { - assert.isString('target', target); - const self = (this as any) as ERC20ProxyContract; - const abiEncodedTransactionData = self._strictEncodeArguments('addAuthorizedAddress(address)', [ - target.toLowerCase(), - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as ERC20ProxyContract; - const abiEncoder = self._lookupAbiEncoder('addAuthorizedAddress(address)'); - return abiEncoder.getSelector(); - }, - }; - public authorities = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync( - index_0: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isBigNumber('index_0', index_0); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ERC20ProxyContract; - const encodedData = self._strictEncodeArguments('authorities(uint256)', [index_0]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('authorities(uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Removes authorizion of an address. - */ - public removeAuthorizedAddress = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param target Address to remove authorization from. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - target: string, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('target', target); - const self = (this as any) as ERC20ProxyContract; - const encodedData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [target.toLowerCase()]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.removeAuthorizedAddress.callAsync(target, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param target Address to remove authorization from. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - target: string, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('target', target); - const self = (this as any) as ERC20ProxyContract; - const txHashPromise = self.removeAuthorizedAddress.sendTransactionAsync(target.toLowerCase(), txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param target Address to remove authorization from. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync(target: string, txData?: Partial | undefined): Promise { - assert.isString('target', target); - const self = (this as any) as ERC20ProxyContract; - const encodedData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [target.toLowerCase()]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param target Address to remove authorization from. - */ - async callAsync(target: string, callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.isString('target', target); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ERC20ProxyContract; - const encodedData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [target.toLowerCase()]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('removeAuthorizedAddress(address)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param target Address to remove authorization from. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(target: string): string { - assert.isString('target', target); - const self = (this as any) as ERC20ProxyContract; - const abiEncodedTransactionData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [ - target.toLowerCase(), - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as ERC20ProxyContract; - const abiEncoder = self._lookupAbiEncoder('removeAuthorizedAddress(address)'); - return abiEncoder.getSelector(); - }, - }; - public owner = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ERC20ProxyContract; - const encodedData = self._strictEncodeArguments('owner()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('owner()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Removes authorizion of an address. - */ - public removeAuthorizedAddressAtIndex = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param target Address to remove authorization from. - * @param index Index of target in authorities array. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - target: string, - index: BigNumber, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('target', target); - assert.isBigNumber('index', index); - const self = (this as any) as ERC20ProxyContract; - const encodedData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [ - target.toLowerCase(), - index, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.removeAuthorizedAddressAtIndex.callAsync(target, index, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param target Address to remove authorization from. - * @param index Index of target in authorities array. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - target: string, - index: BigNumber, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('target', target); - assert.isBigNumber('index', index); - const self = (this as any) as ERC20ProxyContract; - const txHashPromise = self.removeAuthorizedAddressAtIndex.sendTransactionAsync( - target.toLowerCase(), - index, - txData, - opts, - ); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param target Address to remove authorization from. - * @param index Index of target in authorities array. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - target: string, - index: BigNumber, - txData?: Partial | undefined, - ): Promise { - assert.isString('target', target); - assert.isBigNumber('index', index); - const self = (this as any) as ERC20ProxyContract; - const encodedData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [ - target.toLowerCase(), - index, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param target Address to remove authorization from. - * @param index Index of target in authorities array. - */ - async callAsync( - target: string, - index: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('target', target); - assert.isBigNumber('index', index); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ERC20ProxyContract; - const encodedData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [ - target.toLowerCase(), - index, - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('removeAuthorizedAddressAtIndex(address,uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param target Address to remove authorization from. - * @param index Index of target in authorities array. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(target: string, index: BigNumber): string { - assert.isString('target', target); - assert.isBigNumber('index', index); - const self = (this as any) as ERC20ProxyContract; - const abiEncodedTransactionData = self._strictEncodeArguments( - 'removeAuthorizedAddressAtIndex(address,uint256)', - [target.toLowerCase(), index], - ); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as ERC20ProxyContract; - const abiEncoder = self._lookupAbiEncoder('removeAuthorizedAddressAtIndex(address,uint256)'); - return abiEncoder.getSelector(); - }, - }; - /** - * Gets the proxy id associated with the proxy address. - */ - public getProxyId = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @returns Proxy id. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ERC20ProxyContract; - const encodedData = self._strictEncodeArguments('getProxyId()', []); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('getProxyId()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public authorized = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync( - index_0: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('index_0', index_0); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ERC20ProxyContract; - const encodedData = self._strictEncodeArguments('authorized(address)', [index_0.toLowerCase()]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('authorized(address)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Gets all authorized addresses. - */ - public getAuthorizedAddresses = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @returns Array of authorized addresses. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ERC20ProxyContract; - const encodedData = self._strictEncodeArguments('getAuthorizedAddresses()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('getAuthorizedAddresses()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public transferOwnership = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - newOwner: string, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('newOwner', newOwner); - const self = (this as any) as ERC20ProxyContract; - const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.transferOwnership.callAsync(newOwner, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - newOwner: string, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('newOwner', newOwner); - const self = (this as any) as ERC20ProxyContract; - const txHashPromise = self.transferOwnership.sendTransactionAsync(newOwner.toLowerCase(), txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync(newOwner: string, txData?: Partial | undefined): Promise { - assert.isString('newOwner', newOwner); - const self = (this as any) as ERC20ProxyContract; - const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(newOwner: string, callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.isString('newOwner', newOwner); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ERC20ProxyContract; - const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('transferOwnership(address)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(newOwner: string): string { - assert.isString('newOwner', newOwner); - const self = (this as any) as ERC20ProxyContract; - const abiEncodedTransactionData = self._strictEncodeArguments('transferOwnership(address)', [ - newOwner.toLowerCase(), - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as ERC20ProxyContract; - const abiEncoder = self._lookupAbiEncoder('transferOwnership(address)'); - return abiEncoder.getSelector(); - }, - }; + private _methodABIIndex: { [name: string]: number } = {}; private readonly _subscriptionManager: SubscriptionManager; public static async deployFrom0xArtifactAsync( artifact: ContractArtifact | SimpleContractArtifact, @@ -1200,6 +319,740 @@ export class ERC20ProxyContract extends BaseContract { ] as ContractAbi; return abi; } + + public getFunctionSignature(methodName: string): string { + const index = this._methodABIIndex[methodName]; + const methodAbi = ERC20ProxyContract.ABI()[index] as MethodAbi; + const functionSignature = methodAbiToFunctionSignature(methodAbi); + return functionSignature; + } + public getABIDecodedTransactionData(methodName: string, callData: string): T { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as ERC20ProxyContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + const abiDecodedCallData = abiEncoder.strictDecode(callData); + return abiDecodedCallData; + } + public getABIDecodedReturnData(methodName: string, callData: string): T { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as ERC20ProxyContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + const abiDecodedCallData = abiEncoder.strictDecodeReturnValue(callData); + return abiDecodedCallData; + } + public getSelector(methodName: string): string { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as ERC20ProxyContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + return abiEncoder.getSelector(); + } + + /** + * Authorizes an address. + * @param target Address to authorize. + */ + public addAuthorizedAddress(target: string): ContractTxFunctionObj { + const self = (this as any) as ERC20ProxyContract; + assert.isString('target', target); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('addAuthorizedAddress(address)', [ + target.toLowerCase(), + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('addAuthorizedAddress(address)', [ + target.toLowerCase(), + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('addAuthorizedAddress(address)', [ + target.toLowerCase(), + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('addAuthorizedAddress(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('addAuthorizedAddress(address)', [ + target.toLowerCase(), + ]); + return abiEncodedTransactionData; + }, + }; + } + public authorities(index_0: BigNumber): ContractFunctionObj { + const self = (this as any) as ERC20ProxyContract; + assert.isBigNumber('index_0', index_0); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('authorities(uint256)', [index_0]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('authorities(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('authorities(uint256)', [index_0]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Removes authorizion of an address. + * @param target Address to remove authorization from. + */ + public removeAuthorizedAddress(target: string): ContractTxFunctionObj { + const self = (this as any) as ERC20ProxyContract; + assert.isString('target', target); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [ + target.toLowerCase(), + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [ + target.toLowerCase(), + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [ + target.toLowerCase(), + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('removeAuthorizedAddress(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [ + target.toLowerCase(), + ]); + return abiEncodedTransactionData; + }, + }; + } + public owner(): ContractFunctionObj { + const self = (this as any) as ERC20ProxyContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('owner()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('owner()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('owner()', []); + return abiEncodedTransactionData; + }, + }; + } + /** + * Removes authorizion of an address. + * @param target Address to remove authorization from. + * @param index Index of target in authorities array. + */ + public removeAuthorizedAddressAtIndex(target: string, index: BigNumber): ContractTxFunctionObj { + const self = (this as any) as ERC20ProxyContract; + assert.isString('target', target); + assert.isBigNumber('index', index); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [ + target.toLowerCase(), + index, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [ + target.toLowerCase(), + index, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [ + target.toLowerCase(), + index, + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('removeAuthorizedAddressAtIndex(address,uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'removeAuthorizedAddressAtIndex(address,uint256)', + [target.toLowerCase(), index], + ); + return abiEncodedTransactionData; + }, + }; + } + /** + * Gets the proxy id associated with the proxy address. + * @returns Proxy id. + */ + public getProxyId(): ContractFunctionObj { + const self = (this as any) as ERC20ProxyContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('getProxyId()', []); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('getProxyId()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('getProxyId()', []); + return abiEncodedTransactionData; + }, + }; + } + public authorized(index_0: string): ContractFunctionObj { + const self = (this as any) as ERC20ProxyContract; + assert.isString('index_0', index_0); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('authorized(address)', [index_0.toLowerCase()]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('authorized(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('authorized(address)', [ + index_0.toLowerCase(), + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Gets all authorized addresses. + * @returns Array of authorized addresses. + */ + public getAuthorizedAddresses(): ContractFunctionObj { + const self = (this as any) as ERC20ProxyContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('getAuthorizedAddresses()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('getAuthorizedAddresses()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('getAuthorizedAddresses()', []); + return abiEncodedTransactionData; + }, + }; + } + public transferOwnership(newOwner: string): ContractTxFunctionObj { + const self = (this as any) as ERC20ProxyContract; + assert.isString('newOwner', newOwner); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('transferOwnership(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('transferOwnership(address)', [ + newOwner.toLowerCase(), + ]); + return abiEncodedTransactionData; + }, + }; + } + /** * Subscribe to an event type emitted by the ERC20Proxy contract. * @param eventName The ERC20Proxy contract event you would like to subscribe to. @@ -1289,6 +1142,12 @@ export class ERC20ProxyContract extends BaseContract { ERC20ProxyContract.ABI(), this._web3Wrapper, ); + ERC20ProxyContract.ABI().forEach((item, index) => { + if (item.type === 'function') { + const methodAbi = item as MethodAbi; + this._methodABIIndex[methodAbi.name] = index; + } + }); } } diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts b/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts index df2b061a3a..c024421db0 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts @@ -1,7 +1,16 @@ // tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma enum-naming // tslint:disable:whitespace no-unbound-method no-trailing-whitespace // tslint:disable:no-unused-variable -import { BaseContract, SubscriptionManager, PromiseWithTransactionHash } from '@0x/base-contract'; +import { + AwaitTransactionSuccessOpts, + ContractFunctionObj, + ContractTxFunctionObj, + SendTransactionOpts, + BaseContract, + SubscriptionManager, + PromiseWithTransactionHash, + methodAbiToFunctionSignature, +} from '@0x/base-contract'; import { schemas } from '@0x/json-schemas'; import { BlockParam, @@ -19,13 +28,7 @@ import { SupportedProvider, } from 'ethereum-types'; import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils'; -import { - AwaitTransactionSuccessOpts, - EventCallback, - IndexedFilterValues, - SendTransactionOpts, - SimpleContractArtifact, -} from '@0x/types'; +import { EventCallback, IndexedFilterValues, SimpleContractArtifact } from '@0x/types'; import { Web3Wrapper } from '@0x/web3-wrapper'; import { assert } from '@0x/assert'; import * as ethers from 'ethers'; @@ -58,743 +61,7 @@ export class ERC20TokenContract extends BaseContract { * @ignore */ public static deployedBytecode: string | undefined; - /** - * `msg.sender` approves `_spender` to spend `_value` tokens - */ - public approve = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param _spender The address of the account able to transfer the tokens - * @param _value The amount of wei to be approved for transfer - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - _spender: string, - _value: BigNumber, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('_spender', _spender); - assert.isBigNumber('_value', _value); - const self = (this as any) as ERC20TokenContract; - const encodedData = self._strictEncodeArguments('approve(address,uint256)', [ - _spender.toLowerCase(), - _value, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.approve.callAsync(_spender, _value, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param _spender The address of the account able to transfer the tokens - * @param _value The amount of wei to be approved for transfer - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - _spender: string, - _value: BigNumber, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('_spender', _spender); - assert.isBigNumber('_value', _value); - const self = (this as any) as ERC20TokenContract; - const txHashPromise = self.approve.sendTransactionAsync(_spender.toLowerCase(), _value, txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param _spender The address of the account able to transfer the tokens - * @param _value The amount of wei to be approved for transfer - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - _spender: string, - _value: BigNumber, - txData?: Partial | undefined, - ): Promise { - assert.isString('_spender', _spender); - assert.isBigNumber('_value', _value); - const self = (this as any) as ERC20TokenContract; - const encodedData = self._strictEncodeArguments('approve(address,uint256)', [ - _spender.toLowerCase(), - _value, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param _spender The address of the account able to transfer the tokens - * @param _value The amount of wei to be approved for transfer - * @returns Always true if the call has enough gas to complete execution - */ - async callAsync( - _spender: string, - _value: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('_spender', _spender); - assert.isBigNumber('_value', _value); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ERC20TokenContract; - const encodedData = self._strictEncodeArguments('approve(address,uint256)', [ - _spender.toLowerCase(), - _value, - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('approve(address,uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param _spender The address of the account able to transfer the tokens - * @param _value The amount of wei to be approved for transfer - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(_spender: string, _value: BigNumber): string { - assert.isString('_spender', _spender); - assert.isBigNumber('_value', _value); - const self = (this as any) as ERC20TokenContract; - const abiEncodedTransactionData = self._strictEncodeArguments('approve(address,uint256)', [ - _spender.toLowerCase(), - _value, - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as ERC20TokenContract; - const abiEncoder = self._lookupAbiEncoder('approve(address,uint256)'); - return abiEncoder.getSelector(); - }, - }; - /** - * Query total supply of token - */ - public totalSupply = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @returns Total supply of token - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ERC20TokenContract; - const encodedData = self._strictEncodeArguments('totalSupply()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('totalSupply()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * send `value` token to `to` from `from` on the condition it is approved by `from` - */ - public transferFrom = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param _from The address of the sender - * @param _to The address of the recipient - * @param _value The amount of token to be transferred - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - _from: string, - _to: string, - _value: BigNumber, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('_from', _from); - assert.isString('_to', _to); - assert.isBigNumber('_value', _value); - const self = (this as any) as ERC20TokenContract; - const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [ - _from.toLowerCase(), - _to.toLowerCase(), - _value, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.transferFrom.callAsync(_from, _to, _value, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param _from The address of the sender - * @param _to The address of the recipient - * @param _value The amount of token to be transferred - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - _from: string, - _to: string, - _value: BigNumber, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('_from', _from); - assert.isString('_to', _to); - assert.isBigNumber('_value', _value); - const self = (this as any) as ERC20TokenContract; - const txHashPromise = self.transferFrom.sendTransactionAsync( - _from.toLowerCase(), - _to.toLowerCase(), - _value, - txData, - opts, - ); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param _from The address of the sender - * @param _to The address of the recipient - * @param _value The amount of token to be transferred - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - _from: string, - _to: string, - _value: BigNumber, - txData?: Partial | undefined, - ): Promise { - assert.isString('_from', _from); - assert.isString('_to', _to); - assert.isBigNumber('_value', _value); - const self = (this as any) as ERC20TokenContract; - const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [ - _from.toLowerCase(), - _to.toLowerCase(), - _value, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param _from The address of the sender - * @param _to The address of the recipient - * @param _value The amount of token to be transferred - * @returns True if transfer was successful - */ - async callAsync( - _from: string, - _to: string, - _value: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('_from', _from); - assert.isString('_to', _to); - assert.isBigNumber('_value', _value); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ERC20TokenContract; - const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [ - _from.toLowerCase(), - _to.toLowerCase(), - _value, - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('transferFrom(address,address,uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param _from The address of the sender - * @param _to The address of the recipient - * @param _value The amount of token to be transferred - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(_from: string, _to: string, _value: BigNumber): string { - assert.isString('_from', _from); - assert.isString('_to', _to); - assert.isBigNumber('_value', _value); - const self = (this as any) as ERC20TokenContract; - const abiEncodedTransactionData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [ - _from.toLowerCase(), - _to.toLowerCase(), - _value, - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as ERC20TokenContract; - const abiEncoder = self._lookupAbiEncoder('transferFrom(address,address,uint256)'); - return abiEncoder.getSelector(); - }, - }; - /** - * Query the balance of owner - */ - public balanceOf = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param _owner The address from which the balance will be retrieved - * @returns Balance of owner - */ - async callAsync( - _owner: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('_owner', _owner); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ERC20TokenContract; - const encodedData = self._strictEncodeArguments('balanceOf(address)', [_owner.toLowerCase()]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('balanceOf(address)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * send `value` token to `to` from `msg.sender` - */ - public transfer = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param _to The address of the recipient - * @param _value The amount of token to be transferred - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - _to: string, - _value: BigNumber, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('_to', _to); - assert.isBigNumber('_value', _value); - const self = (this as any) as ERC20TokenContract; - const encodedData = self._strictEncodeArguments('transfer(address,uint256)', [_to.toLowerCase(), _value]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.transfer.callAsync(_to, _value, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param _to The address of the recipient - * @param _value The amount of token to be transferred - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - _to: string, - _value: BigNumber, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('_to', _to); - assert.isBigNumber('_value', _value); - const self = (this as any) as ERC20TokenContract; - const txHashPromise = self.transfer.sendTransactionAsync(_to.toLowerCase(), _value, txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param _to The address of the recipient - * @param _value The amount of token to be transferred - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync(_to: string, _value: BigNumber, txData?: Partial | undefined): Promise { - assert.isString('_to', _to); - assert.isBigNumber('_value', _value); - const self = (this as any) as ERC20TokenContract; - const encodedData = self._strictEncodeArguments('transfer(address,uint256)', [_to.toLowerCase(), _value]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param _to The address of the recipient - * @param _value The amount of token to be transferred - * @returns True if transfer was successful - */ - async callAsync( - _to: string, - _value: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('_to', _to); - assert.isBigNumber('_value', _value); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ERC20TokenContract; - const encodedData = self._strictEncodeArguments('transfer(address,uint256)', [_to.toLowerCase(), _value]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('transfer(address,uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param _to The address of the recipient - * @param _value The amount of token to be transferred - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(_to: string, _value: BigNumber): string { - assert.isString('_to', _to); - assert.isBigNumber('_value', _value); - const self = (this as any) as ERC20TokenContract; - const abiEncodedTransactionData = self._strictEncodeArguments('transfer(address,uint256)', [ - _to.toLowerCase(), - _value, - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as ERC20TokenContract; - const abiEncoder = self._lookupAbiEncoder('transfer(address,uint256)'); - return abiEncoder.getSelector(); - }, - }; - public allowance = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param _owner The address of the account owning tokens - * @param _spender The address of the account able to transfer the tokens - * @returns Amount of remaining tokens allowed to spent - */ - async callAsync( - _owner: string, - _spender: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('_owner', _owner); - assert.isString('_spender', _spender); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ERC20TokenContract; - const encodedData = self._strictEncodeArguments('allowance(address,address)', [ - _owner.toLowerCase(), - _spender.toLowerCase(), - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('allowance(address,address)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; + private _methodABIIndex: { [name: string]: number } = {}; private readonly _subscriptionManager: SubscriptionManager; public static async deployFrom0xArtifactAsync( artifact: ContractArtifact | SimpleContractArtifact, @@ -1043,6 +310,577 @@ export class ERC20TokenContract extends BaseContract { ] as ContractAbi; return abi; } + + public getFunctionSignature(methodName: string): string { + const index = this._methodABIIndex[methodName]; + const methodAbi = ERC20TokenContract.ABI()[index] as MethodAbi; + const functionSignature = methodAbiToFunctionSignature(methodAbi); + return functionSignature; + } + public getABIDecodedTransactionData(methodName: string, callData: string): T { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as ERC20TokenContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + const abiDecodedCallData = abiEncoder.strictDecode(callData); + return abiDecodedCallData; + } + public getABIDecodedReturnData(methodName: string, callData: string): T { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as ERC20TokenContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + const abiDecodedCallData = abiEncoder.strictDecodeReturnValue(callData); + return abiDecodedCallData; + } + public getSelector(methodName: string): string { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as ERC20TokenContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + return abiEncoder.getSelector(); + } + + /** + * `msg.sender` approves `_spender` to spend `_value` tokens + * @param _spender The address of the account able to transfer the tokens + * @param _value The amount of wei to be approved for transfer + * @returns Always true if the call has enough gas to complete execution + */ + public approve(_spender: string, _value: BigNumber): ContractTxFunctionObj { + const self = (this as any) as ERC20TokenContract; + assert.isString('_spender', _spender); + assert.isBigNumber('_value', _value); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('approve(address,uint256)', [ + _spender.toLowerCase(), + _value, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('approve(address,uint256)', [ + _spender.toLowerCase(), + _value, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('approve(address,uint256)', [ + _spender.toLowerCase(), + _value, + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('approve(address,uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('approve(address,uint256)', [ + _spender.toLowerCase(), + _value, + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Query total supply of token + * @returns Total supply of token + */ + public totalSupply(): ContractFunctionObj { + const self = (this as any) as ERC20TokenContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('totalSupply()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('totalSupply()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('totalSupply()', []); + return abiEncodedTransactionData; + }, + }; + } + /** + * send `value` token to `to` from `from` on the condition it is approved by `from` + * @param _from The address of the sender + * @param _to The address of the recipient + * @param _value The amount of token to be transferred + * @returns True if transfer was successful + */ + public transferFrom(_from: string, _to: string, _value: BigNumber): ContractTxFunctionObj { + const self = (this as any) as ERC20TokenContract; + assert.isString('_from', _from); + assert.isString('_to', _to); + assert.isBigNumber('_value', _value); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [ + _from.toLowerCase(), + _to.toLowerCase(), + _value, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [ + _from.toLowerCase(), + _to.toLowerCase(), + _value, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [ + _from.toLowerCase(), + _to.toLowerCase(), + _value, + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('transferFrom(address,address,uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [ + _from.toLowerCase(), + _to.toLowerCase(), + _value, + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Query the balance of owner + * @param _owner The address from which the balance will be retrieved + * @returns Balance of owner + */ + public balanceOf(_owner: string): ContractFunctionObj { + const self = (this as any) as ERC20TokenContract; + assert.isString('_owner', _owner); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('balanceOf(address)', [_owner.toLowerCase()]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('balanceOf(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('balanceOf(address)', [ + _owner.toLowerCase(), + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * send `value` token to `to` from `msg.sender` + * @param _to The address of the recipient + * @param _value The amount of token to be transferred + * @returns True if transfer was successful + */ + public transfer(_to: string, _value: BigNumber): ContractTxFunctionObj { + const self = (this as any) as ERC20TokenContract; + assert.isString('_to', _to); + assert.isBigNumber('_value', _value); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('transfer(address,uint256)', [ + _to.toLowerCase(), + _value, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('transfer(address,uint256)', [ + _to.toLowerCase(), + _value, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('transfer(address,uint256)', [ + _to.toLowerCase(), + _value, + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('transfer(address,uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('transfer(address,uint256)', [ + _to.toLowerCase(), + _value, + ]); + return abiEncodedTransactionData; + }, + }; + } + public allowance(_owner: string, _spender: string): ContractFunctionObj { + const self = (this as any) as ERC20TokenContract; + assert.isString('_owner', _owner); + assert.isString('_spender', _spender); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('allowance(address,address)', [ + _owner.toLowerCase(), + _spender.toLowerCase(), + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('allowance(address,address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('allowance(address,address)', [ + _owner.toLowerCase(), + _spender.toLowerCase(), + ]); + return abiEncodedTransactionData; + }, + }; + } + /** * Subscribe to an event type emitted by the ERC20Token contract. * @param eventName The ERC20Token contract event you would like to subscribe to. @@ -1132,6 +970,12 @@ export class ERC20TokenContract extends BaseContract { ERC20TokenContract.ABI(), this._web3Wrapper, ); + ERC20TokenContract.ABI().forEach((item, index) => { + if (item.type === 'function') { + const methodAbi = item as MethodAbi; + this._methodABIIndex[methodAbi.name] = index; + } + }); } } diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts b/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts index 7b84ca85b7..be6b27774b 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts @@ -1,7 +1,16 @@ // tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma enum-naming // tslint:disable:whitespace no-unbound-method no-trailing-whitespace // tslint:disable:no-unused-variable -import { BaseContract, SubscriptionManager, PromiseWithTransactionHash } from '@0x/base-contract'; +import { + AwaitTransactionSuccessOpts, + ContractFunctionObj, + ContractTxFunctionObj, + SendTransactionOpts, + BaseContract, + SubscriptionManager, + PromiseWithTransactionHash, + methodAbiToFunctionSignature, +} from '@0x/base-contract'; import { schemas } from '@0x/json-schemas'; import { BlockParam, @@ -19,13 +28,7 @@ import { SupportedProvider, } from 'ethereum-types'; import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils'; -import { - AwaitTransactionSuccessOpts, - EventCallback, - IndexedFilterValues, - SendTransactionOpts, - SimpleContractArtifact, -} from '@0x/types'; +import { EventCallback, IndexedFilterValues, SimpleContractArtifact } from '@0x/types'; import { Web3Wrapper } from '@0x/web3-wrapper'; import { assert } from '@0x/assert'; import * as ethers from 'ethers'; @@ -59,891 +62,7 @@ export class ERC721ProxyContract extends BaseContract { */ public static deployedBytecode = '0x608060405234801561001057600080fd5b50600436106100a35760003560e01c80639ad2674411610076578063b91816111161005b578063b9181611146103ea578063d39de6e914610431578063f2fde38b14610489576100a3565b80639ad2674414610374578063ae25532e146103ad576100a3565b806342f1181e146102be578063494503d4146102f357806370712939146103395780638da5cb5b1461036c575b7fffffffff00000000000000000000000000000000000000000000000000000000600035167fa85e59e4000000000000000000000000000000000000000000000000000000008114156102b857604080513381526001602082015290812054610177577f08c379a0000000000000000000000000000000000000000000000000000000006000527c20000000000000000000000000000000000000000000000000000000006020527c1553454e4445525f4e4f545f415554484f52495a454400000000000000604052600060605260646000fd5b50600160643503156101f4577f08c379a0000000000000000000000000000000000000000000000000000000006000527c20000000000000000000000000000000000000000000000000000000006020527c0e494e56414c49445f414d4f554e540000000000000000000000000000604052600060605260646000fd5b7f23b872dd000000000000000000000000000000000000000000000000000000006000526040602460043760043560206048820160443760288101356000806064600080855af1915050801561024657005b507f08c379a0000000000000000000000000000000000000000000000000000000006000527c20000000000000000000000000000000000000000000000000000000006020527c0f5452414e534645525f4641494c454400000000000000000000000000604052600060605260646000fd5b50600080fd5b6102f1600480360360208110156102d457600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166104bc565b005b6103106004803603602081101561030957600080fd5b50356106a8565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b6102f16004803603602081101561034f57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166106dc565b6103106109cf565b6102f16004803603604081101561038a57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81351690602001356109eb565b6103b5610d9c565b604080517fffffffff000000000000000000000000000000000000000000000000000000009092168252519081900360200190f35b61041d6004803603602081101561040057600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610dd2565b604080519115158252519081900360200190f35b610439610de7565b60408051602080825283518183015283519192839290830191858101910280838360005b8381101561047557818101518382015260200161045d565b505050509050019250505060405180910390f35b6102f16004803603602081101561049f57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610e56565b60005473ffffffffffffffffffffffffffffffffffffffff16331461054257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f4f4e4c595f434f4e54524143545f4f574e455200000000000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff811660009081526001602052604090205460ff16156105d757604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f5441524745545f414c52454144595f415554484f52495a454400000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff8116600081815260016020819052604080832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00168317905560028054928301815583527f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace90910180547fffffffffffffffffffffffff00000000000000000000000000000000000000001684179055513392917f3147867c59d17e8fa9d522465651d44aae0a9e38f902f3475b97e58072f0ed4c91a350565b600281815481106106b557fe5b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff16905081565b60005473ffffffffffffffffffffffffffffffffffffffff16331461076257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f4f4e4c595f434f4e54524143545f4f574e455200000000000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff811660009081526001602052604090205460ff166107f657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f5441524745545f4e4f545f415554484f52495a45440000000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff8116600090815260016020526040812080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690555b600254811015610988578173ffffffffffffffffffffffffffffffffffffffff166002828154811061087057fe5b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff16141561098057600280547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81019081106108c857fe5b6000918252602090912001546002805473ffffffffffffffffffffffffffffffffffffffff90921691839081106108fb57fe5b600091825260209091200180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055600280547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff019061097a9082610f3c565b50610988565b600101610842565b50604051339073ffffffffffffffffffffffffffffffffffffffff8316907f1f32c1b084e2de0713b8fb16bd46bb9df710a3dbeae2f3ca93af46e016dcc6b090600090a350565b60005473ffffffffffffffffffffffffffffffffffffffff1681565b60005473ffffffffffffffffffffffffffffffffffffffff163314610a7157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f4f4e4c595f434f4e54524143545f4f574e455200000000000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff821660009081526001602052604090205460ff16610b0557604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f5441524745545f4e4f545f415554484f52495a45440000000000000000000000604482015290519081900360640190fd5b6002548110610b7557604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f494e4445585f4f55545f4f465f424f554e445300000000000000000000000000604482015290519081900360640190fd5b8173ffffffffffffffffffffffffffffffffffffffff1660028281548110610b9957fe5b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff1614610c2757604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f415554484f52495a45445f414444524553535f4d49534d415443480000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff8216600090815260016020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169055600280547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8101908110610ca257fe5b6000918252602090912001546002805473ffffffffffffffffffffffffffffffffffffffff9092169183908110610cd557fe5b600091825260209091200180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055600280547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190610d549082610f3c565b50604051339073ffffffffffffffffffffffffffffffffffffffff8416907f1f32c1b084e2de0713b8fb16bd46bb9df710a3dbeae2f3ca93af46e016dcc6b090600090a35050565b604080517f455243373231546f6b656e28616464726573732c75696e7432353629000000008152905190819003601c0190205b90565b60016020526000908152604090205460ff1681565b60606002805480602002602001604051908101604052809291908181526020018280548015610e4c57602002820191906000526020600020905b815473ffffffffffffffffffffffffffffffffffffffff168152600190910190602001808311610e21575b5050505050905090565b60005473ffffffffffffffffffffffffffffffffffffffff163314610edc57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f4f4e4c595f434f4e54524143545f4f574e455200000000000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff811615610f3957600080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83161790555b50565b815481835581811115610f6057600083815260209020610f60918101908301610f65565b505050565b610dcf91905b80821115610f7f5760008155600101610f6b565b509056fea265627a7a723158201e53a891f6df3931041b820f71387e9eecd97f7ea0d346c54fab37668bd022ec64736f6c634300050b0032'; - /** - * Authorizes an address. - */ - public addAuthorizedAddress = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param target Address to authorize. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - target: string, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('target', target); - const self = (this as any) as ERC721ProxyContract; - const encodedData = self._strictEncodeArguments('addAuthorizedAddress(address)', [target.toLowerCase()]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.addAuthorizedAddress.callAsync(target, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param target Address to authorize. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - target: string, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('target', target); - const self = (this as any) as ERC721ProxyContract; - const txHashPromise = self.addAuthorizedAddress.sendTransactionAsync(target.toLowerCase(), txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param target Address to authorize. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync(target: string, txData?: Partial | undefined): Promise { - assert.isString('target', target); - const self = (this as any) as ERC721ProxyContract; - const encodedData = self._strictEncodeArguments('addAuthorizedAddress(address)', [target.toLowerCase()]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param target Address to authorize. - */ - async callAsync(target: string, callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.isString('target', target); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ERC721ProxyContract; - const encodedData = self._strictEncodeArguments('addAuthorizedAddress(address)', [target.toLowerCase()]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('addAuthorizedAddress(address)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param target Address to authorize. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(target: string): string { - assert.isString('target', target); - const self = (this as any) as ERC721ProxyContract; - const abiEncodedTransactionData = self._strictEncodeArguments('addAuthorizedAddress(address)', [ - target.toLowerCase(), - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as ERC721ProxyContract; - const abiEncoder = self._lookupAbiEncoder('addAuthorizedAddress(address)'); - return abiEncoder.getSelector(); - }, - }; - public authorities = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync( - index_0: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isBigNumber('index_0', index_0); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ERC721ProxyContract; - const encodedData = self._strictEncodeArguments('authorities(uint256)', [index_0]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('authorities(uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Removes authorizion of an address. - */ - public removeAuthorizedAddress = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param target Address to remove authorization from. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - target: string, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('target', target); - const self = (this as any) as ERC721ProxyContract; - const encodedData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [target.toLowerCase()]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.removeAuthorizedAddress.callAsync(target, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param target Address to remove authorization from. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - target: string, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('target', target); - const self = (this as any) as ERC721ProxyContract; - const txHashPromise = self.removeAuthorizedAddress.sendTransactionAsync(target.toLowerCase(), txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param target Address to remove authorization from. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync(target: string, txData?: Partial | undefined): Promise { - assert.isString('target', target); - const self = (this as any) as ERC721ProxyContract; - const encodedData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [target.toLowerCase()]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param target Address to remove authorization from. - */ - async callAsync(target: string, callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.isString('target', target); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ERC721ProxyContract; - const encodedData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [target.toLowerCase()]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('removeAuthorizedAddress(address)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param target Address to remove authorization from. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(target: string): string { - assert.isString('target', target); - const self = (this as any) as ERC721ProxyContract; - const abiEncodedTransactionData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [ - target.toLowerCase(), - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as ERC721ProxyContract; - const abiEncoder = self._lookupAbiEncoder('removeAuthorizedAddress(address)'); - return abiEncoder.getSelector(); - }, - }; - public owner = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ERC721ProxyContract; - const encodedData = self._strictEncodeArguments('owner()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('owner()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Removes authorizion of an address. - */ - public removeAuthorizedAddressAtIndex = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param target Address to remove authorization from. - * @param index Index of target in authorities array. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - target: string, - index: BigNumber, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('target', target); - assert.isBigNumber('index', index); - const self = (this as any) as ERC721ProxyContract; - const encodedData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [ - target.toLowerCase(), - index, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.removeAuthorizedAddressAtIndex.callAsync(target, index, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param target Address to remove authorization from. - * @param index Index of target in authorities array. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - target: string, - index: BigNumber, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('target', target); - assert.isBigNumber('index', index); - const self = (this as any) as ERC721ProxyContract; - const txHashPromise = self.removeAuthorizedAddressAtIndex.sendTransactionAsync( - target.toLowerCase(), - index, - txData, - opts, - ); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param target Address to remove authorization from. - * @param index Index of target in authorities array. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - target: string, - index: BigNumber, - txData?: Partial | undefined, - ): Promise { - assert.isString('target', target); - assert.isBigNumber('index', index); - const self = (this as any) as ERC721ProxyContract; - const encodedData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [ - target.toLowerCase(), - index, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param target Address to remove authorization from. - * @param index Index of target in authorities array. - */ - async callAsync( - target: string, - index: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('target', target); - assert.isBigNumber('index', index); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ERC721ProxyContract; - const encodedData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [ - target.toLowerCase(), - index, - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('removeAuthorizedAddressAtIndex(address,uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param target Address to remove authorization from. - * @param index Index of target in authorities array. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(target: string, index: BigNumber): string { - assert.isString('target', target); - assert.isBigNumber('index', index); - const self = (this as any) as ERC721ProxyContract; - const abiEncodedTransactionData = self._strictEncodeArguments( - 'removeAuthorizedAddressAtIndex(address,uint256)', - [target.toLowerCase(), index], - ); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as ERC721ProxyContract; - const abiEncoder = self._lookupAbiEncoder('removeAuthorizedAddressAtIndex(address,uint256)'); - return abiEncoder.getSelector(); - }, - }; - /** - * Gets the proxy id associated with the proxy address. - */ - public getProxyId = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @returns Proxy id. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ERC721ProxyContract; - const encodedData = self._strictEncodeArguments('getProxyId()', []); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('getProxyId()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public authorized = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync( - index_0: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('index_0', index_0); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ERC721ProxyContract; - const encodedData = self._strictEncodeArguments('authorized(address)', [index_0.toLowerCase()]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('authorized(address)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Gets all authorized addresses. - */ - public getAuthorizedAddresses = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @returns Array of authorized addresses. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ERC721ProxyContract; - const encodedData = self._strictEncodeArguments('getAuthorizedAddresses()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('getAuthorizedAddresses()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public transferOwnership = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - newOwner: string, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('newOwner', newOwner); - const self = (this as any) as ERC721ProxyContract; - const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.transferOwnership.callAsync(newOwner, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - newOwner: string, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('newOwner', newOwner); - const self = (this as any) as ERC721ProxyContract; - const txHashPromise = self.transferOwnership.sendTransactionAsync(newOwner.toLowerCase(), txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync(newOwner: string, txData?: Partial | undefined): Promise { - assert.isString('newOwner', newOwner); - const self = (this as any) as ERC721ProxyContract; - const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(newOwner: string, callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.isString('newOwner', newOwner); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ERC721ProxyContract; - const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('transferOwnership(address)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(newOwner: string): string { - assert.isString('newOwner', newOwner); - const self = (this as any) as ERC721ProxyContract; - const abiEncodedTransactionData = self._strictEncodeArguments('transferOwnership(address)', [ - newOwner.toLowerCase(), - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as ERC721ProxyContract; - const abiEncoder = self._lookupAbiEncoder('transferOwnership(address)'); - return abiEncoder.getSelector(); - }, - }; + private _methodABIIndex: { [name: string]: number } = {}; private readonly _subscriptionManager: SubscriptionManager; public static async deployFrom0xArtifactAsync( artifact: ContractArtifact | SimpleContractArtifact, @@ -1200,6 +319,740 @@ export class ERC721ProxyContract extends BaseContract { ] as ContractAbi; return abi; } + + public getFunctionSignature(methodName: string): string { + const index = this._methodABIIndex[methodName]; + const methodAbi = ERC721ProxyContract.ABI()[index] as MethodAbi; + const functionSignature = methodAbiToFunctionSignature(methodAbi); + return functionSignature; + } + public getABIDecodedTransactionData(methodName: string, callData: string): T { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as ERC721ProxyContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + const abiDecodedCallData = abiEncoder.strictDecode(callData); + return abiDecodedCallData; + } + public getABIDecodedReturnData(methodName: string, callData: string): T { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as ERC721ProxyContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + const abiDecodedCallData = abiEncoder.strictDecodeReturnValue(callData); + return abiDecodedCallData; + } + public getSelector(methodName: string): string { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as ERC721ProxyContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + return abiEncoder.getSelector(); + } + + /** + * Authorizes an address. + * @param target Address to authorize. + */ + public addAuthorizedAddress(target: string): ContractTxFunctionObj { + const self = (this as any) as ERC721ProxyContract; + assert.isString('target', target); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('addAuthorizedAddress(address)', [ + target.toLowerCase(), + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('addAuthorizedAddress(address)', [ + target.toLowerCase(), + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('addAuthorizedAddress(address)', [ + target.toLowerCase(), + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('addAuthorizedAddress(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('addAuthorizedAddress(address)', [ + target.toLowerCase(), + ]); + return abiEncodedTransactionData; + }, + }; + } + public authorities(index_0: BigNumber): ContractFunctionObj { + const self = (this as any) as ERC721ProxyContract; + assert.isBigNumber('index_0', index_0); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('authorities(uint256)', [index_0]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('authorities(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('authorities(uint256)', [index_0]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Removes authorizion of an address. + * @param target Address to remove authorization from. + */ + public removeAuthorizedAddress(target: string): ContractTxFunctionObj { + const self = (this as any) as ERC721ProxyContract; + assert.isString('target', target); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [ + target.toLowerCase(), + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [ + target.toLowerCase(), + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [ + target.toLowerCase(), + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('removeAuthorizedAddress(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [ + target.toLowerCase(), + ]); + return abiEncodedTransactionData; + }, + }; + } + public owner(): ContractFunctionObj { + const self = (this as any) as ERC721ProxyContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('owner()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('owner()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('owner()', []); + return abiEncodedTransactionData; + }, + }; + } + /** + * Removes authorizion of an address. + * @param target Address to remove authorization from. + * @param index Index of target in authorities array. + */ + public removeAuthorizedAddressAtIndex(target: string, index: BigNumber): ContractTxFunctionObj { + const self = (this as any) as ERC721ProxyContract; + assert.isString('target', target); + assert.isBigNumber('index', index); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [ + target.toLowerCase(), + index, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [ + target.toLowerCase(), + index, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [ + target.toLowerCase(), + index, + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('removeAuthorizedAddressAtIndex(address,uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'removeAuthorizedAddressAtIndex(address,uint256)', + [target.toLowerCase(), index], + ); + return abiEncodedTransactionData; + }, + }; + } + /** + * Gets the proxy id associated with the proxy address. + * @returns Proxy id. + */ + public getProxyId(): ContractFunctionObj { + const self = (this as any) as ERC721ProxyContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('getProxyId()', []); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('getProxyId()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('getProxyId()', []); + return abiEncodedTransactionData; + }, + }; + } + public authorized(index_0: string): ContractFunctionObj { + const self = (this as any) as ERC721ProxyContract; + assert.isString('index_0', index_0); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('authorized(address)', [index_0.toLowerCase()]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('authorized(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('authorized(address)', [ + index_0.toLowerCase(), + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Gets all authorized addresses. + * @returns Array of authorized addresses. + */ + public getAuthorizedAddresses(): ContractFunctionObj { + const self = (this as any) as ERC721ProxyContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('getAuthorizedAddresses()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('getAuthorizedAddresses()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('getAuthorizedAddresses()', []); + return abiEncodedTransactionData; + }, + }; + } + public transferOwnership(newOwner: string): ContractTxFunctionObj { + const self = (this as any) as ERC721ProxyContract; + assert.isString('newOwner', newOwner); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('transferOwnership(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('transferOwnership(address)', [ + newOwner.toLowerCase(), + ]); + return abiEncodedTransactionData; + }, + }; + } + /** * Subscribe to an event type emitted by the ERC721Proxy contract. * @param eventName The ERC721Proxy contract event you would like to subscribe to. @@ -1289,6 +1142,12 @@ export class ERC721ProxyContract extends BaseContract { ERC721ProxyContract.ABI(), this._web3Wrapper, ); + ERC721ProxyContract.ABI().forEach((item, index) => { + if (item.type === 'function') { + const methodAbi = item as MethodAbi; + this._methodABIIndex[methodAbi.name] = index; + } + }); } } diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts b/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts index 00ee288b74..391b590a1b 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts @@ -1,7 +1,16 @@ // tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma enum-naming // tslint:disable:whitespace no-unbound-method no-trailing-whitespace // tslint:disable:no-unused-variable -import { BaseContract, SubscriptionManager, PromiseWithTransactionHash } from '@0x/base-contract'; +import { + AwaitTransactionSuccessOpts, + ContractFunctionObj, + ContractTxFunctionObj, + SendTransactionOpts, + BaseContract, + SubscriptionManager, + PromiseWithTransactionHash, + methodAbiToFunctionSignature, +} from '@0x/base-contract'; import { schemas } from '@0x/json-schemas'; import { BlockParam, @@ -19,13 +28,7 @@ import { SupportedProvider, } from 'ethereum-types'; import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils'; -import { - AwaitTransactionSuccessOpts, - EventCallback, - IndexedFilterValues, - SendTransactionOpts, - SimpleContractArtifact, -} from '@0x/types'; +import { EventCallback, IndexedFilterValues, SimpleContractArtifact } from '@0x/types'; import { Web3Wrapper } from '@0x/web3-wrapper'; import { assert } from '@0x/assert'; import * as ethers from 'ethers'; @@ -68,1275 +71,7 @@ export class ERC721TokenContract extends BaseContract { * @ignore */ public static deployedBytecode: string | undefined; - /** - * The zero address indicates there is no approved address. - * Throws unless `msg.sender` is the current NFT owner, or an authorized - * operator of the current owner. - */ - public approve = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param _approved The new approved NFT controller - * @param _tokenId The NFT to approve - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - _approved: string, - _tokenId: BigNumber, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('_approved', _approved); - assert.isBigNumber('_tokenId', _tokenId); - const self = (this as any) as ERC721TokenContract; - const encodedData = self._strictEncodeArguments('approve(address,uint256)', [ - _approved.toLowerCase(), - _tokenId, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.approve.callAsync(_approved, _tokenId, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param _approved The new approved NFT controller - * @param _tokenId The NFT to approve - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - _approved: string, - _tokenId: BigNumber, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('_approved', _approved); - assert.isBigNumber('_tokenId', _tokenId); - const self = (this as any) as ERC721TokenContract; - const txHashPromise = self.approve.sendTransactionAsync(_approved.toLowerCase(), _tokenId, txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param _approved The new approved NFT controller - * @param _tokenId The NFT to approve - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - _approved: string, - _tokenId: BigNumber, - txData?: Partial | undefined, - ): Promise { - assert.isString('_approved', _approved); - assert.isBigNumber('_tokenId', _tokenId); - const self = (this as any) as ERC721TokenContract; - const encodedData = self._strictEncodeArguments('approve(address,uint256)', [ - _approved.toLowerCase(), - _tokenId, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param _approved The new approved NFT controller - * @param _tokenId The NFT to approve - */ - async callAsync( - _approved: string, - _tokenId: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('_approved', _approved); - assert.isBigNumber('_tokenId', _tokenId); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ERC721TokenContract; - const encodedData = self._strictEncodeArguments('approve(address,uint256)', [ - _approved.toLowerCase(), - _tokenId, - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('approve(address,uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param _approved The new approved NFT controller - * @param _tokenId The NFT to approve - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(_approved: string, _tokenId: BigNumber): string { - assert.isString('_approved', _approved); - assert.isBigNumber('_tokenId', _tokenId); - const self = (this as any) as ERC721TokenContract; - const abiEncodedTransactionData = self._strictEncodeArguments('approve(address,uint256)', [ - _approved.toLowerCase(), - _tokenId, - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as ERC721TokenContract; - const abiEncoder = self._lookupAbiEncoder('approve(address,uint256)'); - return abiEncoder.getSelector(); - }, - }; - /** - * NFTs assigned to the zero address are considered invalid, and this - * function throws for queries about the zero address. - */ - public balanceOf = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param _owner An address for whom to query the balance - * @returns The number of NFTs owned by `_owner`, possibly zero - */ - async callAsync( - _owner: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('_owner', _owner); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ERC721TokenContract; - const encodedData = self._strictEncodeArguments('balanceOf(address)', [_owner.toLowerCase()]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('balanceOf(address)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Throws if `_tokenId` is not a valid NFT. - */ - public getApproved = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param _tokenId The NFT to find the approved address for - * @returns The approved address for this NFT, or the zero address if there is none - */ - async callAsync( - _tokenId: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isBigNumber('_tokenId', _tokenId); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ERC721TokenContract; - const encodedData = self._strictEncodeArguments('getApproved(uint256)', [_tokenId]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('getApproved(uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public isApprovedForAll = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param _owner The address that owns the NFTs - * @param _operator The address that acts on behalf of the owner - * @returns True if `_operator` is an approved operator for `_owner`, false otherwise - */ - async callAsync( - _owner: string, - _operator: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('_owner', _owner); - assert.isString('_operator', _operator); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ERC721TokenContract; - const encodedData = self._strictEncodeArguments('isApprovedForAll(address,address)', [ - _owner.toLowerCase(), - _operator.toLowerCase(), - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('isApprovedForAll(address,address)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * NFTs assigned to zero address are considered invalid, and queries - * about them do throw. - */ - public ownerOf = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param _tokenId The identifier for an NFT - * @returns The address of the owner of the NFT - */ - async callAsync( - _tokenId: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isBigNumber('_tokenId', _tokenId); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ERC721TokenContract; - const encodedData = self._strictEncodeArguments('ownerOf(uint256)', [_tokenId]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('ownerOf(uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * This works identically to the other function with an extra data parameter, - * except this function just sets data to "". - */ - public safeTransferFrom1 = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param _from The current owner of the NFT - * @param _to The new owner - * @param _tokenId The NFT to transfer - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - _from: string, - _to: string, - _tokenId: BigNumber, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('_from', _from); - assert.isString('_to', _to); - assert.isBigNumber('_tokenId', _tokenId); - const self = (this as any) as ERC721TokenContract; - const encodedData = self._strictEncodeArguments('safeTransferFrom(address,address,uint256)', [ - _from.toLowerCase(), - _to.toLowerCase(), - _tokenId, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.safeTransferFrom1.callAsync(_from, _to, _tokenId, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param _from The current owner of the NFT - * @param _to The new owner - * @param _tokenId The NFT to transfer - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - _from: string, - _to: string, - _tokenId: BigNumber, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('_from', _from); - assert.isString('_to', _to); - assert.isBigNumber('_tokenId', _tokenId); - const self = (this as any) as ERC721TokenContract; - const txHashPromise = self.safeTransferFrom1.sendTransactionAsync( - _from.toLowerCase(), - _to.toLowerCase(), - _tokenId, - txData, - opts, - ); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param _from The current owner of the NFT - * @param _to The new owner - * @param _tokenId The NFT to transfer - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - _from: string, - _to: string, - _tokenId: BigNumber, - txData?: Partial | undefined, - ): Promise { - assert.isString('_from', _from); - assert.isString('_to', _to); - assert.isBigNumber('_tokenId', _tokenId); - const self = (this as any) as ERC721TokenContract; - const encodedData = self._strictEncodeArguments('safeTransferFrom(address,address,uint256)', [ - _from.toLowerCase(), - _to.toLowerCase(), - _tokenId, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param _from The current owner of the NFT - * @param _to The new owner - * @param _tokenId The NFT to transfer - */ - async callAsync( - _from: string, - _to: string, - _tokenId: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('_from', _from); - assert.isString('_to', _to); - assert.isBigNumber('_tokenId', _tokenId); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ERC721TokenContract; - const encodedData = self._strictEncodeArguments('safeTransferFrom(address,address,uint256)', [ - _from.toLowerCase(), - _to.toLowerCase(), - _tokenId, - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('safeTransferFrom(address,address,uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param _from The current owner of the NFT - * @param _to The new owner - * @param _tokenId The NFT to transfer - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(_from: string, _to: string, _tokenId: BigNumber): string { - assert.isString('_from', _from); - assert.isString('_to', _to); - assert.isBigNumber('_tokenId', _tokenId); - const self = (this as any) as ERC721TokenContract; - const abiEncodedTransactionData = self._strictEncodeArguments('safeTransferFrom(address,address,uint256)', [ - _from.toLowerCase(), - _to.toLowerCase(), - _tokenId, - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as ERC721TokenContract; - const abiEncoder = self._lookupAbiEncoder('safeTransferFrom(address,address,uint256)'); - return abiEncoder.getSelector(); - }, - }; - /** - * Throws unless `msg.sender` is the current owner, an authorized - * operator, or the approved address for this NFT. Throws if `_from` is - * not the current owner. Throws if `_to` is the zero address. Throws if - * `_tokenId` is not a valid NFT. When transfer is complete, this function - * checks if `_to` is a smart contract (code size > 0). If so, it calls - * `onERC721Received` on `_to` and throws if the return value is not - * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`. - */ - public safeTransferFrom2 = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param _from The current owner of the NFT - * @param _to The new owner - * @param _tokenId The NFT to transfer - * @param _data Additional data with no specified format, sent in call to `_to` - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - _from: string, - _to: string, - _tokenId: BigNumber, - _data: string, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('_from', _from); - assert.isString('_to', _to); - assert.isBigNumber('_tokenId', _tokenId); - assert.isString('_data', _data); - const self = (this as any) as ERC721TokenContract; - const encodedData = self._strictEncodeArguments('safeTransferFrom(address,address,uint256,bytes)', [ - _from.toLowerCase(), - _to.toLowerCase(), - _tokenId, - _data, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.safeTransferFrom2.callAsync(_from, _to, _tokenId, _data, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param _from The current owner of the NFT - * @param _to The new owner - * @param _tokenId The NFT to transfer - * @param _data Additional data with no specified format, sent in call to `_to` - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - _from: string, - _to: string, - _tokenId: BigNumber, - _data: string, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('_from', _from); - assert.isString('_to', _to); - assert.isBigNumber('_tokenId', _tokenId); - assert.isString('_data', _data); - const self = (this as any) as ERC721TokenContract; - const txHashPromise = self.safeTransferFrom2.sendTransactionAsync( - _from.toLowerCase(), - _to.toLowerCase(), - _tokenId, - _data, - txData, - opts, - ); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param _from The current owner of the NFT - * @param _to The new owner - * @param _tokenId The NFT to transfer - * @param _data Additional data with no specified format, sent in call to `_to` - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - _from: string, - _to: string, - _tokenId: BigNumber, - _data: string, - txData?: Partial | undefined, - ): Promise { - assert.isString('_from', _from); - assert.isString('_to', _to); - assert.isBigNumber('_tokenId', _tokenId); - assert.isString('_data', _data); - const self = (this as any) as ERC721TokenContract; - const encodedData = self._strictEncodeArguments('safeTransferFrom(address,address,uint256,bytes)', [ - _from.toLowerCase(), - _to.toLowerCase(), - _tokenId, - _data, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param _from The current owner of the NFT - * @param _to The new owner - * @param _tokenId The NFT to transfer - * @param _data Additional data with no specified format, sent in call to `_to` - */ - async callAsync( - _from: string, - _to: string, - _tokenId: BigNumber, - _data: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('_from', _from); - assert.isString('_to', _to); - assert.isBigNumber('_tokenId', _tokenId); - assert.isString('_data', _data); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ERC721TokenContract; - const encodedData = self._strictEncodeArguments('safeTransferFrom(address,address,uint256,bytes)', [ - _from.toLowerCase(), - _to.toLowerCase(), - _tokenId, - _data, - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('safeTransferFrom(address,address,uint256,bytes)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param _from The current owner of the NFT - * @param _to The new owner - * @param _tokenId The NFT to transfer - * @param _data Additional data with no specified format, sent in call to `_to` - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(_from: string, _to: string, _tokenId: BigNumber, _data: string): string { - assert.isString('_from', _from); - assert.isString('_to', _to); - assert.isBigNumber('_tokenId', _tokenId); - assert.isString('_data', _data); - const self = (this as any) as ERC721TokenContract; - const abiEncodedTransactionData = self._strictEncodeArguments( - 'safeTransferFrom(address,address,uint256,bytes)', - [_from.toLowerCase(), _to.toLowerCase(), _tokenId, _data], - ); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as ERC721TokenContract; - const abiEncoder = self._lookupAbiEncoder('safeTransferFrom(address,address,uint256,bytes)'); - return abiEncoder.getSelector(); - }, - }; - /** - * Emits the ApprovalForAll event. The contract MUST allow - * multiple operators per owner. - */ - public setApprovalForAll = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param _operator Address to add to the set of authorized operators - * @param _approved True if the operator is approved, false to revoke approval - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - _operator: string, - _approved: boolean, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('_operator', _operator); - assert.isBoolean('_approved', _approved); - const self = (this as any) as ERC721TokenContract; - const encodedData = self._strictEncodeArguments('setApprovalForAll(address,bool)', [ - _operator.toLowerCase(), - _approved, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.setApprovalForAll.callAsync(_operator, _approved, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param _operator Address to add to the set of authorized operators - * @param _approved True if the operator is approved, false to revoke approval - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - _operator: string, - _approved: boolean, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('_operator', _operator); - assert.isBoolean('_approved', _approved); - const self = (this as any) as ERC721TokenContract; - const txHashPromise = self.setApprovalForAll.sendTransactionAsync( - _operator.toLowerCase(), - _approved, - txData, - opts, - ); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param _operator Address to add to the set of authorized operators - * @param _approved True if the operator is approved, false to revoke approval - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - _operator: string, - _approved: boolean, - txData?: Partial | undefined, - ): Promise { - assert.isString('_operator', _operator); - assert.isBoolean('_approved', _approved); - const self = (this as any) as ERC721TokenContract; - const encodedData = self._strictEncodeArguments('setApprovalForAll(address,bool)', [ - _operator.toLowerCase(), - _approved, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param _operator Address to add to the set of authorized operators - * @param _approved True if the operator is approved, false to revoke approval - */ - async callAsync( - _operator: string, - _approved: boolean, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('_operator', _operator); - assert.isBoolean('_approved', _approved); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ERC721TokenContract; - const encodedData = self._strictEncodeArguments('setApprovalForAll(address,bool)', [ - _operator.toLowerCase(), - _approved, - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('setApprovalForAll(address,bool)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param _operator Address to add to the set of authorized operators - * @param _approved True if the operator is approved, false to revoke approval - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(_operator: string, _approved: boolean): string { - assert.isString('_operator', _operator); - assert.isBoolean('_approved', _approved); - const self = (this as any) as ERC721TokenContract; - const abiEncodedTransactionData = self._strictEncodeArguments('setApprovalForAll(address,bool)', [ - _operator.toLowerCase(), - _approved, - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as ERC721TokenContract; - const abiEncoder = self._lookupAbiEncoder('setApprovalForAll(address,bool)'); - return abiEncoder.getSelector(); - }, - }; - /** - * Throws unless `msg.sender` is the current owner, an authorized - * operator, or the approved address for this NFT. Throws if `_from` is - * not the current owner. Throws if `_to` is the zero address. Throws if - * `_tokenId` is not a valid NFT. - */ - public transferFrom = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param _from The current owner of the NFT - * @param _to The new owner - * @param _tokenId The NFT to transfer - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - _from: string, - _to: string, - _tokenId: BigNumber, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('_from', _from); - assert.isString('_to', _to); - assert.isBigNumber('_tokenId', _tokenId); - const self = (this as any) as ERC721TokenContract; - const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [ - _from.toLowerCase(), - _to.toLowerCase(), - _tokenId, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.transferFrom.callAsync(_from, _to, _tokenId, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param _from The current owner of the NFT - * @param _to The new owner - * @param _tokenId The NFT to transfer - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - _from: string, - _to: string, - _tokenId: BigNumber, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('_from', _from); - assert.isString('_to', _to); - assert.isBigNumber('_tokenId', _tokenId); - const self = (this as any) as ERC721TokenContract; - const txHashPromise = self.transferFrom.sendTransactionAsync( - _from.toLowerCase(), - _to.toLowerCase(), - _tokenId, - txData, - opts, - ); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param _from The current owner of the NFT - * @param _to The new owner - * @param _tokenId The NFT to transfer - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - _from: string, - _to: string, - _tokenId: BigNumber, - txData?: Partial | undefined, - ): Promise { - assert.isString('_from', _from); - assert.isString('_to', _to); - assert.isBigNumber('_tokenId', _tokenId); - const self = (this as any) as ERC721TokenContract; - const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [ - _from.toLowerCase(), - _to.toLowerCase(), - _tokenId, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param _from The current owner of the NFT - * @param _to The new owner - * @param _tokenId The NFT to transfer - */ - async callAsync( - _from: string, - _to: string, - _tokenId: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('_from', _from); - assert.isString('_to', _to); - assert.isBigNumber('_tokenId', _tokenId); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ERC721TokenContract; - const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [ - _from.toLowerCase(), - _to.toLowerCase(), - _tokenId, - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('transferFrom(address,address,uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param _from The current owner of the NFT - * @param _to The new owner - * @param _tokenId The NFT to transfer - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(_from: string, _to: string, _tokenId: BigNumber): string { - assert.isString('_from', _from); - assert.isString('_to', _to); - assert.isBigNumber('_tokenId', _tokenId); - const self = (this as any) as ERC721TokenContract; - const abiEncodedTransactionData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [ - _from.toLowerCase(), - _to.toLowerCase(), - _tokenId, - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as ERC721TokenContract; - const abiEncoder = self._lookupAbiEncoder('transferFrom(address,address,uint256)'); - return abiEncoder.getSelector(); - }, - }; + private _methodABIIndex: { [name: string]: number } = {}; private readonly _subscriptionManager: SubscriptionManager; public static async deployFrom0xArtifactAsync( artifact: ContractArtifact | SimpleContractArtifact, @@ -1665,6 +400,912 @@ export class ERC721TokenContract extends BaseContract { ] as ContractAbi; return abi; } + + public getFunctionSignature(methodName: string): string { + const index = this._methodABIIndex[methodName]; + const methodAbi = ERC721TokenContract.ABI()[index] as MethodAbi; + const functionSignature = methodAbiToFunctionSignature(methodAbi); + return functionSignature; + } + public getABIDecodedTransactionData(methodName: string, callData: string): T { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as ERC721TokenContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + const abiDecodedCallData = abiEncoder.strictDecode(callData); + return abiDecodedCallData; + } + public getABIDecodedReturnData(methodName: string, callData: string): T { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as ERC721TokenContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + const abiDecodedCallData = abiEncoder.strictDecodeReturnValue(callData); + return abiDecodedCallData; + } + public getSelector(methodName: string): string { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as ERC721TokenContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + return abiEncoder.getSelector(); + } + + /** + * The zero address indicates there is no approved address. + * Throws unless `msg.sender` is the current NFT owner, or an authorized + * operator of the current owner. + * @param _approved The new approved NFT controller + * @param _tokenId The NFT to approve + */ + public approve(_approved: string, _tokenId: BigNumber): ContractTxFunctionObj { + const self = (this as any) as ERC721TokenContract; + assert.isString('_approved', _approved); + assert.isBigNumber('_tokenId', _tokenId); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('approve(address,uint256)', [ + _approved.toLowerCase(), + _tokenId, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('approve(address,uint256)', [ + _approved.toLowerCase(), + _tokenId, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('approve(address,uint256)', [ + _approved.toLowerCase(), + _tokenId, + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('approve(address,uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('approve(address,uint256)', [ + _approved.toLowerCase(), + _tokenId, + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * NFTs assigned to the zero address are considered invalid, and this + * function throws for queries about the zero address. + * @param _owner An address for whom to query the balance + * @returns The number of NFTs owned by `_owner`, possibly zero + */ + public balanceOf(_owner: string): ContractFunctionObj { + const self = (this as any) as ERC721TokenContract; + assert.isString('_owner', _owner); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('balanceOf(address)', [_owner.toLowerCase()]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('balanceOf(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('balanceOf(address)', [ + _owner.toLowerCase(), + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Throws if `_tokenId` is not a valid NFT. + * @param _tokenId The NFT to find the approved address for + * @returns The approved address for this NFT, or the zero address if there is none + */ + public getApproved(_tokenId: BigNumber): ContractFunctionObj { + const self = (this as any) as ERC721TokenContract; + assert.isBigNumber('_tokenId', _tokenId); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('getApproved(uint256)', [_tokenId]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('getApproved(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('getApproved(uint256)', [_tokenId]); + return abiEncodedTransactionData; + }, + }; + } + public isApprovedForAll(_owner: string, _operator: string): ContractFunctionObj { + const self = (this as any) as ERC721TokenContract; + assert.isString('_owner', _owner); + assert.isString('_operator', _operator); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('isApprovedForAll(address,address)', [ + _owner.toLowerCase(), + _operator.toLowerCase(), + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('isApprovedForAll(address,address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('isApprovedForAll(address,address)', [ + _owner.toLowerCase(), + _operator.toLowerCase(), + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * NFTs assigned to zero address are considered invalid, and queries + * about them do throw. + * @param _tokenId The identifier for an NFT + * @returns The address of the owner of the NFT + */ + public ownerOf(_tokenId: BigNumber): ContractFunctionObj { + const self = (this as any) as ERC721TokenContract; + assert.isBigNumber('_tokenId', _tokenId); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('ownerOf(uint256)', [_tokenId]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('ownerOf(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('ownerOf(uint256)', [_tokenId]); + return abiEncodedTransactionData; + }, + }; + } + /** + * This works identically to the other function with an extra data parameter, + * except this function just sets data to "". + * @param _from The current owner of the NFT + * @param _to The new owner + * @param _tokenId The NFT to transfer + */ + public safeTransferFrom1(_from: string, _to: string, _tokenId: BigNumber): ContractTxFunctionObj { + const self = (this as any) as ERC721TokenContract; + assert.isString('_from', _from); + assert.isString('_to', _to); + assert.isBigNumber('_tokenId', _tokenId); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('safeTransferFrom(address,address,uint256)', [ + _from.toLowerCase(), + _to.toLowerCase(), + _tokenId, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('safeTransferFrom(address,address,uint256)', [ + _from.toLowerCase(), + _to.toLowerCase(), + _tokenId, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('safeTransferFrom(address,address,uint256)', [ + _from.toLowerCase(), + _to.toLowerCase(), + _tokenId, + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('safeTransferFrom(address,address,uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'safeTransferFrom(address,address,uint256)', + [_from.toLowerCase(), _to.toLowerCase(), _tokenId], + ); + return abiEncodedTransactionData; + }, + }; + } + /** + * Throws unless `msg.sender` is the current owner, an authorized + * operator, or the approved address for this NFT. Throws if `_from` is + * not the current owner. Throws if `_to` is the zero address. Throws if + * `_tokenId` is not a valid NFT. When transfer is complete, this function + * checks if `_to` is a smart contract (code size > 0). If so, it calls + * `onERC721Received` on `_to` and throws if the return value is not + * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`. + * @param _from The current owner of the NFT + * @param _to The new owner + * @param _tokenId The NFT to transfer + * @param _data Additional data with no specified format, sent in call to `_to` + */ + public safeTransferFrom2( + _from: string, + _to: string, + _tokenId: BigNumber, + _data: string, + ): ContractTxFunctionObj { + const self = (this as any) as ERC721TokenContract; + assert.isString('_from', _from); + assert.isString('_to', _to); + assert.isBigNumber('_tokenId', _tokenId); + assert.isString('_data', _data); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('safeTransferFrom(address,address,uint256,bytes)', [ + _from.toLowerCase(), + _to.toLowerCase(), + _tokenId, + _data, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('safeTransferFrom(address,address,uint256,bytes)', [ + _from.toLowerCase(), + _to.toLowerCase(), + _tokenId, + _data, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('safeTransferFrom(address,address,uint256,bytes)', [ + _from.toLowerCase(), + _to.toLowerCase(), + _tokenId, + _data, + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('safeTransferFrom(address,address,uint256,bytes)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'safeTransferFrom(address,address,uint256,bytes)', + [_from.toLowerCase(), _to.toLowerCase(), _tokenId, _data], + ); + return abiEncodedTransactionData; + }, + }; + } + /** + * Emits the ApprovalForAll event. The contract MUST allow + * multiple operators per owner. + * @param _operator Address to add to the set of authorized operators + * @param _approved True if the operator is approved, false to revoke approval + */ + public setApprovalForAll(_operator: string, _approved: boolean): ContractTxFunctionObj { + const self = (this as any) as ERC721TokenContract; + assert.isString('_operator', _operator); + assert.isBoolean('_approved', _approved); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('setApprovalForAll(address,bool)', [ + _operator.toLowerCase(), + _approved, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('setApprovalForAll(address,bool)', [ + _operator.toLowerCase(), + _approved, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('setApprovalForAll(address,bool)', [ + _operator.toLowerCase(), + _approved, + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('setApprovalForAll(address,bool)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('setApprovalForAll(address,bool)', [ + _operator.toLowerCase(), + _approved, + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Throws unless `msg.sender` is the current owner, an authorized + * operator, or the approved address for this NFT. Throws if `_from` is + * not the current owner. Throws if `_to` is the zero address. Throws if + * `_tokenId` is not a valid NFT. + * @param _from The current owner of the NFT + * @param _to The new owner + * @param _tokenId The NFT to transfer + */ + public transferFrom(_from: string, _to: string, _tokenId: BigNumber): ContractTxFunctionObj { + const self = (this as any) as ERC721TokenContract; + assert.isString('_from', _from); + assert.isString('_to', _to); + assert.isBigNumber('_tokenId', _tokenId); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [ + _from.toLowerCase(), + _to.toLowerCase(), + _tokenId, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [ + _from.toLowerCase(), + _to.toLowerCase(), + _tokenId, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [ + _from.toLowerCase(), + _to.toLowerCase(), + _tokenId, + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('transferFrom(address,address,uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [ + _from.toLowerCase(), + _to.toLowerCase(), + _tokenId, + ]); + return abiEncodedTransactionData; + }, + }; + } + /** * Subscribe to an event type emitted by the ERC721Token contract. * @param eventName The ERC721Token contract event you would like to subscribe to. @@ -1754,6 +1395,12 @@ export class ERC721TokenContract extends BaseContract { ERC721TokenContract.ABI(), this._web3Wrapper, ); + ERC721TokenContract.ABI().forEach((item, index) => { + if (item.type === 'function') { + const methodAbi = item as MethodAbi; + this._methodABIIndex[methodAbi.name] = index; + } + }); } } diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/eth_balance_checker.ts b/packages/abi-gen-wrappers/src/generated-wrappers/eth_balance_checker.ts index 4fac46c6b4..3d015e1604 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/eth_balance_checker.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/eth_balance_checker.ts @@ -1,7 +1,15 @@ // tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma enum-naming // tslint:disable:whitespace no-unbound-method no-trailing-whitespace // tslint:disable:no-unused-variable -import { BaseContract, PromiseWithTransactionHash } from '@0x/base-contract'; +import { + AwaitTransactionSuccessOpts, + ContractFunctionObj, + ContractTxFunctionObj, + SendTransactionOpts, + BaseContract, + PromiseWithTransactionHash, + methodAbiToFunctionSignature, +} from '@0x/base-contract'; import { schemas } from '@0x/json-schemas'; import { BlockParam, @@ -18,13 +26,7 @@ import { SupportedProvider, } from 'ethereum-types'; import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils'; -import { - AwaitTransactionSuccessOpts, - EventCallback, - IndexedFilterValues, - SendTransactionOpts, - SimpleContractArtifact, -} from '@0x/types'; +import { EventCallback, IndexedFilterValues, SimpleContractArtifact } from '@0x/types'; import { Web3Wrapper } from '@0x/web3-wrapper'; import { assert } from '@0x/assert'; import * as ethers from 'ethers'; @@ -38,59 +40,7 @@ export class EthBalanceCheckerContract extends BaseContract { * @ignore */ public static deployedBytecode: string | undefined; - /** - * Batch fetches ETH balances - */ - public getEthBalances = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param addresses Array of addresses. - * @returns Array of ETH balances. - */ - async callAsync( - addresses: string[], - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isArray('addresses', addresses); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as EthBalanceCheckerContract; - const encodedData = self._strictEncodeArguments('getEthBalances(address[])', [addresses]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('getEthBalances(address[])'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; + private _methodABIIndex: { [name: string]: number } = {}; public static async deployFrom0xArtifactAsync( artifact: ContractArtifact | SimpleContractArtifact, supportedProvider: SupportedProvider, @@ -182,6 +132,88 @@ export class EthBalanceCheckerContract extends BaseContract { ] as ContractAbi; return abi; } + + public getFunctionSignature(methodName: string): string { + const index = this._methodABIIndex[methodName]; + const methodAbi = EthBalanceCheckerContract.ABI()[index] as MethodAbi; + const functionSignature = methodAbiToFunctionSignature(methodAbi); + return functionSignature; + } + public getABIDecodedTransactionData(methodName: string, callData: string): T { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as EthBalanceCheckerContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + const abiDecodedCallData = abiEncoder.strictDecode(callData); + return abiDecodedCallData; + } + public getABIDecodedReturnData(methodName: string, callData: string): T { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as EthBalanceCheckerContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + const abiDecodedCallData = abiEncoder.strictDecodeReturnValue(callData); + return abiDecodedCallData; + } + public getSelector(methodName: string): string { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as EthBalanceCheckerContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + return abiEncoder.getSelector(); + } + + /** + * Batch fetches ETH balances + * @param addresses Array of addresses. + * @returns Array of ETH balances. + */ + public getEthBalances(addresses: string[]): ContractFunctionObj { + const self = (this as any) as EthBalanceCheckerContract; + assert.isArray('addresses', addresses); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('getEthBalances(address[])', [addresses]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('getEthBalances(address[])'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('getEthBalances(address[])', [addresses]); + return abiEncodedTransactionData; + }, + }; + } + constructor( address: string, supportedProvider: SupportedProvider, @@ -199,6 +231,12 @@ export class EthBalanceCheckerContract extends BaseContract { deployedBytecode, ); classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']); + EthBalanceCheckerContract.ABI().forEach((item, index) => { + if (item.type === 'function') { + const methodAbi = item as MethodAbi; + this._methodABIIndex[methodAbi.name] = index; + } + }); } } diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts b/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts index bb4329eef8..fc4dd289cf 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts @@ -1,7 +1,16 @@ // tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma enum-naming // tslint:disable:whitespace no-unbound-method no-trailing-whitespace // tslint:disable:no-unused-variable -import { BaseContract, SubscriptionManager, PromiseWithTransactionHash } from '@0x/base-contract'; +import { + AwaitTransactionSuccessOpts, + ContractFunctionObj, + ContractTxFunctionObj, + SendTransactionOpts, + BaseContract, + SubscriptionManager, + PromiseWithTransactionHash, + methodAbiToFunctionSignature, +} from '@0x/base-contract'; import { schemas } from '@0x/json-schemas'; import { BlockParam, @@ -19,13 +28,7 @@ import { SupportedProvider, } from 'ethereum-types'; import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils'; -import { - AwaitTransactionSuccessOpts, - EventCallback, - IndexedFilterValues, - SendTransactionOpts, - SimpleContractArtifact, -} from '@0x/types'; +import { EventCallback, IndexedFilterValues, SimpleContractArtifact } from '@0x/types'; import { Web3Wrapper } from '@0x/web3-wrapper'; import { assert } from '@0x/assert'; import * as ethers from 'ethers'; @@ -117,8141 +120,1759 @@ export class ExchangeContract extends BaseContract { * @ignore */ public static deployedBytecode: string | undefined; - public EIP1271_MAGIC_VALUE = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments('EIP1271_MAGIC_VALUE()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('EIP1271_MAGIC_VALUE()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public EIP712_EXCHANGE_DOMAIN_HASH = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments('EIP712_EXCHANGE_DOMAIN_HASH()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('EIP712_EXCHANGE_DOMAIN_HASH()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public allowedValidators = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync( - index_0: string, - index_1: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('index_0', index_0); - assert.isString('index_1', index_1); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments('allowedValidators(address,address)', [ - index_0.toLowerCase(), - index_1.toLowerCase(), - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('allowedValidators(address,address)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Executes multiple calls of cancelOrder. - */ - public batchCancelOrders = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param orders Array of order specifications. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isArray('orders', orders); - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments( - 'batchCancelOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[])', - [orders], - ); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.batchCancelOrders.callAsync(orders, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param orders Array of order specifications. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isArray('orders', orders); - const self = (this as any) as ExchangeContract; - const txHashPromise = self.batchCancelOrders.sendTransactionAsync(orders, txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param orders Array of order specifications. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - txData?: Partial | undefined, - ): Promise { - assert.isArray('orders', orders); - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments( - 'batchCancelOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[])', - [orders], - ); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param orders Array of order specifications. - */ - async callAsync( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isArray('orders', orders); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments( - 'batchCancelOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[])', - [orders], - ); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder( - 'batchCancelOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[])', - ); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param orders Array of order specifications. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - ): string { - assert.isArray('orders', orders); - const self = (this as any) as ExchangeContract; - const abiEncodedTransactionData = self._strictEncodeArguments( - 'batchCancelOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[])', - [orders], - ); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as ExchangeContract; - const abiEncoder = self._lookupAbiEncoder( - 'batchCancelOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[])', - ); - return abiEncoder.getSelector(); - }, - }; - /** - * Executes a batch of Exchange method calls in the context of signer(s). - */ - public batchExecuteTransactions = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param transactions Array of 0x transaction structures. - * @param signatures Array of proofs that transactions have been signed by - * signer(s). - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - transactions: Array<{ - salt: BigNumber; - expirationTimeSeconds: BigNumber; - gasPrice: BigNumber; - signerAddress: string; - data: string; - }>, - signatures: string[], - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isArray('transactions', transactions); - assert.isArray('signatures', signatures); - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments( - 'batchExecuteTransactions((uint256,uint256,uint256,address,bytes)[],bytes[])', - [transactions, signatures], - ); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.batchExecuteTransactions.callAsync(transactions, signatures, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param transactions Array of 0x transaction structures. - * @param signatures Array of proofs that transactions have been signed by - * signer(s). - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - transactions: Array<{ - salt: BigNumber; - expirationTimeSeconds: BigNumber; - gasPrice: BigNumber; - signerAddress: string; - data: string; - }>, - signatures: string[], - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isArray('transactions', transactions); - assert.isArray('signatures', signatures); - const self = (this as any) as ExchangeContract; - const txHashPromise = self.batchExecuteTransactions.sendTransactionAsync( - transactions, - signatures, - txData, - opts, - ); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param transactions Array of 0x transaction structures. - * @param signatures Array of proofs that transactions have been signed by - * signer(s). - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - transactions: Array<{ - salt: BigNumber; - expirationTimeSeconds: BigNumber; - gasPrice: BigNumber; - signerAddress: string; - data: string; - }>, - signatures: string[], - txData?: Partial | undefined, - ): Promise { - assert.isArray('transactions', transactions); - assert.isArray('signatures', signatures); - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments( - 'batchExecuteTransactions((uint256,uint256,uint256,address,bytes)[],bytes[])', - [transactions, signatures], - ); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param transactions Array of 0x transaction structures. - * @param signatures Array of proofs that transactions have been signed by - * signer(s). - * @returns Array containing ABI encoded return data for each of the underlying Exchange function calls. - */ - async callAsync( - transactions: Array<{ - salt: BigNumber; - expirationTimeSeconds: BigNumber; - gasPrice: BigNumber; - signerAddress: string; - data: string; - }>, - signatures: string[], - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isArray('transactions', transactions); - assert.isArray('signatures', signatures); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments( - 'batchExecuteTransactions((uint256,uint256,uint256,address,bytes)[],bytes[])', - [transactions, signatures], - ); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder( - 'batchExecuteTransactions((uint256,uint256,uint256,address,bytes)[],bytes[])', - ); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param transactions Array of 0x transaction structures. - * @param signatures Array of proofs that transactions have been signed by - * signer(s). - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData( - transactions: Array<{ - salt: BigNumber; - expirationTimeSeconds: BigNumber; - gasPrice: BigNumber; - signerAddress: string; - data: string; - }>, - signatures: string[], - ): string { - assert.isArray('transactions', transactions); - assert.isArray('signatures', signatures); - const self = (this as any) as ExchangeContract; - const abiEncodedTransactionData = self._strictEncodeArguments( - 'batchExecuteTransactions((uint256,uint256,uint256,address,bytes)[],bytes[])', - [transactions, signatures], - ); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as ExchangeContract; - const abiEncoder = self._lookupAbiEncoder( - 'batchExecuteTransactions((uint256,uint256,uint256,address,bytes)[],bytes[])', - ); - return abiEncoder.getSelector(); - }, - }; - /** - * Executes multiple calls of fillOrKillOrder. - */ - public batchFillOrKillOrders = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param orders Array of order specifications. - * @param takerAssetFillAmounts Array of desired amounts of takerAsset to sell - * in orders. - * @param signatures Proofs that orders have been created by makers. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - takerAssetFillAmounts: BigNumber[], - signatures: string[], - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isArray('orders', orders); - assert.isArray('takerAssetFillAmounts', takerAssetFillAmounts); - assert.isArray('signatures', signatures); - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments( - 'batchFillOrKillOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256[],bytes[])', - [orders, takerAssetFillAmounts, signatures], - ); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.batchFillOrKillOrders.callAsync( - orders, - takerAssetFillAmounts, - signatures, - txDataWithDefaults, - ); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param orders Array of order specifications. - * @param takerAssetFillAmounts Array of desired amounts of takerAsset to sell - * in orders. - * @param signatures Proofs that orders have been created by makers. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - takerAssetFillAmounts: BigNumber[], - signatures: string[], - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isArray('orders', orders); - assert.isArray('takerAssetFillAmounts', takerAssetFillAmounts); - assert.isArray('signatures', signatures); - const self = (this as any) as ExchangeContract; - const txHashPromise = self.batchFillOrKillOrders.sendTransactionAsync( - orders, - takerAssetFillAmounts, - signatures, - txData, - opts, - ); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param orders Array of order specifications. - * @param takerAssetFillAmounts Array of desired amounts of takerAsset to sell - * in orders. - * @param signatures Proofs that orders have been created by makers. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - takerAssetFillAmounts: BigNumber[], - signatures: string[], - txData?: Partial | undefined, - ): Promise { - assert.isArray('orders', orders); - assert.isArray('takerAssetFillAmounts', takerAssetFillAmounts); - assert.isArray('signatures', signatures); - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments( - 'batchFillOrKillOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256[],bytes[])', - [orders, takerAssetFillAmounts, signatures], - ); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param orders Array of order specifications. - * @param takerAssetFillAmounts Array of desired amounts of takerAsset to sell - * in orders. - * @param signatures Proofs that orders have been created by makers. - * @returns Array of amounts filled and fees paid by makers and taker. - */ - async callAsync( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - takerAssetFillAmounts: BigNumber[], - signatures: string[], - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise< - Array<{ - makerAssetFilledAmount: BigNumber; - takerAssetFilledAmount: BigNumber; - makerFeePaid: BigNumber; - takerFeePaid: BigNumber; - protocolFeePaid: BigNumber; - }> - > { - assert.isArray('orders', orders); - assert.isArray('takerAssetFillAmounts', takerAssetFillAmounts); - assert.isArray('signatures', signatures); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments( - 'batchFillOrKillOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256[],bytes[])', - [orders, takerAssetFillAmounts, signatures], - ); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder( - 'batchFillOrKillOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256[],bytes[])', - ); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue< - Array<{ - makerAssetFilledAmount: BigNumber; - takerAssetFilledAmount: BigNumber; - makerFeePaid: BigNumber; - takerFeePaid: BigNumber; - protocolFeePaid: BigNumber; - }> - >(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param orders Array of order specifications. - * @param takerAssetFillAmounts Array of desired amounts of takerAsset to sell - * in orders. - * @param signatures Proofs that orders have been created by makers. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - takerAssetFillAmounts: BigNumber[], - signatures: string[], - ): string { - assert.isArray('orders', orders); - assert.isArray('takerAssetFillAmounts', takerAssetFillAmounts); - assert.isArray('signatures', signatures); - const self = (this as any) as ExchangeContract; - const abiEncodedTransactionData = self._strictEncodeArguments( - 'batchFillOrKillOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256[],bytes[])', - [orders, takerAssetFillAmounts, signatures], - ); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as ExchangeContract; - const abiEncoder = self._lookupAbiEncoder( - 'batchFillOrKillOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256[],bytes[])', - ); - return abiEncoder.getSelector(); - }, - }; - /** - * Executes multiple calls of fillOrder. - */ - public batchFillOrders = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param orders Array of order specifications. - * @param takerAssetFillAmounts Array of desired amounts of takerAsset to sell - * in orders. - * @param signatures Proofs that orders have been created by makers. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - takerAssetFillAmounts: BigNumber[], - signatures: string[], - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isArray('orders', orders); - assert.isArray('takerAssetFillAmounts', takerAssetFillAmounts); - assert.isArray('signatures', signatures); - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments( - 'batchFillOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256[],bytes[])', - [orders, takerAssetFillAmounts, signatures], - ); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.batchFillOrders.callAsync(orders, takerAssetFillAmounts, signatures, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param orders Array of order specifications. - * @param takerAssetFillAmounts Array of desired amounts of takerAsset to sell - * in orders. - * @param signatures Proofs that orders have been created by makers. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - takerAssetFillAmounts: BigNumber[], - signatures: string[], - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isArray('orders', orders); - assert.isArray('takerAssetFillAmounts', takerAssetFillAmounts); - assert.isArray('signatures', signatures); - const self = (this as any) as ExchangeContract; - const txHashPromise = self.batchFillOrders.sendTransactionAsync( - orders, - takerAssetFillAmounts, - signatures, - txData, - opts, - ); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param orders Array of order specifications. - * @param takerAssetFillAmounts Array of desired amounts of takerAsset to sell - * in orders. - * @param signatures Proofs that orders have been created by makers. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - takerAssetFillAmounts: BigNumber[], - signatures: string[], - txData?: Partial | undefined, - ): Promise { - assert.isArray('orders', orders); - assert.isArray('takerAssetFillAmounts', takerAssetFillAmounts); - assert.isArray('signatures', signatures); - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments( - 'batchFillOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256[],bytes[])', - [orders, takerAssetFillAmounts, signatures], - ); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param orders Array of order specifications. - * @param takerAssetFillAmounts Array of desired amounts of takerAsset to sell - * in orders. - * @param signatures Proofs that orders have been created by makers. - * @returns Array of amounts filled and fees paid by makers and taker. - */ - async callAsync( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - takerAssetFillAmounts: BigNumber[], - signatures: string[], - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise< - Array<{ - makerAssetFilledAmount: BigNumber; - takerAssetFilledAmount: BigNumber; - makerFeePaid: BigNumber; - takerFeePaid: BigNumber; - protocolFeePaid: BigNumber; - }> - > { - assert.isArray('orders', orders); - assert.isArray('takerAssetFillAmounts', takerAssetFillAmounts); - assert.isArray('signatures', signatures); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments( - 'batchFillOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256[],bytes[])', - [orders, takerAssetFillAmounts, signatures], - ); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder( - 'batchFillOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256[],bytes[])', - ); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue< - Array<{ - makerAssetFilledAmount: BigNumber; - takerAssetFilledAmount: BigNumber; - makerFeePaid: BigNumber; - takerFeePaid: BigNumber; - protocolFeePaid: BigNumber; - }> - >(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param orders Array of order specifications. - * @param takerAssetFillAmounts Array of desired amounts of takerAsset to sell - * in orders. - * @param signatures Proofs that orders have been created by makers. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - takerAssetFillAmounts: BigNumber[], - signatures: string[], - ): string { - assert.isArray('orders', orders); - assert.isArray('takerAssetFillAmounts', takerAssetFillAmounts); - assert.isArray('signatures', signatures); - const self = (this as any) as ExchangeContract; - const abiEncodedTransactionData = self._strictEncodeArguments( - 'batchFillOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256[],bytes[])', - [orders, takerAssetFillAmounts, signatures], - ); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as ExchangeContract; - const abiEncoder = self._lookupAbiEncoder( - 'batchFillOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256[],bytes[])', - ); - return abiEncoder.getSelector(); - }, - }; - /** - * Executes multiple calls of fillOrder. If any fill reverts, the error is caught and ignored. - */ - public batchFillOrdersNoThrow = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param orders Array of order specifications. - * @param takerAssetFillAmounts Array of desired amounts of takerAsset to sell - * in orders. - * @param signatures Proofs that orders have been created by makers. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - takerAssetFillAmounts: BigNumber[], - signatures: string[], - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isArray('orders', orders); - assert.isArray('takerAssetFillAmounts', takerAssetFillAmounts); - assert.isArray('signatures', signatures); - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments( - 'batchFillOrdersNoThrow((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256[],bytes[])', - [orders, takerAssetFillAmounts, signatures], - ); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.batchFillOrdersNoThrow.callAsync( - orders, - takerAssetFillAmounts, - signatures, - txDataWithDefaults, - ); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param orders Array of order specifications. - * @param takerAssetFillAmounts Array of desired amounts of takerAsset to sell - * in orders. - * @param signatures Proofs that orders have been created by makers. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - takerAssetFillAmounts: BigNumber[], - signatures: string[], - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isArray('orders', orders); - assert.isArray('takerAssetFillAmounts', takerAssetFillAmounts); - assert.isArray('signatures', signatures); - const self = (this as any) as ExchangeContract; - const txHashPromise = self.batchFillOrdersNoThrow.sendTransactionAsync( - orders, - takerAssetFillAmounts, - signatures, - txData, - opts, - ); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param orders Array of order specifications. - * @param takerAssetFillAmounts Array of desired amounts of takerAsset to sell - * in orders. - * @param signatures Proofs that orders have been created by makers. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - takerAssetFillAmounts: BigNumber[], - signatures: string[], - txData?: Partial | undefined, - ): Promise { - assert.isArray('orders', orders); - assert.isArray('takerAssetFillAmounts', takerAssetFillAmounts); - assert.isArray('signatures', signatures); - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments( - 'batchFillOrdersNoThrow((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256[],bytes[])', - [orders, takerAssetFillAmounts, signatures], - ); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param orders Array of order specifications. - * @param takerAssetFillAmounts Array of desired amounts of takerAsset to sell - * in orders. - * @param signatures Proofs that orders have been created by makers. - * @returns Array of amounts filled and fees paid by makers and taker. - */ - async callAsync( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - takerAssetFillAmounts: BigNumber[], - signatures: string[], - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise< - Array<{ - makerAssetFilledAmount: BigNumber; - takerAssetFilledAmount: BigNumber; - makerFeePaid: BigNumber; - takerFeePaid: BigNumber; - protocolFeePaid: BigNumber; - }> - > { - assert.isArray('orders', orders); - assert.isArray('takerAssetFillAmounts', takerAssetFillAmounts); - assert.isArray('signatures', signatures); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments( - 'batchFillOrdersNoThrow((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256[],bytes[])', - [orders, takerAssetFillAmounts, signatures], - ); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder( - 'batchFillOrdersNoThrow((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256[],bytes[])', - ); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue< - Array<{ - makerAssetFilledAmount: BigNumber; - takerAssetFilledAmount: BigNumber; - makerFeePaid: BigNumber; - takerFeePaid: BigNumber; - protocolFeePaid: BigNumber; - }> - >(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param orders Array of order specifications. - * @param takerAssetFillAmounts Array of desired amounts of takerAsset to sell - * in orders. - * @param signatures Proofs that orders have been created by makers. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - takerAssetFillAmounts: BigNumber[], - signatures: string[], - ): string { - assert.isArray('orders', orders); - assert.isArray('takerAssetFillAmounts', takerAssetFillAmounts); - assert.isArray('signatures', signatures); - const self = (this as any) as ExchangeContract; - const abiEncodedTransactionData = self._strictEncodeArguments( - 'batchFillOrdersNoThrow((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256[],bytes[])', - [orders, takerAssetFillAmounts, signatures], - ); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as ExchangeContract; - const abiEncoder = self._lookupAbiEncoder( - 'batchFillOrdersNoThrow((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256[],bytes[])', - ); - return abiEncoder.getSelector(); - }, - }; - /** - * Match complementary orders that have a profitable spread. - * Each order is filled at their respective price point, and - * the matcher receives a profit denominated in the left maker asset. - */ - public batchMatchOrders = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param leftOrders Set of orders with the same maker / taker asset. - * @param rightOrders Set of orders to match against `leftOrders` - * @param leftSignatures Proof that left orders were created by the left - * makers. - * @param rightSignatures Proof that right orders were created by the right - * makers. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - leftOrders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - rightOrders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - leftSignatures: string[], - rightSignatures: string[], - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isArray('leftOrders', leftOrders); - assert.isArray('rightOrders', rightOrders); - assert.isArray('leftSignatures', leftSignatures); - assert.isArray('rightSignatures', rightSignatures); - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments( - 'batchMatchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],bytes[],bytes[])', - [leftOrders, rightOrders, leftSignatures, rightSignatures], - ); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.batchMatchOrders.callAsync( - leftOrders, - rightOrders, - leftSignatures, - rightSignatures, - txDataWithDefaults, - ); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param leftOrders Set of orders with the same maker / taker asset. - * @param rightOrders Set of orders to match against `leftOrders` - * @param leftSignatures Proof that left orders were created by the left - * makers. - * @param rightSignatures Proof that right orders were created by the right - * makers. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - leftOrders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - rightOrders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - leftSignatures: string[], - rightSignatures: string[], - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isArray('leftOrders', leftOrders); - assert.isArray('rightOrders', rightOrders); - assert.isArray('leftSignatures', leftSignatures); - assert.isArray('rightSignatures', rightSignatures); - const self = (this as any) as ExchangeContract; - const txHashPromise = self.batchMatchOrders.sendTransactionAsync( - leftOrders, - rightOrders, - leftSignatures, - rightSignatures, - txData, - opts, - ); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param leftOrders Set of orders with the same maker / taker asset. - * @param rightOrders Set of orders to match against `leftOrders` - * @param leftSignatures Proof that left orders were created by the left - * makers. - * @param rightSignatures Proof that right orders were created by the right - * makers. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - leftOrders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - rightOrders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - leftSignatures: string[], - rightSignatures: string[], - txData?: Partial | undefined, - ): Promise { - assert.isArray('leftOrders', leftOrders); - assert.isArray('rightOrders', rightOrders); - assert.isArray('leftSignatures', leftSignatures); - assert.isArray('rightSignatures', rightSignatures); - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments( - 'batchMatchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],bytes[],bytes[])', - [leftOrders, rightOrders, leftSignatures, rightSignatures], - ); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + private _methodABIIndex: { [name: string]: number } = {}; + private readonly _subscriptionManager: SubscriptionManager; + public static async deployFrom0xArtifactAsync( + artifact: ContractArtifact | SimpleContractArtifact, + supportedProvider: SupportedProvider, + txDefaults: Partial, + logDecodeDependencies: { [contractName: string]: ContractArtifact | SimpleContractArtifact }, + chainId: BigNumber, + ): Promise { + assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (artifact.compilerOutput === undefined) { + throw new Error('Compiler output not found in the artifact file'); + } + const provider = providerUtils.standardizeOrThrow(supportedProvider); + const bytecode = artifact.compilerOutput.evm.bytecode.object; + const abi = artifact.compilerOutput.abi; + const logDecodeDependenciesAbiOnly: { [contractName: string]: ContractAbi } = {}; + if (Object.keys(logDecodeDependencies) !== undefined) { + for (const key of Object.keys(logDecodeDependencies)) { + logDecodeDependenciesAbiOnly[key] = logDecodeDependencies[key].compilerOutput.abi; } + } + return ExchangeContract.deployAsync(bytecode, abi, provider, txDefaults, logDecodeDependenciesAbiOnly, chainId); + } + public static async deployAsync( + bytecode: string, + abi: ContractAbi, + supportedProvider: SupportedProvider, + txDefaults: Partial, + logDecodeDependencies: { [contractName: string]: ContractAbi }, + chainId: BigNumber, + ): Promise { + assert.isHexString('bytecode', bytecode); + assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + const provider = providerUtils.standardizeOrThrow(supportedProvider); + const constructorAbi = BaseContract._lookupConstructorAbi(abi); + [chainId] = BaseContract._formatABIDataItemList( + constructorAbi.inputs, + [chainId], + BaseContract._bigNumberToString, + ); + const iface = new ethers.utils.Interface(abi); + const deployInfo = iface.deployFunction; + const txData = deployInfo.encode(bytecode, [chainId]); + const web3Wrapper = new Web3Wrapper(provider); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { data: txData }, + txDefaults, + web3Wrapper.estimateGasAsync.bind(web3Wrapper), + ); + const txHash = await web3Wrapper.sendTransactionAsync(txDataWithDefaults); + logUtils.log(`transactionHash: ${txHash}`); + const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash); + logUtils.log(`Exchange successfully deployed at ${txReceipt.contractAddress}`); + const contractInstance = new ExchangeContract( + txReceipt.contractAddress as string, + provider, + txDefaults, + logDecodeDependencies, + ); + contractInstance.constructorArgs = [chainId]; + return contractInstance; + } - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param leftOrders Set of orders with the same maker / taker asset. - * @param rightOrders Set of orders to match against `leftOrders` - * @param leftSignatures Proof that left orders were created by the left - * makers. - * @param rightSignatures Proof that right orders were created by the right - * makers. - * @returns batchMatchedFillResults Amounts filled and profit generated. - */ - async callAsync( - leftOrders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - rightOrders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - leftSignatures: string[], - rightSignatures: string[], - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise<{ - left: Array<{ - makerAssetFilledAmount: BigNumber; - takerAssetFilledAmount: BigNumber; - makerFeePaid: BigNumber; - takerFeePaid: BigNumber; - protocolFeePaid: BigNumber; - }>; - right: Array<{ - makerAssetFilledAmount: BigNumber; - takerAssetFilledAmount: BigNumber; - makerFeePaid: BigNumber; - takerFeePaid: BigNumber; - protocolFeePaid: BigNumber; - }>; - profitInLeftMakerAsset: BigNumber; - profitInRightMakerAsset: BigNumber; - }> { - assert.isArray('leftOrders', leftOrders); - assert.isArray('rightOrders', rightOrders); - assert.isArray('leftSignatures', leftSignatures); - assert.isArray('rightSignatures', rightSignatures); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments( - 'batchMatchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],bytes[],bytes[])', - [leftOrders, rightOrders, leftSignatures, rightSignatures], - ); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder( - 'batchMatchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],bytes[],bytes[])', - ); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue<{ - left: Array<{ - makerAssetFilledAmount: BigNumber; - takerAssetFilledAmount: BigNumber; - makerFeePaid: BigNumber; - takerFeePaid: BigNumber; - protocolFeePaid: BigNumber; - }>; - right: Array<{ - makerAssetFilledAmount: BigNumber; - takerAssetFilledAmount: BigNumber; - makerFeePaid: BigNumber; - takerFeePaid: BigNumber; - protocolFeePaid: BigNumber; - }>; - profitInLeftMakerAsset: BigNumber; - profitInRightMakerAsset: BigNumber; - }>(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param leftOrders Set of orders with the same maker / taker asset. - * @param rightOrders Set of orders to match against `leftOrders` - * @param leftSignatures Proof that left orders were created by the left - * makers. - * @param rightSignatures Proof that right orders were created by the right - * makers. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData( - leftOrders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - rightOrders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - leftSignatures: string[], - rightSignatures: string[], - ): string { - assert.isArray('leftOrders', leftOrders); - assert.isArray('rightOrders', rightOrders); - assert.isArray('leftSignatures', leftSignatures); - assert.isArray('rightSignatures', rightSignatures); - const self = (this as any) as ExchangeContract; - const abiEncodedTransactionData = self._strictEncodeArguments( - 'batchMatchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],bytes[],bytes[])', - [leftOrders, rightOrders, leftSignatures, rightSignatures], - ); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as ExchangeContract; - const abiEncoder = self._lookupAbiEncoder( - 'batchMatchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],bytes[],bytes[])', - ); - return abiEncoder.getSelector(); - }, - }; /** - * Match complementary orders that have a profitable spread. - * Each order is maximally filled at their respective price point, and - * the matcher receives a profit denominated in either the left maker asset, - * right maker asset, or a combination of both. - */ - public batchMatchOrdersWithMaximalFill = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param leftOrders Set of orders with the same maker / taker asset. - * @param rightOrders Set of orders to match against `leftOrders` - * @param leftSignatures Proof that left orders were created by the left - * makers. - * @param rightSignatures Proof that right orders were created by the right - * makers. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - leftOrders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - rightOrders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - leftSignatures: string[], - rightSignatures: string[], - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isArray('leftOrders', leftOrders); - assert.isArray('rightOrders', rightOrders); - assert.isArray('leftSignatures', leftSignatures); - assert.isArray('rightSignatures', rightSignatures); - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments( - 'batchMatchOrdersWithMaximalFill((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],bytes[],bytes[])', - [leftOrders, rightOrders, leftSignatures, rightSignatures], - ); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.batchMatchOrdersWithMaximalFill.callAsync( - leftOrders, - rightOrders, - leftSignatures, - rightSignatures, - txDataWithDefaults, - ); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param leftOrders Set of orders with the same maker / taker asset. - * @param rightOrders Set of orders to match against `leftOrders` - * @param leftSignatures Proof that left orders were created by the left - * makers. - * @param rightSignatures Proof that right orders were created by the right - * makers. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - leftOrders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - rightOrders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - leftSignatures: string[], - rightSignatures: string[], - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isArray('leftOrders', leftOrders); - assert.isArray('rightOrders', rightOrders); - assert.isArray('leftSignatures', leftSignatures); - assert.isArray('rightSignatures', rightSignatures); - const self = (this as any) as ExchangeContract; - const txHashPromise = self.batchMatchOrdersWithMaximalFill.sendTransactionAsync( - leftOrders, - rightOrders, - leftSignatures, - rightSignatures, - txData, - opts, - ); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param leftOrders Set of orders with the same maker / taker asset. - * @param rightOrders Set of orders to match against `leftOrders` - * @param leftSignatures Proof that left orders were created by the left - * makers. - * @param rightSignatures Proof that right orders were created by the right - * makers. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - leftOrders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - rightOrders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - leftSignatures: string[], - rightSignatures: string[], - txData?: Partial | undefined, - ): Promise { - assert.isArray('leftOrders', leftOrders); - assert.isArray('rightOrders', rightOrders); - assert.isArray('leftSignatures', leftSignatures); - assert.isArray('rightSignatures', rightSignatures); - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments( - 'batchMatchOrdersWithMaximalFill((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],bytes[],bytes[])', - [leftOrders, rightOrders, leftSignatures, rightSignatures], - ); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param leftOrders Set of orders with the same maker / taker asset. - * @param rightOrders Set of orders to match against `leftOrders` - * @param leftSignatures Proof that left orders were created by the left - * makers. - * @param rightSignatures Proof that right orders were created by the right - * makers. - * @returns batchMatchedFillResults Amounts filled and profit generated. - */ - async callAsync( - leftOrders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - rightOrders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - leftSignatures: string[], - rightSignatures: string[], - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise<{ - left: Array<{ - makerAssetFilledAmount: BigNumber; - takerAssetFilledAmount: BigNumber; - makerFeePaid: BigNumber; - takerFeePaid: BigNumber; - protocolFeePaid: BigNumber; - }>; - right: Array<{ - makerAssetFilledAmount: BigNumber; - takerAssetFilledAmount: BigNumber; - makerFeePaid: BigNumber; - takerFeePaid: BigNumber; - protocolFeePaid: BigNumber; - }>; - profitInLeftMakerAsset: BigNumber; - profitInRightMakerAsset: BigNumber; - }> { - assert.isArray('leftOrders', leftOrders); - assert.isArray('rightOrders', rightOrders); - assert.isArray('leftSignatures', leftSignatures); - assert.isArray('rightSignatures', rightSignatures); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments( - 'batchMatchOrdersWithMaximalFill((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],bytes[],bytes[])', - [leftOrders, rightOrders, leftSignatures, rightSignatures], - ); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder( - 'batchMatchOrdersWithMaximalFill((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],bytes[],bytes[])', - ); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue<{ - left: Array<{ - makerAssetFilledAmount: BigNumber; - takerAssetFilledAmount: BigNumber; - makerFeePaid: BigNumber; - takerFeePaid: BigNumber; - protocolFeePaid: BigNumber; - }>; - right: Array<{ - makerAssetFilledAmount: BigNumber; - takerAssetFilledAmount: BigNumber; - makerFeePaid: BigNumber; - takerFeePaid: BigNumber; - protocolFeePaid: BigNumber; - }>; - profitInLeftMakerAsset: BigNumber; - profitInRightMakerAsset: BigNumber; - }>(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param leftOrders Set of orders with the same maker / taker asset. - * @param rightOrders Set of orders to match against `leftOrders` - * @param leftSignatures Proof that left orders were created by the left - * makers. - * @param rightSignatures Proof that right orders were created by the right - * makers. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData( - leftOrders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - rightOrders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - leftSignatures: string[], - rightSignatures: string[], - ): string { - assert.isArray('leftOrders', leftOrders); - assert.isArray('rightOrders', rightOrders); - assert.isArray('leftSignatures', leftSignatures); - assert.isArray('rightSignatures', rightSignatures); - const self = (this as any) as ExchangeContract; - const abiEncodedTransactionData = self._strictEncodeArguments( - 'batchMatchOrdersWithMaximalFill((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],bytes[],bytes[])', - [leftOrders, rightOrders, leftSignatures, rightSignatures], - ); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as ExchangeContract; - const abiEncoder = self._lookupAbiEncoder( - 'batchMatchOrdersWithMaximalFill((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],bytes[],bytes[])', - ); - return abiEncoder.getSelector(); - }, - }; - /** - * After calling, the order can not be filled anymore. - */ - public cancelOrder = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param order Order struct containing order specifications. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - order: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments( - 'cancelOrder((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes))', - [order], - ); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.cancelOrder.callAsync(order, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param order Order struct containing order specifications. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - order: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - const self = (this as any) as ExchangeContract; - const txHashPromise = self.cancelOrder.sendTransactionAsync(order, txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param order Order struct containing order specifications. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - order: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }, - txData?: Partial | undefined, - ): Promise { - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments( - 'cancelOrder((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes))', - [order], - ); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param order Order struct containing order specifications. - */ - async callAsync( - order: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments( - 'cancelOrder((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes))', - [order], - ); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder( - 'cancelOrder((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes))', - ); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param order Order struct containing order specifications. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(order: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }): string { - const self = (this as any) as ExchangeContract; - const abiEncodedTransactionData = self._strictEncodeArguments( - 'cancelOrder((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes))', - [order], - ); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as ExchangeContract; - const abiEncoder = self._lookupAbiEncoder( - 'cancelOrder((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes))', - ); - return abiEncoder.getSelector(); - }, - }; - /** - * Cancels all orders created by makerAddress with a salt less than or equal to the targetOrderEpoch - * and senderAddress equal to msg.sender (or null address if msg.sender == makerAddress). - */ - public cancelOrdersUpTo = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param targetOrderEpoch Orders created with a salt less or equal to this - * value will be cancelled. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - targetOrderEpoch: BigNumber, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isBigNumber('targetOrderEpoch', targetOrderEpoch); - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments('cancelOrdersUpTo(uint256)', [targetOrderEpoch]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.cancelOrdersUpTo.callAsync(targetOrderEpoch, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param targetOrderEpoch Orders created with a salt less or equal to this - * value will be cancelled. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - targetOrderEpoch: BigNumber, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isBigNumber('targetOrderEpoch', targetOrderEpoch); - const self = (this as any) as ExchangeContract; - const txHashPromise = self.cancelOrdersUpTo.sendTransactionAsync(targetOrderEpoch, txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param targetOrderEpoch Orders created with a salt less or equal to this - * value will be cancelled. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync(targetOrderEpoch: BigNumber, txData?: Partial | undefined): Promise { - assert.isBigNumber('targetOrderEpoch', targetOrderEpoch); - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments('cancelOrdersUpTo(uint256)', [targetOrderEpoch]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param targetOrderEpoch Orders created with a salt less or equal to this - * value will be cancelled. - */ - async callAsync( - targetOrderEpoch: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isBigNumber('targetOrderEpoch', targetOrderEpoch); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments('cancelOrdersUpTo(uint256)', [targetOrderEpoch]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('cancelOrdersUpTo(uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param targetOrderEpoch Orders created with a salt less or equal to this - * value will be cancelled. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(targetOrderEpoch: BigNumber): string { - assert.isBigNumber('targetOrderEpoch', targetOrderEpoch); - const self = (this as any) as ExchangeContract; - const abiEncodedTransactionData = self._strictEncodeArguments('cancelOrdersUpTo(uint256)', [ - targetOrderEpoch, - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as ExchangeContract; - const abiEncoder = self._lookupAbiEncoder('cancelOrdersUpTo(uint256)'); - return abiEncoder.getSelector(); - }, - }; - public cancelled = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync( - index_0: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('index_0', index_0); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments('cancelled(bytes32)', [index_0]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('cancelled(bytes32)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public currentContextAddress = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments('currentContextAddress()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('currentContextAddress()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Executes an Exchange method call in the context of signer. - */ - public executeTransaction = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param transaction 0x transaction structure. - * @param signature Proof that transaction has been signed by signer. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - transaction: { - salt: BigNumber; - expirationTimeSeconds: BigNumber; - gasPrice: BigNumber; - signerAddress: string; - data: string; - }, - signature: string, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('signature', signature); - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments( - 'executeTransaction((uint256,uint256,uint256,address,bytes),bytes)', - [transaction, signature], - ); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.executeTransaction.callAsync(transaction, signature, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param transaction 0x transaction structure. - * @param signature Proof that transaction has been signed by signer. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - transaction: { - salt: BigNumber; - expirationTimeSeconds: BigNumber; - gasPrice: BigNumber; - signerAddress: string; - data: string; - }, - signature: string, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('signature', signature); - const self = (this as any) as ExchangeContract; - const txHashPromise = self.executeTransaction.sendTransactionAsync(transaction, signature, txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param transaction 0x transaction structure. - * @param signature Proof that transaction has been signed by signer. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - transaction: { - salt: BigNumber; - expirationTimeSeconds: BigNumber; - gasPrice: BigNumber; - signerAddress: string; - data: string; - }, - signature: string, - txData?: Partial | undefined, - ): Promise { - assert.isString('signature', signature); - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments( - 'executeTransaction((uint256,uint256,uint256,address,bytes),bytes)', - [transaction, signature], - ); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param transaction 0x transaction structure. - * @param signature Proof that transaction has been signed by signer. - * @returns ABI encoded return data of the underlying Exchange function call. - */ - async callAsync( - transaction: { - salt: BigNumber; - expirationTimeSeconds: BigNumber; - gasPrice: BigNumber; - signerAddress: string; - data: string; - }, - signature: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('signature', signature); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments( - 'executeTransaction((uint256,uint256,uint256,address,bytes),bytes)', - [transaction, signature], - ); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder( - 'executeTransaction((uint256,uint256,uint256,address,bytes),bytes)', - ); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param transaction 0x transaction structure. - * @param signature Proof that transaction has been signed by signer. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData( - transaction: { - salt: BigNumber; - expirationTimeSeconds: BigNumber; - gasPrice: BigNumber; - signerAddress: string; - data: string; - }, - signature: string, - ): string { - assert.isString('signature', signature); - const self = (this as any) as ExchangeContract; - const abiEncodedTransactionData = self._strictEncodeArguments( - 'executeTransaction((uint256,uint256,uint256,address,bytes),bytes)', - [transaction, signature], - ); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as ExchangeContract; - const abiEncoder = self._lookupAbiEncoder( - 'executeTransaction((uint256,uint256,uint256,address,bytes),bytes)', - ); - return abiEncoder.getSelector(); - }, - }; - /** - * Fills the input order. Reverts if exact takerAssetFillAmount not filled. - */ - public fillOrKillOrder = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param order Order struct containing order specifications. - * @param takerAssetFillAmount Desired amount of takerAsset to sell. - * @param signature Proof that order has been created by maker. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - order: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }, - takerAssetFillAmount: BigNumber, - signature: string, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isBigNumber('takerAssetFillAmount', takerAssetFillAmount); - assert.isString('signature', signature); - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments( - 'fillOrKillOrder((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),uint256,bytes)', - [order, takerAssetFillAmount, signature], - ); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.fillOrKillOrder.callAsync(order, takerAssetFillAmount, signature, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param order Order struct containing order specifications. - * @param takerAssetFillAmount Desired amount of takerAsset to sell. - * @param signature Proof that order has been created by maker. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - order: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }, - takerAssetFillAmount: BigNumber, - signature: string, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isBigNumber('takerAssetFillAmount', takerAssetFillAmount); - assert.isString('signature', signature); - const self = (this as any) as ExchangeContract; - const txHashPromise = self.fillOrKillOrder.sendTransactionAsync( - order, - takerAssetFillAmount, - signature, - txData, - opts, - ); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param order Order struct containing order specifications. - * @param takerAssetFillAmount Desired amount of takerAsset to sell. - * @param signature Proof that order has been created by maker. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - order: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }, - takerAssetFillAmount: BigNumber, - signature: string, - txData?: Partial | undefined, - ): Promise { - assert.isBigNumber('takerAssetFillAmount', takerAssetFillAmount); - assert.isString('signature', signature); - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments( - 'fillOrKillOrder((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),uint256,bytes)', - [order, takerAssetFillAmount, signature], - ); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param order Order struct containing order specifications. - * @param takerAssetFillAmount Desired amount of takerAsset to sell. - * @param signature Proof that order has been created by maker. - */ - async callAsync( - order: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }, - takerAssetFillAmount: BigNumber, - signature: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise<{ - makerAssetFilledAmount: BigNumber; - takerAssetFilledAmount: BigNumber; - makerFeePaid: BigNumber; - takerFeePaid: BigNumber; - protocolFeePaid: BigNumber; - }> { - assert.isBigNumber('takerAssetFillAmount', takerAssetFillAmount); - assert.isString('signature', signature); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments( - 'fillOrKillOrder((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),uint256,bytes)', - [order, takerAssetFillAmount, signature], - ); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder( - 'fillOrKillOrder((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),uint256,bytes)', - ); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue<{ - makerAssetFilledAmount: BigNumber; - takerAssetFilledAmount: BigNumber; - makerFeePaid: BigNumber; - takerFeePaid: BigNumber; - protocolFeePaid: BigNumber; - }>(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param order Order struct containing order specifications. - * @param takerAssetFillAmount Desired amount of takerAsset to sell. - * @param signature Proof that order has been created by maker. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData( - order: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }, - takerAssetFillAmount: BigNumber, - signature: string, - ): string { - assert.isBigNumber('takerAssetFillAmount', takerAssetFillAmount); - assert.isString('signature', signature); - const self = (this as any) as ExchangeContract; - const abiEncodedTransactionData = self._strictEncodeArguments( - 'fillOrKillOrder((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),uint256,bytes)', - [order, takerAssetFillAmount, signature], - ); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as ExchangeContract; - const abiEncoder = self._lookupAbiEncoder( - 'fillOrKillOrder((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),uint256,bytes)', - ); - return abiEncoder.getSelector(); - }, - }; - /** - * Fills the input order. - */ - public fillOrder = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param order Order struct containing order specifications. - * @param takerAssetFillAmount Desired amount of takerAsset to sell. - * @param signature Proof that order has been created by maker. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - order: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }, - takerAssetFillAmount: BigNumber, - signature: string, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isBigNumber('takerAssetFillAmount', takerAssetFillAmount); - assert.isString('signature', signature); - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments( - 'fillOrder((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),uint256,bytes)', - [order, takerAssetFillAmount, signature], - ); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.fillOrder.callAsync(order, takerAssetFillAmount, signature, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param order Order struct containing order specifications. - * @param takerAssetFillAmount Desired amount of takerAsset to sell. - * @param signature Proof that order has been created by maker. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - order: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }, - takerAssetFillAmount: BigNumber, - signature: string, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isBigNumber('takerAssetFillAmount', takerAssetFillAmount); - assert.isString('signature', signature); - const self = (this as any) as ExchangeContract; - const txHashPromise = self.fillOrder.sendTransactionAsync( - order, - takerAssetFillAmount, - signature, - txData, - opts, - ); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param order Order struct containing order specifications. - * @param takerAssetFillAmount Desired amount of takerAsset to sell. - * @param signature Proof that order has been created by maker. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - order: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }, - takerAssetFillAmount: BigNumber, - signature: string, - txData?: Partial | undefined, - ): Promise { - assert.isBigNumber('takerAssetFillAmount', takerAssetFillAmount); - assert.isString('signature', signature); - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments( - 'fillOrder((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),uint256,bytes)', - [order, takerAssetFillAmount, signature], - ); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param order Order struct containing order specifications. - * @param takerAssetFillAmount Desired amount of takerAsset to sell. - * @param signature Proof that order has been created by maker. - * @returns Amounts filled and fees paid by maker and taker. - */ - async callAsync( - order: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }, - takerAssetFillAmount: BigNumber, - signature: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise<{ - makerAssetFilledAmount: BigNumber; - takerAssetFilledAmount: BigNumber; - makerFeePaid: BigNumber; - takerFeePaid: BigNumber; - protocolFeePaid: BigNumber; - }> { - assert.isBigNumber('takerAssetFillAmount', takerAssetFillAmount); - assert.isString('signature', signature); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments( - 'fillOrder((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),uint256,bytes)', - [order, takerAssetFillAmount, signature], - ); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder( - 'fillOrder((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),uint256,bytes)', - ); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue<{ - makerAssetFilledAmount: BigNumber; - takerAssetFilledAmount: BigNumber; - makerFeePaid: BigNumber; - takerFeePaid: BigNumber; - protocolFeePaid: BigNumber; - }>(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param order Order struct containing order specifications. - * @param takerAssetFillAmount Desired amount of takerAsset to sell. - * @param signature Proof that order has been created by maker. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData( - order: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }, - takerAssetFillAmount: BigNumber, - signature: string, - ): string { - assert.isBigNumber('takerAssetFillAmount', takerAssetFillAmount); - assert.isString('signature', signature); - const self = (this as any) as ExchangeContract; - const abiEncodedTransactionData = self._strictEncodeArguments( - 'fillOrder((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),uint256,bytes)', - [order, takerAssetFillAmount, signature], - ); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as ExchangeContract; - const abiEncoder = self._lookupAbiEncoder( - 'fillOrder((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),uint256,bytes)', - ); - return abiEncoder.getSelector(); - }, - }; - public filled = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync( - index_0: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('index_0', index_0); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments('filled(bytes32)', [index_0]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('filled(bytes32)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Gets an asset proxy. - */ - public getAssetProxy = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param assetProxyId Id of the asset proxy. - * @returns The asset proxy registered to assetProxyId. Returns 0x0 if no proxy is registered. - */ - async callAsync( - assetProxyId: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('assetProxyId', assetProxyId); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments('getAssetProxy(bytes4)', [assetProxyId]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('getAssetProxy(bytes4)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Gets information about an order: status, hash, and amount filled. - */ - public getOrderInfo = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param order Order to gather information on. - * @returns OrderInfo Information about the order and its state. See LibOrder.OrderInfo for a complete description. - */ - async callAsync( - order: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise<{ orderStatus: number; orderHash: string; orderTakerAssetFilledAmount: BigNumber }> { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments( - 'getOrderInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes))', - [order], - ); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder( - 'getOrderInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes))', - ); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue<{ - orderStatus: number; - orderHash: string; - orderTakerAssetFilledAmount: BigNumber; - }>(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Verifies that a hash has been signed by the given signer. - */ - public isValidHashSignature = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param hash Any 32-byte hash. - * @param signerAddress Address that should have signed the given hash. - * @param signature Proof that the hash has been signed by signer. - * @returns isValid `true` if the signature is valid for the given hash and signer. - */ - async callAsync( - hash: string, - signerAddress: string, - signature: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('hash', hash); - assert.isString('signerAddress', signerAddress); - assert.isString('signature', signature); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments('isValidHashSignature(bytes32,address,bytes)', [ - hash, - signerAddress.toLowerCase(), - signature, - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('isValidHashSignature(bytes32,address,bytes)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Verifies that a signature for an order is valid. - */ - public isValidOrderSignature = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param order The order. - * @param signature Proof that the order has been signed by signer. - * @returns isValid `true` if the signature is valid for the given order and signer. - */ - async callAsync( - order: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }, - signature: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('signature', signature); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments( - 'isValidOrderSignature((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),bytes)', - [order, signature], - ); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder( - 'isValidOrderSignature((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),bytes)', - ); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Verifies that a signature for a transaction is valid. - */ - public isValidTransactionSignature = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param transaction The transaction. - * @param signature Proof that the order has been signed by signer. - * @returns isValid `true` if the signature is valid for the given transaction and signer. - */ - async callAsync( - transaction: { - salt: BigNumber; - expirationTimeSeconds: BigNumber; - gasPrice: BigNumber; - signerAddress: string; - data: string; - }, - signature: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('signature', signature); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments( - 'isValidTransactionSignature((uint256,uint256,uint256,address,bytes),bytes)', - [transaction, signature], - ); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder( - 'isValidTransactionSignature((uint256,uint256,uint256,address,bytes),bytes)', - ); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Calls marketBuyOrdersNoThrow then reverts if < makerAssetFillAmount has been bought. - * NOTE: This function does not enforce that the makerAsset is the same for each order. - */ - public marketBuyOrdersFillOrKill = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param orders Array of order specifications. - * @param makerAssetFillAmount Minimum amount of makerAsset to buy. - * @param signatures Proofs that orders have been signed by makers. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - makerAssetFillAmount: BigNumber, - signatures: string[], - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isArray('orders', orders); - assert.isBigNumber('makerAssetFillAmount', makerAssetFillAmount); - assert.isArray('signatures', signatures); - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments( - 'marketBuyOrdersFillOrKill((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256,bytes[])', - [orders, makerAssetFillAmount, signatures], - ); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.marketBuyOrdersFillOrKill.callAsync( - orders, - makerAssetFillAmount, - signatures, - txDataWithDefaults, - ); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param orders Array of order specifications. - * @param makerAssetFillAmount Minimum amount of makerAsset to buy. - * @param signatures Proofs that orders have been signed by makers. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - makerAssetFillAmount: BigNumber, - signatures: string[], - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isArray('orders', orders); - assert.isBigNumber('makerAssetFillAmount', makerAssetFillAmount); - assert.isArray('signatures', signatures); - const self = (this as any) as ExchangeContract; - const txHashPromise = self.marketBuyOrdersFillOrKill.sendTransactionAsync( - orders, - makerAssetFillAmount, - signatures, - txData, - opts, - ); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param orders Array of order specifications. - * @param makerAssetFillAmount Minimum amount of makerAsset to buy. - * @param signatures Proofs that orders have been signed by makers. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - makerAssetFillAmount: BigNumber, - signatures: string[], - txData?: Partial | undefined, - ): Promise { - assert.isArray('orders', orders); - assert.isBigNumber('makerAssetFillAmount', makerAssetFillAmount); - assert.isArray('signatures', signatures); - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments( - 'marketBuyOrdersFillOrKill((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256,bytes[])', - [orders, makerAssetFillAmount, signatures], - ); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param orders Array of order specifications. - * @param makerAssetFillAmount Minimum amount of makerAsset to buy. - * @param signatures Proofs that orders have been signed by makers. - * @returns Amounts filled and fees paid by makers and taker. - */ - async callAsync( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - makerAssetFillAmount: BigNumber, - signatures: string[], - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise<{ - makerAssetFilledAmount: BigNumber; - takerAssetFilledAmount: BigNumber; - makerFeePaid: BigNumber; - takerFeePaid: BigNumber; - protocolFeePaid: BigNumber; - }> { - assert.isArray('orders', orders); - assert.isBigNumber('makerAssetFillAmount', makerAssetFillAmount); - assert.isArray('signatures', signatures); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments( - 'marketBuyOrdersFillOrKill((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256,bytes[])', - [orders, makerAssetFillAmount, signatures], - ); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder( - 'marketBuyOrdersFillOrKill((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256,bytes[])', - ); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue<{ - makerAssetFilledAmount: BigNumber; - takerAssetFilledAmount: BigNumber; - makerFeePaid: BigNumber; - takerFeePaid: BigNumber; - protocolFeePaid: BigNumber; - }>(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param orders Array of order specifications. - * @param makerAssetFillAmount Minimum amount of makerAsset to buy. - * @param signatures Proofs that orders have been signed by makers. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - makerAssetFillAmount: BigNumber, - signatures: string[], - ): string { - assert.isArray('orders', orders); - assert.isBigNumber('makerAssetFillAmount', makerAssetFillAmount); - assert.isArray('signatures', signatures); - const self = (this as any) as ExchangeContract; - const abiEncodedTransactionData = self._strictEncodeArguments( - 'marketBuyOrdersFillOrKill((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256,bytes[])', - [orders, makerAssetFillAmount, signatures], - ); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as ExchangeContract; - const abiEncoder = self._lookupAbiEncoder( - 'marketBuyOrdersFillOrKill((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256,bytes[])', - ); - return abiEncoder.getSelector(); - }, - }; - /** - * Executes multiple calls of fillOrder until total amount of makerAsset is bought by taker. - * If any fill reverts, the error is caught and ignored. - * NOTE: This function does not enforce that the makerAsset is the same for each order. - */ - public marketBuyOrdersNoThrow = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param orders Array of order specifications. - * @param makerAssetFillAmount Desired amount of makerAsset to buy. - * @param signatures Proofs that orders have been signed by makers. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - makerAssetFillAmount: BigNumber, - signatures: string[], - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isArray('orders', orders); - assert.isBigNumber('makerAssetFillAmount', makerAssetFillAmount); - assert.isArray('signatures', signatures); - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments( - 'marketBuyOrdersNoThrow((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256,bytes[])', - [orders, makerAssetFillAmount, signatures], - ); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.marketBuyOrdersNoThrow.callAsync( - orders, - makerAssetFillAmount, - signatures, - txDataWithDefaults, - ); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param orders Array of order specifications. - * @param makerAssetFillAmount Desired amount of makerAsset to buy. - * @param signatures Proofs that orders have been signed by makers. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - makerAssetFillAmount: BigNumber, - signatures: string[], - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isArray('orders', orders); - assert.isBigNumber('makerAssetFillAmount', makerAssetFillAmount); - assert.isArray('signatures', signatures); - const self = (this as any) as ExchangeContract; - const txHashPromise = self.marketBuyOrdersNoThrow.sendTransactionAsync( - orders, - makerAssetFillAmount, - signatures, - txData, - opts, - ); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param orders Array of order specifications. - * @param makerAssetFillAmount Desired amount of makerAsset to buy. - * @param signatures Proofs that orders have been signed by makers. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - makerAssetFillAmount: BigNumber, - signatures: string[], - txData?: Partial | undefined, - ): Promise { - assert.isArray('orders', orders); - assert.isBigNumber('makerAssetFillAmount', makerAssetFillAmount); - assert.isArray('signatures', signatures); - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments( - 'marketBuyOrdersNoThrow((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256,bytes[])', - [orders, makerAssetFillAmount, signatures], - ); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param orders Array of order specifications. - * @param makerAssetFillAmount Desired amount of makerAsset to buy. - * @param signatures Proofs that orders have been signed by makers. - * @returns Amounts filled and fees paid by makers and taker. - */ - async callAsync( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - makerAssetFillAmount: BigNumber, - signatures: string[], - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise<{ - makerAssetFilledAmount: BigNumber; - takerAssetFilledAmount: BigNumber; - makerFeePaid: BigNumber; - takerFeePaid: BigNumber; - protocolFeePaid: BigNumber; - }> { - assert.isArray('orders', orders); - assert.isBigNumber('makerAssetFillAmount', makerAssetFillAmount); - assert.isArray('signatures', signatures); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments( - 'marketBuyOrdersNoThrow((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256,bytes[])', - [orders, makerAssetFillAmount, signatures], - ); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder( - 'marketBuyOrdersNoThrow((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256,bytes[])', - ); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue<{ - makerAssetFilledAmount: BigNumber; - takerAssetFilledAmount: BigNumber; - makerFeePaid: BigNumber; - takerFeePaid: BigNumber; - protocolFeePaid: BigNumber; - }>(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param orders Array of order specifications. - * @param makerAssetFillAmount Desired amount of makerAsset to buy. - * @param signatures Proofs that orders have been signed by makers. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - makerAssetFillAmount: BigNumber, - signatures: string[], - ): string { - assert.isArray('orders', orders); - assert.isBigNumber('makerAssetFillAmount', makerAssetFillAmount); - assert.isArray('signatures', signatures); - const self = (this as any) as ExchangeContract; - const abiEncodedTransactionData = self._strictEncodeArguments( - 'marketBuyOrdersNoThrow((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256,bytes[])', - [orders, makerAssetFillAmount, signatures], - ); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as ExchangeContract; - const abiEncoder = self._lookupAbiEncoder( - 'marketBuyOrdersNoThrow((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256,bytes[])', - ); - return abiEncoder.getSelector(); - }, - }; - /** - * Calls marketSellOrdersNoThrow then reverts if < takerAssetFillAmount has been sold. - * NOTE: This function does not enforce that the takerAsset is the same for each order. - */ - public marketSellOrdersFillOrKill = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param orders Array of order specifications. - * @param takerAssetFillAmount Minimum amount of takerAsset to sell. - * @param signatures Proofs that orders have been signed by makers. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - takerAssetFillAmount: BigNumber, - signatures: string[], - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isArray('orders', orders); - assert.isBigNumber('takerAssetFillAmount', takerAssetFillAmount); - assert.isArray('signatures', signatures); - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments( - 'marketSellOrdersFillOrKill((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256,bytes[])', - [orders, takerAssetFillAmount, signatures], - ); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.marketSellOrdersFillOrKill.callAsync( - orders, - takerAssetFillAmount, - signatures, - txDataWithDefaults, - ); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param orders Array of order specifications. - * @param takerAssetFillAmount Minimum amount of takerAsset to sell. - * @param signatures Proofs that orders have been signed by makers. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - takerAssetFillAmount: BigNumber, - signatures: string[], - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isArray('orders', orders); - assert.isBigNumber('takerAssetFillAmount', takerAssetFillAmount); - assert.isArray('signatures', signatures); - const self = (this as any) as ExchangeContract; - const txHashPromise = self.marketSellOrdersFillOrKill.sendTransactionAsync( - orders, - takerAssetFillAmount, - signatures, - txData, - opts, - ); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param orders Array of order specifications. - * @param takerAssetFillAmount Minimum amount of takerAsset to sell. - * @param signatures Proofs that orders have been signed by makers. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - takerAssetFillAmount: BigNumber, - signatures: string[], - txData?: Partial | undefined, - ): Promise { - assert.isArray('orders', orders); - assert.isBigNumber('takerAssetFillAmount', takerAssetFillAmount); - assert.isArray('signatures', signatures); - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments( - 'marketSellOrdersFillOrKill((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256,bytes[])', - [orders, takerAssetFillAmount, signatures], - ); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param orders Array of order specifications. - * @param takerAssetFillAmount Minimum amount of takerAsset to sell. - * @param signatures Proofs that orders have been signed by makers. - * @returns Amounts filled and fees paid by makers and taker. - */ - async callAsync( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - takerAssetFillAmount: BigNumber, - signatures: string[], - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise<{ - makerAssetFilledAmount: BigNumber; - takerAssetFilledAmount: BigNumber; - makerFeePaid: BigNumber; - takerFeePaid: BigNumber; - protocolFeePaid: BigNumber; - }> { - assert.isArray('orders', orders); - assert.isBigNumber('takerAssetFillAmount', takerAssetFillAmount); - assert.isArray('signatures', signatures); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments( - 'marketSellOrdersFillOrKill((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256,bytes[])', - [orders, takerAssetFillAmount, signatures], - ); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder( - 'marketSellOrdersFillOrKill((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256,bytes[])', - ); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue<{ - makerAssetFilledAmount: BigNumber; - takerAssetFilledAmount: BigNumber; - makerFeePaid: BigNumber; - takerFeePaid: BigNumber; - protocolFeePaid: BigNumber; - }>(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param orders Array of order specifications. - * @param takerAssetFillAmount Minimum amount of takerAsset to sell. - * @param signatures Proofs that orders have been signed by makers. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - takerAssetFillAmount: BigNumber, - signatures: string[], - ): string { - assert.isArray('orders', orders); - assert.isBigNumber('takerAssetFillAmount', takerAssetFillAmount); - assert.isArray('signatures', signatures); - const self = (this as any) as ExchangeContract; - const abiEncodedTransactionData = self._strictEncodeArguments( - 'marketSellOrdersFillOrKill((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256,bytes[])', - [orders, takerAssetFillAmount, signatures], - ); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as ExchangeContract; - const abiEncoder = self._lookupAbiEncoder( - 'marketSellOrdersFillOrKill((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256,bytes[])', - ); - return abiEncoder.getSelector(); - }, - }; - /** - * Executes multiple calls of fillOrder until total amount of takerAsset is sold by taker. - * If any fill reverts, the error is caught and ignored. - * NOTE: This function does not enforce that the takerAsset is the same for each order. - */ - public marketSellOrdersNoThrow = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param orders Array of order specifications. - * @param takerAssetFillAmount Desired amount of takerAsset to sell. - * @param signatures Proofs that orders have been signed by makers. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - takerAssetFillAmount: BigNumber, - signatures: string[], - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isArray('orders', orders); - assert.isBigNumber('takerAssetFillAmount', takerAssetFillAmount); - assert.isArray('signatures', signatures); - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments( - 'marketSellOrdersNoThrow((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256,bytes[])', - [orders, takerAssetFillAmount, signatures], - ); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.marketSellOrdersNoThrow.callAsync( - orders, - takerAssetFillAmount, - signatures, - txDataWithDefaults, - ); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param orders Array of order specifications. - * @param takerAssetFillAmount Desired amount of takerAsset to sell. - * @param signatures Proofs that orders have been signed by makers. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - takerAssetFillAmount: BigNumber, - signatures: string[], - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isArray('orders', orders); - assert.isBigNumber('takerAssetFillAmount', takerAssetFillAmount); - assert.isArray('signatures', signatures); - const self = (this as any) as ExchangeContract; - const txHashPromise = self.marketSellOrdersNoThrow.sendTransactionAsync( - orders, - takerAssetFillAmount, - signatures, - txData, - opts, - ); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param orders Array of order specifications. - * @param takerAssetFillAmount Desired amount of takerAsset to sell. - * @param signatures Proofs that orders have been signed by makers. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - takerAssetFillAmount: BigNumber, - signatures: string[], - txData?: Partial | undefined, - ): Promise { - assert.isArray('orders', orders); - assert.isBigNumber('takerAssetFillAmount', takerAssetFillAmount); - assert.isArray('signatures', signatures); - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments( - 'marketSellOrdersNoThrow((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256,bytes[])', - [orders, takerAssetFillAmount, signatures], - ); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param orders Array of order specifications. - * @param takerAssetFillAmount Desired amount of takerAsset to sell. - * @param signatures Proofs that orders have been signed by makers. - * @returns Amounts filled and fees paid by makers and taker. - */ - async callAsync( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - takerAssetFillAmount: BigNumber, - signatures: string[], - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise<{ - makerAssetFilledAmount: BigNumber; - takerAssetFilledAmount: BigNumber; - makerFeePaid: BigNumber; - takerFeePaid: BigNumber; - protocolFeePaid: BigNumber; - }> { - assert.isArray('orders', orders); - assert.isBigNumber('takerAssetFillAmount', takerAssetFillAmount); - assert.isArray('signatures', signatures); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments( - 'marketSellOrdersNoThrow((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256,bytes[])', - [orders, takerAssetFillAmount, signatures], - ); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder( - 'marketSellOrdersNoThrow((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256,bytes[])', - ); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue<{ - makerAssetFilledAmount: BigNumber; - takerAssetFilledAmount: BigNumber; - makerFeePaid: BigNumber; - takerFeePaid: BigNumber; - protocolFeePaid: BigNumber; - }>(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param orders Array of order specifications. - * @param takerAssetFillAmount Desired amount of takerAsset to sell. - * @param signatures Proofs that orders have been signed by makers. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - takerAssetFillAmount: BigNumber, - signatures: string[], - ): string { - assert.isArray('orders', orders); - assert.isBigNumber('takerAssetFillAmount', takerAssetFillAmount); - assert.isArray('signatures', signatures); - const self = (this as any) as ExchangeContract; - const abiEncodedTransactionData = self._strictEncodeArguments( - 'marketSellOrdersNoThrow((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256,bytes[])', - [orders, takerAssetFillAmount, signatures], - ); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as ExchangeContract; - const abiEncoder = self._lookupAbiEncoder( - 'marketSellOrdersNoThrow((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256,bytes[])', - ); - return abiEncoder.getSelector(); - }, - }; - /** - * Match two complementary orders that have a profitable spread. - * Each order is filled at their respective price point. However, the calculations are - * carried out as though the orders are both being filled at the right order's price point. - * The profit made by the left order goes to the taker (who matched the two orders). - */ - public matchOrders = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param leftOrder First order to match. - * @param rightOrder Second order to match. - * @param leftSignature Proof that order was created by the left maker. - * @param rightSignature Proof that order was created by the right maker. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - leftOrder: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }, - rightOrder: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }, - leftSignature: string, - rightSignature: string, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('leftSignature', leftSignature); - assert.isString('rightSignature', rightSignature); - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments( - 'matchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),bytes,bytes)', - [leftOrder, rightOrder, leftSignature, rightSignature], - ); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.matchOrders.callAsync( - leftOrder, - rightOrder, - leftSignature, - rightSignature, - txDataWithDefaults, - ); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param leftOrder First order to match. - * @param rightOrder Second order to match. - * @param leftSignature Proof that order was created by the left maker. - * @param rightSignature Proof that order was created by the right maker. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - leftOrder: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }, - rightOrder: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }, - leftSignature: string, - rightSignature: string, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('leftSignature', leftSignature); - assert.isString('rightSignature', rightSignature); - const self = (this as any) as ExchangeContract; - const txHashPromise = self.matchOrders.sendTransactionAsync( - leftOrder, - rightOrder, - leftSignature, - rightSignature, - txData, - opts, - ); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param leftOrder First order to match. - * @param rightOrder Second order to match. - * @param leftSignature Proof that order was created by the left maker. - * @param rightSignature Proof that order was created by the right maker. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - leftOrder: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }, - rightOrder: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }, - leftSignature: string, - rightSignature: string, - txData?: Partial | undefined, - ): Promise { - assert.isString('leftSignature', leftSignature); - assert.isString('rightSignature', rightSignature); - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments( - 'matchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),bytes,bytes)', - [leftOrder, rightOrder, leftSignature, rightSignature], - ); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param leftOrder First order to match. - * @param rightOrder Second order to match. - * @param leftSignature Proof that order was created by the left maker. - * @param rightSignature Proof that order was created by the right maker. - * @returns matchedFillResults Amounts filled and fees paid by maker and taker of matched orders. - */ - async callAsync( - leftOrder: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }, - rightOrder: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }, - leftSignature: string, - rightSignature: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise<{ - left: { - makerAssetFilledAmount: BigNumber; - takerAssetFilledAmount: BigNumber; - makerFeePaid: BigNumber; - takerFeePaid: BigNumber; - protocolFeePaid: BigNumber; - }; - right: { - makerAssetFilledAmount: BigNumber; - takerAssetFilledAmount: BigNumber; - makerFeePaid: BigNumber; - takerFeePaid: BigNumber; - protocolFeePaid: BigNumber; - }; - profitInLeftMakerAsset: BigNumber; - profitInRightMakerAsset: BigNumber; - }> { - assert.isString('leftSignature', leftSignature); - assert.isString('rightSignature', rightSignature); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments( - 'matchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),bytes,bytes)', - [leftOrder, rightOrder, leftSignature, rightSignature], - ); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder( - 'matchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),bytes,bytes)', - ); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue<{ - left: { - makerAssetFilledAmount: BigNumber; - takerAssetFilledAmount: BigNumber; - makerFeePaid: BigNumber; - takerFeePaid: BigNumber; - protocolFeePaid: BigNumber; - }; - right: { - makerAssetFilledAmount: BigNumber; - takerAssetFilledAmount: BigNumber; - makerFeePaid: BigNumber; - takerFeePaid: BigNumber; - protocolFeePaid: BigNumber; - }; - profitInLeftMakerAsset: BigNumber; - profitInRightMakerAsset: BigNumber; - }>(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param leftOrder First order to match. - * @param rightOrder Second order to match. - * @param leftSignature Proof that order was created by the left maker. - * @param rightSignature Proof that order was created by the right maker. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData( - leftOrder: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }, - rightOrder: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }, - leftSignature: string, - rightSignature: string, - ): string { - assert.isString('leftSignature', leftSignature); - assert.isString('rightSignature', rightSignature); - const self = (this as any) as ExchangeContract; - const abiEncodedTransactionData = self._strictEncodeArguments( - 'matchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),bytes,bytes)', - [leftOrder, rightOrder, leftSignature, rightSignature], - ); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as ExchangeContract; - const abiEncoder = self._lookupAbiEncoder( - 'matchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),bytes,bytes)', - ); - return abiEncoder.getSelector(); - }, - }; - /** - * Match two complementary orders that have a profitable spread. - * Each order is maximally filled at their respective price point, and - * the matcher receives a profit denominated in either the left maker asset, - * right maker asset, or a combination of both. - */ - public matchOrdersWithMaximalFill = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param leftOrder First order to match. - * @param rightOrder Second order to match. - * @param leftSignature Proof that order was created by the left maker. - * @param rightSignature Proof that order was created by the right maker. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - leftOrder: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }, - rightOrder: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }, - leftSignature: string, - rightSignature: string, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('leftSignature', leftSignature); - assert.isString('rightSignature', rightSignature); - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments( - 'matchOrdersWithMaximalFill((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),bytes,bytes)', - [leftOrder, rightOrder, leftSignature, rightSignature], - ); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.matchOrdersWithMaximalFill.callAsync( - leftOrder, - rightOrder, - leftSignature, - rightSignature, - txDataWithDefaults, - ); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param leftOrder First order to match. - * @param rightOrder Second order to match. - * @param leftSignature Proof that order was created by the left maker. - * @param rightSignature Proof that order was created by the right maker. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - leftOrder: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }, - rightOrder: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }, - leftSignature: string, - rightSignature: string, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('leftSignature', leftSignature); - assert.isString('rightSignature', rightSignature); - const self = (this as any) as ExchangeContract; - const txHashPromise = self.matchOrdersWithMaximalFill.sendTransactionAsync( - leftOrder, - rightOrder, - leftSignature, - rightSignature, - txData, - opts, - ); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param leftOrder First order to match. - * @param rightOrder Second order to match. - * @param leftSignature Proof that order was created by the left maker. - * @param rightSignature Proof that order was created by the right maker. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - leftOrder: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }, - rightOrder: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }, - leftSignature: string, - rightSignature: string, - txData?: Partial | undefined, - ): Promise { - assert.isString('leftSignature', leftSignature); - assert.isString('rightSignature', rightSignature); - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments( - 'matchOrdersWithMaximalFill((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),bytes,bytes)', - [leftOrder, rightOrder, leftSignature, rightSignature], - ); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param leftOrder First order to match. - * @param rightOrder Second order to match. - * @param leftSignature Proof that order was created by the left maker. - * @param rightSignature Proof that order was created by the right maker. - * @returns matchedFillResults Amounts filled by maker and taker of matched orders. - */ - async callAsync( - leftOrder: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }, - rightOrder: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }, - leftSignature: string, - rightSignature: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise<{ - left: { - makerAssetFilledAmount: BigNumber; - takerAssetFilledAmount: BigNumber; - makerFeePaid: BigNumber; - takerFeePaid: BigNumber; - protocolFeePaid: BigNumber; - }; - right: { - makerAssetFilledAmount: BigNumber; - takerAssetFilledAmount: BigNumber; - makerFeePaid: BigNumber; - takerFeePaid: BigNumber; - protocolFeePaid: BigNumber; - }; - profitInLeftMakerAsset: BigNumber; - profitInRightMakerAsset: BigNumber; - }> { - assert.isString('leftSignature', leftSignature); - assert.isString('rightSignature', rightSignature); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments( - 'matchOrdersWithMaximalFill((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),bytes,bytes)', - [leftOrder, rightOrder, leftSignature, rightSignature], - ); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder( - 'matchOrdersWithMaximalFill((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),bytes,bytes)', - ); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue<{ - left: { - makerAssetFilledAmount: BigNumber; - takerAssetFilledAmount: BigNumber; - makerFeePaid: BigNumber; - takerFeePaid: BigNumber; - protocolFeePaid: BigNumber; - }; - right: { - makerAssetFilledAmount: BigNumber; - takerAssetFilledAmount: BigNumber; - makerFeePaid: BigNumber; - takerFeePaid: BigNumber; - protocolFeePaid: BigNumber; - }; - profitInLeftMakerAsset: BigNumber; - profitInRightMakerAsset: BigNumber; - }>(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param leftOrder First order to match. - * @param rightOrder Second order to match. - * @param leftSignature Proof that order was created by the left maker. - * @param rightSignature Proof that order was created by the right maker. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData( - leftOrder: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }, - rightOrder: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }, - leftSignature: string, - rightSignature: string, - ): string { - assert.isString('leftSignature', leftSignature); - assert.isString('rightSignature', rightSignature); - const self = (this as any) as ExchangeContract; - const abiEncodedTransactionData = self._strictEncodeArguments( - 'matchOrdersWithMaximalFill((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),bytes,bytes)', - [leftOrder, rightOrder, leftSignature, rightSignature], - ); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as ExchangeContract; - const abiEncoder = self._lookupAbiEncoder( - 'matchOrdersWithMaximalFill((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),bytes,bytes)', - ); - return abiEncoder.getSelector(); - }, - }; - public orderEpoch = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync( - index_0: string, - index_1: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('index_0', index_0); - assert.isString('index_1', index_1); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments('orderEpoch(address,address)', [ - index_0.toLowerCase(), - index_1.toLowerCase(), - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('orderEpoch(address,address)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public owner = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments('owner()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('owner()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Approves a hash on-chain. - * After presigning a hash, the preSign signature type will become valid for that hash and signer. - */ - public preSign = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param hash Any 32-byte hash. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - hash: string, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('hash', hash); - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments('preSign(bytes32)', [hash]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.preSign.callAsync(hash, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param hash Any 32-byte hash. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - hash: string, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('hash', hash); - const self = (this as any) as ExchangeContract; - const txHashPromise = self.preSign.sendTransactionAsync(hash, txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param hash Any 32-byte hash. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync(hash: string, txData?: Partial | undefined): Promise { - assert.isString('hash', hash); - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments('preSign(bytes32)', [hash]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param hash Any 32-byte hash. - */ - async callAsync(hash: string, callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.isString('hash', hash); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments('preSign(bytes32)', [hash]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('preSign(bytes32)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param hash Any 32-byte hash. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(hash: string): string { - assert.isString('hash', hash); - const self = (this as any) as ExchangeContract; - const abiEncodedTransactionData = self._strictEncodeArguments('preSign(bytes32)', [hash]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as ExchangeContract; - const abiEncoder = self._lookupAbiEncoder('preSign(bytes32)'); - return abiEncoder.getSelector(); - }, - }; - public preSigned = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync( - index_0: string, - index_1: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('index_0', index_0); - assert.isString('index_1', index_1); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments('preSigned(bytes32,address)', [ - index_0, - index_1.toLowerCase(), - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('preSigned(bytes32,address)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public protocolFeeCollector = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments('protocolFeeCollector()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('protocolFeeCollector()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public protocolFeeMultiplier = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments('protocolFeeMultiplier()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('protocolFeeMultiplier()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Registers an asset proxy to its asset proxy id. - * Once an asset proxy is registered, it cannot be unregistered. - */ - public registerAssetProxy = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param assetProxy Address of new asset proxy to register. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - assetProxy: string, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('assetProxy', assetProxy); - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments('registerAssetProxy(address)', [assetProxy.toLowerCase()]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.registerAssetProxy.callAsync(assetProxy, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param assetProxy Address of new asset proxy to register. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - assetProxy: string, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('assetProxy', assetProxy); - const self = (this as any) as ExchangeContract; - const txHashPromise = self.registerAssetProxy.sendTransactionAsync(assetProxy.toLowerCase(), txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param assetProxy Address of new asset proxy to register. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync(assetProxy: string, txData?: Partial | undefined): Promise { - assert.isString('assetProxy', assetProxy); - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments('registerAssetProxy(address)', [assetProxy.toLowerCase()]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param assetProxy Address of new asset proxy to register. - */ - async callAsync( - assetProxy: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('assetProxy', assetProxy); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments('registerAssetProxy(address)', [assetProxy.toLowerCase()]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('registerAssetProxy(address)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param assetProxy Address of new asset proxy to register. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(assetProxy: string): string { - assert.isString('assetProxy', assetProxy); - const self = (this as any) as ExchangeContract; - const abiEncodedTransactionData = self._strictEncodeArguments('registerAssetProxy(address)', [ - assetProxy.toLowerCase(), - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as ExchangeContract; - const abiEncoder = self._lookupAbiEncoder('registerAssetProxy(address)'); - return abiEncoder.getSelector(); - }, - }; - /** - * Allows the owner to update the protocolFeeCollector address. - */ - public setProtocolFeeCollectorAddress = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param updatedProtocolFeeCollector The updated protocolFeeCollector contract - * address. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - updatedProtocolFeeCollector: string, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('updatedProtocolFeeCollector', updatedProtocolFeeCollector); - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments('setProtocolFeeCollectorAddress(address)', [ - updatedProtocolFeeCollector.toLowerCase(), - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.setProtocolFeeCollectorAddress.callAsync(updatedProtocolFeeCollector, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param updatedProtocolFeeCollector The updated protocolFeeCollector contract - * address. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - updatedProtocolFeeCollector: string, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('updatedProtocolFeeCollector', updatedProtocolFeeCollector); - const self = (this as any) as ExchangeContract; - const txHashPromise = self.setProtocolFeeCollectorAddress.sendTransactionAsync( - updatedProtocolFeeCollector.toLowerCase(), - txData, - opts, - ); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param updatedProtocolFeeCollector The updated protocolFeeCollector contract - * address. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - updatedProtocolFeeCollector: string, - txData?: Partial | undefined, - ): Promise { - assert.isString('updatedProtocolFeeCollector', updatedProtocolFeeCollector); - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments('setProtocolFeeCollectorAddress(address)', [ - updatedProtocolFeeCollector.toLowerCase(), - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param updatedProtocolFeeCollector The updated protocolFeeCollector contract - * address. - */ - async callAsync( - updatedProtocolFeeCollector: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('updatedProtocolFeeCollector', updatedProtocolFeeCollector); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments('setProtocolFeeCollectorAddress(address)', [ - updatedProtocolFeeCollector.toLowerCase(), - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('setProtocolFeeCollectorAddress(address)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param updatedProtocolFeeCollector The updated protocolFeeCollector contract - * address. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(updatedProtocolFeeCollector: string): string { - assert.isString('updatedProtocolFeeCollector', updatedProtocolFeeCollector); - const self = (this as any) as ExchangeContract; - const abiEncodedTransactionData = self._strictEncodeArguments('setProtocolFeeCollectorAddress(address)', [ - updatedProtocolFeeCollector.toLowerCase(), - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as ExchangeContract; - const abiEncoder = self._lookupAbiEncoder('setProtocolFeeCollectorAddress(address)'); - return abiEncoder.getSelector(); - }, - }; - /** - * Allows the owner to update the protocol fee multiplier. - */ - public setProtocolFeeMultiplier = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param updatedProtocolFeeMultiplier The updated protocol fee multiplier. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - updatedProtocolFeeMultiplier: BigNumber, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isBigNumber('updatedProtocolFeeMultiplier', updatedProtocolFeeMultiplier); - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments('setProtocolFeeMultiplier(uint256)', [ - updatedProtocolFeeMultiplier, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.setProtocolFeeMultiplier.callAsync(updatedProtocolFeeMultiplier, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param updatedProtocolFeeMultiplier The updated protocol fee multiplier. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - updatedProtocolFeeMultiplier: BigNumber, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isBigNumber('updatedProtocolFeeMultiplier', updatedProtocolFeeMultiplier); - const self = (this as any) as ExchangeContract; - const txHashPromise = self.setProtocolFeeMultiplier.sendTransactionAsync( - updatedProtocolFeeMultiplier, - txData, - opts, - ); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param updatedProtocolFeeMultiplier The updated protocol fee multiplier. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - updatedProtocolFeeMultiplier: BigNumber, - txData?: Partial | undefined, - ): Promise { - assert.isBigNumber('updatedProtocolFeeMultiplier', updatedProtocolFeeMultiplier); - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments('setProtocolFeeMultiplier(uint256)', [ - updatedProtocolFeeMultiplier, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param updatedProtocolFeeMultiplier The updated protocol fee multiplier. - */ - async callAsync( - updatedProtocolFeeMultiplier: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isBigNumber('updatedProtocolFeeMultiplier', updatedProtocolFeeMultiplier); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments('setProtocolFeeMultiplier(uint256)', [ - updatedProtocolFeeMultiplier, - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('setProtocolFeeMultiplier(uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param updatedProtocolFeeMultiplier The updated protocol fee multiplier. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(updatedProtocolFeeMultiplier: BigNumber): string { - assert.isBigNumber('updatedProtocolFeeMultiplier', updatedProtocolFeeMultiplier); - const self = (this as any) as ExchangeContract; - const abiEncodedTransactionData = self._strictEncodeArguments('setProtocolFeeMultiplier(uint256)', [ - updatedProtocolFeeMultiplier, - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as ExchangeContract; - const abiEncoder = self._lookupAbiEncoder('setProtocolFeeMultiplier(uint256)'); - return abiEncoder.getSelector(); - }, - }; - /** - * Approves/unnapproves a Validator contract to verify signatures on signer's behalf - * using the `Validator` signature type. - */ - public setSignatureValidatorApproval = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param validatorAddress Address of Validator contract. - * @param approval Approval or disapproval of Validator contract. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - validatorAddress: string, - approval: boolean, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('validatorAddress', validatorAddress); - assert.isBoolean('approval', approval); - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments('setSignatureValidatorApproval(address,bool)', [ - validatorAddress.toLowerCase(), - approval, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.setSignatureValidatorApproval.callAsync(validatorAddress, approval, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param validatorAddress Address of Validator contract. - * @param approval Approval or disapproval of Validator contract. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - validatorAddress: string, - approval: boolean, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('validatorAddress', validatorAddress); - assert.isBoolean('approval', approval); - const self = (this as any) as ExchangeContract; - const txHashPromise = self.setSignatureValidatorApproval.sendTransactionAsync( - validatorAddress.toLowerCase(), - approval, - txData, - opts, - ); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param validatorAddress Address of Validator contract. - * @param approval Approval or disapproval of Validator contract. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - validatorAddress: string, - approval: boolean, - txData?: Partial | undefined, - ): Promise { - assert.isString('validatorAddress', validatorAddress); - assert.isBoolean('approval', approval); - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments('setSignatureValidatorApproval(address,bool)', [ - validatorAddress.toLowerCase(), - approval, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param validatorAddress Address of Validator contract. - * @param approval Approval or disapproval of Validator contract. - */ - async callAsync( - validatorAddress: string, - approval: boolean, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('validatorAddress', validatorAddress); - assert.isBoolean('approval', approval); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments('setSignatureValidatorApproval(address,bool)', [ - validatorAddress.toLowerCase(), - approval, - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('setSignatureValidatorApproval(address,bool)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param validatorAddress Address of Validator contract. - * @param approval Approval or disapproval of Validator contract. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(validatorAddress: string, approval: boolean): string { - assert.isString('validatorAddress', validatorAddress); - assert.isBoolean('approval', approval); - const self = (this as any) as ExchangeContract; - const abiEncodedTransactionData = self._strictEncodeArguments( - 'setSignatureValidatorApproval(address,bool)', - [validatorAddress.toLowerCase(), approval], - ); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as ExchangeContract; - const abiEncoder = self._lookupAbiEncoder('setSignatureValidatorApproval(address,bool)'); - return abiEncoder.getSelector(); - }, - }; - /** - * This function may be used to simulate any amount of transfers As they would occur through the Exchange contract. Note that this function will always revert, even if all transfers are successful. However, it may be used with eth_call or with a try/catch pattern in order to simulate the results of the transfers. - */ - public simulateDispatchTransferFromCalls = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param assetData Array of asset details, each encoded per the AssetProxy - * contract specification. - * @param fromAddresses Array containing the `from` addresses that correspond - * with each transfer. - * @param toAddresses Array containing the `to` addresses that correspond with - * each transfer. - * @param amounts Array containing the amounts that correspond to each - * transfer. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - assetData: string[], - fromAddresses: string[], - toAddresses: string[], - amounts: BigNumber[], - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isArray('assetData', assetData); - assert.isArray('fromAddresses', fromAddresses); - assert.isArray('toAddresses', toAddresses); - assert.isArray('amounts', amounts); - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments( - 'simulateDispatchTransferFromCalls(bytes[],address[],address[],uint256[])', - [assetData, fromAddresses, toAddresses, amounts], - ); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.simulateDispatchTransferFromCalls.callAsync( - assetData, - fromAddresses, - toAddresses, - amounts, - txDataWithDefaults, - ); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param assetData Array of asset details, each encoded per the AssetProxy - * contract specification. - * @param fromAddresses Array containing the `from` addresses that correspond - * with each transfer. - * @param toAddresses Array containing the `to` addresses that correspond with - * each transfer. - * @param amounts Array containing the amounts that correspond to each - * transfer. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - assetData: string[], - fromAddresses: string[], - toAddresses: string[], - amounts: BigNumber[], - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isArray('assetData', assetData); - assert.isArray('fromAddresses', fromAddresses); - assert.isArray('toAddresses', toAddresses); - assert.isArray('amounts', amounts); - const self = (this as any) as ExchangeContract; - const txHashPromise = self.simulateDispatchTransferFromCalls.sendTransactionAsync( - assetData, - fromAddresses, - toAddresses, - amounts, - txData, - opts, - ); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param assetData Array of asset details, each encoded per the AssetProxy - * contract specification. - * @param fromAddresses Array containing the `from` addresses that correspond - * with each transfer. - * @param toAddresses Array containing the `to` addresses that correspond with - * each transfer. - * @param amounts Array containing the amounts that correspond to each - * transfer. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - assetData: string[], - fromAddresses: string[], - toAddresses: string[], - amounts: BigNumber[], - txData?: Partial | undefined, - ): Promise { - assert.isArray('assetData', assetData); - assert.isArray('fromAddresses', fromAddresses); - assert.isArray('toAddresses', toAddresses); - assert.isArray('amounts', amounts); - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments( - 'simulateDispatchTransferFromCalls(bytes[],address[],address[],uint256[])', - [assetData, fromAddresses, toAddresses, amounts], - ); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param assetData Array of asset details, each encoded per the AssetProxy - * contract specification. - * @param fromAddresses Array containing the `from` addresses that correspond - * with each transfer. - * @param toAddresses Array containing the `to` addresses that correspond with - * each transfer. - * @param amounts Array containing the amounts that correspond to each - * transfer. - * @returns This function does not return a value. However, it will always revert with `Error("TRANSFERS_SUCCESSFUL")` if all of the transfers were successful. - */ - async callAsync( - assetData: string[], - fromAddresses: string[], - toAddresses: string[], - amounts: BigNumber[], - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isArray('assetData', assetData); - assert.isArray('fromAddresses', fromAddresses); - assert.isArray('toAddresses', toAddresses); - assert.isArray('amounts', amounts); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments( - 'simulateDispatchTransferFromCalls(bytes[],address[],address[],uint256[])', - [assetData, fromAddresses, toAddresses, amounts], - ); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder( - 'simulateDispatchTransferFromCalls(bytes[],address[],address[],uint256[])', - ); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param assetData Array of asset details, each encoded per the AssetProxy - * contract specification. - * @param fromAddresses Array containing the `from` addresses that correspond - * with each transfer. - * @param toAddresses Array containing the `to` addresses that correspond with - * each transfer. - * @param amounts Array containing the amounts that correspond to each - * transfer. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData( - assetData: string[], - fromAddresses: string[], - toAddresses: string[], - amounts: BigNumber[], - ): string { - assert.isArray('assetData', assetData); - assert.isArray('fromAddresses', fromAddresses); - assert.isArray('toAddresses', toAddresses); - assert.isArray('amounts', amounts); - const self = (this as any) as ExchangeContract; - const abiEncodedTransactionData = self._strictEncodeArguments( - 'simulateDispatchTransferFromCalls(bytes[],address[],address[],uint256[])', - [assetData, fromAddresses, toAddresses, amounts], - ); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as ExchangeContract; - const abiEncoder = self._lookupAbiEncoder( - 'simulateDispatchTransferFromCalls(bytes[],address[],address[],uint256[])', - ); - return abiEncoder.getSelector(); - }, - }; - public transactionsExecuted = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync( - index_0: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('index_0', index_0); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments('transactionsExecuted(bytes32)', [index_0]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('transactionsExecuted(bytes32)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public transferOwnership = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - newOwner: string, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('newOwner', newOwner); - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.transferOwnership.callAsync(newOwner, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - newOwner: string, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('newOwner', newOwner); - const self = (this as any) as ExchangeContract; - const txHashPromise = self.transferOwnership.sendTransactionAsync(newOwner.toLowerCase(), txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync(newOwner: string, txData?: Partial | undefined): Promise { - assert.isString('newOwner', newOwner); - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(newOwner: string, callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.isString('newOwner', newOwner); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ExchangeContract; - const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('transferOwnership(address)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(newOwner: string): string { - assert.isString('newOwner', newOwner); - const self = (this as any) as ExchangeContract; - const abiEncodedTransactionData = self._strictEncodeArguments('transferOwnership(address)', [ - newOwner.toLowerCase(), - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as ExchangeContract; - const abiEncoder = self._lookupAbiEncoder('transferOwnership(address)'); - return abiEncoder.getSelector(); - }, - }; - private readonly _subscriptionManager: SubscriptionManager; - public static async deployFrom0xArtifactAsync( - artifact: ContractArtifact | SimpleContractArtifact, - supportedProvider: SupportedProvider, - txDefaults: Partial, - logDecodeDependencies: { [contractName: string]: ContractArtifact | SimpleContractArtifact }, - chainId: BigNumber, - ): Promise { - assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (artifact.compilerOutput === undefined) { - throw new Error('Compiler output not found in the artifact file'); - } - const provider = providerUtils.standardizeOrThrow(supportedProvider); - const bytecode = artifact.compilerOutput.evm.bytecode.object; - const abi = artifact.compilerOutput.abi; - const logDecodeDependenciesAbiOnly: { [contractName: string]: ContractAbi } = {}; - if (Object.keys(logDecodeDependencies) !== undefined) { - for (const key of Object.keys(logDecodeDependencies)) { - logDecodeDependenciesAbiOnly[key] = logDecodeDependencies[key].compilerOutput.abi; - } - } - return ExchangeContract.deployAsync(bytecode, abi, provider, txDefaults, logDecodeDependenciesAbiOnly, chainId); - } - public static async deployAsync( - bytecode: string, - abi: ContractAbi, - supportedProvider: SupportedProvider, - txDefaults: Partial, - logDecodeDependencies: { [contractName: string]: ContractAbi }, - chainId: BigNumber, - ): Promise { - assert.isHexString('bytecode', bytecode); - assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - const provider = providerUtils.standardizeOrThrow(supportedProvider); - const constructorAbi = BaseContract._lookupConstructorAbi(abi); - [chainId] = BaseContract._formatABIDataItemList( - constructorAbi.inputs, - [chainId], - BaseContract._bigNumberToString, - ); - const iface = new ethers.utils.Interface(abi); - const deployInfo = iface.deployFunction; - const txData = deployInfo.encode(bytecode, [chainId]); - const web3Wrapper = new Web3Wrapper(provider); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { data: txData }, - txDefaults, - web3Wrapper.estimateGasAsync.bind(web3Wrapper), - ); - const txHash = await web3Wrapper.sendTransactionAsync(txDataWithDefaults); - logUtils.log(`transactionHash: ${txHash}`); - const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash); - logUtils.log(`Exchange successfully deployed at ${txReceipt.contractAddress}`); - const contractInstance = new ExchangeContract( - txReceipt.contractAddress as string, - provider, - txDefaults, - logDecodeDependencies, - ); - contractInstance.constructorArgs = [chainId]; - return contractInstance; - } - - /** - * @returns The contract ABI + * @returns The contract ABI */ public static ABI(): ContractAbi { const abi = [ { inputs: [ { - name: 'chainId', + name: 'chainId', + type: 'uint256', + }, + ], + outputs: [], + payable: false, + stateMutability: 'nonpayable', + type: 'constructor', + }, + { + anonymous: false, + inputs: [ + { + name: 'id', + type: 'bytes4', + indexed: false, + }, + { + name: 'assetProxy', + type: 'address', + indexed: false, + }, + ], + name: 'AssetProxyRegistered', + outputs: [], + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + name: 'makerAddress', + type: 'address', + indexed: true, + }, + { + name: 'feeRecipientAddress', + type: 'address', + indexed: true, + }, + { + name: 'makerAssetData', + type: 'bytes', + indexed: false, + }, + { + name: 'takerAssetData', + type: 'bytes', + indexed: false, + }, + { + name: 'senderAddress', + type: 'address', + indexed: false, + }, + { + name: 'orderHash', + type: 'bytes32', + indexed: true, + }, + ], + name: 'Cancel', + outputs: [], + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + name: 'makerAddress', + type: 'address', + indexed: true, + }, + { + name: 'orderSenderAddress', + type: 'address', + indexed: true, + }, + { + name: 'orderEpoch', + type: 'uint256', + indexed: false, + }, + ], + name: 'CancelUpTo', + outputs: [], + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + name: 'makerAddress', + type: 'address', + indexed: true, + }, + { + name: 'feeRecipientAddress', + type: 'address', + indexed: true, + }, + { + name: 'makerAssetData', + type: 'bytes', + indexed: false, + }, + { + name: 'takerAssetData', + type: 'bytes', + indexed: false, + }, + { + name: 'makerFeeAssetData', + type: 'bytes', + indexed: false, + }, + { + name: 'takerFeeAssetData', + type: 'bytes', + indexed: false, + }, + { + name: 'orderHash', + type: 'bytes32', + indexed: true, + }, + { + name: 'takerAddress', + type: 'address', + indexed: false, + }, + { + name: 'senderAddress', + type: 'address', + indexed: false, + }, + { + name: 'makerAssetFilledAmount', + type: 'uint256', + indexed: false, + }, + { + name: 'takerAssetFilledAmount', + type: 'uint256', + indexed: false, + }, + { + name: 'makerFeePaid', + type: 'uint256', + indexed: false, + }, + { + name: 'takerFeePaid', + type: 'uint256', + indexed: false, + }, + { + name: 'protocolFeePaid', + type: 'uint256', + indexed: false, + }, + ], + name: 'Fill', + outputs: [], + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + name: 'oldProtocolFeeCollector', + type: 'address', + indexed: false, + }, + { + name: 'updatedProtocolFeeCollector', + type: 'address', + indexed: false, + }, + ], + name: 'ProtocolFeeCollectorAddress', + outputs: [], + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + name: 'oldProtocolFeeMultiplier', + type: 'uint256', + indexed: false, + }, + { + name: 'updatedProtocolFeeMultiplier', + type: 'uint256', + indexed: false, + }, + ], + name: 'ProtocolFeeMultiplier', + outputs: [], + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + name: 'signerAddress', + type: 'address', + indexed: true, + }, + { + name: 'validatorAddress', + type: 'address', + indexed: true, + }, + { + name: 'isApproved', + type: 'bool', + indexed: false, + }, + ], + name: 'SignatureValidatorApproval', + outputs: [], + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + name: 'transactionHash', + type: 'bytes32', + indexed: true, + }, + ], + name: 'TransactionExecution', + outputs: [], + type: 'event', + }, + { + constant: true, + inputs: [], + name: 'EIP1271_MAGIC_VALUE', + outputs: [ + { + name: '', + type: 'bytes4', + }, + ], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'EIP712_EXCHANGE_DOMAIN_HASH', + outputs: [ + { + name: '', + type: 'bytes32', + }, + ], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: true, + inputs: [ + { + name: 'index_0', + type: 'address', + }, + { + name: 'index_1', + type: 'address', + }, + ], + name: 'allowedValidators', + outputs: [ + { + name: '', + type: 'bool', + }, + ], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: false, + inputs: [ + { + name: 'orders', + type: 'tuple[]', + components: [ + { + name: 'makerAddress', + type: 'address', + }, + { + name: 'takerAddress', + type: 'address', + }, + { + name: 'feeRecipientAddress', + type: 'address', + }, + { + name: 'senderAddress', + type: 'address', + }, + { + name: 'makerAssetAmount', + type: 'uint256', + }, + { + name: 'takerAssetAmount', + type: 'uint256', + }, + { + name: 'makerFee', + type: 'uint256', + }, + { + name: 'takerFee', + type: 'uint256', + }, + { + name: 'expirationTimeSeconds', + type: 'uint256', + }, + { + name: 'salt', + type: 'uint256', + }, + { + name: 'makerAssetData', + type: 'bytes', + }, + { + name: 'takerAssetData', + type: 'bytes', + }, + { + name: 'makerFeeAssetData', + type: 'bytes', + }, + { + name: 'takerFeeAssetData', + type: 'bytes', + }, + ], + }, + ], + name: 'batchCancelOrders', + outputs: [], + payable: true, + stateMutability: 'payable', + type: 'function', + }, + { + constant: false, + inputs: [ + { + name: 'transactions', + type: 'tuple[]', + components: [ + { + name: 'salt', + type: 'uint256', + }, + { + name: 'expirationTimeSeconds', + type: 'uint256', + }, + { + name: 'gasPrice', + type: 'uint256', + }, + { + name: 'signerAddress', + type: 'address', + }, + { + name: 'data', + type: 'bytes', + }, + ], + }, + { + name: 'signatures', + type: 'bytes[]', + }, + ], + name: 'batchExecuteTransactions', + outputs: [ + { + name: '', + type: 'bytes[]', + }, + ], + payable: true, + stateMutability: 'payable', + type: 'function', + }, + { + constant: false, + inputs: [ + { + name: 'orders', + type: 'tuple[]', + components: [ + { + name: 'makerAddress', + type: 'address', + }, + { + name: 'takerAddress', + type: 'address', + }, + { + name: 'feeRecipientAddress', + type: 'address', + }, + { + name: 'senderAddress', + type: 'address', + }, + { + name: 'makerAssetAmount', + type: 'uint256', + }, + { + name: 'takerAssetAmount', + type: 'uint256', + }, + { + name: 'makerFee', + type: 'uint256', + }, + { + name: 'takerFee', + type: 'uint256', + }, + { + name: 'expirationTimeSeconds', + type: 'uint256', + }, + { + name: 'salt', + type: 'uint256', + }, + { + name: 'makerAssetData', + type: 'bytes', + }, + { + name: 'takerAssetData', + type: 'bytes', + }, + { + name: 'makerFeeAssetData', + type: 'bytes', + }, + { + name: 'takerFeeAssetData', + type: 'bytes', + }, + ], + }, + { + name: 'takerAssetFillAmounts', + type: 'uint256[]', + }, + { + name: 'signatures', + type: 'bytes[]', + }, + ], + name: 'batchFillOrKillOrders', + outputs: [ + { + name: 'fillResults', + type: 'tuple[]', + components: [ + { + name: 'makerAssetFilledAmount', + type: 'uint256', + }, + { + name: 'takerAssetFilledAmount', + type: 'uint256', + }, + { + name: 'makerFeePaid', + type: 'uint256', + }, + { + name: 'takerFeePaid', + type: 'uint256', + }, + { + name: 'protocolFeePaid', + type: 'uint256', + }, + ], + }, + ], + payable: true, + stateMutability: 'payable', + type: 'function', + }, + { + constant: false, + inputs: [ + { + name: 'orders', + type: 'tuple[]', + components: [ + { + name: 'makerAddress', + type: 'address', + }, + { + name: 'takerAddress', + type: 'address', + }, + { + name: 'feeRecipientAddress', + type: 'address', + }, + { + name: 'senderAddress', + type: 'address', + }, + { + name: 'makerAssetAmount', + type: 'uint256', + }, + { + name: 'takerAssetAmount', + type: 'uint256', + }, + { + name: 'makerFee', + type: 'uint256', + }, + { + name: 'takerFee', + type: 'uint256', + }, + { + name: 'expirationTimeSeconds', + type: 'uint256', + }, + { + name: 'salt', + type: 'uint256', + }, + { + name: 'makerAssetData', + type: 'bytes', + }, + { + name: 'takerAssetData', + type: 'bytes', + }, + { + name: 'makerFeeAssetData', + type: 'bytes', + }, + { + name: 'takerFeeAssetData', + type: 'bytes', + }, + ], + }, + { + name: 'takerAssetFillAmounts', + type: 'uint256[]', + }, + { + name: 'signatures', + type: 'bytes[]', + }, + ], + name: 'batchFillOrders', + outputs: [ + { + name: 'fillResults', + type: 'tuple[]', + components: [ + { + name: 'makerAssetFilledAmount', + type: 'uint256', + }, + { + name: 'takerAssetFilledAmount', + type: 'uint256', + }, + { + name: 'makerFeePaid', + type: 'uint256', + }, + { + name: 'takerFeePaid', + type: 'uint256', + }, + { + name: 'protocolFeePaid', + type: 'uint256', + }, + ], + }, + ], + payable: true, + stateMutability: 'payable', + type: 'function', + }, + { + constant: false, + inputs: [ + { + name: 'orders', + type: 'tuple[]', + components: [ + { + name: 'makerAddress', + type: 'address', + }, + { + name: 'takerAddress', + type: 'address', + }, + { + name: 'feeRecipientAddress', + type: 'address', + }, + { + name: 'senderAddress', + type: 'address', + }, + { + name: 'makerAssetAmount', + type: 'uint256', + }, + { + name: 'takerAssetAmount', + type: 'uint256', + }, + { + name: 'makerFee', + type: 'uint256', + }, + { + name: 'takerFee', + type: 'uint256', + }, + { + name: 'expirationTimeSeconds', + type: 'uint256', + }, + { + name: 'salt', + type: 'uint256', + }, + { + name: 'makerAssetData', + type: 'bytes', + }, + { + name: 'takerAssetData', + type: 'bytes', + }, + { + name: 'makerFeeAssetData', + type: 'bytes', + }, + { + name: 'takerFeeAssetData', + type: 'bytes', + }, + ], + }, + { + name: 'takerAssetFillAmounts', + type: 'uint256[]', + }, + { + name: 'signatures', + type: 'bytes[]', + }, + ], + name: 'batchFillOrdersNoThrow', + outputs: [ + { + name: 'fillResults', + type: 'tuple[]', + components: [ + { + name: 'makerAssetFilledAmount', + type: 'uint256', + }, + { + name: 'takerAssetFilledAmount', + type: 'uint256', + }, + { + name: 'makerFeePaid', + type: 'uint256', + }, + { + name: 'takerFeePaid', + type: 'uint256', + }, + { + name: 'protocolFeePaid', + type: 'uint256', + }, + ], + }, + ], + payable: true, + stateMutability: 'payable', + type: 'function', + }, + { + constant: false, + inputs: [ + { + name: 'leftOrders', + type: 'tuple[]', + components: [ + { + name: 'makerAddress', + type: 'address', + }, + { + name: 'takerAddress', + type: 'address', + }, + { + name: 'feeRecipientAddress', + type: 'address', + }, + { + name: 'senderAddress', + type: 'address', + }, + { + name: 'makerAssetAmount', + type: 'uint256', + }, + { + name: 'takerAssetAmount', + type: 'uint256', + }, + { + name: 'makerFee', + type: 'uint256', + }, + { + name: 'takerFee', + type: 'uint256', + }, + { + name: 'expirationTimeSeconds', + type: 'uint256', + }, + { + name: 'salt', + type: 'uint256', + }, + { + name: 'makerAssetData', + type: 'bytes', + }, + { + name: 'takerAssetData', + type: 'bytes', + }, + { + name: 'makerFeeAssetData', + type: 'bytes', + }, + { + name: 'takerFeeAssetData', + type: 'bytes', + }, + ], + }, + { + name: 'rightOrders', + type: 'tuple[]', + components: [ + { + name: 'makerAddress', + type: 'address', + }, + { + name: 'takerAddress', + type: 'address', + }, + { + name: 'feeRecipientAddress', + type: 'address', + }, + { + name: 'senderAddress', + type: 'address', + }, + { + name: 'makerAssetAmount', + type: 'uint256', + }, + { + name: 'takerAssetAmount', + type: 'uint256', + }, + { + name: 'makerFee', + type: 'uint256', + }, + { + name: 'takerFee', + type: 'uint256', + }, + { + name: 'expirationTimeSeconds', + type: 'uint256', + }, + { + name: 'salt', + type: 'uint256', + }, + { + name: 'makerAssetData', + type: 'bytes', + }, + { + name: 'takerAssetData', + type: 'bytes', + }, + { + name: 'makerFeeAssetData', + type: 'bytes', + }, + { + name: 'takerFeeAssetData', + type: 'bytes', + }, + ], + }, + { + name: 'leftSignatures', + type: 'bytes[]', + }, + { + name: 'rightSignatures', + type: 'bytes[]', + }, + ], + name: 'batchMatchOrders', + outputs: [ + { + name: 'batchMatchedFillResults', + type: 'tuple', + components: [ + { + name: 'left', + type: 'tuple[]', + components: [ + { + name: 'makerAssetFilledAmount', + type: 'uint256', + }, + { + name: 'takerAssetFilledAmount', + type: 'uint256', + }, + { + name: 'makerFeePaid', + type: 'uint256', + }, + { + name: 'takerFeePaid', + type: 'uint256', + }, + { + name: 'protocolFeePaid', + type: 'uint256', + }, + ], + }, + { + name: 'right', + type: 'tuple[]', + components: [ + { + name: 'makerAssetFilledAmount', + type: 'uint256', + }, + { + name: 'takerAssetFilledAmount', + type: 'uint256', + }, + { + name: 'makerFeePaid', + type: 'uint256', + }, + { + name: 'takerFeePaid', + type: 'uint256', + }, + { + name: 'protocolFeePaid', + type: 'uint256', + }, + ], + }, + { + name: 'profitInLeftMakerAsset', + type: 'uint256', + }, + { + name: 'profitInRightMakerAsset', + type: 'uint256', + }, + ], + }, + ], + payable: true, + stateMutability: 'payable', + type: 'function', + }, + { + constant: false, + inputs: [ + { + name: 'leftOrders', + type: 'tuple[]', + components: [ + { + name: 'makerAddress', + type: 'address', + }, + { + name: 'takerAddress', + type: 'address', + }, + { + name: 'feeRecipientAddress', + type: 'address', + }, + { + name: 'senderAddress', + type: 'address', + }, + { + name: 'makerAssetAmount', + type: 'uint256', + }, + { + name: 'takerAssetAmount', + type: 'uint256', + }, + { + name: 'makerFee', + type: 'uint256', + }, + { + name: 'takerFee', + type: 'uint256', + }, + { + name: 'expirationTimeSeconds', + type: 'uint256', + }, + { + name: 'salt', + type: 'uint256', + }, + { + name: 'makerAssetData', + type: 'bytes', + }, + { + name: 'takerAssetData', + type: 'bytes', + }, + { + name: 'makerFeeAssetData', + type: 'bytes', + }, + { + name: 'takerFeeAssetData', + type: 'bytes', + }, + ], + }, + { + name: 'rightOrders', + type: 'tuple[]', + components: [ + { + name: 'makerAddress', + type: 'address', + }, + { + name: 'takerAddress', + type: 'address', + }, + { + name: 'feeRecipientAddress', + type: 'address', + }, + { + name: 'senderAddress', + type: 'address', + }, + { + name: 'makerAssetAmount', + type: 'uint256', + }, + { + name: 'takerAssetAmount', + type: 'uint256', + }, + { + name: 'makerFee', + type: 'uint256', + }, + { + name: 'takerFee', + type: 'uint256', + }, + { + name: 'expirationTimeSeconds', + type: 'uint256', + }, + { + name: 'salt', + type: 'uint256', + }, + { + name: 'makerAssetData', + type: 'bytes', + }, + { + name: 'takerAssetData', + type: 'bytes', + }, + { + name: 'makerFeeAssetData', + type: 'bytes', + }, + { + name: 'takerFeeAssetData', + type: 'bytes', + }, + ], + }, + { + name: 'leftSignatures', + type: 'bytes[]', + }, + { + name: 'rightSignatures', + type: 'bytes[]', + }, + ], + name: 'batchMatchOrdersWithMaximalFill', + outputs: [ + { + name: 'batchMatchedFillResults', + type: 'tuple', + components: [ + { + name: 'left', + type: 'tuple[]', + components: [ + { + name: 'makerAssetFilledAmount', + type: 'uint256', + }, + { + name: 'takerAssetFilledAmount', + type: 'uint256', + }, + { + name: 'makerFeePaid', + type: 'uint256', + }, + { + name: 'takerFeePaid', + type: 'uint256', + }, + { + name: 'protocolFeePaid', + type: 'uint256', + }, + ], + }, + { + name: 'right', + type: 'tuple[]', + components: [ + { + name: 'makerAssetFilledAmount', + type: 'uint256', + }, + { + name: 'takerAssetFilledAmount', + type: 'uint256', + }, + { + name: 'makerFeePaid', + type: 'uint256', + }, + { + name: 'takerFeePaid', + type: 'uint256', + }, + { + name: 'protocolFeePaid', + type: 'uint256', + }, + ], + }, + { + name: 'profitInLeftMakerAsset', + type: 'uint256', + }, + { + name: 'profitInRightMakerAsset', + type: 'uint256', + }, + ], + }, + ], + payable: true, + stateMutability: 'payable', + type: 'function', + }, + { + constant: false, + inputs: [ + { + name: 'order', + type: 'tuple', + components: [ + { + name: 'makerAddress', + type: 'address', + }, + { + name: 'takerAddress', + type: 'address', + }, + { + name: 'feeRecipientAddress', + type: 'address', + }, + { + name: 'senderAddress', + type: 'address', + }, + { + name: 'makerAssetAmount', + type: 'uint256', + }, + { + name: 'takerAssetAmount', + type: 'uint256', + }, + { + name: 'makerFee', + type: 'uint256', + }, + { + name: 'takerFee', + type: 'uint256', + }, + { + name: 'expirationTimeSeconds', + type: 'uint256', + }, + { + name: 'salt', + type: 'uint256', + }, + { + name: 'makerAssetData', + type: 'bytes', + }, + { + name: 'takerAssetData', + type: 'bytes', + }, + { + name: 'makerFeeAssetData', + type: 'bytes', + }, + { + name: 'takerFeeAssetData', + type: 'bytes', + }, + ], + }, + ], + name: 'cancelOrder', + outputs: [], + payable: true, + stateMutability: 'payable', + type: 'function', + }, + { + constant: false, + inputs: [ + { + name: 'targetOrderEpoch', type: 'uint256', }, ], + name: 'cancelOrdersUpTo', outputs: [], - payable: false, - stateMutability: 'nonpayable', - type: 'constructor', + payable: true, + stateMutability: 'payable', + type: 'function', }, { - anonymous: false, + constant: true, inputs: [ { - name: 'id', - type: 'bytes4', - indexed: false, + name: 'index_0', + type: 'bytes32', }, + ], + name: 'cancelled', + outputs: [ { - name: 'assetProxy', + name: '', + type: 'bool', + }, + ], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'currentContextAddress', + outputs: [ + { + name: '', type: 'address', - indexed: false, }, ], - name: 'AssetProxyRegistered', - outputs: [], - type: 'event', + payable: false, + stateMutability: 'view', + type: 'function', }, { - anonymous: false, + constant: false, inputs: [ { - name: 'makerAddress', - type: 'address', - indexed: true, + name: 'transaction', + type: 'tuple', + components: [ + { + name: 'salt', + type: 'uint256', + }, + { + name: 'expirationTimeSeconds', + type: 'uint256', + }, + { + name: 'gasPrice', + type: 'uint256', + }, + { + name: 'signerAddress', + type: 'address', + }, + { + name: 'data', + type: 'bytes', + }, + ], }, { - name: 'feeRecipientAddress', - type: 'address', - indexed: true, + name: 'signature', + type: 'bytes', + }, + ], + name: 'executeTransaction', + outputs: [ + { + name: '', + type: 'bytes', + }, + ], + payable: true, + stateMutability: 'payable', + type: 'function', + }, + { + constant: false, + inputs: [ + { + name: 'order', + type: 'tuple', + components: [ + { + name: 'makerAddress', + type: 'address', + }, + { + name: 'takerAddress', + type: 'address', + }, + { + name: 'feeRecipientAddress', + type: 'address', + }, + { + name: 'senderAddress', + type: 'address', + }, + { + name: 'makerAssetAmount', + type: 'uint256', + }, + { + name: 'takerAssetAmount', + type: 'uint256', + }, + { + name: 'makerFee', + type: 'uint256', + }, + { + name: 'takerFee', + type: 'uint256', + }, + { + name: 'expirationTimeSeconds', + type: 'uint256', + }, + { + name: 'salt', + type: 'uint256', + }, + { + name: 'makerAssetData', + type: 'bytes', + }, + { + name: 'takerAssetData', + type: 'bytes', + }, + { + name: 'makerFeeAssetData', + type: 'bytes', + }, + { + name: 'takerFeeAssetData', + type: 'bytes', + }, + ], }, { - name: 'makerAssetData', - type: 'bytes', - indexed: false, + name: 'takerAssetFillAmount', + type: 'uint256', }, { - name: 'takerAssetData', + name: 'signature', type: 'bytes', - indexed: false, - }, - { - name: 'senderAddress', - type: 'address', - indexed: false, - }, - { - name: 'orderHash', - type: 'bytes32', - indexed: true, }, ], - name: 'Cancel', - outputs: [], - type: 'event', - }, - { - anonymous: false, - inputs: [ - { - name: 'makerAddress', - type: 'address', - indexed: true, - }, - { - name: 'orderSenderAddress', - type: 'address', - indexed: true, - }, + name: 'fillOrKillOrder', + outputs: [ { - name: 'orderEpoch', - type: 'uint256', - indexed: false, + name: 'fillResults', + type: 'tuple', + components: [ + { + name: 'makerAssetFilledAmount', + type: 'uint256', + }, + { + name: 'takerAssetFilledAmount', + type: 'uint256', + }, + { + name: 'makerFeePaid', + type: 'uint256', + }, + { + name: 'takerFeePaid', + type: 'uint256', + }, + { + name: 'protocolFeePaid', + type: 'uint256', + }, + ], }, ], - name: 'CancelUpTo', - outputs: [], - type: 'event', + payable: true, + stateMutability: 'payable', + type: 'function', }, { - anonymous: false, + constant: false, inputs: [ { - name: 'makerAddress', - type: 'address', - indexed: true, - }, - { - name: 'feeRecipientAddress', - type: 'address', - indexed: true, - }, - { - name: 'makerAssetData', - type: 'bytes', - indexed: false, + name: 'order', + type: 'tuple', + components: [ + { + name: 'makerAddress', + type: 'address', + }, + { + name: 'takerAddress', + type: 'address', + }, + { + name: 'feeRecipientAddress', + type: 'address', + }, + { + name: 'senderAddress', + type: 'address', + }, + { + name: 'makerAssetAmount', + type: 'uint256', + }, + { + name: 'takerAssetAmount', + type: 'uint256', + }, + { + name: 'makerFee', + type: 'uint256', + }, + { + name: 'takerFee', + type: 'uint256', + }, + { + name: 'expirationTimeSeconds', + type: 'uint256', + }, + { + name: 'salt', + type: 'uint256', + }, + { + name: 'makerAssetData', + type: 'bytes', + }, + { + name: 'takerAssetData', + type: 'bytes', + }, + { + name: 'makerFeeAssetData', + type: 'bytes', + }, + { + name: 'takerFeeAssetData', + type: 'bytes', + }, + ], }, { - name: 'takerAssetData', - type: 'bytes', - indexed: false, + name: 'takerAssetFillAmount', + type: 'uint256', }, { - name: 'makerFeeAssetData', + name: 'signature', type: 'bytes', - indexed: false, }, + ], + name: 'fillOrder', + outputs: [ { - name: 'takerFeeAssetData', - type: 'bytes', - indexed: false, + name: 'fillResults', + type: 'tuple', + components: [ + { + name: 'makerAssetFilledAmount', + type: 'uint256', + }, + { + name: 'takerAssetFilledAmount', + type: 'uint256', + }, + { + name: 'makerFeePaid', + type: 'uint256', + }, + { + name: 'takerFeePaid', + type: 'uint256', + }, + { + name: 'protocolFeePaid', + type: 'uint256', + }, + ], }, + ], + payable: true, + stateMutability: 'payable', + type: 'function', + }, + { + constant: true, + inputs: [ { - name: 'orderHash', + name: 'index_0', type: 'bytes32', - indexed: true, - }, - { - name: 'takerAddress', - type: 'address', - indexed: false, - }, - { - name: 'senderAddress', - type: 'address', - indexed: false, - }, - { - name: 'makerAssetFilledAmount', - type: 'uint256', - indexed: false, - }, - { - name: 'takerAssetFilledAmount', - type: 'uint256', - indexed: false, - }, - { - name: 'makerFeePaid', - type: 'uint256', - indexed: false, - }, - { - name: 'takerFeePaid', - type: 'uint256', - indexed: false, }, + ], + name: 'filled', + outputs: [ { - name: 'protocolFeePaid', + name: '', type: 'uint256', - indexed: false, }, ], - name: 'Fill', - outputs: [], - type: 'event', + payable: false, + stateMutability: 'view', + type: 'function', }, { - anonymous: false, - inputs: [ - { - name: 'oldProtocolFeeCollector', - type: 'address', - indexed: false, + constant: true, + inputs: [ + { + name: 'assetProxyId', + type: 'bytes4', }, + ], + name: 'getAssetProxy', + outputs: [ { - name: 'updatedProtocolFeeCollector', + name: '', type: 'address', - indexed: false, }, ], - name: 'ProtocolFeeCollectorAddress', - outputs: [], - type: 'event', + payable: false, + stateMutability: 'view', + type: 'function', }, { - anonymous: false, + constant: true, inputs: [ { - name: 'oldProtocolFeeMultiplier', - type: 'uint256', - indexed: false, + name: 'order', + type: 'tuple', + components: [ + { + name: 'makerAddress', + type: 'address', + }, + { + name: 'takerAddress', + type: 'address', + }, + { + name: 'feeRecipientAddress', + type: 'address', + }, + { + name: 'senderAddress', + type: 'address', + }, + { + name: 'makerAssetAmount', + type: 'uint256', + }, + { + name: 'takerAssetAmount', + type: 'uint256', + }, + { + name: 'makerFee', + type: 'uint256', + }, + { + name: 'takerFee', + type: 'uint256', + }, + { + name: 'expirationTimeSeconds', + type: 'uint256', + }, + { + name: 'salt', + type: 'uint256', + }, + { + name: 'makerAssetData', + type: 'bytes', + }, + { + name: 'takerAssetData', + type: 'bytes', + }, + { + name: 'makerFeeAssetData', + type: 'bytes', + }, + { + name: 'takerFeeAssetData', + type: 'bytes', + }, + ], }, + ], + name: 'getOrderInfo', + outputs: [ { - name: 'updatedProtocolFeeMultiplier', - type: 'uint256', - indexed: false, + name: 'orderInfo', + type: 'tuple', + components: [ + { + name: 'orderStatus', + type: 'uint8', + }, + { + name: 'orderHash', + type: 'bytes32', + }, + { + name: 'orderTakerAssetFilledAmount', + type: 'uint256', + }, + ], }, ], - name: 'ProtocolFeeMultiplier', - outputs: [], - type: 'event', + payable: false, + stateMutability: 'view', + type: 'function', }, { - anonymous: false, + constant: true, inputs: [ { - name: 'signerAddress', - type: 'address', - indexed: true, + name: 'hash', + type: 'bytes32', }, { - name: 'validatorAddress', + name: 'signerAddress', type: 'address', - indexed: true, - }, - { - name: 'isApproved', - type: 'bool', - indexed: false, }, - ], - name: 'SignatureValidatorApproval', - outputs: [], - type: 'event', - }, - { - anonymous: false, - inputs: [ { - name: 'transactionHash', - type: 'bytes32', - indexed: true, + name: 'signature', + type: 'bytes', }, ], - name: 'TransactionExecution', - outputs: [], - type: 'event', - }, - { - constant: true, - inputs: [], - name: 'EIP1271_MAGIC_VALUE', + name: 'isValidHashSignature', outputs: [ { - name: '', - type: 'bytes4', + name: 'isValid', + type: 'bool', }, ], payable: false, @@ -8260,12 +1881,79 @@ export class ExchangeContract extends BaseContract { }, { constant: true, - inputs: [], - name: 'EIP712_EXCHANGE_DOMAIN_HASH', + inputs: [ + { + name: 'order', + type: 'tuple', + components: [ + { + name: 'makerAddress', + type: 'address', + }, + { + name: 'takerAddress', + type: 'address', + }, + { + name: 'feeRecipientAddress', + type: 'address', + }, + { + name: 'senderAddress', + type: 'address', + }, + { + name: 'makerAssetAmount', + type: 'uint256', + }, + { + name: 'takerAssetAmount', + type: 'uint256', + }, + { + name: 'makerFee', + type: 'uint256', + }, + { + name: 'takerFee', + type: 'uint256', + }, + { + name: 'expirationTimeSeconds', + type: 'uint256', + }, + { + name: 'salt', + type: 'uint256', + }, + { + name: 'makerAssetData', + type: 'bytes', + }, + { + name: 'takerAssetData', + type: 'bytes', + }, + { + name: 'makerFeeAssetData', + type: 'bytes', + }, + { + name: 'takerFeeAssetData', + type: 'bytes', + }, + ], + }, + { + name: 'signature', + type: 'bytes', + }, + ], + name: 'isValidOrderSignature', outputs: [ { - name: '', - type: 'bytes32', + name: 'isValid', + type: 'bool', }, ], payable: false, @@ -8276,18 +1964,40 @@ export class ExchangeContract extends BaseContract { constant: true, inputs: [ { - name: 'index_0', - type: 'address', + name: 'transaction', + type: 'tuple', + components: [ + { + name: 'salt', + type: 'uint256', + }, + { + name: 'expirationTimeSeconds', + type: 'uint256', + }, + { + name: 'gasPrice', + type: 'uint256', + }, + { + name: 'signerAddress', + type: 'address', + }, + { + name: 'data', + type: 'bytes', + }, + ], }, { - name: 'index_1', - type: 'address', + name: 'signature', + type: 'bytes', }, ], - name: 'allowedValidators', + name: 'isValidTransactionSignature', outputs: [ { - name: '', + name: 'isValid', type: 'bool', }, ], @@ -8360,53 +2070,43 @@ export class ExchangeContract extends BaseContract { }, ], }, + { + name: 'makerAssetFillAmount', + type: 'uint256', + }, + { + name: 'signatures', + type: 'bytes[]', + }, ], - name: 'batchCancelOrders', - outputs: [], - payable: true, - stateMutability: 'payable', - type: 'function', - }, - { - constant: false, - inputs: [ + name: 'marketBuyOrdersFillOrKill', + outputs: [ { - name: 'transactions', - type: 'tuple[]', + name: 'fillResults', + type: 'tuple', components: [ { - name: 'salt', + name: 'makerAssetFilledAmount', type: 'uint256', }, { - name: 'expirationTimeSeconds', + name: 'takerAssetFilledAmount', type: 'uint256', }, { - name: 'gasPrice', + name: 'makerFeePaid', type: 'uint256', }, { - name: 'signerAddress', - type: 'address', + name: 'takerFeePaid', + type: 'uint256', }, { - name: 'data', - type: 'bytes', + name: 'protocolFeePaid', + type: 'uint256', }, ], }, - { - name: 'signatures', - type: 'bytes[]', - }, - ], - name: 'batchExecuteTransactions', - outputs: [ - { - name: '', - type: 'bytes[]', - }, ], payable: true, stateMutability: 'payable', @@ -8478,19 +2178,19 @@ export class ExchangeContract extends BaseContract { ], }, { - name: 'takerAssetFillAmounts', - type: 'uint256[]', + name: 'makerAssetFillAmount', + type: 'uint256', }, { name: 'signatures', type: 'bytes[]', }, ], - name: 'batchFillOrKillOrders', + name: 'marketBuyOrdersNoThrow', outputs: [ { name: 'fillResults', - type: 'tuple[]', + type: 'tuple', components: [ { name: 'makerAssetFilledAmount', @@ -8585,19 +2285,19 @@ export class ExchangeContract extends BaseContract { ], }, { - name: 'takerAssetFillAmounts', - type: 'uint256[]', + name: 'takerAssetFillAmount', + type: 'uint256', }, { name: 'signatures', type: 'bytes[]', }, ], - name: 'batchFillOrders', + name: 'marketSellOrdersFillOrKill', outputs: [ { name: 'fillResults', - type: 'tuple[]', + type: 'tuple', components: [ { name: 'makerAssetFilledAmount', @@ -8692,19 +2392,19 @@ export class ExchangeContract extends BaseContract { ], }, { - name: 'takerAssetFillAmounts', - type: 'uint256[]', + name: 'takerAssetFillAmount', + type: 'uint256', }, { name: 'signatures', type: 'bytes[]', }, ], - name: 'batchFillOrdersNoThrow', + name: 'marketSellOrdersNoThrow', outputs: [ { name: 'fillResults', - type: 'tuple[]', + type: 'tuple', components: [ { name: 'makerAssetFilledAmount', @@ -8737,8 +2437,8 @@ export class ExchangeContract extends BaseContract { constant: false, inputs: [ { - name: 'leftOrders', - type: 'tuple[]', + name: 'leftOrder', + type: 'tuple', components: [ { name: 'makerAddress', @@ -8799,8 +2499,8 @@ export class ExchangeContract extends BaseContract { ], }, { - name: 'rightOrders', - type: 'tuple[]', + name: 'rightOrder', + type: 'tuple', components: [ { name: 'makerAddress', @@ -8861,23 +2561,23 @@ export class ExchangeContract extends BaseContract { ], }, { - name: 'leftSignatures', - type: 'bytes[]', + name: 'leftSignature', + type: 'bytes', }, { - name: 'rightSignatures', - type: 'bytes[]', + name: 'rightSignature', + type: 'bytes', }, ], - name: 'batchMatchOrders', + name: 'matchOrders', outputs: [ { - name: 'batchMatchedFillResults', + name: 'matchedFillResults', type: 'tuple', components: [ { name: 'left', - type: 'tuple[]', + type: 'tuple', components: [ { name: 'makerAssetFilledAmount', @@ -8903,7 +2603,7 @@ export class ExchangeContract extends BaseContract { }, { name: 'right', - type: 'tuple[]', + type: 'tuple', components: [ { name: 'makerAssetFilledAmount', @@ -8946,8 +2646,8 @@ export class ExchangeContract extends BaseContract { constant: false, inputs: [ { - name: 'leftOrders', - type: 'tuple[]', + name: 'leftOrder', + type: 'tuple', components: [ { name: 'makerAddress', @@ -9008,8 +2708,8 @@ export class ExchangeContract extends BaseContract { ], }, { - name: 'rightOrders', - type: 'tuple[]', + name: 'rightOrder', + type: 'tuple', components: [ { name: 'makerAddress', @@ -9070,23 +2770,23 @@ export class ExchangeContract extends BaseContract { ], }, { - name: 'leftSignatures', - type: 'bytes[]', + name: 'leftSignature', + type: 'bytes', }, { - name: 'rightSignatures', - type: 'bytes[]', + name: 'rightSignature', + type: 'bytes', }, ], - name: 'batchMatchOrdersWithMaximalFill', + name: 'matchOrdersWithMaximalFill', outputs: [ { - name: 'batchMatchedFillResults', + name: 'matchedFillResults', type: 'tuple', components: [ { name: 'left', - type: 'tuple[]', + type: 'tuple', components: [ { name: 'makerAssetFilledAmount', @@ -9112,7 +2812,7 @@ export class ExchangeContract extends BaseContract { }, { name: 'right', - type: 'tuple[]', + type: 'tuple', components: [ { name: 'makerAssetFilledAmount', @@ -9147,77 +2847,167 @@ export class ExchangeContract extends BaseContract { ], }, ], - payable: true, - stateMutability: 'payable', + payable: true, + stateMutability: 'payable', + type: 'function', + }, + { + constant: true, + inputs: [ + { + name: 'index_0', + type: 'address', + }, + { + name: 'index_1', + type: 'address', + }, + ], + name: 'orderEpoch', + outputs: [ + { + name: '', + type: 'uint256', + }, + ], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'owner', + outputs: [ + { + name: '', + type: 'address', + }, + ], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: false, + inputs: [ + { + name: 'hash', + type: 'bytes32', + }, + ], + name: 'preSign', + outputs: [], + payable: true, + stateMutability: 'payable', + type: 'function', + }, + { + constant: true, + inputs: [ + { + name: 'index_0', + type: 'bytes32', + }, + { + name: 'index_1', + type: 'address', + }, + ], + name: 'preSigned', + outputs: [ + { + name: '', + type: 'bool', + }, + ], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'protocolFeeCollector', + outputs: [ + { + name: '', + type: 'address', + }, + ], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'protocolFeeMultiplier', + outputs: [ + { + name: '', + type: 'uint256', + }, + ], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: false, + inputs: [ + { + name: 'assetProxy', + type: 'address', + }, + ], + name: 'registerAssetProxy', + outputs: [], + payable: false, + stateMutability: 'nonpayable', + type: 'function', + }, + { + constant: false, + inputs: [ + { + name: 'updatedProtocolFeeCollector', + type: 'address', + }, + ], + name: 'setProtocolFeeCollectorAddress', + outputs: [], + payable: false, + stateMutability: 'nonpayable', + type: 'function', + }, + { + constant: false, + inputs: [ + { + name: 'updatedProtocolFeeMultiplier', + type: 'uint256', + }, + ], + name: 'setProtocolFeeMultiplier', + outputs: [], + payable: false, + stateMutability: 'nonpayable', type: 'function', }, { constant: false, inputs: [ { - name: 'order', - type: 'tuple', - components: [ - { - name: 'makerAddress', - type: 'address', - }, - { - name: 'takerAddress', - type: 'address', - }, - { - name: 'feeRecipientAddress', - type: 'address', - }, - { - name: 'senderAddress', - type: 'address', - }, - { - name: 'makerAssetAmount', - type: 'uint256', - }, - { - name: 'takerAssetAmount', - type: 'uint256', - }, - { - name: 'makerFee', - type: 'uint256', - }, - { - name: 'takerFee', - type: 'uint256', - }, - { - name: 'expirationTimeSeconds', - type: 'uint256', - }, - { - name: 'salt', - type: 'uint256', - }, - { - name: 'makerAssetData', - type: 'bytes', - }, - { - name: 'takerAssetData', - type: 'bytes', - }, - { - name: 'makerFeeAssetData', - type: 'bytes', - }, - { - name: 'takerFeeAssetData', - type: 'bytes', - }, - ], + name: 'validatorAddress', + type: 'address', + }, + { + name: 'approval', + type: 'bool', }, ], - name: 'cancelOrder', + name: 'setSignatureValidatorApproval', outputs: [], payable: true, stateMutability: 'payable', @@ -9227,14 +3017,26 @@ export class ExchangeContract extends BaseContract { constant: false, inputs: [ { - name: 'targetOrderEpoch', - type: 'uint256', + name: 'assetData', + type: 'bytes[]', + }, + { + name: 'fromAddresses', + type: 'address[]', + }, + { + name: 'toAddresses', + type: 'address[]', + }, + { + name: 'amounts', + type: 'uint256[]', }, ], - name: 'cancelOrdersUpTo', + name: 'simulateDispatchTransferFromCalls', outputs: [], - payable: true, - stateMutability: 'payable', + payable: false, + stateMutability: 'nonpayable', type: 'function', }, { @@ -9245,1642 +3047,4955 @@ export class ExchangeContract extends BaseContract { type: 'bytes32', }, ], - name: 'cancelled', + name: 'transactionsExecuted', outputs: [ { - name: '', - type: 'bool', + name: '', + type: 'bool', + }, + ], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: false, + inputs: [ + { + name: 'newOwner', + type: 'address', + }, + ], + name: 'transferOwnership', + outputs: [], + payable: false, + stateMutability: 'nonpayable', + type: 'function', + }, + ] as ContractAbi; + return abi; + } + + public getFunctionSignature(methodName: string): string { + const index = this._methodABIIndex[methodName]; + const methodAbi = ExchangeContract.ABI()[index] as MethodAbi; + const functionSignature = methodAbiToFunctionSignature(methodAbi); + return functionSignature; + } + public getABIDecodedTransactionData(methodName: string, callData: string): T { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as ExchangeContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + const abiDecodedCallData = abiEncoder.strictDecode(callData); + return abiDecodedCallData; + } + public getABIDecodedReturnData(methodName: string, callData: string): T { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as ExchangeContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + const abiDecodedCallData = abiEncoder.strictDecodeReturnValue(callData); + return abiDecodedCallData; + } + public getSelector(methodName: string): string { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as ExchangeContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + return abiEncoder.getSelector(); + } + + public EIP1271_MAGIC_VALUE(): ContractFunctionObj { + const self = (this as any) as ExchangeContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('EIP1271_MAGIC_VALUE()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('EIP1271_MAGIC_VALUE()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('EIP1271_MAGIC_VALUE()', []); + return abiEncodedTransactionData; + }, + }; + } + public EIP712_EXCHANGE_DOMAIN_HASH(): ContractFunctionObj { + const self = (this as any) as ExchangeContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('EIP712_EXCHANGE_DOMAIN_HASH()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('EIP712_EXCHANGE_DOMAIN_HASH()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('EIP712_EXCHANGE_DOMAIN_HASH()', []); + return abiEncodedTransactionData; + }, + }; + } + public allowedValidators(index_0: string, index_1: string): ContractFunctionObj { + const self = (this as any) as ExchangeContract; + assert.isString('index_0', index_0); + assert.isString('index_1', index_1); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('allowedValidators(address,address)', [ + index_0.toLowerCase(), + index_1.toLowerCase(), + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('allowedValidators(address,address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('allowedValidators(address,address)', [ + index_0.toLowerCase(), + index_1.toLowerCase(), + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Executes multiple calls of cancelOrder. + * @param orders Array of order specifications. + */ + public batchCancelOrders( + orders: Array<{ + makerAddress: string; + takerAddress: string; + feeRecipientAddress: string; + senderAddress: string; + makerAssetAmount: BigNumber; + takerAssetAmount: BigNumber; + makerFee: BigNumber; + takerFee: BigNumber; + expirationTimeSeconds: BigNumber; + salt: BigNumber; + makerAssetData: string; + takerAssetData: string; + makerFeeAssetData: string; + takerFeeAssetData: string; + }>, + ): ContractTxFunctionObj { + const self = (this as any) as ExchangeContract; + assert.isArray('orders', orders); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments( + 'batchCancelOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[])', + [orders], + ); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments( + 'batchCancelOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[])', + [orders], + ); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments( + 'batchCancelOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[])', + [orders], + ); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder( + 'batchCancelOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[])', + ); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'batchCancelOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[])', + [orders], + ); + return abiEncodedTransactionData; + }, + }; + } + /** + * Executes a batch of Exchange method calls in the context of signer(s). + * @param transactions Array of 0x transaction structures. + * @param signatures Array of proofs that transactions have been signed by + * signer(s). + * @returns Array containing ABI encoded return data for each of the underlying Exchange function calls. + */ + public batchExecuteTransactions( + transactions: Array<{ + salt: BigNumber; + expirationTimeSeconds: BigNumber; + gasPrice: BigNumber; + signerAddress: string; + data: string; + }>, + signatures: string[], + ): ContractTxFunctionObj { + const self = (this as any) as ExchangeContract; + assert.isArray('transactions', transactions); + assert.isArray('signatures', signatures); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments( + 'batchExecuteTransactions((uint256,uint256,uint256,address,bytes)[],bytes[])', + [transactions, signatures], + ); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments( + 'batchExecuteTransactions((uint256,uint256,uint256,address,bytes)[],bytes[])', + [transactions, signatures], + ); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments( + 'batchExecuteTransactions((uint256,uint256,uint256,address,bytes)[],bytes[])', + [transactions, signatures], + ); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder( + 'batchExecuteTransactions((uint256,uint256,uint256,address,bytes)[],bytes[])', + ); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'batchExecuteTransactions((uint256,uint256,uint256,address,bytes)[],bytes[])', + [transactions, signatures], + ); + return abiEncodedTransactionData; + }, + }; + } + /** + * Executes multiple calls of fillOrKillOrder. + * @param orders Array of order specifications. + * @param takerAssetFillAmounts Array of desired amounts of takerAsset to sell + * in orders. + * @param signatures Proofs that orders have been created by makers. + * @returns Array of amounts filled and fees paid by makers and taker. + */ + public batchFillOrKillOrders( + orders: Array<{ + makerAddress: string; + takerAddress: string; + feeRecipientAddress: string; + senderAddress: string; + makerAssetAmount: BigNumber; + takerAssetAmount: BigNumber; + makerFee: BigNumber; + takerFee: BigNumber; + expirationTimeSeconds: BigNumber; + salt: BigNumber; + makerAssetData: string; + takerAssetData: string; + makerFeeAssetData: string; + takerFeeAssetData: string; + }>, + takerAssetFillAmounts: BigNumber[], + signatures: string[], + ): ContractTxFunctionObj< + Array<{ + makerAssetFilledAmount: BigNumber; + takerAssetFilledAmount: BigNumber; + makerFeePaid: BigNumber; + takerFeePaid: BigNumber; + protocolFeePaid: BigNumber; + }> + > { + const self = (this as any) as ExchangeContract; + assert.isArray('orders', orders); + assert.isArray('takerAssetFillAmounts', takerAssetFillAmounts); + assert.isArray('signatures', signatures); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments( + 'batchFillOrKillOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256[],bytes[])', + [orders, takerAssetFillAmounts, signatures], + ); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, }, - ], - payable: false, - stateMutability: 'view', - type: 'function', + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; }, - { - constant: true, - inputs: [], - name: 'currentContextAddress', - outputs: [ - { - name: '', - type: 'address', - }, - ], - payable: false, - stateMutability: 'view', - type: 'function', + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); }, - { - constant: false, - inputs: [ - { - name: 'transaction', - type: 'tuple', - components: [ - { - name: 'salt', - type: 'uint256', - }, - { - name: 'expirationTimeSeconds', - type: 'uint256', - }, - { - name: 'gasPrice', - type: 'uint256', - }, - { - name: 'signerAddress', - type: 'address', - }, - { - name: 'data', - type: 'bytes', - }, - ], - }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments( + 'batchFillOrKillOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256[],bytes[])', + [orders, takerAssetFillAmounts, signatures], + ); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'signature', - type: 'bytes', + to: self.address, + ...txData, + data: encodedData, }, - ], - name: 'executeTransaction', - outputs: [ + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync( + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise< + Array<{ + makerAssetFilledAmount: BigNumber; + takerAssetFilledAmount: BigNumber; + makerFeePaid: BigNumber; + takerFeePaid: BigNumber; + protocolFeePaid: BigNumber; + }> + > { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments( + 'batchFillOrKillOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256[],bytes[])', + [orders, takerAssetFillAmounts, signatures], + ); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: '', - type: 'bytes', + to: self.address, + ...callData, + data: encodedData, }, - ], - payable: true, - stateMutability: 'payable', - type: 'function', + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder( + 'batchFillOrKillOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256[],bytes[])', + ); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue< + Array<{ + makerAssetFilledAmount: BigNumber; + takerAssetFilledAmount: BigNumber; + makerFeePaid: BigNumber; + takerFeePaid: BigNumber; + protocolFeePaid: BigNumber; + }> + >(rawCallResult); + // tslint:enable boolean-naming + return result; }, - { - constant: false, - inputs: [ + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'batchFillOrKillOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256[],bytes[])', + [orders, takerAssetFillAmounts, signatures], + ); + return abiEncodedTransactionData; + }, + }; + } + /** + * Executes multiple calls of fillOrder. + * @param orders Array of order specifications. + * @param takerAssetFillAmounts Array of desired amounts of takerAsset to sell + * in orders. + * @param signatures Proofs that orders have been created by makers. + * @returns Array of amounts filled and fees paid by makers and taker. + */ + public batchFillOrders( + orders: Array<{ + makerAddress: string; + takerAddress: string; + feeRecipientAddress: string; + senderAddress: string; + makerAssetAmount: BigNumber; + takerAssetAmount: BigNumber; + makerFee: BigNumber; + takerFee: BigNumber; + expirationTimeSeconds: BigNumber; + salt: BigNumber; + makerAssetData: string; + takerAssetData: string; + makerFeeAssetData: string; + takerFeeAssetData: string; + }>, + takerAssetFillAmounts: BigNumber[], + signatures: string[], + ): ContractTxFunctionObj< + Array<{ + makerAssetFilledAmount: BigNumber; + takerAssetFilledAmount: BigNumber; + makerFeePaid: BigNumber; + takerFeePaid: BigNumber; + protocolFeePaid: BigNumber; + }> + > { + const self = (this as any) as ExchangeContract; + assert.isArray('orders', orders); + assert.isArray('takerAssetFillAmounts', takerAssetFillAmounts); + assert.isArray('signatures', signatures); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments( + 'batchFillOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256[],bytes[])', + [orders, takerAssetFillAmounts, signatures], + ); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'order', - type: 'tuple', - components: [ - { - name: 'makerAddress', - type: 'address', - }, - { - name: 'takerAddress', - type: 'address', - }, - { - name: 'feeRecipientAddress', - type: 'address', - }, - { - name: 'senderAddress', - type: 'address', - }, - { - name: 'makerAssetAmount', - type: 'uint256', - }, - { - name: 'takerAssetAmount', - type: 'uint256', - }, - { - name: 'makerFee', - type: 'uint256', - }, - { - name: 'takerFee', - type: 'uint256', - }, - { - name: 'expirationTimeSeconds', - type: 'uint256', - }, - { - name: 'salt', - type: 'uint256', - }, - { - name: 'makerAssetData', - type: 'bytes', - }, - { - name: 'takerAssetData', - type: 'bytes', - }, - { - name: 'makerFeeAssetData', - type: 'bytes', - }, - { - name: 'takerFeeAssetData', - type: 'bytes', - }, - ], + to: self.address, + ...txData, + data: encodedData, }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments( + 'batchFillOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256[],bytes[])', + [orders, takerAssetFillAmounts, signatures], + ); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'takerAssetFillAmount', - type: 'uint256', + to: self.address, + ...txData, + data: encodedData, }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync( + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise< + Array<{ + makerAssetFilledAmount: BigNumber; + takerAssetFilledAmount: BigNumber; + makerFeePaid: BigNumber; + takerFeePaid: BigNumber; + protocolFeePaid: BigNumber; + }> + > { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments( + 'batchFillOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256[],bytes[])', + [orders, takerAssetFillAmounts, signatures], + ); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'signature', - type: 'bytes', + to: self.address, + ...callData, + data: encodedData, }, - ], - name: 'fillOrKillOrder', - outputs: [ - { - name: 'fillResults', - type: 'tuple', - components: [ - { - name: 'makerAssetFilledAmount', - type: 'uint256', - }, - { - name: 'takerAssetFilledAmount', - type: 'uint256', - }, - { - name: 'makerFeePaid', - type: 'uint256', - }, - { - name: 'takerFeePaid', - type: 'uint256', - }, - { - name: 'protocolFeePaid', - type: 'uint256', - }, - ], + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder( + 'batchFillOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256[],bytes[])', + ); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue< + Array<{ + makerAssetFilledAmount: BigNumber; + takerAssetFilledAmount: BigNumber; + makerFeePaid: BigNumber; + takerFeePaid: BigNumber; + protocolFeePaid: BigNumber; + }> + >(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'batchFillOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256[],bytes[])', + [orders, takerAssetFillAmounts, signatures], + ); + return abiEncodedTransactionData; + }, + }; + } + /** + * Executes multiple calls of fillOrder. If any fill reverts, the error is caught and ignored. + * @param orders Array of order specifications. + * @param takerAssetFillAmounts Array of desired amounts of takerAsset to sell + * in orders. + * @param signatures Proofs that orders have been created by makers. + * @returns Array of amounts filled and fees paid by makers and taker. + */ + public batchFillOrdersNoThrow( + orders: Array<{ + makerAddress: string; + takerAddress: string; + feeRecipientAddress: string; + senderAddress: string; + makerAssetAmount: BigNumber; + takerAssetAmount: BigNumber; + makerFee: BigNumber; + takerFee: BigNumber; + expirationTimeSeconds: BigNumber; + salt: BigNumber; + makerAssetData: string; + takerAssetData: string; + makerFeeAssetData: string; + takerFeeAssetData: string; + }>, + takerAssetFillAmounts: BigNumber[], + signatures: string[], + ): ContractTxFunctionObj< + Array<{ + makerAssetFilledAmount: BigNumber; + takerAssetFilledAmount: BigNumber; + makerFeePaid: BigNumber; + takerFeePaid: BigNumber; + protocolFeePaid: BigNumber; + }> + > { + const self = (this as any) as ExchangeContract; + assert.isArray('orders', orders); + assert.isArray('takerAssetFillAmounts', takerAssetFillAmounts); + assert.isArray('signatures', signatures); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments( + 'batchFillOrdersNoThrow((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256[],bytes[])', + [orders, takerAssetFillAmounts, signatures], + ); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, }, - ], - payable: true, - stateMutability: 'payable', - type: 'function', + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; }, - { - constant: false, - inputs: [ + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments( + 'batchFillOrdersNoThrow((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256[],bytes[])', + [orders, takerAssetFillAmounts, signatures], + ); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'order', - type: 'tuple', - components: [ - { - name: 'makerAddress', - type: 'address', - }, - { - name: 'takerAddress', - type: 'address', - }, - { - name: 'feeRecipientAddress', - type: 'address', - }, - { - name: 'senderAddress', - type: 'address', - }, - { - name: 'makerAssetAmount', - type: 'uint256', - }, - { - name: 'takerAssetAmount', - type: 'uint256', - }, - { - name: 'makerFee', - type: 'uint256', - }, - { - name: 'takerFee', - type: 'uint256', - }, - { - name: 'expirationTimeSeconds', - type: 'uint256', - }, - { - name: 'salt', - type: 'uint256', - }, - { - name: 'makerAssetData', - type: 'bytes', - }, - { - name: 'takerAssetData', - type: 'bytes', - }, - { - name: 'makerFeeAssetData', - type: 'bytes', - }, - { - name: 'takerFeeAssetData', - type: 'bytes', - }, - ], + to: self.address, + ...txData, + data: encodedData, }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync( + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise< + Array<{ + makerAssetFilledAmount: BigNumber; + takerAssetFilledAmount: BigNumber; + makerFeePaid: BigNumber; + takerFeePaid: BigNumber; + protocolFeePaid: BigNumber; + }> + > { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments( + 'batchFillOrdersNoThrow((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256[],bytes[])', + [orders, takerAssetFillAmounts, signatures], + ); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'takerAssetFillAmount', - type: 'uint256', + to: self.address, + ...callData, + data: encodedData, }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder( + 'batchFillOrdersNoThrow((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256[],bytes[])', + ); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue< + Array<{ + makerAssetFilledAmount: BigNumber; + takerAssetFilledAmount: BigNumber; + makerFeePaid: BigNumber; + takerFeePaid: BigNumber; + protocolFeePaid: BigNumber; + }> + >(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'batchFillOrdersNoThrow((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256[],bytes[])', + [orders, takerAssetFillAmounts, signatures], + ); + return abiEncodedTransactionData; + }, + }; + } + /** + * Match complementary orders that have a profitable spread. + * Each order is filled at their respective price point, and + * the matcher receives a profit denominated in the left maker asset. + * @param leftOrders Set of orders with the same maker / taker asset. + * @param rightOrders Set of orders to match against `leftOrders` + * @param leftSignatures Proof that left orders were created by the left + * makers. + * @param rightSignatures Proof that right orders were created by the right + * makers. + * @returns batchMatchedFillResults Amounts filled and profit generated. + */ + public batchMatchOrders( + leftOrders: Array<{ + makerAddress: string; + takerAddress: string; + feeRecipientAddress: string; + senderAddress: string; + makerAssetAmount: BigNumber; + takerAssetAmount: BigNumber; + makerFee: BigNumber; + takerFee: BigNumber; + expirationTimeSeconds: BigNumber; + salt: BigNumber; + makerAssetData: string; + takerAssetData: string; + makerFeeAssetData: string; + takerFeeAssetData: string; + }>, + rightOrders: Array<{ + makerAddress: string; + takerAddress: string; + feeRecipientAddress: string; + senderAddress: string; + makerAssetAmount: BigNumber; + takerAssetAmount: BigNumber; + makerFee: BigNumber; + takerFee: BigNumber; + expirationTimeSeconds: BigNumber; + salt: BigNumber; + makerAssetData: string; + takerAssetData: string; + makerFeeAssetData: string; + takerFeeAssetData: string; + }>, + leftSignatures: string[], + rightSignatures: string[], + ): ContractTxFunctionObj<{ + left: Array<{ + makerAssetFilledAmount: BigNumber; + takerAssetFilledAmount: BigNumber; + makerFeePaid: BigNumber; + takerFeePaid: BigNumber; + protocolFeePaid: BigNumber; + }>; + right: Array<{ + makerAssetFilledAmount: BigNumber; + takerAssetFilledAmount: BigNumber; + makerFeePaid: BigNumber; + takerFeePaid: BigNumber; + protocolFeePaid: BigNumber; + }>; + profitInLeftMakerAsset: BigNumber; + profitInRightMakerAsset: BigNumber; + }> { + const self = (this as any) as ExchangeContract; + assert.isArray('leftOrders', leftOrders); + assert.isArray('rightOrders', rightOrders); + assert.isArray('leftSignatures', leftSignatures); + assert.isArray('rightSignatures', rightSignatures); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments( + 'batchMatchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],bytes[],bytes[])', + [leftOrders, rightOrders, leftSignatures, rightSignatures], + ); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'signature', - type: 'bytes', + to: self.address, + ...txData, + data: encodedData, }, - ], - name: 'fillOrder', - outputs: [ + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments( + 'batchMatchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],bytes[],bytes[])', + [leftOrders, rightOrders, leftSignatures, rightSignatures], + ); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'fillResults', - type: 'tuple', - components: [ - { - name: 'makerAssetFilledAmount', - type: 'uint256', - }, - { - name: 'takerAssetFilledAmount', - type: 'uint256', - }, - { - name: 'makerFeePaid', - type: 'uint256', - }, - { - name: 'takerFeePaid', - type: 'uint256', - }, - { - name: 'protocolFeePaid', - type: 'uint256', - }, - ], + to: self.address, + ...txData, + data: encodedData, }, - ], - payable: true, - stateMutability: 'payable', - type: 'function', + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; }, - { - constant: true, - inputs: [ + async callAsync( + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise<{ + left: Array<{ + makerAssetFilledAmount: BigNumber; + takerAssetFilledAmount: BigNumber; + makerFeePaid: BigNumber; + takerFeePaid: BigNumber; + protocolFeePaid: BigNumber; + }>; + right: Array<{ + makerAssetFilledAmount: BigNumber; + takerAssetFilledAmount: BigNumber; + makerFeePaid: BigNumber; + takerFeePaid: BigNumber; + protocolFeePaid: BigNumber; + }>; + profitInLeftMakerAsset: BigNumber; + profitInRightMakerAsset: BigNumber; + }> { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments( + 'batchMatchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],bytes[],bytes[])', + [leftOrders, rightOrders, leftSignatures, rightSignatures], + ); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'index_0', - type: 'bytes32', + to: self.address, + ...callData, + data: encodedData, }, - ], - name: 'filled', - outputs: [ + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder( + 'batchMatchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],bytes[],bytes[])', + ); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<{ + left: Array<{ + makerAssetFilledAmount: BigNumber; + takerAssetFilledAmount: BigNumber; + makerFeePaid: BigNumber; + takerFeePaid: BigNumber; + protocolFeePaid: BigNumber; + }>; + right: Array<{ + makerAssetFilledAmount: BigNumber; + takerAssetFilledAmount: BigNumber; + makerFeePaid: BigNumber; + takerFeePaid: BigNumber; + protocolFeePaid: BigNumber; + }>; + profitInLeftMakerAsset: BigNumber; + profitInRightMakerAsset: BigNumber; + }>(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'batchMatchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],bytes[],bytes[])', + [leftOrders, rightOrders, leftSignatures, rightSignatures], + ); + return abiEncodedTransactionData; + }, + }; + } + /** + * Match complementary orders that have a profitable spread. + * Each order is maximally filled at their respective price point, and + * the matcher receives a profit denominated in either the left maker asset, + * right maker asset, or a combination of both. + * @param leftOrders Set of orders with the same maker / taker asset. + * @param rightOrders Set of orders to match against `leftOrders` + * @param leftSignatures Proof that left orders were created by the left + * makers. + * @param rightSignatures Proof that right orders were created by the right + * makers. + * @returns batchMatchedFillResults Amounts filled and profit generated. + */ + public batchMatchOrdersWithMaximalFill( + leftOrders: Array<{ + makerAddress: string; + takerAddress: string; + feeRecipientAddress: string; + senderAddress: string; + makerAssetAmount: BigNumber; + takerAssetAmount: BigNumber; + makerFee: BigNumber; + takerFee: BigNumber; + expirationTimeSeconds: BigNumber; + salt: BigNumber; + makerAssetData: string; + takerAssetData: string; + makerFeeAssetData: string; + takerFeeAssetData: string; + }>, + rightOrders: Array<{ + makerAddress: string; + takerAddress: string; + feeRecipientAddress: string; + senderAddress: string; + makerAssetAmount: BigNumber; + takerAssetAmount: BigNumber; + makerFee: BigNumber; + takerFee: BigNumber; + expirationTimeSeconds: BigNumber; + salt: BigNumber; + makerAssetData: string; + takerAssetData: string; + makerFeeAssetData: string; + takerFeeAssetData: string; + }>, + leftSignatures: string[], + rightSignatures: string[], + ): ContractTxFunctionObj<{ + left: Array<{ + makerAssetFilledAmount: BigNumber; + takerAssetFilledAmount: BigNumber; + makerFeePaid: BigNumber; + takerFeePaid: BigNumber; + protocolFeePaid: BigNumber; + }>; + right: Array<{ + makerAssetFilledAmount: BigNumber; + takerAssetFilledAmount: BigNumber; + makerFeePaid: BigNumber; + takerFeePaid: BigNumber; + protocolFeePaid: BigNumber; + }>; + profitInLeftMakerAsset: BigNumber; + profitInRightMakerAsset: BigNumber; + }> { + const self = (this as any) as ExchangeContract; + assert.isArray('leftOrders', leftOrders); + assert.isArray('rightOrders', rightOrders); + assert.isArray('leftSignatures', leftSignatures); + assert.isArray('rightSignatures', rightSignatures); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments( + 'batchMatchOrdersWithMaximalFill((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],bytes[],bytes[])', + [leftOrders, rightOrders, leftSignatures, rightSignatures], + ); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: '', - type: 'uint256', + to: self.address, + ...txData, + data: encodedData, }, - ], - payable: false, - stateMutability: 'view', - type: 'function', + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; }, - { - constant: true, - inputs: [ - { - name: 'assetProxyId', - type: 'bytes4', - }, - ], - name: 'getAssetProxy', - outputs: [ - { - name: '', - type: 'address', - }, - ], - payable: false, - stateMutability: 'view', - type: 'function', + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); }, - { - constant: true, - inputs: [ - { - name: 'order', - type: 'tuple', - components: [ - { - name: 'makerAddress', - type: 'address', - }, - { - name: 'takerAddress', - type: 'address', - }, - { - name: 'feeRecipientAddress', - type: 'address', - }, - { - name: 'senderAddress', - type: 'address', - }, - { - name: 'makerAssetAmount', - type: 'uint256', - }, - { - name: 'takerAssetAmount', - type: 'uint256', - }, - { - name: 'makerFee', - type: 'uint256', - }, - { - name: 'takerFee', - type: 'uint256', - }, - { - name: 'expirationTimeSeconds', - type: 'uint256', - }, - { - name: 'salt', - type: 'uint256', - }, - { - name: 'makerAssetData', - type: 'bytes', - }, - { - name: 'takerAssetData', - type: 'bytes', - }, - { - name: 'makerFeeAssetData', - type: 'bytes', - }, - { - name: 'takerFeeAssetData', - type: 'bytes', - }, - ], - }, - ], - name: 'getOrderInfo', - outputs: [ + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments( + 'batchMatchOrdersWithMaximalFill((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],bytes[],bytes[])', + [leftOrders, rightOrders, leftSignatures, rightSignatures], + ); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'orderInfo', - type: 'tuple', - components: [ - { - name: 'orderStatus', - type: 'uint8', - }, - { - name: 'orderHash', - type: 'bytes32', - }, - { - name: 'orderTakerAssetFilledAmount', - type: 'uint256', - }, - ], + to: self.address, + ...txData, + data: encodedData, }, - ], - payable: false, - stateMutability: 'view', - type: 'function', + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; }, - { - constant: true, - inputs: [ + async callAsync( + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise<{ + left: Array<{ + makerAssetFilledAmount: BigNumber; + takerAssetFilledAmount: BigNumber; + makerFeePaid: BigNumber; + takerFeePaid: BigNumber; + protocolFeePaid: BigNumber; + }>; + right: Array<{ + makerAssetFilledAmount: BigNumber; + takerAssetFilledAmount: BigNumber; + makerFeePaid: BigNumber; + takerFeePaid: BigNumber; + protocolFeePaid: BigNumber; + }>; + profitInLeftMakerAsset: BigNumber; + profitInRightMakerAsset: BigNumber; + }> { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments( + 'batchMatchOrdersWithMaximalFill((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],bytes[],bytes[])', + [leftOrders, rightOrders, leftSignatures, rightSignatures], + ); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'hash', - type: 'bytes32', + to: self.address, + ...callData, + data: encodedData, }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder( + 'batchMatchOrdersWithMaximalFill((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],bytes[],bytes[])', + ); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<{ + left: Array<{ + makerAssetFilledAmount: BigNumber; + takerAssetFilledAmount: BigNumber; + makerFeePaid: BigNumber; + takerFeePaid: BigNumber; + protocolFeePaid: BigNumber; + }>; + right: Array<{ + makerAssetFilledAmount: BigNumber; + takerAssetFilledAmount: BigNumber; + makerFeePaid: BigNumber; + takerFeePaid: BigNumber; + protocolFeePaid: BigNumber; + }>; + profitInLeftMakerAsset: BigNumber; + profitInRightMakerAsset: BigNumber; + }>(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'batchMatchOrdersWithMaximalFill((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],bytes[],bytes[])', + [leftOrders, rightOrders, leftSignatures, rightSignatures], + ); + return abiEncodedTransactionData; + }, + }; + } + /** + * After calling, the order can not be filled anymore. + * @param order Order struct containing order specifications. + */ + public cancelOrder(order: { + makerAddress: string; + takerAddress: string; + feeRecipientAddress: string; + senderAddress: string; + makerAssetAmount: BigNumber; + takerAssetAmount: BigNumber; + makerFee: BigNumber; + takerFee: BigNumber; + expirationTimeSeconds: BigNumber; + salt: BigNumber; + makerAssetData: string; + takerAssetData: string; + makerFeeAssetData: string; + takerFeeAssetData: string; + }): ContractTxFunctionObj { + const self = (this as any) as ExchangeContract; + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments( + 'cancelOrder((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes))', + [order], + ); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'signerAddress', - type: 'address', + to: self.address, + ...txData, + data: encodedData, }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments( + 'cancelOrder((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes))', + [order], + ); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'signature', - type: 'bytes', + to: self.address, + ...txData, + data: encodedData, }, - ], - name: 'isValidHashSignature', - outputs: [ + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments( + 'cancelOrder((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes))', + [order], + ); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'isValid', - type: 'bool', + to: self.address, + ...callData, + data: encodedData, }, - ], - payable: false, - stateMutability: 'view', - type: 'function', + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder( + 'cancelOrder((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes))', + ); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; }, - { - constant: true, - inputs: [ - { - name: 'order', - type: 'tuple', - components: [ - { - name: 'makerAddress', - type: 'address', - }, - { - name: 'takerAddress', - type: 'address', - }, - { - name: 'feeRecipientAddress', - type: 'address', - }, - { - name: 'senderAddress', - type: 'address', - }, - { - name: 'makerAssetAmount', - type: 'uint256', - }, - { - name: 'takerAssetAmount', - type: 'uint256', - }, - { - name: 'makerFee', - type: 'uint256', - }, - { - name: 'takerFee', - type: 'uint256', - }, - { - name: 'expirationTimeSeconds', - type: 'uint256', - }, - { - name: 'salt', - type: 'uint256', - }, - { - name: 'makerAssetData', - type: 'bytes', - }, - { - name: 'takerAssetData', - type: 'bytes', - }, - { - name: 'makerFeeAssetData', - type: 'bytes', - }, - { - name: 'takerFeeAssetData', - type: 'bytes', - }, - ], + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'cancelOrder((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes))', + [order], + ); + return abiEncodedTransactionData; + }, + }; + } + /** + * Cancels all orders created by makerAddress with a salt less than or equal to the targetOrderEpoch + * and senderAddress equal to msg.sender (or null address if msg.sender == makerAddress). + * @param targetOrderEpoch Orders created with a salt less or equal to this + * value will be cancelled. + */ + public cancelOrdersUpTo(targetOrderEpoch: BigNumber): ContractTxFunctionObj { + const self = (this as any) as ExchangeContract; + assert.isBigNumber('targetOrderEpoch', targetOrderEpoch); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('cancelOrdersUpTo(uint256)', [targetOrderEpoch]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('cancelOrdersUpTo(uint256)', [targetOrderEpoch]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('cancelOrdersUpTo(uint256)', [targetOrderEpoch]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'signature', - type: 'bytes', + to: self.address, + ...callData, + data: encodedData, }, - ], - name: 'isValidOrderSignature', - outputs: [ + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('cancelOrdersUpTo(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('cancelOrdersUpTo(uint256)', [ + targetOrderEpoch, + ]); + return abiEncodedTransactionData; + }, + }; + } + public cancelled(index_0: string): ContractFunctionObj { + const self = (this as any) as ExchangeContract; + assert.isString('index_0', index_0); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('cancelled(bytes32)', [index_0]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'isValid', - type: 'bool', + to: self.address, + ...callData, + data: encodedData, }, - ], - payable: false, - stateMutability: 'view', - type: 'function', + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('cancelled(bytes32)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; }, - { - constant: true, - inputs: [ + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('cancelled(bytes32)', [index_0]); + return abiEncodedTransactionData; + }, + }; + } + public currentContextAddress(): ContractFunctionObj { + const self = (this as any) as ExchangeContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('currentContextAddress()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'transaction', - type: 'tuple', - components: [ - { - name: 'salt', - type: 'uint256', - }, - { - name: 'expirationTimeSeconds', - type: 'uint256', - }, - { - name: 'gasPrice', - type: 'uint256', - }, - { - name: 'signerAddress', - type: 'address', - }, - { - name: 'data', - type: 'bytes', - }, - ], + to: self.address, + ...callData, + data: encodedData, }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('currentContextAddress()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('currentContextAddress()', []); + return abiEncodedTransactionData; + }, + }; + } + /** + * Executes an Exchange method call in the context of signer. + * @param transaction 0x transaction structure. + * @param signature Proof that transaction has been signed by signer. + * @returns ABI encoded return data of the underlying Exchange function call. + */ + public executeTransaction( + transaction: { + salt: BigNumber; + expirationTimeSeconds: BigNumber; + gasPrice: BigNumber; + signerAddress: string; + data: string; + }, + signature: string, + ): ContractTxFunctionObj { + const self = (this as any) as ExchangeContract; + + assert.isString('signature', signature); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments( + 'executeTransaction((uint256,uint256,uint256,address,bytes),bytes)', + [transaction, signature], + ); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'signature', - type: 'bytes', + to: self.address, + ...txData, + data: encodedData, }, - ], - name: 'isValidTransactionSignature', - outputs: [ + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments( + 'executeTransaction((uint256,uint256,uint256,address,bytes),bytes)', + [transaction, signature], + ); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'isValid', - type: 'bool', + to: self.address, + ...txData, + data: encodedData, }, - ], - payable: false, - stateMutability: 'view', - type: 'function', + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; }, - { - constant: false, - inputs: [ + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments( + 'executeTransaction((uint256,uint256,uint256,address,bytes),bytes)', + [transaction, signature], + ); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'orders', - type: 'tuple[]', - components: [ - { - name: 'makerAddress', - type: 'address', - }, - { - name: 'takerAddress', - type: 'address', - }, - { - name: 'feeRecipientAddress', - type: 'address', - }, - { - name: 'senderAddress', - type: 'address', - }, - { - name: 'makerAssetAmount', - type: 'uint256', - }, - { - name: 'takerAssetAmount', - type: 'uint256', - }, - { - name: 'makerFee', - type: 'uint256', - }, - { - name: 'takerFee', - type: 'uint256', - }, - { - name: 'expirationTimeSeconds', - type: 'uint256', - }, - { - name: 'salt', - type: 'uint256', - }, - { - name: 'makerAssetData', - type: 'bytes', - }, - { - name: 'takerAssetData', - type: 'bytes', - }, - { - name: 'makerFeeAssetData', - type: 'bytes', - }, - { - name: 'takerFeeAssetData', - type: 'bytes', - }, - ], + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder( + 'executeTransaction((uint256,uint256,uint256,address,bytes),bytes)', + ); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'executeTransaction((uint256,uint256,uint256,address,bytes),bytes)', + [transaction, signature], + ); + return abiEncodedTransactionData; + }, + }; + } + /** + * Fills the input order. Reverts if exact takerAssetFillAmount not filled. + * @param order Order struct containing order specifications. + * @param takerAssetFillAmount Desired amount of takerAsset to sell. + * @param signature Proof that order has been created by maker. + */ + public fillOrKillOrder( + order: { + makerAddress: string; + takerAddress: string; + feeRecipientAddress: string; + senderAddress: string; + makerAssetAmount: BigNumber; + takerAssetAmount: BigNumber; + makerFee: BigNumber; + takerFee: BigNumber; + expirationTimeSeconds: BigNumber; + salt: BigNumber; + makerAssetData: string; + takerAssetData: string; + makerFeeAssetData: string; + takerFeeAssetData: string; + }, + takerAssetFillAmount: BigNumber, + signature: string, + ): ContractTxFunctionObj<{ + makerAssetFilledAmount: BigNumber; + takerAssetFilledAmount: BigNumber; + makerFeePaid: BigNumber; + takerFeePaid: BigNumber; + protocolFeePaid: BigNumber; + }> { + const self = (this as any) as ExchangeContract; + + assert.isBigNumber('takerAssetFillAmount', takerAssetFillAmount); + assert.isString('signature', signature); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments( + 'fillOrKillOrder((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),uint256,bytes)', + [order, takerAssetFillAmount, signature], + ); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments( + 'fillOrKillOrder((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),uint256,bytes)', + [order, takerAssetFillAmount, signature], + ); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'makerAssetFillAmount', - type: 'uint256', + to: self.address, + ...txData, + data: encodedData, }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync( + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise<{ + makerAssetFilledAmount: BigNumber; + takerAssetFilledAmount: BigNumber; + makerFeePaid: BigNumber; + takerFeePaid: BigNumber; + protocolFeePaid: BigNumber; + }> { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments( + 'fillOrKillOrder((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),uint256,bytes)', + [order, takerAssetFillAmount, signature], + ); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'signatures', - type: 'bytes[]', + to: self.address, + ...callData, + data: encodedData, }, - ], - name: 'marketBuyOrdersFillOrKill', - outputs: [ + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder( + 'fillOrKillOrder((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),uint256,bytes)', + ); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<{ + makerAssetFilledAmount: BigNumber; + takerAssetFilledAmount: BigNumber; + makerFeePaid: BigNumber; + takerFeePaid: BigNumber; + protocolFeePaid: BigNumber; + }>(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'fillOrKillOrder((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),uint256,bytes)', + [order, takerAssetFillAmount, signature], + ); + return abiEncodedTransactionData; + }, + }; + } + /** + * Fills the input order. + * @param order Order struct containing order specifications. + * @param takerAssetFillAmount Desired amount of takerAsset to sell. + * @param signature Proof that order has been created by maker. + * @returns Amounts filled and fees paid by maker and taker. + */ + public fillOrder( + order: { + makerAddress: string; + takerAddress: string; + feeRecipientAddress: string; + senderAddress: string; + makerAssetAmount: BigNumber; + takerAssetAmount: BigNumber; + makerFee: BigNumber; + takerFee: BigNumber; + expirationTimeSeconds: BigNumber; + salt: BigNumber; + makerAssetData: string; + takerAssetData: string; + makerFeeAssetData: string; + takerFeeAssetData: string; + }, + takerAssetFillAmount: BigNumber, + signature: string, + ): ContractTxFunctionObj<{ + makerAssetFilledAmount: BigNumber; + takerAssetFilledAmount: BigNumber; + makerFeePaid: BigNumber; + takerFeePaid: BigNumber; + protocolFeePaid: BigNumber; + }> { + const self = (this as any) as ExchangeContract; + + assert.isBigNumber('takerAssetFillAmount', takerAssetFillAmount); + assert.isString('signature', signature); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments( + 'fillOrder((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),uint256,bytes)', + [order, takerAssetFillAmount, signature], + ); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'fillResults', - type: 'tuple', - components: [ - { - name: 'makerAssetFilledAmount', - type: 'uint256', - }, - { - name: 'takerAssetFilledAmount', - type: 'uint256', - }, - { - name: 'makerFeePaid', - type: 'uint256', - }, - { - name: 'takerFeePaid', - type: 'uint256', - }, - { - name: 'protocolFeePaid', - type: 'uint256', - }, - ], + to: self.address, + ...txData, + data: encodedData, }, - ], - payable: true, - stateMutability: 'payable', - type: 'function', + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; }, - { - constant: false, - inputs: [ + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments( + 'fillOrder((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),uint256,bytes)', + [order, takerAssetFillAmount, signature], + ); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'orders', - type: 'tuple[]', - components: [ - { - name: 'makerAddress', - type: 'address', - }, - { - name: 'takerAddress', - type: 'address', - }, - { - name: 'feeRecipientAddress', - type: 'address', - }, - { - name: 'senderAddress', - type: 'address', - }, - { - name: 'makerAssetAmount', - type: 'uint256', - }, - { - name: 'takerAssetAmount', - type: 'uint256', - }, - { - name: 'makerFee', - type: 'uint256', - }, - { - name: 'takerFee', - type: 'uint256', - }, - { - name: 'expirationTimeSeconds', - type: 'uint256', - }, - { - name: 'salt', - type: 'uint256', - }, - { - name: 'makerAssetData', - type: 'bytes', - }, - { - name: 'takerAssetData', - type: 'bytes', - }, - { - name: 'makerFeeAssetData', - type: 'bytes', - }, - { - name: 'takerFeeAssetData', - type: 'bytes', - }, - ], + to: self.address, + ...txData, + data: encodedData, }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync( + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise<{ + makerAssetFilledAmount: BigNumber; + takerAssetFilledAmount: BigNumber; + makerFeePaid: BigNumber; + takerFeePaid: BigNumber; + protocolFeePaid: BigNumber; + }> { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments( + 'fillOrder((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),uint256,bytes)', + [order, takerAssetFillAmount, signature], + ); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'makerAssetFillAmount', - type: 'uint256', + to: self.address, + ...callData, + data: encodedData, }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder( + 'fillOrder((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),uint256,bytes)', + ); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<{ + makerAssetFilledAmount: BigNumber; + takerAssetFilledAmount: BigNumber; + makerFeePaid: BigNumber; + takerFeePaid: BigNumber; + protocolFeePaid: BigNumber; + }>(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'fillOrder((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),uint256,bytes)', + [order, takerAssetFillAmount, signature], + ); + return abiEncodedTransactionData; + }, + }; + } + public filled(index_0: string): ContractFunctionObj { + const self = (this as any) as ExchangeContract; + assert.isString('index_0', index_0); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('filled(bytes32)', [index_0]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'signatures', - type: 'bytes[]', + to: self.address, + ...callData, + data: encodedData, }, - ], - name: 'marketBuyOrdersNoThrow', - outputs: [ + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('filled(bytes32)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('filled(bytes32)', [index_0]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Gets an asset proxy. + * @param assetProxyId Id of the asset proxy. + * @returns The asset proxy registered to assetProxyId. Returns 0x0 if no proxy is registered. + */ + public getAssetProxy(assetProxyId: string): ContractFunctionObj { + const self = (this as any) as ExchangeContract; + assert.isString('assetProxyId', assetProxyId); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('getAssetProxy(bytes4)', [assetProxyId]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'fillResults', - type: 'tuple', - components: [ - { - name: 'makerAssetFilledAmount', - type: 'uint256', - }, - { - name: 'takerAssetFilledAmount', - type: 'uint256', - }, - { - name: 'makerFeePaid', - type: 'uint256', - }, - { - name: 'takerFeePaid', - type: 'uint256', - }, - { - name: 'protocolFeePaid', - type: 'uint256', - }, - ], + to: self.address, + ...callData, + data: encodedData, }, - ], - payable: true, - stateMutability: 'payable', - type: 'function', + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('getAssetProxy(bytes4)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; }, - { - constant: false, - inputs: [ + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('getAssetProxy(bytes4)', [assetProxyId]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Gets information about an order: status, hash, and amount filled. + * @param order Order to gather information on. + * @returns OrderInfo Information about the order and its state. See LibOrder.OrderInfo for a complete description. + */ + public getOrderInfo(order: { + makerAddress: string; + takerAddress: string; + feeRecipientAddress: string; + senderAddress: string; + makerAssetAmount: BigNumber; + takerAssetAmount: BigNumber; + makerFee: BigNumber; + takerFee: BigNumber; + expirationTimeSeconds: BigNumber; + salt: BigNumber; + makerAssetData: string; + takerAssetData: string; + makerFeeAssetData: string; + takerFeeAssetData: string; + }): ContractFunctionObj<{ orderStatus: number; orderHash: string; orderTakerAssetFilledAmount: BigNumber }> { + const self = (this as any) as ExchangeContract; + + return { + async callAsync( + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise<{ orderStatus: number; orderHash: string; orderTakerAssetFilledAmount: BigNumber }> { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments( + 'getOrderInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes))', + [order], + ); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'orders', - type: 'tuple[]', - components: [ - { - name: 'makerAddress', - type: 'address', - }, - { - name: 'takerAddress', - type: 'address', - }, - { - name: 'feeRecipientAddress', - type: 'address', - }, - { - name: 'senderAddress', - type: 'address', - }, - { - name: 'makerAssetAmount', - type: 'uint256', - }, - { - name: 'takerAssetAmount', - type: 'uint256', - }, - { - name: 'makerFee', - type: 'uint256', - }, - { - name: 'takerFee', - type: 'uint256', - }, - { - name: 'expirationTimeSeconds', - type: 'uint256', - }, - { - name: 'salt', - type: 'uint256', - }, - { - name: 'makerAssetData', - type: 'bytes', - }, - { - name: 'takerAssetData', - type: 'bytes', - }, - { - name: 'makerFeeAssetData', - type: 'bytes', - }, - { - name: 'takerFeeAssetData', - type: 'bytes', - }, - ], + to: self.address, + ...callData, + data: encodedData, }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder( + 'getOrderInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes))', + ); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<{ + orderStatus: number; + orderHash: string; + orderTakerAssetFilledAmount: BigNumber; + }>(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'getOrderInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes))', + [order], + ); + return abiEncodedTransactionData; + }, + }; + } + /** + * Verifies that a hash has been signed by the given signer. + * @param hash Any 32-byte hash. + * @param signerAddress Address that should have signed the given hash. + * @param signature Proof that the hash has been signed by signer. + * @returns isValid `true` if the signature is valid for the given hash and signer. + */ + public isValidHashSignature(hash: string, signerAddress: string, signature: string): ContractFunctionObj { + const self = (this as any) as ExchangeContract; + assert.isString('hash', hash); + assert.isString('signerAddress', signerAddress); + assert.isString('signature', signature); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('isValidHashSignature(bytes32,address,bytes)', [ + hash, + signerAddress.toLowerCase(), + signature, + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'takerAssetFillAmount', - type: 'uint256', + to: self.address, + ...callData, + data: encodedData, }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('isValidHashSignature(bytes32,address,bytes)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'isValidHashSignature(bytes32,address,bytes)', + [hash, signerAddress.toLowerCase(), signature], + ); + return abiEncodedTransactionData; + }, + }; + } + /** + * Verifies that a signature for an order is valid. + * @param order The order. + * @param signature Proof that the order has been signed by signer. + * @returns isValid `true` if the signature is valid for the given order and signer. + */ + public isValidOrderSignature( + order: { + makerAddress: string; + takerAddress: string; + feeRecipientAddress: string; + senderAddress: string; + makerAssetAmount: BigNumber; + takerAssetAmount: BigNumber; + makerFee: BigNumber; + takerFee: BigNumber; + expirationTimeSeconds: BigNumber; + salt: BigNumber; + makerAssetData: string; + takerAssetData: string; + makerFeeAssetData: string; + takerFeeAssetData: string; + }, + signature: string, + ): ContractFunctionObj { + const self = (this as any) as ExchangeContract; + + assert.isString('signature', signature); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments( + 'isValidOrderSignature((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),bytes)', + [order, signature], + ); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'signatures', - type: 'bytes[]', + to: self.address, + ...callData, + data: encodedData, }, - ], - name: 'marketSellOrdersFillOrKill', - outputs: [ + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder( + 'isValidOrderSignature((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),bytes)', + ); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'isValidOrderSignature((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),bytes)', + [order, signature], + ); + return abiEncodedTransactionData; + }, + }; + } + /** + * Verifies that a signature for a transaction is valid. + * @param transaction The transaction. + * @param signature Proof that the order has been signed by signer. + * @returns isValid `true` if the signature is valid for the given transaction and signer. + */ + public isValidTransactionSignature( + transaction: { + salt: BigNumber; + expirationTimeSeconds: BigNumber; + gasPrice: BigNumber; + signerAddress: string; + data: string; + }, + signature: string, + ): ContractFunctionObj { + const self = (this as any) as ExchangeContract; + + assert.isString('signature', signature); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments( + 'isValidTransactionSignature((uint256,uint256,uint256,address,bytes),bytes)', + [transaction, signature], + ); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'fillResults', - type: 'tuple', - components: [ - { - name: 'makerAssetFilledAmount', - type: 'uint256', - }, - { - name: 'takerAssetFilledAmount', - type: 'uint256', - }, - { - name: 'makerFeePaid', - type: 'uint256', - }, - { - name: 'takerFeePaid', - type: 'uint256', - }, - { - name: 'protocolFeePaid', - type: 'uint256', - }, - ], + to: self.address, + ...callData, + data: encodedData, }, - ], - payable: true, - stateMutability: 'payable', - type: 'function', + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder( + 'isValidTransactionSignature((uint256,uint256,uint256,address,bytes),bytes)', + ); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; }, - { - constant: false, - inputs: [ + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'isValidTransactionSignature((uint256,uint256,uint256,address,bytes),bytes)', + [transaction, signature], + ); + return abiEncodedTransactionData; + }, + }; + } + /** + * Calls marketBuyOrdersNoThrow then reverts if < makerAssetFillAmount has been bought. + * NOTE: This function does not enforce that the makerAsset is the same for each order. + * @param orders Array of order specifications. + * @param makerAssetFillAmount Minimum amount of makerAsset to buy. + * @param signatures Proofs that orders have been signed by makers. + * @returns Amounts filled and fees paid by makers and taker. + */ + public marketBuyOrdersFillOrKill( + orders: Array<{ + makerAddress: string; + takerAddress: string; + feeRecipientAddress: string; + senderAddress: string; + makerAssetAmount: BigNumber; + takerAssetAmount: BigNumber; + makerFee: BigNumber; + takerFee: BigNumber; + expirationTimeSeconds: BigNumber; + salt: BigNumber; + makerAssetData: string; + takerAssetData: string; + makerFeeAssetData: string; + takerFeeAssetData: string; + }>, + makerAssetFillAmount: BigNumber, + signatures: string[], + ): ContractTxFunctionObj<{ + makerAssetFilledAmount: BigNumber; + takerAssetFilledAmount: BigNumber; + makerFeePaid: BigNumber; + takerFeePaid: BigNumber; + protocolFeePaid: BigNumber; + }> { + const self = (this as any) as ExchangeContract; + assert.isArray('orders', orders); + assert.isBigNumber('makerAssetFillAmount', makerAssetFillAmount); + assert.isArray('signatures', signatures); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments( + 'marketBuyOrdersFillOrKill((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256,bytes[])', + [orders, makerAssetFillAmount, signatures], + ); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'orders', - type: 'tuple[]', - components: [ - { - name: 'makerAddress', - type: 'address', - }, - { - name: 'takerAddress', - type: 'address', - }, - { - name: 'feeRecipientAddress', - type: 'address', - }, - { - name: 'senderAddress', - type: 'address', - }, - { - name: 'makerAssetAmount', - type: 'uint256', - }, - { - name: 'takerAssetAmount', - type: 'uint256', - }, - { - name: 'makerFee', - type: 'uint256', - }, - { - name: 'takerFee', - type: 'uint256', - }, - { - name: 'expirationTimeSeconds', - type: 'uint256', - }, - { - name: 'salt', - type: 'uint256', - }, - { - name: 'makerAssetData', - type: 'bytes', - }, - { - name: 'takerAssetData', - type: 'bytes', - }, - { - name: 'makerFeeAssetData', - type: 'bytes', - }, - { - name: 'takerFeeAssetData', - type: 'bytes', - }, - ], + to: self.address, + ...txData, + data: encodedData, }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments( + 'marketBuyOrdersFillOrKill((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256,bytes[])', + [orders, makerAssetFillAmount, signatures], + ); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'takerAssetFillAmount', - type: 'uint256', + to: self.address, + ...txData, + data: encodedData, }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync( + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise<{ + makerAssetFilledAmount: BigNumber; + takerAssetFilledAmount: BigNumber; + makerFeePaid: BigNumber; + takerFeePaid: BigNumber; + protocolFeePaid: BigNumber; + }> { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments( + 'marketBuyOrdersFillOrKill((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256,bytes[])', + [orders, makerAssetFillAmount, signatures], + ); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'signatures', - type: 'bytes[]', + to: self.address, + ...callData, + data: encodedData, }, - ], - name: 'marketSellOrdersNoThrow', - outputs: [ + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder( + 'marketBuyOrdersFillOrKill((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256,bytes[])', + ); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<{ + makerAssetFilledAmount: BigNumber; + takerAssetFilledAmount: BigNumber; + makerFeePaid: BigNumber; + takerFeePaid: BigNumber; + protocolFeePaid: BigNumber; + }>(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'marketBuyOrdersFillOrKill((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256,bytes[])', + [orders, makerAssetFillAmount, signatures], + ); + return abiEncodedTransactionData; + }, + }; + } + /** + * Executes multiple calls of fillOrder until total amount of makerAsset is bought by taker. + * If any fill reverts, the error is caught and ignored. + * NOTE: This function does not enforce that the makerAsset is the same for each order. + * @param orders Array of order specifications. + * @param makerAssetFillAmount Desired amount of makerAsset to buy. + * @param signatures Proofs that orders have been signed by makers. + * @returns Amounts filled and fees paid by makers and taker. + */ + public marketBuyOrdersNoThrow( + orders: Array<{ + makerAddress: string; + takerAddress: string; + feeRecipientAddress: string; + senderAddress: string; + makerAssetAmount: BigNumber; + takerAssetAmount: BigNumber; + makerFee: BigNumber; + takerFee: BigNumber; + expirationTimeSeconds: BigNumber; + salt: BigNumber; + makerAssetData: string; + takerAssetData: string; + makerFeeAssetData: string; + takerFeeAssetData: string; + }>, + makerAssetFillAmount: BigNumber, + signatures: string[], + ): ContractTxFunctionObj<{ + makerAssetFilledAmount: BigNumber; + takerAssetFilledAmount: BigNumber; + makerFeePaid: BigNumber; + takerFeePaid: BigNumber; + protocolFeePaid: BigNumber; + }> { + const self = (this as any) as ExchangeContract; + assert.isArray('orders', orders); + assert.isBigNumber('makerAssetFillAmount', makerAssetFillAmount); + assert.isArray('signatures', signatures); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments( + 'marketBuyOrdersNoThrow((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256,bytes[])', + [orders, makerAssetFillAmount, signatures], + ); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'fillResults', - type: 'tuple', - components: [ - { - name: 'makerAssetFilledAmount', - type: 'uint256', - }, - { - name: 'takerAssetFilledAmount', - type: 'uint256', - }, - { - name: 'makerFeePaid', - type: 'uint256', - }, - { - name: 'takerFeePaid', - type: 'uint256', - }, - { - name: 'protocolFeePaid', - type: 'uint256', - }, - ], + to: self.address, + ...txData, + data: encodedData, }, - ], - payable: true, - stateMutability: 'payable', - type: 'function', + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; }, - { - constant: false, - inputs: [ + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments( + 'marketBuyOrdersNoThrow((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256,bytes[])', + [orders, makerAssetFillAmount, signatures], + ); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'leftOrder', - type: 'tuple', - components: [ - { - name: 'makerAddress', - type: 'address', - }, - { - name: 'takerAddress', - type: 'address', - }, - { - name: 'feeRecipientAddress', - type: 'address', - }, - { - name: 'senderAddress', - type: 'address', - }, - { - name: 'makerAssetAmount', - type: 'uint256', - }, - { - name: 'takerAssetAmount', - type: 'uint256', - }, - { - name: 'makerFee', - type: 'uint256', - }, - { - name: 'takerFee', - type: 'uint256', - }, - { - name: 'expirationTimeSeconds', - type: 'uint256', - }, - { - name: 'salt', - type: 'uint256', - }, - { - name: 'makerAssetData', - type: 'bytes', - }, - { - name: 'takerAssetData', - type: 'bytes', - }, - { - name: 'makerFeeAssetData', - type: 'bytes', - }, - { - name: 'takerFeeAssetData', - type: 'bytes', - }, - ], + to: self.address, + ...txData, + data: encodedData, }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync( + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise<{ + makerAssetFilledAmount: BigNumber; + takerAssetFilledAmount: BigNumber; + makerFeePaid: BigNumber; + takerFeePaid: BigNumber; + protocolFeePaid: BigNumber; + }> { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments( + 'marketBuyOrdersNoThrow((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256,bytes[])', + [orders, makerAssetFillAmount, signatures], + ); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'rightOrder', - type: 'tuple', - components: [ - { - name: 'makerAddress', - type: 'address', - }, - { - name: 'takerAddress', - type: 'address', - }, - { - name: 'feeRecipientAddress', - type: 'address', - }, - { - name: 'senderAddress', - type: 'address', - }, - { - name: 'makerAssetAmount', - type: 'uint256', - }, - { - name: 'takerAssetAmount', - type: 'uint256', - }, - { - name: 'makerFee', - type: 'uint256', - }, - { - name: 'takerFee', - type: 'uint256', - }, - { - name: 'expirationTimeSeconds', - type: 'uint256', - }, - { - name: 'salt', - type: 'uint256', - }, - { - name: 'makerAssetData', - type: 'bytes', - }, - { - name: 'takerAssetData', - type: 'bytes', - }, - { - name: 'makerFeeAssetData', - type: 'bytes', - }, - { - name: 'takerFeeAssetData', - type: 'bytes', - }, - ], + to: self.address, + ...callData, + data: encodedData, }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder( + 'marketBuyOrdersNoThrow((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256,bytes[])', + ); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<{ + makerAssetFilledAmount: BigNumber; + takerAssetFilledAmount: BigNumber; + makerFeePaid: BigNumber; + takerFeePaid: BigNumber; + protocolFeePaid: BigNumber; + }>(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'marketBuyOrdersNoThrow((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256,bytes[])', + [orders, makerAssetFillAmount, signatures], + ); + return abiEncodedTransactionData; + }, + }; + } + /** + * Calls marketSellOrdersNoThrow then reverts if < takerAssetFillAmount has been sold. + * NOTE: This function does not enforce that the takerAsset is the same for each order. + * @param orders Array of order specifications. + * @param takerAssetFillAmount Minimum amount of takerAsset to sell. + * @param signatures Proofs that orders have been signed by makers. + * @returns Amounts filled and fees paid by makers and taker. + */ + public marketSellOrdersFillOrKill( + orders: Array<{ + makerAddress: string; + takerAddress: string; + feeRecipientAddress: string; + senderAddress: string; + makerAssetAmount: BigNumber; + takerAssetAmount: BigNumber; + makerFee: BigNumber; + takerFee: BigNumber; + expirationTimeSeconds: BigNumber; + salt: BigNumber; + makerAssetData: string; + takerAssetData: string; + makerFeeAssetData: string; + takerFeeAssetData: string; + }>, + takerAssetFillAmount: BigNumber, + signatures: string[], + ): ContractTxFunctionObj<{ + makerAssetFilledAmount: BigNumber; + takerAssetFilledAmount: BigNumber; + makerFeePaid: BigNumber; + takerFeePaid: BigNumber; + protocolFeePaid: BigNumber; + }> { + const self = (this as any) as ExchangeContract; + assert.isArray('orders', orders); + assert.isBigNumber('takerAssetFillAmount', takerAssetFillAmount); + assert.isArray('signatures', signatures); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments( + 'marketSellOrdersFillOrKill((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256,bytes[])', + [orders, takerAssetFillAmount, signatures], + ); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'leftSignature', - type: 'bytes', + to: self.address, + ...txData, + data: encodedData, }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments( + 'marketSellOrdersFillOrKill((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256,bytes[])', + [orders, takerAssetFillAmount, signatures], + ); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'rightSignature', - type: 'bytes', + to: self.address, + ...txData, + data: encodedData, }, - ], - name: 'matchOrders', - outputs: [ + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync( + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise<{ + makerAssetFilledAmount: BigNumber; + takerAssetFilledAmount: BigNumber; + makerFeePaid: BigNumber; + takerFeePaid: BigNumber; + protocolFeePaid: BigNumber; + }> { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments( + 'marketSellOrdersFillOrKill((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256,bytes[])', + [orders, takerAssetFillAmount, signatures], + ); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'matchedFillResults', - type: 'tuple', - components: [ - { - name: 'left', - type: 'tuple', - components: [ - { - name: 'makerAssetFilledAmount', - type: 'uint256', - }, - { - name: 'takerAssetFilledAmount', - type: 'uint256', - }, - { - name: 'makerFeePaid', - type: 'uint256', - }, - { - name: 'takerFeePaid', - type: 'uint256', - }, - { - name: 'protocolFeePaid', - type: 'uint256', - }, - ], - }, - { - name: 'right', - type: 'tuple', - components: [ - { - name: 'makerAssetFilledAmount', - type: 'uint256', - }, - { - name: 'takerAssetFilledAmount', - type: 'uint256', - }, - { - name: 'makerFeePaid', - type: 'uint256', - }, - { - name: 'takerFeePaid', - type: 'uint256', - }, - { - name: 'protocolFeePaid', - type: 'uint256', - }, - ], - }, - { - name: 'profitInLeftMakerAsset', - type: 'uint256', - }, - { - name: 'profitInRightMakerAsset', - type: 'uint256', - }, - ], + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder( + 'marketSellOrdersFillOrKill((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256,bytes[])', + ); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<{ + makerAssetFilledAmount: BigNumber; + takerAssetFilledAmount: BigNumber; + makerFeePaid: BigNumber; + takerFeePaid: BigNumber; + protocolFeePaid: BigNumber; + }>(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'marketSellOrdersFillOrKill((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256,bytes[])', + [orders, takerAssetFillAmount, signatures], + ); + return abiEncodedTransactionData; + }, + }; + } + /** + * Executes multiple calls of fillOrder until total amount of takerAsset is sold by taker. + * If any fill reverts, the error is caught and ignored. + * NOTE: This function does not enforce that the takerAsset is the same for each order. + * @param orders Array of order specifications. + * @param takerAssetFillAmount Desired amount of takerAsset to sell. + * @param signatures Proofs that orders have been signed by makers. + * @returns Amounts filled and fees paid by makers and taker. + */ + public marketSellOrdersNoThrow( + orders: Array<{ + makerAddress: string; + takerAddress: string; + feeRecipientAddress: string; + senderAddress: string; + makerAssetAmount: BigNumber; + takerAssetAmount: BigNumber; + makerFee: BigNumber; + takerFee: BigNumber; + expirationTimeSeconds: BigNumber; + salt: BigNumber; + makerAssetData: string; + takerAssetData: string; + makerFeeAssetData: string; + takerFeeAssetData: string; + }>, + takerAssetFillAmount: BigNumber, + signatures: string[], + ): ContractTxFunctionObj<{ + makerAssetFilledAmount: BigNumber; + takerAssetFilledAmount: BigNumber; + makerFeePaid: BigNumber; + takerFeePaid: BigNumber; + protocolFeePaid: BigNumber; + }> { + const self = (this as any) as ExchangeContract; + assert.isArray('orders', orders); + assert.isBigNumber('takerAssetFillAmount', takerAssetFillAmount); + assert.isArray('signatures', signatures); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments( + 'marketSellOrdersNoThrow((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256,bytes[])', + [orders, takerAssetFillAmount, signatures], + ); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, }, - ], - payable: true, - stateMutability: 'payable', - type: 'function', + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; }, - { - constant: false, - inputs: [ + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments( + 'marketSellOrdersNoThrow((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256,bytes[])', + [orders, takerAssetFillAmount, signatures], + ); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'leftOrder', - type: 'tuple', - components: [ - { - name: 'makerAddress', - type: 'address', - }, - { - name: 'takerAddress', - type: 'address', - }, - { - name: 'feeRecipientAddress', - type: 'address', - }, - { - name: 'senderAddress', - type: 'address', - }, - { - name: 'makerAssetAmount', - type: 'uint256', - }, - { - name: 'takerAssetAmount', - type: 'uint256', - }, - { - name: 'makerFee', - type: 'uint256', - }, - { - name: 'takerFee', - type: 'uint256', - }, - { - name: 'expirationTimeSeconds', - type: 'uint256', - }, - { - name: 'salt', - type: 'uint256', - }, - { - name: 'makerAssetData', - type: 'bytes', - }, - { - name: 'takerAssetData', - type: 'bytes', - }, - { - name: 'makerFeeAssetData', - type: 'bytes', - }, - { - name: 'takerFeeAssetData', - type: 'bytes', - }, - ], + to: self.address, + ...txData, + data: encodedData, }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync( + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise<{ + makerAssetFilledAmount: BigNumber; + takerAssetFilledAmount: BigNumber; + makerFeePaid: BigNumber; + takerFeePaid: BigNumber; + protocolFeePaid: BigNumber; + }> { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments( + 'marketSellOrdersNoThrow((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256,bytes[])', + [orders, takerAssetFillAmount, signatures], + ); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'rightOrder', - type: 'tuple', - components: [ - { - name: 'makerAddress', - type: 'address', - }, - { - name: 'takerAddress', - type: 'address', - }, - { - name: 'feeRecipientAddress', - type: 'address', - }, - { - name: 'senderAddress', - type: 'address', - }, - { - name: 'makerAssetAmount', - type: 'uint256', - }, - { - name: 'takerAssetAmount', - type: 'uint256', - }, - { - name: 'makerFee', - type: 'uint256', - }, - { - name: 'takerFee', - type: 'uint256', - }, - { - name: 'expirationTimeSeconds', - type: 'uint256', - }, - { - name: 'salt', - type: 'uint256', - }, - { - name: 'makerAssetData', - type: 'bytes', - }, - { - name: 'takerAssetData', - type: 'bytes', - }, - { - name: 'makerFeeAssetData', - type: 'bytes', - }, - { - name: 'takerFeeAssetData', - type: 'bytes', - }, - ], + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder( + 'marketSellOrdersNoThrow((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256,bytes[])', + ); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<{ + makerAssetFilledAmount: BigNumber; + takerAssetFilledAmount: BigNumber; + makerFeePaid: BigNumber; + takerFeePaid: BigNumber; + protocolFeePaid: BigNumber; + }>(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'marketSellOrdersNoThrow((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256,bytes[])', + [orders, takerAssetFillAmount, signatures], + ); + return abiEncodedTransactionData; + }, + }; + } + /** + * Match two complementary orders that have a profitable spread. + * Each order is filled at their respective price point. However, the calculations are + * carried out as though the orders are both being filled at the right order's price point. + * The profit made by the left order goes to the taker (who matched the two orders). + * @param leftOrder First order to match. + * @param rightOrder Second order to match. + * @param leftSignature Proof that order was created by the left maker. + * @param rightSignature Proof that order was created by the right maker. + * @returns matchedFillResults Amounts filled and fees paid by maker and taker of matched orders. + */ + public matchOrders( + leftOrder: { + makerAddress: string; + takerAddress: string; + feeRecipientAddress: string; + senderAddress: string; + makerAssetAmount: BigNumber; + takerAssetAmount: BigNumber; + makerFee: BigNumber; + takerFee: BigNumber; + expirationTimeSeconds: BigNumber; + salt: BigNumber; + makerAssetData: string; + takerAssetData: string; + makerFeeAssetData: string; + takerFeeAssetData: string; + }, + rightOrder: { + makerAddress: string; + takerAddress: string; + feeRecipientAddress: string; + senderAddress: string; + makerAssetAmount: BigNumber; + takerAssetAmount: BigNumber; + makerFee: BigNumber; + takerFee: BigNumber; + expirationTimeSeconds: BigNumber; + salt: BigNumber; + makerAssetData: string; + takerAssetData: string; + makerFeeAssetData: string; + takerFeeAssetData: string; + }, + leftSignature: string, + rightSignature: string, + ): ContractTxFunctionObj<{ + left: { + makerAssetFilledAmount: BigNumber; + takerAssetFilledAmount: BigNumber; + makerFeePaid: BigNumber; + takerFeePaid: BigNumber; + protocolFeePaid: BigNumber; + }; + right: { + makerAssetFilledAmount: BigNumber; + takerAssetFilledAmount: BigNumber; + makerFeePaid: BigNumber; + takerFeePaid: BigNumber; + protocolFeePaid: BigNumber; + }; + profitInLeftMakerAsset: BigNumber; + profitInRightMakerAsset: BigNumber; + }> { + const self = (this as any) as ExchangeContract; + + assert.isString('leftSignature', leftSignature); + assert.isString('rightSignature', rightSignature); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments( + 'matchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),bytes,bytes)', + [leftOrder, rightOrder, leftSignature, rightSignature], + ); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments( + 'matchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),bytes,bytes)', + [leftOrder, rightOrder, leftSignature, rightSignature], + ); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'leftSignature', - type: 'bytes', + to: self.address, + ...txData, + data: encodedData, }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync( + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise<{ + left: { + makerAssetFilledAmount: BigNumber; + takerAssetFilledAmount: BigNumber; + makerFeePaid: BigNumber; + takerFeePaid: BigNumber; + protocolFeePaid: BigNumber; + }; + right: { + makerAssetFilledAmount: BigNumber; + takerAssetFilledAmount: BigNumber; + makerFeePaid: BigNumber; + takerFeePaid: BigNumber; + protocolFeePaid: BigNumber; + }; + profitInLeftMakerAsset: BigNumber; + profitInRightMakerAsset: BigNumber; + }> { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments( + 'matchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),bytes,bytes)', + [leftOrder, rightOrder, leftSignature, rightSignature], + ); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'rightSignature', - type: 'bytes', + to: self.address, + ...callData, + data: encodedData, }, - ], - name: 'matchOrdersWithMaximalFill', - outputs: [ + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder( + 'matchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),bytes,bytes)', + ); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<{ + left: { + makerAssetFilledAmount: BigNumber; + takerAssetFilledAmount: BigNumber; + makerFeePaid: BigNumber; + takerFeePaid: BigNumber; + protocolFeePaid: BigNumber; + }; + right: { + makerAssetFilledAmount: BigNumber; + takerAssetFilledAmount: BigNumber; + makerFeePaid: BigNumber; + takerFeePaid: BigNumber; + protocolFeePaid: BigNumber; + }; + profitInLeftMakerAsset: BigNumber; + profitInRightMakerAsset: BigNumber; + }>(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'matchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),bytes,bytes)', + [leftOrder, rightOrder, leftSignature, rightSignature], + ); + return abiEncodedTransactionData; + }, + }; + } + /** + * Match two complementary orders that have a profitable spread. + * Each order is maximally filled at their respective price point, and + * the matcher receives a profit denominated in either the left maker asset, + * right maker asset, or a combination of both. + * @param leftOrder First order to match. + * @param rightOrder Second order to match. + * @param leftSignature Proof that order was created by the left maker. + * @param rightSignature Proof that order was created by the right maker. + * @returns matchedFillResults Amounts filled by maker and taker of matched orders. + */ + public matchOrdersWithMaximalFill( + leftOrder: { + makerAddress: string; + takerAddress: string; + feeRecipientAddress: string; + senderAddress: string; + makerAssetAmount: BigNumber; + takerAssetAmount: BigNumber; + makerFee: BigNumber; + takerFee: BigNumber; + expirationTimeSeconds: BigNumber; + salt: BigNumber; + makerAssetData: string; + takerAssetData: string; + makerFeeAssetData: string; + takerFeeAssetData: string; + }, + rightOrder: { + makerAddress: string; + takerAddress: string; + feeRecipientAddress: string; + senderAddress: string; + makerAssetAmount: BigNumber; + takerAssetAmount: BigNumber; + makerFee: BigNumber; + takerFee: BigNumber; + expirationTimeSeconds: BigNumber; + salt: BigNumber; + makerAssetData: string; + takerAssetData: string; + makerFeeAssetData: string; + takerFeeAssetData: string; + }, + leftSignature: string, + rightSignature: string, + ): ContractTxFunctionObj<{ + left: { + makerAssetFilledAmount: BigNumber; + takerAssetFilledAmount: BigNumber; + makerFeePaid: BigNumber; + takerFeePaid: BigNumber; + protocolFeePaid: BigNumber; + }; + right: { + makerAssetFilledAmount: BigNumber; + takerAssetFilledAmount: BigNumber; + makerFeePaid: BigNumber; + takerFeePaid: BigNumber; + protocolFeePaid: BigNumber; + }; + profitInLeftMakerAsset: BigNumber; + profitInRightMakerAsset: BigNumber; + }> { + const self = (this as any) as ExchangeContract; + + assert.isString('leftSignature', leftSignature); + assert.isString('rightSignature', rightSignature); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments( + 'matchOrdersWithMaximalFill((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),bytes,bytes)', + [leftOrder, rightOrder, leftSignature, rightSignature], + ); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'matchedFillResults', - type: 'tuple', - components: [ - { - name: 'left', - type: 'tuple', - components: [ - { - name: 'makerAssetFilledAmount', - type: 'uint256', - }, - { - name: 'takerAssetFilledAmount', - type: 'uint256', - }, - { - name: 'makerFeePaid', - type: 'uint256', - }, - { - name: 'takerFeePaid', - type: 'uint256', - }, - { - name: 'protocolFeePaid', - type: 'uint256', - }, - ], - }, - { - name: 'right', - type: 'tuple', - components: [ - { - name: 'makerAssetFilledAmount', - type: 'uint256', - }, - { - name: 'takerAssetFilledAmount', - type: 'uint256', - }, - { - name: 'makerFeePaid', - type: 'uint256', - }, - { - name: 'takerFeePaid', - type: 'uint256', - }, - { - name: 'protocolFeePaid', - type: 'uint256', - }, - ], - }, - { - name: 'profitInLeftMakerAsset', - type: 'uint256', - }, - { - name: 'profitInRightMakerAsset', - type: 'uint256', - }, - ], + to: self.address, + ...txData, + data: encodedData, }, - ], - payable: true, - stateMutability: 'payable', - type: 'function', + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; }, - { - constant: true, - inputs: [ + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments( + 'matchOrdersWithMaximalFill((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),bytes,bytes)', + [leftOrder, rightOrder, leftSignature, rightSignature], + ); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'index_0', - type: 'address', + to: self.address, + ...txData, + data: encodedData, }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync( + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise<{ + left: { + makerAssetFilledAmount: BigNumber; + takerAssetFilledAmount: BigNumber; + makerFeePaid: BigNumber; + takerFeePaid: BigNumber; + protocolFeePaid: BigNumber; + }; + right: { + makerAssetFilledAmount: BigNumber; + takerAssetFilledAmount: BigNumber; + makerFeePaid: BigNumber; + takerFeePaid: BigNumber; + protocolFeePaid: BigNumber; + }; + profitInLeftMakerAsset: BigNumber; + profitInRightMakerAsset: BigNumber; + }> { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments( + 'matchOrdersWithMaximalFill((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),bytes,bytes)', + [leftOrder, rightOrder, leftSignature, rightSignature], + ); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'index_1', - type: 'address', + to: self.address, + ...callData, + data: encodedData, }, - ], - name: 'orderEpoch', - outputs: [ + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder( + 'matchOrdersWithMaximalFill((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),bytes,bytes)', + ); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<{ + left: { + makerAssetFilledAmount: BigNumber; + takerAssetFilledAmount: BigNumber; + makerFeePaid: BigNumber; + takerFeePaid: BigNumber; + protocolFeePaid: BigNumber; + }; + right: { + makerAssetFilledAmount: BigNumber; + takerAssetFilledAmount: BigNumber; + makerFeePaid: BigNumber; + takerFeePaid: BigNumber; + protocolFeePaid: BigNumber; + }; + profitInLeftMakerAsset: BigNumber; + profitInRightMakerAsset: BigNumber; + }>(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'matchOrdersWithMaximalFill((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),bytes,bytes)', + [leftOrder, rightOrder, leftSignature, rightSignature], + ); + return abiEncodedTransactionData; + }, + }; + } + public orderEpoch(index_0: string, index_1: string): ContractFunctionObj { + const self = (this as any) as ExchangeContract; + assert.isString('index_0', index_0); + assert.isString('index_1', index_1); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('orderEpoch(address,address)', [ + index_0.toLowerCase(), + index_1.toLowerCase(), + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: '', - type: 'uint256', + to: self.address, + ...callData, + data: encodedData, }, - ], - payable: false, - stateMutability: 'view', - type: 'function', + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('orderEpoch(address,address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; }, - { - constant: true, - inputs: [], - name: 'owner', - outputs: [ + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('orderEpoch(address,address)', [ + index_0.toLowerCase(), + index_1.toLowerCase(), + ]); + return abiEncodedTransactionData; + }, + }; + } + public owner(): ContractFunctionObj { + const self = (this as any) as ExchangeContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('owner()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: '', - type: 'address', + to: self.address, + ...callData, + data: encodedData, }, - ], - payable: false, - stateMutability: 'view', - type: 'function', + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('owner()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; }, - { - constant: false, - inputs: [ + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('owner()', []); + return abiEncodedTransactionData; + }, + }; + } + /** + * Approves a hash on-chain. + * After presigning a hash, the preSign signature type will become valid for that hash and signer. + * @param hash Any 32-byte hash. + */ + public preSign(hash: string): ContractTxFunctionObj { + const self = (this as any) as ExchangeContract; + assert.isString('hash', hash); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('preSign(bytes32)', [hash]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('preSign(bytes32)', [hash]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'hash', - type: 'bytes32', + to: self.address, + ...txData, + data: encodedData, }, - ], - name: 'preSign', - outputs: [], - payable: true, - stateMutability: 'payable', - type: 'function', + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; }, - { - constant: true, - inputs: [ + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('preSign(bytes32)', [hash]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'index_0', - type: 'bytes32', + to: self.address, + ...callData, + data: encodedData, }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('preSign(bytes32)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('preSign(bytes32)', [hash]); + return abiEncodedTransactionData; + }, + }; + } + public preSigned(index_0: string, index_1: string): ContractFunctionObj { + const self = (this as any) as ExchangeContract; + assert.isString('index_0', index_0); + assert.isString('index_1', index_1); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('preSigned(bytes32,address)', [ + index_0, + index_1.toLowerCase(), + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'index_1', - type: 'address', - }, - ], - name: 'preSigned', - outputs: [ + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('preSigned(bytes32,address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('preSigned(bytes32,address)', [ + index_0, + index_1.toLowerCase(), + ]); + return abiEncodedTransactionData; + }, + }; + } + public protocolFeeCollector(): ContractFunctionObj { + const self = (this as any) as ExchangeContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('protocolFeeCollector()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: '', - type: 'bool', + to: self.address, + ...callData, + data: encodedData, }, - ], - payable: false, - stateMutability: 'view', - type: 'function', + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('protocolFeeCollector()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; }, - { - constant: true, - inputs: [], - name: 'protocolFeeCollector', - outputs: [ + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('protocolFeeCollector()', []); + return abiEncodedTransactionData; + }, + }; + } + public protocolFeeMultiplier(): ContractFunctionObj { + const self = (this as any) as ExchangeContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('protocolFeeMultiplier()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: '', - type: 'address', + to: self.address, + ...callData, + data: encodedData, }, - ], - payable: false, - stateMutability: 'view', - type: 'function', + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('protocolFeeMultiplier()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; }, - { - constant: true, - inputs: [], - name: 'protocolFeeMultiplier', - outputs: [ + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('protocolFeeMultiplier()', []); + return abiEncodedTransactionData; + }, + }; + } + /** + * Registers an asset proxy to its asset proxy id. + * Once an asset proxy is registered, it cannot be unregistered. + * @param assetProxy Address of new asset proxy to register. + */ + public registerAssetProxy(assetProxy: string): ContractTxFunctionObj { + const self = (this as any) as ExchangeContract; + assert.isString('assetProxy', assetProxy); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('registerAssetProxy(address)', [ + assetProxy.toLowerCase(), + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('registerAssetProxy(address)', [ + assetProxy.toLowerCase(), + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: '', - type: 'uint256', + to: self.address, + ...txData, + data: encodedData, }, - ], - payable: false, - stateMutability: 'view', - type: 'function', + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; }, - { - constant: false, - inputs: [ + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('registerAssetProxy(address)', [ + assetProxy.toLowerCase(), + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'assetProxy', - type: 'address', + to: self.address, + ...callData, + data: encodedData, }, - ], - name: 'registerAssetProxy', - outputs: [], - payable: false, - stateMutability: 'nonpayable', - type: 'function', + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('registerAssetProxy(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; }, - { - constant: false, - inputs: [ + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('registerAssetProxy(address)', [ + assetProxy.toLowerCase(), + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Allows the owner to update the protocolFeeCollector address. + * @param updatedProtocolFeeCollector The updated protocolFeeCollector contract + * address. + */ + public setProtocolFeeCollectorAddress(updatedProtocolFeeCollector: string): ContractTxFunctionObj { + const self = (this as any) as ExchangeContract; + assert.isString('updatedProtocolFeeCollector', updatedProtocolFeeCollector); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('setProtocolFeeCollectorAddress(address)', [ + updatedProtocolFeeCollector.toLowerCase(), + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('setProtocolFeeCollectorAddress(address)', [ + updatedProtocolFeeCollector.toLowerCase(), + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'updatedProtocolFeeCollector', - type: 'address', + to: self.address, + ...txData, + data: encodedData, }, - ], - name: 'setProtocolFeeCollectorAddress', - outputs: [], - payable: false, - stateMutability: 'nonpayable', - type: 'function', + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; }, - { - constant: false, - inputs: [ + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('setProtocolFeeCollectorAddress(address)', [ + updatedProtocolFeeCollector.toLowerCase(), + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'updatedProtocolFeeMultiplier', - type: 'uint256', + to: self.address, + ...callData, + data: encodedData, }, - ], - name: 'setProtocolFeeMultiplier', - outputs: [], - payable: false, - stateMutability: 'nonpayable', - type: 'function', + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('setProtocolFeeCollectorAddress(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; }, - { - constant: false, - inputs: [ + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'setProtocolFeeCollectorAddress(address)', + [updatedProtocolFeeCollector.toLowerCase()], + ); + return abiEncodedTransactionData; + }, + }; + } + /** + * Allows the owner to update the protocol fee multiplier. + * @param updatedProtocolFeeMultiplier The updated protocol fee multiplier. + */ + public setProtocolFeeMultiplier(updatedProtocolFeeMultiplier: BigNumber): ContractTxFunctionObj { + const self = (this as any) as ExchangeContract; + assert.isBigNumber('updatedProtocolFeeMultiplier', updatedProtocolFeeMultiplier); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('setProtocolFeeMultiplier(uint256)', [ + updatedProtocolFeeMultiplier, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('setProtocolFeeMultiplier(uint256)', [ + updatedProtocolFeeMultiplier, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'validatorAddress', - type: 'address', + to: self.address, + ...txData, + data: encodedData, }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('setProtocolFeeMultiplier(uint256)', [ + updatedProtocolFeeMultiplier, + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'approval', - type: 'bool', + to: self.address, + ...callData, + data: encodedData, }, - ], - name: 'setSignatureValidatorApproval', - outputs: [], - payable: true, - stateMutability: 'payable', - type: 'function', + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('setProtocolFeeMultiplier(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; }, - { - constant: false, - inputs: [ + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('setProtocolFeeMultiplier(uint256)', [ + updatedProtocolFeeMultiplier, + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Approves/unnapproves a Validator contract to verify signatures on signer's behalf + * using the `Validator` signature type. + * @param validatorAddress Address of Validator contract. + * @param approval Approval or disapproval of Validator contract. + */ + public setSignatureValidatorApproval(validatorAddress: string, approval: boolean): ContractTxFunctionObj { + const self = (this as any) as ExchangeContract; + assert.isString('validatorAddress', validatorAddress); + assert.isBoolean('approval', approval); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('setSignatureValidatorApproval(address,bool)', [ + validatorAddress.toLowerCase(), + approval, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('setSignatureValidatorApproval(address,bool)', [ + validatorAddress.toLowerCase(), + approval, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('setSignatureValidatorApproval(address,bool)', [ + validatorAddress.toLowerCase(), + approval, + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'assetData', - type: 'bytes[]', + to: self.address, + ...callData, + data: encodedData, }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('setSignatureValidatorApproval(address,bool)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'setSignatureValidatorApproval(address,bool)', + [validatorAddress.toLowerCase(), approval], + ); + return abiEncodedTransactionData; + }, + }; + } + /** + * This function may be used to simulate any amount of transfers As they would occur through the Exchange contract. Note that this function will always revert, even if all transfers are successful. However, it may be used with eth_call or with a try/catch pattern in order to simulate the results of the transfers. + * @param assetData Array of asset details, each encoded per the AssetProxy + * contract specification. + * @param fromAddresses Array containing the `from` addresses that correspond + * with each transfer. + * @param toAddresses Array containing the `to` addresses that correspond with + * each transfer. + * @param amounts Array containing the amounts that correspond to each + * transfer. + * @returns This function does not return a value. However, it will always revert with `Error("TRANSFERS_SUCCESSFUL")` if all of the transfers were successful. + */ + public simulateDispatchTransferFromCalls( + assetData: string[], + fromAddresses: string[], + toAddresses: string[], + amounts: BigNumber[], + ): ContractTxFunctionObj { + const self = (this as any) as ExchangeContract; + assert.isArray('assetData', assetData); + assert.isArray('fromAddresses', fromAddresses); + assert.isArray('toAddresses', toAddresses); + assert.isArray('amounts', amounts); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments( + 'simulateDispatchTransferFromCalls(bytes[],address[],address[],uint256[])', + [assetData, fromAddresses, toAddresses, amounts], + ); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'fromAddresses', - type: 'address[]', + to: self.address, + ...txData, + data: encodedData, }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments( + 'simulateDispatchTransferFromCalls(bytes[],address[],address[],uint256[])', + [assetData, fromAddresses, toAddresses, amounts], + ); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'toAddresses', - type: 'address[]', + to: self.address, + ...txData, + data: encodedData, }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments( + 'simulateDispatchTransferFromCalls(bytes[],address[],address[],uint256[])', + [assetData, fromAddresses, toAddresses, amounts], + ); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'amounts', - type: 'uint256[]', + to: self.address, + ...callData, + data: encodedData, }, - ], - name: 'simulateDispatchTransferFromCalls', - outputs: [], - payable: false, - stateMutability: 'nonpayable', - type: 'function', + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder( + 'simulateDispatchTransferFromCalls(bytes[],address[],address[],uint256[])', + ); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; }, - { - constant: true, - inputs: [ + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'simulateDispatchTransferFromCalls(bytes[],address[],address[],uint256[])', + [assetData, fromAddresses, toAddresses, amounts], + ); + return abiEncodedTransactionData; + }, + }; + } + public transactionsExecuted(index_0: string): ContractFunctionObj { + const self = (this as any) as ExchangeContract; + assert.isString('index_0', index_0); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('transactionsExecuted(bytes32)', [index_0]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'index_0', - type: 'bytes32', + to: self.address, + ...callData, + data: encodedData, }, - ], - name: 'transactionsExecuted', - outputs: [ + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('transactionsExecuted(bytes32)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('transactionsExecuted(bytes32)', [ + index_0, + ]); + return abiEncodedTransactionData; + }, + }; + } + public transferOwnership(newOwner: string): ContractTxFunctionObj { + const self = (this as any) as ExchangeContract; + assert.isString('newOwner', newOwner); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: '', - type: 'bool', + to: self.address, + ...txData, + data: encodedData, }, - ], - payable: false, - stateMutability: 'view', - type: 'function', + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; }, - { - constant: false, - inputs: [ + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { - name: 'newOwner', - type: 'address', + to: self.address, + ...callData, + data: encodedData, }, - ], - name: 'transferOwnership', - outputs: [], - payable: false, - stateMutability: 'nonpayable', - type: 'function', + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('transferOwnership(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; }, - ] as ContractAbi; - return abi; + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('transferOwnership(address)', [ + newOwner.toLowerCase(), + ]); + return abiEncodedTransactionData; + }, + }; } + /** * Subscribe to an event type emitted by the Exchange contract. * @param eventName The Exchange contract event you would like to subscribe to. @@ -10970,6 +8085,12 @@ export class ExchangeContract extends BaseContract { ExchangeContract.ABI(), this._web3Wrapper, ); + ExchangeContract.ABI().forEach((item, index) => { + if (item.type === 'function') { + const methodAbi = item as MethodAbi; + this._methodABIIndex[methodAbi.name] = index; + } + }); } } diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts b/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts index fd921962fc..ba3fa9e2e0 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts @@ -1,7 +1,15 @@ // tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma enum-naming // tslint:disable:whitespace no-unbound-method no-trailing-whitespace // tslint:disable:no-unused-variable -import { BaseContract, PromiseWithTransactionHash } from '@0x/base-contract'; +import { + AwaitTransactionSuccessOpts, + ContractFunctionObj, + ContractTxFunctionObj, + SendTransactionOpts, + BaseContract, + PromiseWithTransactionHash, + methodAbiToFunctionSignature, +} from '@0x/base-contract'; import { schemas } from '@0x/json-schemas'; import { BlockParam, @@ -18,13 +26,7 @@ import { SupportedProvider, } from 'ethereum-types'; import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils'; -import { - AwaitTransactionSuccessOpts, - EventCallback, - IndexedFilterValues, - SendTransactionOpts, - SimpleContractArtifact, -} from '@0x/types'; +import { EventCallback, IndexedFilterValues, SimpleContractArtifact } from '@0x/types'; import { Web3Wrapper } from '@0x/web3-wrapper'; import { assert } from '@0x/assert'; import * as ethers from 'ethers'; @@ -38,1212 +40,7 @@ export class ForwarderContract extends BaseContract { * @ignore */ public static deployedBytecode: string | undefined; - /** - * Approves the respective proxy for a given asset to transfer tokens on the Forwarder contract's behalf. - * This is necessary because an order fee denominated in the maker asset (i.e. a percentage fee) is sent by the - * Forwarder contract to the fee recipient. - * This method needs to be called before forwarding orders of a maker asset that hasn't - * previously been approved. - */ - public approveMakerAssetProxy = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param assetData Byte array encoded for the respective asset proxy. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - assetData: string, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('assetData', assetData); - const self = (this as any) as ForwarderContract; - const encodedData = self._strictEncodeArguments('approveMakerAssetProxy(bytes)', [assetData]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.approveMakerAssetProxy.callAsync(assetData, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param assetData Byte array encoded for the respective asset proxy. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - assetData: string, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('assetData', assetData); - const self = (this as any) as ForwarderContract; - const txHashPromise = self.approveMakerAssetProxy.sendTransactionAsync(assetData, txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param assetData Byte array encoded for the respective asset proxy. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync(assetData: string, txData?: Partial | undefined): Promise { - assert.isString('assetData', assetData); - const self = (this as any) as ForwarderContract; - const encodedData = self._strictEncodeArguments('approveMakerAssetProxy(bytes)', [assetData]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param assetData Byte array encoded for the respective asset proxy. - */ - async callAsync(assetData: string, callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.isString('assetData', assetData); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ForwarderContract; - const encodedData = self._strictEncodeArguments('approveMakerAssetProxy(bytes)', [assetData]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('approveMakerAssetProxy(bytes)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param assetData Byte array encoded for the respective asset proxy. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(assetData: string): string { - assert.isString('assetData', assetData); - const self = (this as any) as ForwarderContract; - const abiEncodedTransactionData = self._strictEncodeArguments('approveMakerAssetProxy(bytes)', [assetData]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as ForwarderContract; - const abiEncoder = self._lookupAbiEncoder('approveMakerAssetProxy(bytes)'); - return abiEncoder.getSelector(); - }, - }; - /** - * Attempt to buy makerAssetBuyAmount of makerAsset by selling ETH provided with transaction. - * The Forwarder may *fill* more than makerAssetBuyAmount of the makerAsset so that it can - * pay takerFees where takerFeeAssetData == makerAssetData (i.e. percentage fees). - * Any ETH not spent will be refunded to sender. - */ - public marketBuyOrdersWithEth = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param orders Array of order specifications used containing desired - * makerAsset and WETH as takerAsset. - * @param makerAssetBuyAmount Desired amount of makerAsset to purchase. - * @param signatures Proofs that orders have been created by makers. - * @param feePercentage Percentage of WETH sold that will payed as fee to - * forwarding contract feeRecipient. - * @param feeRecipient Address that will receive ETH when orders are filled. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - makerAssetBuyAmount: BigNumber, - signatures: string[], - feePercentage: BigNumber, - feeRecipient: string, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isArray('orders', orders); - assert.isBigNumber('makerAssetBuyAmount', makerAssetBuyAmount); - assert.isArray('signatures', signatures); - assert.isBigNumber('feePercentage', feePercentage); - assert.isString('feeRecipient', feeRecipient); - const self = (this as any) as ForwarderContract; - const encodedData = self._strictEncodeArguments( - 'marketBuyOrdersWithEth((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256,bytes[],uint256,address)', - [orders, makerAssetBuyAmount, signatures, feePercentage, feeRecipient.toLowerCase()], - ); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.marketBuyOrdersWithEth.callAsync( - orders, - makerAssetBuyAmount, - signatures, - feePercentage, - feeRecipient, - txDataWithDefaults, - ); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param orders Array of order specifications used containing desired - * makerAsset and WETH as takerAsset. - * @param makerAssetBuyAmount Desired amount of makerAsset to purchase. - * @param signatures Proofs that orders have been created by makers. - * @param feePercentage Percentage of WETH sold that will payed as fee to - * forwarding contract feeRecipient. - * @param feeRecipient Address that will receive ETH when orders are filled. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - makerAssetBuyAmount: BigNumber, - signatures: string[], - feePercentage: BigNumber, - feeRecipient: string, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isArray('orders', orders); - assert.isBigNumber('makerAssetBuyAmount', makerAssetBuyAmount); - assert.isArray('signatures', signatures); - assert.isBigNumber('feePercentage', feePercentage); - assert.isString('feeRecipient', feeRecipient); - const self = (this as any) as ForwarderContract; - const txHashPromise = self.marketBuyOrdersWithEth.sendTransactionAsync( - orders, - makerAssetBuyAmount, - signatures, - feePercentage, - feeRecipient.toLowerCase(), - txData, - opts, - ); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param orders Array of order specifications used containing desired - * makerAsset and WETH as takerAsset. - * @param makerAssetBuyAmount Desired amount of makerAsset to purchase. - * @param signatures Proofs that orders have been created by makers. - * @param feePercentage Percentage of WETH sold that will payed as fee to - * forwarding contract feeRecipient. - * @param feeRecipient Address that will receive ETH when orders are filled. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - makerAssetBuyAmount: BigNumber, - signatures: string[], - feePercentage: BigNumber, - feeRecipient: string, - txData?: Partial | undefined, - ): Promise { - assert.isArray('orders', orders); - assert.isBigNumber('makerAssetBuyAmount', makerAssetBuyAmount); - assert.isArray('signatures', signatures); - assert.isBigNumber('feePercentage', feePercentage); - assert.isString('feeRecipient', feeRecipient); - const self = (this as any) as ForwarderContract; - const encodedData = self._strictEncodeArguments( - 'marketBuyOrdersWithEth((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256,bytes[],uint256,address)', - [orders, makerAssetBuyAmount, signatures, feePercentage, feeRecipient.toLowerCase()], - ); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param orders Array of order specifications used containing desired - * makerAsset and WETH as takerAsset. - * @param makerAssetBuyAmount Desired amount of makerAsset to purchase. - * @param signatures Proofs that orders have been created by makers. - * @param feePercentage Percentage of WETH sold that will payed as fee to - * forwarding contract feeRecipient. - * @param feeRecipient Address that will receive ETH when orders are filled. - * @returns wethSpentAmount Amount of WETH spent on the given set of orders.makerAssetAcquiredAmount Amount of maker asset acquired from the given set of orders.ethFeePaid Amount of ETH spent on the given forwarder fee. - */ - async callAsync( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - makerAssetBuyAmount: BigNumber, - signatures: string[], - feePercentage: BigNumber, - feeRecipient: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise<[BigNumber, BigNumber, BigNumber]> { - assert.isArray('orders', orders); - assert.isBigNumber('makerAssetBuyAmount', makerAssetBuyAmount); - assert.isArray('signatures', signatures); - assert.isBigNumber('feePercentage', feePercentage); - assert.isString('feeRecipient', feeRecipient); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ForwarderContract; - const encodedData = self._strictEncodeArguments( - 'marketBuyOrdersWithEth((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256,bytes[],uint256,address)', - [orders, makerAssetBuyAmount, signatures, feePercentage, feeRecipient.toLowerCase()], - ); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder( - 'marketBuyOrdersWithEth((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256,bytes[],uint256,address)', - ); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue<[BigNumber, BigNumber, BigNumber]>(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param orders Array of order specifications used containing desired - * makerAsset and WETH as takerAsset. - * @param makerAssetBuyAmount Desired amount of makerAsset to purchase. - * @param signatures Proofs that orders have been created by makers. - * @param feePercentage Percentage of WETH sold that will payed as fee to - * forwarding contract feeRecipient. - * @param feeRecipient Address that will receive ETH when orders are filled. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - makerAssetBuyAmount: BigNumber, - signatures: string[], - feePercentage: BigNumber, - feeRecipient: string, - ): string { - assert.isArray('orders', orders); - assert.isBigNumber('makerAssetBuyAmount', makerAssetBuyAmount); - assert.isArray('signatures', signatures); - assert.isBigNumber('feePercentage', feePercentage); - assert.isString('feeRecipient', feeRecipient); - const self = (this as any) as ForwarderContract; - const abiEncodedTransactionData = self._strictEncodeArguments( - 'marketBuyOrdersWithEth((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256,bytes[],uint256,address)', - [orders, makerAssetBuyAmount, signatures, feePercentage, feeRecipient.toLowerCase()], - ); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as ForwarderContract; - const abiEncoder = self._lookupAbiEncoder( - 'marketBuyOrdersWithEth((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256,bytes[],uint256,address)', - ); - return abiEncoder.getSelector(); - }, - }; - /** - * Purchases as much of orders' makerAssets as possible by selling as much of the ETH value sent - * as possible, accounting for order and forwarder fees. - */ - public marketSellOrdersWithEth = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param orders Array of order specifications used containing desired - * makerAsset and WETH as takerAsset. - * @param signatures Proofs that orders have been created by makers. - * @param feePercentage Percentage of WETH sold that will payed as fee to - * forwarding contract feeRecipient. - * @param feeRecipient Address that will receive ETH when orders are filled. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - signatures: string[], - feePercentage: BigNumber, - feeRecipient: string, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isArray('orders', orders); - assert.isArray('signatures', signatures); - assert.isBigNumber('feePercentage', feePercentage); - assert.isString('feeRecipient', feeRecipient); - const self = (this as any) as ForwarderContract; - const encodedData = self._strictEncodeArguments( - 'marketSellOrdersWithEth((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],bytes[],uint256,address)', - [orders, signatures, feePercentage, feeRecipient.toLowerCase()], - ); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.marketSellOrdersWithEth.callAsync( - orders, - signatures, - feePercentage, - feeRecipient, - txDataWithDefaults, - ); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param orders Array of order specifications used containing desired - * makerAsset and WETH as takerAsset. - * @param signatures Proofs that orders have been created by makers. - * @param feePercentage Percentage of WETH sold that will payed as fee to - * forwarding contract feeRecipient. - * @param feeRecipient Address that will receive ETH when orders are filled. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - signatures: string[], - feePercentage: BigNumber, - feeRecipient: string, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isArray('orders', orders); - assert.isArray('signatures', signatures); - assert.isBigNumber('feePercentage', feePercentage); - assert.isString('feeRecipient', feeRecipient); - const self = (this as any) as ForwarderContract; - const txHashPromise = self.marketSellOrdersWithEth.sendTransactionAsync( - orders, - signatures, - feePercentage, - feeRecipient.toLowerCase(), - txData, - opts, - ); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param orders Array of order specifications used containing desired - * makerAsset and WETH as takerAsset. - * @param signatures Proofs that orders have been created by makers. - * @param feePercentage Percentage of WETH sold that will payed as fee to - * forwarding contract feeRecipient. - * @param feeRecipient Address that will receive ETH when orders are filled. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - signatures: string[], - feePercentage: BigNumber, - feeRecipient: string, - txData?: Partial | undefined, - ): Promise { - assert.isArray('orders', orders); - assert.isArray('signatures', signatures); - assert.isBigNumber('feePercentage', feePercentage); - assert.isString('feeRecipient', feeRecipient); - const self = (this as any) as ForwarderContract; - const encodedData = self._strictEncodeArguments( - 'marketSellOrdersWithEth((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],bytes[],uint256,address)', - [orders, signatures, feePercentage, feeRecipient.toLowerCase()], - ); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param orders Array of order specifications used containing desired - * makerAsset and WETH as takerAsset. - * @param signatures Proofs that orders have been created by makers. - * @param feePercentage Percentage of WETH sold that will payed as fee to - * forwarding contract feeRecipient. - * @param feeRecipient Address that will receive ETH when orders are filled. - * @returns wethSpentAmount Amount of WETH spent on the given set of orders.makerAssetAcquiredAmount Amount of maker asset acquired from the given set of orders.ethFeePaid Amount of ETH spent on the given forwarder fee. - */ - async callAsync( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - signatures: string[], - feePercentage: BigNumber, - feeRecipient: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise<[BigNumber, BigNumber, BigNumber]> { - assert.isArray('orders', orders); - assert.isArray('signatures', signatures); - assert.isBigNumber('feePercentage', feePercentage); - assert.isString('feeRecipient', feeRecipient); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ForwarderContract; - const encodedData = self._strictEncodeArguments( - 'marketSellOrdersWithEth((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],bytes[],uint256,address)', - [orders, signatures, feePercentage, feeRecipient.toLowerCase()], - ); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder( - 'marketSellOrdersWithEth((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],bytes[],uint256,address)', - ); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue<[BigNumber, BigNumber, BigNumber]>(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param orders Array of order specifications used containing desired - * makerAsset and WETH as takerAsset. - * @param signatures Proofs that orders have been created by makers. - * @param feePercentage Percentage of WETH sold that will payed as fee to - * forwarding contract feeRecipient. - * @param feeRecipient Address that will receive ETH when orders are filled. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - makerFeeAssetData: string; - takerFeeAssetData: string; - }>, - signatures: string[], - feePercentage: BigNumber, - feeRecipient: string, - ): string { - assert.isArray('orders', orders); - assert.isArray('signatures', signatures); - assert.isBigNumber('feePercentage', feePercentage); - assert.isString('feeRecipient', feeRecipient); - const self = (this as any) as ForwarderContract; - const abiEncodedTransactionData = self._strictEncodeArguments( - 'marketSellOrdersWithEth((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],bytes[],uint256,address)', - [orders, signatures, feePercentage, feeRecipient.toLowerCase()], - ); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as ForwarderContract; - const abiEncoder = self._lookupAbiEncoder( - 'marketSellOrdersWithEth((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],bytes[],uint256,address)', - ); - return abiEncoder.getSelector(); - }, - }; - public owner = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ForwarderContract; - const encodedData = self._strictEncodeArguments('owner()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('owner()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public transferOwnership = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - newOwner: string, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('newOwner', newOwner); - const self = (this as any) as ForwarderContract; - const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.transferOwnership.callAsync(newOwner, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - newOwner: string, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('newOwner', newOwner); - const self = (this as any) as ForwarderContract; - const txHashPromise = self.transferOwnership.sendTransactionAsync(newOwner.toLowerCase(), txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync(newOwner: string, txData?: Partial | undefined): Promise { - assert.isString('newOwner', newOwner); - const self = (this as any) as ForwarderContract; - const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(newOwner: string, callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.isString('newOwner', newOwner); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ForwarderContract; - const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('transferOwnership(address)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(newOwner: string): string { - assert.isString('newOwner', newOwner); - const self = (this as any) as ForwarderContract; - const abiEncodedTransactionData = self._strictEncodeArguments('transferOwnership(address)', [ - newOwner.toLowerCase(), - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as ForwarderContract; - const abiEncoder = self._lookupAbiEncoder('transferOwnership(address)'); - return abiEncoder.getSelector(); - }, - }; - /** - * Withdraws assets from this contract. The contract formerly required a ZRX balance in order - * to function optimally, and this function allows the ZRX to be withdrawn by owner. - * It may also be used to withdraw assets that were accidentally sent to this contract. - */ - public withdrawAsset = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param assetData Byte array encoded for the respective asset proxy. - * @param amount Amount of ERC20 token to withdraw. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - assetData: string, - amount: BigNumber, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('assetData', assetData); - assert.isBigNumber('amount', amount); - const self = (this as any) as ForwarderContract; - const encodedData = self._strictEncodeArguments('withdrawAsset(bytes,uint256)', [assetData, amount]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.withdrawAsset.callAsync(assetData, amount, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param assetData Byte array encoded for the respective asset proxy. - * @param amount Amount of ERC20 token to withdraw. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - assetData: string, - amount: BigNumber, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('assetData', assetData); - assert.isBigNumber('amount', amount); - const self = (this as any) as ForwarderContract; - const txHashPromise = self.withdrawAsset.sendTransactionAsync(assetData, amount, txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param assetData Byte array encoded for the respective asset proxy. - * @param amount Amount of ERC20 token to withdraw. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - assetData: string, - amount: BigNumber, - txData?: Partial | undefined, - ): Promise { - assert.isString('assetData', assetData); - assert.isBigNumber('amount', amount); - const self = (this as any) as ForwarderContract; - const encodedData = self._strictEncodeArguments('withdrawAsset(bytes,uint256)', [assetData, amount]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param assetData Byte array encoded for the respective asset proxy. - * @param amount Amount of ERC20 token to withdraw. - */ - async callAsync( - assetData: string, - amount: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('assetData', assetData); - assert.isBigNumber('amount', amount); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ForwarderContract; - const encodedData = self._strictEncodeArguments('withdrawAsset(bytes,uint256)', [assetData, amount]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('withdrawAsset(bytes,uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param assetData Byte array encoded for the respective asset proxy. - * @param amount Amount of ERC20 token to withdraw. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(assetData: string, amount: BigNumber): string { - assert.isString('assetData', assetData); - assert.isBigNumber('amount', amount); - const self = (this as any) as ForwarderContract; - const abiEncodedTransactionData = self._strictEncodeArguments('withdrawAsset(bytes,uint256)', [ - assetData, - amount, - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as ForwarderContract; - const abiEncoder = self._lookupAbiEncoder('withdrawAsset(bytes,uint256)'); - return abiEncoder.getSelector(); - }, - }; + private _methodABIIndex: { [name: string]: number } = {}; public static async deployFrom0xArtifactAsync( artifact: ContractArtifact | SimpleContractArtifact, supportedProvider: SupportedProvider, @@ -1613,6 +410,742 @@ export class ForwarderContract extends BaseContract { ] as ContractAbi; return abi; } + + public getFunctionSignature(methodName: string): string { + const index = this._methodABIIndex[methodName]; + const methodAbi = ForwarderContract.ABI()[index] as MethodAbi; + const functionSignature = methodAbiToFunctionSignature(methodAbi); + return functionSignature; + } + public getABIDecodedTransactionData(methodName: string, callData: string): T { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as ForwarderContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + const abiDecodedCallData = abiEncoder.strictDecode(callData); + return abiDecodedCallData; + } + public getABIDecodedReturnData(methodName: string, callData: string): T { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as ForwarderContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + const abiDecodedCallData = abiEncoder.strictDecodeReturnValue(callData); + return abiDecodedCallData; + } + public getSelector(methodName: string): string { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as ForwarderContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + return abiEncoder.getSelector(); + } + + /** + * Approves the respective proxy for a given asset to transfer tokens on the Forwarder contract's behalf. + * This is necessary because an order fee denominated in the maker asset (i.e. a percentage fee) is sent by the + * Forwarder contract to the fee recipient. + * This method needs to be called before forwarding orders of a maker asset that hasn't + * previously been approved. + * @param assetData Byte array encoded for the respective asset proxy. + */ + public approveMakerAssetProxy(assetData: string): ContractTxFunctionObj { + const self = (this as any) as ForwarderContract; + assert.isString('assetData', assetData); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('approveMakerAssetProxy(bytes)', [assetData]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('approveMakerAssetProxy(bytes)', [assetData]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('approveMakerAssetProxy(bytes)', [assetData]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('approveMakerAssetProxy(bytes)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('approveMakerAssetProxy(bytes)', [ + assetData, + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Attempt to buy makerAssetBuyAmount of makerAsset by selling ETH provided with transaction. + * The Forwarder may *fill* more than makerAssetBuyAmount of the makerAsset so that it can + * pay takerFees where takerFeeAssetData == makerAssetData (i.e. percentage fees). + * Any ETH not spent will be refunded to sender. + * @param orders Array of order specifications used containing desired + * makerAsset and WETH as takerAsset. + * @param makerAssetBuyAmount Desired amount of makerAsset to purchase. + * @param signatures Proofs that orders have been created by makers. + * @param feePercentage Percentage of WETH sold that will payed as fee to + * forwarding contract feeRecipient. + * @param feeRecipient Address that will receive ETH when orders are filled. + * @returns wethSpentAmount Amount of WETH spent on the given set of orders.makerAssetAcquiredAmount Amount of maker asset acquired from the given set of orders.ethFeePaid Amount of ETH spent on the given forwarder fee. + */ + public marketBuyOrdersWithEth( + orders: Array<{ + makerAddress: string; + takerAddress: string; + feeRecipientAddress: string; + senderAddress: string; + makerAssetAmount: BigNumber; + takerAssetAmount: BigNumber; + makerFee: BigNumber; + takerFee: BigNumber; + expirationTimeSeconds: BigNumber; + salt: BigNumber; + makerAssetData: string; + takerAssetData: string; + makerFeeAssetData: string; + takerFeeAssetData: string; + }>, + makerAssetBuyAmount: BigNumber, + signatures: string[], + feePercentage: BigNumber, + feeRecipient: string, + ): ContractTxFunctionObj<[BigNumber, BigNumber, BigNumber]> { + const self = (this as any) as ForwarderContract; + assert.isArray('orders', orders); + assert.isBigNumber('makerAssetBuyAmount', makerAssetBuyAmount); + assert.isArray('signatures', signatures); + assert.isBigNumber('feePercentage', feePercentage); + assert.isString('feeRecipient', feeRecipient); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments( + 'marketBuyOrdersWithEth((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256,bytes[],uint256,address)', + [orders, makerAssetBuyAmount, signatures, feePercentage, feeRecipient.toLowerCase()], + ); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments( + 'marketBuyOrdersWithEth((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256,bytes[],uint256,address)', + [orders, makerAssetBuyAmount, signatures, feePercentage, feeRecipient.toLowerCase()], + ); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync( + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise<[BigNumber, BigNumber, BigNumber]> { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments( + 'marketBuyOrdersWithEth((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256,bytes[],uint256,address)', + [orders, makerAssetBuyAmount, signatures, feePercentage, feeRecipient.toLowerCase()], + ); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder( + 'marketBuyOrdersWithEth((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256,bytes[],uint256,address)', + ); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<[BigNumber, BigNumber, BigNumber]>(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'marketBuyOrdersWithEth((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256,bytes[],uint256,address)', + [orders, makerAssetBuyAmount, signatures, feePercentage, feeRecipient.toLowerCase()], + ); + return abiEncodedTransactionData; + }, + }; + } + /** + * Purchases as much of orders' makerAssets as possible by selling as much of the ETH value sent + * as possible, accounting for order and forwarder fees. + * @param orders Array of order specifications used containing desired + * makerAsset and WETH as takerAsset. + * @param signatures Proofs that orders have been created by makers. + * @param feePercentage Percentage of WETH sold that will payed as fee to + * forwarding contract feeRecipient. + * @param feeRecipient Address that will receive ETH when orders are filled. + * @returns wethSpentAmount Amount of WETH spent on the given set of orders.makerAssetAcquiredAmount Amount of maker asset acquired from the given set of orders.ethFeePaid Amount of ETH spent on the given forwarder fee. + */ + public marketSellOrdersWithEth( + orders: Array<{ + makerAddress: string; + takerAddress: string; + feeRecipientAddress: string; + senderAddress: string; + makerAssetAmount: BigNumber; + takerAssetAmount: BigNumber; + makerFee: BigNumber; + takerFee: BigNumber; + expirationTimeSeconds: BigNumber; + salt: BigNumber; + makerAssetData: string; + takerAssetData: string; + makerFeeAssetData: string; + takerFeeAssetData: string; + }>, + signatures: string[], + feePercentage: BigNumber, + feeRecipient: string, + ): ContractTxFunctionObj<[BigNumber, BigNumber, BigNumber]> { + const self = (this as any) as ForwarderContract; + assert.isArray('orders', orders); + assert.isArray('signatures', signatures); + assert.isBigNumber('feePercentage', feePercentage); + assert.isString('feeRecipient', feeRecipient); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments( + 'marketSellOrdersWithEth((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],bytes[],uint256,address)', + [orders, signatures, feePercentage, feeRecipient.toLowerCase()], + ); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments( + 'marketSellOrdersWithEth((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],bytes[],uint256,address)', + [orders, signatures, feePercentage, feeRecipient.toLowerCase()], + ); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync( + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise<[BigNumber, BigNumber, BigNumber]> { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments( + 'marketSellOrdersWithEth((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],bytes[],uint256,address)', + [orders, signatures, feePercentage, feeRecipient.toLowerCase()], + ); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder( + 'marketSellOrdersWithEth((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],bytes[],uint256,address)', + ); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<[BigNumber, BigNumber, BigNumber]>(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'marketSellOrdersWithEth((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],bytes[],uint256,address)', + [orders, signatures, feePercentage, feeRecipient.toLowerCase()], + ); + return abiEncodedTransactionData; + }, + }; + } + public owner(): ContractFunctionObj { + const self = (this as any) as ForwarderContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('owner()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('owner()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('owner()', []); + return abiEncodedTransactionData; + }, + }; + } + public transferOwnership(newOwner: string): ContractTxFunctionObj { + const self = (this as any) as ForwarderContract; + assert.isString('newOwner', newOwner); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('transferOwnership(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('transferOwnership(address)', [ + newOwner.toLowerCase(), + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Withdraws assets from this contract. The contract formerly required a ZRX balance in order + * to function optimally, and this function allows the ZRX to be withdrawn by owner. + * It may also be used to withdraw assets that were accidentally sent to this contract. + * @param assetData Byte array encoded for the respective asset proxy. + * @param amount Amount of ERC20 token to withdraw. + */ + public withdrawAsset(assetData: string, amount: BigNumber): ContractTxFunctionObj { + const self = (this as any) as ForwarderContract; + assert.isString('assetData', assetData); + assert.isBigNumber('amount', amount); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('withdrawAsset(bytes,uint256)', [assetData, amount]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('withdrawAsset(bytes,uint256)', [assetData, amount]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('withdrawAsset(bytes,uint256)', [assetData, amount]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('withdrawAsset(bytes,uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('withdrawAsset(bytes,uint256)', [ + assetData, + amount, + ]); + return abiEncodedTransactionData; + }, + }; + } + constructor( address: string, supportedProvider: SupportedProvider, @@ -1630,6 +1163,12 @@ export class ForwarderContract extends BaseContract { deployedBytecode, ); classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']); + ForwarderContract.ABI().forEach((item, index) => { + if (item.type === 'function') { + const methodAbi = item as MethodAbi; + this._methodABIIndex[methodAbi.name] = index; + } + }); } } diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/i_asset_proxy.ts b/packages/abi-gen-wrappers/src/generated-wrappers/i_asset_proxy.ts index 1862f8c11a..57ec1480df 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/i_asset_proxy.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/i_asset_proxy.ts @@ -1,7 +1,15 @@ // tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma enum-naming // tslint:disable:whitespace no-unbound-method no-trailing-whitespace // tslint:disable:no-unused-variable -import { BaseContract, PromiseWithTransactionHash } from '@0x/base-contract'; +import { + AwaitTransactionSuccessOpts, + ContractFunctionObj, + ContractTxFunctionObj, + SendTransactionOpts, + BaseContract, + PromiseWithTransactionHash, + methodAbiToFunctionSignature, +} from '@0x/base-contract'; import { schemas } from '@0x/json-schemas'; import { BlockParam, @@ -18,13 +26,7 @@ import { SupportedProvider, } from 'ethereum-types'; import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils'; -import { - AwaitTransactionSuccessOpts, - EventCallback, - IndexedFilterValues, - SendTransactionOpts, - SimpleContractArtifact, -} from '@0x/types'; +import { EventCallback, IndexedFilterValues, SimpleContractArtifact } from '@0x/types'; import { Web3Wrapper } from '@0x/web3-wrapper'; import { assert } from '@0x/assert'; import * as ethers from 'ethers'; @@ -38,275 +40,7 @@ export class IAssetProxyContract extends BaseContract { * @ignore */ public static deployedBytecode: string | undefined; - /** - * Transfers assets. Either succeeds or throws. - */ - public transferFrom = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param assetData Byte array encoded for the respective asset proxy. - * @param from Address to transfer asset from. - * @param to Address to transfer asset to. - * @param amount Amount of asset to transfer. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - assetData: string, - from: string, - to: string, - amount: BigNumber, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('assetData', assetData); - assert.isString('from', from); - assert.isString('to', to); - assert.isBigNumber('amount', amount); - const self = (this as any) as IAssetProxyContract; - const encodedData = self._strictEncodeArguments('transferFrom(bytes,address,address,uint256)', [ - assetData, - from.toLowerCase(), - to.toLowerCase(), - amount, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.transferFrom.callAsync(assetData, from, to, amount, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param assetData Byte array encoded for the respective asset proxy. - * @param from Address to transfer asset from. - * @param to Address to transfer asset to. - * @param amount Amount of asset to transfer. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - assetData: string, - from: string, - to: string, - amount: BigNumber, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('assetData', assetData); - assert.isString('from', from); - assert.isString('to', to); - assert.isBigNumber('amount', amount); - const self = (this as any) as IAssetProxyContract; - const txHashPromise = self.transferFrom.sendTransactionAsync( - assetData, - from.toLowerCase(), - to.toLowerCase(), - amount, - txData, - opts, - ); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param assetData Byte array encoded for the respective asset proxy. - * @param from Address to transfer asset from. - * @param to Address to transfer asset to. - * @param amount Amount of asset to transfer. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - assetData: string, - from: string, - to: string, - amount: BigNumber, - txData?: Partial | undefined, - ): Promise { - assert.isString('assetData', assetData); - assert.isString('from', from); - assert.isString('to', to); - assert.isBigNumber('amount', amount); - const self = (this as any) as IAssetProxyContract; - const encodedData = self._strictEncodeArguments('transferFrom(bytes,address,address,uint256)', [ - assetData, - from.toLowerCase(), - to.toLowerCase(), - amount, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param assetData Byte array encoded for the respective asset proxy. - * @param from Address to transfer asset from. - * @param to Address to transfer asset to. - * @param amount Amount of asset to transfer. - */ - async callAsync( - assetData: string, - from: string, - to: string, - amount: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('assetData', assetData); - assert.isString('from', from); - assert.isString('to', to); - assert.isBigNumber('amount', amount); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as IAssetProxyContract; - const encodedData = self._strictEncodeArguments('transferFrom(bytes,address,address,uint256)', [ - assetData, - from.toLowerCase(), - to.toLowerCase(), - amount, - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('transferFrom(bytes,address,address,uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param assetData Byte array encoded for the respective asset proxy. - * @param from Address to transfer asset from. - * @param to Address to transfer asset to. - * @param amount Amount of asset to transfer. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(assetData: string, from: string, to: string, amount: BigNumber): string { - assert.isString('assetData', assetData); - assert.isString('from', from); - assert.isString('to', to); - assert.isBigNumber('amount', amount); - const self = (this as any) as IAssetProxyContract; - const abiEncodedTransactionData = self._strictEncodeArguments( - 'transferFrom(bytes,address,address,uint256)', - [assetData, from.toLowerCase(), to.toLowerCase(), amount], - ); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as IAssetProxyContract; - const abiEncoder = self._lookupAbiEncoder('transferFrom(bytes,address,address,uint256)'); - return abiEncoder.getSelector(); - }, - }; - /** - * Gets the proxy id associated with the proxy address. - */ - public getProxyId = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @returns Proxy id. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as IAssetProxyContract; - const encodedData = self._strictEncodeArguments('getProxyId()', []); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('getProxyId()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; + private _methodABIIndex: { [name: string]: number } = {}; public static async deployFrom0xArtifactAsync( artifact: ContractArtifact | SimpleContractArtifact, supportedProvider: SupportedProvider, @@ -419,6 +153,210 @@ export class IAssetProxyContract extends BaseContract { ] as ContractAbi; return abi; } + + public getFunctionSignature(methodName: string): string { + const index = this._methodABIIndex[methodName]; + const methodAbi = IAssetProxyContract.ABI()[index] as MethodAbi; + const functionSignature = methodAbiToFunctionSignature(methodAbi); + return functionSignature; + } + public getABIDecodedTransactionData(methodName: string, callData: string): T { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as IAssetProxyContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + const abiDecodedCallData = abiEncoder.strictDecode(callData); + return abiDecodedCallData; + } + public getABIDecodedReturnData(methodName: string, callData: string): T { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as IAssetProxyContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + const abiDecodedCallData = abiEncoder.strictDecodeReturnValue(callData); + return abiDecodedCallData; + } + public getSelector(methodName: string): string { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as IAssetProxyContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + return abiEncoder.getSelector(); + } + + /** + * Transfers assets. Either succeeds or throws. + * @param assetData Byte array encoded for the respective asset proxy. + * @param from Address to transfer asset from. + * @param to Address to transfer asset to. + * @param amount Amount of asset to transfer. + */ + public transferFrom(assetData: string, from: string, to: string, amount: BigNumber): ContractTxFunctionObj { + const self = (this as any) as IAssetProxyContract; + assert.isString('assetData', assetData); + assert.isString('from', from); + assert.isString('to', to); + assert.isBigNumber('amount', amount); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('transferFrom(bytes,address,address,uint256)', [ + assetData, + from.toLowerCase(), + to.toLowerCase(), + amount, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('transferFrom(bytes,address,address,uint256)', [ + assetData, + from.toLowerCase(), + to.toLowerCase(), + amount, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('transferFrom(bytes,address,address,uint256)', [ + assetData, + from.toLowerCase(), + to.toLowerCase(), + amount, + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('transferFrom(bytes,address,address,uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'transferFrom(bytes,address,address,uint256)', + [assetData, from.toLowerCase(), to.toLowerCase(), amount], + ); + return abiEncodedTransactionData; + }, + }; + } + /** + * Gets the proxy id associated with the proxy address. + * @returns Proxy id. + */ + public getProxyId(): ContractFunctionObj { + const self = (this as any) as IAssetProxyContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('getProxyId()', []); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('getProxyId()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('getProxyId()', []); + return abiEncodedTransactionData; + }, + }; + } + constructor( address: string, supportedProvider: SupportedProvider, @@ -436,6 +374,12 @@ export class IAssetProxyContract extends BaseContract { deployedBytecode, ); classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']); + IAssetProxyContract.ABI().forEach((item, index) => { + if (item.type === 'function') { + const methodAbi = item as MethodAbi; + this._methodABIIndex[methodAbi.name] = index; + } + }); } } diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/i_validator.ts b/packages/abi-gen-wrappers/src/generated-wrappers/i_validator.ts index 1f97f3f316..b0120f9670 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/i_validator.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/i_validator.ts @@ -1,7 +1,15 @@ // tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma enum-naming // tslint:disable:whitespace no-unbound-method no-trailing-whitespace // tslint:disable:no-unused-variable -import { BaseContract, PromiseWithTransactionHash } from '@0x/base-contract'; +import { + AwaitTransactionSuccessOpts, + ContractFunctionObj, + ContractTxFunctionObj, + SendTransactionOpts, + BaseContract, + PromiseWithTransactionHash, + methodAbiToFunctionSignature, +} from '@0x/base-contract'; import { schemas } from '@0x/json-schemas'; import { BlockParam, @@ -18,13 +26,7 @@ import { SupportedProvider, } from 'ethereum-types'; import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils'; -import { - AwaitTransactionSuccessOpts, - EventCallback, - IndexedFilterValues, - SendTransactionOpts, - SimpleContractArtifact, -} from '@0x/types'; +import { EventCallback, IndexedFilterValues, SimpleContractArtifact } from '@0x/types'; import { Web3Wrapper } from '@0x/web3-wrapper'; import { assert } from '@0x/assert'; import * as ethers from 'ethers'; @@ -38,69 +40,7 @@ export class IValidatorContract extends BaseContract { * @ignore */ public static deployedBytecode: string | undefined; - /** - * Verifies that a signature is valid. - */ - public isValidSignature = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param hash Message hash that is signed. - * @param signerAddress Address that should have signed the given hash. - * @param signature Proof of signing. - * @returns Magic bytes4 value if the signature is valid. Magic value is bytes4(keccak256("isValidValidatorSignature(address,bytes32,address,bytes)")) - */ - async callAsync( - hash: string, - signerAddress: string, - signature: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('hash', hash); - assert.isString('signerAddress', signerAddress); - assert.isString('signature', signature); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as IValidatorContract; - const encodedData = self._strictEncodeArguments('isValidSignature(bytes32,address,bytes)', [ - hash, - signerAddress.toLowerCase(), - signature, - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('isValidSignature(bytes32,address,bytes)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; + private _methodABIIndex: { [name: string]: number } = {}; public static async deployFrom0xArtifactAsync( artifact: ContractArtifact | SimpleContractArtifact, supportedProvider: SupportedProvider, @@ -200,6 +140,99 @@ export class IValidatorContract extends BaseContract { ] as ContractAbi; return abi; } + + public getFunctionSignature(methodName: string): string { + const index = this._methodABIIndex[methodName]; + const methodAbi = IValidatorContract.ABI()[index] as MethodAbi; + const functionSignature = methodAbiToFunctionSignature(methodAbi); + return functionSignature; + } + public getABIDecodedTransactionData(methodName: string, callData: string): T { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as IValidatorContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + const abiDecodedCallData = abiEncoder.strictDecode(callData); + return abiDecodedCallData; + } + public getABIDecodedReturnData(methodName: string, callData: string): T { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as IValidatorContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + const abiDecodedCallData = abiEncoder.strictDecodeReturnValue(callData); + return abiDecodedCallData; + } + public getSelector(methodName: string): string { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as IValidatorContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + return abiEncoder.getSelector(); + } + + /** + * Verifies that a signature is valid. + * @param hash Message hash that is signed. + * @param signerAddress Address that should have signed the given hash. + * @param signature Proof of signing. + * @returns Magic bytes4 value if the signature is valid. Magic value is bytes4(keccak256("isValidValidatorSignature(address,bytes32,address,bytes)")) + */ + public isValidSignature(hash: string, signerAddress: string, signature: string): ContractFunctionObj { + const self = (this as any) as IValidatorContract; + assert.isString('hash', hash); + assert.isString('signerAddress', signerAddress); + assert.isString('signature', signature); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('isValidSignature(bytes32,address,bytes)', [ + hash, + signerAddress.toLowerCase(), + signature, + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('isValidSignature(bytes32,address,bytes)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'isValidSignature(bytes32,address,bytes)', + [hash, signerAddress.toLowerCase(), signature], + ); + return abiEncodedTransactionData; + }, + }; + } + constructor( address: string, supportedProvider: SupportedProvider, @@ -217,6 +250,12 @@ export class IValidatorContract extends BaseContract { deployedBytecode, ); classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']); + IValidatorContract.ABI().forEach((item, index) => { + if (item.type === 'function') { + const methodAbi = item as MethodAbi; + this._methodABIIndex[methodAbi.name] = index; + } + }); } } diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/i_wallet.ts b/packages/abi-gen-wrappers/src/generated-wrappers/i_wallet.ts index 000d0798b6..2c58f37459 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/i_wallet.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/i_wallet.ts @@ -1,7 +1,15 @@ // tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma enum-naming // tslint:disable:whitespace no-unbound-method no-trailing-whitespace // tslint:disable:no-unused-variable -import { BaseContract, PromiseWithTransactionHash } from '@0x/base-contract'; +import { + AwaitTransactionSuccessOpts, + ContractFunctionObj, + ContractTxFunctionObj, + SendTransactionOpts, + BaseContract, + PromiseWithTransactionHash, + methodAbiToFunctionSignature, +} from '@0x/base-contract'; import { schemas } from '@0x/json-schemas'; import { BlockParam, @@ -18,13 +26,7 @@ import { SupportedProvider, } from 'ethereum-types'; import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils'; -import { - AwaitTransactionSuccessOpts, - EventCallback, - IndexedFilterValues, - SendTransactionOpts, - SimpleContractArtifact, -} from '@0x/types'; +import { EventCallback, IndexedFilterValues, SimpleContractArtifact } from '@0x/types'; import { Web3Wrapper } from '@0x/web3-wrapper'; import { assert } from '@0x/assert'; import * as ethers from 'ethers'; @@ -38,62 +40,7 @@ export class IWalletContract extends BaseContract { * @ignore */ public static deployedBytecode: string | undefined; - /** - * Validates a hash with the `Wallet` signature type. - */ - public isValidSignature = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param hash Message hash that is signed. - * @param signature Proof of signing. - * @returns magicValue `bytes4(0xb0671381)` if the signature check succeeds. - */ - async callAsync( - hash: string, - signature: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('hash', hash); - assert.isString('signature', signature); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as IWalletContract; - const encodedData = self._strictEncodeArguments('isValidSignature(bytes32,bytes)', [hash, signature]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('isValidSignature(bytes32,bytes)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; + private _methodABIIndex: { [name: string]: number } = {}; public static async deployFrom0xArtifactAsync( artifact: ContractArtifact | SimpleContractArtifact, supportedProvider: SupportedProvider, @@ -189,6 +136,93 @@ export class IWalletContract extends BaseContract { ] as ContractAbi; return abi; } + + public getFunctionSignature(methodName: string): string { + const index = this._methodABIIndex[methodName]; + const methodAbi = IWalletContract.ABI()[index] as MethodAbi; + const functionSignature = methodAbiToFunctionSignature(methodAbi); + return functionSignature; + } + public getABIDecodedTransactionData(methodName: string, callData: string): T { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as IWalletContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + const abiDecodedCallData = abiEncoder.strictDecode(callData); + return abiDecodedCallData; + } + public getABIDecodedReturnData(methodName: string, callData: string): T { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as IWalletContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + const abiDecodedCallData = abiEncoder.strictDecodeReturnValue(callData); + return abiDecodedCallData; + } + public getSelector(methodName: string): string { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as IWalletContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + return abiEncoder.getSelector(); + } + + /** + * Validates a hash with the `Wallet` signature type. + * @param hash Message hash that is signed. + * @param signature Proof of signing. + * @returns magicValue `bytes4(0xb0671381)` if the signature check succeeds. + */ + public isValidSignature(hash: string, signature: string): ContractFunctionObj { + const self = (this as any) as IWalletContract; + assert.isString('hash', hash); + assert.isString('signature', signature); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('isValidSignature(bytes32,bytes)', [hash, signature]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('isValidSignature(bytes32,bytes)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('isValidSignature(bytes32,bytes)', [ + hash, + signature, + ]); + return abiEncodedTransactionData; + }, + }; + } + constructor( address: string, supportedProvider: SupportedProvider, @@ -206,6 +240,12 @@ export class IWalletContract extends BaseContract { deployedBytecode, ); classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']); + IWalletContract.ABI().forEach((item, index) => { + if (item.type === 'function') { + const methodAbi = item as MethodAbi; + this._methodABIIndex[methodAbi.name] = index; + } + }); } } diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/multi_asset_proxy.ts b/packages/abi-gen-wrappers/src/generated-wrappers/multi_asset_proxy.ts index 752c5eba6e..45dc76173e 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/multi_asset_proxy.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/multi_asset_proxy.ts @@ -1,7 +1,16 @@ // tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma enum-naming // tslint:disable:whitespace no-unbound-method no-trailing-whitespace // tslint:disable:no-unused-variable -import { BaseContract, SubscriptionManager, PromiseWithTransactionHash } from '@0x/base-contract'; +import { + AwaitTransactionSuccessOpts, + ContractFunctionObj, + ContractTxFunctionObj, + SendTransactionOpts, + BaseContract, + SubscriptionManager, + PromiseWithTransactionHash, + methodAbiToFunctionSignature, +} from '@0x/base-contract'; import { schemas } from '@0x/json-schemas'; import { BlockParam, @@ -19,13 +28,7 @@ import { SupportedProvider, } from 'ethereum-types'; import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils'; -import { - AwaitTransactionSuccessOpts, - EventCallback, - IndexedFilterValues, - SendTransactionOpts, - SimpleContractArtifact, -} from '@0x/types'; +import { EventCallback, IndexedFilterValues, SimpleContractArtifact } from '@0x/types'; import { Web3Wrapper } from '@0x/web3-wrapper'; import { assert } from '@0x/assert'; import * as ethers from 'ethers'; @@ -66,1151 +69,7 @@ export class MultiAssetProxyContract extends BaseContract { */ public static deployedBytecode = '0x608060405234801561001057600080fd5b50600436106100d45760003560e01c80639ad2674411610081578063c585bb931161005b578063c585bb9314610789578063d39de6e9146107bc578063f2fde38b14610814576100d4565b80639ad26744146106cc578063ae25532e14610705578063b918161114610742576100d4565b806360704108116100b2578063607041081461065257806370712939146106915780638da5cb5b146106c4576100d4565b80633fd3c9971461059857806342f1181e14610600578063494503d414610635575b7fffffffff00000000000000000000000000000000000000000000000000000000600035167fa85e59e400000000000000000000000000000000000000000000000000000000811415610592573360005260026020526040600020546101a5577f08c379a0000000000000000000000000000000000000000000000000000000006000527c20000000000000000000000000000000000000000000000000000000006020527c1553454e4445525f4e4f545f415554484f52495a454400000000000000604052600060605260646000fd5b600480350180356020600482030660448210171561022e577f08c379a0000000000000000000000000000000000000000000000000000000006000527c20000000000000000000000000000000000000000000000000000000006020527c19494e56414c49445f41535345545f444154415f4c454e475448000000604052600060605260646000fd5b602081018201368111156102ad577f08c379a0000000000000000000000000000000000000000000000000000000006000527c20000000000000000000000000000000000000000000000000000000006020527c16494e56414c49445f41535345545f444154415f454e44000000000000604052600060605260646000fd5b5050602481013560448201356044820183016020810335925060448201840160208103358085031561034a577f08c379a0000000000000000000000000000000000000000000000000000000006000527c20000000000000000000000000000000000000000000000000000000006020527c0f4c454e4754485f4d49534d4154434800000000000000000000000000604052600060605260646000fd5b5060646000803760806004526000936064359060200285805b82811015610587578086013584810281868204148615176103ef577f08c379a0000000000000000000000000000000000000000000000000000000006000527c20000000000000000000000000000000000000000000000000000000006020527c1055494e543235365f4f564552464c4f57000000000000000000000000604052600060605260646000fd5b60649081528287013589018b01604481019250018135600481101561049e577f08c379a0000000000000000000000000000000000000000000000000000000006000527c20000000000000000000000000000000000000000000000000000000006020527c1e4c454e4754485f475245415445525f5448414e5f335f5245515549526040527f454400000000000000000000000000000000000000000000000000000000000060605260646000fd5b7fffffffff000000000000000000000000000000000000000000000000000000008235168b8103156104df57809b508b608452600160a45260406084205495505b5084610556577f08c379a0000000000000000000000000000000000000000000000000000000006000527c20000000000000000000000000000000000000000000000000000000006020527c1a41535345545f50524f58595f444f45535f4e4f545f45584953540000604052600060605260646000fd5b60208101836084376000808260a401600080895af1925050508061057e573d6000803e3d6000fd5b50602001610363565b505050505050505050005b50600080fd5b6105d7600480360360208110156105ae57600080fd5b50357fffffffff0000000000000000000000000000000000000000000000000000000016610847565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b6106336004803603602081101561061657600080fd5b503573ffffffffffffffffffffffffffffffffffffffff1661086f565b005b6105d76004803603602081101561064b57600080fd5b5035610a5b565b6105d76004803603602081101561066857600080fd5b50357fffffffff0000000000000000000000000000000000000000000000000000000016610a8f565b610633600480360360208110156106a757600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610ad9565b6105d7610dcc565b610633600480360360408110156106e257600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135169060200135610de8565b61070d611199565b604080517fffffffff000000000000000000000000000000000000000000000000000000009092168252519081900360200190f35b6107756004803603602081101561075857600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166111cf565b604080519115158252519081900360200190f35b6106336004803603602081101561079f57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166111e4565b6107c4611446565b60408051602080825283518183015283519192839290830191858101910280838360005b838110156108005781810151838201526020016107e8565b505050509050019250505060405180910390f35b6106336004803603602081101561082a57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166114b5565b60016020526000908152604090205473ffffffffffffffffffffffffffffffffffffffff1681565b60005473ffffffffffffffffffffffffffffffffffffffff1633146108f557604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f4f4e4c595f434f4e54524143545f4f574e455200000000000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff811660009081526002602052604090205460ff161561098a57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f5441524745545f414c52454144595f415554484f52495a454400000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff811660008181526002602052604080822080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600190811790915560038054918201815583527fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b0180547fffffffffffffffffffffffff00000000000000000000000000000000000000001684179055513392917f3147867c59d17e8fa9d522465651d44aae0a9e38f902f3475b97e58072f0ed4c91a350565b60038181548110610a6857fe5b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff16905081565b7fffffffff000000000000000000000000000000000000000000000000000000001660009081526001602052604090205473ffffffffffffffffffffffffffffffffffffffff1690565b60005473ffffffffffffffffffffffffffffffffffffffff163314610b5f57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f4f4e4c595f434f4e54524143545f4f574e455200000000000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff811660009081526002602052604090205460ff16610bf357604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f5441524745545f4e4f545f415554484f52495a45440000000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff8116600090815260026020526040812080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690555b600354811015610d85578173ffffffffffffffffffffffffffffffffffffffff1660038281548110610c6d57fe5b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff161415610d7d57600380547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8101908110610cc557fe5b6000918252602090912001546003805473ffffffffffffffffffffffffffffffffffffffff9092169183908110610cf857fe5b600091825260209091200180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055600380547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190610d77908261159b565b50610d85565b600101610c3f565b50604051339073ffffffffffffffffffffffffffffffffffffffff8316907f1f32c1b084e2de0713b8fb16bd46bb9df710a3dbeae2f3ca93af46e016dcc6b090600090a350565b60005473ffffffffffffffffffffffffffffffffffffffff1681565b60005473ffffffffffffffffffffffffffffffffffffffff163314610e6e57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f4f4e4c595f434f4e54524143545f4f574e455200000000000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff821660009081526002602052604090205460ff16610f0257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f5441524745545f4e4f545f415554484f52495a45440000000000000000000000604482015290519081900360640190fd5b6003548110610f7257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f494e4445585f4f55545f4f465f424f554e445300000000000000000000000000604482015290519081900360640190fd5b8173ffffffffffffffffffffffffffffffffffffffff1660038281548110610f9657fe5b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff161461102457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f415554484f52495a45445f414444524553535f4d49534d415443480000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff8216600090815260026020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169055600380547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff810190811061109f57fe5b6000918252602090912001546003805473ffffffffffffffffffffffffffffffffffffffff90921691839081106110d257fe5b600091825260209091200180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055600380547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190611151908261159b565b50604051339073ffffffffffffffffffffffffffffffffffffffff8416907f1f32c1b084e2de0713b8fb16bd46bb9df710a3dbeae2f3ca93af46e016dcc6b090600090a35050565b604080517f4d756c746941737365742875696e743235365b5d2c62797465735b5d290000008152905190819003601d0190205b90565b60026020526000908152604090205460ff1681565b60005473ffffffffffffffffffffffffffffffffffffffff16331461126a57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f4f4e4c595f434f4e54524143545f4f574e455200000000000000000000000000604482015290519081900360640190fd5b60008173ffffffffffffffffffffffffffffffffffffffff1663ae25532e6040518163ffffffff1660e01b815260040160206040518083038186803b1580156112b257600080fd5b505afa1580156112c6573d6000803e3d6000fd5b505050506040513d60208110156112dc57600080fd5b50517fffffffff00000000000000000000000000000000000000000000000000000000811660009081526001602052604090205490915073ffffffffffffffffffffffffffffffffffffffff16801561139657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f41535345545f50524f58595f414c52454144595f455849535453000000000000604482015290519081900360640190fd5b7fffffffff00000000000000000000000000000000000000000000000000000000821660008181526001602090815260409182902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff881690811790915582519384529083015280517fd2c6b762299c609bdb96520b58a49bfb80186934d4f71a86a367571a15c031949281900390910190a1505050565b606060038054806020026020016040519081016040528092919081815260200182805480156114ab57602002820191906000526020600020905b815473ffffffffffffffffffffffffffffffffffffffff168152600190910190602001808311611480575b5050505050905090565b60005473ffffffffffffffffffffffffffffffffffffffff16331461153b57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f4f4e4c595f434f4e54524143545f4f574e455200000000000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff81161561159857600080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83161790555b50565b8154818355818111156115bf576000838152602090206115bf9181019083016115c4565b505050565b6111cc91905b808211156115de57600081556001016115ca565b509056fea265627a7a72315820ff218c9e47c47135d1028b03281d63826ba3569217fc501ee67c0661fa98fc5164736f6c634300050b0032'; - public assetProxies = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(index_0: string, callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.isString('index_0', index_0); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as MultiAssetProxyContract; - const encodedData = self._strictEncodeArguments('assetProxies(bytes4)', [index_0]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('assetProxies(bytes4)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Authorizes an address. - */ - public addAuthorizedAddress = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param target Address to authorize. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - target: string, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('target', target); - const self = (this as any) as MultiAssetProxyContract; - const encodedData = self._strictEncodeArguments('addAuthorizedAddress(address)', [target.toLowerCase()]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.addAuthorizedAddress.callAsync(target, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param target Address to authorize. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - target: string, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('target', target); - const self = (this as any) as MultiAssetProxyContract; - const txHashPromise = self.addAuthorizedAddress.sendTransactionAsync(target.toLowerCase(), txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param target Address to authorize. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync(target: string, txData?: Partial | undefined): Promise { - assert.isString('target', target); - const self = (this as any) as MultiAssetProxyContract; - const encodedData = self._strictEncodeArguments('addAuthorizedAddress(address)', [target.toLowerCase()]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param target Address to authorize. - */ - async callAsync(target: string, callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.isString('target', target); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as MultiAssetProxyContract; - const encodedData = self._strictEncodeArguments('addAuthorizedAddress(address)', [target.toLowerCase()]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('addAuthorizedAddress(address)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param target Address to authorize. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(target: string): string { - assert.isString('target', target); - const self = (this as any) as MultiAssetProxyContract; - const abiEncodedTransactionData = self._strictEncodeArguments('addAuthorizedAddress(address)', [ - target.toLowerCase(), - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as MultiAssetProxyContract; - const abiEncoder = self._lookupAbiEncoder('addAuthorizedAddress(address)'); - return abiEncoder.getSelector(); - }, - }; - public authorities = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync( - index_0: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isBigNumber('index_0', index_0); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as MultiAssetProxyContract; - const encodedData = self._strictEncodeArguments('authorities(uint256)', [index_0]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('authorities(uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Gets an asset proxy. - */ - public getAssetProxy = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param assetProxyId Id of the asset proxy. - * @returns The asset proxy registered to assetProxyId. Returns 0x0 if no proxy is registered. - */ - async callAsync( - assetProxyId: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('assetProxyId', assetProxyId); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as MultiAssetProxyContract; - const encodedData = self._strictEncodeArguments('getAssetProxy(bytes4)', [assetProxyId]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('getAssetProxy(bytes4)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Removes authorizion of an address. - */ - public removeAuthorizedAddress = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param target Address to remove authorization from. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - target: string, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('target', target); - const self = (this as any) as MultiAssetProxyContract; - const encodedData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [target.toLowerCase()]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.removeAuthorizedAddress.callAsync(target, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param target Address to remove authorization from. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - target: string, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('target', target); - const self = (this as any) as MultiAssetProxyContract; - const txHashPromise = self.removeAuthorizedAddress.sendTransactionAsync(target.toLowerCase(), txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param target Address to remove authorization from. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync(target: string, txData?: Partial | undefined): Promise { - assert.isString('target', target); - const self = (this as any) as MultiAssetProxyContract; - const encodedData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [target.toLowerCase()]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param target Address to remove authorization from. - */ - async callAsync(target: string, callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.isString('target', target); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as MultiAssetProxyContract; - const encodedData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [target.toLowerCase()]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('removeAuthorizedAddress(address)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param target Address to remove authorization from. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(target: string): string { - assert.isString('target', target); - const self = (this as any) as MultiAssetProxyContract; - const abiEncodedTransactionData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [ - target.toLowerCase(), - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as MultiAssetProxyContract; - const abiEncoder = self._lookupAbiEncoder('removeAuthorizedAddress(address)'); - return abiEncoder.getSelector(); - }, - }; - public owner = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as MultiAssetProxyContract; - const encodedData = self._strictEncodeArguments('owner()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('owner()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Removes authorizion of an address. - */ - public removeAuthorizedAddressAtIndex = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param target Address to remove authorization from. - * @param index Index of target in authorities array. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - target: string, - index: BigNumber, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('target', target); - assert.isBigNumber('index', index); - const self = (this as any) as MultiAssetProxyContract; - const encodedData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [ - target.toLowerCase(), - index, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.removeAuthorizedAddressAtIndex.callAsync(target, index, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param target Address to remove authorization from. - * @param index Index of target in authorities array. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - target: string, - index: BigNumber, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('target', target); - assert.isBigNumber('index', index); - const self = (this as any) as MultiAssetProxyContract; - const txHashPromise = self.removeAuthorizedAddressAtIndex.sendTransactionAsync( - target.toLowerCase(), - index, - txData, - opts, - ); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param target Address to remove authorization from. - * @param index Index of target in authorities array. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - target: string, - index: BigNumber, - txData?: Partial | undefined, - ): Promise { - assert.isString('target', target); - assert.isBigNumber('index', index); - const self = (this as any) as MultiAssetProxyContract; - const encodedData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [ - target.toLowerCase(), - index, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param target Address to remove authorization from. - * @param index Index of target in authorities array. - */ - async callAsync( - target: string, - index: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('target', target); - assert.isBigNumber('index', index); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as MultiAssetProxyContract; - const encodedData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [ - target.toLowerCase(), - index, - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('removeAuthorizedAddressAtIndex(address,uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param target Address to remove authorization from. - * @param index Index of target in authorities array. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(target: string, index: BigNumber): string { - assert.isString('target', target); - assert.isBigNumber('index', index); - const self = (this as any) as MultiAssetProxyContract; - const abiEncodedTransactionData = self._strictEncodeArguments( - 'removeAuthorizedAddressAtIndex(address,uint256)', - [target.toLowerCase(), index], - ); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as MultiAssetProxyContract; - const abiEncoder = self._lookupAbiEncoder('removeAuthorizedAddressAtIndex(address,uint256)'); - return abiEncoder.getSelector(); - }, - }; - /** - * Gets the proxy id associated with the proxy address. - */ - public getProxyId = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @returns Proxy id. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as MultiAssetProxyContract; - const encodedData = self._strictEncodeArguments('getProxyId()', []); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('getProxyId()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public authorized = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync( - index_0: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('index_0', index_0); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as MultiAssetProxyContract; - const encodedData = self._strictEncodeArguments('authorized(address)', [index_0.toLowerCase()]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('authorized(address)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Registers an asset proxy to its asset proxy id. - * Once an asset proxy is registered, it cannot be unregistered. - */ - public registerAssetProxy = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param assetProxy Address of new asset proxy to register. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - assetProxy: string, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('assetProxy', assetProxy); - const self = (this as any) as MultiAssetProxyContract; - const encodedData = self._strictEncodeArguments('registerAssetProxy(address)', [assetProxy.toLowerCase()]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.registerAssetProxy.callAsync(assetProxy, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param assetProxy Address of new asset proxy to register. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - assetProxy: string, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('assetProxy', assetProxy); - const self = (this as any) as MultiAssetProxyContract; - const txHashPromise = self.registerAssetProxy.sendTransactionAsync(assetProxy.toLowerCase(), txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param assetProxy Address of new asset proxy to register. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync(assetProxy: string, txData?: Partial | undefined): Promise { - assert.isString('assetProxy', assetProxy); - const self = (this as any) as MultiAssetProxyContract; - const encodedData = self._strictEncodeArguments('registerAssetProxy(address)', [assetProxy.toLowerCase()]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param assetProxy Address of new asset proxy to register. - */ - async callAsync( - assetProxy: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('assetProxy', assetProxy); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as MultiAssetProxyContract; - const encodedData = self._strictEncodeArguments('registerAssetProxy(address)', [assetProxy.toLowerCase()]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('registerAssetProxy(address)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param assetProxy Address of new asset proxy to register. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(assetProxy: string): string { - assert.isString('assetProxy', assetProxy); - const self = (this as any) as MultiAssetProxyContract; - const abiEncodedTransactionData = self._strictEncodeArguments('registerAssetProxy(address)', [ - assetProxy.toLowerCase(), - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as MultiAssetProxyContract; - const abiEncoder = self._lookupAbiEncoder('registerAssetProxy(address)'); - return abiEncoder.getSelector(); - }, - }; - /** - * Gets all authorized addresses. - */ - public getAuthorizedAddresses = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @returns Array of authorized addresses. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as MultiAssetProxyContract; - const encodedData = self._strictEncodeArguments('getAuthorizedAddresses()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('getAuthorizedAddresses()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public transferOwnership = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - newOwner: string, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('newOwner', newOwner); - const self = (this as any) as MultiAssetProxyContract; - const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.transferOwnership.callAsync(newOwner, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - newOwner: string, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('newOwner', newOwner); - const self = (this as any) as MultiAssetProxyContract; - const txHashPromise = self.transferOwnership.sendTransactionAsync(newOwner.toLowerCase(), txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync(newOwner: string, txData?: Partial | undefined): Promise { - assert.isString('newOwner', newOwner); - const self = (this as any) as MultiAssetProxyContract; - const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(newOwner: string, callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.isString('newOwner', newOwner); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as MultiAssetProxyContract; - const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('transferOwnership(address)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(newOwner: string): string { - assert.isString('newOwner', newOwner); - const self = (this as any) as MultiAssetProxyContract; - const abiEncodedTransactionData = self._strictEncodeArguments('transferOwnership(address)', [ - newOwner.toLowerCase(), - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as MultiAssetProxyContract; - const abiEncoder = self._lookupAbiEncoder('transferOwnership(address)'); - return abiEncoder.getSelector(); - }, - }; + private _methodABIIndex: { [name: string]: number } = {}; private readonly _subscriptionManager: SubscriptionManager; public static async deployFrom0xArtifactAsync( artifact: ContractArtifact | SimpleContractArtifact, @@ -1537,6 +396,960 @@ export class MultiAssetProxyContract extends BaseContract { ] as ContractAbi; return abi; } + + public getFunctionSignature(methodName: string): string { + const index = this._methodABIIndex[methodName]; + const methodAbi = MultiAssetProxyContract.ABI()[index] as MethodAbi; + const functionSignature = methodAbiToFunctionSignature(methodAbi); + return functionSignature; + } + public getABIDecodedTransactionData(methodName: string, callData: string): T { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as MultiAssetProxyContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + const abiDecodedCallData = abiEncoder.strictDecode(callData); + return abiDecodedCallData; + } + public getABIDecodedReturnData(methodName: string, callData: string): T { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as MultiAssetProxyContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + const abiDecodedCallData = abiEncoder.strictDecodeReturnValue(callData); + return abiDecodedCallData; + } + public getSelector(methodName: string): string { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as MultiAssetProxyContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + return abiEncoder.getSelector(); + } + + public assetProxies(index_0: string): ContractFunctionObj { + const self = (this as any) as MultiAssetProxyContract; + assert.isString('index_0', index_0); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('assetProxies(bytes4)', [index_0]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('assetProxies(bytes4)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('assetProxies(bytes4)', [index_0]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Authorizes an address. + * @param target Address to authorize. + */ + public addAuthorizedAddress(target: string): ContractTxFunctionObj { + const self = (this as any) as MultiAssetProxyContract; + assert.isString('target', target); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('addAuthorizedAddress(address)', [ + target.toLowerCase(), + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('addAuthorizedAddress(address)', [ + target.toLowerCase(), + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('addAuthorizedAddress(address)', [ + target.toLowerCase(), + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('addAuthorizedAddress(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('addAuthorizedAddress(address)', [ + target.toLowerCase(), + ]); + return abiEncodedTransactionData; + }, + }; + } + public authorities(index_0: BigNumber): ContractFunctionObj { + const self = (this as any) as MultiAssetProxyContract; + assert.isBigNumber('index_0', index_0); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('authorities(uint256)', [index_0]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('authorities(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('authorities(uint256)', [index_0]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Gets an asset proxy. + * @param assetProxyId Id of the asset proxy. + * @returns The asset proxy registered to assetProxyId. Returns 0x0 if no proxy is registered. + */ + public getAssetProxy(assetProxyId: string): ContractFunctionObj { + const self = (this as any) as MultiAssetProxyContract; + assert.isString('assetProxyId', assetProxyId); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('getAssetProxy(bytes4)', [assetProxyId]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('getAssetProxy(bytes4)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('getAssetProxy(bytes4)', [assetProxyId]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Removes authorizion of an address. + * @param target Address to remove authorization from. + */ + public removeAuthorizedAddress(target: string): ContractTxFunctionObj { + const self = (this as any) as MultiAssetProxyContract; + assert.isString('target', target); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [ + target.toLowerCase(), + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [ + target.toLowerCase(), + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [ + target.toLowerCase(), + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('removeAuthorizedAddress(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [ + target.toLowerCase(), + ]); + return abiEncodedTransactionData; + }, + }; + } + public owner(): ContractFunctionObj { + const self = (this as any) as MultiAssetProxyContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('owner()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('owner()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('owner()', []); + return abiEncodedTransactionData; + }, + }; + } + /** + * Removes authorizion of an address. + * @param target Address to remove authorization from. + * @param index Index of target in authorities array. + */ + public removeAuthorizedAddressAtIndex(target: string, index: BigNumber): ContractTxFunctionObj { + const self = (this as any) as MultiAssetProxyContract; + assert.isString('target', target); + assert.isBigNumber('index', index); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [ + target.toLowerCase(), + index, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [ + target.toLowerCase(), + index, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [ + target.toLowerCase(), + index, + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('removeAuthorizedAddressAtIndex(address,uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'removeAuthorizedAddressAtIndex(address,uint256)', + [target.toLowerCase(), index], + ); + return abiEncodedTransactionData; + }, + }; + } + /** + * Gets the proxy id associated with the proxy address. + * @returns Proxy id. + */ + public getProxyId(): ContractFunctionObj { + const self = (this as any) as MultiAssetProxyContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('getProxyId()', []); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('getProxyId()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('getProxyId()', []); + return abiEncodedTransactionData; + }, + }; + } + public authorized(index_0: string): ContractFunctionObj { + const self = (this as any) as MultiAssetProxyContract; + assert.isString('index_0', index_0); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('authorized(address)', [index_0.toLowerCase()]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('authorized(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('authorized(address)', [ + index_0.toLowerCase(), + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Registers an asset proxy to its asset proxy id. + * Once an asset proxy is registered, it cannot be unregistered. + * @param assetProxy Address of new asset proxy to register. + */ + public registerAssetProxy(assetProxy: string): ContractTxFunctionObj { + const self = (this as any) as MultiAssetProxyContract; + assert.isString('assetProxy', assetProxy); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('registerAssetProxy(address)', [ + assetProxy.toLowerCase(), + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('registerAssetProxy(address)', [ + assetProxy.toLowerCase(), + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('registerAssetProxy(address)', [ + assetProxy.toLowerCase(), + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('registerAssetProxy(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('registerAssetProxy(address)', [ + assetProxy.toLowerCase(), + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Gets all authorized addresses. + * @returns Array of authorized addresses. + */ + public getAuthorizedAddresses(): ContractFunctionObj { + const self = (this as any) as MultiAssetProxyContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('getAuthorizedAddresses()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('getAuthorizedAddresses()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('getAuthorizedAddresses()', []); + return abiEncodedTransactionData; + }, + }; + } + public transferOwnership(newOwner: string): ContractTxFunctionObj { + const self = (this as any) as MultiAssetProxyContract; + assert.isString('newOwner', newOwner); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('transferOwnership(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('transferOwnership(address)', [ + newOwner.toLowerCase(), + ]); + return abiEncodedTransactionData; + }, + }; + } + /** * Subscribe to an event type emitted by the MultiAssetProxy contract. * @param eventName The MultiAssetProxy contract event you would like to subscribe to. @@ -1626,6 +1439,12 @@ export class MultiAssetProxyContract extends BaseContract { MultiAssetProxyContract.ABI(), this._web3Wrapper, ); + MultiAssetProxyContract.ABI().forEach((item, index) => { + if (item.type === 'function') { + const methodAbi = item as MethodAbi; + this._methodABIIndex[methodAbi.name] = index; + } + }); } } diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/order_validator.ts b/packages/abi-gen-wrappers/src/generated-wrappers/order_validator.ts index aadf482932..acd8ba4ec1 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/order_validator.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/order_validator.ts @@ -1,7 +1,15 @@ // tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma enum-naming // tslint:disable:whitespace no-unbound-method no-trailing-whitespace // tslint:disable:no-unused-variable -import { BaseContract, PromiseWithTransactionHash } from '@0x/base-contract'; +import { + AwaitTransactionSuccessOpts, + ContractFunctionObj, + ContractTxFunctionObj, + SendTransactionOpts, + BaseContract, + PromiseWithTransactionHash, + methodAbiToFunctionSignature, +} from '@0x/base-contract'; import { schemas } from '@0x/json-schemas'; import { BlockParam, @@ -18,13 +26,7 @@ import { SupportedProvider, } from 'ethereum-types'; import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils'; -import { - AwaitTransactionSuccessOpts, - EventCallback, - IndexedFilterValues, - SendTransactionOpts, - SimpleContractArtifact, -} from '@0x/types'; +import { EventCallback, IndexedFilterValues, SimpleContractArtifact } from '@0x/types'; import { Web3Wrapper } from '@0x/web3-wrapper'; import { assert } from '@0x/assert'; import * as ethers from 'ethers'; @@ -38,531 +40,7 @@ export class OrderValidatorContract extends BaseContract { * @ignore */ public static deployedBytecode: string | undefined; - public getOrderAndTraderInfo = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync( - order: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - }, - takerAddress: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise< - [ - { orderStatus: number; orderHash: string; orderTakerAssetFilledAmount: BigNumber }, - { - makerBalance: BigNumber; - makerAllowance: BigNumber; - takerBalance: BigNumber; - takerAllowance: BigNumber; - makerZrxBalance: BigNumber; - makerZrxAllowance: BigNumber; - takerZrxBalance: BigNumber; - takerZrxAllowance: BigNumber; - } - ] - > { - assert.isString('takerAddress', takerAddress); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as OrderValidatorContract; - const encodedData = self._strictEncodeArguments( - 'getOrderAndTraderInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),address)', - [order, takerAddress.toLowerCase()], - ); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder( - 'getOrderAndTraderInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),address)', - ); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue< - [ - { orderStatus: number; orderHash: string; orderTakerAssetFilledAmount: BigNumber }, - { - makerBalance: BigNumber; - makerAllowance: BigNumber; - takerBalance: BigNumber; - takerAllowance: BigNumber; - makerZrxBalance: BigNumber; - makerZrxAllowance: BigNumber; - takerZrxBalance: BigNumber; - takerZrxAllowance: BigNumber; - } - ] - >(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public getBalanceAndAllowance = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync( - target: string, - assetData: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise<[BigNumber, BigNumber]> { - assert.isString('target', target); - assert.isString('assetData', assetData); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as OrderValidatorContract; - const encodedData = self._strictEncodeArguments('getBalanceAndAllowance(address,bytes)', [ - target.toLowerCase(), - assetData, - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('getBalanceAndAllowance(address,bytes)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue<[BigNumber, BigNumber]>(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public getOrdersAndTradersInfo = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - }>, - takerAddresses: string[], - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise< - [ - Array<{ orderStatus: number; orderHash: string; orderTakerAssetFilledAmount: BigNumber }>, - Array<{ - makerBalance: BigNumber; - makerAllowance: BigNumber; - takerBalance: BigNumber; - takerAllowance: BigNumber; - makerZrxBalance: BigNumber; - makerZrxAllowance: BigNumber; - takerZrxBalance: BigNumber; - takerZrxAllowance: BigNumber; - }> - ] - > { - assert.isArray('orders', orders); - assert.isArray('takerAddresses', takerAddresses); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as OrderValidatorContract; - const encodedData = self._strictEncodeArguments( - 'getOrdersAndTradersInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],address[])', - [orders, takerAddresses], - ); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder( - 'getOrdersAndTradersInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],address[])', - ); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue< - [ - Array<{ orderStatus: number; orderHash: string; orderTakerAssetFilledAmount: BigNumber }>, - Array<{ - makerBalance: BigNumber; - makerAllowance: BigNumber; - takerBalance: BigNumber; - takerAllowance: BigNumber; - makerZrxBalance: BigNumber; - makerZrxAllowance: BigNumber; - takerZrxBalance: BigNumber; - takerZrxAllowance: BigNumber; - }> - ] - >(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public getTradersInfo = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - }>, - takerAddresses: string[], - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise< - Array<{ - makerBalance: BigNumber; - makerAllowance: BigNumber; - takerBalance: BigNumber; - takerAllowance: BigNumber; - makerZrxBalance: BigNumber; - makerZrxAllowance: BigNumber; - takerZrxBalance: BigNumber; - takerZrxAllowance: BigNumber; - }> - > { - assert.isArray('orders', orders); - assert.isArray('takerAddresses', takerAddresses); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as OrderValidatorContract; - const encodedData = self._strictEncodeArguments( - 'getTradersInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],address[])', - [orders, takerAddresses], - ); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder( - 'getTradersInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],address[])', - ); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue< - Array<{ - makerBalance: BigNumber; - makerAllowance: BigNumber; - takerBalance: BigNumber; - takerAllowance: BigNumber; - makerZrxBalance: BigNumber; - makerZrxAllowance: BigNumber; - takerZrxBalance: BigNumber; - takerZrxAllowance: BigNumber; - }> - >(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public getERC721TokenOwner = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync( - token: string, - tokenId: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('token', token); - assert.isBigNumber('tokenId', tokenId); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as OrderValidatorContract; - const encodedData = self._strictEncodeArguments('getERC721TokenOwner(address,uint256)', [ - token.toLowerCase(), - tokenId, - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('getERC721TokenOwner(address,uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public getBalancesAndAllowances = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync( - target: string, - assetData: string[], - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise<[BigNumber[], BigNumber[]]> { - assert.isString('target', target); - assert.isArray('assetData', assetData); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as OrderValidatorContract; - const encodedData = self._strictEncodeArguments('getBalancesAndAllowances(address,bytes[])', [ - target.toLowerCase(), - assetData, - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('getBalancesAndAllowances(address,bytes[])'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue<[BigNumber[], BigNumber[]]>(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public getTraderInfo = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync( - order: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - }, - takerAddress: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise<{ - makerBalance: BigNumber; - makerAllowance: BigNumber; - takerBalance: BigNumber; - takerAllowance: BigNumber; - makerZrxBalance: BigNumber; - makerZrxAllowance: BigNumber; - takerZrxBalance: BigNumber; - takerZrxAllowance: BigNumber; - }> { - assert.isString('takerAddress', takerAddress); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as OrderValidatorContract; - const encodedData = self._strictEncodeArguments( - 'getTraderInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),address)', - [order, takerAddress.toLowerCase()], - ); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder( - 'getTraderInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),address)', - ); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue<{ - makerBalance: BigNumber; - makerAllowance: BigNumber; - takerBalance: BigNumber; - takerAllowance: BigNumber; - makerZrxBalance: BigNumber; - makerZrxAllowance: BigNumber; - takerZrxBalance: BigNumber; - takerZrxAllowance: BigNumber; - }>(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; + private _methodABIIndex: { [name: string]: number } = {}; public static async deployFrom0xArtifactAsync( artifact: ContractArtifact | SimpleContractArtifact, supportedProvider: SupportedProvider, @@ -1208,6 +686,657 @@ export class OrderValidatorContract extends BaseContract { ] as ContractAbi; return abi; } + + public getFunctionSignature(methodName: string): string { + const index = this._methodABIIndex[methodName]; + const methodAbi = OrderValidatorContract.ABI()[index] as MethodAbi; + const functionSignature = methodAbiToFunctionSignature(methodAbi); + return functionSignature; + } + public getABIDecodedTransactionData(methodName: string, callData: string): T { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as OrderValidatorContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + const abiDecodedCallData = abiEncoder.strictDecode(callData); + return abiDecodedCallData; + } + public getABIDecodedReturnData(methodName: string, callData: string): T { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as OrderValidatorContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + const abiDecodedCallData = abiEncoder.strictDecodeReturnValue(callData); + return abiDecodedCallData; + } + public getSelector(methodName: string): string { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as OrderValidatorContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + return abiEncoder.getSelector(); + } + + public getOrderAndTraderInfo( + order: { + makerAddress: string; + takerAddress: string; + feeRecipientAddress: string; + senderAddress: string; + makerAssetAmount: BigNumber; + takerAssetAmount: BigNumber; + makerFee: BigNumber; + takerFee: BigNumber; + expirationTimeSeconds: BigNumber; + salt: BigNumber; + makerAssetData: string; + takerAssetData: string; + }, + takerAddress: string, + ): ContractFunctionObj< + [ + { orderStatus: number; orderHash: string; orderTakerAssetFilledAmount: BigNumber }, + { + makerBalance: BigNumber; + makerAllowance: BigNumber; + takerBalance: BigNumber; + takerAllowance: BigNumber; + makerZrxBalance: BigNumber; + makerZrxAllowance: BigNumber; + takerZrxBalance: BigNumber; + takerZrxAllowance: BigNumber; + } + ] + > { + const self = (this as any) as OrderValidatorContract; + + assert.isString('takerAddress', takerAddress); + + return { + async callAsync( + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise< + [ + { orderStatus: number; orderHash: string; orderTakerAssetFilledAmount: BigNumber }, + { + makerBalance: BigNumber; + makerAllowance: BigNumber; + takerBalance: BigNumber; + takerAllowance: BigNumber; + makerZrxBalance: BigNumber; + makerZrxAllowance: BigNumber; + takerZrxBalance: BigNumber; + takerZrxAllowance: BigNumber; + } + ] + > { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments( + 'getOrderAndTraderInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),address)', + [order, takerAddress.toLowerCase()], + ); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder( + 'getOrderAndTraderInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),address)', + ); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue< + [ + { orderStatus: number; orderHash: string; orderTakerAssetFilledAmount: BigNumber }, + { + makerBalance: BigNumber; + makerAllowance: BigNumber; + takerBalance: BigNumber; + takerAllowance: BigNumber; + makerZrxBalance: BigNumber; + makerZrxAllowance: BigNumber; + takerZrxBalance: BigNumber; + takerZrxAllowance: BigNumber; + } + ] + >(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'getOrderAndTraderInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),address)', + [order, takerAddress.toLowerCase()], + ); + return abiEncodedTransactionData; + }, + }; + } + public getBalanceAndAllowance(target: string, assetData: string): ContractFunctionObj<[BigNumber, BigNumber]> { + const self = (this as any) as OrderValidatorContract; + assert.isString('target', target); + assert.isString('assetData', assetData); + + return { + async callAsync( + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise<[BigNumber, BigNumber]> { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('getBalanceAndAllowance(address,bytes)', [ + target.toLowerCase(), + assetData, + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('getBalanceAndAllowance(address,bytes)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<[BigNumber, BigNumber]>(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('getBalanceAndAllowance(address,bytes)', [ + target.toLowerCase(), + assetData, + ]); + return abiEncodedTransactionData; + }, + }; + } + public getOrdersAndTradersInfo( + orders: Array<{ + makerAddress: string; + takerAddress: string; + feeRecipientAddress: string; + senderAddress: string; + makerAssetAmount: BigNumber; + takerAssetAmount: BigNumber; + makerFee: BigNumber; + takerFee: BigNumber; + expirationTimeSeconds: BigNumber; + salt: BigNumber; + makerAssetData: string; + takerAssetData: string; + }>, + takerAddresses: string[], + ): ContractFunctionObj< + [ + Array<{ orderStatus: number; orderHash: string; orderTakerAssetFilledAmount: BigNumber }>, + Array<{ + makerBalance: BigNumber; + makerAllowance: BigNumber; + takerBalance: BigNumber; + takerAllowance: BigNumber; + makerZrxBalance: BigNumber; + makerZrxAllowance: BigNumber; + takerZrxBalance: BigNumber; + takerZrxAllowance: BigNumber; + }> + ] + > { + const self = (this as any) as OrderValidatorContract; + assert.isArray('orders', orders); + assert.isArray('takerAddresses', takerAddresses); + + return { + async callAsync( + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise< + [ + Array<{ orderStatus: number; orderHash: string; orderTakerAssetFilledAmount: BigNumber }>, + Array<{ + makerBalance: BigNumber; + makerAllowance: BigNumber; + takerBalance: BigNumber; + takerAllowance: BigNumber; + makerZrxBalance: BigNumber; + makerZrxAllowance: BigNumber; + takerZrxBalance: BigNumber; + takerZrxAllowance: BigNumber; + }> + ] + > { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments( + 'getOrdersAndTradersInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],address[])', + [orders, takerAddresses], + ); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder( + 'getOrdersAndTradersInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],address[])', + ); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue< + [ + Array<{ orderStatus: number; orderHash: string; orderTakerAssetFilledAmount: BigNumber }>, + Array<{ + makerBalance: BigNumber; + makerAllowance: BigNumber; + takerBalance: BigNumber; + takerAllowance: BigNumber; + makerZrxBalance: BigNumber; + makerZrxAllowance: BigNumber; + takerZrxBalance: BigNumber; + takerZrxAllowance: BigNumber; + }> + ] + >(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'getOrdersAndTradersInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],address[])', + [orders, takerAddresses], + ); + return abiEncodedTransactionData; + }, + }; + } + public getTradersInfo( + orders: Array<{ + makerAddress: string; + takerAddress: string; + feeRecipientAddress: string; + senderAddress: string; + makerAssetAmount: BigNumber; + takerAssetAmount: BigNumber; + makerFee: BigNumber; + takerFee: BigNumber; + expirationTimeSeconds: BigNumber; + salt: BigNumber; + makerAssetData: string; + takerAssetData: string; + }>, + takerAddresses: string[], + ): ContractFunctionObj< + Array<{ + makerBalance: BigNumber; + makerAllowance: BigNumber; + takerBalance: BigNumber; + takerAllowance: BigNumber; + makerZrxBalance: BigNumber; + makerZrxAllowance: BigNumber; + takerZrxBalance: BigNumber; + takerZrxAllowance: BigNumber; + }> + > { + const self = (this as any) as OrderValidatorContract; + assert.isArray('orders', orders); + assert.isArray('takerAddresses', takerAddresses); + + return { + async callAsync( + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise< + Array<{ + makerBalance: BigNumber; + makerAllowance: BigNumber; + takerBalance: BigNumber; + takerAllowance: BigNumber; + makerZrxBalance: BigNumber; + makerZrxAllowance: BigNumber; + takerZrxBalance: BigNumber; + takerZrxAllowance: BigNumber; + }> + > { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments( + 'getTradersInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],address[])', + [orders, takerAddresses], + ); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder( + 'getTradersInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],address[])', + ); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue< + Array<{ + makerBalance: BigNumber; + makerAllowance: BigNumber; + takerBalance: BigNumber; + takerAllowance: BigNumber; + makerZrxBalance: BigNumber; + makerZrxAllowance: BigNumber; + takerZrxBalance: BigNumber; + takerZrxAllowance: BigNumber; + }> + >(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'getTradersInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],address[])', + [orders, takerAddresses], + ); + return abiEncodedTransactionData; + }, + }; + } + public getERC721TokenOwner(token: string, tokenId: BigNumber): ContractFunctionObj { + const self = (this as any) as OrderValidatorContract; + assert.isString('token', token); + assert.isBigNumber('tokenId', tokenId); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('getERC721TokenOwner(address,uint256)', [ + token.toLowerCase(), + tokenId, + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('getERC721TokenOwner(address,uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('getERC721TokenOwner(address,uint256)', [ + token.toLowerCase(), + tokenId, + ]); + return abiEncodedTransactionData; + }, + }; + } + public getBalancesAndAllowances( + target: string, + assetData: string[], + ): ContractFunctionObj<[BigNumber[], BigNumber[]]> { + const self = (this as any) as OrderValidatorContract; + assert.isString('target', target); + assert.isArray('assetData', assetData); + + return { + async callAsync( + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise<[BigNumber[], BigNumber[]]> { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('getBalancesAndAllowances(address,bytes[])', [ + target.toLowerCase(), + assetData, + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('getBalancesAndAllowances(address,bytes[])'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<[BigNumber[], BigNumber[]]>(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'getBalancesAndAllowances(address,bytes[])', + [target.toLowerCase(), assetData], + ); + return abiEncodedTransactionData; + }, + }; + } + public getTraderInfo( + order: { + makerAddress: string; + takerAddress: string; + feeRecipientAddress: string; + senderAddress: string; + makerAssetAmount: BigNumber; + takerAssetAmount: BigNumber; + makerFee: BigNumber; + takerFee: BigNumber; + expirationTimeSeconds: BigNumber; + salt: BigNumber; + makerAssetData: string; + takerAssetData: string; + }, + takerAddress: string, + ): ContractFunctionObj<{ + makerBalance: BigNumber; + makerAllowance: BigNumber; + takerBalance: BigNumber; + takerAllowance: BigNumber; + makerZrxBalance: BigNumber; + makerZrxAllowance: BigNumber; + takerZrxBalance: BigNumber; + takerZrxAllowance: BigNumber; + }> { + const self = (this as any) as OrderValidatorContract; + + assert.isString('takerAddress', takerAddress); + + return { + async callAsync( + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise<{ + makerBalance: BigNumber; + makerAllowance: BigNumber; + takerBalance: BigNumber; + takerAllowance: BigNumber; + makerZrxBalance: BigNumber; + makerZrxAllowance: BigNumber; + takerZrxBalance: BigNumber; + takerZrxAllowance: BigNumber; + }> { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments( + 'getTraderInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),address)', + [order, takerAddress.toLowerCase()], + ); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder( + 'getTraderInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),address)', + ); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<{ + makerBalance: BigNumber; + makerAllowance: BigNumber; + takerBalance: BigNumber; + takerAllowance: BigNumber; + makerZrxBalance: BigNumber; + makerZrxAllowance: BigNumber; + takerZrxBalance: BigNumber; + takerZrxAllowance: BigNumber; + }>(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'getTraderInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),address)', + [order, takerAddress.toLowerCase()], + ); + return abiEncodedTransactionData; + }, + }; + } + constructor( address: string, supportedProvider: SupportedProvider, @@ -1225,6 +1354,12 @@ export class OrderValidatorContract extends BaseContract { deployedBytecode, ); classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']); + OrderValidatorContract.ABI().forEach((item, index) => { + if (item.type === 'function') { + const methodAbi = item as MethodAbi; + this._methodABIIndex[methodAbi.name] = index; + } + }); } } diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/staking.ts b/packages/abi-gen-wrappers/src/generated-wrappers/staking.ts index ae9708edef..978bdc798e 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/staking.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/staking.ts @@ -1,7 +1,16 @@ // tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma enum-naming // tslint:disable:whitespace no-unbound-method no-trailing-whitespace // tslint:disable:no-unused-variable -import { BaseContract, SubscriptionManager, PromiseWithTransactionHash } from '@0x/base-contract'; +import { + AwaitTransactionSuccessOpts, + ContractFunctionObj, + ContractTxFunctionObj, + SendTransactionOpts, + BaseContract, + SubscriptionManager, + PromiseWithTransactionHash, + methodAbiToFunctionSignature, +} from '@0x/base-contract'; import { schemas } from '@0x/json-schemas'; import { BlockParam, @@ -19,13 +28,7 @@ import { SupportedProvider, } from 'ethereum-types'; import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils'; -import { - AwaitTransactionSuccessOpts, - EventCallback, - IndexedFilterValues, - SendTransactionOpts, - SimpleContractArtifact, -} from '@0x/types'; +import { EventCallback, IndexedFilterValues, SimpleContractArtifact } from '@0x/types'; import { Web3Wrapper } from '@0x/web3-wrapper'; import { assert } from '@0x/assert'; import * as ethers from 'ethers'; @@ -169,4819 +172,90 @@ export class StakingContract extends BaseContract { * @ignore */ public static deployedBytecode: string | undefined; - /** - * Authorizes an address. - */ - public addAuthorizedAddress = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param target Address to authorize. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - target: string, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('target', target); - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('addAuthorizedAddress(address)', [target.toLowerCase()]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.addAuthorizedAddress.callAsync(target, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param target Address to authorize. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - target: string, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('target', target); - const self = (this as any) as StakingContract; - const txHashPromise = self.addAuthorizedAddress.sendTransactionAsync(target.toLowerCase(), txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param target Address to authorize. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync(target: string, txData?: Partial | undefined): Promise { - assert.isString('target', target); - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('addAuthorizedAddress(address)', [target.toLowerCase()]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param target Address to authorize. - */ - async callAsync(target: string, callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.isString('target', target); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('addAuthorizedAddress(address)', [target.toLowerCase()]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('addAuthorizedAddress(address)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param target Address to authorize. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(target: string): string { - assert.isString('target', target); - const self = (this as any) as StakingContract; - const abiEncodedTransactionData = self._strictEncodeArguments('addAuthorizedAddress(address)', [ - target.toLowerCase(), - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as StakingContract; - const abiEncoder = self._lookupAbiEncoder('addAuthorizedAddress(address)'); - return abiEncoder.getSelector(); - }, - }; - /** - * Adds a new exchange address - */ - public addExchangeAddress = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param addr Address of exchange contract to add - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - addr: string, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('addr', addr); - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('addExchangeAddress(address)', [addr.toLowerCase()]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.addExchangeAddress.callAsync(addr, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param addr Address of exchange contract to add - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - addr: string, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('addr', addr); - const self = (this as any) as StakingContract; - const txHashPromise = self.addExchangeAddress.sendTransactionAsync(addr.toLowerCase(), txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param addr Address of exchange contract to add - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync(addr: string, txData?: Partial | undefined): Promise { - assert.isString('addr', addr); - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('addExchangeAddress(address)', [addr.toLowerCase()]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param addr Address of exchange contract to add - */ - async callAsync(addr: string, callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.isString('addr', addr); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('addExchangeAddress(address)', [addr.toLowerCase()]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('addExchangeAddress(address)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param addr Address of exchange contract to add - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(addr: string): string { - assert.isString('addr', addr); - const self = (this as any) as StakingContract; - const abiEncodedTransactionData = self._strictEncodeArguments('addExchangeAddress(address)', [ - addr.toLowerCase(), - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as StakingContract; - const abiEncoder = self._lookupAbiEncoder('addExchangeAddress(address)'); - return abiEncoder.getSelector(); - }, - }; - public aggregatedStatsByEpoch = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync( - index_0: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise<[BigNumber, BigNumber, BigNumber, BigNumber, BigNumber]> { - assert.isBigNumber('index_0', index_0); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('aggregatedStatsByEpoch(uint256)', [index_0]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('aggregatedStatsByEpoch(uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue<[BigNumber, BigNumber, BigNumber, BigNumber, BigNumber]>( - rawCallResult, - ); - // tslint:enable boolean-naming - return result; - }, - }; - public authorities = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync( - index_0: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isBigNumber('index_0', index_0); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('authorities(uint256)', [index_0]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('authorities(uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public authorized = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync( - index_0: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('index_0', index_0); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('authorized(address)', [index_0.toLowerCase()]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('authorized(address)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public cobbDouglasAlphaDenominator = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('cobbDouglasAlphaDenominator()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('cobbDouglasAlphaDenominator()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public cobbDouglasAlphaNumerator = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('cobbDouglasAlphaNumerator()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('cobbDouglasAlphaNumerator()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Computes the reward balance in ETH of a specific member of a pool. - */ - public computeRewardBalanceOfDelegator = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param poolId Unique id of pool. - * @param member The member of the pool. - * @returns totalReward Balance in ETH. - */ - async callAsync( - poolId: string, - member: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('poolId', poolId); - assert.isString('member', member); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('computeRewardBalanceOfDelegator(bytes32,address)', [ - poolId, - member.toLowerCase(), - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('computeRewardBalanceOfDelegator(bytes32,address)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Computes the reward balance in ETH of the operator of a pool. - */ - public computeRewardBalanceOfOperator = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param poolId Unique id of pool. - * @returns totalReward Balance in ETH. - */ - async callAsync( - poolId: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('poolId', poolId); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('computeRewardBalanceOfOperator(bytes32)', [poolId]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('computeRewardBalanceOfOperator(bytes32)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Create a new staking pool. The sender will be the operator of this pool. Note that an operator must be payable. - */ - public createStakingPool = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param operatorShare Portion of rewards owned by the operator, in ppm. - * @param addOperatorAsMaker Adds operator to the created pool as a maker for - * convenience iff true. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - operatorShare: number | BigNumber, - addOperatorAsMaker: boolean, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isNumberOrBigNumber('operatorShare', operatorShare); - assert.isBoolean('addOperatorAsMaker', addOperatorAsMaker); - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('createStakingPool(uint32,bool)', [ - operatorShare, - addOperatorAsMaker, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.createStakingPool.callAsync(operatorShare, addOperatorAsMaker, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param operatorShare Portion of rewards owned by the operator, in ppm. - * @param addOperatorAsMaker Adds operator to the created pool as a maker for - * convenience iff true. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - operatorShare: number | BigNumber, - addOperatorAsMaker: boolean, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isNumberOrBigNumber('operatorShare', operatorShare); - assert.isBoolean('addOperatorAsMaker', addOperatorAsMaker); - const self = (this as any) as StakingContract; - const txHashPromise = self.createStakingPool.sendTransactionAsync( - operatorShare, - addOperatorAsMaker, - txData, - opts, - ); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param operatorShare Portion of rewards owned by the operator, in ppm. - * @param addOperatorAsMaker Adds operator to the created pool as a maker for - * convenience iff true. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - operatorShare: number | BigNumber, - addOperatorAsMaker: boolean, - txData?: Partial | undefined, - ): Promise { - assert.isNumberOrBigNumber('operatorShare', operatorShare); - assert.isBoolean('addOperatorAsMaker', addOperatorAsMaker); - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('createStakingPool(uint32,bool)', [ - operatorShare, - addOperatorAsMaker, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param operatorShare Portion of rewards owned by the operator, in ppm. - * @param addOperatorAsMaker Adds operator to the created pool as a maker for - * convenience iff true. - * @returns poolId The unique pool id generated for this pool. - */ - async callAsync( - operatorShare: number | BigNumber, - addOperatorAsMaker: boolean, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isNumberOrBigNumber('operatorShare', operatorShare); - assert.isBoolean('addOperatorAsMaker', addOperatorAsMaker); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('createStakingPool(uint32,bool)', [ - operatorShare, - addOperatorAsMaker, - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('createStakingPool(uint32,bool)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param operatorShare Portion of rewards owned by the operator, in ppm. - * @param addOperatorAsMaker Adds operator to the created pool as a maker for - * convenience iff true. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(operatorShare: number | BigNumber, addOperatorAsMaker: boolean): string { - assert.isNumberOrBigNumber('operatorShare', operatorShare); - assert.isBoolean('addOperatorAsMaker', addOperatorAsMaker); - const self = (this as any) as StakingContract; - const abiEncodedTransactionData = self._strictEncodeArguments('createStakingPool(uint32,bool)', [ - operatorShare, - addOperatorAsMaker, - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as StakingContract; - const abiEncoder = self._lookupAbiEncoder('createStakingPool(uint32,bool)'); - return abiEncoder.getSelector(); - }, - }; - public currentEpoch = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('currentEpoch()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('currentEpoch()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public currentEpochStartTimeInSeconds = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('currentEpochStartTimeInSeconds()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('currentEpochStartTimeInSeconds()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Decreases the operator share for the given pool (i.e. increases pool rewards for members). - */ - public decreaseStakingPoolOperatorShare = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param poolId Unique Id of pool. - * @param newOperatorShare The newly decreased percentage of any rewards owned - * by the operator. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - poolId: string, - newOperatorShare: number | BigNumber, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('poolId', poolId); - assert.isNumberOrBigNumber('newOperatorShare', newOperatorShare); - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('decreaseStakingPoolOperatorShare(bytes32,uint32)', [ - poolId, - newOperatorShare, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.decreaseStakingPoolOperatorShare.callAsync(poolId, newOperatorShare, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param poolId Unique Id of pool. - * @param newOperatorShare The newly decreased percentage of any rewards owned - * by the operator. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - poolId: string, - newOperatorShare: number | BigNumber, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('poolId', poolId); - assert.isNumberOrBigNumber('newOperatorShare', newOperatorShare); - const self = (this as any) as StakingContract; - const txHashPromise = self.decreaseStakingPoolOperatorShare.sendTransactionAsync( - poolId, - newOperatorShare, - txData, - opts, - ); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param poolId Unique Id of pool. - * @param newOperatorShare The newly decreased percentage of any rewards owned - * by the operator. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - poolId: string, - newOperatorShare: number | BigNumber, - txData?: Partial | undefined, - ): Promise { - assert.isString('poolId', poolId); - assert.isNumberOrBigNumber('newOperatorShare', newOperatorShare); - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('decreaseStakingPoolOperatorShare(bytes32,uint32)', [ - poolId, - newOperatorShare, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param poolId Unique Id of pool. - * @param newOperatorShare The newly decreased percentage of any rewards owned - * by the operator. - */ - async callAsync( - poolId: string, - newOperatorShare: number | BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('poolId', poolId); - assert.isNumberOrBigNumber('newOperatorShare', newOperatorShare); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('decreaseStakingPoolOperatorShare(bytes32,uint32)', [ - poolId, - newOperatorShare, - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('decreaseStakingPoolOperatorShare(bytes32,uint32)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param poolId Unique Id of pool. - * @param newOperatorShare The newly decreased percentage of any rewards owned - * by the operator. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(poolId: string, newOperatorShare: number | BigNumber): string { - assert.isString('poolId', poolId); - assert.isNumberOrBigNumber('newOperatorShare', newOperatorShare); - const self = (this as any) as StakingContract; - const abiEncodedTransactionData = self._strictEncodeArguments( - 'decreaseStakingPoolOperatorShare(bytes32,uint32)', - [poolId, newOperatorShare], - ); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as StakingContract; - const abiEncoder = self._lookupAbiEncoder('decreaseStakingPoolOperatorShare(bytes32,uint32)'); - return abiEncoder.getSelector(); - }, - }; - /** - * Begins a new epoch, preparing the prior one for finalization. - * Throws if not enough time has passed between epochs or if the - * previous epoch was not fully finalized. - */ - public endEpoch = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('endEpoch()', []); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.endEpoch.callAsync(txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - const self = (this as any) as StakingContract; - const txHashPromise = self.endEpoch.sendTransactionAsync(txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync(txData?: Partial | undefined): Promise { - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('endEpoch()', []); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @returns numPoolsToFinalize The number of unfinalized pools. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('endEpoch()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('endEpoch()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(): string { - const self = (this as any) as StakingContract; - const abiEncodedTransactionData = self._strictEncodeArguments('endEpoch()', []); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as StakingContract; - const abiEncoder = self._lookupAbiEncoder('endEpoch()'); - return abiEncoder.getSelector(); - }, - }; - public epochDurationInSeconds = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('epochDurationInSeconds()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('epochDurationInSeconds()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Instantly finalizes a single pool that earned rewards in the previous - * epoch, crediting it rewards for members and withdrawing operator's - * rewards as WETH. This can be called by internal functions that need - * to finalize a pool immediately. Does nothing if the pool is already - * finalized or did not earn rewards in the previous epoch. - */ - public finalizePool = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param poolId The pool ID to finalize. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - poolId: string, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('poolId', poolId); - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('finalizePool(bytes32)', [poolId]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.finalizePool.callAsync(poolId, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param poolId The pool ID to finalize. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - poolId: string, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('poolId', poolId); - const self = (this as any) as StakingContract; - const txHashPromise = self.finalizePool.sendTransactionAsync(poolId, txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param poolId The pool ID to finalize. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync(poolId: string, txData?: Partial | undefined): Promise { - assert.isString('poolId', poolId); - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('finalizePool(bytes32)', [poolId]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + private _methodABIIndex: { [name: string]: number } = {}; + private readonly _subscriptionManager: SubscriptionManager; + public static async deployFrom0xArtifactAsync( + artifact: ContractArtifact | SimpleContractArtifact, + supportedProvider: SupportedProvider, + txDefaults: Partial, + logDecodeDependencies: { [contractName: string]: ContractArtifact | SimpleContractArtifact }, + wethAddress_: string, + zrxVaultAddress_: string, + ): Promise { + assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (artifact.compilerOutput === undefined) { + throw new Error('Compiler output not found in the artifact file'); + } + const provider = providerUtils.standardizeOrThrow(supportedProvider); + const bytecode = artifact.compilerOutput.evm.bytecode.object; + const abi = artifact.compilerOutput.abi; + const logDecodeDependenciesAbiOnly: { [contractName: string]: ContractAbi } = {}; + if (Object.keys(logDecodeDependencies) !== undefined) { + for (const key of Object.keys(logDecodeDependencies)) { + logDecodeDependenciesAbiOnly[key] = logDecodeDependencies[key].compilerOutput.abi; } + } + return StakingContract.deployAsync( + bytecode, + abi, + provider, + txDefaults, + logDecodeDependenciesAbiOnly, + wethAddress_, + zrxVaultAddress_, + ); + } + public static async deployAsync( + bytecode: string, + abi: ContractAbi, + supportedProvider: SupportedProvider, + txDefaults: Partial, + logDecodeDependencies: { [contractName: string]: ContractAbi }, + wethAddress_: string, + zrxVaultAddress_: string, + ): Promise { + assert.isHexString('bytecode', bytecode); + assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + const provider = providerUtils.standardizeOrThrow(supportedProvider); + const constructorAbi = BaseContract._lookupConstructorAbi(abi); + [wethAddress_, zrxVaultAddress_] = BaseContract._formatABIDataItemList( + constructorAbi.inputs, + [wethAddress_, zrxVaultAddress_], + BaseContract._bigNumberToString, + ); + const iface = new ethers.utils.Interface(abi); + const deployInfo = iface.deployFunction; + const txData = deployInfo.encode(bytecode, [wethAddress_, zrxVaultAddress_]); + const web3Wrapper = new Web3Wrapper(provider); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { data: txData }, + txDefaults, + web3Wrapper.estimateGasAsync.bind(web3Wrapper), + ); + const txHash = await web3Wrapper.sendTransactionAsync(txDataWithDefaults); + logUtils.log(`transactionHash: ${txHash}`); + const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash); + logUtils.log(`Staking successfully deployed at ${txReceipt.contractAddress}`); + const contractInstance = new StakingContract( + txReceipt.contractAddress as string, + provider, + txDefaults, + logDecodeDependencies, + ); + contractInstance.constructorArgs = [wethAddress_, zrxVaultAddress_]; + return contractInstance; + } - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param poolId The pool ID to finalize. - */ - async callAsync(poolId: string, callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.isString('poolId', poolId); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('finalizePool(bytes32)', [poolId]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('finalizePool(bytes32)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param poolId The pool ID to finalize. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(poolId: string): string { - assert.isString('poolId', poolId); - const self = (this as any) as StakingContract; - const abiEncodedTransactionData = self._strictEncodeArguments('finalizePool(bytes32)', [poolId]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as StakingContract; - const abiEncoder = self._lookupAbiEncoder('finalizePool(bytes32)'); - return abiEncoder.getSelector(); - }, - }; - /** - * Gets all authorized addresses. - */ - public getAuthorizedAddresses = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @returns Array of authorized addresses. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('getAuthorizedAddresses()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('getAuthorizedAddresses()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Returns the earliest end time in seconds of this epoch. - * The next epoch can begin once this time is reached. - * Epoch period = [startTimeInSeconds..endTimeInSeconds) - */ - public getCurrentEpochEarliestEndTimeInSeconds = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @returns Time in seconds. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('getCurrentEpochEarliestEndTimeInSeconds()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('getCurrentEpochEarliestEndTimeInSeconds()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Gets global stake for a given status. - */ - public getGlobalStakeByStatus = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param stakeStatus UNDELEGATED or DELEGATED - * @returns Global stake for given status. - */ - async callAsync( - stakeStatus: number | BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise<{ currentEpoch: BigNumber; currentEpochBalance: BigNumber; nextEpochBalance: BigNumber }> { - assert.isNumberOrBigNumber('stakeStatus', stakeStatus); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('getGlobalStakeByStatus(uint8)', [stakeStatus]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('getGlobalStakeByStatus(uint8)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue<{ - currentEpoch: BigNumber; - currentEpochBalance: BigNumber; - nextEpochBalance: BigNumber; - }>(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Gets an owner's stake balances by status. - */ - public getOwnerStakeByStatus = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param staker Owner of stake. - * @param stakeStatus UNDELEGATED or DELEGATED - * @returns Owner's stake balances for given status. - */ - async callAsync( - staker: string, - stakeStatus: number | BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise<{ currentEpoch: BigNumber; currentEpochBalance: BigNumber; nextEpochBalance: BigNumber }> { - assert.isString('staker', staker); - assert.isNumberOrBigNumber('stakeStatus', stakeStatus); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('getOwnerStakeByStatus(address,uint8)', [ - staker.toLowerCase(), - stakeStatus, - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('getOwnerStakeByStatus(address,uint8)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue<{ - currentEpoch: BigNumber; - currentEpochBalance: BigNumber; - nextEpochBalance: BigNumber; - }>(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Retrieves all configurable parameter values. - */ - public getParams = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @returns _epochDurationInSeconds Minimum seconds between epochs._rewardDelegatedStakeWeight How much delegated stake is weighted vs operator stake, in ppm._minimumPoolStake Minimum amount of stake required in a pool to collect rewards._cobbDouglasAlphaNumerator Numerator for cobb douglas alpha factor._cobbDouglasAlphaDenominator Denominator for cobb douglas alpha factor. - */ - async callAsync( - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise<[BigNumber, number, BigNumber, number, number]> { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('getParams()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('getParams()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue<[BigNumber, number, BigNumber, number, number]>( - rawCallResult, - ); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Returns the stake delegated to a specific staking pool, by a given staker. - */ - public getStakeDelegatedToPoolByOwner = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param staker of stake. - * @param poolId Unique Id of pool. - * @returns Stake delegated to pool by staker. - */ - async callAsync( - staker: string, - poolId: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise<{ currentEpoch: BigNumber; currentEpochBalance: BigNumber; nextEpochBalance: BigNumber }> { - assert.isString('staker', staker); - assert.isString('poolId', poolId); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('getStakeDelegatedToPoolByOwner(address,bytes32)', [ - staker.toLowerCase(), - poolId, - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('getStakeDelegatedToPoolByOwner(address,bytes32)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue<{ - currentEpoch: BigNumber; - currentEpochBalance: BigNumber; - nextEpochBalance: BigNumber; - }>(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Returns a staking pool - */ - public getStakingPool = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param poolId Unique id of pool. - */ - async callAsync( - poolId: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise<{ operator: string; operatorShare: number }> { - assert.isString('poolId', poolId); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('getStakingPool(bytes32)', [poolId]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('getStakingPool(bytes32)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue<{ operator: string; operatorShare: number }>( - rawCallResult, - ); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Get stats on a staking pool in this epoch. - */ - public getStakingPoolStatsThisEpoch = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param poolId Pool Id to query. - * @returns PoolStats struct for pool id. - */ - async callAsync( - poolId: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise<{ feesCollected: BigNumber; weightedStake: BigNumber; membersStake: BigNumber }> { - assert.isString('poolId', poolId); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('getStakingPoolStatsThisEpoch(bytes32)', [poolId]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('getStakingPoolStatsThisEpoch(bytes32)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue<{ - feesCollected: BigNumber; - weightedStake: BigNumber; - membersStake: BigNumber; - }>(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Returns the total stake for a given staker. - */ - public getTotalStake = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param staker of stake. - * @returns Total ZRX staked by `staker`. - */ - async callAsync( - staker: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('staker', staker); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('getTotalStake(address)', [staker.toLowerCase()]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('getTotalStake(address)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Returns the total stake delegated to a specific staking pool, - * across all members. - */ - public getTotalStakeDelegatedToPool = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param poolId Unique Id of pool. - * @returns Total stake delegated to pool. - */ - async callAsync( - poolId: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise<{ currentEpoch: BigNumber; currentEpochBalance: BigNumber; nextEpochBalance: BigNumber }> { - assert.isString('poolId', poolId); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('getTotalStakeDelegatedToPool(bytes32)', [poolId]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('getTotalStakeDelegatedToPool(bytes32)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue<{ - currentEpoch: BigNumber; - currentEpochBalance: BigNumber; - nextEpochBalance: BigNumber; - }>(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Returns the current weth contract address - */ - public getWethContract = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @returns wethContract The WETH contract instance. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('getWethContract()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('getWethContract()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Returns the current zrxVault address. - */ - public getZrxVault = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @returns zrxVault The zrxVault contract. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('getZrxVault()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('getZrxVault()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; /** - * Initialize storage owned by this contract. - * This function should not be called directly. - * The StakingProxy contract will call it in `attachStakingContract()`. - */ - public init = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('init()', []); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.init.callAsync(txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - const self = (this as any) as StakingContract; - const txHashPromise = self.init.sendTransactionAsync(txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync(txData?: Partial | undefined): Promise { - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('init()', []); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('init()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('init()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(): string { - const self = (this as any) as StakingContract; - const abiEncodedTransactionData = self._strictEncodeArguments('init()', []); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as StakingContract; - const abiEncoder = self._lookupAbiEncoder('init()'); - return abiEncoder.getSelector(); - }, - }; - /** - * Allows caller to join a staking pool as a maker. - */ - public joinStakingPoolAsMaker = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param poolId Unique id of pool. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - poolId: string, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('poolId', poolId); - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('joinStakingPoolAsMaker(bytes32)', [poolId]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.joinStakingPoolAsMaker.callAsync(poolId, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param poolId Unique id of pool. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - poolId: string, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('poolId', poolId); - const self = (this as any) as StakingContract; - const txHashPromise = self.joinStakingPoolAsMaker.sendTransactionAsync(poolId, txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param poolId Unique id of pool. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync(poolId: string, txData?: Partial | undefined): Promise { - assert.isString('poolId', poolId); - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('joinStakingPoolAsMaker(bytes32)', [poolId]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param poolId Unique id of pool. - */ - async callAsync(poolId: string, callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.isString('poolId', poolId); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('joinStakingPoolAsMaker(bytes32)', [poolId]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('joinStakingPoolAsMaker(bytes32)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param poolId Unique id of pool. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(poolId: string): string { - assert.isString('poolId', poolId); - const self = (this as any) as StakingContract; - const abiEncodedTransactionData = self._strictEncodeArguments('joinStakingPoolAsMaker(bytes32)', [poolId]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as StakingContract; - const abiEncoder = self._lookupAbiEncoder('joinStakingPoolAsMaker(bytes32)'); - return abiEncoder.getSelector(); - }, - }; - public lastPoolId = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('lastPoolId()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('lastPoolId()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public minimumPoolStake = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('minimumPoolStake()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('minimumPoolStake()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Moves stake between statuses: 'undelegated' or 'delegated'. - * Delegated stake can also be moved between pools. - * This change comes into effect next epoch. - */ - public moveStake = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param from status to move stake out of. - * @param to status to move stake into. - * @param amount of stake to move. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - from: { status: number | BigNumber; poolId: string }, - to: { status: number | BigNumber; poolId: string }, - amount: BigNumber, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isBigNumber('amount', amount); - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('moveStake((uint8,bytes32),(uint8,bytes32),uint256)', [ - from, - to, - amount, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.moveStake.callAsync(from, to, amount, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param from status to move stake out of. - * @param to status to move stake into. - * @param amount of stake to move. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - from: { status: number | BigNumber; poolId: string }, - to: { status: number | BigNumber; poolId: string }, - amount: BigNumber, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isBigNumber('amount', amount); - const self = (this as any) as StakingContract; - const txHashPromise = self.moveStake.sendTransactionAsync(from, to, amount, txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param from status to move stake out of. - * @param to status to move stake into. - * @param amount of stake to move. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - from: { status: number | BigNumber; poolId: string }, - to: { status: number | BigNumber; poolId: string }, - amount: BigNumber, - txData?: Partial | undefined, - ): Promise { - assert.isBigNumber('amount', amount); - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('moveStake((uint8,bytes32),(uint8,bytes32),uint256)', [ - from, - to, - amount, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param from status to move stake out of. - * @param to status to move stake into. - * @param amount of stake to move. - */ - async callAsync( - from: { status: number | BigNumber; poolId: string }, - to: { status: number | BigNumber; poolId: string }, - amount: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isBigNumber('amount', amount); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('moveStake((uint8,bytes32),(uint8,bytes32),uint256)', [ - from, - to, - amount, - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('moveStake((uint8,bytes32),(uint8,bytes32),uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param from status to move stake out of. - * @param to status to move stake into. - * @param amount of stake to move. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData( - from: { status: number | BigNumber; poolId: string }, - to: { status: number | BigNumber; poolId: string }, - amount: BigNumber, - ): string { - assert.isBigNumber('amount', amount); - const self = (this as any) as StakingContract; - const abiEncodedTransactionData = self._strictEncodeArguments( - 'moveStake((uint8,bytes32),(uint8,bytes32),uint256)', - [from, to, amount], - ); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as StakingContract; - const abiEncoder = self._lookupAbiEncoder('moveStake((uint8,bytes32),(uint8,bytes32),uint256)'); - return abiEncoder.getSelector(); - }, - }; - public owner = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('owner()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('owner()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Pays a protocol fee in ETH or WETH. - * Only a known 0x exchange can call this method. See - * (MixinExchangeManager). - */ - public payProtocolFee = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param makerAddress The address of the order's maker. - * @param payerAddress The address of the protocol fee payer. - * @param protocolFee The protocol fee amount. This is either passed as ETH or - * transferred as WETH. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - makerAddress: string, - payerAddress: string, - protocolFee: BigNumber, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('makerAddress', makerAddress); - assert.isString('payerAddress', payerAddress); - assert.isBigNumber('protocolFee', protocolFee); - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('payProtocolFee(address,address,uint256)', [ - makerAddress.toLowerCase(), - payerAddress.toLowerCase(), - protocolFee, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.payProtocolFee.callAsync(makerAddress, payerAddress, protocolFee, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param makerAddress The address of the order's maker. - * @param payerAddress The address of the protocol fee payer. - * @param protocolFee The protocol fee amount. This is either passed as ETH or - * transferred as WETH. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - makerAddress: string, - payerAddress: string, - protocolFee: BigNumber, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('makerAddress', makerAddress); - assert.isString('payerAddress', payerAddress); - assert.isBigNumber('protocolFee', protocolFee); - const self = (this as any) as StakingContract; - const txHashPromise = self.payProtocolFee.sendTransactionAsync( - makerAddress.toLowerCase(), - payerAddress.toLowerCase(), - protocolFee, - txData, - opts, - ); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param makerAddress The address of the order's maker. - * @param payerAddress The address of the protocol fee payer. - * @param protocolFee The protocol fee amount. This is either passed as ETH or - * transferred as WETH. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - makerAddress: string, - payerAddress: string, - protocolFee: BigNumber, - txData?: Partial | undefined, - ): Promise { - assert.isString('makerAddress', makerAddress); - assert.isString('payerAddress', payerAddress); - assert.isBigNumber('protocolFee', protocolFee); - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('payProtocolFee(address,address,uint256)', [ - makerAddress.toLowerCase(), - payerAddress.toLowerCase(), - protocolFee, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param makerAddress The address of the order's maker. - * @param payerAddress The address of the protocol fee payer. - * @param protocolFee The protocol fee amount. This is either passed as ETH or - * transferred as WETH. - */ - async callAsync( - makerAddress: string, - payerAddress: string, - protocolFee: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('makerAddress', makerAddress); - assert.isString('payerAddress', payerAddress); - assert.isBigNumber('protocolFee', protocolFee); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('payProtocolFee(address,address,uint256)', [ - makerAddress.toLowerCase(), - payerAddress.toLowerCase(), - protocolFee, - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('payProtocolFee(address,address,uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param makerAddress The address of the order's maker. - * @param payerAddress The address of the protocol fee payer. - * @param protocolFee The protocol fee amount. This is either passed as ETH or - * transferred as WETH. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(makerAddress: string, payerAddress: string, protocolFee: BigNumber): string { - assert.isString('makerAddress', makerAddress); - assert.isString('payerAddress', payerAddress); - assert.isBigNumber('protocolFee', protocolFee); - const self = (this as any) as StakingContract; - const abiEncodedTransactionData = self._strictEncodeArguments('payProtocolFee(address,address,uint256)', [ - makerAddress.toLowerCase(), - payerAddress.toLowerCase(), - protocolFee, - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as StakingContract; - const abiEncoder = self._lookupAbiEncoder('payProtocolFee(address,address,uint256)'); - return abiEncoder.getSelector(); - }, - }; - public poolIdByMaker = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(index_0: string, callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.isString('index_0', index_0); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('poolIdByMaker(address)', [index_0.toLowerCase()]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('poolIdByMaker(address)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public poolStatsByEpoch = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync( - index_0: string, - index_1: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise<[BigNumber, BigNumber, BigNumber]> { - assert.isString('index_0', index_0); - assert.isBigNumber('index_1', index_1); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('poolStatsByEpoch(bytes32,uint256)', [index_0, index_1]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('poolStatsByEpoch(bytes32,uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue<[BigNumber, BigNumber, BigNumber]>(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Removes authorizion of an address. - */ - public removeAuthorizedAddress = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param target Address to remove authorization from. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - target: string, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('target', target); - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [target.toLowerCase()]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.removeAuthorizedAddress.callAsync(target, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param target Address to remove authorization from. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - target: string, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('target', target); - const self = (this as any) as StakingContract; - const txHashPromise = self.removeAuthorizedAddress.sendTransactionAsync(target.toLowerCase(), txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param target Address to remove authorization from. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync(target: string, txData?: Partial | undefined): Promise { - assert.isString('target', target); - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [target.toLowerCase()]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param target Address to remove authorization from. - */ - async callAsync(target: string, callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.isString('target', target); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [target.toLowerCase()]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('removeAuthorizedAddress(address)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param target Address to remove authorization from. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(target: string): string { - assert.isString('target', target); - const self = (this as any) as StakingContract; - const abiEncodedTransactionData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [ - target.toLowerCase(), - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as StakingContract; - const abiEncoder = self._lookupAbiEncoder('removeAuthorizedAddress(address)'); - return abiEncoder.getSelector(); - }, - }; - /** - * Removes authorizion of an address. - */ - public removeAuthorizedAddressAtIndex = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param target Address to remove authorization from. - * @param index Index of target in authorities array. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - target: string, - index: BigNumber, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('target', target); - assert.isBigNumber('index', index); - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [ - target.toLowerCase(), - index, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.removeAuthorizedAddressAtIndex.callAsync(target, index, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param target Address to remove authorization from. - * @param index Index of target in authorities array. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - target: string, - index: BigNumber, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('target', target); - assert.isBigNumber('index', index); - const self = (this as any) as StakingContract; - const txHashPromise = self.removeAuthorizedAddressAtIndex.sendTransactionAsync( - target.toLowerCase(), - index, - txData, - opts, - ); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param target Address to remove authorization from. - * @param index Index of target in authorities array. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - target: string, - index: BigNumber, - txData?: Partial | undefined, - ): Promise { - assert.isString('target', target); - assert.isBigNumber('index', index); - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [ - target.toLowerCase(), - index, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param target Address to remove authorization from. - * @param index Index of target in authorities array. - */ - async callAsync( - target: string, - index: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('target', target); - assert.isBigNumber('index', index); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [ - target.toLowerCase(), - index, - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('removeAuthorizedAddressAtIndex(address,uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param target Address to remove authorization from. - * @param index Index of target in authorities array. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(target: string, index: BigNumber): string { - assert.isString('target', target); - assert.isBigNumber('index', index); - const self = (this as any) as StakingContract; - const abiEncodedTransactionData = self._strictEncodeArguments( - 'removeAuthorizedAddressAtIndex(address,uint256)', - [target.toLowerCase(), index], - ); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as StakingContract; - const abiEncoder = self._lookupAbiEncoder('removeAuthorizedAddressAtIndex(address,uint256)'); - return abiEncoder.getSelector(); - }, - }; - /** - * Removes an existing exchange address - */ - public removeExchangeAddress = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param addr Address of exchange contract to remove - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - addr: string, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('addr', addr); - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('removeExchangeAddress(address)', [addr.toLowerCase()]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.removeExchangeAddress.callAsync(addr, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param addr Address of exchange contract to remove - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - addr: string, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('addr', addr); - const self = (this as any) as StakingContract; - const txHashPromise = self.removeExchangeAddress.sendTransactionAsync(addr.toLowerCase(), txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param addr Address of exchange contract to remove - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync(addr: string, txData?: Partial | undefined): Promise { - assert.isString('addr', addr); - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('removeExchangeAddress(address)', [addr.toLowerCase()]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param addr Address of exchange contract to remove - */ - async callAsync(addr: string, callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.isString('addr', addr); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('removeExchangeAddress(address)', [addr.toLowerCase()]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('removeExchangeAddress(address)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param addr Address of exchange contract to remove - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(addr: string): string { - assert.isString('addr', addr); - const self = (this as any) as StakingContract; - const abiEncodedTransactionData = self._strictEncodeArguments('removeExchangeAddress(address)', [ - addr.toLowerCase(), - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as StakingContract; - const abiEncoder = self._lookupAbiEncoder('removeExchangeAddress(address)'); - return abiEncoder.getSelector(); - }, - }; - public rewardDelegatedStakeWeight = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('rewardDelegatedStakeWeight()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('rewardDelegatedStakeWeight()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public rewardsByPoolId = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync( - index_0: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('index_0', index_0); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('rewardsByPoolId(bytes32)', [index_0]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('rewardsByPoolId(bytes32)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Set all configurable parameters at once. - */ - public setParams = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param _epochDurationInSeconds Minimum seconds between epochs. - * @param _rewardDelegatedStakeWeight How much delegated stake is weighted vs - * operator stake, in ppm. - * @param _minimumPoolStake Minimum amount of stake required in a pool to - * collect rewards. - * @param _cobbDouglasAlphaNumerator Numerator for cobb douglas alpha factor. - * @param _cobbDouglasAlphaDenominator Denominator for cobb douglas alpha - * factor. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - _epochDurationInSeconds: BigNumber, - _rewardDelegatedStakeWeight: number | BigNumber, - _minimumPoolStake: BigNumber, - _cobbDouglasAlphaNumerator: number | BigNumber, - _cobbDouglasAlphaDenominator: number | BigNumber, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isBigNumber('_epochDurationInSeconds', _epochDurationInSeconds); - assert.isNumberOrBigNumber('_rewardDelegatedStakeWeight', _rewardDelegatedStakeWeight); - assert.isBigNumber('_minimumPoolStake', _minimumPoolStake); - assert.isNumberOrBigNumber('_cobbDouglasAlphaNumerator', _cobbDouglasAlphaNumerator); - assert.isNumberOrBigNumber('_cobbDouglasAlphaDenominator', _cobbDouglasAlphaDenominator); - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('setParams(uint256,uint32,uint256,uint32,uint32)', [ - _epochDurationInSeconds, - _rewardDelegatedStakeWeight, - _minimumPoolStake, - _cobbDouglasAlphaNumerator, - _cobbDouglasAlphaDenominator, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.setParams.callAsync( - _epochDurationInSeconds, - _rewardDelegatedStakeWeight, - _minimumPoolStake, - _cobbDouglasAlphaNumerator, - _cobbDouglasAlphaDenominator, - txDataWithDefaults, - ); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param _epochDurationInSeconds Minimum seconds between epochs. - * @param _rewardDelegatedStakeWeight How much delegated stake is weighted vs - * operator stake, in ppm. - * @param _minimumPoolStake Minimum amount of stake required in a pool to - * collect rewards. - * @param _cobbDouglasAlphaNumerator Numerator for cobb douglas alpha factor. - * @param _cobbDouglasAlphaDenominator Denominator for cobb douglas alpha - * factor. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - _epochDurationInSeconds: BigNumber, - _rewardDelegatedStakeWeight: number | BigNumber, - _minimumPoolStake: BigNumber, - _cobbDouglasAlphaNumerator: number | BigNumber, - _cobbDouglasAlphaDenominator: number | BigNumber, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isBigNumber('_epochDurationInSeconds', _epochDurationInSeconds); - assert.isNumberOrBigNumber('_rewardDelegatedStakeWeight', _rewardDelegatedStakeWeight); - assert.isBigNumber('_minimumPoolStake', _minimumPoolStake); - assert.isNumberOrBigNumber('_cobbDouglasAlphaNumerator', _cobbDouglasAlphaNumerator); - assert.isNumberOrBigNumber('_cobbDouglasAlphaDenominator', _cobbDouglasAlphaDenominator); - const self = (this as any) as StakingContract; - const txHashPromise = self.setParams.sendTransactionAsync( - _epochDurationInSeconds, - _rewardDelegatedStakeWeight, - _minimumPoolStake, - _cobbDouglasAlphaNumerator, - _cobbDouglasAlphaDenominator, - txData, - opts, - ); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param _epochDurationInSeconds Minimum seconds between epochs. - * @param _rewardDelegatedStakeWeight How much delegated stake is weighted vs - * operator stake, in ppm. - * @param _minimumPoolStake Minimum amount of stake required in a pool to - * collect rewards. - * @param _cobbDouglasAlphaNumerator Numerator for cobb douglas alpha factor. - * @param _cobbDouglasAlphaDenominator Denominator for cobb douglas alpha - * factor. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - _epochDurationInSeconds: BigNumber, - _rewardDelegatedStakeWeight: number | BigNumber, - _minimumPoolStake: BigNumber, - _cobbDouglasAlphaNumerator: number | BigNumber, - _cobbDouglasAlphaDenominator: number | BigNumber, - txData?: Partial | undefined, - ): Promise { - assert.isBigNumber('_epochDurationInSeconds', _epochDurationInSeconds); - assert.isNumberOrBigNumber('_rewardDelegatedStakeWeight', _rewardDelegatedStakeWeight); - assert.isBigNumber('_minimumPoolStake', _minimumPoolStake); - assert.isNumberOrBigNumber('_cobbDouglasAlphaNumerator', _cobbDouglasAlphaNumerator); - assert.isNumberOrBigNumber('_cobbDouglasAlphaDenominator', _cobbDouglasAlphaDenominator); - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('setParams(uint256,uint32,uint256,uint32,uint32)', [ - _epochDurationInSeconds, - _rewardDelegatedStakeWeight, - _minimumPoolStake, - _cobbDouglasAlphaNumerator, - _cobbDouglasAlphaDenominator, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param _epochDurationInSeconds Minimum seconds between epochs. - * @param _rewardDelegatedStakeWeight How much delegated stake is weighted vs - * operator stake, in ppm. - * @param _minimumPoolStake Minimum amount of stake required in a pool to - * collect rewards. - * @param _cobbDouglasAlphaNumerator Numerator for cobb douglas alpha factor. - * @param _cobbDouglasAlphaDenominator Denominator for cobb douglas alpha - * factor. - */ - async callAsync( - _epochDurationInSeconds: BigNumber, - _rewardDelegatedStakeWeight: number | BigNumber, - _minimumPoolStake: BigNumber, - _cobbDouglasAlphaNumerator: number | BigNumber, - _cobbDouglasAlphaDenominator: number | BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isBigNumber('_epochDurationInSeconds', _epochDurationInSeconds); - assert.isNumberOrBigNumber('_rewardDelegatedStakeWeight', _rewardDelegatedStakeWeight); - assert.isBigNumber('_minimumPoolStake', _minimumPoolStake); - assert.isNumberOrBigNumber('_cobbDouglasAlphaNumerator', _cobbDouglasAlphaNumerator); - assert.isNumberOrBigNumber('_cobbDouglasAlphaDenominator', _cobbDouglasAlphaDenominator); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('setParams(uint256,uint32,uint256,uint32,uint32)', [ - _epochDurationInSeconds, - _rewardDelegatedStakeWeight, - _minimumPoolStake, - _cobbDouglasAlphaNumerator, - _cobbDouglasAlphaDenominator, - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('setParams(uint256,uint32,uint256,uint32,uint32)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param _epochDurationInSeconds Minimum seconds between epochs. - * @param _rewardDelegatedStakeWeight How much delegated stake is weighted vs - * operator stake, in ppm. - * @param _minimumPoolStake Minimum amount of stake required in a pool to - * collect rewards. - * @param _cobbDouglasAlphaNumerator Numerator for cobb douglas alpha factor. - * @param _cobbDouglasAlphaDenominator Denominator for cobb douglas alpha - * factor. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData( - _epochDurationInSeconds: BigNumber, - _rewardDelegatedStakeWeight: number | BigNumber, - _minimumPoolStake: BigNumber, - _cobbDouglasAlphaNumerator: number | BigNumber, - _cobbDouglasAlphaDenominator: number | BigNumber, - ): string { - assert.isBigNumber('_epochDurationInSeconds', _epochDurationInSeconds); - assert.isNumberOrBigNumber('_rewardDelegatedStakeWeight', _rewardDelegatedStakeWeight); - assert.isBigNumber('_minimumPoolStake', _minimumPoolStake); - assert.isNumberOrBigNumber('_cobbDouglasAlphaNumerator', _cobbDouglasAlphaNumerator); - assert.isNumberOrBigNumber('_cobbDouglasAlphaDenominator', _cobbDouglasAlphaDenominator); - const self = (this as any) as StakingContract; - const abiEncodedTransactionData = self._strictEncodeArguments( - 'setParams(uint256,uint32,uint256,uint32,uint32)', - [ - _epochDurationInSeconds, - _rewardDelegatedStakeWeight, - _minimumPoolStake, - _cobbDouglasAlphaNumerator, - _cobbDouglasAlphaDenominator, - ], - ); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as StakingContract; - const abiEncoder = self._lookupAbiEncoder('setParams(uint256,uint32,uint256,uint32,uint32)'); - return abiEncoder.getSelector(); - }, - }; - /** - * Stake ZRX tokens. Tokens are deposited into the ZRX Vault. - * Unstake to retrieve the ZRX. Stake is in the 'Active' status. - */ - public stake = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param amount of ZRX to stake. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - amount: BigNumber, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isBigNumber('amount', amount); - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('stake(uint256)', [amount]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.stake.callAsync(amount, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param amount of ZRX to stake. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - amount: BigNumber, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isBigNumber('amount', amount); - const self = (this as any) as StakingContract; - const txHashPromise = self.stake.sendTransactionAsync(amount, txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param amount of ZRX to stake. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync(amount: BigNumber, txData?: Partial | undefined): Promise { - assert.isBigNumber('amount', amount); - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('stake(uint256)', [amount]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param amount of ZRX to stake. - */ - async callAsync(amount: BigNumber, callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.isBigNumber('amount', amount); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('stake(uint256)', [amount]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('stake(uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param amount of ZRX to stake. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(amount: BigNumber): string { - assert.isBigNumber('amount', amount); - const self = (this as any) as StakingContract; - const abiEncodedTransactionData = self._strictEncodeArguments('stake(uint256)', [amount]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as StakingContract; - const abiEncoder = self._lookupAbiEncoder('stake(uint256)'); - return abiEncoder.getSelector(); - }, - }; - public stakingContract = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('stakingContract()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('stakingContract()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public transferOwnership = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - newOwner: string, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('newOwner', newOwner); - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.transferOwnership.callAsync(newOwner, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - newOwner: string, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('newOwner', newOwner); - const self = (this as any) as StakingContract; - const txHashPromise = self.transferOwnership.sendTransactionAsync(newOwner.toLowerCase(), txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync(newOwner: string, txData?: Partial | undefined): Promise { - assert.isString('newOwner', newOwner); - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(newOwner: string, callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.isString('newOwner', newOwner); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('transferOwnership(address)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(newOwner: string): string { - assert.isString('newOwner', newOwner); - const self = (this as any) as StakingContract; - const abiEncodedTransactionData = self._strictEncodeArguments('transferOwnership(address)', [ - newOwner.toLowerCase(), - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as StakingContract; - const abiEncoder = self._lookupAbiEncoder('transferOwnership(address)'); - return abiEncoder.getSelector(); - }, - }; - /** - * Unstake. Tokens are withdrawn from the ZRX Vault and returned to - * the staker. Stake must be in the 'undelegated' status in both the - * current and next epoch in order to be unstaked. - */ - public unstake = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param amount of ZRX to unstake. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - amount: BigNumber, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isBigNumber('amount', amount); - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('unstake(uint256)', [amount]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.unstake.callAsync(amount, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param amount of ZRX to unstake. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - amount: BigNumber, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isBigNumber('amount', amount); - const self = (this as any) as StakingContract; - const txHashPromise = self.unstake.sendTransactionAsync(amount, txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param amount of ZRX to unstake. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync(amount: BigNumber, txData?: Partial | undefined): Promise { - assert.isBigNumber('amount', amount); - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('unstake(uint256)', [amount]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param amount of ZRX to unstake. - */ - async callAsync(amount: BigNumber, callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.isBigNumber('amount', amount); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('unstake(uint256)', [amount]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('unstake(uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param amount of ZRX to unstake. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(amount: BigNumber): string { - assert.isBigNumber('amount', amount); - const self = (this as any) as StakingContract; - const abiEncodedTransactionData = self._strictEncodeArguments('unstake(uint256)', [amount]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as StakingContract; - const abiEncoder = self._lookupAbiEncoder('unstake(uint256)'); - return abiEncoder.getSelector(); - }, - }; - public validExchanges = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync( - index_0: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('index_0', index_0); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('validExchanges(address)', [index_0.toLowerCase()]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('validExchanges(address)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public wethReservedForPoolRewards = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('wethReservedForPoolRewards()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('wethReservedForPoolRewards()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Withdraws the caller's WETH rewards that have accumulated - * until the last epoch. - */ - public withdrawDelegatorRewards = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param poolId Unique id of pool. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - poolId: string, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('poolId', poolId); - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('withdrawDelegatorRewards(bytes32)', [poolId]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.withdrawDelegatorRewards.callAsync(poolId, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param poolId Unique id of pool. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - poolId: string, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('poolId', poolId); - const self = (this as any) as StakingContract; - const txHashPromise = self.withdrawDelegatorRewards.sendTransactionAsync(poolId, txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param poolId Unique id of pool. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync(poolId: string, txData?: Partial | undefined): Promise { - assert.isString('poolId', poolId); - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('withdrawDelegatorRewards(bytes32)', [poolId]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param poolId Unique id of pool. - */ - async callAsync(poolId: string, callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.isString('poolId', poolId); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingContract; - const encodedData = self._strictEncodeArguments('withdrawDelegatorRewards(bytes32)', [poolId]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('withdrawDelegatorRewards(bytes32)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param poolId Unique id of pool. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(poolId: string): string { - assert.isString('poolId', poolId); - const self = (this as any) as StakingContract; - const abiEncodedTransactionData = self._strictEncodeArguments('withdrawDelegatorRewards(bytes32)', [ - poolId, - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as StakingContract; - const abiEncoder = self._lookupAbiEncoder('withdrawDelegatorRewards(bytes32)'); - return abiEncoder.getSelector(); - }, - }; - private readonly _subscriptionManager: SubscriptionManager; - public static async deployFrom0xArtifactAsync( - artifact: ContractArtifact | SimpleContractArtifact, - supportedProvider: SupportedProvider, - txDefaults: Partial, - logDecodeDependencies: { [contractName: string]: ContractArtifact | SimpleContractArtifact }, - wethAddress_: string, - zrxVaultAddress_: string, - ): Promise { - assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (artifact.compilerOutput === undefined) { - throw new Error('Compiler output not found in the artifact file'); - } - const provider = providerUtils.standardizeOrThrow(supportedProvider); - const bytecode = artifact.compilerOutput.evm.bytecode.object; - const abi = artifact.compilerOutput.abi; - const logDecodeDependenciesAbiOnly: { [contractName: string]: ContractAbi } = {}; - if (Object.keys(logDecodeDependencies) !== undefined) { - for (const key of Object.keys(logDecodeDependencies)) { - logDecodeDependenciesAbiOnly[key] = logDecodeDependencies[key].compilerOutput.abi; - } - } - return StakingContract.deployAsync( - bytecode, - abi, - provider, - txDefaults, - logDecodeDependenciesAbiOnly, - wethAddress_, - zrxVaultAddress_, - ); - } - public static async deployAsync( - bytecode: string, - abi: ContractAbi, - supportedProvider: SupportedProvider, - txDefaults: Partial, - logDecodeDependencies: { [contractName: string]: ContractAbi }, - wethAddress_: string, - zrxVaultAddress_: string, - ): Promise { - assert.isHexString('bytecode', bytecode); - assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - const provider = providerUtils.standardizeOrThrow(supportedProvider); - const constructorAbi = BaseContract._lookupConstructorAbi(abi); - [wethAddress_, zrxVaultAddress_] = BaseContract._formatABIDataItemList( - constructorAbi.inputs, - [wethAddress_, zrxVaultAddress_], - BaseContract._bigNumberToString, - ); - const iface = new ethers.utils.Interface(abi); - const deployInfo = iface.deployFunction; - const txData = deployInfo.encode(bytecode, [wethAddress_, zrxVaultAddress_]); - const web3Wrapper = new Web3Wrapper(provider); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { data: txData }, - txDefaults, - web3Wrapper.estimateGasAsync.bind(web3Wrapper), - ); - const txHash = await web3Wrapper.sendTransactionAsync(txDataWithDefaults); - logUtils.log(`transactionHash: ${txHash}`); - const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash); - logUtils.log(`Staking successfully deployed at ${txReceipt.contractAddress}`); - const contractInstance = new StakingContract( - txReceipt.contractAddress as string, - provider, - txDefaults, - logDecodeDependencies, - ); - contractInstance.constructorArgs = [wethAddress_, zrxVaultAddress_]; - return contractInstance; - } - - /** - * @returns The contract ABI + * @returns The contract ABI */ public static ABI(): ContractAbi { const abi = [ @@ -6337,14 +1611,3909 @@ export class StakingContract extends BaseContract { ] as ContractAbi; return abi; } + + public getFunctionSignature(methodName: string): string { + const index = this._methodABIIndex[methodName]; + const methodAbi = StakingContract.ABI()[index] as MethodAbi; + const functionSignature = methodAbiToFunctionSignature(methodAbi); + return functionSignature; + } + public getABIDecodedTransactionData(methodName: string, callData: string): T { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as StakingContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + const abiDecodedCallData = abiEncoder.strictDecode(callData); + return abiDecodedCallData; + } + public getABIDecodedReturnData(methodName: string, callData: string): T { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as StakingContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + const abiDecodedCallData = abiEncoder.strictDecodeReturnValue(callData); + return abiDecodedCallData; + } + public getSelector(methodName: string): string { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as StakingContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + return abiEncoder.getSelector(); + } + /** - * Subscribe to an event type emitted by the Staking contract. - * @param eventName The Staking contract event you would like to subscribe to. - * @param indexFilterValues An object where the keys are indexed args returned by the event and - * the value is the value you are interested in. E.g `{maker: aUserAddressHex}` - * @param callback Callback that gets called when a log is added/removed - * @param isVerbose Enable verbose subscription warnings (e.g recoverable network issues encountered) - * @return Subscription token used later to unsubscribe + * Authorizes an address. + * @param target Address to authorize. + */ + public addAuthorizedAddress(target: string): ContractTxFunctionObj { + const self = (this as any) as StakingContract; + assert.isString('target', target); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('addAuthorizedAddress(address)', [ + target.toLowerCase(), + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('addAuthorizedAddress(address)', [ + target.toLowerCase(), + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('addAuthorizedAddress(address)', [ + target.toLowerCase(), + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('addAuthorizedAddress(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('addAuthorizedAddress(address)', [ + target.toLowerCase(), + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Adds a new exchange address + * @param addr Address of exchange contract to add + */ + public addExchangeAddress(addr: string): ContractTxFunctionObj { + const self = (this as any) as StakingContract; + assert.isString('addr', addr); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('addExchangeAddress(address)', [addr.toLowerCase()]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('addExchangeAddress(address)', [addr.toLowerCase()]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('addExchangeAddress(address)', [addr.toLowerCase()]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('addExchangeAddress(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('addExchangeAddress(address)', [ + addr.toLowerCase(), + ]); + return abiEncodedTransactionData; + }, + }; + } + public aggregatedStatsByEpoch( + index_0: BigNumber, + ): ContractFunctionObj<[BigNumber, BigNumber, BigNumber, BigNumber, BigNumber]> { + const self = (this as any) as StakingContract; + assert.isBigNumber('index_0', index_0); + + return { + async callAsync( + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise<[BigNumber, BigNumber, BigNumber, BigNumber, BigNumber]> { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('aggregatedStatsByEpoch(uint256)', [index_0]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('aggregatedStatsByEpoch(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue< + [BigNumber, BigNumber, BigNumber, BigNumber, BigNumber] + >(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('aggregatedStatsByEpoch(uint256)', [ + index_0, + ]); + return abiEncodedTransactionData; + }, + }; + } + public authorities(index_0: BigNumber): ContractFunctionObj { + const self = (this as any) as StakingContract; + assert.isBigNumber('index_0', index_0); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('authorities(uint256)', [index_0]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('authorities(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('authorities(uint256)', [index_0]); + return abiEncodedTransactionData; + }, + }; + } + public authorized(index_0: string): ContractFunctionObj { + const self = (this as any) as StakingContract; + assert.isString('index_0', index_0); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('authorized(address)', [index_0.toLowerCase()]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('authorized(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('authorized(address)', [ + index_0.toLowerCase(), + ]); + return abiEncodedTransactionData; + }, + }; + } + public cobbDouglasAlphaDenominator(): ContractFunctionObj { + const self = (this as any) as StakingContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('cobbDouglasAlphaDenominator()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('cobbDouglasAlphaDenominator()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('cobbDouglasAlphaDenominator()', []); + return abiEncodedTransactionData; + }, + }; + } + public cobbDouglasAlphaNumerator(): ContractFunctionObj { + const self = (this as any) as StakingContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('cobbDouglasAlphaNumerator()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('cobbDouglasAlphaNumerator()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('cobbDouglasAlphaNumerator()', []); + return abiEncodedTransactionData; + }, + }; + } + /** + * Computes the reward balance in ETH of a specific member of a pool. + * @param poolId Unique id of pool. + * @param member The member of the pool. + * @returns totalReward Balance in ETH. + */ + public computeRewardBalanceOfDelegator(poolId: string, member: string): ContractFunctionObj { + const self = (this as any) as StakingContract; + assert.isString('poolId', poolId); + assert.isString('member', member); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('computeRewardBalanceOfDelegator(bytes32,address)', [ + poolId, + member.toLowerCase(), + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('computeRewardBalanceOfDelegator(bytes32,address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'computeRewardBalanceOfDelegator(bytes32,address)', + [poolId, member.toLowerCase()], + ); + return abiEncodedTransactionData; + }, + }; + } + /** + * Computes the reward balance in ETH of the operator of a pool. + * @param poolId Unique id of pool. + * @returns totalReward Balance in ETH. + */ + public computeRewardBalanceOfOperator(poolId: string): ContractFunctionObj { + const self = (this as any) as StakingContract; + assert.isString('poolId', poolId); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('computeRewardBalanceOfOperator(bytes32)', [poolId]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('computeRewardBalanceOfOperator(bytes32)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'computeRewardBalanceOfOperator(bytes32)', + [poolId], + ); + return abiEncodedTransactionData; + }, + }; + } + /** + * Create a new staking pool. The sender will be the operator of this pool. Note that an operator must be payable. + * @param operatorShare Portion of rewards owned by the operator, in ppm. + * @param addOperatorAsMaker Adds operator to the created pool as a maker for + * convenience iff true. + * @returns poolId The unique pool id generated for this pool. + */ + public createStakingPool( + operatorShare: number | BigNumber, + addOperatorAsMaker: boolean, + ): ContractTxFunctionObj { + const self = (this as any) as StakingContract; + assert.isNumberOrBigNumber('operatorShare', operatorShare); + assert.isBoolean('addOperatorAsMaker', addOperatorAsMaker); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('createStakingPool(uint32,bool)', [ + operatorShare, + addOperatorAsMaker, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('createStakingPool(uint32,bool)', [ + operatorShare, + addOperatorAsMaker, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('createStakingPool(uint32,bool)', [ + operatorShare, + addOperatorAsMaker, + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('createStakingPool(uint32,bool)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('createStakingPool(uint32,bool)', [ + operatorShare, + addOperatorAsMaker, + ]); + return abiEncodedTransactionData; + }, + }; + } + public currentEpoch(): ContractFunctionObj { + const self = (this as any) as StakingContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('currentEpoch()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('currentEpoch()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('currentEpoch()', []); + return abiEncodedTransactionData; + }, + }; + } + public currentEpochStartTimeInSeconds(): ContractFunctionObj { + const self = (this as any) as StakingContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('currentEpochStartTimeInSeconds()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('currentEpochStartTimeInSeconds()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('currentEpochStartTimeInSeconds()', []); + return abiEncodedTransactionData; + }, + }; + } + /** + * Decreases the operator share for the given pool (i.e. increases pool rewards for members). + * @param poolId Unique Id of pool. + * @param newOperatorShare The newly decreased percentage of any rewards owned + * by the operator. + */ + public decreaseStakingPoolOperatorShare( + poolId: string, + newOperatorShare: number | BigNumber, + ): ContractTxFunctionObj { + const self = (this as any) as StakingContract; + assert.isString('poolId', poolId); + assert.isNumberOrBigNumber('newOperatorShare', newOperatorShare); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('decreaseStakingPoolOperatorShare(bytes32,uint32)', [ + poolId, + newOperatorShare, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('decreaseStakingPoolOperatorShare(bytes32,uint32)', [ + poolId, + newOperatorShare, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('decreaseStakingPoolOperatorShare(bytes32,uint32)', [ + poolId, + newOperatorShare, + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('decreaseStakingPoolOperatorShare(bytes32,uint32)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'decreaseStakingPoolOperatorShare(bytes32,uint32)', + [poolId, newOperatorShare], + ); + return abiEncodedTransactionData; + }, + }; + } + /** + * Begins a new epoch, preparing the prior one for finalization. + * Throws if not enough time has passed between epochs or if the + * previous epoch was not fully finalized. + * @returns numPoolsToFinalize The number of unfinalized pools. + */ + public endEpoch(): ContractTxFunctionObj { + const self = (this as any) as StakingContract; + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('endEpoch()', []); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('endEpoch()', []); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('endEpoch()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('endEpoch()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('endEpoch()', []); + return abiEncodedTransactionData; + }, + }; + } + public epochDurationInSeconds(): ContractFunctionObj { + const self = (this as any) as StakingContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('epochDurationInSeconds()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('epochDurationInSeconds()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('epochDurationInSeconds()', []); + return abiEncodedTransactionData; + }, + }; + } + /** + * Instantly finalizes a single pool that earned rewards in the previous + * epoch, crediting it rewards for members and withdrawing operator's + * rewards as WETH. This can be called by internal functions that need + * to finalize a pool immediately. Does nothing if the pool is already + * finalized or did not earn rewards in the previous epoch. + * @param poolId The pool ID to finalize. + */ + public finalizePool(poolId: string): ContractTxFunctionObj { + const self = (this as any) as StakingContract; + assert.isString('poolId', poolId); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('finalizePool(bytes32)', [poolId]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('finalizePool(bytes32)', [poolId]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('finalizePool(bytes32)', [poolId]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('finalizePool(bytes32)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('finalizePool(bytes32)', [poolId]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Gets all authorized addresses. + * @returns Array of authorized addresses. + */ + public getAuthorizedAddresses(): ContractFunctionObj { + const self = (this as any) as StakingContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('getAuthorizedAddresses()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('getAuthorizedAddresses()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('getAuthorizedAddresses()', []); + return abiEncodedTransactionData; + }, + }; + } + /** + * Returns the earliest end time in seconds of this epoch. + * The next epoch can begin once this time is reached. + * Epoch period = [startTimeInSeconds..endTimeInSeconds) + * @returns Time in seconds. + */ + public getCurrentEpochEarliestEndTimeInSeconds(): ContractFunctionObj { + const self = (this as any) as StakingContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('getCurrentEpochEarliestEndTimeInSeconds()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('getCurrentEpochEarliestEndTimeInSeconds()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'getCurrentEpochEarliestEndTimeInSeconds()', + [], + ); + return abiEncodedTransactionData; + }, + }; + } + /** + * Gets global stake for a given status. + * @param stakeStatus UNDELEGATED or DELEGATED + * @returns Global stake for given status. + */ + public getGlobalStakeByStatus( + stakeStatus: number | BigNumber, + ): ContractFunctionObj<{ currentEpoch: BigNumber; currentEpochBalance: BigNumber; nextEpochBalance: BigNumber }> { + const self = (this as any) as StakingContract; + assert.isNumberOrBigNumber('stakeStatus', stakeStatus); + + return { + async callAsync( + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise<{ currentEpoch: BigNumber; currentEpochBalance: BigNumber; nextEpochBalance: BigNumber }> { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('getGlobalStakeByStatus(uint8)', [stakeStatus]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('getGlobalStakeByStatus(uint8)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<{ + currentEpoch: BigNumber; + currentEpochBalance: BigNumber; + nextEpochBalance: BigNumber; + }>(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('getGlobalStakeByStatus(uint8)', [ + stakeStatus, + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Gets an owner's stake balances by status. + * @param staker Owner of stake. + * @param stakeStatus UNDELEGATED or DELEGATED + * @returns Owner's stake balances for given status. + */ + public getOwnerStakeByStatus( + staker: string, + stakeStatus: number | BigNumber, + ): ContractFunctionObj<{ currentEpoch: BigNumber; currentEpochBalance: BigNumber; nextEpochBalance: BigNumber }> { + const self = (this as any) as StakingContract; + assert.isString('staker', staker); + assert.isNumberOrBigNumber('stakeStatus', stakeStatus); + + return { + async callAsync( + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise<{ currentEpoch: BigNumber; currentEpochBalance: BigNumber; nextEpochBalance: BigNumber }> { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('getOwnerStakeByStatus(address,uint8)', [ + staker.toLowerCase(), + stakeStatus, + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('getOwnerStakeByStatus(address,uint8)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<{ + currentEpoch: BigNumber; + currentEpochBalance: BigNumber; + nextEpochBalance: BigNumber; + }>(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('getOwnerStakeByStatus(address,uint8)', [ + staker.toLowerCase(), + stakeStatus, + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Retrieves all configurable parameter values. + * @returns _epochDurationInSeconds Minimum seconds between epochs._rewardDelegatedStakeWeight How much delegated stake is weighted vs operator stake, in ppm._minimumPoolStake Minimum amount of stake required in a pool to collect rewards._cobbDouglasAlphaNumerator Numerator for cobb douglas alpha factor._cobbDouglasAlphaDenominator Denominator for cobb douglas alpha factor. + */ + public getParams(): ContractFunctionObj<[BigNumber, number, BigNumber, number, number]> { + const self = (this as any) as StakingContract; + + return { + async callAsync( + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise<[BigNumber, number, BigNumber, number, number]> { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('getParams()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('getParams()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<[BigNumber, number, BigNumber, number, number]>( + rawCallResult, + ); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('getParams()', []); + return abiEncodedTransactionData; + }, + }; + } + /** + * Returns the stake delegated to a specific staking pool, by a given staker. + * @param staker of stake. + * @param poolId Unique Id of pool. + * @returns Stake delegated to pool by staker. + */ + public getStakeDelegatedToPoolByOwner( + staker: string, + poolId: string, + ): ContractFunctionObj<{ currentEpoch: BigNumber; currentEpochBalance: BigNumber; nextEpochBalance: BigNumber }> { + const self = (this as any) as StakingContract; + assert.isString('staker', staker); + assert.isString('poolId', poolId); + + return { + async callAsync( + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise<{ currentEpoch: BigNumber; currentEpochBalance: BigNumber; nextEpochBalance: BigNumber }> { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('getStakeDelegatedToPoolByOwner(address,bytes32)', [ + staker.toLowerCase(), + poolId, + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('getStakeDelegatedToPoolByOwner(address,bytes32)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<{ + currentEpoch: BigNumber; + currentEpochBalance: BigNumber; + nextEpochBalance: BigNumber; + }>(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'getStakeDelegatedToPoolByOwner(address,bytes32)', + [staker.toLowerCase(), poolId], + ); + return abiEncodedTransactionData; + }, + }; + } + /** + * Returns a staking pool + * @param poolId Unique id of pool. + */ + public getStakingPool(poolId: string): ContractFunctionObj<{ operator: string; operatorShare: number }> { + const self = (this as any) as StakingContract; + assert.isString('poolId', poolId); + + return { + async callAsync( + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise<{ operator: string; operatorShare: number }> { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('getStakingPool(bytes32)', [poolId]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('getStakingPool(bytes32)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<{ operator: string; operatorShare: number }>( + rawCallResult, + ); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('getStakingPool(bytes32)', [poolId]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Get stats on a staking pool in this epoch. + * @param poolId Pool Id to query. + * @returns PoolStats struct for pool id. + */ + public getStakingPoolStatsThisEpoch( + poolId: string, + ): ContractFunctionObj<{ feesCollected: BigNumber; weightedStake: BigNumber; membersStake: BigNumber }> { + const self = (this as any) as StakingContract; + assert.isString('poolId', poolId); + + return { + async callAsync( + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise<{ feesCollected: BigNumber; weightedStake: BigNumber; membersStake: BigNumber }> { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('getStakingPoolStatsThisEpoch(bytes32)', [poolId]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('getStakingPoolStatsThisEpoch(bytes32)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<{ + feesCollected: BigNumber; + weightedStake: BigNumber; + membersStake: BigNumber; + }>(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('getStakingPoolStatsThisEpoch(bytes32)', [ + poolId, + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Returns the total stake for a given staker. + * @param staker of stake. + * @returns Total ZRX staked by `staker`. + */ + public getTotalStake(staker: string): ContractFunctionObj { + const self = (this as any) as StakingContract; + assert.isString('staker', staker); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('getTotalStake(address)', [staker.toLowerCase()]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('getTotalStake(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('getTotalStake(address)', [ + staker.toLowerCase(), + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Returns the total stake delegated to a specific staking pool, + * across all members. + * @param poolId Unique Id of pool. + * @returns Total stake delegated to pool. + */ + public getTotalStakeDelegatedToPool( + poolId: string, + ): ContractFunctionObj<{ currentEpoch: BigNumber; currentEpochBalance: BigNumber; nextEpochBalance: BigNumber }> { + const self = (this as any) as StakingContract; + assert.isString('poolId', poolId); + + return { + async callAsync( + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise<{ currentEpoch: BigNumber; currentEpochBalance: BigNumber; nextEpochBalance: BigNumber }> { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('getTotalStakeDelegatedToPool(bytes32)', [poolId]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('getTotalStakeDelegatedToPool(bytes32)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<{ + currentEpoch: BigNumber; + currentEpochBalance: BigNumber; + nextEpochBalance: BigNumber; + }>(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('getTotalStakeDelegatedToPool(bytes32)', [ + poolId, + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Returns the current weth contract address + * @returns wethContract The WETH contract instance. + */ + public getWethContract(): ContractFunctionObj { + const self = (this as any) as StakingContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('getWethContract()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('getWethContract()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('getWethContract()', []); + return abiEncodedTransactionData; + }, + }; + } + /** + * Returns the current zrxVault address. + * @returns zrxVault The zrxVault contract. + */ + public getZrxVault(): ContractFunctionObj { + const self = (this as any) as StakingContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('getZrxVault()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('getZrxVault()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('getZrxVault()', []); + return abiEncodedTransactionData; + }, + }; + } + /** + * Initialize storage owned by this contract. + * This function should not be called directly. + * The StakingProxy contract will call it in `attachStakingContract()`. + */ + public init(): ContractTxFunctionObj { + const self = (this as any) as StakingContract; + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('init()', []); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('init()', []); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('init()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('init()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('init()', []); + return abiEncodedTransactionData; + }, + }; + } + /** + * Allows caller to join a staking pool as a maker. + * @param poolId Unique id of pool. + */ + public joinStakingPoolAsMaker(poolId: string): ContractTxFunctionObj { + const self = (this as any) as StakingContract; + assert.isString('poolId', poolId); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('joinStakingPoolAsMaker(bytes32)', [poolId]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('joinStakingPoolAsMaker(bytes32)', [poolId]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('joinStakingPoolAsMaker(bytes32)', [poolId]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('joinStakingPoolAsMaker(bytes32)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('joinStakingPoolAsMaker(bytes32)', [ + poolId, + ]); + return abiEncodedTransactionData; + }, + }; + } + public lastPoolId(): ContractFunctionObj { + const self = (this as any) as StakingContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('lastPoolId()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('lastPoolId()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('lastPoolId()', []); + return abiEncodedTransactionData; + }, + }; + } + public minimumPoolStake(): ContractFunctionObj { + const self = (this as any) as StakingContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('minimumPoolStake()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('minimumPoolStake()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('minimumPoolStake()', []); + return abiEncodedTransactionData; + }, + }; + } + /** + * Moves stake between statuses: 'undelegated' or 'delegated'. + * Delegated stake can also be moved between pools. + * This change comes into effect next epoch. + * @param from status to move stake out of. + * @param to status to move stake into. + * @param amount of stake to move. + */ + public moveStake( + from: { status: number | BigNumber; poolId: string }, + to: { status: number | BigNumber; poolId: string }, + amount: BigNumber, + ): ContractTxFunctionObj { + const self = (this as any) as StakingContract; + + assert.isBigNumber('amount', amount); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('moveStake((uint8,bytes32),(uint8,bytes32),uint256)', [ + from, + to, + amount, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('moveStake((uint8,bytes32),(uint8,bytes32),uint256)', [ + from, + to, + amount, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('moveStake((uint8,bytes32),(uint8,bytes32),uint256)', [ + from, + to, + amount, + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('moveStake((uint8,bytes32),(uint8,bytes32),uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'moveStake((uint8,bytes32),(uint8,bytes32),uint256)', + [from, to, amount], + ); + return abiEncodedTransactionData; + }, + }; + } + public owner(): ContractFunctionObj { + const self = (this as any) as StakingContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('owner()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('owner()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('owner()', []); + return abiEncodedTransactionData; + }, + }; + } + /** + * Pays a protocol fee in ETH or WETH. + * Only a known 0x exchange can call this method. See + * (MixinExchangeManager). + * @param makerAddress The address of the order's maker. + * @param payerAddress The address of the protocol fee payer. + * @param protocolFee The protocol fee amount. This is either passed as ETH or + * transferred as WETH. + */ + public payProtocolFee( + makerAddress: string, + payerAddress: string, + protocolFee: BigNumber, + ): ContractTxFunctionObj { + const self = (this as any) as StakingContract; + assert.isString('makerAddress', makerAddress); + assert.isString('payerAddress', payerAddress); + assert.isBigNumber('protocolFee', protocolFee); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('payProtocolFee(address,address,uint256)', [ + makerAddress.toLowerCase(), + payerAddress.toLowerCase(), + protocolFee, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('payProtocolFee(address,address,uint256)', [ + makerAddress.toLowerCase(), + payerAddress.toLowerCase(), + protocolFee, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('payProtocolFee(address,address,uint256)', [ + makerAddress.toLowerCase(), + payerAddress.toLowerCase(), + protocolFee, + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('payProtocolFee(address,address,uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'payProtocolFee(address,address,uint256)', + [makerAddress.toLowerCase(), payerAddress.toLowerCase(), protocolFee], + ); + return abiEncodedTransactionData; + }, + }; + } + public poolIdByMaker(index_0: string): ContractFunctionObj { + const self = (this as any) as StakingContract; + assert.isString('index_0', index_0); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('poolIdByMaker(address)', [index_0.toLowerCase()]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('poolIdByMaker(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('poolIdByMaker(address)', [ + index_0.toLowerCase(), + ]); + return abiEncodedTransactionData; + }, + }; + } + public poolStatsByEpoch( + index_0: string, + index_1: BigNumber, + ): ContractFunctionObj<[BigNumber, BigNumber, BigNumber]> { + const self = (this as any) as StakingContract; + assert.isString('index_0', index_0); + assert.isBigNumber('index_1', index_1); + + return { + async callAsync( + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise<[BigNumber, BigNumber, BigNumber]> { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('poolStatsByEpoch(bytes32,uint256)', [ + index_0, + index_1, + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('poolStatsByEpoch(bytes32,uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<[BigNumber, BigNumber, BigNumber]>(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('poolStatsByEpoch(bytes32,uint256)', [ + index_0, + index_1, + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Removes authorizion of an address. + * @param target Address to remove authorization from. + */ + public removeAuthorizedAddress(target: string): ContractTxFunctionObj { + const self = (this as any) as StakingContract; + assert.isString('target', target); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [ + target.toLowerCase(), + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [ + target.toLowerCase(), + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [ + target.toLowerCase(), + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('removeAuthorizedAddress(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [ + target.toLowerCase(), + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Removes authorizion of an address. + * @param target Address to remove authorization from. + * @param index Index of target in authorities array. + */ + public removeAuthorizedAddressAtIndex(target: string, index: BigNumber): ContractTxFunctionObj { + const self = (this as any) as StakingContract; + assert.isString('target', target); + assert.isBigNumber('index', index); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [ + target.toLowerCase(), + index, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [ + target.toLowerCase(), + index, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [ + target.toLowerCase(), + index, + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('removeAuthorizedAddressAtIndex(address,uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'removeAuthorizedAddressAtIndex(address,uint256)', + [target.toLowerCase(), index], + ); + return abiEncodedTransactionData; + }, + }; + } + /** + * Removes an existing exchange address + * @param addr Address of exchange contract to remove + */ + public removeExchangeAddress(addr: string): ContractTxFunctionObj { + const self = (this as any) as StakingContract; + assert.isString('addr', addr); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('removeExchangeAddress(address)', [addr.toLowerCase()]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('removeExchangeAddress(address)', [addr.toLowerCase()]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('removeExchangeAddress(address)', [addr.toLowerCase()]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('removeExchangeAddress(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('removeExchangeAddress(address)', [ + addr.toLowerCase(), + ]); + return abiEncodedTransactionData; + }, + }; + } + public rewardDelegatedStakeWeight(): ContractFunctionObj { + const self = (this as any) as StakingContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('rewardDelegatedStakeWeight()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('rewardDelegatedStakeWeight()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('rewardDelegatedStakeWeight()', []); + return abiEncodedTransactionData; + }, + }; + } + public rewardsByPoolId(index_0: string): ContractFunctionObj { + const self = (this as any) as StakingContract; + assert.isString('index_0', index_0); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('rewardsByPoolId(bytes32)', [index_0]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('rewardsByPoolId(bytes32)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('rewardsByPoolId(bytes32)', [index_0]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Set all configurable parameters at once. + * @param _epochDurationInSeconds Minimum seconds between epochs. + * @param _rewardDelegatedStakeWeight How much delegated stake is weighted vs + * operator stake, in ppm. + * @param _minimumPoolStake Minimum amount of stake required in a pool to + * collect rewards. + * @param _cobbDouglasAlphaNumerator Numerator for cobb douglas alpha factor. + * @param _cobbDouglasAlphaDenominator Denominator for cobb douglas alpha + * factor. + */ + public setParams( + _epochDurationInSeconds: BigNumber, + _rewardDelegatedStakeWeight: number | BigNumber, + _minimumPoolStake: BigNumber, + _cobbDouglasAlphaNumerator: number | BigNumber, + _cobbDouglasAlphaDenominator: number | BigNumber, + ): ContractTxFunctionObj { + const self = (this as any) as StakingContract; + assert.isBigNumber('_epochDurationInSeconds', _epochDurationInSeconds); + assert.isNumberOrBigNumber('_rewardDelegatedStakeWeight', _rewardDelegatedStakeWeight); + assert.isBigNumber('_minimumPoolStake', _minimumPoolStake); + assert.isNumberOrBigNumber('_cobbDouglasAlphaNumerator', _cobbDouglasAlphaNumerator); + assert.isNumberOrBigNumber('_cobbDouglasAlphaDenominator', _cobbDouglasAlphaDenominator); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('setParams(uint256,uint32,uint256,uint32,uint32)', [ + _epochDurationInSeconds, + _rewardDelegatedStakeWeight, + _minimumPoolStake, + _cobbDouglasAlphaNumerator, + _cobbDouglasAlphaDenominator, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('setParams(uint256,uint32,uint256,uint32,uint32)', [ + _epochDurationInSeconds, + _rewardDelegatedStakeWeight, + _minimumPoolStake, + _cobbDouglasAlphaNumerator, + _cobbDouglasAlphaDenominator, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('setParams(uint256,uint32,uint256,uint32,uint32)', [ + _epochDurationInSeconds, + _rewardDelegatedStakeWeight, + _minimumPoolStake, + _cobbDouglasAlphaNumerator, + _cobbDouglasAlphaDenominator, + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('setParams(uint256,uint32,uint256,uint32,uint32)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'setParams(uint256,uint32,uint256,uint32,uint32)', + [ + _epochDurationInSeconds, + _rewardDelegatedStakeWeight, + _minimumPoolStake, + _cobbDouglasAlphaNumerator, + _cobbDouglasAlphaDenominator, + ], + ); + return abiEncodedTransactionData; + }, + }; + } + /** + * Stake ZRX tokens. Tokens are deposited into the ZRX Vault. + * Unstake to retrieve the ZRX. Stake is in the 'Active' status. + * @param amount of ZRX to stake. + */ + public stake(amount: BigNumber): ContractTxFunctionObj { + const self = (this as any) as StakingContract; + assert.isBigNumber('amount', amount); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('stake(uint256)', [amount]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('stake(uint256)', [amount]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('stake(uint256)', [amount]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('stake(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('stake(uint256)', [amount]); + return abiEncodedTransactionData; + }, + }; + } + public stakingContract(): ContractFunctionObj { + const self = (this as any) as StakingContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('stakingContract()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('stakingContract()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('stakingContract()', []); + return abiEncodedTransactionData; + }, + }; + } + public transferOwnership(newOwner: string): ContractTxFunctionObj { + const self = (this as any) as StakingContract; + assert.isString('newOwner', newOwner); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('transferOwnership(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('transferOwnership(address)', [ + newOwner.toLowerCase(), + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Unstake. Tokens are withdrawn from the ZRX Vault and returned to + * the staker. Stake must be in the 'undelegated' status in both the + * current and next epoch in order to be unstaked. + * @param amount of ZRX to unstake. + */ + public unstake(amount: BigNumber): ContractTxFunctionObj { + const self = (this as any) as StakingContract; + assert.isBigNumber('amount', amount); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('unstake(uint256)', [amount]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('unstake(uint256)', [amount]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('unstake(uint256)', [amount]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('unstake(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('unstake(uint256)', [amount]); + return abiEncodedTransactionData; + }, + }; + } + public validExchanges(index_0: string): ContractFunctionObj { + const self = (this as any) as StakingContract; + assert.isString('index_0', index_0); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('validExchanges(address)', [index_0.toLowerCase()]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('validExchanges(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('validExchanges(address)', [ + index_0.toLowerCase(), + ]); + return abiEncodedTransactionData; + }, + }; + } + public wethReservedForPoolRewards(): ContractFunctionObj { + const self = (this as any) as StakingContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('wethReservedForPoolRewards()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('wethReservedForPoolRewards()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('wethReservedForPoolRewards()', []); + return abiEncodedTransactionData; + }, + }; + } + /** + * Withdraws the caller's WETH rewards that have accumulated + * until the last epoch. + * @param poolId Unique id of pool. + */ + public withdrawDelegatorRewards(poolId: string): ContractTxFunctionObj { + const self = (this as any) as StakingContract; + assert.isString('poolId', poolId); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('withdrawDelegatorRewards(bytes32)', [poolId]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('withdrawDelegatorRewards(bytes32)', [poolId]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('withdrawDelegatorRewards(bytes32)', [poolId]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('withdrawDelegatorRewards(bytes32)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('withdrawDelegatorRewards(bytes32)', [ + poolId, + ]); + return abiEncodedTransactionData; + }, + }; + } + + /** + * Subscribe to an event type emitted by the Staking contract. + * @param eventName The Staking contract event you would like to subscribe to. + * @param indexFilterValues An object where the keys are indexed args returned by the event and + * the value is the value you are interested in. E.g `{maker: aUserAddressHex}` + * @param callback Callback that gets called when a log is added/removed + * @param isVerbose Enable verbose subscription warnings (e.g recoverable network issues encountered) + * @return Subscription token used later to unsubscribe */ public subscribe( eventName: StakingEvents, @@ -6426,6 +5595,12 @@ export class StakingContract extends BaseContract { StakingContract.ABI(), this._web3Wrapper, ); + StakingContract.ABI().forEach((item, index) => { + if (item.type === 'function') { + const methodAbi = item as MethodAbi; + this._methodABIIndex[methodAbi.name] = index; + } + }); } } diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/staking_proxy.ts b/packages/abi-gen-wrappers/src/generated-wrappers/staking_proxy.ts index 0083595a0e..e2317306dc 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/staking_proxy.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/staking_proxy.ts @@ -1,7 +1,16 @@ // tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma enum-naming // tslint:disable:whitespace no-unbound-method no-trailing-whitespace // tslint:disable:no-unused-variable -import { BaseContract, SubscriptionManager, PromiseWithTransactionHash } from '@0x/base-contract'; +import { + AwaitTransactionSuccessOpts, + ContractFunctionObj, + ContractTxFunctionObj, + SendTransactionOpts, + BaseContract, + SubscriptionManager, + PromiseWithTransactionHash, + methodAbiToFunctionSignature, +} from '@0x/base-contract'; import { schemas } from '@0x/json-schemas'; import { BlockParam, @@ -19,13 +28,7 @@ import { SupportedProvider, } from 'ethereum-types'; import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils'; -import { - AwaitTransactionSuccessOpts, - EventCallback, - IndexedFilterValues, - SendTransactionOpts, - SimpleContractArtifact, -} from '@0x/types'; +import { EventCallback, IndexedFilterValues, SimpleContractArtifact } from '@0x/types'; import { Web3Wrapper } from '@0x/web3-wrapper'; import { assert } from '@0x/assert'; import * as ethers from 'ethers'; @@ -75,2049 +78,7 @@ export class StakingProxyContract extends BaseContract { * @ignore */ public static deployedBytecode: string | undefined; - /** - * Authorizes an address. - */ - public addAuthorizedAddress = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param target Address to authorize. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - target: string, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('target', target); - const self = (this as any) as StakingProxyContract; - const encodedData = self._strictEncodeArguments('addAuthorizedAddress(address)', [target.toLowerCase()]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.addAuthorizedAddress.callAsync(target, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param target Address to authorize. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - target: string, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('target', target); - const self = (this as any) as StakingProxyContract; - const txHashPromise = self.addAuthorizedAddress.sendTransactionAsync(target.toLowerCase(), txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param target Address to authorize. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync(target: string, txData?: Partial | undefined): Promise { - assert.isString('target', target); - const self = (this as any) as StakingProxyContract; - const encodedData = self._strictEncodeArguments('addAuthorizedAddress(address)', [target.toLowerCase()]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param target Address to authorize. - */ - async callAsync(target: string, callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.isString('target', target); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingProxyContract; - const encodedData = self._strictEncodeArguments('addAuthorizedAddress(address)', [target.toLowerCase()]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('addAuthorizedAddress(address)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param target Address to authorize. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(target: string): string { - assert.isString('target', target); - const self = (this as any) as StakingProxyContract; - const abiEncodedTransactionData = self._strictEncodeArguments('addAuthorizedAddress(address)', [ - target.toLowerCase(), - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as StakingProxyContract; - const abiEncoder = self._lookupAbiEncoder('addAuthorizedAddress(address)'); - return abiEncoder.getSelector(); - }, - }; - public aggregatedStatsByEpoch = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync( - index_0: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise<[BigNumber, BigNumber, BigNumber, BigNumber, BigNumber]> { - assert.isBigNumber('index_0', index_0); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingProxyContract; - const encodedData = self._strictEncodeArguments('aggregatedStatsByEpoch(uint256)', [index_0]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('aggregatedStatsByEpoch(uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue<[BigNumber, BigNumber, BigNumber, BigNumber, BigNumber]>( - rawCallResult, - ); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Asserts that an epoch is between 5 and 30 days long. - */ - public assertValidStorageParams = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingProxyContract; - const encodedData = self._strictEncodeArguments('assertValidStorageParams()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('assertValidStorageParams()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Attach a staking contract; future calls will be delegated to the staking contract. Note that this is callable only by an authorized address. - */ - public attachStakingContract = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param _stakingContract Address of staking contract. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - _stakingContract: string, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('_stakingContract', _stakingContract); - const self = (this as any) as StakingProxyContract; - const encodedData = self._strictEncodeArguments('attachStakingContract(address)', [ - _stakingContract.toLowerCase(), - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.attachStakingContract.callAsync(_stakingContract, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param _stakingContract Address of staking contract. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - _stakingContract: string, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('_stakingContract', _stakingContract); - const self = (this as any) as StakingProxyContract; - const txHashPromise = self.attachStakingContract.sendTransactionAsync( - _stakingContract.toLowerCase(), - txData, - opts, - ); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param _stakingContract Address of staking contract. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync(_stakingContract: string, txData?: Partial | undefined): Promise { - assert.isString('_stakingContract', _stakingContract); - const self = (this as any) as StakingProxyContract; - const encodedData = self._strictEncodeArguments('attachStakingContract(address)', [ - _stakingContract.toLowerCase(), - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param _stakingContract Address of staking contract. - */ - async callAsync( - _stakingContract: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('_stakingContract', _stakingContract); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingProxyContract; - const encodedData = self._strictEncodeArguments('attachStakingContract(address)', [ - _stakingContract.toLowerCase(), - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('attachStakingContract(address)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param _stakingContract Address of staking contract. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(_stakingContract: string): string { - assert.isString('_stakingContract', _stakingContract); - const self = (this as any) as StakingProxyContract; - const abiEncodedTransactionData = self._strictEncodeArguments('attachStakingContract(address)', [ - _stakingContract.toLowerCase(), - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as StakingProxyContract; - const abiEncoder = self._lookupAbiEncoder('attachStakingContract(address)'); - return abiEncoder.getSelector(); - }, - }; - public authorities = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync( - index_0: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isBigNumber('index_0', index_0); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingProxyContract; - const encodedData = self._strictEncodeArguments('authorities(uint256)', [index_0]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('authorities(uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public authorized = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync( - index_0: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('index_0', index_0); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingProxyContract; - const encodedData = self._strictEncodeArguments('authorized(address)', [index_0.toLowerCase()]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('authorized(address)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Batch executes a series of calls to the staking contract. - */ - public batchExecute = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param data An array of data that encodes a sequence of functions to - * call in the staking contracts. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - data: string[], - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isArray('data', data); - const self = (this as any) as StakingProxyContract; - const encodedData = self._strictEncodeArguments('batchExecute(bytes[])', [data]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.batchExecute.callAsync(data, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param data An array of data that encodes a sequence of functions to - * call in the staking contracts. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - data: string[], - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isArray('data', data); - const self = (this as any) as StakingProxyContract; - const txHashPromise = self.batchExecute.sendTransactionAsync(data, txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param data An array of data that encodes a sequence of functions to - * call in the staking contracts. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync(data: string[], txData?: Partial | undefined): Promise { - assert.isArray('data', data); - const self = (this as any) as StakingProxyContract; - const encodedData = self._strictEncodeArguments('batchExecute(bytes[])', [data]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param data An array of data that encodes a sequence of functions to - * call in the staking contracts. - */ - async callAsync( - data: string[], - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isArray('data', data); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingProxyContract; - const encodedData = self._strictEncodeArguments('batchExecute(bytes[])', [data]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('batchExecute(bytes[])'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param data An array of data that encodes a sequence of functions to - * call in the staking contracts. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(data: string[]): string { - assert.isArray('data', data); - const self = (this as any) as StakingProxyContract; - const abiEncodedTransactionData = self._strictEncodeArguments('batchExecute(bytes[])', [data]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as StakingProxyContract; - const abiEncoder = self._lookupAbiEncoder('batchExecute(bytes[])'); - return abiEncoder.getSelector(); - }, - }; - public cobbDouglasAlphaDenominator = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingProxyContract; - const encodedData = self._strictEncodeArguments('cobbDouglasAlphaDenominator()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('cobbDouglasAlphaDenominator()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public cobbDouglasAlphaNumerator = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingProxyContract; - const encodedData = self._strictEncodeArguments('cobbDouglasAlphaNumerator()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('cobbDouglasAlphaNumerator()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public currentEpoch = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingProxyContract; - const encodedData = self._strictEncodeArguments('currentEpoch()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('currentEpoch()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public currentEpochStartTimeInSeconds = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingProxyContract; - const encodedData = self._strictEncodeArguments('currentEpochStartTimeInSeconds()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('currentEpochStartTimeInSeconds()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Detach the current staking contract. Note that this is callable only by an authorized address. - */ - public detachStakingContract = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - const self = (this as any) as StakingProxyContract; - const encodedData = self._strictEncodeArguments('detachStakingContract()', []); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.detachStakingContract.callAsync(txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - const self = (this as any) as StakingProxyContract; - const txHashPromise = self.detachStakingContract.sendTransactionAsync(txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync(txData?: Partial | undefined): Promise { - const self = (this as any) as StakingProxyContract; - const encodedData = self._strictEncodeArguments('detachStakingContract()', []); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingProxyContract; - const encodedData = self._strictEncodeArguments('detachStakingContract()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('detachStakingContract()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(): string { - const self = (this as any) as StakingProxyContract; - const abiEncodedTransactionData = self._strictEncodeArguments('detachStakingContract()', []); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as StakingProxyContract; - const abiEncoder = self._lookupAbiEncoder('detachStakingContract()'); - return abiEncoder.getSelector(); - }, - }; - public epochDurationInSeconds = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingProxyContract; - const encodedData = self._strictEncodeArguments('epochDurationInSeconds()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('epochDurationInSeconds()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Gets all authorized addresses. - */ - public getAuthorizedAddresses = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @returns Array of authorized addresses. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingProxyContract; - const encodedData = self._strictEncodeArguments('getAuthorizedAddresses()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('getAuthorizedAddresses()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public lastPoolId = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingProxyContract; - const encodedData = self._strictEncodeArguments('lastPoolId()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('lastPoolId()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public minimumPoolStake = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingProxyContract; - const encodedData = self._strictEncodeArguments('minimumPoolStake()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('minimumPoolStake()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public owner = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingProxyContract; - const encodedData = self._strictEncodeArguments('owner()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('owner()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public poolIdByMaker = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(index_0: string, callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.isString('index_0', index_0); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingProxyContract; - const encodedData = self._strictEncodeArguments('poolIdByMaker(address)', [index_0.toLowerCase()]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('poolIdByMaker(address)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public poolStatsByEpoch = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync( - index_0: string, - index_1: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise<[BigNumber, BigNumber, BigNumber]> { - assert.isString('index_0', index_0); - assert.isBigNumber('index_1', index_1); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingProxyContract; - const encodedData = self._strictEncodeArguments('poolStatsByEpoch(bytes32,uint256)', [index_0, index_1]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('poolStatsByEpoch(bytes32,uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue<[BigNumber, BigNumber, BigNumber]>(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Removes authorizion of an address. - */ - public removeAuthorizedAddress = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param target Address to remove authorization from. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - target: string, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('target', target); - const self = (this as any) as StakingProxyContract; - const encodedData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [target.toLowerCase()]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.removeAuthorizedAddress.callAsync(target, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param target Address to remove authorization from. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - target: string, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('target', target); - const self = (this as any) as StakingProxyContract; - const txHashPromise = self.removeAuthorizedAddress.sendTransactionAsync(target.toLowerCase(), txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param target Address to remove authorization from. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync(target: string, txData?: Partial | undefined): Promise { - assert.isString('target', target); - const self = (this as any) as StakingProxyContract; - const encodedData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [target.toLowerCase()]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param target Address to remove authorization from. - */ - async callAsync(target: string, callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.isString('target', target); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingProxyContract; - const encodedData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [target.toLowerCase()]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('removeAuthorizedAddress(address)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param target Address to remove authorization from. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(target: string): string { - assert.isString('target', target); - const self = (this as any) as StakingProxyContract; - const abiEncodedTransactionData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [ - target.toLowerCase(), - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as StakingProxyContract; - const abiEncoder = self._lookupAbiEncoder('removeAuthorizedAddress(address)'); - return abiEncoder.getSelector(); - }, - }; - /** - * Removes authorizion of an address. - */ - public removeAuthorizedAddressAtIndex = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param target Address to remove authorization from. - * @param index Index of target in authorities array. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - target: string, - index: BigNumber, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('target', target); - assert.isBigNumber('index', index); - const self = (this as any) as StakingProxyContract; - const encodedData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [ - target.toLowerCase(), - index, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.removeAuthorizedAddressAtIndex.callAsync(target, index, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param target Address to remove authorization from. - * @param index Index of target in authorities array. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - target: string, - index: BigNumber, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('target', target); - assert.isBigNumber('index', index); - const self = (this as any) as StakingProxyContract; - const txHashPromise = self.removeAuthorizedAddressAtIndex.sendTransactionAsync( - target.toLowerCase(), - index, - txData, - opts, - ); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param target Address to remove authorization from. - * @param index Index of target in authorities array. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - target: string, - index: BigNumber, - txData?: Partial | undefined, - ): Promise { - assert.isString('target', target); - assert.isBigNumber('index', index); - const self = (this as any) as StakingProxyContract; - const encodedData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [ - target.toLowerCase(), - index, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param target Address to remove authorization from. - * @param index Index of target in authorities array. - */ - async callAsync( - target: string, - index: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('target', target); - assert.isBigNumber('index', index); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingProxyContract; - const encodedData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [ - target.toLowerCase(), - index, - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('removeAuthorizedAddressAtIndex(address,uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param target Address to remove authorization from. - * @param index Index of target in authorities array. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(target: string, index: BigNumber): string { - assert.isString('target', target); - assert.isBigNumber('index', index); - const self = (this as any) as StakingProxyContract; - const abiEncodedTransactionData = self._strictEncodeArguments( - 'removeAuthorizedAddressAtIndex(address,uint256)', - [target.toLowerCase(), index], - ); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as StakingProxyContract; - const abiEncoder = self._lookupAbiEncoder('removeAuthorizedAddressAtIndex(address,uint256)'); - return abiEncoder.getSelector(); - }, - }; - public rewardDelegatedStakeWeight = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingProxyContract; - const encodedData = self._strictEncodeArguments('rewardDelegatedStakeWeight()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('rewardDelegatedStakeWeight()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public rewardsByPoolId = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync( - index_0: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('index_0', index_0); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingProxyContract; - const encodedData = self._strictEncodeArguments('rewardsByPoolId(bytes32)', [index_0]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('rewardsByPoolId(bytes32)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public stakingContract = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingProxyContract; - const encodedData = self._strictEncodeArguments('stakingContract()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('stakingContract()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public transferOwnership = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - newOwner: string, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('newOwner', newOwner); - const self = (this as any) as StakingProxyContract; - const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.transferOwnership.callAsync(newOwner, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - newOwner: string, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('newOwner', newOwner); - const self = (this as any) as StakingProxyContract; - const txHashPromise = self.transferOwnership.sendTransactionAsync(newOwner.toLowerCase(), txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync(newOwner: string, txData?: Partial | undefined): Promise { - assert.isString('newOwner', newOwner); - const self = (this as any) as StakingProxyContract; - const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(newOwner: string, callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.isString('newOwner', newOwner); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingProxyContract; - const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('transferOwnership(address)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(newOwner: string): string { - assert.isString('newOwner', newOwner); - const self = (this as any) as StakingProxyContract; - const abiEncodedTransactionData = self._strictEncodeArguments('transferOwnership(address)', [ - newOwner.toLowerCase(), - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as StakingProxyContract; - const abiEncoder = self._lookupAbiEncoder('transferOwnership(address)'); - return abiEncoder.getSelector(); - }, - }; - public validExchanges = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync( - index_0: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('index_0', index_0); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingProxyContract; - const encodedData = self._strictEncodeArguments('validExchanges(address)', [index_0.toLowerCase()]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('validExchanges(address)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public wethReservedForPoolRewards = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StakingProxyContract; - const encodedData = self._strictEncodeArguments('wethReservedForPoolRewards()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('wethReservedForPoolRewards()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; + private _methodABIIndex: { [name: string]: number } = {}; private readonly _subscriptionManager: SubscriptionManager; public static async deployFrom0xArtifactAsync( artifact: ContractArtifact | SimpleContractArtifact, @@ -2737,6 +698,1822 @@ export class StakingProxyContract extends BaseContract { ] as ContractAbi; return abi; } + + public getFunctionSignature(methodName: string): string { + const index = this._methodABIIndex[methodName]; + const methodAbi = StakingProxyContract.ABI()[index] as MethodAbi; + const functionSignature = methodAbiToFunctionSignature(methodAbi); + return functionSignature; + } + public getABIDecodedTransactionData(methodName: string, callData: string): T { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as StakingProxyContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + const abiDecodedCallData = abiEncoder.strictDecode(callData); + return abiDecodedCallData; + } + public getABIDecodedReturnData(methodName: string, callData: string): T { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as StakingProxyContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + const abiDecodedCallData = abiEncoder.strictDecodeReturnValue(callData); + return abiDecodedCallData; + } + public getSelector(methodName: string): string { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as StakingProxyContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + return abiEncoder.getSelector(); + } + + /** + * Authorizes an address. + * @param target Address to authorize. + */ + public addAuthorizedAddress(target: string): ContractTxFunctionObj { + const self = (this as any) as StakingProxyContract; + assert.isString('target', target); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('addAuthorizedAddress(address)', [ + target.toLowerCase(), + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('addAuthorizedAddress(address)', [ + target.toLowerCase(), + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('addAuthorizedAddress(address)', [ + target.toLowerCase(), + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('addAuthorizedAddress(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('addAuthorizedAddress(address)', [ + target.toLowerCase(), + ]); + return abiEncodedTransactionData; + }, + }; + } + public aggregatedStatsByEpoch( + index_0: BigNumber, + ): ContractFunctionObj<[BigNumber, BigNumber, BigNumber, BigNumber, BigNumber]> { + const self = (this as any) as StakingProxyContract; + assert.isBigNumber('index_0', index_0); + + return { + async callAsync( + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise<[BigNumber, BigNumber, BigNumber, BigNumber, BigNumber]> { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('aggregatedStatsByEpoch(uint256)', [index_0]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('aggregatedStatsByEpoch(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue< + [BigNumber, BigNumber, BigNumber, BigNumber, BigNumber] + >(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('aggregatedStatsByEpoch(uint256)', [ + index_0, + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Asserts that an epoch is between 5 and 30 days long. + */ + public assertValidStorageParams(): ContractFunctionObj { + const self = (this as any) as StakingProxyContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('assertValidStorageParams()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('assertValidStorageParams()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('assertValidStorageParams()', []); + return abiEncodedTransactionData; + }, + }; + } + /** + * Attach a staking contract; future calls will be delegated to the staking contract. Note that this is callable only by an authorized address. + * @param _stakingContract Address of staking contract. + */ + public attachStakingContract(_stakingContract: string): ContractTxFunctionObj { + const self = (this as any) as StakingProxyContract; + assert.isString('_stakingContract', _stakingContract); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('attachStakingContract(address)', [ + _stakingContract.toLowerCase(), + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('attachStakingContract(address)', [ + _stakingContract.toLowerCase(), + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('attachStakingContract(address)', [ + _stakingContract.toLowerCase(), + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('attachStakingContract(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('attachStakingContract(address)', [ + _stakingContract.toLowerCase(), + ]); + return abiEncodedTransactionData; + }, + }; + } + public authorities(index_0: BigNumber): ContractFunctionObj { + const self = (this as any) as StakingProxyContract; + assert.isBigNumber('index_0', index_0); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('authorities(uint256)', [index_0]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('authorities(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('authorities(uint256)', [index_0]); + return abiEncodedTransactionData; + }, + }; + } + public authorized(index_0: string): ContractFunctionObj { + const self = (this as any) as StakingProxyContract; + assert.isString('index_0', index_0); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('authorized(address)', [index_0.toLowerCase()]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('authorized(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('authorized(address)', [ + index_0.toLowerCase(), + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Batch executes a series of calls to the staking contract. + * @param data An array of data that encodes a sequence of functions to + * call in the staking contracts. + */ + public batchExecute(data: string[]): ContractTxFunctionObj { + const self = (this as any) as StakingProxyContract; + assert.isArray('data', data); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('batchExecute(bytes[])', [data]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('batchExecute(bytes[])', [data]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('batchExecute(bytes[])', [data]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('batchExecute(bytes[])'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('batchExecute(bytes[])', [data]); + return abiEncodedTransactionData; + }, + }; + } + public cobbDouglasAlphaDenominator(): ContractFunctionObj { + const self = (this as any) as StakingProxyContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('cobbDouglasAlphaDenominator()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('cobbDouglasAlphaDenominator()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('cobbDouglasAlphaDenominator()', []); + return abiEncodedTransactionData; + }, + }; + } + public cobbDouglasAlphaNumerator(): ContractFunctionObj { + const self = (this as any) as StakingProxyContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('cobbDouglasAlphaNumerator()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('cobbDouglasAlphaNumerator()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('cobbDouglasAlphaNumerator()', []); + return abiEncodedTransactionData; + }, + }; + } + public currentEpoch(): ContractFunctionObj { + const self = (this as any) as StakingProxyContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('currentEpoch()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('currentEpoch()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('currentEpoch()', []); + return abiEncodedTransactionData; + }, + }; + } + public currentEpochStartTimeInSeconds(): ContractFunctionObj { + const self = (this as any) as StakingProxyContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('currentEpochStartTimeInSeconds()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('currentEpochStartTimeInSeconds()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('currentEpochStartTimeInSeconds()', []); + return abiEncodedTransactionData; + }, + }; + } + /** + * Detach the current staking contract. Note that this is callable only by an authorized address. + */ + public detachStakingContract(): ContractTxFunctionObj { + const self = (this as any) as StakingProxyContract; + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('detachStakingContract()', []); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('detachStakingContract()', []); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('detachStakingContract()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('detachStakingContract()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('detachStakingContract()', []); + return abiEncodedTransactionData; + }, + }; + } + public epochDurationInSeconds(): ContractFunctionObj { + const self = (this as any) as StakingProxyContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('epochDurationInSeconds()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('epochDurationInSeconds()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('epochDurationInSeconds()', []); + return abiEncodedTransactionData; + }, + }; + } + /** + * Gets all authorized addresses. + * @returns Array of authorized addresses. + */ + public getAuthorizedAddresses(): ContractFunctionObj { + const self = (this as any) as StakingProxyContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('getAuthorizedAddresses()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('getAuthorizedAddresses()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('getAuthorizedAddresses()', []); + return abiEncodedTransactionData; + }, + }; + } + public lastPoolId(): ContractFunctionObj { + const self = (this as any) as StakingProxyContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('lastPoolId()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('lastPoolId()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('lastPoolId()', []); + return abiEncodedTransactionData; + }, + }; + } + public minimumPoolStake(): ContractFunctionObj { + const self = (this as any) as StakingProxyContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('minimumPoolStake()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('minimumPoolStake()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('minimumPoolStake()', []); + return abiEncodedTransactionData; + }, + }; + } + public owner(): ContractFunctionObj { + const self = (this as any) as StakingProxyContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('owner()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('owner()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('owner()', []); + return abiEncodedTransactionData; + }, + }; + } + public poolIdByMaker(index_0: string): ContractFunctionObj { + const self = (this as any) as StakingProxyContract; + assert.isString('index_0', index_0); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('poolIdByMaker(address)', [index_0.toLowerCase()]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('poolIdByMaker(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('poolIdByMaker(address)', [ + index_0.toLowerCase(), + ]); + return abiEncodedTransactionData; + }, + }; + } + public poolStatsByEpoch( + index_0: string, + index_1: BigNumber, + ): ContractFunctionObj<[BigNumber, BigNumber, BigNumber]> { + const self = (this as any) as StakingProxyContract; + assert.isString('index_0', index_0); + assert.isBigNumber('index_1', index_1); + + return { + async callAsync( + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise<[BigNumber, BigNumber, BigNumber]> { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('poolStatsByEpoch(bytes32,uint256)', [ + index_0, + index_1, + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('poolStatsByEpoch(bytes32,uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<[BigNumber, BigNumber, BigNumber]>(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('poolStatsByEpoch(bytes32,uint256)', [ + index_0, + index_1, + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Removes authorizion of an address. + * @param target Address to remove authorization from. + */ + public removeAuthorizedAddress(target: string): ContractTxFunctionObj { + const self = (this as any) as StakingProxyContract; + assert.isString('target', target); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [ + target.toLowerCase(), + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [ + target.toLowerCase(), + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [ + target.toLowerCase(), + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('removeAuthorizedAddress(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [ + target.toLowerCase(), + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Removes authorizion of an address. + * @param target Address to remove authorization from. + * @param index Index of target in authorities array. + */ + public removeAuthorizedAddressAtIndex(target: string, index: BigNumber): ContractTxFunctionObj { + const self = (this as any) as StakingProxyContract; + assert.isString('target', target); + assert.isBigNumber('index', index); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [ + target.toLowerCase(), + index, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [ + target.toLowerCase(), + index, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [ + target.toLowerCase(), + index, + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('removeAuthorizedAddressAtIndex(address,uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'removeAuthorizedAddressAtIndex(address,uint256)', + [target.toLowerCase(), index], + ); + return abiEncodedTransactionData; + }, + }; + } + public rewardDelegatedStakeWeight(): ContractFunctionObj { + const self = (this as any) as StakingProxyContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('rewardDelegatedStakeWeight()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('rewardDelegatedStakeWeight()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('rewardDelegatedStakeWeight()', []); + return abiEncodedTransactionData; + }, + }; + } + public rewardsByPoolId(index_0: string): ContractFunctionObj { + const self = (this as any) as StakingProxyContract; + assert.isString('index_0', index_0); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('rewardsByPoolId(bytes32)', [index_0]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('rewardsByPoolId(bytes32)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('rewardsByPoolId(bytes32)', [index_0]); + return abiEncodedTransactionData; + }, + }; + } + public stakingContract(): ContractFunctionObj { + const self = (this as any) as StakingProxyContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('stakingContract()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('stakingContract()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('stakingContract()', []); + return abiEncodedTransactionData; + }, + }; + } + public transferOwnership(newOwner: string): ContractTxFunctionObj { + const self = (this as any) as StakingProxyContract; + assert.isString('newOwner', newOwner); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('transferOwnership(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('transferOwnership(address)', [ + newOwner.toLowerCase(), + ]); + return abiEncodedTransactionData; + }, + }; + } + public validExchanges(index_0: string): ContractFunctionObj { + const self = (this as any) as StakingProxyContract; + assert.isString('index_0', index_0); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('validExchanges(address)', [index_0.toLowerCase()]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('validExchanges(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('validExchanges(address)', [ + index_0.toLowerCase(), + ]); + return abiEncodedTransactionData; + }, + }; + } + public wethReservedForPoolRewards(): ContractFunctionObj { + const self = (this as any) as StakingProxyContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('wethReservedForPoolRewards()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('wethReservedForPoolRewards()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('wethReservedForPoolRewards()', []); + return abiEncodedTransactionData; + }, + }; + } + /** * Subscribe to an event type emitted by the StakingProxy contract. * @param eventName The StakingProxy contract event you would like to subscribe to. @@ -2826,6 +2603,12 @@ export class StakingProxyContract extends BaseContract { StakingProxyContract.ABI(), this._web3Wrapper, ); + StakingProxyContract.ABI().forEach((item, index) => { + if (item.type === 'function') { + const methodAbi = item as MethodAbi; + this._methodABIIndex[methodAbi.name] = index; + } + }); } } diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/static_call_proxy.ts b/packages/abi-gen-wrappers/src/generated-wrappers/static_call_proxy.ts index c75c4d2457..834bf73d2f 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/static_call_proxy.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/static_call_proxy.ts @@ -1,7 +1,15 @@ // tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma enum-naming // tslint:disable:whitespace no-unbound-method no-trailing-whitespace // tslint:disable:no-unused-variable -import { BaseContract, PromiseWithTransactionHash } from '@0x/base-contract'; +import { + AwaitTransactionSuccessOpts, + ContractFunctionObj, + ContractTxFunctionObj, + SendTransactionOpts, + BaseContract, + PromiseWithTransactionHash, + methodAbiToFunctionSignature, +} from '@0x/base-contract'; import { schemas } from '@0x/json-schemas'; import { BlockParam, @@ -18,13 +26,7 @@ import { SupportedProvider, } from 'ethereum-types'; import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils'; -import { - AwaitTransactionSuccessOpts, - EventCallback, - IndexedFilterValues, - SendTransactionOpts, - SimpleContractArtifact, -} from '@0x/types'; +import { EventCallback, IndexedFilterValues, SimpleContractArtifact } from '@0x/types'; import { Web3Wrapper } from '@0x/web3-wrapper'; import { assert } from '@0x/assert'; import * as ethers from 'ethers'; @@ -39,112 +41,7 @@ export class StaticCallProxyContract extends BaseContract { */ public static deployedBytecode = '0x608060405234801561001057600080fd5b50600436106100365760003560e01c8063a85e59e41461003b578063ae25532e146100d3575b600080fd5b6100d16004803603608081101561005157600080fd5b81019060208101813564010000000081111561006c57600080fd5b82018360208201111561007e57600080fd5b803590602001918460018302840111640100000000831117156100a057600080fd5b919350915073ffffffffffffffffffffffffffffffffffffffff813581169160208101359091169060400135610110565b005b6100db6103a5565b604080517fffffffff000000000000000000000000000000000000000000000000000000009092168252519081900360200190f35b6000606060006101656004898990508a8a8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525092949392505063ffffffff6103c5169050565b806020019051606081101561017957600080fd5b8151602083018051604051929492938301929190846401000000008211156101a057600080fd5b9083019060208201858111156101b557600080fd5b82516401000000008111828201881017156101cf57600080fd5b82525081516020918201929091019080838360005b838110156101fc5781810151838201526020016101e4565b50505050905090810190601f1680156102295780820380516001836020036101000a031916815260200191505b5060405260200180519060200190929190505050925092509250600060608473ffffffffffffffffffffffffffffffffffffffff16846040518082805190602001908083835b602083106102ac57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161026f565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855afa9150503d806000811461030c576040519150601f19603f3d011682016040523d82523d6000602084013e610311565b606091505b50915091508161032357805160208201fd5b8051602082012083811461039857604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f554e45585045435445445f5354415449435f43414c4c5f524553554c54000000604482015290519081900360640190fd5b5050505050505050505050565b600060405180806104b06021913960210190506040518091039020905090565b6060818311156103e3576103e36103de60008585610408565b6104a7565b83518211156103fc576103fc6103de6001848751610408565b50819003910190815290565b6060632800659560e01b8484846040516024018084600781111561042857fe5b60ff1681526020018381526020018281526020019350505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505090509392505050565b805160208201fdfe53746174696343616c6c28616464726573732c62797465732c6279746573333229a265627a7a72315820c55cf13cfcaaf322238d786911313ce7d45854692241ae9b56709bdbfed4f54c64736f6c634300050b0032'; - /** - * Makes a staticcall to a target address and verifies that the data returned matches the expected return data. - */ - public transferFrom = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param assetData Byte array encoded with staticCallTarget, staticCallData, - * and expectedCallResultHash - * @param from This value is ignored. - * @param to This value is ignored. - * @param amount This value is ignored. - */ - async callAsync( - assetData: string, - from: string, - to: string, - amount: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('assetData', assetData); - assert.isString('from', from); - assert.isString('to', to); - assert.isBigNumber('amount', amount); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StaticCallProxyContract; - const encodedData = self._strictEncodeArguments('transferFrom(bytes,address,address,uint256)', [ - assetData, - from.toLowerCase(), - to.toLowerCase(), - amount, - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('transferFrom(bytes,address,address,uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * Gets the proxy id associated with the proxy address. - */ - public getProxyId = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @returns Proxy id. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as StaticCallProxyContract; - const encodedData = self._strictEncodeArguments('getProxyId()', []); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('getProxyId()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; + private _methodABIIndex: { [name: string]: number } = {}; public static async deployFrom0xArtifactAsync( artifact: ContractArtifact | SimpleContractArtifact, supportedProvider: SupportedProvider, @@ -257,6 +154,143 @@ export class StaticCallProxyContract extends BaseContract { ] as ContractAbi; return abi; } + + public getFunctionSignature(methodName: string): string { + const index = this._methodABIIndex[methodName]; + const methodAbi = StaticCallProxyContract.ABI()[index] as MethodAbi; + const functionSignature = methodAbiToFunctionSignature(methodAbi); + return functionSignature; + } + public getABIDecodedTransactionData(methodName: string, callData: string): T { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as StaticCallProxyContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + const abiDecodedCallData = abiEncoder.strictDecode(callData); + return abiDecodedCallData; + } + public getABIDecodedReturnData(methodName: string, callData: string): T { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as StaticCallProxyContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + const abiDecodedCallData = abiEncoder.strictDecodeReturnValue(callData); + return abiDecodedCallData; + } + public getSelector(methodName: string): string { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as StaticCallProxyContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + return abiEncoder.getSelector(); + } + + /** + * Makes a staticcall to a target address and verifies that the data returned matches the expected return data. + * @param assetData Byte array encoded with staticCallTarget, staticCallData, + * and expectedCallResultHash + * @param from This value is ignored. + * @param to This value is ignored. + * @param amount This value is ignored. + */ + public transferFrom(assetData: string, from: string, to: string, amount: BigNumber): ContractFunctionObj { + const self = (this as any) as StaticCallProxyContract; + assert.isString('assetData', assetData); + assert.isString('from', from); + assert.isString('to', to); + assert.isBigNumber('amount', amount); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('transferFrom(bytes,address,address,uint256)', [ + assetData, + from.toLowerCase(), + to.toLowerCase(), + amount, + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('transferFrom(bytes,address,address,uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'transferFrom(bytes,address,address,uint256)', + [assetData, from.toLowerCase(), to.toLowerCase(), amount], + ); + return abiEncodedTransactionData; + }, + }; + } + /** + * Gets the proxy id associated with the proxy address. + * @returns Proxy id. + */ + public getProxyId(): ContractFunctionObj { + const self = (this as any) as StaticCallProxyContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('getProxyId()', []); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('getProxyId()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('getProxyId()', []); + return abiEncodedTransactionData; + }, + }; + } + constructor( address: string, supportedProvider: SupportedProvider, @@ -274,6 +308,12 @@ export class StaticCallProxyContract extends BaseContract { deployedBytecode, ); classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']); + StaticCallProxyContract.ABI().forEach((item, index) => { + if (item.type === 'function') { + const methodAbi = item as MethodAbi; + this._methodABIIndex[methodAbi.name] = index; + } + }); } } diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts b/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts index ee4032ab99..30f9c6a7f0 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts @@ -1,7 +1,16 @@ // tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma enum-naming // tslint:disable:whitespace no-unbound-method no-trailing-whitespace // tslint:disable:no-unused-variable -import { BaseContract, SubscriptionManager, PromiseWithTransactionHash } from '@0x/base-contract'; +import { + AwaitTransactionSuccessOpts, + ContractFunctionObj, + ContractTxFunctionObj, + SendTransactionOpts, + BaseContract, + SubscriptionManager, + PromiseWithTransactionHash, + methodAbiToFunctionSignature, +} from '@0x/base-contract'; import { schemas } from '@0x/json-schemas'; import { BlockParam, @@ -19,13 +28,7 @@ import { SupportedProvider, } from 'ethereum-types'; import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils'; -import { - AwaitTransactionSuccessOpts, - EventCallback, - IndexedFilterValues, - SendTransactionOpts, - SimpleContractArtifact, -} from '@0x/types'; +import { EventCallback, IndexedFilterValues, SimpleContractArtifact } from '@0x/types'; import { Web3Wrapper } from '@0x/web3-wrapper'; import { assert } from '@0x/assert'; import * as ethers from 'ethers'; @@ -74,1089 +77,7 @@ export class WETH9Contract extends BaseContract { * @ignore */ public static deployedBytecode: string | undefined; - public name = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as WETH9Contract; - const encodedData = self._strictEncodeArguments('name()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('name()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public approve = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - guy: string, - wad: BigNumber, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('guy', guy); - assert.isBigNumber('wad', wad); - const self = (this as any) as WETH9Contract; - const encodedData = self._strictEncodeArguments('approve(address,uint256)', [guy.toLowerCase(), wad]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.approve.callAsync(guy, wad, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - guy: string, - wad: BigNumber, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('guy', guy); - assert.isBigNumber('wad', wad); - const self = (this as any) as WETH9Contract; - const txHashPromise = self.approve.sendTransactionAsync(guy.toLowerCase(), wad, txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync(guy: string, wad: BigNumber, txData?: Partial | undefined): Promise { - assert.isString('guy', guy); - assert.isBigNumber('wad', wad); - const self = (this as any) as WETH9Contract; - const encodedData = self._strictEncodeArguments('approve(address,uint256)', [guy.toLowerCase(), wad]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync( - guy: string, - wad: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('guy', guy); - assert.isBigNumber('wad', wad); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as WETH9Contract; - const encodedData = self._strictEncodeArguments('approve(address,uint256)', [guy.toLowerCase(), wad]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('approve(address,uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(guy: string, wad: BigNumber): string { - assert.isString('guy', guy); - assert.isBigNumber('wad', wad); - const self = (this as any) as WETH9Contract; - const abiEncodedTransactionData = self._strictEncodeArguments('approve(address,uint256)', [ - guy.toLowerCase(), - wad, - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as WETH9Contract; - const abiEncoder = self._lookupAbiEncoder('approve(address,uint256)'); - return abiEncoder.getSelector(); - }, - }; - public totalSupply = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as WETH9Contract; - const encodedData = self._strictEncodeArguments('totalSupply()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('totalSupply()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public transferFrom = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - src: string, - dst: string, - wad: BigNumber, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('src', src); - assert.isString('dst', dst); - assert.isBigNumber('wad', wad); - const self = (this as any) as WETH9Contract; - const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [ - src.toLowerCase(), - dst.toLowerCase(), - wad, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.transferFrom.callAsync(src, dst, wad, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - src: string, - dst: string, - wad: BigNumber, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('src', src); - assert.isString('dst', dst); - assert.isBigNumber('wad', wad); - const self = (this as any) as WETH9Contract; - const txHashPromise = self.transferFrom.sendTransactionAsync( - src.toLowerCase(), - dst.toLowerCase(), - wad, - txData, - opts, - ); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - src: string, - dst: string, - wad: BigNumber, - txData?: Partial | undefined, - ): Promise { - assert.isString('src', src); - assert.isString('dst', dst); - assert.isBigNumber('wad', wad); - const self = (this as any) as WETH9Contract; - const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [ - src.toLowerCase(), - dst.toLowerCase(), - wad, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync( - src: string, - dst: string, - wad: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('src', src); - assert.isString('dst', dst); - assert.isBigNumber('wad', wad); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as WETH9Contract; - const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [ - src.toLowerCase(), - dst.toLowerCase(), - wad, - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('transferFrom(address,address,uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(src: string, dst: string, wad: BigNumber): string { - assert.isString('src', src); - assert.isString('dst', dst); - assert.isBigNumber('wad', wad); - const self = (this as any) as WETH9Contract; - const abiEncodedTransactionData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [ - src.toLowerCase(), - dst.toLowerCase(), - wad, - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as WETH9Contract; - const abiEncoder = self._lookupAbiEncoder('transferFrom(address,address,uint256)'); - return abiEncoder.getSelector(); - }, - }; - public withdraw = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - wad: BigNumber, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isBigNumber('wad', wad); - const self = (this as any) as WETH9Contract; - const encodedData = self._strictEncodeArguments('withdraw(uint256)', [wad]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.withdraw.callAsync(wad, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - wad: BigNumber, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isBigNumber('wad', wad); - const self = (this as any) as WETH9Contract; - const txHashPromise = self.withdraw.sendTransactionAsync(wad, txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync(wad: BigNumber, txData?: Partial | undefined): Promise { - assert.isBigNumber('wad', wad); - const self = (this as any) as WETH9Contract; - const encodedData = self._strictEncodeArguments('withdraw(uint256)', [wad]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(wad: BigNumber, callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.isBigNumber('wad', wad); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as WETH9Contract; - const encodedData = self._strictEncodeArguments('withdraw(uint256)', [wad]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('withdraw(uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(wad: BigNumber): string { - assert.isBigNumber('wad', wad); - const self = (this as any) as WETH9Contract; - const abiEncodedTransactionData = self._strictEncodeArguments('withdraw(uint256)', [wad]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as WETH9Contract; - const abiEncoder = self._lookupAbiEncoder('withdraw(uint256)'); - return abiEncoder.getSelector(); - }, - }; - public decimals = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as WETH9Contract; - const encodedData = self._strictEncodeArguments('decimals()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('decimals()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public balanceOf = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync( - index_0: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('index_0', index_0); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as WETH9Contract; - const encodedData = self._strictEncodeArguments('balanceOf(address)', [index_0.toLowerCase()]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('balanceOf(address)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public symbol = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as WETH9Contract; - const encodedData = self._strictEncodeArguments('symbol()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('symbol()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public transfer = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - dst: string, - wad: BigNumber, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('dst', dst); - assert.isBigNumber('wad', wad); - const self = (this as any) as WETH9Contract; - const encodedData = self._strictEncodeArguments('transfer(address,uint256)', [dst.toLowerCase(), wad]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.transfer.callAsync(dst, wad, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - dst: string, - wad: BigNumber, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('dst', dst); - assert.isBigNumber('wad', wad); - const self = (this as any) as WETH9Contract; - const txHashPromise = self.transfer.sendTransactionAsync(dst.toLowerCase(), wad, txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync(dst: string, wad: BigNumber, txData?: Partial | undefined): Promise { - assert.isString('dst', dst); - assert.isBigNumber('wad', wad); - const self = (this as any) as WETH9Contract; - const encodedData = self._strictEncodeArguments('transfer(address,uint256)', [dst.toLowerCase(), wad]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync( - dst: string, - wad: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('dst', dst); - assert.isBigNumber('wad', wad); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as WETH9Contract; - const encodedData = self._strictEncodeArguments('transfer(address,uint256)', [dst.toLowerCase(), wad]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('transfer(address,uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(dst: string, wad: BigNumber): string { - assert.isString('dst', dst); - assert.isBigNumber('wad', wad); - const self = (this as any) as WETH9Contract; - const abiEncodedTransactionData = self._strictEncodeArguments('transfer(address,uint256)', [ - dst.toLowerCase(), - wad, - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as WETH9Contract; - const abiEncoder = self._lookupAbiEncoder('transfer(address,uint256)'); - return abiEncoder.getSelector(); - }, - }; - public deposit = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - const self = (this as any) as WETH9Contract; - const encodedData = self._strictEncodeArguments('deposit()', []); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.deposit.callAsync(txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - const self = (this as any) as WETH9Contract; - const txHashPromise = self.deposit.sendTransactionAsync(txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync(txData?: Partial | undefined): Promise { - const self = (this as any) as WETH9Contract; - const encodedData = self._strictEncodeArguments('deposit()', []); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as WETH9Contract; - const encodedData = self._strictEncodeArguments('deposit()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('deposit()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(): string { - const self = (this as any) as WETH9Contract; - const abiEncodedTransactionData = self._strictEncodeArguments('deposit()', []); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as WETH9Contract; - const abiEncoder = self._lookupAbiEncoder('deposit()'); - return abiEncoder.getSelector(); - }, - }; - public allowance = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync( - index_0: string, - index_1: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('index_0', index_0); - assert.isString('index_1', index_1); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as WETH9Contract; - const encodedData = self._strictEncodeArguments('allowance(address,address)', [ - index_0.toLowerCase(), - index_1.toLowerCase(), - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('allowance(address,address)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; + private _methodABIIndex: { [name: string]: number } = {}; private readonly _subscriptionManager: SubscriptionManager; public static async deployFrom0xArtifactAsync( artifact: ContractArtifact | SimpleContractArtifact, @@ -1513,6 +434,883 @@ export class WETH9Contract extends BaseContract { ] as ContractAbi; return abi; } + + public getFunctionSignature(methodName: string): string { + const index = this._methodABIIndex[methodName]; + const methodAbi = WETH9Contract.ABI()[index] as MethodAbi; + const functionSignature = methodAbiToFunctionSignature(methodAbi); + return functionSignature; + } + public getABIDecodedTransactionData(methodName: string, callData: string): T { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as WETH9Contract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + const abiDecodedCallData = abiEncoder.strictDecode(callData); + return abiDecodedCallData; + } + public getABIDecodedReturnData(methodName: string, callData: string): T { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as WETH9Contract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + const abiDecodedCallData = abiEncoder.strictDecodeReturnValue(callData); + return abiDecodedCallData; + } + public getSelector(methodName: string): string { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as WETH9Contract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + return abiEncoder.getSelector(); + } + + public name(): ContractFunctionObj { + const self = (this as any) as WETH9Contract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('name()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('name()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('name()', []); + return abiEncodedTransactionData; + }, + }; + } + public approve(guy: string, wad: BigNumber): ContractTxFunctionObj { + const self = (this as any) as WETH9Contract; + assert.isString('guy', guy); + assert.isBigNumber('wad', wad); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('approve(address,uint256)', [guy.toLowerCase(), wad]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('approve(address,uint256)', [guy.toLowerCase(), wad]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('approve(address,uint256)', [guy.toLowerCase(), wad]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('approve(address,uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('approve(address,uint256)', [ + guy.toLowerCase(), + wad, + ]); + return abiEncodedTransactionData; + }, + }; + } + public totalSupply(): ContractFunctionObj { + const self = (this as any) as WETH9Contract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('totalSupply()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('totalSupply()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('totalSupply()', []); + return abiEncodedTransactionData; + }, + }; + } + public transferFrom(src: string, dst: string, wad: BigNumber): ContractTxFunctionObj { + const self = (this as any) as WETH9Contract; + assert.isString('src', src); + assert.isString('dst', dst); + assert.isBigNumber('wad', wad); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [ + src.toLowerCase(), + dst.toLowerCase(), + wad, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [ + src.toLowerCase(), + dst.toLowerCase(), + wad, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [ + src.toLowerCase(), + dst.toLowerCase(), + wad, + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('transferFrom(address,address,uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [ + src.toLowerCase(), + dst.toLowerCase(), + wad, + ]); + return abiEncodedTransactionData; + }, + }; + } + public withdraw(wad: BigNumber): ContractTxFunctionObj { + const self = (this as any) as WETH9Contract; + assert.isBigNumber('wad', wad); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('withdraw(uint256)', [wad]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('withdraw(uint256)', [wad]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('withdraw(uint256)', [wad]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('withdraw(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('withdraw(uint256)', [wad]); + return abiEncodedTransactionData; + }, + }; + } + public decimals(): ContractFunctionObj { + const self = (this as any) as WETH9Contract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('decimals()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('decimals()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('decimals()', []); + return abiEncodedTransactionData; + }, + }; + } + public balanceOf(index_0: string): ContractFunctionObj { + const self = (this as any) as WETH9Contract; + assert.isString('index_0', index_0); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('balanceOf(address)', [index_0.toLowerCase()]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('balanceOf(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('balanceOf(address)', [ + index_0.toLowerCase(), + ]); + return abiEncodedTransactionData; + }, + }; + } + public symbol(): ContractFunctionObj { + const self = (this as any) as WETH9Contract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('symbol()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('symbol()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('symbol()', []); + return abiEncodedTransactionData; + }, + }; + } + public transfer(dst: string, wad: BigNumber): ContractTxFunctionObj { + const self = (this as any) as WETH9Contract; + assert.isString('dst', dst); + assert.isBigNumber('wad', wad); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('transfer(address,uint256)', [dst.toLowerCase(), wad]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('transfer(address,uint256)', [dst.toLowerCase(), wad]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('transfer(address,uint256)', [dst.toLowerCase(), wad]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('transfer(address,uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('transfer(address,uint256)', [ + dst.toLowerCase(), + wad, + ]); + return abiEncodedTransactionData; + }, + }; + } + public deposit(): ContractTxFunctionObj { + const self = (this as any) as WETH9Contract; + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('deposit()', []); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('deposit()', []); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('deposit()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('deposit()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('deposit()', []); + return abiEncodedTransactionData; + }, + }; + } + public allowance(index_0: string, index_1: string): ContractFunctionObj { + const self = (this as any) as WETH9Contract; + assert.isString('index_0', index_0); + assert.isString('index_1', index_1); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('allowance(address,address)', [ + index_0.toLowerCase(), + index_1.toLowerCase(), + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('allowance(address,address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('allowance(address,address)', [ + index_0.toLowerCase(), + index_1.toLowerCase(), + ]); + return abiEncodedTransactionData; + }, + }; + } + /** * Subscribe to an event type emitted by the WETH9 contract. * @param eventName The WETH9 contract event you would like to subscribe to. @@ -1602,6 +1400,12 @@ export class WETH9Contract extends BaseContract { WETH9Contract.ABI(), this._web3Wrapper, ); + WETH9Contract.ABI().forEach((item, index) => { + if (item.type === 'function') { + const methodAbi = item as MethodAbi; + this._methodABIIndex[methodAbi.name] = index; + } + }); } } diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts b/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts index 811787ec7b..2aa19aea36 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts @@ -1,7 +1,16 @@ // tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma enum-naming // tslint:disable:whitespace no-unbound-method no-trailing-whitespace // tslint:disable:no-unused-variable -import { BaseContract, SubscriptionManager, PromiseWithTransactionHash } from '@0x/base-contract'; +import { + AwaitTransactionSuccessOpts, + ContractFunctionObj, + ContractTxFunctionObj, + SendTransactionOpts, + BaseContract, + SubscriptionManager, + PromiseWithTransactionHash, + methodAbiToFunctionSignature, +} from '@0x/base-contract'; import { schemas } from '@0x/json-schemas'; import { BlockParam, @@ -19,13 +28,7 @@ import { SupportedProvider, } from 'ethereum-types'; import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils'; -import { - AwaitTransactionSuccessOpts, - EventCallback, - IndexedFilterValues, - SendTransactionOpts, - SimpleContractArtifact, -} from '@0x/types'; +import { EventCallback, IndexedFilterValues, SimpleContractArtifact } from '@0x/types'; import { Web3Wrapper } from '@0x/web3-wrapper'; import { assert } from '@0x/assert'; import * as ethers from 'ethers'; @@ -58,832 +61,7 @@ export class ZRXTokenContract extends BaseContract { * @ignore */ public static deployedBytecode: string | undefined; - public name = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ZRXTokenContract; - const encodedData = self._strictEncodeArguments('name()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('name()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public approve = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - _spender: string, - _value: BigNumber, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('_spender', _spender); - assert.isBigNumber('_value', _value); - const self = (this as any) as ZRXTokenContract; - const encodedData = self._strictEncodeArguments('approve(address,uint256)', [ - _spender.toLowerCase(), - _value, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.approve.callAsync(_spender, _value, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - _spender: string, - _value: BigNumber, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('_spender', _spender); - assert.isBigNumber('_value', _value); - const self = (this as any) as ZRXTokenContract; - const txHashPromise = self.approve.sendTransactionAsync(_spender.toLowerCase(), _value, txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - _spender: string, - _value: BigNumber, - txData?: Partial | undefined, - ): Promise { - assert.isString('_spender', _spender); - assert.isBigNumber('_value', _value); - const self = (this as any) as ZRXTokenContract; - const encodedData = self._strictEncodeArguments('approve(address,uint256)', [ - _spender.toLowerCase(), - _value, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync( - _spender: string, - _value: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('_spender', _spender); - assert.isBigNumber('_value', _value); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ZRXTokenContract; - const encodedData = self._strictEncodeArguments('approve(address,uint256)', [ - _spender.toLowerCase(), - _value, - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('approve(address,uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(_spender: string, _value: BigNumber): string { - assert.isString('_spender', _spender); - assert.isBigNumber('_value', _value); - const self = (this as any) as ZRXTokenContract; - const abiEncodedTransactionData = self._strictEncodeArguments('approve(address,uint256)', [ - _spender.toLowerCase(), - _value, - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as ZRXTokenContract; - const abiEncoder = self._lookupAbiEncoder('approve(address,uint256)'); - return abiEncoder.getSelector(); - }, - }; - public totalSupply = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ZRXTokenContract; - const encodedData = self._strictEncodeArguments('totalSupply()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('totalSupply()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - /** - * ERC20 transferFrom, modified such that an allowance of MAX_UINT represents an unlimited allowance. - */ - public transferFrom = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param _from Address to transfer from. - * @param _to Address to transfer to. - * @param _value Amount to transfer. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - _from: string, - _to: string, - _value: BigNumber, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('_from', _from); - assert.isString('_to', _to); - assert.isBigNumber('_value', _value); - const self = (this as any) as ZRXTokenContract; - const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [ - _from.toLowerCase(), - _to.toLowerCase(), - _value, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.transferFrom.callAsync(_from, _to, _value, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param _from Address to transfer from. - * @param _to Address to transfer to. - * @param _value Amount to transfer. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - _from: string, - _to: string, - _value: BigNumber, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('_from', _from); - assert.isString('_to', _to); - assert.isBigNumber('_value', _value); - const self = (this as any) as ZRXTokenContract; - const txHashPromise = self.transferFrom.sendTransactionAsync( - _from.toLowerCase(), - _to.toLowerCase(), - _value, - txData, - opts, - ); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param _from Address to transfer from. - * @param _to Address to transfer to. - * @param _value Amount to transfer. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - _from: string, - _to: string, - _value: BigNumber, - txData?: Partial | undefined, - ): Promise { - assert.isString('_from', _from); - assert.isString('_to', _to); - assert.isBigNumber('_value', _value); - const self = (this as any) as ZRXTokenContract; - const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [ - _from.toLowerCase(), - _to.toLowerCase(), - _value, - ]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param _from Address to transfer from. - * @param _to Address to transfer to. - * @param _value Amount to transfer. - * @returns Success of transfer. - */ - async callAsync( - _from: string, - _to: string, - _value: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('_from', _from); - assert.isString('_to', _to); - assert.isBigNumber('_value', _value); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ZRXTokenContract; - const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [ - _from.toLowerCase(), - _to.toLowerCase(), - _value, - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('transferFrom(address,address,uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param _from Address to transfer from. - * @param _to Address to transfer to. - * @param _value Amount to transfer. - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(_from: string, _to: string, _value: BigNumber): string { - assert.isString('_from', _from); - assert.isString('_to', _to); - assert.isBigNumber('_value', _value); - const self = (this as any) as ZRXTokenContract; - const abiEncodedTransactionData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [ - _from.toLowerCase(), - _to.toLowerCase(), - _value, - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as ZRXTokenContract; - const abiEncoder = self._lookupAbiEncoder('transferFrom(address,address,uint256)'); - return abiEncoder.getSelector(); - }, - }; - public decimals = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ZRXTokenContract; - const encodedData = self._strictEncodeArguments('decimals()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('decimals()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public balanceOf = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync( - _owner: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('_owner', _owner); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ZRXTokenContract; - const encodedData = self._strictEncodeArguments('balanceOf(address)', [_owner.toLowerCase()]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('balanceOf(address)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public symbol = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ZRXTokenContract; - const encodedData = self._strictEncodeArguments('symbol()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('symbol()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public transfer = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - _to: string, - _value: BigNumber, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isString('_to', _to); - assert.isBigNumber('_value', _value); - const self = (this as any) as ZRXTokenContract; - const encodedData = self._strictEncodeArguments('transfer(address,uint256)', [_to.toLowerCase(), _value]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.transfer.callAsync(_to, _value, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - _to: string, - _value: BigNumber, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isString('_to', _to); - assert.isBigNumber('_value', _value); - const self = (this as any) as ZRXTokenContract; - const txHashPromise = self.transfer.sendTransactionAsync(_to.toLowerCase(), _value, txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync(_to: string, _value: BigNumber, txData?: Partial | undefined): Promise { - assert.isString('_to', _to); - assert.isBigNumber('_value', _value); - const self = (this as any) as ZRXTokenContract; - const encodedData = self._strictEncodeArguments('transfer(address,uint256)', [_to.toLowerCase(), _value]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync( - _to: string, - _value: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('_to', _to); - assert.isBigNumber('_value', _value); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ZRXTokenContract; - const encodedData = self._strictEncodeArguments('transfer(address,uint256)', [_to.toLowerCase(), _value]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('transfer(address,uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(_to: string, _value: BigNumber): string { - assert.isString('_to', _to); - assert.isBigNumber('_value', _value); - const self = (this as any) as ZRXTokenContract; - const abiEncodedTransactionData = self._strictEncodeArguments('transfer(address,uint256)', [ - _to.toLowerCase(), - _value, - ]); - return abiEncodedTransactionData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as ZRXTokenContract; - const abiEncoder = self._lookupAbiEncoder('transfer(address,uint256)'); - return abiEncoder.getSelector(); - }, - }; - public allowance = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync( - _owner: string, - _spender: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('_owner', _owner); - assert.isString('_spender', _spender); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as ZRXTokenContract; - const encodedData = self._strictEncodeArguments('allowance(address,address)', [ - _owner.toLowerCase(), - _spender.toLowerCase(), - ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('allowance(address,address)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; + private _methodABIIndex: { [name: string]: number } = {}; private readonly _subscriptionManager: SubscriptionManager; public static async deployFrom0xArtifactAsync( artifact: ContractArtifact | SimpleContractArtifact, @@ -1171,6 +349,697 @@ export class ZRXTokenContract extends BaseContract { ] as ContractAbi; return abi; } + + public getFunctionSignature(methodName: string): string { + const index = this._methodABIIndex[methodName]; + const methodAbi = ZRXTokenContract.ABI()[index] as MethodAbi; + const functionSignature = methodAbiToFunctionSignature(methodAbi); + return functionSignature; + } + public getABIDecodedTransactionData(methodName: string, callData: string): T { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as ZRXTokenContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + const abiDecodedCallData = abiEncoder.strictDecode(callData); + return abiDecodedCallData; + } + public getABIDecodedReturnData(methodName: string, callData: string): T { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as ZRXTokenContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + const abiDecodedCallData = abiEncoder.strictDecodeReturnValue(callData); + return abiDecodedCallData; + } + public getSelector(methodName: string): string { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as ZRXTokenContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + return abiEncoder.getSelector(); + } + + public name(): ContractFunctionObj { + const self = (this as any) as ZRXTokenContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('name()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('name()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('name()', []); + return abiEncodedTransactionData; + }, + }; + } + public approve(_spender: string, _value: BigNumber): ContractTxFunctionObj { + const self = (this as any) as ZRXTokenContract; + assert.isString('_spender', _spender); + assert.isBigNumber('_value', _value); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('approve(address,uint256)', [ + _spender.toLowerCase(), + _value, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('approve(address,uint256)', [ + _spender.toLowerCase(), + _value, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('approve(address,uint256)', [ + _spender.toLowerCase(), + _value, + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('approve(address,uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('approve(address,uint256)', [ + _spender.toLowerCase(), + _value, + ]); + return abiEncodedTransactionData; + }, + }; + } + public totalSupply(): ContractFunctionObj { + const self = (this as any) as ZRXTokenContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('totalSupply()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('totalSupply()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('totalSupply()', []); + return abiEncodedTransactionData; + }, + }; + } + /** + * ERC20 transferFrom, modified such that an allowance of MAX_UINT represents an unlimited allowance. + * @param _from Address to transfer from. + * @param _to Address to transfer to. + * @param _value Amount to transfer. + * @returns Success of transfer. + */ + public transferFrom(_from: string, _to: string, _value: BigNumber): ContractTxFunctionObj { + const self = (this as any) as ZRXTokenContract; + assert.isString('_from', _from); + assert.isString('_to', _to); + assert.isBigNumber('_value', _value); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [ + _from.toLowerCase(), + _to.toLowerCase(), + _value, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [ + _from.toLowerCase(), + _to.toLowerCase(), + _value, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [ + _from.toLowerCase(), + _to.toLowerCase(), + _value, + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('transferFrom(address,address,uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [ + _from.toLowerCase(), + _to.toLowerCase(), + _value, + ]); + return abiEncodedTransactionData; + }, + }; + } + public decimals(): ContractFunctionObj { + const self = (this as any) as ZRXTokenContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('decimals()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('decimals()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('decimals()', []); + return abiEncodedTransactionData; + }, + }; + } + public balanceOf(_owner: string): ContractFunctionObj { + const self = (this as any) as ZRXTokenContract; + assert.isString('_owner', _owner); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('balanceOf(address)', [_owner.toLowerCase()]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('balanceOf(address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('balanceOf(address)', [ + _owner.toLowerCase(), + ]); + return abiEncodedTransactionData; + }, + }; + } + public symbol(): ContractFunctionObj { + const self = (this as any) as ZRXTokenContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('symbol()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('symbol()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('symbol()', []); + return abiEncodedTransactionData; + }, + }; + } + public transfer(_to: string, _value: BigNumber): ContractTxFunctionObj { + const self = (this as any) as ZRXTokenContract; + assert.isString('_to', _to); + assert.isBigNumber('_value', _value); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('transfer(address,uint256)', [ + _to.toLowerCase(), + _value, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('transfer(address,uint256)', [ + _to.toLowerCase(), + _value, + ]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('transfer(address,uint256)', [ + _to.toLowerCase(), + _value, + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('transfer(address,uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('transfer(address,uint256)', [ + _to.toLowerCase(), + _value, + ]); + return abiEncodedTransactionData; + }, + }; + } + public allowance(_owner: string, _spender: string): ContractFunctionObj { + const self = (this as any) as ZRXTokenContract; + assert.isString('_owner', _owner); + assert.isString('_spender', _spender); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('allowance(address,address)', [ + _owner.toLowerCase(), + _spender.toLowerCase(), + ]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('allowance(address,address)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('allowance(address,address)', [ + _owner.toLowerCase(), + _spender.toLowerCase(), + ]); + return abiEncodedTransactionData; + }, + }; + } + /** * Subscribe to an event type emitted by the ZRXToken contract. * @param eventName The ZRXToken contract event you would like to subscribe to. @@ -1260,6 +1129,12 @@ export class ZRXTokenContract extends BaseContract { ZRXTokenContract.ABI(), this._web3Wrapper, ); + ZRXTokenContract.ABI().forEach((item, index) => { + if (item.type === 'function') { + const methodAbi = item as MethodAbi; + this._methodABIIndex[methodAbi.name] = index; + } + }); } } diff --git a/packages/abi-gen/src/index.ts b/packages/abi-gen/src/index.ts index ef65285cd8..8a18eaf701 100644 --- a/packages/abi-gen/src/index.ts +++ b/packages/abi-gen/src/index.ts @@ -1,10 +1,8 @@ #!/usr/bin/env node - -import { execSync } from 'child_process'; - import { AbiEncoder, abiUtils, logUtils } from '@0x/utils'; import chalk from 'chalk'; import * as changeCase from 'change-case'; +import { execSync } from 'child_process'; import * as cliFormat from 'cli-format'; import { AbiDefinition, @@ -44,10 +42,6 @@ const args = yargs normalize: true, demandOption: true, }) - .option('debug', { - describe: 'Includes debug functions in the wrappers such as `getABIDecodedTransactionData`', - type: 'boolean', - }) .option('partials', { describe: 'Glob pattern for the partial template files', type: 'string', diff --git a/packages/abi-gen/src/types.ts b/packages/abi-gen/src/types.ts index dd1c8d9693..b02259f754 100644 --- a/packages/abi-gen/src/types.ts +++ b/packages/abi-gen/src/types.ts @@ -1,5 +1,4 @@ import { ContractAbi, EventAbi, MethodAbi } from 'ethereum-types'; - export enum ParamKind { Input = 'input', Output = 'output', diff --git a/packages/abi-gen/templates/TypeScript/contract.handlebars b/packages/abi-gen/templates/TypeScript/contract.handlebars index 2a2d56f845..606a3e0732 100644 --- a/packages/abi-gen/templates/TypeScript/contract.handlebars +++ b/packages/abi-gen/templates/TypeScript/contract.handlebars @@ -1,8 +1,16 @@ // tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma enum-naming // tslint:disable:whitespace no-unbound-method no-trailing-whitespace // tslint:disable:no-unused-variable -import { BaseContract{{#if events}}, - SubscriptionManager{{/if}},PromiseWithTransactionHash } from '@0x/base-contract'; +import { + AwaitTransactionSuccessOpts, + ContractFunctionObj, + ContractTxFunctionObj, + SendTransactionOpts, + BaseContract, + {{#if events~}}SubscriptionManager,{{/if~}} + PromiseWithTransactionHash, + methodAbiToFunctionSignature, +} from '@0x/base-contract'; import { schemas } from '@0x/json-schemas'; import { BlockParam, @@ -20,12 +28,13 @@ import { SupportedProvider, } from 'ethereum-types'; import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils'; -import { AwaitTransactionSuccessOpts, EventCallback, IndexedFilterValues, SendTransactionOpts, SimpleContractArtifact } from '@0x/types'; +import { EventCallback, IndexedFilterValues, SimpleContractArtifact } from '@0x/types'; import { Web3Wrapper } from '@0x/web3-wrapper'; import { assert } from '@0x/assert'; import * as ethers from 'ethers'; // tslint:enable:no-unused-variable + {{#if events}} export type {{contractName}}EventArgs = {{#each events}} @@ -56,27 +65,12 @@ export class {{contractName}}Contract extends BaseContract { {{else~}} public static deployedBytecode = '{{this.deployedBytecode}}'; {{/ifEquals~}} + private _methodABIIndex: { [name:string]: number } = {}; + {{#if events~}} + private readonly _subscriptionManager: SubscriptionManager<{{contractName}}EventArgs, {{contractName}}Events>; + {{/if~}} -{{#each methods}} - {{#if this.devdoc.details}} - /** - * {{formatDocstringForMethodTs this.devdoc.details}} - */ - {{/if}} - public {{languageSpecificName}} = { - {{^this.constant}} - {{> method_tx contractName=../contractName}} - {{/this.constant}} - {{#ifEquals this.stateMutability "pure"}} - {{> method_call_pure contractName=../contractName}} - {{else}} - {{> method_call contractName=../contractName}} - {{/ifEquals}} - {{> method_abi_helper contractName=../contractName debug=../debug}} - }; -{{/each}} -{{#if events}}private readonly _subscriptionManager: SubscriptionManager<{{contractName}}EventArgs, {{contractName}}Events>; -{{/if}}public static async deployFrom0xArtifactAsync( + public static async deployFrom0xArtifactAsync( artifact: ContractArtifact | SimpleContractArtifact, supportedProvider: SupportedProvider, txDefaults: Partial, @@ -169,7 +163,63 @@ export class {{contractName}}Contract extends BaseContract { {{/each}} ] as ContractAbi; return abi; - }{{#if events}} + } + + public getFunctionSignature(methodName: string): string { + const index = this._methodABIIndex[methodName]; + const methodAbi = {{contractName}}Contract.ABI()[index] as MethodAbi; + const functionSignature = methodAbiToFunctionSignature(methodAbi); + return functionSignature; + } + public getABIDecodedTransactionData(methodName: string, callData: string): T { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as {{contractName}}Contract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + const abiDecodedCallData = abiEncoder.strictDecode(callData); + return abiDecodedCallData; + } + public getABIDecodedReturnData(methodName: string, callData: string): T { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as {{contractName}}Contract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + const abiDecodedCallData = abiEncoder.strictDecodeReturnValue(callData); + return abiDecodedCallData; + } + public getSelector(methodName: string): string { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as {{contractName}}Contract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + return abiEncoder.getSelector(); + } + + {{#each methods}} + {{#if this.devdoc.details}} + /** + * {{formatDocstringForMethodTs this.devdoc.details}} + {{> params_docstring inputs=inputs docstrings=devdoc.params}} + {{#if devdoc.return}} + * @returns {{devdoc.return}} + {{/if}} + */ + {{/if}} + public {{languageSpecificName}}( + {{> typed_params inputs=this.inputs}} + ): Contract{{^this.constant}}Tx{{/this.constant}}FunctionObj<{{> return_type outputs=outputs ~}}> { + const self = this as any as {{../contractName}}Contract; + {{#each inputs}} + {{#assertionType name type}}{{/assertionType}} + {{/each}} + + return { + {{^this.constant}} + {{> method_tx}} + {{/this.constant}} + {{> method_call stateMutability=this.stateMutability}} + } + }; + {{/each}} + + {{#if events}} /** * Subscribe to an event type emitted by the {{contractName}} contract. * @param eventName The {{contractName}} contract event you would like to subscribe to. @@ -246,11 +296,18 @@ export class {{contractName}}Contract extends BaseContract { deployedBytecode: string | undefined = {{contractName}}Contract.deployedBytecode, ) { super('{{contractName}}', {{contractName}}Contract.ABI(), address, supportedProvider, txDefaults, logDecodeDependencies, deployedBytecode); - classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']);{{#if events}} + classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']); + {{#if events~}} this._subscriptionManager = new SubscriptionManager<{{contractName}}EventArgs, {{contractName}}Events>( {{contractName}}Contract.ABI(), this._web3Wrapper, - );{{/if}} + );{{/if~}} + {{contractName}}Contract.ABI().forEach((item, index) => { + if (item.type === 'function') { + const methodAbi = item as MethodAbi; + this._methodABIIndex[methodAbi.name] = index; + } + }) } } diff --git a/packages/abi-gen/templates/TypeScript/partials/method_abi_helper.handlebars b/packages/abi-gen/templates/TypeScript/partials/method_abi_helper.handlebars deleted file mode 100644 index 64780645ea..0000000000 --- a/packages/abi-gen/templates/TypeScript/partials/method_abi_helper.handlebars +++ /dev/null @@ -1,86 +0,0 @@ -{{!-- if ((NOT constant) AND (NOT debug)), to avoid repetition bbecause we use all 4 functions if (debug) --}} -{{^if constant~}} -{{^if debug~}} -/** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). -{{> params_docstring inputs=inputs docstrings=devdoc.params}} - * @returns The ABI encoded transaction data as a string - */ -getABIEncodedTransactionData( - {{> typed_params inputs=inputs}} - ): string { - {{#each inputs}} - {{#assertionType name type}}{{/assertionType}} - {{/each}} - const self = this as any as {{contractName}}Contract; - const abiEncodedTransactionData = self._strictEncodeArguments('{{this.functionSignature}}', [{{> normalized_params inputs=inputs}}]); - return abiEncodedTransactionData; -}, -/** - * Returns the 4 byte function selector as a hex string. - */ -getSelector(): string { - const self = this as any as {{contractName}}Contract; - const abiEncoder = self._lookupAbiEncoder('{{this.functionSignature}}'); - return abiEncoder.getSelector(); -} -{{/if~}} -{{/if~}} - -{{#if debug~}} -/** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). -{{> params_docstring inputs=inputs docstrings=devdoc.params}} - * @returns The ABI encoded transaction data as a string - */ -getABIEncodedTransactionData( - {{> typed_params inputs=inputs}} - ): string { - {{#each inputs}} - {{#assertionType name type}}{{/assertionType}} - {{/each}} - const self = this as any as {{contractName}}Contract; - const abiEncodedTransactionData = self._strictEncodeArguments('{{this.functionSignature}}', [{{> normalized_params inputs=inputs}}]); - return abiEncodedTransactionData; -}, -/** - * Decode the ABI-encoded transaction data into its input arguments - * @param callData The ABI-encoded transaction data - * @returns An array representing the input arguments in order. Keynames of nested structs are preserved. - */ -getABIDecodedTransactionData( - callData: string -): ({{> return_type outputs=inputs ~}}) { - const self = this as any as {{contractName}}Contract; - const abiEncoder = self._lookupAbiEncoder('{{this.functionSignature}}'); - // tslint:disable boolean-naming - const abiDecodedCallData = abiEncoder.strictDecode<{{> return_type outputs=inputs}}>(callData); - return abiDecodedCallData; -}, -/** - * Decode the ABI-encoded return data from a transaction - * @param returnData the data returned after transaction execution - * @returns An array representing the output results in order. Keynames of nested structs are preserved. - */ -getABIDecodedReturnData( - returnData: string -): ({{> return_type outputs=outputs ~}}) { - const self = this as any as {{contractName}}Contract; - const abiEncoder = self._lookupAbiEncoder('{{this.functionSignature}}'); - // tslint:disable boolean-naming - const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<{{> return_type outputs=outputs}}>(returnData); - return abiDecodedReturnData; -}, -/** - * Returns the 4 byte function selector as a hex string. - */ -getSelector(): string { - const self = this as any as {{contractName}}Contract; - const abiEncoder = self._lookupAbiEncoder('{{this.functionSignature}}'); - return abiEncoder.getSelector(); -} -{{/if}} diff --git a/packages/abi-gen/templates/TypeScript/partials/method_call.handlebars b/packages/abi-gen/templates/TypeScript/partials/method_call.handlebars index cfb8faf7d1..25e07f1188 100644 --- a/packages/abi-gen/templates/TypeScript/partials/method_call.handlebars +++ b/packages/abi-gen/templates/TypeScript/partials/method_call.handlebars @@ -1,20 +1,7 @@ -/** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. -{{> params_docstring inputs=inputs docstrings=devdoc.params}} -{{#if devdoc.return}} - * @returns {{devdoc.return}} -{{/if}} - */ async callAsync( -{{> typed_params inputs=inputs}} callData: Partial = {}, defaultBlock?: BlockParam, ): Promise<{{> return_type outputs=outputs}}> { - {{#each inputs}} - {{#assertionType name type}}{{/assertionType}} - {{/each}} assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ schemas.addressSchema, schemas.numberSchema, @@ -23,8 +10,14 @@ async callAsync( if (defaultBlock !== undefined) { assert.isBlockParam('defaultBlock', defaultBlock); } - const self = this as any as {{contractName}}Contract; const encodedData = self._strictEncodeArguments('{{this.functionSignature}}', [{{> normalized_params inputs=inputs}}]); + let rawCallResult; + + {{#ifEquals this.stateMutability "pure"}} + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + {{else}} const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { to: self.address, @@ -34,13 +27,14 @@ async callAsync( self._web3Wrapper.getContractDefaults(), ); callDataWithDefaults.from = callDataWithDefaults.from ? callDataWithDefaults.from.toLowerCase() : callDataWithDefaults.from; - let rawCallResult; try { rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + {{/ifEquals}} } catch (err) { BaseContract._throwIfThrownErrorIsRevertError(err); throw err; } + BaseContract._throwIfCallResultIsRevertError(rawCallResult); const abiEncoder = self._lookupAbiEncoder('{{this.functionSignature}}'); // tslint:disable boolean-naming @@ -48,3 +42,7 @@ async callAsync( // tslint:enable boolean-naming return result; }, +getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('{{this.functionSignature}}', [{{> normalized_params inputs=inputs}}]); + return abiEncodedTransactionData; +}, diff --git a/packages/abi-gen/templates/TypeScript/partials/method_call_pure.handlebars b/packages/abi-gen/templates/TypeScript/partials/method_call_pure.handlebars deleted file mode 100644 index 2ec68190f9..0000000000 --- a/packages/abi-gen/templates/TypeScript/partials/method_call_pure.handlebars +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. -{{> params_docstring inputs=inputs docstrings=devdoc.params}} -{{#if devdoc.return}} - * @returns {{devdoc.return}} -{{/if}} - */ -async callAsync( -{{> typed_params inputs=inputs}} - callData: Partial = {}, - defaultBlock?: BlockParam, -): Promise<{{> return_type outputs=outputs}}> { - {{#each inputs}} - {{#assertionType name type}}{{/assertionType}} - {{/each}} - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = this as any as {{contractName}}Contract; - const encodedData = self._strictEncodeArguments('{{this.functionSignature}}', [{{> normalized_params inputs=inputs}}]); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('{{this.functionSignature}}'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue<{{> return_type outputs=outputs}}>(rawCallResult); - // tslint:enable boolean-naming - return result; -}, diff --git a/packages/abi-gen/templates/TypeScript/partials/method_tx.handlebars b/packages/abi-gen/templates/TypeScript/partials/method_tx.handlebars index de4e7eb324..6262c3d39e 100644 --- a/packages/abi-gen/templates/TypeScript/partials/method_tx.handlebars +++ b/packages/abi-gen/templates/TypeScript/partials/method_tx.handlebars @@ -1,19 +1,7 @@ -/** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - {{> params_docstring inputs=inputs docstrings=devdoc.params}} - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ async sendTransactionAsync( -{{> typed_params inputs=inputs}} -txData?: Partial | undefined, -opts: SendTransactionOpts = { shouldValidate: true }, + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, ): Promise { - {{#each inputs}} - {{#assertionType name type}}{{/assertionType}} - {{/each}} - const self = this as any as {{contractName}}Contract; const encodedData = self._strictEncodeArguments('{{this.functionSignature}}', [{{> normalized_params inputs=inputs}}]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { @@ -28,10 +16,7 @@ opts: SendTransactionOpts = { shouldValidate: true }, } if (opts.shouldValidate !== false) { - await self.{{languageSpecificName}}.callAsync( - {{#each inputs~}} - {{name}}, - {{/each~}} + await this.callAsync( txDataWithDefaults, ); } @@ -39,28 +24,11 @@ opts: SendTransactionOpts = { shouldValidate: true }, const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); return txHash; }, -/** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - {{> params_docstring inputs=inputs docstrings=devdoc.params}} - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ awaitTransactionSuccessAsync( -{{> typed_params inputs=inputs}} txData?: Partial, opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, ): PromiseWithTransactionHash { - {{#each inputs}} - {{#assertionType name type}}{{/assertionType}} - {{/each}} - const self = this as any as {{contractName}}Contract; - {{#if inputs}} - const txHashPromise = self.{{languageSpecificName}}.sendTransactionAsync({{> normalized_params input=inputs}}, txData, opts); - {{else}} - const txHashPromise = self.{{languageSpecificName}}.sendTransactionAsync(txData, opts); - {{/if}} + const txHashPromise = this.sendTransactionAsync(txData, opts); return new PromiseWithTransactionHash( txHashPromise, (async (): Promise => { @@ -73,20 +41,9 @@ awaitTransactionSuccessAsync( })(), ); }, -/** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - {{> params_docstring inputs=inputs docstrings=devdoc.params}} - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ async estimateGasAsync( -{{> typed_params inputs=inputs}} txData?: Partial | undefined, ): Promise { - {{#each inputs}} - {{#assertionType name type}}{{/assertionType}} - {{/each}} - const self = this as any as {{contractName}}Contract; const encodedData = self._strictEncodeArguments('{{this.functionSignature}}', [{{> normalized_params inputs=inputs}}]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { diff --git a/packages/abi-gen/test-cli/output/typescript/abi_gen_dummy.ts b/packages/abi-gen/test-cli/output/typescript/abi_gen_dummy.ts index 71fd822b91..cd0c70c3d1 100644 --- a/packages/abi-gen/test-cli/output/typescript/abi_gen_dummy.ts +++ b/packages/abi-gen/test-cli/output/typescript/abi_gen_dummy.ts @@ -1,7 +1,16 @@ // tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma enum-naming // tslint:disable:whitespace no-unbound-method no-trailing-whitespace // tslint:disable:no-unused-variable -import { BaseContract, SubscriptionManager, PromiseWithTransactionHash } from '@0x/base-contract'; +import { + AwaitTransactionSuccessOpts, + ContractFunctionObj, + ContractTxFunctionObj, + SendTransactionOpts, + BaseContract, + SubscriptionManager, + PromiseWithTransactionHash, + methodAbiToFunctionSignature, +} from '@0x/base-contract'; import { schemas } from '@0x/json-schemas'; import { BlockParam, @@ -19,13 +28,7 @@ import { SupportedProvider, } from 'ethereum-types'; import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils'; -import { - AwaitTransactionSuccessOpts, - EventCallback, - IndexedFilterValues, - SendTransactionOpts, - SimpleContractArtifact, -} from '@0x/types'; +import { EventCallback, IndexedFilterValues, SimpleContractArtifact } from '@0x/types'; import { Web3Wrapper } from '@0x/web3-wrapper'; import { assert } from '@0x/assert'; import * as ethers from 'ethers'; @@ -57,2974 +60,7 @@ export class AbiGenDummyContract extends BaseContract { */ public static deployedBytecode = '0x608060405234801561001057600080fd5b50600436106101d95760003560e01c806376f15d5b11610104578063bb607362116100a2578063d88be12f11610071578063d88be12f1461039b578063ee8b86fb146103a3578063f408fb3114610279578063fa315f9d146103b6576101d9565b8063bb60736214610353578063bdab168814610369578063cd3c0b971461037e578063d6d7618c14610386576101d9565b80638ee52b4e116100de5780638ee52b4e146103225780639a3b618514610335578063a3c2f6b61461033d578063ae2dae1714610345576101d9565b806376f15d5b146102f25780637833bec0146102fa5780637a791e6e1461031a576101d9565b80634303a5421161017c57806359c28add1161014b57806359c28add146102b45780635ba3c7c0146102c957806363d69c88146102d1578063647341eb146102e4576101d9565b80634303a542146102875780634582eab21461028f57806345fdbdb714610297578063586f84b21461029f576101d9565b80632e1a7d4d116101b85780632e1a7d4d146102245780633687617d1461023757806336b32396146102595780633e9ef66a14610279576101d9565b806209e437146101de5780630527c28f146101e85780631310e444146101fb575b600080fd5b6101e66103c4565b005b6101e66101f6366004610c7f565b610401565b61020e610209366004610d87565b610404565b60405161021b91906113e8565b60405180910390f35b6101e6610232366004610d87565b61040b565b61024a610245366004610efc565b61045c565b60405161021b93929190611151565b61026c610267366004610d0b565b6104fc565b60405161021b9190611094565b6101e66101f6366004610d4c565b61020e6105de565b6101e66105e5565b6101e661064a565b6102a761067c565b60405161021b9190611373565b6102bc610684565b60405161021b919061137e565b6101e661068c565b61026c6102df366004610c2e565b6106f1565b6101e66101f6366004610ec9565b61020e6106fa565b61030d610308366004610d9f565b610708565b60405161021b9190611287565b6101e66107c5565b61020e610330366004610d87565b6107ca565b6101e66107d0565b61020e6107db565b6101e66101f6366004610e39565b61035b6107e0565b60405161021b9291906113f1565b610371610819565b60405161021b91906110b5565b6101e661081e565b61038e610855565b60405161021b91906113d5565b61020e6109ae565b6101e66103b1366004610d87565b6101f6565b6101e66101f6366004610d87565b6040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103f690611250565b60405180910390fd5b565b50565b506107c790565b3373ffffffffffffffffffffffffffffffffffffffff167f7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b658260405161045191906113e8565b60405180910390a250565b505060408051808201825260048082527f1234567800000000000000000000000000000000000000000000000000000000602080840191909152835180850185528281527f87654321000000000000000000000000000000000000000000000000000000008183015284518086019095529184527f616d657400000000000000000000000000000000000000000000000000000000908401529093909250565b600060606040518060400160405280601c81526020017f19457468657265756d205369676e6564204d6573736167653a0a33320000000081525090506000818760405160200161054d929190611072565b604051602081830303815290604052805190602001209050600181878787604051600081526020016040526040516105889493929190611133565b6020604051602081039080840390855afa1580156105aa573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015198975050505050505050565b6107c75b90565b604080518082018252601481527f5245564552545f574954485f434f4e5354414e54000000000000000000000000602082015290517f08c379a00000000000000000000000000000000000000000000000000000000081526103f69190600401611193565b6040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103f690611219565b6105e26109b4565b6105e26109cc565b604080518082018252601581527f524551554952455f574954485f434f4e5354414e540000000000000000000000602082015290517f08c379a00000000000000000000000000000000000000000000000000000000081526103f69190600401611193565b50929392505050565b600080546001019081905590565b6107106109ec565b50604080516080810182529182528051808201825260048082527f123456780000000000000000000000000000000000000000000000000000000060208381019190915280850192909252825180840184528181527f87654321000000000000000000000000000000000000000000000000000000008184015284840152825180840190935282527f616d65740000000000000000000000000000000000000000000000000000000090820152606082015290565b6103ff565b60010190565b600080546001019055565b600190565b60408051808201909152600581527f68656c6c6f0000000000000000000000000000000000000000000000000000006020820152600191565b606090565b7f61a6029a4c7ddee5824d171331eecbd015d26a271310a223718b837facb5b77160405161084b906111ad565b60405180910390a1565b61085d610a1a565b6040805160028082526060828101909352816020015b60608152602001906001900390816108735790505090506040518060400160405280600581526020017f3078313233000000000000000000000000000000000000000000000000000000815250816000815181106108cd57fe5b60200260200101819052506040518060400160405280600581526020017f30783332310000000000000000000000000000000000000000000000000000008152508160018151811061091b57fe5b6020908102919091018101919091526040805160c0810182526005608082018181527f307831323300000000000000000000000000000000000000000000000000000060a0840152825281840152808201939093528051808201909152600381527f6162630000000000000000000000000000000000000000000000000000000000918101919091526060820152905090565b6104d290565b60405180602001604052806109c7610a48565b905290565b60405180604001604052806109df610a1a565b8152602001606081525090565b60405180608001604052806109ff610a5b565b81526020016060815260200160608152602001606081525090565b604051806080016040528060608152602001600063ffffffff16815260200160608152602001606081525090565b6040518060200160405280600081525090565b60405180606001604052806000815260200160608152602001606081525090565b600082601f830112610a8c578081fd5b8135610a9f610a9a82611431565b61140a565b8181529150602080830190840160005b83811015610adc57610ac78760208435890101610ae6565b83526020928301929190910190600101610aaf565b5050505092915050565b600082601f830112610af6578081fd5b813567ffffffffffffffff811115610b0c578182fd5b610b3d60207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8401160161140a565b9150808252836020828501011115610b5457600080fd5b8060208401602084013760009082016020015292915050565b600060808284031215610b7e578081fd5b610b88608061140a565b9050813567ffffffffffffffff80821115610ba257600080fd5b610bae85838601610ae6565b8352610bbd8560208601610c14565b60208401526040840135915080821115610bd657600080fd5b610be285838601610a7c565b60408401526060840135915080821115610bfb57600080fd5b50610c0884828501610ae6565b60608301525092915050565b803563ffffffff81168114610c2857600080fd5b92915050565b600080600080600060a08688031215610c45578081fd5b8535610c5081611481565b945060208601359350604086013592506060860135610c6e81611481565b949793965091946080013592915050565b60006020808385031215610c91578182fd5b823567ffffffffffffffff811115610ca7578283fd5b80840185601f820112610cb8578384fd5b80359150610cc8610a9a83611431565b82815283810190828501865b85811015610cfd57610ceb8a888435880101610ae6565b84529286019290860190600101610cd4565b509098975050505050505050565b60008060008060808587031215610d20578384fd5b84359350602085013560ff81168114610d37578384fd5b93969395505050506040820135916060013590565b600060208284031215610d5d578081fd5b813567ffffffffffffffff811115610d73578182fd5b610d7f84828501610ae6565b949350505050565b600060208284031215610d98578081fd5b5035919050565b600060208284031215610db0578081fd5b813567ffffffffffffffff80821115610dc7578283fd5b81840160608187031215610dd9578384fd5b610de3606061140a565b925080358352602081013582811115610dfa578485fd5b610e0687828401610ae6565b602085015250604081013582811115610e1d578485fd5b610e2987828401610ae6565b6040850152509195945050505050565b600060208284031215610e4a578081fd5b813567ffffffffffffffff80821115610e61578283fd5b81840160408187031215610e73578384fd5b610e7d604061140a565b9250803582811115610e8d578485fd5b610e9987828401610b6d565b845250602081013582811115610ead578485fd5b610eb987828401610ae6565b6020850152509195945050505050565b600060208284031215610eda578081fd5b813567ffffffffffffffff811115610ef0578182fd5b610d7f84828501610b6d565b600080600060608486031215610f10578081fd5b83359250602084013567ffffffffffffffff80821115610f2e578283fd5b610f3a87838801610ae6565b93506040860135915080821115610f4f578283fd5b50610f5c86828701610ae6565b9150509250925092565b60008151808452610f7e816020860160208601611451565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b6000815160808452610fc56080850182610f66565b6020915063ffffffff828501511682860152604084015185820360408701528181518084528484019150848582028501018584018794505b8285101561104b577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0868303018452611037828251610f66565b600195909501949387019391508601610ffd565b506060880151955088810360608a01526110658187610f66565b9998505050505050505050565b60008351611084818460208801611451565b9190910191825250602001919050565b73ffffffffffffffffffffffffffffffffffffffff91909116815260200190565b6000602080830181845280855180835260408601915060408482028701019250838701855b82811015611126577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc0888603018452611114858351610fb0565b945092850192908501906001016110da565b5092979650505050505050565b93845260ff9290921660208401526040830152606082015260800190565b6000606082526111646060830186610f66565b82810360208401526111768186610f66565b83810360408501526111888186610f66565b979650505050505050565b6000602082526111a66020830184610f66565b9392505050565b60408082526004908201527f123456780000000000000000000000000000000000000000000000000000000060608201526080602082018190526005908201527f6c6f72656d00000000000000000000000000000000000000000000000000000060a082015260c00190565b6020808252600d908201527f53494d504c455f52455645525400000000000000000000000000000000000000604082015260600190565b6020808252600e908201527f53494d504c455f52455155495245000000000000000000000000000000000000604082015260600190565b600060208252825160806020840152805160a08401526020810151606060c08501526112b7610100850182610f66565b604083015191507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff608582030160e08601526112f28183610f66565b9250505060208401517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0808584030160408601526113308383610f66565b604087015193508186820301606087015261134b8185610f66565b92505060608601519250808583030160808601525061136a8183610f66565b95945050505050565b905151815260200190565b60006020825282516040602084015261139a6060840182610fb0565b602085015191507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe084820301604085015261136a8183610f66565b6000602082526111a66020830184610fb0565b90815260200190565b600083825260406020830152610d7f6040830184610f66565b60405181810167ffffffffffffffff8111828210171561142957600080fd5b604052919050565b600067ffffffffffffffff821115611447578081fd5b5060209081020190565b60005b8381101561146c578181015183820152602001611454565b8381111561147b576000848401525b50505050565b73ffffffffffffffffffffffffffffffffffffffff8116811461040157600080fdfea365627a7a723158204f5b227587475ada330d11bfb46020f41172555bd06234eaaad1a7d10a4c2a396c6578706572696d656e74616cf564736f6c634300050c0040'; - /** - * a method that accepts an array of bytes - */ - public acceptsAnArrayOfBytes = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param a the array of bytes being accepted - */ - async callAsync(a: string[], callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.isArray('a', a); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as AbiGenDummyContract; - const encodedData = self._strictEncodeArguments('acceptsAnArrayOfBytes(bytes[])', [a]); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('acceptsAnArrayOfBytes(bytes[])'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param a the array of bytes being accepted - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(a: string[]): string { - assert.isArray('a', a); - const self = (this as any) as AbiGenDummyContract; - const abiEncodedTransactionData = self._strictEncodeArguments('acceptsAnArrayOfBytes(bytes[])', [a]); - return abiEncodedTransactionData; - }, - /** - * Decode the ABI-encoded transaction data into its input arguments - * @param callData The ABI-encoded transaction data - * @returns An array representing the input arguments in order. Keynames of nested structs are preserved. - */ - getABIDecodedTransactionData(callData: string): [string[]] { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('acceptsAnArrayOfBytes(bytes[])'); - // tslint:disable boolean-naming - const abiDecodedCallData = abiEncoder.strictDecode<[string[]]>(callData); - return abiDecodedCallData; - }, - /** - * Decode the ABI-encoded return data from a transaction - * @param returnData the data returned after transaction execution - * @returns An array representing the output results in order. Keynames of nested structs are preserved. - */ - getABIDecodedReturnData(returnData: string): void { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('acceptsAnArrayOfBytes(bytes[])'); - // tslint:disable boolean-naming - const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); - return abiDecodedReturnData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('acceptsAnArrayOfBytes(bytes[])'); - return abiEncoder.getSelector(); - }, - }; - public acceptsBytes = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(a: string, callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.isString('a', a); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as AbiGenDummyContract; - const encodedData = self._strictEncodeArguments('acceptsBytes(bytes)', [a]); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('acceptsBytes(bytes)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(a: string): string { - assert.isString('a', a); - const self = (this as any) as AbiGenDummyContract; - const abiEncodedTransactionData = self._strictEncodeArguments('acceptsBytes(bytes)', [a]); - return abiEncodedTransactionData; - }, - /** - * Decode the ABI-encoded transaction data into its input arguments - * @param callData The ABI-encoded transaction data - * @returns An array representing the input arguments in order. Keynames of nested structs are preserved. - */ - getABIDecodedTransactionData(callData: string): [string] { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('acceptsBytes(bytes)'); - // tslint:disable boolean-naming - const abiDecodedCallData = abiEncoder.strictDecode<[string]>(callData); - return abiDecodedCallData; - }, - /** - * Decode the ABI-encoded return data from a transaction - * @param returnData the data returned after transaction execution - * @returns An array representing the output results in order. Keynames of nested structs are preserved. - */ - getABIDecodedReturnData(returnData: string): void { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('acceptsBytes(bytes)'); - // tslint:disable boolean-naming - const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); - return abiDecodedReturnData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('acceptsBytes(bytes)'); - return abiEncoder.getSelector(); - }, - }; - /** - * Tests decoding when the input and output are complex. - */ - public complexInputComplexOutput = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync( - complexInput: { foo: BigNumber; bar: string; car: string }, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise<{ - input: { foo: BigNumber; bar: string; car: string }; - lorem: string; - ipsum: string; - dolor: string; - }> { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as AbiGenDummyContract; - const encodedData = self._strictEncodeArguments('complexInputComplexOutput((uint256,bytes,string))', [ - complexInput, - ]); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('complexInputComplexOutput((uint256,bytes,string))'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue<{ - input: { foo: BigNumber; bar: string; car: string }; - lorem: string; - ipsum: string; - dolor: string; - }>(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(complexInput: { foo: BigNumber; bar: string; car: string }): string { - const self = (this as any) as AbiGenDummyContract; - const abiEncodedTransactionData = self._strictEncodeArguments( - 'complexInputComplexOutput((uint256,bytes,string))', - [complexInput], - ); - return abiEncodedTransactionData; - }, - /** - * Decode the ABI-encoded transaction data into its input arguments - * @param callData The ABI-encoded transaction data - * @returns An array representing the input arguments in order. Keynames of nested structs are preserved. - */ - getABIDecodedTransactionData(callData: string): { foo: BigNumber; bar: string; car: string } { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('complexInputComplexOutput((uint256,bytes,string))'); - // tslint:disable boolean-naming - const abiDecodedCallData = abiEncoder.strictDecode<{ foo: BigNumber; bar: string; car: string }>(callData); - return abiDecodedCallData; - }, - /** - * Decode the ABI-encoded return data from a transaction - * @param returnData the data returned after transaction execution - * @returns An array representing the output results in order. Keynames of nested structs are preserved. - */ - getABIDecodedReturnData( - returnData: string, - ): { input: { foo: BigNumber; bar: string; car: string }; lorem: string; ipsum: string; dolor: string } { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('complexInputComplexOutput((uint256,bytes,string))'); - // tslint:disable boolean-naming - const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<{ - input: { foo: BigNumber; bar: string; car: string }; - lorem: string; - ipsum: string; - dolor: string; - }>(returnData); - return abiDecodedReturnData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('complexInputComplexOutput((uint256,bytes,string))'); - return abiEncoder.getSelector(); - }, - }; - /** - * test that devdocs will be generated and - * that multiline devdocs will look okay - */ - public ecrecoverFn = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param hash description of some hash. Let's make this line super long to - * demonstrate hanging indents for method params. It has to be more than - * one hundred twenty columns. - * @param v some v, recovery id - * @param r ECDSA r output - * @param s ECDSA s output - * @returns the signerAddress that created this signature. this line too is super long in order to demonstrate the proper hanging indentation in generated code. - */ - async callAsync( - hash: string, - v: number | BigNumber, - r: string, - s: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('hash', hash); - assert.isNumberOrBigNumber('v', v); - assert.isString('r', r); - assert.isString('s', s); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as AbiGenDummyContract; - const encodedData = self._strictEncodeArguments('ecrecoverFn(bytes32,uint8,bytes32,bytes32)', [ - hash, - v, - r, - s, - ]); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('ecrecoverFn(bytes32,uint8,bytes32,bytes32)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @param hash description of some hash. Let's make this line super long to - * demonstrate hanging indents for method params. It has to be more than - * one hundred twenty columns. - * @param v some v, recovery id - * @param r ECDSA r output - * @param s ECDSA s output - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(hash: string, v: number | BigNumber, r: string, s: string): string { - assert.isString('hash', hash); - assert.isNumberOrBigNumber('v', v); - assert.isString('r', r); - assert.isString('s', s); - const self = (this as any) as AbiGenDummyContract; - const abiEncodedTransactionData = self._strictEncodeArguments( - 'ecrecoverFn(bytes32,uint8,bytes32,bytes32)', - [hash, v, r, s], - ); - return abiEncodedTransactionData; - }, - /** - * Decode the ABI-encoded transaction data into its input arguments - * @param callData The ABI-encoded transaction data - * @returns An array representing the input arguments in order. Keynames of nested structs are preserved. - */ - getABIDecodedTransactionData(callData: string): string { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('ecrecoverFn(bytes32,uint8,bytes32,bytes32)'); - // tslint:disable boolean-naming - const abiDecodedCallData = abiEncoder.strictDecode(callData); - return abiDecodedCallData; - }, - /** - * Decode the ABI-encoded return data from a transaction - * @param returnData the data returned after transaction execution - * @returns An array representing the output results in order. Keynames of nested structs are preserved. - */ - getABIDecodedReturnData(returnData: string): string { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('ecrecoverFn(bytes32,uint8,bytes32,bytes32)'); - // tslint:disable boolean-naming - const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); - return abiDecodedReturnData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('ecrecoverFn(bytes32,uint8,bytes32,bytes32)'); - return abiEncoder.getSelector(); - }, - }; - public emitSimpleEvent = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - const self = (this as any) as AbiGenDummyContract; - const encodedData = self._strictEncodeArguments('emitSimpleEvent()', []); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.emitSimpleEvent.callAsync(txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - const self = (this as any) as AbiGenDummyContract; - const txHashPromise = self.emitSimpleEvent.sendTransactionAsync(txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync(txData?: Partial | undefined): Promise { - const self = (this as any) as AbiGenDummyContract; - const encodedData = self._strictEncodeArguments('emitSimpleEvent()', []); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as AbiGenDummyContract; - const encodedData = self._strictEncodeArguments('emitSimpleEvent()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('emitSimpleEvent()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(): string { - const self = (this as any) as AbiGenDummyContract; - const abiEncodedTransactionData = self._strictEncodeArguments('emitSimpleEvent()', []); - return abiEncodedTransactionData; - }, - /** - * Decode the ABI-encoded transaction data into its input arguments - * @param callData The ABI-encoded transaction data - * @returns An array representing the input arguments in order. Keynames of nested structs are preserved. - */ - getABIDecodedTransactionData(callData: string): void { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('emitSimpleEvent()'); - // tslint:disable boolean-naming - const abiDecodedCallData = abiEncoder.strictDecode(callData); - return abiDecodedCallData; - }, - /** - * Decode the ABI-encoded return data from a transaction - * @param returnData the data returned after transaction execution - * @returns An array representing the output results in order. Keynames of nested structs are preserved. - */ - getABIDecodedReturnData(returnData: string): void { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('emitSimpleEvent()'); - // tslint:disable boolean-naming - const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); - return abiDecodedReturnData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('emitSimpleEvent()'); - return abiEncoder.getSelector(); - }, - }; - public methodReturningArrayOfStructs = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync( - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise> { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as AbiGenDummyContract; - const encodedData = self._strictEncodeArguments('methodReturningArrayOfStructs()', []); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('methodReturningArrayOfStructs()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue< - Array<{ someBytes: string; anInteger: number; aDynamicArrayOfBytes: string[]; aString: string }> - >(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(): string { - const self = (this as any) as AbiGenDummyContract; - const abiEncodedTransactionData = self._strictEncodeArguments('methodReturningArrayOfStructs()', []); - return abiEncodedTransactionData; - }, - /** - * Decode the ABI-encoded transaction data into its input arguments - * @param callData The ABI-encoded transaction data - * @returns An array representing the input arguments in order. Keynames of nested structs are preserved. - */ - getABIDecodedTransactionData(callData: string): void { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('methodReturningArrayOfStructs()'); - // tslint:disable boolean-naming - const abiDecodedCallData = abiEncoder.strictDecode(callData); - return abiDecodedCallData; - }, - /** - * Decode the ABI-encoded return data from a transaction - * @param returnData the data returned after transaction execution - * @returns An array representing the output results in order. Keynames of nested structs are preserved. - */ - getABIDecodedReturnData( - returnData: string, - ): Array<{ someBytes: string; anInteger: number; aDynamicArrayOfBytes: string[]; aString: string }> { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('methodReturningArrayOfStructs()'); - // tslint:disable boolean-naming - const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue< - Array<{ someBytes: string; anInteger: number; aDynamicArrayOfBytes: string[]; aString: string }> - >(returnData); - return abiDecodedReturnData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('methodReturningArrayOfStructs()'); - return abiEncoder.getSelector(); - }, - }; - public methodReturningMultipleValues = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise<[BigNumber, string]> { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as AbiGenDummyContract; - const encodedData = self._strictEncodeArguments('methodReturningMultipleValues()', []); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('methodReturningMultipleValues()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue<[BigNumber, string]>(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(): string { - const self = (this as any) as AbiGenDummyContract; - const abiEncodedTransactionData = self._strictEncodeArguments('methodReturningMultipleValues()', []); - return abiEncodedTransactionData; - }, - /** - * Decode the ABI-encoded transaction data into its input arguments - * @param callData The ABI-encoded transaction data - * @returns An array representing the input arguments in order. Keynames of nested structs are preserved. - */ - getABIDecodedTransactionData(callData: string): void { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('methodReturningMultipleValues()'); - // tslint:disable boolean-naming - const abiDecodedCallData = abiEncoder.strictDecode(callData); - return abiDecodedCallData; - }, - /** - * Decode the ABI-encoded return data from a transaction - * @param returnData the data returned after transaction execution - * @returns An array representing the output results in order. Keynames of nested structs are preserved. - */ - getABIDecodedReturnData(returnData: string): [BigNumber, string] { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('methodReturningMultipleValues()'); - // tslint:disable boolean-naming - const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<[BigNumber, string]>(returnData); - return abiDecodedReturnData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('methodReturningMultipleValues()'); - return abiEncoder.getSelector(); - }, - }; - public methodUsingNestedStructWithInnerStructNotUsedElsewhere = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync( - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise<{ innerStruct: { aField: BigNumber } }> { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as AbiGenDummyContract; - const encodedData = self._strictEncodeArguments( - 'methodUsingNestedStructWithInnerStructNotUsedElsewhere()', - [], - ); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('methodUsingNestedStructWithInnerStructNotUsedElsewhere()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue<{ innerStruct: { aField: BigNumber } }>(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(): string { - const self = (this as any) as AbiGenDummyContract; - const abiEncodedTransactionData = self._strictEncodeArguments( - 'methodUsingNestedStructWithInnerStructNotUsedElsewhere()', - [], - ); - return abiEncodedTransactionData; - }, - /** - * Decode the ABI-encoded transaction data into its input arguments - * @param callData The ABI-encoded transaction data - * @returns An array representing the input arguments in order. Keynames of nested structs are preserved. - */ - getABIDecodedTransactionData(callData: string): void { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('methodUsingNestedStructWithInnerStructNotUsedElsewhere()'); - // tslint:disable boolean-naming - const abiDecodedCallData = abiEncoder.strictDecode(callData); - return abiDecodedCallData; - }, - /** - * Decode the ABI-encoded return data from a transaction - * @param returnData the data returned after transaction execution - * @returns An array representing the output results in order. Keynames of nested structs are preserved. - */ - getABIDecodedReturnData(returnData: string): { innerStruct: { aField: BigNumber } } { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('methodUsingNestedStructWithInnerStructNotUsedElsewhere()'); - // tslint:disable boolean-naming - const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<{ innerStruct: { aField: BigNumber } }>( - returnData, - ); - return abiDecodedReturnData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('methodUsingNestedStructWithInnerStructNotUsedElsewhere()'); - return abiEncoder.getSelector(); - }, - }; - /** - * Tests decoding when the input and output are complex and have more than one argument. - */ - public multiInputMultiOutput = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync( - index_0: BigNumber, - index_1: string, - index_2: string, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise<[string, string, string]> { - assert.isBigNumber('index_0', index_0); - assert.isString('index_1', index_1); - assert.isString('index_2', index_2); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as AbiGenDummyContract; - const encodedData = self._strictEncodeArguments('multiInputMultiOutput(uint256,bytes,string)', [ - index_0, - index_1, - index_2, - ]); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('multiInputMultiOutput(uint256,bytes,string)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue<[string, string, string]>(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(index_0: BigNumber, index_1: string, index_2: string): string { - assert.isBigNumber('index_0', index_0); - assert.isString('index_1', index_1); - assert.isString('index_2', index_2); - const self = (this as any) as AbiGenDummyContract; - const abiEncodedTransactionData = self._strictEncodeArguments( - 'multiInputMultiOutput(uint256,bytes,string)', - [index_0, index_1, index_2], - ); - return abiEncodedTransactionData; - }, - /** - * Decode the ABI-encoded transaction data into its input arguments - * @param callData The ABI-encoded transaction data - * @returns An array representing the input arguments in order. Keynames of nested structs are preserved. - */ - getABIDecodedTransactionData(callData: string): [BigNumber, string, string] { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('multiInputMultiOutput(uint256,bytes,string)'); - // tslint:disable boolean-naming - const abiDecodedCallData = abiEncoder.strictDecode<[BigNumber, string, string]>(callData); - return abiDecodedCallData; - }, - /** - * Decode the ABI-encoded return data from a transaction - * @param returnData the data returned after transaction execution - * @returns An array representing the output results in order. Keynames of nested structs are preserved. - */ - getABIDecodedReturnData(returnData: string): [string, string, string] { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('multiInputMultiOutput(uint256,bytes,string)'); - // tslint:disable boolean-naming - const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<[string, string, string]>(returnData); - return abiDecodedReturnData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('multiInputMultiOutput(uint256,bytes,string)'); - return abiEncoder.getSelector(); - }, - }; - public nestedStructInput = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync( - n: { - innerStruct: { - someBytes: string; - anInteger: number | BigNumber; - aDynamicArrayOfBytes: string[]; - aString: string; - }; - description: string; - }, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as AbiGenDummyContract; - const encodedData = self._strictEncodeArguments( - 'nestedStructInput(((bytes,uint32,bytes[],string),string))', - [n], - ); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('nestedStructInput(((bytes,uint32,bytes[],string),string))'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(n: { - innerStruct: { - someBytes: string; - anInteger: number | BigNumber; - aDynamicArrayOfBytes: string[]; - aString: string; - }; - description: string; - }): string { - const self = (this as any) as AbiGenDummyContract; - const abiEncodedTransactionData = self._strictEncodeArguments( - 'nestedStructInput(((bytes,uint32,bytes[],string),string))', - [n], - ); - return abiEncodedTransactionData; - }, - /** - * Decode the ABI-encoded transaction data into its input arguments - * @param callData The ABI-encoded transaction data - * @returns An array representing the input arguments in order. Keynames of nested structs are preserved. - */ - getABIDecodedTransactionData( - callData: string, - ): [ - { - innerStruct: { someBytes: string; anInteger: number; aDynamicArrayOfBytes: string[]; aString: string }; - description: string; - } - ] { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('nestedStructInput(((bytes,uint32,bytes[],string),string))'); - // tslint:disable boolean-naming - const abiDecodedCallData = abiEncoder.strictDecode< - [ - { - innerStruct: { - someBytes: string; - anInteger: number; - aDynamicArrayOfBytes: string[]; - aString: string; - }; - description: string; - } - ] - >(callData); - return abiDecodedCallData; - }, - /** - * Decode the ABI-encoded return data from a transaction - * @param returnData the data returned after transaction execution - * @returns An array representing the output results in order. Keynames of nested structs are preserved. - */ - getABIDecodedReturnData(returnData: string): void { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('nestedStructInput(((bytes,uint32,bytes[],string),string))'); - // tslint:disable boolean-naming - const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); - return abiDecodedReturnData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('nestedStructInput(((bytes,uint32,bytes[],string),string))'); - return abiEncoder.getSelector(); - }, - }; - public nestedStructOutput = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync( - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise<{ - innerStruct: { someBytes: string; anInteger: number; aDynamicArrayOfBytes: string[]; aString: string }; - description: string; - }> { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as AbiGenDummyContract; - const encodedData = self._strictEncodeArguments('nestedStructOutput()', []); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('nestedStructOutput()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue<{ - innerStruct: { someBytes: string; anInteger: number; aDynamicArrayOfBytes: string[]; aString: string }; - description: string; - }>(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(): string { - const self = (this as any) as AbiGenDummyContract; - const abiEncodedTransactionData = self._strictEncodeArguments('nestedStructOutput()', []); - return abiEncodedTransactionData; - }, - /** - * Decode the ABI-encoded transaction data into its input arguments - * @param callData The ABI-encoded transaction data - * @returns An array representing the input arguments in order. Keynames of nested structs are preserved. - */ - getABIDecodedTransactionData(callData: string): void { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('nestedStructOutput()'); - // tslint:disable boolean-naming - const abiDecodedCallData = abiEncoder.strictDecode(callData); - return abiDecodedCallData; - }, - /** - * Decode the ABI-encoded return data from a transaction - * @param returnData the data returned after transaction execution - * @returns An array representing the output results in order. Keynames of nested structs are preserved. - */ - getABIDecodedReturnData( - returnData: string, - ): { - innerStruct: { someBytes: string; anInteger: number; aDynamicArrayOfBytes: string[]; aString: string }; - description: string; - } { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('nestedStructOutput()'); - // tslint:disable boolean-naming - const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<{ - innerStruct: { someBytes: string; anInteger: number; aDynamicArrayOfBytes: string[]; aString: string }; - description: string; - }>(returnData); - return abiDecodedReturnData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('nestedStructOutput()'); - return abiEncoder.getSelector(); - }, - }; - /** - * Tests decoding when both input and output are empty. - */ - public noInputNoOutput = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as AbiGenDummyContract; - const encodedData = self._strictEncodeArguments('noInputNoOutput()', []); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('noInputNoOutput()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(): string { - const self = (this as any) as AbiGenDummyContract; - const abiEncodedTransactionData = self._strictEncodeArguments('noInputNoOutput()', []); - return abiEncodedTransactionData; - }, - /** - * Decode the ABI-encoded transaction data into its input arguments - * @param callData The ABI-encoded transaction data - * @returns An array representing the input arguments in order. Keynames of nested structs are preserved. - */ - getABIDecodedTransactionData(callData: string): void { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('noInputNoOutput()'); - // tslint:disable boolean-naming - const abiDecodedCallData = abiEncoder.strictDecode(callData); - return abiDecodedCallData; - }, - /** - * Decode the ABI-encoded return data from a transaction - * @param returnData the data returned after transaction execution - * @returns An array representing the output results in order. Keynames of nested structs are preserved. - */ - getABIDecodedReturnData(returnData: string): void { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('noInputNoOutput()'); - // tslint:disable boolean-naming - const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); - return abiDecodedReturnData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('noInputNoOutput()'); - return abiEncoder.getSelector(); - }, - }; - /** - * Tests decoding when input is empty and output is non-empty. - */ - public noInputSimpleOutput = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as AbiGenDummyContract; - const encodedData = self._strictEncodeArguments('noInputSimpleOutput()', []); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('noInputSimpleOutput()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(): string { - const self = (this as any) as AbiGenDummyContract; - const abiEncodedTransactionData = self._strictEncodeArguments('noInputSimpleOutput()', []); - return abiEncodedTransactionData; - }, - /** - * Decode the ABI-encoded transaction data into its input arguments - * @param callData The ABI-encoded transaction data - * @returns An array representing the input arguments in order. Keynames of nested structs are preserved. - */ - getABIDecodedTransactionData(callData: string): void { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('noInputSimpleOutput()'); - // tslint:disable boolean-naming - const abiDecodedCallData = abiEncoder.strictDecode(callData); - return abiDecodedCallData; - }, - /** - * Decode the ABI-encoded return data from a transaction - * @param returnData the data returned after transaction execution - * @returns An array representing the output results in order. Keynames of nested structs are preserved. - */ - getABIDecodedReturnData(returnData: string): BigNumber { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('noInputSimpleOutput()'); - // tslint:disable boolean-naming - const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); - return abiDecodedReturnData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('noInputSimpleOutput()'); - return abiEncoder.getSelector(); - }, - }; - public nonPureMethod = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - const self = (this as any) as AbiGenDummyContract; - const encodedData = self._strictEncodeArguments('nonPureMethod()', []); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.nonPureMethod.callAsync(txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - const self = (this as any) as AbiGenDummyContract; - const txHashPromise = self.nonPureMethod.sendTransactionAsync(txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync(txData?: Partial | undefined): Promise { - const self = (this as any) as AbiGenDummyContract; - const encodedData = self._strictEncodeArguments('nonPureMethod()', []); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as AbiGenDummyContract; - const encodedData = self._strictEncodeArguments('nonPureMethod()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('nonPureMethod()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(): string { - const self = (this as any) as AbiGenDummyContract; - const abiEncodedTransactionData = self._strictEncodeArguments('nonPureMethod()', []); - return abiEncodedTransactionData; - }, - /** - * Decode the ABI-encoded transaction data into its input arguments - * @param callData The ABI-encoded transaction data - * @returns An array representing the input arguments in order. Keynames of nested structs are preserved. - */ - getABIDecodedTransactionData(callData: string): void { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('nonPureMethod()'); - // tslint:disable boolean-naming - const abiDecodedCallData = abiEncoder.strictDecode(callData); - return abiDecodedCallData; - }, - /** - * Decode the ABI-encoded return data from a transaction - * @param returnData the data returned after transaction execution - * @returns An array representing the output results in order. Keynames of nested structs are preserved. - */ - getABIDecodedReturnData(returnData: string): BigNumber { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('nonPureMethod()'); - // tslint:disable boolean-naming - const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); - return abiDecodedReturnData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('nonPureMethod()'); - return abiEncoder.getSelector(); - }, - }; - public nonPureMethodThatReturnsNothing = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - const self = (this as any) as AbiGenDummyContract; - const encodedData = self._strictEncodeArguments('nonPureMethodThatReturnsNothing()', []); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.nonPureMethodThatReturnsNothing.callAsync(txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - const self = (this as any) as AbiGenDummyContract; - const txHashPromise = self.nonPureMethodThatReturnsNothing.sendTransactionAsync(txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync(txData?: Partial | undefined): Promise { - const self = (this as any) as AbiGenDummyContract; - const encodedData = self._strictEncodeArguments('nonPureMethodThatReturnsNothing()', []); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as AbiGenDummyContract; - const encodedData = self._strictEncodeArguments('nonPureMethodThatReturnsNothing()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('nonPureMethodThatReturnsNothing()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(): string { - const self = (this as any) as AbiGenDummyContract; - const abiEncodedTransactionData = self._strictEncodeArguments('nonPureMethodThatReturnsNothing()', []); - return abiEncodedTransactionData; - }, - /** - * Decode the ABI-encoded transaction data into its input arguments - * @param callData The ABI-encoded transaction data - * @returns An array representing the input arguments in order. Keynames of nested structs are preserved. - */ - getABIDecodedTransactionData(callData: string): void { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('nonPureMethodThatReturnsNothing()'); - // tslint:disable boolean-naming - const abiDecodedCallData = abiEncoder.strictDecode(callData); - return abiDecodedCallData; - }, - /** - * Decode the ABI-encoded return data from a transaction - * @param returnData the data returned after transaction execution - * @returns An array representing the output results in order. Keynames of nested structs are preserved. - */ - getABIDecodedReturnData(returnData: string): void { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('nonPureMethodThatReturnsNothing()'); - // tslint:disable boolean-naming - const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); - return abiDecodedReturnData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('nonPureMethodThatReturnsNothing()'); - return abiEncoder.getSelector(); - }, - }; - public overloadedMethod2 = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(a: string, callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.isString('a', a); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as AbiGenDummyContract; - const encodedData = self._strictEncodeArguments('overloadedMethod(string)', [a]); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('overloadedMethod(string)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(a: string): string { - assert.isString('a', a); - const self = (this as any) as AbiGenDummyContract; - const abiEncodedTransactionData = self._strictEncodeArguments('overloadedMethod(string)', [a]); - return abiEncodedTransactionData; - }, - /** - * Decode the ABI-encoded transaction data into its input arguments - * @param callData The ABI-encoded transaction data - * @returns An array representing the input arguments in order. Keynames of nested structs are preserved. - */ - getABIDecodedTransactionData(callData: string): [string] { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('overloadedMethod(string)'); - // tslint:disable boolean-naming - const abiDecodedCallData = abiEncoder.strictDecode<[string]>(callData); - return abiDecodedCallData; - }, - /** - * Decode the ABI-encoded return data from a transaction - * @param returnData the data returned after transaction execution - * @returns An array representing the output results in order. Keynames of nested structs are preserved. - */ - getABIDecodedReturnData(returnData: string): void { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('overloadedMethod(string)'); - // tslint:disable boolean-naming - const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); - return abiDecodedReturnData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('overloadedMethod(string)'); - return abiEncoder.getSelector(); - }, - }; - public overloadedMethod1 = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(a: BigNumber, callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.isBigNumber('a', a); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as AbiGenDummyContract; - const encodedData = self._strictEncodeArguments('overloadedMethod(int256)', [a]); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('overloadedMethod(int256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(a: BigNumber): string { - assert.isBigNumber('a', a); - const self = (this as any) as AbiGenDummyContract; - const abiEncodedTransactionData = self._strictEncodeArguments('overloadedMethod(int256)', [a]); - return abiEncodedTransactionData; - }, - /** - * Decode the ABI-encoded transaction data into its input arguments - * @param callData The ABI-encoded transaction data - * @returns An array representing the input arguments in order. Keynames of nested structs are preserved. - */ - getABIDecodedTransactionData(callData: string): [BigNumber] { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('overloadedMethod(int256)'); - // tslint:disable boolean-naming - const abiDecodedCallData = abiEncoder.strictDecode<[BigNumber]>(callData); - return abiDecodedCallData; - }, - /** - * Decode the ABI-encoded return data from a transaction - * @param returnData the data returned after transaction execution - * @returns An array representing the output results in order. Keynames of nested structs are preserved. - */ - getABIDecodedReturnData(returnData: string): void { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('overloadedMethod(int256)'); - // tslint:disable boolean-naming - const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); - return abiDecodedReturnData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('overloadedMethod(int256)'); - return abiEncoder.getSelector(); - }, - }; - public pureFunctionWithConstant = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as AbiGenDummyContract; - const encodedData = self._strictEncodeArguments('pureFunctionWithConstant()', []); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('pureFunctionWithConstant()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(): string { - const self = (this as any) as AbiGenDummyContract; - const abiEncodedTransactionData = self._strictEncodeArguments('pureFunctionWithConstant()', []); - return abiEncodedTransactionData; - }, - /** - * Decode the ABI-encoded transaction data into its input arguments - * @param callData The ABI-encoded transaction data - * @returns An array representing the input arguments in order. Keynames of nested structs are preserved. - */ - getABIDecodedTransactionData(callData: string): void { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('pureFunctionWithConstant()'); - // tslint:disable boolean-naming - const abiDecodedCallData = abiEncoder.strictDecode(callData); - return abiDecodedCallData; - }, - /** - * Decode the ABI-encoded return data from a transaction - * @param returnData the data returned after transaction execution - * @returns An array representing the output results in order. Keynames of nested structs are preserved. - */ - getABIDecodedReturnData(returnData: string): BigNumber { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('pureFunctionWithConstant()'); - // tslint:disable boolean-naming - const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); - return abiDecodedReturnData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('pureFunctionWithConstant()'); - return abiEncoder.getSelector(); - }, - }; - public requireWithConstant = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as AbiGenDummyContract; - const encodedData = self._strictEncodeArguments('requireWithConstant()', []); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('requireWithConstant()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(): string { - const self = (this as any) as AbiGenDummyContract; - const abiEncodedTransactionData = self._strictEncodeArguments('requireWithConstant()', []); - return abiEncodedTransactionData; - }, - /** - * Decode the ABI-encoded transaction data into its input arguments - * @param callData The ABI-encoded transaction data - * @returns An array representing the input arguments in order. Keynames of nested structs are preserved. - */ - getABIDecodedTransactionData(callData: string): void { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('requireWithConstant()'); - // tslint:disable boolean-naming - const abiDecodedCallData = abiEncoder.strictDecode(callData); - return abiDecodedCallData; - }, - /** - * Decode the ABI-encoded return data from a transaction - * @param returnData the data returned after transaction execution - * @returns An array representing the output results in order. Keynames of nested structs are preserved. - */ - getABIDecodedReturnData(returnData: string): void { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('requireWithConstant()'); - // tslint:disable boolean-naming - const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); - return abiDecodedReturnData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('requireWithConstant()'); - return abiEncoder.getSelector(); - }, - }; - public revertWithConstant = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as AbiGenDummyContract; - const encodedData = self._strictEncodeArguments('revertWithConstant()', []); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('revertWithConstant()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(): string { - const self = (this as any) as AbiGenDummyContract; - const abiEncodedTransactionData = self._strictEncodeArguments('revertWithConstant()', []); - return abiEncodedTransactionData; - }, - /** - * Decode the ABI-encoded transaction data into its input arguments - * @param callData The ABI-encoded transaction data - * @returns An array representing the input arguments in order. Keynames of nested structs are preserved. - */ - getABIDecodedTransactionData(callData: string): void { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('revertWithConstant()'); - // tslint:disable boolean-naming - const abiDecodedCallData = abiEncoder.strictDecode(callData); - return abiDecodedCallData; - }, - /** - * Decode the ABI-encoded return data from a transaction - * @param returnData the data returned after transaction execution - * @returns An array representing the output results in order. Keynames of nested structs are preserved. - */ - getABIDecodedReturnData(returnData: string): void { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('revertWithConstant()'); - // tslint:disable boolean-naming - const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); - return abiDecodedReturnData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('revertWithConstant()'); - return abiEncoder.getSelector(); - }, - }; - /** - * Tests decoding when input is not empty but output is empty. - */ - public simpleInputNoOutput = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync( - index_0: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isBigNumber('index_0', index_0); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as AbiGenDummyContract; - const encodedData = self._strictEncodeArguments('simpleInputNoOutput(uint256)', [index_0]); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('simpleInputNoOutput(uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(index_0: BigNumber): string { - assert.isBigNumber('index_0', index_0); - const self = (this as any) as AbiGenDummyContract; - const abiEncodedTransactionData = self._strictEncodeArguments('simpleInputNoOutput(uint256)', [index_0]); - return abiEncodedTransactionData; - }, - /** - * Decode the ABI-encoded transaction data into its input arguments - * @param callData The ABI-encoded transaction data - * @returns An array representing the input arguments in order. Keynames of nested structs are preserved. - */ - getABIDecodedTransactionData(callData: string): [BigNumber] { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('simpleInputNoOutput(uint256)'); - // tslint:disable boolean-naming - const abiDecodedCallData = abiEncoder.strictDecode<[BigNumber]>(callData); - return abiDecodedCallData; - }, - /** - * Decode the ABI-encoded return data from a transaction - * @param returnData the data returned after transaction execution - * @returns An array representing the output results in order. Keynames of nested structs are preserved. - */ - getABIDecodedReturnData(returnData: string): void { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('simpleInputNoOutput(uint256)'); - // tslint:disable boolean-naming - const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); - return abiDecodedReturnData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('simpleInputNoOutput(uint256)'); - return abiEncoder.getSelector(); - }, - }; - /** - * Tests decoding when both input and output are non-empty. - */ - public simpleInputSimpleOutput = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync( - index_0: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isBigNumber('index_0', index_0); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as AbiGenDummyContract; - const encodedData = self._strictEncodeArguments('simpleInputSimpleOutput(uint256)', [index_0]); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('simpleInputSimpleOutput(uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(index_0: BigNumber): string { - assert.isBigNumber('index_0', index_0); - const self = (this as any) as AbiGenDummyContract; - const abiEncodedTransactionData = self._strictEncodeArguments('simpleInputSimpleOutput(uint256)', [ - index_0, - ]); - return abiEncodedTransactionData; - }, - /** - * Decode the ABI-encoded transaction data into its input arguments - * @param callData The ABI-encoded transaction data - * @returns An array representing the input arguments in order. Keynames of nested structs are preserved. - */ - getABIDecodedTransactionData(callData: string): BigNumber { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('simpleInputSimpleOutput(uint256)'); - // tslint:disable boolean-naming - const abiDecodedCallData = abiEncoder.strictDecode(callData); - return abiDecodedCallData; - }, - /** - * Decode the ABI-encoded return data from a transaction - * @param returnData the data returned after transaction execution - * @returns An array representing the output results in order. Keynames of nested structs are preserved. - */ - getABIDecodedReturnData(returnData: string): BigNumber { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('simpleInputSimpleOutput(uint256)'); - // tslint:disable boolean-naming - const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); - return abiDecodedReturnData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('simpleInputSimpleOutput(uint256)'); - return abiEncoder.getSelector(); - }, - }; - public simplePureFunction = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as AbiGenDummyContract; - const encodedData = self._strictEncodeArguments('simplePureFunction()', []); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('simplePureFunction()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(): string { - const self = (this as any) as AbiGenDummyContract; - const abiEncodedTransactionData = self._strictEncodeArguments('simplePureFunction()', []); - return abiEncodedTransactionData; - }, - /** - * Decode the ABI-encoded transaction data into its input arguments - * @param callData The ABI-encoded transaction data - * @returns An array representing the input arguments in order. Keynames of nested structs are preserved. - */ - getABIDecodedTransactionData(callData: string): void { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('simplePureFunction()'); - // tslint:disable boolean-naming - const abiDecodedCallData = abiEncoder.strictDecode(callData); - return abiDecodedCallData; - }, - /** - * Decode the ABI-encoded return data from a transaction - * @param returnData the data returned after transaction execution - * @returns An array representing the output results in order. Keynames of nested structs are preserved. - */ - getABIDecodedReturnData(returnData: string): BigNumber { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('simplePureFunction()'); - // tslint:disable boolean-naming - const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); - return abiDecodedReturnData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('simplePureFunction()'); - return abiEncoder.getSelector(); - }, - }; - public simplePureFunctionWithInput = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(x: BigNumber, callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.isBigNumber('x', x); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as AbiGenDummyContract; - const encodedData = self._strictEncodeArguments('simplePureFunctionWithInput(uint256)', [x]); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('simplePureFunctionWithInput(uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(x: BigNumber): string { - assert.isBigNumber('x', x); - const self = (this as any) as AbiGenDummyContract; - const abiEncodedTransactionData = self._strictEncodeArguments('simplePureFunctionWithInput(uint256)', [x]); - return abiEncodedTransactionData; - }, - /** - * Decode the ABI-encoded transaction data into its input arguments - * @param callData The ABI-encoded transaction data - * @returns An array representing the input arguments in order. Keynames of nested structs are preserved. - */ - getABIDecodedTransactionData(callData: string): BigNumber { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('simplePureFunctionWithInput(uint256)'); - // tslint:disable boolean-naming - const abiDecodedCallData = abiEncoder.strictDecode(callData); - return abiDecodedCallData; - }, - /** - * Decode the ABI-encoded return data from a transaction - * @param returnData the data returned after transaction execution - * @returns An array representing the output results in order. Keynames of nested structs are preserved. - */ - getABIDecodedReturnData(returnData: string): BigNumber { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('simplePureFunctionWithInput(uint256)'); - // tslint:disable boolean-naming - const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); - return abiDecodedReturnData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('simplePureFunctionWithInput(uint256)'); - return abiEncoder.getSelector(); - }, - }; - public simpleRequire = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as AbiGenDummyContract; - const encodedData = self._strictEncodeArguments('simpleRequire()', []); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('simpleRequire()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(): string { - const self = (this as any) as AbiGenDummyContract; - const abiEncodedTransactionData = self._strictEncodeArguments('simpleRequire()', []); - return abiEncodedTransactionData; - }, - /** - * Decode the ABI-encoded transaction data into its input arguments - * @param callData The ABI-encoded transaction data - * @returns An array representing the input arguments in order. Keynames of nested structs are preserved. - */ - getABIDecodedTransactionData(callData: string): void { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('simpleRequire()'); - // tslint:disable boolean-naming - const abiDecodedCallData = abiEncoder.strictDecode(callData); - return abiDecodedCallData; - }, - /** - * Decode the ABI-encoded return data from a transaction - * @param returnData the data returned after transaction execution - * @returns An array representing the output results in order. Keynames of nested structs are preserved. - */ - getABIDecodedReturnData(returnData: string): void { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('simpleRequire()'); - // tslint:disable boolean-naming - const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); - return abiDecodedReturnData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('simpleRequire()'); - return abiEncoder.getSelector(); - }, - }; - public simpleRevert = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as AbiGenDummyContract; - const encodedData = self._strictEncodeArguments('simpleRevert()', []); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('simpleRevert()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(): string { - const self = (this as any) as AbiGenDummyContract; - const abiEncodedTransactionData = self._strictEncodeArguments('simpleRevert()', []); - return abiEncodedTransactionData; - }, - /** - * Decode the ABI-encoded transaction data into its input arguments - * @param callData The ABI-encoded transaction data - * @returns An array representing the input arguments in order. Keynames of nested structs are preserved. - */ - getABIDecodedTransactionData(callData: string): void { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('simpleRevert()'); - // tslint:disable boolean-naming - const abiDecodedCallData = abiEncoder.strictDecode(callData); - return abiDecodedCallData; - }, - /** - * Decode the ABI-encoded return data from a transaction - * @param returnData the data returned after transaction execution - * @returns An array representing the output results in order. Keynames of nested structs are preserved. - */ - getABIDecodedReturnData(returnData: string): void { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('simpleRevert()'); - // tslint:disable boolean-naming - const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); - return abiDecodedReturnData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('simpleRevert()'); - return abiEncoder.getSelector(); - }, - }; - public structInput = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync( - s: { someBytes: string; anInteger: number | BigNumber; aDynamicArrayOfBytes: string[]; aString: string }, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as AbiGenDummyContract; - const encodedData = self._strictEncodeArguments('structInput((bytes,uint32,bytes[],string))', [s]); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('structInput((bytes,uint32,bytes[],string))'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(s: { - someBytes: string; - anInteger: number | BigNumber; - aDynamicArrayOfBytes: string[]; - aString: string; - }): string { - const self = (this as any) as AbiGenDummyContract; - const abiEncodedTransactionData = self._strictEncodeArguments( - 'structInput((bytes,uint32,bytes[],string))', - [s], - ); - return abiEncodedTransactionData; - }, - /** - * Decode the ABI-encoded transaction data into its input arguments - * @param callData The ABI-encoded transaction data - * @returns An array representing the input arguments in order. Keynames of nested structs are preserved. - */ - getABIDecodedTransactionData( - callData: string, - ): [{ someBytes: string; anInteger: number; aDynamicArrayOfBytes: string[]; aString: string }] { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('structInput((bytes,uint32,bytes[],string))'); - // tslint:disable boolean-naming - const abiDecodedCallData = abiEncoder.strictDecode< - [{ someBytes: string; anInteger: number; aDynamicArrayOfBytes: string[]; aString: string }] - >(callData); - return abiDecodedCallData; - }, - /** - * Decode the ABI-encoded return data from a transaction - * @param returnData the data returned after transaction execution - * @returns An array representing the output results in order. Keynames of nested structs are preserved. - */ - getABIDecodedReturnData(returnData: string): void { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('structInput((bytes,uint32,bytes[],string))'); - // tslint:disable boolean-naming - const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); - return abiDecodedReturnData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('structInput((bytes,uint32,bytes[],string))'); - return abiEncoder.getSelector(); - }, - }; - /** - * a method that returns a struct - */ - public structOutput = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @returns a Struct struct - */ - async callAsync( - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise<{ someBytes: string; anInteger: number; aDynamicArrayOfBytes: string[]; aString: string }> { - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as AbiGenDummyContract; - const encodedData = self._strictEncodeArguments('structOutput()', []); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('structOutput()'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue<{ - someBytes: string; - anInteger: number; - aDynamicArrayOfBytes: string[]; - aString: string; - }>(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(): string { - const self = (this as any) as AbiGenDummyContract; - const abiEncodedTransactionData = self._strictEncodeArguments('structOutput()', []); - return abiEncodedTransactionData; - }, - /** - * Decode the ABI-encoded transaction data into its input arguments - * @param callData The ABI-encoded transaction data - * @returns An array representing the input arguments in order. Keynames of nested structs are preserved. - */ - getABIDecodedTransactionData(callData: string): void { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('structOutput()'); - // tslint:disable boolean-naming - const abiDecodedCallData = abiEncoder.strictDecode(callData); - return abiDecodedCallData; - }, - /** - * Decode the ABI-encoded return data from a transaction - * @param returnData the data returned after transaction execution - * @returns An array representing the output results in order. Keynames of nested structs are preserved. - */ - getABIDecodedReturnData( - returnData: string, - ): { someBytes: string; anInteger: number; aDynamicArrayOfBytes: string[]; aString: string } { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('structOutput()'); - // tslint:disable boolean-naming - const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<{ - someBytes: string; - anInteger: number; - aDynamicArrayOfBytes: string[]; - aString: string; - }>(returnData); - return abiDecodedReturnData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('structOutput()'); - return abiEncoder.getSelector(); - }, - }; - public withAddressInput = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync( - x: string, - a: BigNumber, - b: BigNumber, - y: string, - c: BigNumber, - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isString('x', x); - assert.isBigNumber('a', a); - assert.isBigNumber('b', b); - assert.isString('y', y); - assert.isBigNumber('c', c); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as AbiGenDummyContract; - const encodedData = self._strictEncodeArguments( - 'withAddressInput(address,uint256,uint256,address,uint256)', - [x.toLowerCase(), a, b, y.toLowerCase(), c], - ); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('withAddressInput(address,uint256,uint256,address,uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(x: string, a: BigNumber, b: BigNumber, y: string, c: BigNumber): string { - assert.isString('x', x); - assert.isBigNumber('a', a); - assert.isBigNumber('b', b); - assert.isString('y', y); - assert.isBigNumber('c', c); - const self = (this as any) as AbiGenDummyContract; - const abiEncodedTransactionData = self._strictEncodeArguments( - 'withAddressInput(address,uint256,uint256,address,uint256)', - [x.toLowerCase(), a, b, y.toLowerCase(), c], - ); - return abiEncodedTransactionData; - }, - /** - * Decode the ABI-encoded transaction data into its input arguments - * @param callData The ABI-encoded transaction data - * @returns An array representing the input arguments in order. Keynames of nested structs are preserved. - */ - getABIDecodedTransactionData(callData: string): string { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('withAddressInput(address,uint256,uint256,address,uint256)'); - // tslint:disable boolean-naming - const abiDecodedCallData = abiEncoder.strictDecode(callData); - return abiDecodedCallData; - }, - /** - * Decode the ABI-encoded return data from a transaction - * @param returnData the data returned after transaction execution - * @returns An array representing the output results in order. Keynames of nested structs are preserved. - */ - getABIDecodedReturnData(returnData: string): string { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('withAddressInput(address,uint256,uint256,address,uint256)'); - // tslint:disable boolean-naming - const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); - return abiDecodedReturnData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('withAddressInput(address,uint256,uint256,address,uint256)'); - return abiEncoder.getSelector(); - }, - }; - public withdraw = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - wad: BigNumber, - txData?: Partial | undefined, - opts: SendTransactionOpts = { shouldValidate: true }, - ): Promise { - assert.isBigNumber('wad', wad); - const self = (this as any) as AbiGenDummyContract; - const encodedData = self._strictEncodeArguments('withdraw(uint256)', [wad]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - if (opts.shouldValidate !== false) { - await self.withdraw.callAsync(wad, txDataWithDefaults); - } - - const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); - return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - wad: BigNumber, - txData?: Partial, - opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, - ): PromiseWithTransactionHash { - assert.isBigNumber('wad', wad); - const self = (this as any) as AbiGenDummyContract; - const txHashPromise = self.withdraw.sendTransactionAsync(wad, txData, opts); - return new PromiseWithTransactionHash( - txHashPromise, - (async (): Promise => { - // When the transaction hash resolves, wait for it to be mined. - return self._web3Wrapper.awaitTransactionSuccessAsync( - await txHashPromise, - opts.pollingIntervalMs, - opts.timeoutMs, - ); - })(), - ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync(wad: BigNumber, txData?: Partial | undefined): Promise { - assert.isBigNumber('wad', wad); - const self = (this as any) as AbiGenDummyContract; - const encodedData = self._strictEncodeArguments('withdraw(uint256)', [wad]); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...txData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; - }, - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(wad: BigNumber, callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.isBigNumber('wad', wad); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as AbiGenDummyContract; - const encodedData = self._strictEncodeArguments('withdraw(uint256)', [wad]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('withdraw(uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(wad: BigNumber): string { - assert.isBigNumber('wad', wad); - const self = (this as any) as AbiGenDummyContract; - const abiEncodedTransactionData = self._strictEncodeArguments('withdraw(uint256)', [wad]); - return abiEncodedTransactionData; - }, - /** - * Decode the ABI-encoded transaction data into its input arguments - * @param callData The ABI-encoded transaction data - * @returns An array representing the input arguments in order. Keynames of nested structs are preserved. - */ - getABIDecodedTransactionData(callData: string): [BigNumber] { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('withdraw(uint256)'); - // tslint:disable boolean-naming - const abiDecodedCallData = abiEncoder.strictDecode<[BigNumber]>(callData); - return abiDecodedCallData; - }, - /** - * Decode the ABI-encoded return data from a transaction - * @param returnData the data returned after transaction execution - * @returns An array representing the output results in order. Keynames of nested structs are preserved. - */ - getABIDecodedReturnData(returnData: string): void { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('withdraw(uint256)'); - // tslint:disable boolean-naming - const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); - return abiDecodedReturnData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as AbiGenDummyContract; - const abiEncoder = self._lookupAbiEncoder('withdraw(uint256)'); - return abiEncoder.getSelector(); - }, - }; + private _methodABIIndex: { [name: string]: number } = {}; private readonly _subscriptionManager: SubscriptionManager; public static async deployFrom0xArtifactAsync( artifact: ContractArtifact | SimpleContractArtifact, @@ -3765,6 +801,1615 @@ export class AbiGenDummyContract extends BaseContract { ] as ContractAbi; return abi; } + + public getFunctionSignature(methodName: string): string { + const index = this._methodABIIndex[methodName]; + const methodAbi = AbiGenDummyContract.ABI()[index] as MethodAbi; + const functionSignature = methodAbiToFunctionSignature(methodAbi); + return functionSignature; + } + public getABIDecodedTransactionData(methodName: string, callData: string): T { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as AbiGenDummyContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + const abiDecodedCallData = abiEncoder.strictDecode(callData); + return abiDecodedCallData; + } + public getABIDecodedReturnData(methodName: string, callData: string): T { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as AbiGenDummyContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + const abiDecodedCallData = abiEncoder.strictDecodeReturnValue(callData); + return abiDecodedCallData; + } + public getSelector(methodName: string): string { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as AbiGenDummyContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + return abiEncoder.getSelector(); + } + + /** + * a method that accepts an array of bytes + * @param a the array of bytes being accepted + */ + public acceptsAnArrayOfBytes(a: string[]): ContractFunctionObj { + const self = (this as any) as AbiGenDummyContract; + assert.isArray('a', a); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('acceptsAnArrayOfBytes(bytes[])', [a]); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('acceptsAnArrayOfBytes(bytes[])'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('acceptsAnArrayOfBytes(bytes[])', [a]); + return abiEncodedTransactionData; + }, + }; + } + public acceptsBytes(a: string): ContractFunctionObj { + const self = (this as any) as AbiGenDummyContract; + assert.isString('a', a); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('acceptsBytes(bytes)', [a]); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('acceptsBytes(bytes)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('acceptsBytes(bytes)', [a]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Tests decoding when the input and output are complex. + */ + public complexInputComplexOutput(complexInput: { + foo: BigNumber; + bar: string; + car: string; + }): ContractFunctionObj<{ + input: { foo: BigNumber; bar: string; car: string }; + lorem: string; + ipsum: string; + dolor: string; + }> { + const self = (this as any) as AbiGenDummyContract; + + return { + async callAsync( + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise<{ + input: { foo: BigNumber; bar: string; car: string }; + lorem: string; + ipsum: string; + dolor: string; + }> { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('complexInputComplexOutput((uint256,bytes,string))', [ + complexInput, + ]); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('complexInputComplexOutput((uint256,bytes,string))'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<{ + input: { foo: BigNumber; bar: string; car: string }; + lorem: string; + ipsum: string; + dolor: string; + }>(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'complexInputComplexOutput((uint256,bytes,string))', + [complexInput], + ); + return abiEncodedTransactionData; + }, + }; + } + /** + * test that devdocs will be generated and + * that multiline devdocs will look okay + * @param hash description of some hash. Let's make this line super long to + * demonstrate hanging indents for method params. It has to be more than + * one hundred twenty columns. + * @param v some v, recovery id + * @param r ECDSA r output + * @param s ECDSA s output + * @returns the signerAddress that created this signature. this line too is super long in order to demonstrate the proper hanging indentation in generated code. + */ + public ecrecoverFn(hash: string, v: number | BigNumber, r: string, s: string): ContractFunctionObj { + const self = (this as any) as AbiGenDummyContract; + assert.isString('hash', hash); + assert.isNumberOrBigNumber('v', v); + assert.isString('r', r); + assert.isString('s', s); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('ecrecoverFn(bytes32,uint8,bytes32,bytes32)', [ + hash, + v, + r, + s, + ]); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('ecrecoverFn(bytes32,uint8,bytes32,bytes32)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'ecrecoverFn(bytes32,uint8,bytes32,bytes32)', + [hash, v, r, s], + ); + return abiEncodedTransactionData; + }, + }; + } + public emitSimpleEvent(): ContractTxFunctionObj { + const self = (this as any) as AbiGenDummyContract; + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('emitSimpleEvent()', []); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('emitSimpleEvent()', []); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('emitSimpleEvent()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('emitSimpleEvent()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('emitSimpleEvent()', []); + return abiEncodedTransactionData; + }, + }; + } + public methodReturningArrayOfStructs(): ContractFunctionObj< + Array<{ someBytes: string; anInteger: number; aDynamicArrayOfBytes: string[]; aString: string }> + > { + const self = (this as any) as AbiGenDummyContract; + + return { + async callAsync( + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise< + Array<{ someBytes: string; anInteger: number; aDynamicArrayOfBytes: string[]; aString: string }> + > { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('methodReturningArrayOfStructs()', []); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('methodReturningArrayOfStructs()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue< + Array<{ someBytes: string; anInteger: number; aDynamicArrayOfBytes: string[]; aString: string }> + >(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('methodReturningArrayOfStructs()', []); + return abiEncodedTransactionData; + }, + }; + } + public methodReturningMultipleValues(): ContractFunctionObj<[BigNumber, string]> { + const self = (this as any) as AbiGenDummyContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise<[BigNumber, string]> { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('methodReturningMultipleValues()', []); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('methodReturningMultipleValues()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<[BigNumber, string]>(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('methodReturningMultipleValues()', []); + return abiEncodedTransactionData; + }, + }; + } + public methodUsingNestedStructWithInnerStructNotUsedElsewhere(): ContractFunctionObj<{ + innerStruct: { aField: BigNumber }; + }> { + const self = (this as any) as AbiGenDummyContract; + + return { + async callAsync( + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise<{ innerStruct: { aField: BigNumber } }> { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments( + 'methodUsingNestedStructWithInnerStructNotUsedElsewhere()', + [], + ); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('methodUsingNestedStructWithInnerStructNotUsedElsewhere()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<{ innerStruct: { aField: BigNumber } }>( + rawCallResult, + ); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'methodUsingNestedStructWithInnerStructNotUsedElsewhere()', + [], + ); + return abiEncodedTransactionData; + }, + }; + } + /** + * Tests decoding when the input and output are complex and have more than one argument. + */ + public multiInputMultiOutput( + index_0: BigNumber, + index_1: string, + index_2: string, + ): ContractFunctionObj<[string, string, string]> { + const self = (this as any) as AbiGenDummyContract; + assert.isBigNumber('index_0', index_0); + assert.isString('index_1', index_1); + assert.isString('index_2', index_2); + + return { + async callAsync( + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise<[string, string, string]> { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('multiInputMultiOutput(uint256,bytes,string)', [ + index_0, + index_1, + index_2, + ]); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('multiInputMultiOutput(uint256,bytes,string)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<[string, string, string]>(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'multiInputMultiOutput(uint256,bytes,string)', + [index_0, index_1, index_2], + ); + return abiEncodedTransactionData; + }, + }; + } + public nestedStructInput(n: { + innerStruct: { + someBytes: string; + anInteger: number | BigNumber; + aDynamicArrayOfBytes: string[]; + aString: string; + }; + description: string; + }): ContractFunctionObj { + const self = (this as any) as AbiGenDummyContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments( + 'nestedStructInput(((bytes,uint32,bytes[],string),string))', + [n], + ); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('nestedStructInput(((bytes,uint32,bytes[],string),string))'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'nestedStructInput(((bytes,uint32,bytes[],string),string))', + [n], + ); + return abiEncodedTransactionData; + }, + }; + } + public nestedStructOutput(): ContractFunctionObj<{ + innerStruct: { someBytes: string; anInteger: number; aDynamicArrayOfBytes: string[]; aString: string }; + description: string; + }> { + const self = (this as any) as AbiGenDummyContract; + + return { + async callAsync( + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise<{ + innerStruct: { someBytes: string; anInteger: number; aDynamicArrayOfBytes: string[]; aString: string }; + description: string; + }> { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('nestedStructOutput()', []); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('nestedStructOutput()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<{ + innerStruct: { + someBytes: string; + anInteger: number; + aDynamicArrayOfBytes: string[]; + aString: string; + }; + description: string; + }>(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('nestedStructOutput()', []); + return abiEncodedTransactionData; + }, + }; + } + /** + * Tests decoding when both input and output are empty. + */ + public noInputNoOutput(): ContractFunctionObj { + const self = (this as any) as AbiGenDummyContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('noInputNoOutput()', []); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('noInputNoOutput()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('noInputNoOutput()', []); + return abiEncodedTransactionData; + }, + }; + } + /** + * Tests decoding when input is empty and output is non-empty. + */ + public noInputSimpleOutput(): ContractFunctionObj { + const self = (this as any) as AbiGenDummyContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('noInputSimpleOutput()', []); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('noInputSimpleOutput()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('noInputSimpleOutput()', []); + return abiEncodedTransactionData; + }, + }; + } + public nonPureMethod(): ContractTxFunctionObj { + const self = (this as any) as AbiGenDummyContract; + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('nonPureMethod()', []); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('nonPureMethod()', []); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('nonPureMethod()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('nonPureMethod()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('nonPureMethod()', []); + return abiEncodedTransactionData; + }, + }; + } + public nonPureMethodThatReturnsNothing(): ContractTxFunctionObj { + const self = (this as any) as AbiGenDummyContract; + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('nonPureMethodThatReturnsNothing()', []); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('nonPureMethodThatReturnsNothing()', []); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('nonPureMethodThatReturnsNothing()', []); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('nonPureMethodThatReturnsNothing()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('nonPureMethodThatReturnsNothing()', []); + return abiEncodedTransactionData; + }, + }; + } + public overloadedMethod2(a: string): ContractFunctionObj { + const self = (this as any) as AbiGenDummyContract; + assert.isString('a', a); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('overloadedMethod(string)', [a]); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('overloadedMethod(string)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('overloadedMethod(string)', [a]); + return abiEncodedTransactionData; + }, + }; + } + public overloadedMethod1(a: BigNumber): ContractFunctionObj { + const self = (this as any) as AbiGenDummyContract; + assert.isBigNumber('a', a); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('overloadedMethod(int256)', [a]); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('overloadedMethod(int256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('overloadedMethod(int256)', [a]); + return abiEncodedTransactionData; + }, + }; + } + public pureFunctionWithConstant(): ContractFunctionObj { + const self = (this as any) as AbiGenDummyContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('pureFunctionWithConstant()', []); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('pureFunctionWithConstant()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('pureFunctionWithConstant()', []); + return abiEncodedTransactionData; + }, + }; + } + public requireWithConstant(): ContractFunctionObj { + const self = (this as any) as AbiGenDummyContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('requireWithConstant()', []); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('requireWithConstant()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('requireWithConstant()', []); + return abiEncodedTransactionData; + }, + }; + } + public revertWithConstant(): ContractFunctionObj { + const self = (this as any) as AbiGenDummyContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('revertWithConstant()', []); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('revertWithConstant()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('revertWithConstant()', []); + return abiEncodedTransactionData; + }, + }; + } + /** + * Tests decoding when input is not empty but output is empty. + */ + public simpleInputNoOutput(index_0: BigNumber): ContractFunctionObj { + const self = (this as any) as AbiGenDummyContract; + assert.isBigNumber('index_0', index_0); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('simpleInputNoOutput(uint256)', [index_0]); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('simpleInputNoOutput(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('simpleInputNoOutput(uint256)', [ + index_0, + ]); + return abiEncodedTransactionData; + }, + }; + } + /** + * Tests decoding when both input and output are non-empty. + */ + public simpleInputSimpleOutput(index_0: BigNumber): ContractFunctionObj { + const self = (this as any) as AbiGenDummyContract; + assert.isBigNumber('index_0', index_0); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('simpleInputSimpleOutput(uint256)', [index_0]); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('simpleInputSimpleOutput(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('simpleInputSimpleOutput(uint256)', [ + index_0, + ]); + return abiEncodedTransactionData; + }, + }; + } + public simplePureFunction(): ContractFunctionObj { + const self = (this as any) as AbiGenDummyContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('simplePureFunction()', []); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('simplePureFunction()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('simplePureFunction()', []); + return abiEncodedTransactionData; + }, + }; + } + public simplePureFunctionWithInput(x: BigNumber): ContractFunctionObj { + const self = (this as any) as AbiGenDummyContract; + assert.isBigNumber('x', x); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('simplePureFunctionWithInput(uint256)', [x]); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('simplePureFunctionWithInput(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('simplePureFunctionWithInput(uint256)', [ + x, + ]); + return abiEncodedTransactionData; + }, + }; + } + public simpleRequire(): ContractFunctionObj { + const self = (this as any) as AbiGenDummyContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('simpleRequire()', []); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('simpleRequire()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('simpleRequire()', []); + return abiEncodedTransactionData; + }, + }; + } + public simpleRevert(): ContractFunctionObj { + const self = (this as any) as AbiGenDummyContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('simpleRevert()', []); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('simpleRevert()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('simpleRevert()', []); + return abiEncodedTransactionData; + }, + }; + } + public structInput(s: { + someBytes: string; + anInteger: number | BigNumber; + aDynamicArrayOfBytes: string[]; + aString: string; + }): ContractFunctionObj { + const self = (this as any) as AbiGenDummyContract; + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('structInput((bytes,uint32,bytes[],string))', [s]); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('structInput((bytes,uint32,bytes[],string))'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'structInput((bytes,uint32,bytes[],string))', + [s], + ); + return abiEncodedTransactionData; + }, + }; + } + /** + * a method that returns a struct + * @returns a Struct struct + */ + public structOutput(): ContractFunctionObj<{ + someBytes: string; + anInteger: number; + aDynamicArrayOfBytes: string[]; + aString: string; + }> { + const self = (this as any) as AbiGenDummyContract; + + return { + async callAsync( + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise<{ someBytes: string; anInteger: number; aDynamicArrayOfBytes: string[]; aString: string }> { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('structOutput()', []); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('structOutput()'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<{ + someBytes: string; + anInteger: number; + aDynamicArrayOfBytes: string[]; + aString: string; + }>(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('structOutput()', []); + return abiEncodedTransactionData; + }, + }; + } + public withAddressInput( + x: string, + a: BigNumber, + b: BigNumber, + y: string, + c: BigNumber, + ): ContractFunctionObj { + const self = (this as any) as AbiGenDummyContract; + assert.isString('x', x); + assert.isBigNumber('a', a); + assert.isBigNumber('b', b); + assert.isString('y', y); + assert.isBigNumber('c', c); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments( + 'withAddressInput(address,uint256,uint256,address,uint256)', + [x.toLowerCase(), a, b, y.toLowerCase(), c], + ); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('withAddressInput(address,uint256,uint256,address,uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments( + 'withAddressInput(address,uint256,uint256,address,uint256)', + [x.toLowerCase(), a, b, y.toLowerCase(), c], + ); + return abiEncodedTransactionData; + }, + }; + } + public withdraw(wad: BigNumber): ContractTxFunctionObj { + const self = (this as any) as AbiGenDummyContract; + assert.isBigNumber('wad', wad); + + return { + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + const encodedData = self._strictEncodeArguments('withdraw(uint256)', [wad]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + if (opts.shouldValidate !== false) { + await this.callAsync(txDataWithDefaults); + } + + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + awaitTransactionSuccessAsync( + txData?: Partial, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + const txHashPromise = this.sendTransactionAsync(txData, opts); + return new PromiseWithTransactionHash( + txHashPromise, + (async (): Promise => { + // When the transaction hash resolves, wait for it to be mined. + return self._web3Wrapper.awaitTransactionSuccessAsync( + await txHashPromise, + opts.pollingIntervalMs, + opts.timeoutMs, + ); + })(), + ); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const encodedData = self._strictEncodeArguments('withdraw(uint256)', [wad]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('withdraw(uint256)', [wad]); + let rawCallResult; + + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + callDataWithDefaults.from = callDataWithDefaults.from + ? callDataWithDefaults.from.toLowerCase() + : callDataWithDefaults.from; + try { + rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('withdraw(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('withdraw(uint256)', [wad]); + return abiEncodedTransactionData; + }, + }; + } + /** * Subscribe to an event type emitted by the AbiGenDummy contract. * @param eventName The AbiGenDummy contract event you would like to subscribe to. @@ -3854,6 +2499,12 @@ export class AbiGenDummyContract extends BaseContract { AbiGenDummyContract.ABI(), this._web3Wrapper, ); + AbiGenDummyContract.ABI().forEach((item, index) => { + if (item.type === 'function') { + const methodAbi = item as MethodAbi; + this._methodABIIndex[methodAbi.name] = index; + } + }); } } diff --git a/packages/abi-gen/test-cli/output/typescript/lib_dummy.ts b/packages/abi-gen/test-cli/output/typescript/lib_dummy.ts index 39d6a9f45e..ae506e5de1 100644 --- a/packages/abi-gen/test-cli/output/typescript/lib_dummy.ts +++ b/packages/abi-gen/test-cli/output/typescript/lib_dummy.ts @@ -1,7 +1,15 @@ // tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma enum-naming // tslint:disable:whitespace no-unbound-method no-trailing-whitespace // tslint:disable:no-unused-variable -import { BaseContract, PromiseWithTransactionHash } from '@0x/base-contract'; +import { + AwaitTransactionSuccessOpts, + ContractFunctionObj, + ContractTxFunctionObj, + SendTransactionOpts, + BaseContract, + PromiseWithTransactionHash, + methodAbiToFunctionSignature, +} from '@0x/base-contract'; import { schemas } from '@0x/json-schemas'; import { BlockParam, @@ -18,13 +26,7 @@ import { SupportedProvider, } from 'ethereum-types'; import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils'; -import { - AwaitTransactionSuccessOpts, - EventCallback, - IndexedFilterValues, - SendTransactionOpts, - SimpleContractArtifact, -} from '@0x/types'; +import { EventCallback, IndexedFilterValues, SimpleContractArtifact } from '@0x/types'; import { Web3Wrapper } from '@0x/web3-wrapper'; import { assert } from '@0x/assert'; import * as ethers from 'ethers'; @@ -38,6 +40,7 @@ export class LibDummyContract extends BaseContract { * @ignore */ public static deployedBytecode: string | undefined; + private _methodABIIndex: { [name: string]: number } = {}; public static async deployFrom0xArtifactAsync( artifact: ContractArtifact | SimpleContractArtifact, supportedProvider: SupportedProvider, @@ -109,6 +112,34 @@ export class LibDummyContract extends BaseContract { const abi = [] as ContractAbi; return abi; } + + public getFunctionSignature(methodName: string): string { + const index = this._methodABIIndex[methodName]; + const methodAbi = LibDummyContract.ABI()[index] as MethodAbi; + const functionSignature = methodAbiToFunctionSignature(methodAbi); + return functionSignature; + } + public getABIDecodedTransactionData(methodName: string, callData: string): T { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as LibDummyContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + const abiDecodedCallData = abiEncoder.strictDecode(callData); + return abiDecodedCallData; + } + public getABIDecodedReturnData(methodName: string, callData: string): T { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as LibDummyContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + const abiDecodedCallData = abiEncoder.strictDecodeReturnValue(callData); + return abiDecodedCallData; + } + public getSelector(methodName: string): string { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as LibDummyContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + return abiEncoder.getSelector(); + } + constructor( address: string, supportedProvider: SupportedProvider, @@ -126,6 +157,12 @@ export class LibDummyContract extends BaseContract { deployedBytecode, ); classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']); + LibDummyContract.ABI().forEach((item, index) => { + if (item.type === 'function') { + const methodAbi = item as MethodAbi; + this._methodABIIndex[methodAbi.name] = index; + } + }); } } diff --git a/packages/abi-gen/test-cli/output/typescript/test_lib_dummy.ts b/packages/abi-gen/test-cli/output/typescript/test_lib_dummy.ts index b1721f5ca3..a2a53a7b6b 100644 --- a/packages/abi-gen/test-cli/output/typescript/test_lib_dummy.ts +++ b/packages/abi-gen/test-cli/output/typescript/test_lib_dummy.ts @@ -1,7 +1,15 @@ // tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma enum-naming // tslint:disable:whitespace no-unbound-method no-trailing-whitespace // tslint:disable:no-unused-variable -import { BaseContract, PromiseWithTransactionHash } from '@0x/base-contract'; +import { + AwaitTransactionSuccessOpts, + ContractFunctionObj, + ContractTxFunctionObj, + SendTransactionOpts, + BaseContract, + PromiseWithTransactionHash, + methodAbiToFunctionSignature, +} from '@0x/base-contract'; import { schemas } from '@0x/json-schemas'; import { BlockParam, @@ -18,13 +26,7 @@ import { SupportedProvider, } from 'ethereum-types'; import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils'; -import { - AwaitTransactionSuccessOpts, - EventCallback, - IndexedFilterValues, - SendTransactionOpts, - SimpleContractArtifact, -} from '@0x/types'; +import { EventCallback, IndexedFilterValues, SimpleContractArtifact } from '@0x/types'; import { Web3Wrapper } from '@0x/web3-wrapper'; import { assert } from '@0x/assert'; import * as ethers from 'ethers'; @@ -39,166 +41,7 @@ export class TestLibDummyContract extends BaseContract { */ public static deployedBytecode = '0x6080604052348015600f57600080fd5b506004361060325760003560e01c806322935e921460375780632b82fdf0146063575b600080fd5b605160048036036020811015604b57600080fd5b5035607d565b60408051918252519081900360200190f35b605160048036036020811015607757600080fd5b5035608c565b60006086826095565b92915050565b6000608682609c565b6104d20190565b6001019056fea265627a7a72315820863e53f0da474a1275d583d88852313fe053941e79bddd5279abd812b31e020c64736f6c634300050c0032'; - public publicAddConstant = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(x: BigNumber, callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.isBigNumber('x', x); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as TestLibDummyContract; - const encodedData = self._strictEncodeArguments('publicAddConstant(uint256)', [x]); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('publicAddConstant(uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(x: BigNumber): string { - assert.isBigNumber('x', x); - const self = (this as any) as TestLibDummyContract; - const abiEncodedTransactionData = self._strictEncodeArguments('publicAddConstant(uint256)', [x]); - return abiEncodedTransactionData; - }, - /** - * Decode the ABI-encoded transaction data into its input arguments - * @param callData The ABI-encoded transaction data - * @returns An array representing the input arguments in order. Keynames of nested structs are preserved. - */ - getABIDecodedTransactionData(callData: string): BigNumber { - const self = (this as any) as TestLibDummyContract; - const abiEncoder = self._lookupAbiEncoder('publicAddConstant(uint256)'); - // tslint:disable boolean-naming - const abiDecodedCallData = abiEncoder.strictDecode(callData); - return abiDecodedCallData; - }, - /** - * Decode the ABI-encoded return data from a transaction - * @param returnData the data returned after transaction execution - * @returns An array representing the output results in order. Keynames of nested structs are preserved. - */ - getABIDecodedReturnData(returnData: string): BigNumber { - const self = (this as any) as TestLibDummyContract; - const abiEncoder = self._lookupAbiEncoder('publicAddConstant(uint256)'); - // tslint:disable boolean-naming - const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); - return abiDecodedReturnData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as TestLibDummyContract; - const abiEncoder = self._lookupAbiEncoder('publicAddConstant(uint256)'); - return abiEncoder.getSelector(); - }, - }; - public publicAddOne = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - */ - async callAsync(x: BigNumber, callData: Partial = {}, defaultBlock?: BlockParam): Promise { - assert.isBigNumber('x', x); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as TestLibDummyContract; - const encodedData = self._strictEncodeArguments('publicAddOne(uint256)', [x]); - const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - - let rawCallResult; - try { - rawCallResult = await self._evmExecAsync(encodedDataBytes); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - - const abiEncoder = self._lookupAbiEncoder('publicAddOne(uint256)'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(x: BigNumber): string { - assert.isBigNumber('x', x); - const self = (this as any) as TestLibDummyContract; - const abiEncodedTransactionData = self._strictEncodeArguments('publicAddOne(uint256)', [x]); - return abiEncodedTransactionData; - }, - /** - * Decode the ABI-encoded transaction data into its input arguments - * @param callData The ABI-encoded transaction data - * @returns An array representing the input arguments in order. Keynames of nested structs are preserved. - */ - getABIDecodedTransactionData(callData: string): BigNumber { - const self = (this as any) as TestLibDummyContract; - const abiEncoder = self._lookupAbiEncoder('publicAddOne(uint256)'); - // tslint:disable boolean-naming - const abiDecodedCallData = abiEncoder.strictDecode(callData); - return abiDecodedCallData; - }, - /** - * Decode the ABI-encoded return data from a transaction - * @param returnData the data returned after transaction execution - * @returns An array representing the output results in order. Keynames of nested structs are preserved. - */ - getABIDecodedReturnData(returnData: string): BigNumber { - const self = (this as any) as TestLibDummyContract; - const abiEncoder = self._lookupAbiEncoder('publicAddOne(uint256)'); - // tslint:disable boolean-naming - const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); - return abiDecodedReturnData; - }, - /** - * Returns the 4 byte function selector as a hex string. - */ - getSelector(): string { - const self = (this as any) as TestLibDummyContract; - const abiEncoder = self._lookupAbiEncoder('publicAddOne(uint256)'); - return abiEncoder.getSelector(); - }, - }; + private _methodABIIndex: { [name: string]: number } = {}; public static async deployFrom0xArtifactAsync( artifact: ContractArtifact | SimpleContractArtifact, supportedProvider: SupportedProvider, @@ -309,6 +152,111 @@ export class TestLibDummyContract extends BaseContract { ] as ContractAbi; return abi; } + + public getFunctionSignature(methodName: string): string { + const index = this._methodABIIndex[methodName]; + const methodAbi = TestLibDummyContract.ABI()[index] as MethodAbi; + const functionSignature = methodAbiToFunctionSignature(methodAbi); + return functionSignature; + } + public getABIDecodedTransactionData(methodName: string, callData: string): T { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as TestLibDummyContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + const abiDecodedCallData = abiEncoder.strictDecode(callData); + return abiDecodedCallData; + } + public getABIDecodedReturnData(methodName: string, callData: string): T { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as TestLibDummyContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + const abiDecodedCallData = abiEncoder.strictDecodeReturnValue(callData); + return abiDecodedCallData; + } + public getSelector(methodName: string): string { + const functionSignature = this.getFunctionSignature(methodName); + const self = (this as any) as TestLibDummyContract; + const abiEncoder = self._lookupAbiEncoder(functionSignature); + return abiEncoder.getSelector(); + } + + public publicAddConstant(x: BigNumber): ContractFunctionObj { + const self = (this as any) as TestLibDummyContract; + assert.isBigNumber('x', x); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('publicAddConstant(uint256)', [x]); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('publicAddConstant(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('publicAddConstant(uint256)', [x]); + return abiEncodedTransactionData; + }, + }; + } + public publicAddOne(x: BigNumber): ContractFunctionObj { + const self = (this as any) as TestLibDummyContract; + assert.isBigNumber('x', x); + + return { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const encodedData = self._strictEncodeArguments('publicAddOne(uint256)', [x]); + let rawCallResult; + + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + try { + rawCallResult = await self._evmExecAsync(encodedDataBytes); + } catch (err) { + BaseContract._throwIfThrownErrorIsRevertError(err); + throw err; + } + + BaseContract._throwIfCallResultIsRevertError(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('publicAddOne(uint256)'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue(rawCallResult); + // tslint:enable boolean-naming + return result; + }, + getABIEncodedTransactionData(): string { + const abiEncodedTransactionData = self._strictEncodeArguments('publicAddOne(uint256)', [x]); + return abiEncodedTransactionData; + }, + }; + } + constructor( address: string, supportedProvider: SupportedProvider, @@ -326,6 +274,12 @@ export class TestLibDummyContract extends BaseContract { deployedBytecode, ); classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']); + TestLibDummyContract.ABI().forEach((item, index) => { + if (item.type === 'function') { + const methodAbi = item as MethodAbi; + this._methodABIIndex[methodAbi.name] = index; + } + }); } } diff --git a/packages/abi-gen/test-cli/test_typescript/test/abi_gen_dummy_test.ts b/packages/abi-gen/test-cli/test_typescript/test/abi_gen_dummy_test.ts index 948f909c7a..5dfc7eb503 100644 --- a/packages/abi-gen/test-cli/test_typescript/test/abi_gen_dummy_test.ts +++ b/packages/abi-gen/test-cli/test_typescript/test/abi_gen_dummy_test.ts @@ -1,3 +1,4 @@ +import { ContractFunctionObj } from '@0x/base-contract'; import { BlockchainLifecycle, devConstants, web3Factory } from '@0x/dev-utils'; import { Web3ProviderEngine } from '@0x/subproviders'; import { BigNumber, providerUtils, StringRevertError } from '@0x/utils'; @@ -33,10 +34,15 @@ const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper); describe('AbiGenDummy Contract', () => { let abiGenDummy: AbiGenDummyContract; - const runTestAsync = async (contractMethod: any, input: any, output: any) => { - const transaction = contractMethod.getABIEncodedTransactionData(input); + const runTestAsync = async ( + contractMethodName: string, + contractMethod: ContractFunctionObj, + input: any, + output: any, + ) => { + const transaction = contractMethod.getABIEncodedTransactionData(); // try decoding transaction - const decodedInput = contractMethod.getABIDecodedTransactionData(transaction); + const decodedInput = abiGenDummy.getABIDecodedTransactionData(contractMethodName, transaction); expect(decodedInput, 'decoded input').to.be.deep.equal(input); // execute transaction const rawOutput = await web3Wrapper.callAsync({ @@ -44,7 +50,7 @@ describe('AbiGenDummy Contract', () => { data: transaction, }); // try decoding output - const decodedOutput = contractMethod.getABIDecodedReturnData(rawOutput); + const decodedOutput = abiGenDummy.getABIDecodedReturnData(contractMethodName, rawOutput); expect(decodedOutput, 'decoded output').to.be.deep.equal(output); }; before(async () => { @@ -62,46 +68,46 @@ describe('AbiGenDummy Contract', () => { }); describe('simplePureFunction', () => { it('should call simplePureFunction', async () => { - const result = await abiGenDummy.simplePureFunction.callAsync(); + const result = await abiGenDummy.simplePureFunction().callAsync(); expect(result).to.deep.equal(new BigNumber(1)); }); }); describe('simplePureFunctionWithInput', () => { it('should call simplePureFunctionWithInput', async () => { - const result = await abiGenDummy.simplePureFunctionWithInput.callAsync(new BigNumber(5)); + const result = await abiGenDummy.simplePureFunctionWithInput(new BigNumber(5)).callAsync(); expect(result).to.deep.equal(new BigNumber(6)); }); }); describe('pureFunctionWithConstant', () => { it('should call pureFunctionWithConstant', async () => { - const result = await abiGenDummy.pureFunctionWithConstant.callAsync(); + const result = await abiGenDummy.pureFunctionWithConstant().callAsync(); expect(result).to.deep.equal(new BigNumber(1234)); }); }); describe('simpleRevert', () => { it('should call simpleRevert', async () => { - expect(abiGenDummy.simpleRevert.callAsync()) + expect(abiGenDummy.simpleRevert().callAsync()) .to.eventually.be.rejectedWith(StringRevertError) .and.deep.equal(new StringRevertError('SIMPLE_REVERT')); }); }); describe('revertWithConstant', () => { it('should call revertWithConstant', async () => { - expect(abiGenDummy.revertWithConstant.callAsync()) + expect(abiGenDummy.revertWithConstant().callAsync()) .to.eventually.be.rejectedWith(StringRevertError) .and.deep.equal(new StringRevertError('REVERT_WITH_CONSTANT')); }); }); describe('simpleRequire', () => { it('should call simpleRequire', async () => { - expect(abiGenDummy.simpleRequire.callAsync()) + expect(abiGenDummy.simpleRequire().callAsync()) .to.eventually.be.rejectedWith(StringRevertError) .and.deep.equal(new StringRevertError('SIMPLE_REQUIRE')); }); }); describe('requireWithConstant', () => { it('should call requireWithConstant', async () => { - expect(abiGenDummy.requireWithConstant.callAsync()) + expect(abiGenDummy.requireWithConstant().callAsync()) .to.eventually.be.rejectedWith(StringRevertError) .and.deep.equal(new StringRevertError('REQUIRE_WITH_CONSTANT')); }); @@ -115,7 +121,7 @@ describe('AbiGenDummy Contract', () => { someBytes: '0x3078313233', }; it('should be able to handle struct output', async () => { - const result = await abiGenDummy.structOutput.callAsync(); + const result = await abiGenDummy.structOutput().callAsync(); expect(result).to.deep.equal(sampleStruct); }); }); @@ -133,7 +139,7 @@ describe('AbiGenDummy Contract', () => { const v_decimal = parseInt(v, 16) + 27; // v: (0 or 1) => (27 or 28) // tslint:enable:custom-no-magic-numbers - const result = await abiGenDummy.ecrecoverFn.callAsync(message, v_decimal, r, s); + const result = await abiGenDummy.ecrecoverFn(message, v_decimal, r, s).callAsync(); expect(result).to.equal(signerAddress); }); }); @@ -174,7 +180,7 @@ describe('AbiGenDummy Contract', () => { toBlock: BlockParamLiteral.Latest, }; it('should get logs with decoded args emitted by EventWithStruct', async () => { - await abiGenDummy.emitSimpleEvent.awaitTransactionSuccessAsync(); + await abiGenDummy.emitSimpleEvent().awaitTransactionSuccessAsync(); const eventName = AbiGenDummyEvents.SimpleEvent; const indexFilterValues = {}; const logs = await abiGenDummy.getLogsAsync(eventName, blockRange, indexFilterValues); @@ -182,7 +188,7 @@ describe('AbiGenDummy Contract', () => { expect(logs[0].event).to.be.equal(eventName); }); it('should only get the logs with the correct event name', async () => { - await abiGenDummy.emitSimpleEvent.awaitTransactionSuccessAsync(); + await abiGenDummy.emitSimpleEvent().awaitTransactionSuccessAsync(); const differentEventName = AbiGenDummyEvents.Withdrawal; const indexFilterValues = {}; const logs = await abiGenDummy.getLogsAsync(differentEventName, blockRange, indexFilterValues); @@ -190,8 +196,8 @@ describe('AbiGenDummy Contract', () => { }); it('should only get the logs with the correct indexed fields', async () => { const [addressOne, addressTwo] = await web3Wrapper.getAvailableAddressesAsync(); - await abiGenDummy.withdraw.awaitTransactionSuccessAsync(new BigNumber(1), { from: addressOne }); - await abiGenDummy.withdraw.awaitTransactionSuccessAsync(new BigNumber(1), { from: addressTwo }); + await abiGenDummy.withdraw(new BigNumber(1)).awaitTransactionSuccessAsync({ from: addressOne }); + await abiGenDummy.withdraw(new BigNumber(1)).awaitTransactionSuccessAsync({ from: addressTwo }); const eventName = AbiGenDummyEvents.Withdrawal; const indexFilterValues = { _owner: addressOne, @@ -214,7 +220,7 @@ describe('AbiGenDummy Contract', () => { const a = new BigNumber(1); const b = new BigNumber(2); const c = new BigNumber(3); - const output = await abiGenDummy.withAddressInput.callAsync(xAddress, a, b, yAddress, c); + const output = await abiGenDummy.withAddressInput(xAddress, a, b, yAddress, c).callAsync(); expect(output).to.equal(xAddress.toLowerCase()); }); @@ -224,22 +230,22 @@ describe('AbiGenDummy Contract', () => { it('should successfully encode/decode (no input / no output)', async () => { const input = undefined; const output = undefined; - await runTestAsync(abiGenDummy.noInputNoOutput, input, output); + await runTestAsync('noInputNoOutput', abiGenDummy.noInputNoOutput(), input, output); }); it('should successfully encode/decode (no input / simple output)', async () => { const input = undefined; const output = new BigNumber(1991); - await runTestAsync(abiGenDummy.noInputSimpleOutput, input, output); + await runTestAsync('noInputSimpleOutput', abiGenDummy.noInputSimpleOutput(), input, output); }); it('should successfully encode/decode (simple input / no output)', async () => { const input = new BigNumber(1991); const output = undefined; - await runTestAsync(abiGenDummy.simpleInputNoOutput, input, output); + await runTestAsync('simpleInputNoOutput', abiGenDummy.simpleInputNoOutput(input), input, output); }); it('should successfully encode/decode (simple input / simple output)', async () => { const input = new BigNumber(16); const output = new BigNumber(1991); - await runTestAsync(abiGenDummy.simpleInputSimpleOutput, input, output); + await runTestAsync('simpleInputSimpleOutput', abiGenDummy.simpleInputSimpleOutput(input), input, output); }); it('should successfully encode/decode (complex input / complex output)', async () => { const input = { @@ -253,18 +259,21 @@ describe('AbiGenDummy Contract', () => { ipsum: '0x87654321', dolor: 'amet', }; - await runTestAsync(abiGenDummy.complexInputComplexOutput, input, output); + await runTestAsync( + 'complexInputComplexOutput', + abiGenDummy.complexInputComplexOutput(input), + input, + output, + ); }); it('should successfully encode/decode (multi-input / multi-output)', async () => { const input = [new BigNumber(1991), '0x1234', 'zoom zoom']; const output = ['0x12345678', '0x87654321', 'amet']; - const transaction = abiGenDummy.multiInputMultiOutput.getABIEncodedTransactionData( - input[0] as BigNumber, - input[1] as string, - input[2] as string, - ); + const transaction = abiGenDummy + .multiInputMultiOutput(input[0] as BigNumber, input[1] as string, input[2] as string) + .getABIEncodedTransactionData(); // try decoding transaction - const decodedInput = abiGenDummy.multiInputMultiOutput.getABIDecodedTransactionData(transaction); + const decodedInput = abiGenDummy.getABIDecodedTransactionData('multiInputMultiOutput', transaction); expect(decodedInput, 'decoded input').to.be.deep.equal(input); // execute transaction const rawOutput = await web3Wrapper.callAsync({ @@ -272,14 +281,14 @@ describe('AbiGenDummy Contract', () => { data: transaction, }); // try decoding output - const decodedOutput = abiGenDummy.multiInputMultiOutput.getABIDecodedReturnData(rawOutput); + const decodedOutput = abiGenDummy.getABIDecodedReturnData('multiInputMultiOutput', rawOutput); expect(decodedOutput, 'decoded output').to.be.deep.equal(output); }); }); describe('awaitTransactionSuccessAsync', async () => { it('should successfully call the non pure function', async () => { expect( - abiGenDummy.nonPureMethod.awaitTransactionSuccessAsync({}, { pollingIntervalMs: 10, timeoutMs: 100 }), + abiGenDummy.nonPureMethod().awaitTransactionSuccessAsync({}, { pollingIntervalMs: 10, timeoutMs: 100 }), ).to.be.fulfilled(''); }); }); @@ -309,12 +318,12 @@ describe('Lib dummy contract', () => { }); it('should call a library function', async () => { - const result = await libDummy.publicAddOne.callAsync(new BigNumber(1)); + const result = await libDummy.publicAddOne(new BigNumber(1)).callAsync(); expect(result).to.deep.equal(new BigNumber(2)); }); it('should call a library function referencing a constant', async () => { - const result = await libDummy.publicAddConstant.callAsync(new BigNumber(1)); + const result = await libDummy.publicAddConstant(new BigNumber(1)).callAsync(); expect(result).to.deep.equal(new BigNumber(1235)); }); }); diff --git a/packages/base-contract/src/index.ts b/packages/base-contract/src/index.ts index a1c5937be2..e3076946a0 100644 --- a/packages/base-contract/src/index.ts +++ b/packages/base-contract/src/index.ts @@ -29,6 +29,8 @@ import { default as VM } from 'ethereumjs-vm'; import PStateManager from 'ethereumjs-vm/dist/state/promisified'; import * as _ from 'lodash'; +export { methodAbiToFunctionSignature } from './utils'; + import { formatABIDataItem } from './utils'; export { SubscriptionManager } from './subscription_manager'; diff --git a/packages/base-contract/src/types.ts b/packages/base-contract/src/types.ts index 5414dd2090..e834668e46 100644 --- a/packages/base-contract/src/types.ts +++ b/packages/base-contract/src/types.ts @@ -1,4 +1,6 @@ -import { LogEntryEvent } from 'ethereum-types'; +import { BlockParam, CallData, LogEntryEvent, TransactionReceiptWithDecodedLogs, TxData } from 'ethereum-types'; + +import { PromiseWithTransactionHash } from './index'; export type LogEvent = LogEntryEvent; @@ -18,3 +20,36 @@ export enum SubscriptionErrors { SubscriptionNotFound = 'SUBSCRIPTION_NOT_FOUND', SubscriptionAlreadyPresent = 'SUBSCRIPTION_ALREADY_PRESENT', } + +/** + * Used with `sendTransactionAsync` + * * shouldValidate: Flag indicating whether the library should make attempts to validate a transaction before + * broadcasting it. For example, order has a valid signature, maker has sufficient funds, etc. Default=true. + */ +export interface SendTransactionOpts { + shouldValidate?: boolean; +} + +/** + * Used with `awaitTransactionSuccessAsync` + * * pollingIntervalMs: Determine polling intervals in milliseconds + * * timeoutMs: Determines timeout in milliseconds + */ +export interface AwaitTransactionSuccessOpts extends SendTransactionOpts { + pollingIntervalMs?: number; + timeoutMs?: number; +} + +export interface ContractFunctionObj { + callAsync(callData?: Partial, defaultBlock?: BlockParam): Promise; + getABIEncodedTransactionData(): string; +} + +export interface ContractTxFunctionObj extends ContractFunctionObj { + sendTransactionAsync(txData?: Partial, opts?: SendTransactionOpts): Promise; + awaitTransactionSuccessAsync( + txData?: Partial, + opts?: AwaitTransactionSuccessOpts, + ): PromiseWithTransactionHash; + estimateGasAsync(txData?: Partial): Promise; +} diff --git a/packages/base-contract/src/utils.ts b/packages/base-contract/src/utils.ts index 61f176df5d..24273051f2 100644 --- a/packages/base-contract/src/utils.ts +++ b/packages/base-contract/src/utils.ts @@ -1,4 +1,4 @@ -import { DataItem } from 'ethereum-types'; +import { DataItem, MethodAbi } from 'ethereum-types'; import * as _ from 'lodash'; // tslint:disable-next-line:completed-docs @@ -23,3 +23,22 @@ export function formatABIDataItem(abi: DataItem, value: any, formatter: (type: s return formatter(abi.type, value); } } + +function dataItemsToABIString(dataItems: DataItem[]): string { + const types = dataItems.map(item => { + if (item.components) { + return `(${dataItemsToABIString(item.components)})`; + } else { + return item.type; + } + }); + return `${types.join(',')}`; +} +/** + * Takes a MethodAbi and returns a function signature for ABI encoding/decoding + * @return a function signature as a string, e.g. 'functionName(uint256, bytes[])' + */ +export function methodAbiToFunctionSignature(methodAbi: MethodAbi): string { + const inputs = dataItemsToABIString(methodAbi.inputs); + return `${methodAbi.name}(${inputs})`; +} diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts index 12508b8302..c52de62441 100644 --- a/packages/types/src/index.ts +++ b/packages/types/src/index.ts @@ -854,30 +854,6 @@ export interface IndexedFilterValues { [index: string]: ContractEventArg; } -/* Begin types for @0x/abi-gen-wrappers - * Allow these types to be imported when needed instead of having to import - * the whole package, which is large - */ - -/** - * Used with `sendTransactionAsync` - * * shouldValidate: Flag indicating whether the library should make attempts to validate a transaction before - * broadcasting it. For example, order has a valid signature, maker has sufficient funds, etc. Default=true. - */ -export interface SendTransactionOpts { - shouldValidate?: boolean; -} - -/** - * Used with `awaitTransactionSuccessAsync` - * * pollingIntervalMs: Determine polling intervals in milliseconds - * * timeoutMs: Determines timeout in milliseconds - */ -export interface AwaitTransactionSuccessOpts extends SendTransactionOpts { - pollingIntervalMs?: number; - timeoutMs?: number; -} - export interface SimpleContractArtifact { schemaVersion: string; contractName: string; From d58b770417b93446057257a65d6e80205740edb7 Mon Sep 17 00:00:00 2001 From: xianny Date: Tue, 12 Nov 2019 19:29:49 -0600 Subject: [PATCH 02/20] wip: get all packages to build --- contracts/asset-proxy/test/authorizable.ts | 54 +- contracts/asset-proxy/test/erc1155_proxy.ts | 224 +- .../asset-proxy/test/erc20bridge_proxy.ts | 31 +- contracts/asset-proxy/test/eth2dai_bridge.ts | 30 +- contracts/asset-proxy/test/proxies.ts | 922 +++--- .../asset-proxy/test/static_call_proxy.ts | 147 +- contracts/asset-proxy/test/uniswap_bridge.ts | 81 +- .../test/utils/erc1155_proxy_wrapper.ts | 40 +- .../asset-proxy/test/utils/erc20_wrapper.ts | 40 +- .../asset-proxy/test/utils/erc721_wrapper.ts | 24 +- .../coordinator/test/coordinator_registry.ts | 39 +- contracts/coordinator/test/libs.ts | 2 +- contracts/coordinator/test/mixins.ts | 280 +- contracts/erc1155/test/erc1155_token.ts | 70 +- .../erc1155/test/utils/erc1155_wrapper.ts | 40 +- contracts/erc20/test/lib_erc20_token.ts | 279 +- .../erc20/test/unlimited_allowance_token.ts | 56 +- contracts/erc20/test/weth9.ts | 24 +- contracts/erc20/test/zrx_token.ts | 64 +- contracts/erc721/test/erc721_token.ts | 52 +- .../test/lib_eip712_exchange_domain.ts | 4 +- .../exchange-libs/test/lib_fill_results.ts | 203 +- contracts/exchange-libs/test/lib_math.ts | 67 +- contracts/exchange-libs/test/lib_order.ts | 8 +- .../test/lib_zero_ex_transaction.ts | 18 +- contracts/exchange/src/wrapper_interfaces.ts | 62 +- .../assertion_wrappers/fill_order_wrapper.ts | 26 +- .../blockchain_balance_store.ts | 11 +- .../balance_stores/local_balance_store.ts | 18 +- contracts/exchange/test/core.ts | 418 ++- contracts/exchange/test/dispatcher.ts | 207 +- contracts/exchange/test/internal.ts | 109 +- contracts/exchange/test/match_orders.ts | 174 +- contracts/exchange/test/protocol_fees.ts | 263 +- .../exchange/test/protocol_fees_manager.ts | 34 +- contracts/exchange/test/reentrancy_tests.ts | 8 +- .../exchange/test/signature_validator.ts | 218 +- contracts/exchange/test/transactions.ts | 102 +- .../exchange/test/transactions_unit_tests.ts | 239 +- .../exchange/test/utils/asset_wrapper.ts | 74 +- .../test/utils/exchange_data_encoder.ts | 52 +- .../exchange/test/utils/exchange_wrapper.ts | 290 +- .../utils/fill_order_combinatorial_utils.ts | 20 +- .../test/utils/isolated_exchange_wrapper.ts | 50 +- .../exchange/test/utils/match_order_tester.ts | 14 +- .../test/utils/order_factory_from_scenario.ts | 204 +- contracts/exchange/test/wrapper_unit_tests.ts | 2656 ++++++++--------- .../test/balance_threshold_filter.ts | 21 +- contracts/extensions/test/dutch_auction.ts | 31 +- contracts/extensions/test/order_matcher.ts | 212 +- .../test/utils/balance_threshold_wrapper.ts | 138 +- .../test/utils/dutch_auction_test_wrapper.ts | 14 +- contracts/integrations/test/actors/base.ts | 29 +- contracts/integrations/test/actors/keeper.ts | 8 +- contracts/integrations/test/actors/maker.ts | 4 +- .../integrations/test/actors/pool_operator.ts | 16 +- contracts/integrations/test/actors/staker.ts | 15 +- contracts/integrations/test/actors/taker.ts | 11 +- .../test/coordinator/coordinator_test.ts | 179 +- .../test/forwarder/forwarder_test.ts | 102 +- .../test/forwarder/forwarder_test_factory.ts | 42 +- .../deployment_manager_test.ts | 56 +- .../function_assertion_test.ts | 2 +- .../deployment_test.ts | 61 +- .../exchange_wrapper_test.ts | 128 +- .../fillorder_test.ts | 20 +- .../test/utils/deployment_manager.ts | 32 +- .../test/utils/function_assertions.ts | 30 +- .../multisig/test/multi_sig_with_time_lock.ts | 34 +- .../multisig/test/utils/multi_sig_wrapper.ts | 8 +- .../test/utils/zero_ex_governor_wrapper.ts | 24 +- contracts/multisig/test/zero_ex_governor.ts | 292 +- .../staking/test/actors/finalizer_actor.ts | 24 +- contracts/staking/test/actors/maker_actor.ts | 9 +- .../test/actors/pool_operator_actor.ts | 14 +- contracts/staking/test/actors/staker_actor.ts | 80 +- contracts/staking/test/epoch_test.ts | 4 +- contracts/staking/test/migration_test.ts | 153 +- contracts/staking/test/pools_test.ts | 4 +- contracts/staking/test/rewards_test.ts | 60 +- contracts/staking/test/stake_test.ts | 2 +- .../test/unit_tests/delegator_reward_test.ts | 48 +- .../staking/test/unit_tests/exchange_test.ts | 28 +- .../staking/test/unit_tests/finalizer_test.ts | 119 +- .../test/unit_tests/lib_cobb_douglas_test.ts | 23 +- .../test/unit_tests/lib_fixed_math_test.ts | 216 +- .../test/unit_tests/lib_safe_downcast_test.ts | 4 +- .../mixin_cumulative_rewards_test.ts | 150 +- .../test/unit_tests/mixin_scheduler_test.ts | 38 +- .../unit_tests/mixin_stake_storage_test.ts | 64 +- .../unit_tests/mixin_staking_pool_rewards.ts | 180 +- .../staking/test/unit_tests/params_test.ts | 23 +- .../test/unit_tests/protocol_fees_test.ts | 189 +- .../test/unit_tests/stake_balances_test.ts | 71 +- .../staking/test/unit_tests/stake_test.ts | 256 +- .../test/unit_tests/staking_pool_test.ts | 172 +- .../test/unit_tests/staking_proxy_test.ts | 95 +- .../staking/test/unit_tests/zrx_vault_test.ts | 128 +- contracts/staking/test/utils/api_wrapper.ts | 68 +- .../cumulative_reward_tracking_simulation.ts | 57 +- contracts/test-utils/package.json | 1 + contracts/test-utils/src/index.ts | 2 +- .../test-utils/src/transaction_helper.ts | 61 +- .../tests/test/dev-utils/lib_asset_data.ts | 332 +-- .../test/dev-utils/lib_transaction_decoder.ts | 49 +- .../test/dev-utils/order_validation_utils.ts | 443 ++- contracts/utils/test/authorizable.ts | 56 +- contracts/utils/test/lib_address.ts | 4 +- contracts/utils/test/lib_address_array.ts | 38 +- contracts/utils/test/lib_bytes.ts | 223 +- contracts/utils/test/lib_eip712.ts | 11 +- contracts/utils/test/lib_rich_errors.ts | 4 +- contracts/utils/test/lib_safe_math.ts | 52 +- contracts/utils/test/log_decoding.ts | 22 +- contracts/utils/test/ownable.ts | 10 +- contracts/utils/test/reentrancy_guard.ts | 4 +- contracts/utils/test/refundable.ts | 28 +- packages/asset-buyer/src/asset_buyer.ts | 33 +- .../order_provider_response_processor.ts | 7 +- .../exchange_swap_quote_consumer.ts | 22 +- .../forwarder_swap_quote_consumer.ts | 37 +- packages/asset-swapper/src/swap_quoter.ts | 29 +- .../order_provider_response_processor.ts | 7 +- .../src/utils/swap_quote_consumer_utils.ts | 8 +- .../test/exchange_swap_quote_consumer_test.ts | 50 +- .../forwarder_swap_quote_consumer_test.ts | 58 +- .../test/swap_quote_consumer_test.ts | 26 +- .../test/swap_quote_consumer_utils_test.ts | 10 +- .../src/coordinator_wrapper.ts | 58 +- packages/contract-wrappers/src/index.ts | 3 +- .../src/utils/getAbiEncodedTransactionData.ts | 2 +- .../test/calldata_decoder_test.ts | 48 +- .../test/coordinator_wrapper_test.ts | 54 +- .../test/utils/token_utils.ts | 2 +- packages/migrations/src/migration.ts | 44 +- .../migrations/src/test_contract_configs.ts | 110 +- packages/migrations/src/testnet_migrations.ts | 132 +- ...set_balance_and_proxy_allowance_fetcher.ts | 4 +- packages/order-utils/src/signature_utils.ts | 19 +- .../test/exchange_transfer_simulator_test.ts | 20 +- ...c20_balance_and_proxy_allowance_fetcher.ts | 6 +- .../src/ts/dispense_asset_tasks.ts | 4 +- 142 files changed, 6562 insertions(+), 7407 deletions(-) diff --git a/contracts/asset-proxy/test/authorizable.ts b/contracts/asset-proxy/test/authorizable.ts index 4a7794734c..31401d281b 100644 --- a/contracts/asset-proxy/test/authorizable.ts +++ b/contracts/asset-proxy/test/authorizable.ts @@ -47,21 +47,21 @@ describe('Authorizable', () => { describe('addAuthorizedAddress', () => { it('should revert if not called by owner', async () => { await expectTransactionFailedAsync( - authorizable.addAuthorizedAddress.sendTransactionAsync(notOwner, { from: notOwner }), + authorizable.addAuthorizedAddress(notOwner).sendTransactionAsync({ from: notOwner }), RevertReason.OnlyContractOwner, ); }); it('should allow owner to add an authorized address', async () => { - await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner }); - const isAuthorized = await authorizable.authorized.callAsync(address); + await authorizable.addAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner }); + const isAuthorized = await authorizable.authorized(address).callAsync(); expect(isAuthorized).to.be.true(); }); it('should revert if owner attempts to authorize a duplicate address', async () => { - await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner }); + await authorizable.addAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner }); return expectTransactionFailedAsync( - authorizable.addAuthorizedAddress.sendTransactionAsync(address, { from: owner }), + authorizable.addAuthorizedAddress(address).sendTransactionAsync({ from: owner }), RevertReason.TargetAlreadyAuthorized, ); }); @@ -69,23 +69,23 @@ describe('Authorizable', () => { describe('removeAuthorizedAddress', () => { it('should revert if not called by owner', async () => { - await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner }); + await authorizable.addAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner }); await expectTransactionFailedAsync( - authorizable.removeAuthorizedAddress.sendTransactionAsync(address, { from: notOwner }), + authorizable.removeAuthorizedAddress(address).sendTransactionAsync({ from: notOwner }), RevertReason.OnlyContractOwner, ); }); it('should allow owner to remove an authorized address', async () => { - await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner }); - await authorizable.removeAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner }); - const isAuthorized = await authorizable.authorized.callAsync(address); + await authorizable.addAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner }); + await authorizable.removeAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner }); + const isAuthorized = await authorizable.authorized(address).callAsync(); expect(isAuthorized).to.be.false(); }); it('should revert if owner attempts to remove an address that is not authorized', async () => { return expectTransactionFailedAsync( - authorizable.removeAuthorizedAddress.sendTransactionAsync(address, { + authorizable.removeAuthorizedAddress(address).sendTransactionAsync({ from: owner, }), RevertReason.TargetNotAuthorized, @@ -95,10 +95,10 @@ describe('Authorizable', () => { describe('removeAuthorizedAddressAtIndex', () => { it('should revert if not called by owner', async () => { - await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner }); + await authorizable.addAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner }); const index = new BigNumber(0); await expectTransactionFailedAsync( - authorizable.removeAuthorizedAddressAtIndex.sendTransactionAsync(address, index, { + authorizable.removeAuthorizedAddressAtIndex(address, index).sendTransactionAsync({ from: notOwner, }), RevertReason.OnlyContractOwner, @@ -106,10 +106,10 @@ describe('Authorizable', () => { }); it('should revert if index is >= authorities.length', async () => { - await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner }); + await authorizable.addAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner }); const index = new BigNumber(1); return expectTransactionFailedAsync( - authorizable.removeAuthorizedAddressAtIndex.sendTransactionAsync(address, index, { + authorizable.removeAuthorizedAddressAtIndex(address, index).sendTransactionAsync({ from: owner, }), RevertReason.IndexOutOfBounds, @@ -119,7 +119,7 @@ describe('Authorizable', () => { it('should revert if owner attempts to remove an address that is not authorized', async () => { const index = new BigNumber(0); return expectTransactionFailedAsync( - authorizable.removeAuthorizedAddressAtIndex.sendTransactionAsync(address, index, { + authorizable.removeAuthorizedAddressAtIndex(address, index).sendTransactionAsync({ from: owner, }), RevertReason.TargetNotAuthorized, @@ -129,11 +129,11 @@ describe('Authorizable', () => { it('should revert if address at index does not match target', async () => { const address1 = address; const address2 = notOwner; - await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address1, { from: owner }); - await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address2, { from: owner }); + await authorizable.addAuthorizedAddress(address1).awaitTransactionSuccessAsync({ from: owner }); + await authorizable.addAuthorizedAddress(address2).awaitTransactionSuccessAsync({ from: owner }); const address1Index = new BigNumber(0); return expectTransactionFailedAsync( - authorizable.removeAuthorizedAddressAtIndex.sendTransactionAsync(address2, address1Index, { + authorizable.removeAuthorizedAddressAtIndex(address2, address1Index).sendTransactionAsync({ from: owner, }), RevertReason.AuthorizedAddressMismatch, @@ -141,26 +141,26 @@ describe('Authorizable', () => { }); it('should allow owner to remove an authorized address', async () => { - await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner }); + await authorizable.addAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner }); const index = new BigNumber(0); - await authorizable.removeAuthorizedAddressAtIndex.awaitTransactionSuccessAsync(address, index, { + await authorizable.removeAuthorizedAddressAtIndex(address, index).awaitTransactionSuccessAsync({ from: owner, }); - const isAuthorized = await authorizable.authorized.callAsync(address); + const isAuthorized = await authorizable.authorized(address).callAsync(); expect(isAuthorized).to.be.false(); }); }); describe('getAuthorizedAddresses', () => { it('should return all authorized addresses', async () => { - const initial = await authorizable.getAuthorizedAddresses.callAsync(); + const initial = await authorizable.getAuthorizedAddresses().callAsync(); expect(initial).to.have.length(0); - await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner }); - const afterAdd = await authorizable.getAuthorizedAddresses.callAsync(); + await authorizable.addAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner }); + const afterAdd = await authorizable.getAuthorizedAddresses().callAsync(); expect(afterAdd).to.have.length(1); expect(afterAdd).to.include(address); - await authorizable.removeAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner }); - const afterRemove = await authorizable.getAuthorizedAddresses.callAsync(); + await authorizable.removeAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner }); + const afterRemove = await authorizable.getAuthorizedAddresses().callAsync(); expect(afterRemove).to.have.length(0); }); }); diff --git a/contracts/asset-proxy/test/erc1155_proxy.ts b/contracts/asset-proxy/test/erc1155_proxy.ts index 82c410a184..015b2bd44f 100644 --- a/contracts/asset-proxy/test/erc1155_proxy.ts +++ b/contracts/asset-proxy/test/erc1155_proxy.ts @@ -74,8 +74,8 @@ describe('ERC1155Proxy', () => { const usedAddresses = ([owner, notAuthorized, authorized, spender, receiver] = _.slice(accounts, 0, 5)); erc1155ProxyWrapper = new ERC1155ProxyWrapper(provider, usedAddresses, owner); erc1155Proxy = await erc1155ProxyWrapper.deployProxyAsync(); - await erc1155Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(authorized, { from: owner }); - await erc1155Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(erc1155Proxy.address, { from: owner }); + await erc1155Proxy.addAuthorizedAddress(authorized).awaitTransactionSuccessAsync({ from: owner }); + await erc1155Proxy.addAuthorizedAddress(erc1155Proxy.address).awaitTransactionSuccessAsync({ from: owner }); // deploy & configure ERC1155 tokens and receiver [erc1155Wrapper] = await erc1155ProxyWrapper.deployDummyContractsAsync(); erc1155Contract = erc1155Wrapper.getContract(); @@ -119,7 +119,7 @@ describe('ERC1155Proxy', () => { ); }); it('should have an id of 0xa7cb5fb7', async () => { - const proxyId = await erc1155Proxy.getProxyId.callAsync(); + const proxyId = await erc1155Proxy.getProxyId().callAsync(); const expectedProxyId = AssetProxyId.ERC1155; expect(proxyId).to.equal(expectedProxyId); }); @@ -634,12 +634,14 @@ describe('ERC1155Proxy', () => { return value.times(valueMultiplier); }); const erc1155ContractAddress = erc1155Wrapper.getContract().address; - const assetData = await devUtils.encodeERC1155AssetData.callAsync( - erc1155ContractAddress, - tokensToTransfer, - valuesToTransfer, - receiverCallbackData, - ); + const assetData = await devUtils + .encodeERC1155AssetData( + erc1155ContractAddress, + tokensToTransfer, + valuesToTransfer, + receiverCallbackData, + ) + .callAsync(); const extraData = '0102030405060708091001020304050607080910010203040506070809100102'; const assetDataWithExtraData = `${assetData}${extraData}`; // check balances before transfer @@ -694,14 +696,16 @@ describe('ERC1155Proxy', () => { // create token await erc1155Wrapper .getContract() - .createWithType.awaitTransactionSuccessAsync(tokenToCreate, tokenUri, { + .createWithType(tokenToCreate, tokenUri) + .awaitTransactionSuccessAsync({ from: owner, }); // mint balance for spender await erc1155Wrapper .getContract() - .mintFungible.awaitTransactionSuccessAsync(tokenToCreate, [spender], [spenderInitialBalance], { + .mintFungible(tokenToCreate, [spender], [spenderInitialBalance]) + .awaitTransactionSuccessAsync({ from: owner, }); } @@ -739,7 +743,7 @@ describe('ERC1155Proxy', () => { // hand encode optimized assetData because our tooling (based on LibAssetData.sol/encodeERC1155AssetData) does not use optimized encoding const assetDataContract = new IAssetDataContract(constants.NULL_ADDRESS, provider); - const selector = assetDataContract.ERC1155Assets.getSelector(); + const selector = assetDataContract.getSelector('ERC1155Assets'); const assetDataWithoutContractAddress = '0000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000040102030400000000000000000000000000000000000000000000000000000000'; const assetData = `${selector}000000000000000000000000${erc1155ContractAddress.substr( @@ -794,14 +798,16 @@ describe('ERC1155Proxy', () => { // create token await erc1155Wrapper .getContract() - .createWithType.awaitTransactionSuccessAsync(tokenToCreate, tokenUri, { + .createWithType(tokenToCreate, tokenUri) + .awaitTransactionSuccessAsync({ from: owner, }); // mint balance for spender await erc1155Wrapper .getContract() - .mintFungible.awaitTransactionSuccessAsync(tokenToCreate, [spender], [spenderInitialBalance], { + .mintFungible(tokenToCreate, [spender], [spenderInitialBalance]) + .awaitTransactionSuccessAsync({ from: owner, }); } @@ -847,12 +853,14 @@ describe('ERC1155Proxy', () => { const valuesToTransfer = [new BigNumber(2), new BigNumber(2)]; const valueMultiplier = new BigNumber(2); // create callback data that is the encoded version of `valuesToTransfer` - const generatedAssetData = await devUtils.encodeERC1155AssetData.callAsync( - erc1155ContractAddress, - tokensToTransfer, - valuesToTransfer, - receiverCallbackData, - ); + const generatedAssetData = await devUtils + .encodeERC1155AssetData( + erc1155ContractAddress, + tokensToTransfer, + valuesToTransfer, + receiverCallbackData, + ) + .callAsync(); // remove the function selector and contract address from check, as these change on each test const offsetToTokenIds = 74; const assetDataSelectorAndContractAddress = generatedAssetData.substr(0, offsetToTokenIds); @@ -919,14 +927,16 @@ describe('ERC1155Proxy', () => { // create token await erc1155Wrapper .getContract() - .createWithType.awaitTransactionSuccessAsync(tokenToCreate, tokenUri, { + .createWithType(tokenToCreate, tokenUri) + .awaitTransactionSuccessAsync({ from: owner, }); // mint balance for spender await erc1155Wrapper .getContract() - .mintFungible.awaitTransactionSuccessAsync(tokenToCreate, [spender], [spenderInitialBalance], { + .mintFungible(tokenToCreate, [spender], [spenderInitialBalance]) + .awaitTransactionSuccessAsync({ from: owner, }); } @@ -969,12 +979,14 @@ describe('ERC1155Proxy', () => { const valuesToTransfer = [new BigNumber(1), new BigNumber(2)]; const valueMultiplier = new BigNumber(2); // create callback data that is the encoded version of `valuesToTransfer` - const generatedAssetData = await devUtils.encodeERC1155AssetData.callAsync( - erc1155ContractAddress, - tokensToTransfer, - valuesToTransfer, - receiverCallbackData, - ); + const generatedAssetData = await devUtils + .encodeERC1155AssetData( + erc1155ContractAddress, + tokensToTransfer, + valuesToTransfer, + receiverCallbackData, + ) + .callAsync(); // remove the function selector and contract address from check, as these change on each test const offsetToTokenIds = 74; const assetDataSelectorAndContractAddress = generatedAssetData.substr(0, offsetToTokenIds); @@ -1032,12 +1044,14 @@ describe('ERC1155Proxy', () => { const valuesToTransfer = [fungibleValueToTransferLarge]; const valueMultiplier = valueMultiplierSmall; const erc1155ContractAddress = erc1155Wrapper.getContract().address; - const assetData = await devUtils.encodeERC1155AssetData.callAsync( - erc1155ContractAddress, - tokensToTransfer, - valuesToTransfer, - receiverCallbackData, - ); + const assetData = await devUtils + .encodeERC1155AssetData( + erc1155ContractAddress, + tokensToTransfer, + valuesToTransfer, + receiverCallbackData, + ) + .callAsync(); // The asset data we just generated will look like this: // a7cb5fb7 // 0x 0000000000000000000000000b1ba0af832d7c05fd64161e0db78e85978e8082 @@ -1079,12 +1093,14 @@ describe('ERC1155Proxy', () => { const valuesToTransfer = [fungibleValueToTransferLarge]; const valueMultiplier = valueMultiplierSmall; const erc1155ContractAddress = erc1155Wrapper.getContract().address; - const assetData = await devUtils.encodeERC1155AssetData.callAsync( - erc1155ContractAddress, - tokensToTransfer, - valuesToTransfer, - receiverCallbackData, - ); + const assetData = await devUtils + .encodeERC1155AssetData( + erc1155ContractAddress, + tokensToTransfer, + valuesToTransfer, + receiverCallbackData, + ) + .callAsync(); // The asset data we just generated will look like this: // a7cb5fb7 // 0x 0000000000000000000000000b1ba0af832d7c05fd64161e0db78e85978e8082 @@ -1130,12 +1146,14 @@ describe('ERC1155Proxy', () => { const valuesToTransfer = [fungibleValueToTransferLarge]; const valueMultiplier = valueMultiplierSmall; const erc1155ContractAddress = erc1155Wrapper.getContract().address; - const assetData = await devUtils.encodeERC1155AssetData.callAsync( - erc1155ContractAddress, - tokensToTransfer, - valuesToTransfer, - receiverCallbackData, - ); + const assetData = await devUtils + .encodeERC1155AssetData( + erc1155ContractAddress, + tokensToTransfer, + valuesToTransfer, + receiverCallbackData, + ) + .callAsync(); // The asset data we just generated will look like this: // a7cb5fb7 // 0x 0000000000000000000000000b1ba0af832d7c05fd64161e0db78e85978e8082 @@ -1181,12 +1199,14 @@ describe('ERC1155Proxy', () => { const valuesToTransfer = [fungibleValueToTransferLarge]; const valueMultiplier = valueMultiplierSmall; const erc1155ContractAddress = erc1155Wrapper.getContract().address; - const assetData = await devUtils.encodeERC1155AssetData.callAsync( - erc1155ContractAddress, - tokensToTransfer, - valuesToTransfer, - receiverCallbackData, - ); + const assetData = await devUtils + .encodeERC1155AssetData( + erc1155ContractAddress, + tokensToTransfer, + valuesToTransfer, + receiverCallbackData, + ) + .callAsync(); // The asset data we just generated will look like this: // a7cb5fb7 // 0x 0000000000000000000000000b1ba0af832d7c05fd64161e0db78e85978e8082 @@ -1232,12 +1252,14 @@ describe('ERC1155Proxy', () => { const valuesToTransfer = [fungibleValueToTransferLarge]; const valueMultiplier = valueMultiplierSmall; const erc1155ContractAddress = erc1155Wrapper.getContract().address; - const assetData = await devUtils.encodeERC1155AssetData.callAsync( - erc1155ContractAddress, - tokensToTransfer, - valuesToTransfer, - receiverCallbackData, - ); + const assetData = await devUtils + .encodeERC1155AssetData( + erc1155ContractAddress, + tokensToTransfer, + valuesToTransfer, + receiverCallbackData, + ) + .callAsync(); // The asset data we just generated will look like this: // a7cb5fb7 // 0x 0000000000000000000000000b1ba0af832d7c05fd64161e0db78e85978e8082 @@ -1284,12 +1306,14 @@ describe('ERC1155Proxy', () => { const valuesToTransfer = [fungibleValueToTransferLarge]; const valueMultiplier = valueMultiplierSmall; const erc1155ContractAddress = erc1155Wrapper.getContract().address; - const assetData = await devUtils.encodeERC1155AssetData.callAsync( - erc1155ContractAddress, - tokensToTransfer, - valuesToTransfer, - receiverCallbackData, - ); + const assetData = await devUtils + .encodeERC1155AssetData( + erc1155ContractAddress, + tokensToTransfer, + valuesToTransfer, + receiverCallbackData, + ) + .callAsync(); // The asset data we just generated will look like this: // a7cb5fb7 // 0x 0000000000000000000000000b1ba0af832d7c05fd64161e0db78e85978e8082 @@ -1331,12 +1355,14 @@ describe('ERC1155Proxy', () => { const valuesToTransfer = [fungibleValueToTransferLarge]; const valueMultiplier = valueMultiplierSmall; const erc1155ContractAddress = erc1155Wrapper.getContract().address; - const assetData = await devUtils.encodeERC1155AssetData.callAsync( - erc1155ContractAddress, - tokensToTransfer, - valuesToTransfer, - receiverCallbackData, - ); + const assetData = await devUtils + .encodeERC1155AssetData( + erc1155ContractAddress, + tokensToTransfer, + valuesToTransfer, + receiverCallbackData, + ) + .callAsync(); // The asset data we just generated will look like this: // a7cb5fb7 // 0x 0000000000000000000000000b1ba0af832d7c05fd64161e0db78e85978e8082 @@ -1382,12 +1408,14 @@ describe('ERC1155Proxy', () => { const valuesToTransfer = [fungibleValueToTransferLarge]; const valueMultiplier = valueMultiplierSmall; const erc1155ContractAddress = erc1155Wrapper.getContract().address; - const assetData = await devUtils.encodeERC1155AssetData.callAsync( - erc1155ContractAddress, - tokensToTransfer, - valuesToTransfer, - receiverCallbackData, - ); + const assetData = await devUtils + .encodeERC1155AssetData( + erc1155ContractAddress, + tokensToTransfer, + valuesToTransfer, + receiverCallbackData, + ) + .callAsync(); // The asset data we just generated will look like this: // a7cb5fb7 // 0x 0000000000000000000000000b1ba0af832d7c05fd64161e0db78e85978e8082 @@ -1429,12 +1457,14 @@ describe('ERC1155Proxy', () => { const valuesToTransfer = [fungibleValueToTransferLarge]; const valueMultiplier = valueMultiplierSmall; const erc1155ContractAddress = erc1155Wrapper.getContract().address; - const assetData = await devUtils.encodeERC1155AssetData.callAsync( - erc1155ContractAddress, - tokensToTransfer, - valuesToTransfer, - receiverCallbackData, - ); + const assetData = await devUtils + .encodeERC1155AssetData( + erc1155ContractAddress, + tokensToTransfer, + valuesToTransfer, + receiverCallbackData, + ) + .callAsync(); // The asset data we just generated will look like this: // a7cb5fb7 // 0x 0000000000000000000000000b1ba0af832d7c05fd64161e0db78e85978e8082 @@ -1480,12 +1510,14 @@ describe('ERC1155Proxy', () => { const valuesToTransfer = [fungibleValueToTransferLarge]; const valueMultiplier = valueMultiplierSmall; const erc1155ContractAddress = erc1155Wrapper.getContract().address; - const assetData = await devUtils.encodeERC1155AssetData.callAsync( - erc1155ContractAddress, - tokensToTransfer, - valuesToTransfer, - receiverCallbackData, - ); + const assetData = await devUtils + .encodeERC1155AssetData( + erc1155ContractAddress, + tokensToTransfer, + valuesToTransfer, + receiverCallbackData, + ) + .callAsync(); const txData = await erc1155ProxyWrapper.getTransferFromAbiEncodedTxDataAsync( spender, receiverContract, @@ -1511,12 +1543,14 @@ describe('ERC1155Proxy', () => { const valuesToTransfer = [fungibleValueToTransferLarge]; const valueMultiplier = valueMultiplierSmall; const erc1155ContractAddress = erc1155Wrapper.getContract().address; - const assetData = await devUtils.encodeERC1155AssetData.callAsync( - erc1155ContractAddress, - tokensToTransfer, - valuesToTransfer, - receiverCallbackData, - ); + const assetData = await devUtils + .encodeERC1155AssetData( + erc1155ContractAddress, + tokensToTransfer, + valuesToTransfer, + receiverCallbackData, + ) + .callAsync(); const txData = await erc1155ProxyWrapper.getTransferFromAbiEncodedTxDataAsync( spender, receiverContract, @@ -1640,7 +1674,7 @@ describe('ERC1155Proxy', () => { it('should propagate revert reason from erc1155 contract failure', async () => { // disable transfers const shouldRejectTransfer = true; - await erc1155Receiver.setRejectTransferFlag.awaitTransactionSuccessAsync(shouldRejectTransfer, { + await erc1155Receiver.setRejectTransferFlag(shouldRejectTransfer).awaitTransactionSuccessAsync({ from: owner, }); // setup test parameters diff --git a/contracts/asset-proxy/test/erc20bridge_proxy.ts b/contracts/asset-proxy/test/erc20bridge_proxy.ts index 358b0038b2..ef25b78a50 100644 --- a/contracts/asset-proxy/test/erc20bridge_proxy.ts +++ b/contracts/asset-proxy/test/erc20bridge_proxy.ts @@ -44,8 +44,8 @@ blockchainTests.resets('ERC20BridgeProxy unit tests', env => { env.txDefaults, artifacts, ); - testTokenAddress = await bridgeContract.testToken.callAsync(); - await assetProxy.addAuthorizedAddress.awaitTransactionSuccessAsync(owner); + testTokenAddress = await bridgeContract.testToken().callAsync(); + await assetProxy.addAuthorizedAddress(owner).awaitTransactionSuccessAsync(); }); interface AssetDataOpts { @@ -102,7 +102,7 @@ blockchainTests.resets('ERC20BridgeProxy unit tests', env => { } async function setTestTokenBalanceAsync(_owner: string, balance: Numberish): Promise { - await bridgeContract.setTestTokenBalance.awaitTransactionSuccessAsync(_owner, new BigNumber(balance)); + await bridgeContract.setTestTokenBalance(_owner, new BigNumber(balance)).awaitTransactionSuccessAsync(); } describe('transferFrom()', () => { @@ -132,13 +132,9 @@ blockchainTests.resets('ERC20BridgeProxy unit tests', env => { async function transferFromAsync(opts?: Partial, caller?: string): Promise { const _opts = createTransferFromOpts(opts); - const { logs } = await assetProxy.transferFrom.awaitTransactionSuccessAsync( - encodeAssetData(_opts.assetData), - _opts.from, - _opts.to, - new BigNumber(_opts.amount), - { from: caller }, - ); + const { logs } = await assetProxy + .transferFrom(encodeAssetData(_opts.assetData), _opts.from, _opts.to, new BigNumber(_opts.amount)) + .awaitTransactionSuccessAsync({ from: caller }); return (logs as any) as DecodedLogs; } @@ -180,12 +176,9 @@ blockchainTests.resets('ERC20BridgeProxy unit tests', env => { it('fails if asset data is truncated', async () => { const opts = createTransferFromOpts(); const truncatedAssetData = hexSlice(encodeAssetData(opts.assetData), 0, -1); - const tx = assetProxy.transferFrom.awaitTransactionSuccessAsync( - truncatedAssetData, - opts.from, - opts.to, - new BigNumber(opts.amount), - ); + const tx = assetProxy + .transferFrom(truncatedAssetData, opts.from, opts.to, new BigNumber(opts.amount)) + .awaitTransactionSuccessAsync(); return expect(tx).to.be.rejected(); }); @@ -281,18 +274,18 @@ blockchainTests.resets('ERC20BridgeProxy unit tests', env => { it('retrieves the balance of the encoded token', async () => { const _owner = randomAddress(); const balance = getRandomInteger(1, 100e18); - await bridgeContract.setTestTokenBalance.awaitTransactionSuccessAsync(_owner, balance); + await bridgeContract.setTestTokenBalance(_owner, balance).awaitTransactionSuccessAsync(); const assetData = createAssetData({ tokenAddress: testTokenAddress, }); - const actualBalance = await assetProxy.balanceOf.callAsync(encodeAssetData(assetData), _owner); + const actualBalance = await assetProxy.balanceOf(encodeAssetData(assetData), _owner).callAsync(); expect(actualBalance).to.bignumber.eq(balance); }); }); describe('getProxyId()', () => { it('returns the correct proxy ID', async () => { - const proxyId = await assetProxy.getProxyId.callAsync(); + const proxyId = await assetProxy.getProxyId().callAsync(); expect(proxyId).to.eq(PROXY_ID); }); }); diff --git a/contracts/asset-proxy/test/eth2dai_bridge.ts b/contracts/asset-proxy/test/eth2dai_bridge.ts index 2cf0173239..4af06f95a8 100644 --- a/contracts/asset-proxy/test/eth2dai_bridge.ts +++ b/contracts/asset-proxy/test/eth2dai_bridge.ts @@ -8,7 +8,7 @@ import { hexRandom, Numberish, randomAddress, - TransactionHelper, + transactionHelper, } from '@0x/contracts-test-utils'; import { AssetProxyId } from '@0x/types'; import { BigNumber, RawRevertError } from '@0x/utils'; @@ -25,7 +25,6 @@ import { } from '../src'; blockchainTests.resets('Eth2DaiBridge unit tests', env => { - const txHelper = new TransactionHelper(env.web3Wrapper, artifacts); let testContract: TestEth2DaiBridgeContract; before(async () => { @@ -40,7 +39,7 @@ blockchainTests.resets('Eth2DaiBridge unit tests', env => { describe('isValidSignature()', () => { it('returns success bytes', async () => { const LEGACY_WALLET_MAGIC_VALUE = '0xb0671381'; - const result = await testContract.isValidSignature.callAsync(hexRandom(), hexRandom(_.random(0, 32))); + const result = await testContract.isValidSignature(hexRandom(), hexRandom(_.random(0, 32))).callAsync(); expect(result).to.eq(LEGACY_WALLET_MAGIC_VALUE); }); }); @@ -80,31 +79,32 @@ blockchainTests.resets('Eth2DaiBridge unit tests', env => { async function withdrawToAsync(opts?: Partial): Promise { const _opts = createWithdrawToOpts(opts); // Set the fill behavior. - await testContract.setFillBehavior.awaitTransactionSuccessAsync( - _opts.revertReason, - new BigNumber(_opts.fillAmount), - ); + await testContract + .setFillBehavior(_opts.revertReason, new BigNumber(_opts.fillAmount)) + .awaitTransactionSuccessAsync(); // Create tokens and balances. if (_opts.fromTokenAddress === undefined) { - [_opts.fromTokenAddress] = await txHelper.getResultAndReceiptAsync( + [_opts.fromTokenAddress] = await transactionHelper.getResultAndReceiptAsync( testContract.createToken, new BigNumber(_opts.fromTokenBalance), ); } if (_opts.toTokenAddress === undefined) { - [_opts.toTokenAddress] = await txHelper.getResultAndReceiptAsync( + [_opts.toTokenAddress] = await transactionHelper.getResultAndReceiptAsync( testContract.createToken, constants.ZERO_AMOUNT, ); } // Set the transfer behavior of `toTokenAddress`. - await testContract.setTransferBehavior.awaitTransactionSuccessAsync( - _opts.toTokenAddress, - _opts.toTokentransferRevertReason, - _opts.toTokenTransferReturnData, - ); + await testContract + .setTransferBehavior( + _opts.toTokenAddress, + _opts.toTokentransferRevertReason, + _opts.toTokenTransferReturnData, + ) + .awaitTransactionSuccessAsync(); // Call bridgeTransferFrom(). - const [result, { logs }] = await txHelper.getResultAndReceiptAsync( + const [result, { logs }] = await transactionHelper.getResultAndReceiptAsync( testContract.bridgeTransferFrom, // "to" token address _opts.toTokenAddress, diff --git a/contracts/asset-proxy/test/proxies.ts b/contracts/asset-proxy/test/proxies.ts index 232b085086..9de496ec3e 100644 --- a/contracts/asset-proxy/test/proxies.ts +++ b/contracts/asset-proxy/test/proxies.ts @@ -107,24 +107,24 @@ describe('Asset Transfer Proxies', () => { ); // Configure ERC20Proxy - await erc20Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(authorized, { from: owner }); - await erc20Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(multiAssetProxy.address, { from: owner }); + await erc20Proxy.addAuthorizedAddress(authorized).awaitTransactionSuccessAsync({ from: owner }); + await erc20Proxy.addAuthorizedAddress(multiAssetProxy.address).awaitTransactionSuccessAsync({ from: owner }); // Configure ERC721Proxy - await erc721Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(authorized, { from: owner }); - await erc721Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(multiAssetProxy.address, { from: owner }); + await erc721Proxy.addAuthorizedAddress(authorized).awaitTransactionSuccessAsync({ from: owner }); + await erc721Proxy.addAuthorizedAddress(multiAssetProxy.address).awaitTransactionSuccessAsync({ from: owner }); // Configure ERC115Proxy erc1155ProxyWrapper = new ERC1155ProxyWrapper(provider, usedAddresses, owner); erc1155Proxy = await erc1155ProxyWrapper.deployProxyAsync(); - await erc1155Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(authorized, { from: owner }); - await erc1155Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(multiAssetProxy.address, { from: owner }); + await erc1155Proxy.addAuthorizedAddress(authorized).awaitTransactionSuccessAsync({ from: owner }); + await erc1155Proxy.addAuthorizedAddress(multiAssetProxy.address).awaitTransactionSuccessAsync({ from: owner }); // Configure MultiAssetProxy - await multiAssetProxy.addAuthorizedAddress.awaitTransactionSuccessAsync(authorized, { from: owner }); - await multiAssetProxy.registerAssetProxy.awaitTransactionSuccessAsync(erc20Proxy.address, { from: owner }); - await multiAssetProxy.registerAssetProxy.awaitTransactionSuccessAsync(erc721Proxy.address, { from: owner }); - await multiAssetProxy.registerAssetProxy.awaitTransactionSuccessAsync(erc1155Proxy.address, { from: owner }); + await multiAssetProxy.addAuthorizedAddress(authorized).awaitTransactionSuccessAsync({ from: owner }); + await multiAssetProxy.registerAssetProxy(erc20Proxy.address).awaitTransactionSuccessAsync({ from: owner }); + await multiAssetProxy.registerAssetProxy(erc721Proxy.address).awaitTransactionSuccessAsync({ from: owner }); + await multiAssetProxy.registerAssetProxy(erc1155Proxy.address).awaitTransactionSuccessAsync({ from: owner }); // Deploy and configure ERC20 tokens const numDummyErc20ToDeploy = 2; @@ -154,26 +154,20 @@ describe('Asset Transfer Proxies', () => { ); await erc20Wrapper.setBalancesAndAllowancesAsync(); - await noReturnErc20Token.setBalance.awaitTransactionSuccessAsync(fromAddress, constants.INITIAL_ERC20_BALANCE, { + await noReturnErc20Token.setBalance(fromAddress, constants.INITIAL_ERC20_BALANCE).awaitTransactionSuccessAsync({ from: owner, }); - await noReturnErc20Token.approve.awaitTransactionSuccessAsync( - erc20Proxy.address, - constants.INITIAL_ERC20_ALLOWANCE, - { from: fromAddress }, - ); - await multipleReturnErc20Token.setBalance.awaitTransactionSuccessAsync( - fromAddress, - constants.INITIAL_ERC20_BALANCE, - { + await noReturnErc20Token + .approve(erc20Proxy.address, constants.INITIAL_ERC20_ALLOWANCE) + .awaitTransactionSuccessAsync({ from: fromAddress }); + await multipleReturnErc20Token + .setBalance(fromAddress, constants.INITIAL_ERC20_BALANCE) + .awaitTransactionSuccessAsync({ from: owner, - }, - ); - await multipleReturnErc20Token.approve.awaitTransactionSuccessAsync( - erc20Proxy.address, - constants.INITIAL_ERC20_ALLOWANCE, - { from: fromAddress }, - ); + }); + await multipleReturnErc20Token + .approve(erc20Proxy.address, constants.INITIAL_ERC20_ALLOWANCE) + .awaitTransactionSuccessAsync({ from: fromAddress }); // Deploy and configure ERC721 tokens and receiver [erc721TokenA, erc721TokenB] = await erc721Wrapper.deployDummyTokensAsync(); @@ -225,23 +219,20 @@ describe('Asset Transfer Proxies', () => { ); }); it('should have an id of 0xf47261b0', async () => { - const proxyId = await erc20Proxy.getProxyId.callAsync(); + const proxyId = await erc20Proxy.getProxyId().callAsync(); const expectedProxyId = '0xf47261b0'; expect(proxyId).to.equal(expectedProxyId); }); describe('transferFrom', () => { it('should successfully transfer tokens', async () => { // Construct ERC20 asset data - const encodedAssetData = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); + const encodedAssetData = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); // Perform a transfer from fromAddress to toAddress const erc20Balances = await erc20Wrapper.getBalancesAsync(); const amount = new BigNumber(10); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - encodedAssetData, - fromAddress, - toAddress, - amount, - ); + const data = assetProxyInterface + .transferFrom(encodedAssetData, fromAddress, toAddress, amount) + .getABIEncodedTransactionData(); await web3Wrapper.awaitTransactionSuccessAsync( await web3Wrapper.sendTransactionAsync({ to: erc20Proxy.address, @@ -262,17 +253,14 @@ describe('Asset Transfer Proxies', () => { it('should successfully transfer tokens that do not return a value', async () => { // Construct ERC20 asset data - const encodedAssetData = await devUtils.encodeERC20AssetData.callAsync(noReturnErc20Token.address); + const encodedAssetData = await devUtils.encodeERC20AssetData(noReturnErc20Token.address).callAsync(); // Perform a transfer from fromAddress to toAddress - const initialFromBalance = await noReturnErc20Token.balanceOf.callAsync(fromAddress); - const initialToBalance = await noReturnErc20Token.balanceOf.callAsync(toAddress); + const initialFromBalance = await noReturnErc20Token.balanceOf(fromAddress).callAsync(); + const initialToBalance = await noReturnErc20Token.balanceOf(toAddress).callAsync(); const amount = new BigNumber(10); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - encodedAssetData, - fromAddress, - toAddress, - amount, - ); + const data = assetProxyInterface + .transferFrom(encodedAssetData, fromAddress, toAddress, amount) + .getABIEncodedTransactionData(); await web3Wrapper.awaitTransactionSuccessAsync( await web3Wrapper.sendTransactionAsync({ to: erc20Proxy.address, @@ -282,8 +270,8 @@ describe('Asset Transfer Proxies', () => { constants.AWAIT_TRANSACTION_MINED_MS, ); // Verify transfer was successful - const newFromBalance = await noReturnErc20Token.balanceOf.callAsync(fromAddress); - const newToBalance = await noReturnErc20Token.balanceOf.callAsync(toAddress); + const newFromBalance = await noReturnErc20Token.balanceOf(fromAddress).callAsync(); + const newToBalance = await noReturnErc20Token.balanceOf(toAddress).callAsync(); expect(newFromBalance).to.be.bignumber.equal(initialFromBalance.minus(amount)); expect(newToBalance).to.be.bignumber.equal(initialToBalance.plus(amount)); }); @@ -291,18 +279,15 @@ describe('Asset Transfer Proxies', () => { it('should successfully transfer tokens and ignore extra assetData', async () => { // Construct ERC20 asset data const extraData = '0102030405060708'; - const encodedAssetData = `${await devUtils.encodeERC20AssetData.callAsync( - erc20TokenA.address, - )}${extraData}`; + const encodedAssetData = `${await devUtils + .encodeERC20AssetData(erc20TokenA.address) + .callAsync()}${extraData}`; // Perform a transfer from fromAddress to toAddress const erc20Balances = await erc20Wrapper.getBalancesAsync(); const amount = new BigNumber(10); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - encodedAssetData, - fromAddress, - toAddress, - amount, - ); + const data = assetProxyInterface + .transferFrom(encodedAssetData, fromAddress, toAddress, amount) + .getABIEncodedTransactionData(); await web3Wrapper.awaitTransactionSuccessAsync( await web3Wrapper.sendTransactionAsync({ to: erc20Proxy.address, @@ -323,16 +308,13 @@ describe('Asset Transfer Proxies', () => { it('should do nothing if transferring 0 amount of a token', async () => { // Construct ERC20 asset data - const encodedAssetData = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); + const encodedAssetData = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); // Perform a transfer from fromAddress to toAddress const erc20Balances = await erc20Wrapper.getBalancesAsync(); const amount = new BigNumber(0); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - encodedAssetData, - fromAddress, - toAddress, - amount, - ); + const data = assetProxyInterface + .transferFrom(encodedAssetData, fromAddress, toAddress, amount) + .getABIEncodedTransactionData(); await web3Wrapper.awaitTransactionSuccessAsync( await web3Wrapper.sendTransactionAsync({ to: erc20Proxy.address, @@ -353,17 +335,14 @@ describe('Asset Transfer Proxies', () => { it('should revert if allowances are too low', async () => { // Construct ERC20 asset data - const encodedAssetData = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); + const encodedAssetData = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); // Create allowance less than transfer amount. Set allowance on proxy. const allowance = new BigNumber(0); const amount = new BigNumber(10); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - encodedAssetData, - fromAddress, - toAddress, - amount, - ); - await erc20TokenA.approve.awaitTransactionSuccessAsync(erc20Proxy.address, allowance, { + const data = assetProxyInterface + .transferFrom(encodedAssetData, fromAddress, toAddress, amount) + .getABIEncodedTransactionData(); + await erc20TokenA.approve(erc20Proxy.address, allowance).awaitTransactionSuccessAsync({ from: fromAddress, }); const erc20Balances = await erc20Wrapper.getBalancesAsync(); @@ -382,21 +361,18 @@ describe('Asset Transfer Proxies', () => { it('should revert if allowances are too low and token does not return a value', async () => { // Construct ERC20 asset data - const encodedAssetData = await devUtils.encodeERC20AssetData.callAsync(noReturnErc20Token.address); + const encodedAssetData = await devUtils.encodeERC20AssetData(noReturnErc20Token.address).callAsync(); // Create allowance less than transfer amount. Set allowance on proxy. const allowance = new BigNumber(0); const amount = new BigNumber(10); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - encodedAssetData, - fromAddress, - toAddress, - amount, - ); - await noReturnErc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, allowance, { + const data = assetProxyInterface + .transferFrom(encodedAssetData, fromAddress, toAddress, amount) + .getABIEncodedTransactionData(); + await noReturnErc20Token.approve(erc20Proxy.address, allowance).awaitTransactionSuccessAsync({ from: fromAddress, }); - const initialFromBalance = await noReturnErc20Token.balanceOf.callAsync(fromAddress); - const initialToBalance = await noReturnErc20Token.balanceOf.callAsync(toAddress); + const initialFromBalance = await noReturnErc20Token.balanceOf(fromAddress).callAsync(); + const initialToBalance = await noReturnErc20Token.balanceOf(toAddress).callAsync(); // Perform a transfer; expect this to fail. await expectTransactionFailedAsync( web3Wrapper.sendTransactionAsync({ @@ -406,23 +382,20 @@ describe('Asset Transfer Proxies', () => { }), RevertReason.TransferFailed, ); - const newFromBalance = await noReturnErc20Token.balanceOf.callAsync(fromAddress); - const newToBalance = await noReturnErc20Token.balanceOf.callAsync(toAddress); + const newFromBalance = await noReturnErc20Token.balanceOf(fromAddress).callAsync(); + const newToBalance = await noReturnErc20Token.balanceOf(toAddress).callAsync(); expect(newFromBalance).to.be.bignumber.equal(initialFromBalance); expect(newToBalance).to.be.bignumber.equal(initialToBalance); }); it('should revert if caller is not authorized', async () => { // Construct ERC20 asset data - const encodedAssetData = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); + const encodedAssetData = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); // Perform a transfer from fromAddress to toAddress const amount = new BigNumber(10); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - encodedAssetData, - fromAddress, - toAddress, - amount, - ); + const data = assetProxyInterface + .transferFrom(encodedAssetData, fromAddress, toAddress, amount) + .getABIEncodedTransactionData(); const erc20Balances = await erc20Wrapper.getBalancesAsync(); await expectTransactionFailedAsync( web3Wrapper.sendTransactionAsync({ @@ -438,18 +411,15 @@ describe('Asset Transfer Proxies', () => { it('should revert if token returns more than 32 bytes', async () => { // Construct ERC20 asset data - const encodedAssetData = await devUtils.encodeERC20AssetData.callAsync( - multipleReturnErc20Token.address, - ); + const encodedAssetData = await devUtils + .encodeERC20AssetData(multipleReturnErc20Token.address) + .callAsync(); const amount = new BigNumber(10); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - encodedAssetData, - fromAddress, - toAddress, - amount, - ); - const initialFromBalance = await multipleReturnErc20Token.balanceOf.callAsync(fromAddress); - const initialToBalance = await multipleReturnErc20Token.balanceOf.callAsync(toAddress); + const data = assetProxyInterface + .transferFrom(encodedAssetData, fromAddress, toAddress, amount) + .getABIEncodedTransactionData(); + const initialFromBalance = await multipleReturnErc20Token.balanceOf(fromAddress).callAsync(); + const initialToBalance = await multipleReturnErc20Token.balanceOf(toAddress).callAsync(); // Perform a transfer; expect this to fail. await expectTransactionFailedAsync( web3Wrapper.sendTransactionAsync({ @@ -459,8 +429,8 @@ describe('Asset Transfer Proxies', () => { }), RevertReason.TransferFailed, ); - const newFromBalance = await multipleReturnErc20Token.balanceOf.callAsync(fromAddress); - const newToBalance = await multipleReturnErc20Token.balanceOf.callAsync(toAddress); + const newFromBalance = await multipleReturnErc20Token.balanceOf(fromAddress).callAsync(); + const newToBalance = await multipleReturnErc20Token.balanceOf(toAddress).callAsync(); expect(newFromBalance).to.be.bignumber.equal(initialFromBalance); expect(newToBalance).to.be.bignumber.equal(initialToBalance); }); @@ -480,28 +450,24 @@ describe('Asset Transfer Proxies', () => { ); }); it('should have an id of 0x02571792', async () => { - const proxyId = await erc721Proxy.getProxyId.callAsync(); + const proxyId = await erc721Proxy.getProxyId().callAsync(); const expectedProxyId = '0x02571792'; expect(proxyId).to.equal(expectedProxyId); }); describe('transferFrom', () => { it('should successfully transfer tokens', async () => { // Construct ERC721 asset data - const encodedAssetData = await devUtils.encodeERC721AssetData.callAsync( - erc721TokenA.address, - erc721AFromTokenId, - ); + const encodedAssetData = await devUtils + .encodeERC721AssetData(erc721TokenA.address, erc721AFromTokenId) + .callAsync(); // Verify pre-condition - const ownerFromAsset = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId); + const ownerFromAsset = await erc721TokenA.ownerOf(erc721AFromTokenId).callAsync(); expect(ownerFromAsset).to.be.equal(fromAddress); // Perform a transfer from fromAddress to toAddress const amount = new BigNumber(1); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - encodedAssetData, - fromAddress, - toAddress, - amount, - ); + const data = assetProxyInterface + .transferFrom(encodedAssetData, fromAddress, toAddress, amount) + .getABIEncodedTransactionData(); await web3Wrapper.awaitTransactionSuccessAsync( await web3Wrapper.sendTransactionAsync({ to: erc721Proxy.address, @@ -511,28 +477,24 @@ describe('Asset Transfer Proxies', () => { constants.AWAIT_TRANSACTION_MINED_MS, ); // Verify transfer was successful - const newOwnerFromAsset = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId); + const newOwnerFromAsset = await erc721TokenA.ownerOf(erc721AFromTokenId).callAsync(); expect(newOwnerFromAsset).to.be.bignumber.equal(toAddress); }); it('should successfully transfer tokens and ignore extra assetData', async () => { // Construct ERC721 asset data const extraData = '0102030405060708'; - const encodedAssetData = `${await devUtils.encodeERC721AssetData.callAsync( - erc721TokenA.address, - erc721AFromTokenId, - )}${extraData}`; + const encodedAssetData = `${await devUtils + .encodeERC721AssetData(erc721TokenA.address, erc721AFromTokenId) + .callAsync()}${extraData}`; // Verify pre-condition - const ownerFromAsset = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId); + const ownerFromAsset = await erc721TokenA.ownerOf(erc721AFromTokenId).callAsync(); expect(ownerFromAsset).to.be.equal(fromAddress); // Perform a transfer from fromAddress to toAddress const amount = new BigNumber(1); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - encodedAssetData, - fromAddress, - toAddress, - amount, - ); + const data = assetProxyInterface + .transferFrom(encodedAssetData, fromAddress, toAddress, amount) + .getABIEncodedTransactionData(); await web3Wrapper.awaitTransactionSuccessAsync( await web3Wrapper.sendTransactionAsync({ to: erc721Proxy.address, @@ -542,27 +504,23 @@ describe('Asset Transfer Proxies', () => { constants.AWAIT_TRANSACTION_MINED_MS, ); // Verify transfer was successful - const newOwnerFromAsset = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId); + const newOwnerFromAsset = await erc721TokenA.ownerOf(erc721AFromTokenId).callAsync(); expect(newOwnerFromAsset).to.be.bignumber.equal(toAddress); }); it('should not call onERC721Received when transferring to a smart contract', async () => { // Construct ERC721 asset data - const encodedAssetData = await devUtils.encodeERC721AssetData.callAsync( - erc721TokenA.address, - erc721AFromTokenId, - ); + const encodedAssetData = await devUtils + .encodeERC721AssetData(erc721TokenA.address, erc721AFromTokenId) + .callAsync(); // Verify pre-condition - const ownerFromAsset = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId); + const ownerFromAsset = await erc721TokenA.ownerOf(erc721AFromTokenId).callAsync(); expect(ownerFromAsset).to.be.equal(fromAddress); // Perform a transfer from fromAddress to toAddress const amount = new BigNumber(1); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - encodedAssetData, - fromAddress, - erc721Receiver.address, - amount, - ); + const data = assetProxyInterface + .transferFrom(encodedAssetData, fromAddress, erc721Receiver.address, amount) + .getABIEncodedTransactionData(); const logDecoder = new LogDecoder(web3Wrapper, { ...artifacts, ...erc721Artifacts }); const tx = await logDecoder.getTxWithDecodedLogsAsync( await web3Wrapper.sendTransactionAsync({ @@ -575,27 +533,23 @@ describe('Asset Transfer Proxies', () => { // Verify that no log was emitted by erc721 receiver expect(tx.logs.length).to.be.equal(1); // Verify transfer was successful - const newOwnerFromAsset = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId); + const newOwnerFromAsset = await erc721TokenA.ownerOf(erc721AFromTokenId).callAsync(); expect(newOwnerFromAsset).to.be.bignumber.equal(erc721Receiver.address); }); it('should revert if transferring 0 amount of a token', async () => { // Construct ERC721 asset data - const encodedAssetData = await devUtils.encodeERC721AssetData.callAsync( - erc721TokenA.address, - erc721AFromTokenId, - ); + const encodedAssetData = await devUtils + .encodeERC721AssetData(erc721TokenA.address, erc721AFromTokenId) + .callAsync(); // Verify pre-condition - const ownerFromAsset = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId); + const ownerFromAsset = await erc721TokenA.ownerOf(erc721AFromTokenId).callAsync(); expect(ownerFromAsset).to.be.equal(fromAddress); // Perform a transfer from fromAddress to toAddress const amount = new BigNumber(0); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - encodedAssetData, - fromAddress, - toAddress, - amount, - ); + const data = assetProxyInterface + .transferFrom(encodedAssetData, fromAddress, toAddress, amount) + .getABIEncodedTransactionData(); await expectTransactionFailedAsync( web3Wrapper.sendTransactionAsync({ to: erc721Proxy.address, @@ -604,27 +558,23 @@ describe('Asset Transfer Proxies', () => { }), RevertReason.InvalidAmount, ); - const newOwner = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId); + const newOwner = await erc721TokenA.ownerOf(erc721AFromTokenId).callAsync(); expect(newOwner).to.be.equal(ownerFromAsset); }); it('should revert if transferring > 1 amount of a token', async () => { // Construct ERC721 asset data - const encodedAssetData = await devUtils.encodeERC721AssetData.callAsync( - erc721TokenA.address, - erc721AFromTokenId, - ); + const encodedAssetData = await devUtils + .encodeERC721AssetData(erc721TokenA.address, erc721AFromTokenId) + .callAsync(); // Verify pre-condition - const ownerFromAsset = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId); + const ownerFromAsset = await erc721TokenA.ownerOf(erc721AFromTokenId).callAsync(); expect(ownerFromAsset).to.be.equal(fromAddress); // Perform a transfer from fromAddress to toAddress const amount = new BigNumber(500); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - encodedAssetData, - fromAddress, - toAddress, - amount, - ); + const data = assetProxyInterface + .transferFrom(encodedAssetData, fromAddress, toAddress, amount) + .getABIEncodedTransactionData(); await expectTransactionFailedAsync( web3Wrapper.sendTransactionAsync({ to: erc721Proxy.address, @@ -633,35 +583,31 @@ describe('Asset Transfer Proxies', () => { }), RevertReason.InvalidAmount, ); - const newOwner = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId); + const newOwner = await erc721TokenA.ownerOf(erc721AFromTokenId).callAsync(); expect(newOwner).to.be.equal(ownerFromAsset); }); it('should revert if allowances are too low', async () => { // Construct ERC721 asset data - const encodedAssetData = await devUtils.encodeERC721AssetData.callAsync( - erc721TokenA.address, - erc721AFromTokenId, - ); + const encodedAssetData = await devUtils + .encodeERC721AssetData(erc721TokenA.address, erc721AFromTokenId) + .callAsync(); // Verify pre-condition - const ownerFromAsset = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId); + const ownerFromAsset = await erc721TokenA.ownerOf(erc721AFromTokenId).callAsync(); expect(ownerFromAsset).to.be.equal(fromAddress); // Remove blanket transfer approval for fromAddress. - await erc721TokenA.setApprovalForAll.awaitTransactionSuccessAsync(erc721Proxy.address, false, { + await erc721TokenA.setApprovalForAll(erc721Proxy.address, false).awaitTransactionSuccessAsync({ from: fromAddress, }); // Remove token transfer approval for fromAddress. - await erc721TokenA.approve.awaitTransactionSuccessAsync(constants.NULL_ADDRESS, erc721AFromTokenId, { + await erc721TokenA.approve(constants.NULL_ADDRESS, erc721AFromTokenId).awaitTransactionSuccessAsync({ from: fromAddress, }); // Perform a transfer; expect this to fail. const amount = new BigNumber(1); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - encodedAssetData, - fromAddress, - toAddress, - amount, - ); + const data = assetProxyInterface + .transferFrom(encodedAssetData, fromAddress, toAddress, amount) + .getABIEncodedTransactionData(); await expectTransactionFailedAsync( web3Wrapper.sendTransactionAsync({ to: erc721Proxy.address, @@ -670,27 +616,23 @@ describe('Asset Transfer Proxies', () => { }), RevertReason.TransferFailed, ); - const newOwner = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId); + const newOwner = await erc721TokenA.ownerOf(erc721AFromTokenId).callAsync(); expect(newOwner).to.be.equal(ownerFromAsset); }); it('should revert if caller is not authorized', async () => { // Construct ERC721 asset data - const encodedAssetData = await devUtils.encodeERC721AssetData.callAsync( - erc721TokenA.address, - erc721AFromTokenId, - ); + const encodedAssetData = await devUtils + .encodeERC721AssetData(erc721TokenA.address, erc721AFromTokenId) + .callAsync(); // Verify pre-condition - const ownerFromAsset = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId); + const ownerFromAsset = await erc721TokenA.ownerOf(erc721AFromTokenId).callAsync(); expect(ownerFromAsset).to.be.equal(fromAddress); // Perform a transfer from fromAddress to toAddress const amount = new BigNumber(1); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - encodedAssetData, - fromAddress, - toAddress, - amount, - ); + const data = assetProxyInterface + .transferFrom(encodedAssetData, fromAddress, toAddress, amount) + .getABIEncodedTransactionData(); await expectTransactionFailedAsync( web3Wrapper.sendTransactionAsync({ to: erc721Proxy.address, @@ -699,7 +641,7 @@ describe('Asset Transfer Proxies', () => { }), RevertReason.SenderNotAuthorized, ); - const newOwner = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId); + const newOwner = await erc721TokenA.ownerOf(erc721AFromTokenId).callAsync(); expect(newOwner).to.be.equal(ownerFromAsset); }); }); @@ -717,7 +659,7 @@ describe('Asset Transfer Proxies', () => { ); }); it('should have an id of 0x94cfcdd7', async () => { - const proxyId = await multiAssetProxy.getProxyId.callAsync(); + const proxyId = await multiAssetProxy.getProxyId().callAsync(); // first 4 bytes of `keccak256('MultiAsset(uint256[],bytes[])')` const expectedProxyId = '0x94cfcdd7'; expect(proxyId).to.equal(expectedProxyId); @@ -726,16 +668,13 @@ describe('Asset Transfer Proxies', () => { it('should transfer a single ERC20 token', async () => { const inputAmount = new BigNumber(1); const erc20Amount = new BigNumber(10); - const erc20AssetData = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); + const erc20AssetData = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); const amounts = [erc20Amount]; const nestedAssetData = [erc20AssetData]; - const assetData = await devUtils.encodeMultiAssetData.callAsync(amounts, nestedAssetData); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - assetData, - fromAddress, - toAddress, - inputAmount, - ); + const assetData = await devUtils.encodeMultiAssetData(amounts, nestedAssetData).callAsync(); + const data = assetProxyInterface + .transferFrom(assetData, fromAddress, toAddress, inputAmount) + .getABIEncodedTransactionData(); const erc20Balances = await erc20Wrapper.getBalancesAsync(); await web3Wrapper.awaitTransactionSuccessAsync( await web3Wrapper.sendTransactionAsync({ @@ -757,16 +696,15 @@ describe('Asset Transfer Proxies', () => { it('should dispatch an ERC20 transfer when input amount is 0', async () => { const inputAmount = constants.ZERO_AMOUNT; const erc20Amount = new BigNumber(10); - const erc20AssetData = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); + const erc20AssetData = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); const amounts = [erc20Amount]; const nestedAssetData = [erc20AssetData]; - const assetData = assetDataInterface.MultiAsset.getABIEncodedTransactionData(amounts, nestedAssetData); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - assetData, - fromAddress, - toAddress, - inputAmount, - ); + const assetData = assetDataInterface + .MultiAsset(amounts, nestedAssetData) + .getABIEncodedTransactionData(); + const data = assetProxyInterface + .transferFrom(assetData, fromAddress, toAddress, inputAmount) + .getABIEncodedTransactionData(); const erc20Balances = await erc20Wrapper.getBalancesAsync(); const logDecoder = new LogDecoder(web3Wrapper, { ...artifacts, ...erc20Artifacts }); const tx = await logDecoder.getTxWithDecodedLogsAsync( @@ -788,17 +726,14 @@ describe('Asset Transfer Proxies', () => { const inputAmount = new BigNumber(1); const erc20Amount1 = new BigNumber(10); const erc20Amount2 = new BigNumber(20); - const erc20AssetData1 = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); - const erc20AssetData2 = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); + const erc20AssetData1 = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); + const erc20AssetData2 = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); const amounts = [erc20Amount1, erc20Amount2]; const nestedAssetData = [erc20AssetData1, erc20AssetData2]; - const assetData = await devUtils.encodeMultiAssetData.callAsync(amounts, nestedAssetData); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - assetData, - fromAddress, - toAddress, - inputAmount, - ); + const assetData = await devUtils.encodeMultiAssetData(amounts, nestedAssetData).callAsync(); + const data = assetProxyInterface + .transferFrom(assetData, fromAddress, toAddress, inputAmount) + .getABIEncodedTransactionData(); const erc20Balances = await erc20Wrapper.getBalancesAsync(); await web3Wrapper.awaitTransactionSuccessAsync( await web3Wrapper.sendTransactionAsync({ @@ -821,17 +756,14 @@ describe('Asset Transfer Proxies', () => { const inputAmount = new BigNumber(1); const erc20Amount1 = new BigNumber(10); const erc20Amount2 = new BigNumber(20); - const erc20AssetData1 = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); - const erc20AssetData2 = await devUtils.encodeERC20AssetData.callAsync(erc20TokenB.address); + const erc20AssetData1 = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); + const erc20AssetData2 = await devUtils.encodeERC20AssetData(erc20TokenB.address).callAsync(); const amounts = [erc20Amount1, erc20Amount2]; const nestedAssetData = [erc20AssetData1, erc20AssetData2]; - const assetData = await devUtils.encodeMultiAssetData.callAsync(amounts, nestedAssetData); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - assetData, - fromAddress, - toAddress, - inputAmount, - ); + const assetData = await devUtils.encodeMultiAssetData(amounts, nestedAssetData).callAsync(); + const data = assetProxyInterface + .transferFrom(assetData, fromAddress, toAddress, inputAmount) + .getABIEncodedTransactionData(); const erc20Balances = await erc20Wrapper.getBalancesAsync(); await web3Wrapper.awaitTransactionSuccessAsync( await web3Wrapper.sendTransactionAsync({ @@ -860,20 +792,16 @@ describe('Asset Transfer Proxies', () => { it('should transfer a single ERC721 token', async () => { const inputAmount = new BigNumber(1); const erc721Amount = new BigNumber(1); - const erc721AssetData = await devUtils.encodeERC721AssetData.callAsync( - erc721TokenA.address, - erc721AFromTokenId, - ); + const erc721AssetData = await devUtils + .encodeERC721AssetData(erc721TokenA.address, erc721AFromTokenId) + .callAsync(); const amounts = [erc721Amount]; const nestedAssetData = [erc721AssetData]; - const assetData = await devUtils.encodeMultiAssetData.callAsync(amounts, nestedAssetData); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - assetData, - fromAddress, - toAddress, - inputAmount, - ); - const ownerFromAsset = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId); + const assetData = await devUtils.encodeMultiAssetData(amounts, nestedAssetData).callAsync(); + const data = assetProxyInterface + .transferFrom(assetData, fromAddress, toAddress, inputAmount) + .getABIEncodedTransactionData(); + const ownerFromAsset = await erc721TokenA.ownerOf(erc721AFromTokenId).callAsync(); expect(ownerFromAsset).to.be.equal(fromAddress); await web3Wrapper.awaitTransactionSuccessAsync( await web3Wrapper.sendTransactionAsync({ @@ -883,34 +811,29 @@ describe('Asset Transfer Proxies', () => { }), constants.AWAIT_TRANSACTION_MINED_MS, ); - const newOwnerFromAsset = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId); + const newOwnerFromAsset = await erc721TokenA.ownerOf(erc721AFromTokenId).callAsync(); expect(newOwnerFromAsset).to.be.equal(toAddress); }); it('should successfully transfer multiple of the same ERC721 token', async () => { const erc721Balances = await erc721Wrapper.getBalancesAsync(); const erc721AFromTokenId2 = erc721Balances[fromAddress][erc721TokenA.address][1]; - const erc721AssetData1 = await devUtils.encodeERC721AssetData.callAsync( - erc721TokenA.address, - erc721AFromTokenId, - ); - const erc721AssetData2 = await devUtils.encodeERC721AssetData.callAsync( - erc721TokenA.address, - erc721AFromTokenId2, - ); + const erc721AssetData1 = await devUtils + .encodeERC721AssetData(erc721TokenA.address, erc721AFromTokenId) + .callAsync(); + const erc721AssetData2 = await devUtils + .encodeERC721AssetData(erc721TokenA.address, erc721AFromTokenId2) + .callAsync(); const inputAmount = new BigNumber(1); const erc721Amount = new BigNumber(1); const amounts = [erc721Amount, erc721Amount]; const nestedAssetData = [erc721AssetData1, erc721AssetData2]; - const assetData = await devUtils.encodeMultiAssetData.callAsync(amounts, nestedAssetData); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - assetData, - fromAddress, - toAddress, - inputAmount, - ); - const ownerFromAsset1 = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId); + const assetData = await devUtils.encodeMultiAssetData(amounts, nestedAssetData).callAsync(); + const data = assetProxyInterface + .transferFrom(assetData, fromAddress, toAddress, inputAmount) + .getABIEncodedTransactionData(); + const ownerFromAsset1 = await erc721TokenA.ownerOf(erc721AFromTokenId).callAsync(); expect(ownerFromAsset1).to.be.equal(fromAddress); - const ownerFromAsset2 = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId2); + const ownerFromAsset2 = await erc721TokenA.ownerOf(erc721AFromTokenId2).callAsync(); expect(ownerFromAsset2).to.be.equal(fromAddress); await web3Wrapper.awaitTransactionSuccessAsync( await web3Wrapper.sendTransactionAsync({ @@ -921,34 +844,29 @@ describe('Asset Transfer Proxies', () => { }), constants.AWAIT_TRANSACTION_MINED_MS, ); - const newOwnerFromAsset1 = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId); - const newOwnerFromAsset2 = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId2); + const newOwnerFromAsset1 = await erc721TokenA.ownerOf(erc721AFromTokenId).callAsync(); + const newOwnerFromAsset2 = await erc721TokenA.ownerOf(erc721AFromTokenId2).callAsync(); expect(newOwnerFromAsset1).to.be.equal(toAddress); expect(newOwnerFromAsset2).to.be.equal(toAddress); }); it('should successfully transfer multiple different ERC721 tokens', async () => { - const erc721AssetData1 = await devUtils.encodeERC721AssetData.callAsync( - erc721TokenA.address, - erc721AFromTokenId, - ); - const erc721AssetData2 = await devUtils.encodeERC721AssetData.callAsync( - erc721TokenB.address, - erc721BFromTokenId, - ); + const erc721AssetData1 = await devUtils + .encodeERC721AssetData(erc721TokenA.address, erc721AFromTokenId) + .callAsync(); + const erc721AssetData2 = await devUtils + .encodeERC721AssetData(erc721TokenB.address, erc721BFromTokenId) + .callAsync(); const inputAmount = new BigNumber(1); const erc721Amount = new BigNumber(1); const amounts = [erc721Amount, erc721Amount]; const nestedAssetData = [erc721AssetData1, erc721AssetData2]; - const assetData = await devUtils.encodeMultiAssetData.callAsync(amounts, nestedAssetData); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - assetData, - fromAddress, - toAddress, - inputAmount, - ); - const ownerFromAsset1 = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId); + const assetData = await devUtils.encodeMultiAssetData(amounts, nestedAssetData).callAsync(); + const data = assetProxyInterface + .transferFrom(assetData, fromAddress, toAddress, inputAmount) + .getABIEncodedTransactionData(); + const ownerFromAsset1 = await erc721TokenA.ownerOf(erc721AFromTokenId).callAsync(); expect(ownerFromAsset1).to.be.equal(fromAddress); - const ownerFromAsset2 = await erc721TokenB.ownerOf.callAsync(erc721BFromTokenId); + const ownerFromAsset2 = await erc721TokenB.ownerOf(erc721BFromTokenId).callAsync(); expect(ownerFromAsset2).to.be.equal(fromAddress); await web3Wrapper.awaitTransactionSuccessAsync( await web3Wrapper.sendTransactionAsync({ @@ -959,8 +877,8 @@ describe('Asset Transfer Proxies', () => { }), constants.AWAIT_TRANSACTION_MINED_MS, ); - const newOwnerFromAsset1 = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId); - const newOwnerFromAsset2 = await erc721TokenB.ownerOf.callAsync(erc721BFromTokenId); + const newOwnerFromAsset1 = await erc721TokenA.ownerOf(erc721AFromTokenId).callAsync(); + const newOwnerFromAsset2 = await erc721TokenB.ownerOf(erc721BFromTokenId).callAsync(); expect(newOwnerFromAsset1).to.be.equal(toAddress); expect(newOwnerFromAsset2).to.be.equal(toAddress); }); @@ -980,23 +898,22 @@ describe('Asset Transfer Proxies', () => { ]; await erc1155Wrapper.assertBalancesAsync(tokenHolders, tokensToTransfer, expectedInitialBalances); // encode erc1155 asset data - const erc1155AssetData = await devUtils.encodeERC1155AssetData.callAsync( - erc1155Contract.address, - tokensToTransfer, - valuesToTransfer, - receiverCallbackData, - ); + const erc1155AssetData = await devUtils + .encodeERC1155AssetData( + erc1155Contract.address, + tokensToTransfer, + valuesToTransfer, + receiverCallbackData, + ) + .callAsync(); // encode multi-asset data const multiAssetAmount = new BigNumber(5); const amounts = [valueMultiplier]; const nestedAssetData = [erc1155AssetData]; - const assetData = await devUtils.encodeMultiAssetData.callAsync(amounts, nestedAssetData); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - assetData, - fromAddress, - toAddress, - multiAssetAmount, - ); + const assetData = await devUtils.encodeMultiAssetData(amounts, nestedAssetData).callAsync(); + const data = assetProxyInterface + .transferFrom(assetData, fromAddress, toAddress, multiAssetAmount) + .getABIEncodedTransactionData(); // execute transfer await web3Wrapper.awaitTransactionSuccessAsync( await web3Wrapper.sendTransactionAsync({ @@ -1036,23 +953,22 @@ describe('Asset Transfer Proxies', () => { ]; await erc1155Wrapper.assertBalancesAsync(tokenHolders, tokensToTransfer, expectedInitialBalances); // encode erc1155 asset data - const erc1155AssetData = await devUtils.encodeERC1155AssetData.callAsync( - erc1155Contract.address, - tokensToTransfer, - valuesToTransfer, - receiverCallbackData, - ); + const erc1155AssetData = await devUtils + .encodeERC1155AssetData( + erc1155Contract.address, + tokensToTransfer, + valuesToTransfer, + receiverCallbackData, + ) + .callAsync(); // encode multi-asset data const multiAssetAmount = new BigNumber(5); const amounts = [valueMultiplier]; const nestedAssetData = [erc1155AssetData]; - const assetData = await devUtils.encodeMultiAssetData.callAsync(amounts, nestedAssetData); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - assetData, - fromAddress, - toAddress, - multiAssetAmount, - ); + const assetData = await devUtils.encodeMultiAssetData(amounts, nestedAssetData).callAsync(); + const data = assetProxyInterface + .transferFrom(assetData, fromAddress, toAddress, multiAssetAmount) + .getABIEncodedTransactionData(); // execute transfer await web3Wrapper.awaitTransactionSuccessAsync( await web3Wrapper.sendTransactionAsync({ @@ -1100,23 +1016,22 @@ describe('Asset Transfer Proxies', () => { ]; await erc1155Wrapper.assertBalancesAsync(tokenHolders, tokensToTransfer, expectedInitialBalances); // encode erc1155 asset data - const erc1155AssetData = await devUtils.encodeERC1155AssetData.callAsync( - erc1155Contract.address, - tokensToTransfer, - valuesToTransfer, - receiverCallbackData, - ); + const erc1155AssetData = await devUtils + .encodeERC1155AssetData( + erc1155Contract.address, + tokensToTransfer, + valuesToTransfer, + receiverCallbackData, + ) + .callAsync(); // encode multi-asset data const multiAssetAmount = new BigNumber(1); const amounts = [valueMultiplier]; const nestedAssetData = [erc1155AssetData]; - const assetData = await devUtils.encodeMultiAssetData.callAsync(amounts, nestedAssetData); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - assetData, - fromAddress, - toAddress, - multiAssetAmount, - ); + const assetData = await devUtils.encodeMultiAssetData(amounts, nestedAssetData).callAsync(); + const data = assetProxyInterface + .transferFrom(assetData, fromAddress, toAddress, multiAssetAmount) + .getABIEncodedTransactionData(); // execute transfer await web3Wrapper.awaitTransactionSuccessAsync( await web3Wrapper.sendTransactionAsync({ @@ -1157,29 +1072,30 @@ describe('Asset Transfer Proxies', () => { await erc1155Wrapper.assertBalancesAsync(tokenHolders, tokensToTransfer, expectedInitialBalances); await erc1155Wrapper2.assertBalancesAsync(tokenHolders, tokensToTransfer, expectedInitialBalances); // encode erc1155 asset data - const erc1155AssetData1 = await devUtils.encodeERC1155AssetData.callAsync( - erc1155Contract.address, - tokensToTransfer, - valuesToTransfer, - receiverCallbackData, - ); - const erc1155AssetData2 = await devUtils.encodeERC1155AssetData.callAsync( - erc1155Contract2.address, - tokensToTransfer, - valuesToTransfer, - receiverCallbackData, - ); + const erc1155AssetData1 = await devUtils + .encodeERC1155AssetData( + erc1155Contract.address, + tokensToTransfer, + valuesToTransfer, + receiverCallbackData, + ) + .callAsync(); + const erc1155AssetData2 = await devUtils + .encodeERC1155AssetData( + erc1155Contract2.address, + tokensToTransfer, + valuesToTransfer, + receiverCallbackData, + ) + .callAsync(); // encode multi-asset data const multiAssetAmount = new BigNumber(5); const amounts = [valueMultiplier, valueMultiplier]; const nestedAssetData = [erc1155AssetData1, erc1155AssetData2]; - const assetData = await devUtils.encodeMultiAssetData.callAsync(amounts, nestedAssetData); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - assetData, - fromAddress, - toAddress, - multiAssetAmount, - ); + const assetData = await devUtils.encodeMultiAssetData(amounts, nestedAssetData).callAsync(); + const data = assetProxyInterface + .transferFrom(assetData, fromAddress, toAddress, multiAssetAmount) + .getABIEncodedTransactionData(); // execute transfer await web3Wrapper.awaitTransactionSuccessAsync( await web3Wrapper.sendTransactionAsync({ @@ -1204,35 +1120,33 @@ describe('Asset Transfer Proxies', () => { // setup test parameters const inputAmount = new BigNumber(1); const erc20Amount = new BigNumber(10); - const erc20AssetData = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); + const erc20AssetData = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); const erc721Amount = new BigNumber(1); - const erc721AssetData = await devUtils.encodeERC721AssetData.callAsync( - erc721TokenA.address, - erc721AFromTokenId, - ); + const erc721AssetData = await devUtils + .encodeERC721AssetData(erc721TokenA.address, erc721AFromTokenId) + .callAsync(); const erc1155TokenHolders = [fromAddress, toAddress]; const erc1155TokensToTransfer = erc1155FungibleTokens.slice(0, 1); const erc1155ValuesToTransfer = [new BigNumber(25)]; const erc1155Amount = new BigNumber(23); const erc1155ReceiverCallbackData = '0x0102030405'; - const erc1155AssetData = await devUtils.encodeERC1155AssetData.callAsync( - erc1155Contract.address, - erc1155TokensToTransfer, - erc1155ValuesToTransfer, - erc1155ReceiverCallbackData, - ); + const erc1155AssetData = await devUtils + .encodeERC1155AssetData( + erc1155Contract.address, + erc1155TokensToTransfer, + erc1155ValuesToTransfer, + erc1155ReceiverCallbackData, + ) + .callAsync(); const amounts = [erc20Amount, erc721Amount, erc1155Amount]; const nestedAssetData = [erc20AssetData, erc721AssetData, erc1155AssetData]; - const assetData = await devUtils.encodeMultiAssetData.callAsync(amounts, nestedAssetData); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - assetData, - fromAddress, - toAddress, - inputAmount, - ); + const assetData = await devUtils.encodeMultiAssetData(amounts, nestedAssetData).callAsync(); + const data = assetProxyInterface + .transferFrom(assetData, fromAddress, toAddress, inputAmount) + .getABIEncodedTransactionData(); // check balances before transfer const erc20Balances = await erc20Wrapper.getBalancesAsync(); - const ownerFromAsset = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId); + const ownerFromAsset = await erc721TokenA.ownerOf(erc721AFromTokenId).callAsync(); expect(ownerFromAsset).to.be.equal(fromAddress); const erc1155ExpectedInitialBalances = [ constants.INITIAL_ERC1155_FUNGIBLE_BALANCE, @@ -1262,7 +1176,7 @@ describe('Asset Transfer Proxies', () => { expect(newBalances[toAddress][erc20TokenA.address]).to.be.bignumber.equal( erc20Balances[toAddress][erc20TokenA.address].plus(totalAmount), ); - const newOwnerFromAsset = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId); + const newOwnerFromAsset = await erc721TokenA.ownerOf(erc721AFromTokenId).callAsync(); expect(newOwnerFromAsset).to.be.equal(toAddress); const erc1155TotalValueTransferred = erc1155ValuesToTransfer[0].times(erc1155Amount).times(inputAmount); const expectedFinalBalances = [ @@ -1278,23 +1192,19 @@ describe('Asset Transfer Proxies', () => { it('should successfully transfer a combination of ERC20 and ERC721 tokens', async () => { const inputAmount = new BigNumber(1); const erc20Amount = new BigNumber(10); - const erc20AssetData = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); + const erc20AssetData = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); const erc721Amount = new BigNumber(1); - const erc721AssetData = await devUtils.encodeERC721AssetData.callAsync( - erc721TokenA.address, - erc721AFromTokenId, - ); + const erc721AssetData = await devUtils + .encodeERC721AssetData(erc721TokenA.address, erc721AFromTokenId) + .callAsync(); const amounts = [erc20Amount, erc721Amount]; const nestedAssetData = [erc20AssetData, erc721AssetData]; - const assetData = await devUtils.encodeMultiAssetData.callAsync(amounts, nestedAssetData); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - assetData, - fromAddress, - toAddress, - inputAmount, - ); + const assetData = await devUtils.encodeMultiAssetData(amounts, nestedAssetData).callAsync(); + const data = assetProxyInterface + .transferFrom(assetData, fromAddress, toAddress, inputAmount) + .getABIEncodedTransactionData(); const erc20Balances = await erc20Wrapper.getBalancesAsync(); - const ownerFromAsset = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId); + const ownerFromAsset = await erc721TokenA.ownerOf(erc721AFromTokenId).callAsync(); expect(ownerFromAsset).to.be.equal(fromAddress); await web3Wrapper.awaitTransactionSuccessAsync( await web3Wrapper.sendTransactionAsync({ @@ -1312,33 +1222,28 @@ describe('Asset Transfer Proxies', () => { expect(newBalances[toAddress][erc20TokenA.address]).to.be.bignumber.equal( erc20Balances[toAddress][erc20TokenA.address].plus(totalAmount), ); - const newOwnerFromAsset = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId); + const newOwnerFromAsset = await erc721TokenA.ownerOf(erc721AFromTokenId).callAsync(); expect(newOwnerFromAsset).to.be.equal(toAddress); }); it('should successfully transfer tokens and ignore extra assetData', async () => { const inputAmount = new BigNumber(1); const erc20Amount = new BigNumber(10); - const erc20AssetData = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); + const erc20AssetData = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); const erc721Amount = new BigNumber(1); - const erc721AssetData = await devUtils.encodeERC721AssetData.callAsync( - erc721TokenA.address, - erc721AFromTokenId, - ); + const erc721AssetData = await devUtils + .encodeERC721AssetData(erc721TokenA.address, erc721AFromTokenId) + .callAsync(); const amounts = [erc20Amount, erc721Amount]; const nestedAssetData = [erc20AssetData, erc721AssetData]; const extraData = '0102030405060708090001020304050607080900010203040506070809000102'; - const assetData = `${await devUtils.encodeMultiAssetData.callAsync( - amounts, - nestedAssetData, - )}${extraData}`; - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - assetData, - fromAddress, - toAddress, - inputAmount, - ); + const assetData = `${await devUtils + .encodeMultiAssetData(amounts, nestedAssetData) + .callAsync()}${extraData}`; + const data = assetProxyInterface + .transferFrom(assetData, fromAddress, toAddress, inputAmount) + .getABIEncodedTransactionData(); const erc20Balances = await erc20Wrapper.getBalancesAsync(); - const ownerFromAsset = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId); + const ownerFromAsset = await erc721TokenA.ownerOf(erc721AFromTokenId).callAsync(); expect(ownerFromAsset).to.be.equal(fromAddress); await web3Wrapper.awaitTransactionSuccessAsync( await web3Wrapper.sendTransactionAsync({ @@ -1356,24 +1261,21 @@ describe('Asset Transfer Proxies', () => { expect(newBalances[toAddress][erc20TokenA.address]).to.be.bignumber.equal( erc20Balances[toAddress][erc20TokenA.address].plus(totalAmount), ); - const newOwnerFromAsset = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId); + const newOwnerFromAsset = await erc721TokenA.ownerOf(erc721AFromTokenId).callAsync(); expect(newOwnerFromAsset).to.be.equal(toAddress); }); it('should successfully transfer correct amounts when the `amount` > 1', async () => { const inputAmount = new BigNumber(100); const erc20Amount1 = new BigNumber(10); const erc20Amount2 = new BigNumber(20); - const erc20AssetData1 = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); - const erc20AssetData2 = await devUtils.encodeERC20AssetData.callAsync(erc20TokenB.address); + const erc20AssetData1 = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); + const erc20AssetData2 = await devUtils.encodeERC20AssetData(erc20TokenB.address).callAsync(); const amounts = [erc20Amount1, erc20Amount2]; const nestedAssetData = [erc20AssetData1, erc20AssetData2]; - const assetData = await devUtils.encodeMultiAssetData.callAsync(amounts, nestedAssetData); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - assetData, - fromAddress, - toAddress, - inputAmount, - ); + const assetData = await devUtils.encodeMultiAssetData(amounts, nestedAssetData).callAsync(); + const data = assetProxyInterface + .transferFrom(assetData, fromAddress, toAddress, inputAmount) + .getABIEncodedTransactionData(); const erc20Balances = await erc20Wrapper.getBalancesAsync(); await web3Wrapper.awaitTransactionSuccessAsync( await web3Wrapper.sendTransactionAsync({ @@ -1403,28 +1305,24 @@ describe('Asset Transfer Proxies', () => { const inputAmount = new BigNumber(1); const erc20Amount1 = new BigNumber(10); const erc20Amount2 = new BigNumber(20); - const erc20AssetData1 = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); - const erc20AssetData2 = await devUtils.encodeERC20AssetData.callAsync(erc20TokenB.address); + const erc20AssetData1 = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); + const erc20AssetData2 = await devUtils.encodeERC20AssetData(erc20TokenB.address).callAsync(); const erc721Amount = new BigNumber(1); const erc721Balances = await erc721Wrapper.getBalancesAsync(); const erc721AFromTokenId2 = erc721Balances[fromAddress][erc721TokenA.address][1]; const erc721BFromTokenId2 = erc721Balances[fromAddress][erc721TokenB.address][1]; - const erc721AssetData1 = await devUtils.encodeERC721AssetData.callAsync( - erc721TokenA.address, - erc721AFromTokenId, - ); - const erc721AssetData2 = await devUtils.encodeERC721AssetData.callAsync( - erc721TokenA.address, - erc721AFromTokenId2, - ); - const erc721AssetData3 = await devUtils.encodeERC721AssetData.callAsync( - erc721TokenB.address, - erc721BFromTokenId, - ); - const erc721AssetData4 = await devUtils.encodeERC721AssetData.callAsync( - erc721TokenB.address, - erc721BFromTokenId2, - ); + const erc721AssetData1 = await devUtils + .encodeERC721AssetData(erc721TokenA.address, erc721AFromTokenId) + .callAsync(); + const erc721AssetData2 = await devUtils + .encodeERC721AssetData(erc721TokenA.address, erc721AFromTokenId2) + .callAsync(); + const erc721AssetData3 = await devUtils + .encodeERC721AssetData(erc721TokenB.address, erc721BFromTokenId) + .callAsync(); + const erc721AssetData4 = await devUtils + .encodeERC721AssetData(erc721TokenB.address, erc721BFromTokenId2) + .callAsync(); const amounts = [erc721Amount, erc20Amount1, erc721Amount, erc20Amount2, erc721Amount, erc721Amount]; const nestedAssetData = [ erc721AssetData1, @@ -1434,20 +1332,17 @@ describe('Asset Transfer Proxies', () => { erc721AssetData3, erc721AssetData4, ]; - const assetData = await devUtils.encodeMultiAssetData.callAsync(amounts, nestedAssetData); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - assetData, - fromAddress, - toAddress, - inputAmount, - ); - const ownerFromAsset1 = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId); + const assetData = await devUtils.encodeMultiAssetData(amounts, nestedAssetData).callAsync(); + const data = assetProxyInterface + .transferFrom(assetData, fromAddress, toAddress, inputAmount) + .getABIEncodedTransactionData(); + const ownerFromAsset1 = await erc721TokenA.ownerOf(erc721AFromTokenId).callAsync(); expect(ownerFromAsset1).to.be.equal(fromAddress); - const ownerFromAsset2 = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId2); + const ownerFromAsset2 = await erc721TokenA.ownerOf(erc721AFromTokenId2).callAsync(); expect(ownerFromAsset2).to.be.equal(fromAddress); - const ownerFromAsset3 = await erc721TokenB.ownerOf.callAsync(erc721BFromTokenId); + const ownerFromAsset3 = await erc721TokenB.ownerOf(erc721BFromTokenId).callAsync(); expect(ownerFromAsset3).to.be.equal(fromAddress); - const ownerFromAsset4 = await erc721TokenB.ownerOf.callAsync(erc721BFromTokenId2); + const ownerFromAsset4 = await erc721TokenB.ownerOf(erc721BFromTokenId2).callAsync(); expect(ownerFromAsset4).to.be.equal(fromAddress); const erc20Balances = await erc20Wrapper.getBalancesAsync(); await web3Wrapper.awaitTransactionSuccessAsync( @@ -1459,10 +1354,10 @@ describe('Asset Transfer Proxies', () => { }), constants.AWAIT_TRANSACTION_MINED_MS, ); - const newOwnerFromAsset1 = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId); - const newOwnerFromAsset2 = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId2); - const newOwnerFromAsset3 = await erc721TokenB.ownerOf.callAsync(erc721BFromTokenId); - const newOwnerFromAsset4 = await erc721TokenB.ownerOf.callAsync(erc721BFromTokenId2); + const newOwnerFromAsset1 = await erc721TokenA.ownerOf(erc721AFromTokenId).callAsync(); + const newOwnerFromAsset2 = await erc721TokenA.ownerOf(erc721AFromTokenId2).callAsync(); + const newOwnerFromAsset3 = await erc721TokenB.ownerOf(erc721BFromTokenId).callAsync(); + const newOwnerFromAsset4 = await erc721TokenB.ownerOf(erc721BFromTokenId2).callAsync(); expect(newOwnerFromAsset1).to.be.equal(toAddress); expect(newOwnerFromAsset2).to.be.equal(toAddress); expect(newOwnerFromAsset3).to.be.equal(toAddress); @@ -1486,22 +1381,18 @@ describe('Asset Transfer Proxies', () => { it('should revert if a single transfer fails', async () => { const inputAmount = new BigNumber(1); const erc20Amount = new BigNumber(10); - const erc20AssetData = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); + const erc20AssetData = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); // 2 is an invalid erc721 amount const erc721Amount = new BigNumber(2); - const erc721AssetData = await devUtils.encodeERC721AssetData.callAsync( - erc721TokenA.address, - erc721AFromTokenId, - ); + const erc721AssetData = await devUtils + .encodeERC721AssetData(erc721TokenA.address, erc721AFromTokenId) + .callAsync(); const amounts = [erc20Amount, erc721Amount]; const nestedAssetData = [erc20AssetData, erc721AssetData]; - const assetData = await devUtils.encodeMultiAssetData.callAsync(amounts, nestedAssetData); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - assetData, - fromAddress, - toAddress, - inputAmount, - ); + const assetData = await devUtils.encodeMultiAssetData(amounts, nestedAssetData).callAsync(); + const data = assetProxyInterface + .transferFrom(assetData, fromAddress, toAddress, inputAmount) + .getABIEncodedTransactionData(); await expectTransactionFailedAsync( web3Wrapper.sendTransactionAsync({ to: multiAssetProxy.address, @@ -1514,23 +1405,19 @@ describe('Asset Transfer Proxies', () => { it('should revert if an AssetProxy is not registered', async () => { const inputAmount = new BigNumber(1); const erc20Amount = new BigNumber(10); - const erc20AssetData = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); + const erc20AssetData = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); const erc721Amount = new BigNumber(1); - const erc721AssetData = await devUtils.encodeERC721AssetData.callAsync( - erc721TokenA.address, - erc721AFromTokenId, - ); + const erc721AssetData = await devUtils + .encodeERC721AssetData(erc721TokenA.address, erc721AFromTokenId) + .callAsync(); const invalidProxyId = '0x12345678'; const invalidErc721AssetData = `${invalidProxyId}${erc721AssetData.slice(10)}`; const amounts = [erc20Amount, erc721Amount]; const nestedAssetData = [erc20AssetData, invalidErc721AssetData]; - const assetData = await devUtils.encodeMultiAssetData.callAsync(amounts, nestedAssetData); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - assetData, - fromAddress, - toAddress, - inputAmount, - ); + const assetData = await devUtils.encodeMultiAssetData(amounts, nestedAssetData).callAsync(); + const data = assetProxyInterface + .transferFrom(assetData, fromAddress, toAddress, inputAmount) + .getABIEncodedTransactionData(); await expectTransactionFailedAsync( web3Wrapper.sendTransactionAsync({ to: multiAssetProxy.address, @@ -1543,20 +1430,16 @@ describe('Asset Transfer Proxies', () => { it('should revert if the length of `amounts` does not match the length of `nestedAssetData`', async () => { const inputAmount = new BigNumber(1); const erc20Amount = new BigNumber(10); - const erc20AssetData = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); - const erc721AssetData = await devUtils.encodeERC721AssetData.callAsync( - erc721TokenA.address, - erc721AFromTokenId, - ); + const erc20AssetData = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); + const erc721AssetData = await devUtils + .encodeERC721AssetData(erc721TokenA.address, erc721AFromTokenId) + .callAsync(); const amounts = [erc20Amount]; const nestedAssetData = [erc20AssetData, erc721AssetData]; - const assetData = await devUtils.encodeMultiAssetData.callAsync(amounts, nestedAssetData); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - assetData, - fromAddress, - toAddress, - inputAmount, - ); + const assetData = await devUtils.encodeMultiAssetData(amounts, nestedAssetData).callAsync(); + const data = assetProxyInterface + .transferFrom(assetData, fromAddress, toAddress, inputAmount) + .getABIEncodedTransactionData(); await expectTransactionFailedAsync( web3Wrapper.sendTransactionAsync({ to: multiAssetProxy.address, @@ -1569,16 +1452,13 @@ describe('Asset Transfer Proxies', () => { it('should revert if amounts multiplication results in an overflow', async () => { const inputAmount = new BigNumber(2).pow(128); const erc20Amount = new BigNumber(2).pow(128); - const erc20AssetData = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); + const erc20AssetData = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); const amounts = [erc20Amount]; const nestedAssetData = [erc20AssetData]; - const assetData = await devUtils.encodeMultiAssetData.callAsync(amounts, nestedAssetData); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - assetData, - fromAddress, - toAddress, - inputAmount, - ); + const assetData = await devUtils.encodeMultiAssetData(amounts, nestedAssetData).callAsync(); + const data = assetProxyInterface + .transferFrom(assetData, fromAddress, toAddress, inputAmount) + .getABIEncodedTransactionData(); await expectTransactionFailedAsync( web3Wrapper.sendTransactionAsync({ to: multiAssetProxy.address, @@ -1591,18 +1471,15 @@ describe('Asset Transfer Proxies', () => { it('should revert if an element of `nestedAssetData` is < 4 bytes long', async () => { const inputAmount = new BigNumber(1); const erc20Amount = new BigNumber(10); - const erc20AssetData = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); + const erc20AssetData = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); const erc721Amount = new BigNumber(1); const erc721AssetData = '0x123456'; const amounts = [erc20Amount, erc721Amount]; const nestedAssetData = [erc20AssetData, erc721AssetData]; - const assetData = await devUtils.encodeMultiAssetData.callAsync(amounts, nestedAssetData); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - assetData, - fromAddress, - toAddress, - inputAmount, - ); + const assetData = await devUtils.encodeMultiAssetData(amounts, nestedAssetData).callAsync(); + const data = assetProxyInterface + .transferFrom(assetData, fromAddress, toAddress, inputAmount) + .getABIEncodedTransactionData(); await expectTransactionFailedAsync( web3Wrapper.sendTransactionAsync({ to: multiAssetProxy.address, @@ -1615,21 +1492,17 @@ describe('Asset Transfer Proxies', () => { it('should revert if caller is not authorized', async () => { const inputAmount = new BigNumber(1); const erc20Amount = new BigNumber(10); - const erc20AssetData = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); + const erc20AssetData = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); const erc721Amount = new BigNumber(1); - const erc721AssetData = await devUtils.encodeERC721AssetData.callAsync( - erc721TokenA.address, - erc721AFromTokenId, - ); + const erc721AssetData = await devUtils + .encodeERC721AssetData(erc721TokenA.address, erc721AFromTokenId) + .callAsync(); const amounts = [erc20Amount, erc721Amount]; const nestedAssetData = [erc20AssetData, erc721AssetData]; - const assetData = await devUtils.encodeMultiAssetData.callAsync(amounts, nestedAssetData); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - assetData, - fromAddress, - toAddress, - inputAmount, - ); + const assetData = await devUtils.encodeMultiAssetData(amounts, nestedAssetData).callAsync(); + const data = assetProxyInterface + .transferFrom(assetData, fromAddress, toAddress, inputAmount) + .getABIEncodedTransactionData(); await expectTransactionFailedAsync( web3Wrapper.sendTransactionAsync({ to: multiAssetProxy.address, @@ -1642,21 +1515,17 @@ describe('Asset Transfer Proxies', () => { it('should revert if asset data overflows beyond the bounds of calldata', async () => { const inputAmount = new BigNumber(1); const erc20Amount = new BigNumber(10); - const erc20AssetData = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); + const erc20AssetData = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); const erc721Amount = new BigNumber(1); - const erc721AssetData = await devUtils.encodeERC721AssetData.callAsync( - erc721TokenA.address, - erc721AFromTokenId, - ); + const erc721AssetData = await devUtils + .encodeERC721AssetData(erc721TokenA.address, erc721AFromTokenId) + .callAsync(); const amounts = [erc20Amount, erc721Amount]; const nestedAssetData = [erc20AssetData, erc721AssetData]; - const assetData = await devUtils.encodeMultiAssetData.callAsync(amounts, nestedAssetData); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - assetData, - fromAddress, - toAddress, - inputAmount, - ); + const assetData = await devUtils.encodeMultiAssetData(amounts, nestedAssetData).callAsync(); + const data = assetProxyInterface + .transferFrom(assetData, fromAddress, toAddress, inputAmount) + .getABIEncodedTransactionData(); // append asset data to end of tx data with a length of 0x300 bytes, which will extend past actual calldata. const offsetToAssetData = '0000000000000000000000000000000000000000000000000000000000000080'; const invalidOffsetToAssetData = '00000000000000000000000000000000000000000000000000000000000002a0'; @@ -1675,21 +1544,17 @@ describe('Asset Transfer Proxies', () => { it('should revert if asset data resolves to a location beyond the bounds of calldata', async () => { const inputAmount = new BigNumber(1); const erc20Amount = new BigNumber(10); - const erc20AssetData = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); + const erc20AssetData = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); const erc721Amount = new BigNumber(1); - const erc721AssetData = await devUtils.encodeERC721AssetData.callAsync( - erc721TokenA.address, - erc721AFromTokenId, - ); + const erc721AssetData = await devUtils + .encodeERC721AssetData(erc721TokenA.address, erc721AFromTokenId) + .callAsync(); const amounts = [erc20Amount, erc721Amount]; const nestedAssetData = [erc20AssetData, erc721AssetData]; - const assetData = await devUtils.encodeMultiAssetData.callAsync(amounts, nestedAssetData); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - assetData, - fromAddress, - toAddress, - inputAmount, - ); + const assetData = await devUtils.encodeMultiAssetData(amounts, nestedAssetData).callAsync(); + const data = assetProxyInterface + .transferFrom(assetData, fromAddress, toAddress, inputAmount) + .getABIEncodedTransactionData(); const offsetToAssetData = '0000000000000000000000000000000000000000000000000000000000000080'; const invalidOffsetToAssetData = '0000000000000000000000000000000000000000000000000000000000000400'; const badData = data.replace(offsetToAssetData, invalidOffsetToAssetData); @@ -1709,23 +1574,19 @@ describe('Asset Transfer Proxies', () => { // setup test parameters const inputAmount = new BigNumber(1); const erc20Amount = new BigNumber(10); - const erc20AssetData = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); + const erc20AssetData = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); const erc721Amount = new BigNumber(1); - const erc721AssetData = await devUtils.encodeERC721AssetData.callAsync( - erc721TokenA.address, - erc721AFromTokenId, - ); + const erc721AssetData = await devUtils + .encodeERC721AssetData(erc721TokenA.address, erc721AFromTokenId) + .callAsync(); const amounts = [erc20Amount, erc721Amount]; const nestedAssetData = [erc20AssetData, erc721AssetData]; - const assetData = await devUtils.encodeMultiAssetData.callAsync(amounts, nestedAssetData); + const assetData = await devUtils.encodeMultiAssetData(amounts, nestedAssetData).callAsync(); const extraData = '01'; const assetDataWithExtraData = `${assetData}${extraData}`; - const badData = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - assetDataWithExtraData, - fromAddress, - toAddress, - inputAmount, - ); + const badData = assetProxyInterface + .transferFrom(assetDataWithExtraData, fromAddress, toAddress, inputAmount) + .getABIEncodedTransactionData(); // execute transfer await expectTransactionFailedAsync( web3Wrapper.sendTransactionAsync({ @@ -1746,12 +1607,9 @@ describe('Asset Transfer Proxies', () => { // so that we know the error is not triggered by another check in the code. const zeros32Bytes = '0'.repeat(64); const assetData36Bytes = `${AssetProxyId.MultiAsset}${zeros32Bytes}`; - const badData = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - assetData36Bytes, - fromAddress, - toAddress, - inputAmount, - ); + const badData = assetProxyInterface + .transferFrom(assetData36Bytes, fromAddress, toAddress, inputAmount) + .getABIEncodedTransactionData(); // execute transfer await expectTransactionFailedAsync( web3Wrapper.sendTransactionAsync({ diff --git a/contracts/asset-proxy/test/static_call_proxy.ts b/contracts/asset-proxy/test/static_call_proxy.ts index 743cc476a3..f366b61c02 100644 --- a/contracts/asset-proxy/test/static_call_proxy.ts +++ b/contracts/asset-proxy/test/static_call_proxy.ts @@ -79,26 +79,21 @@ describe('StaticCallProxy', () => { ); }); it('should have an id of 0xc339d10a', async () => { - const proxyId = await staticCallProxy.getProxyId.callAsync(); + const proxyId = await staticCallProxy.getProxyId().callAsync(); const expectedProxyId = AssetProxyId.StaticCall; expect(proxyId).to.equal(expectedProxyId); }); }); describe('transferFrom', () => { it('should revert if assetData lies outside the bounds of calldata', async () => { - const staticCallData = staticCallTarget.noInputFunction.getABIEncodedTransactionData(); + const staticCallData = staticCallTarget.noInputFunction().getABIEncodedTransactionData(); const expectedResultHash = constants.KECCAK256_NULL; - const assetData = await devUtils.encodeStaticCallAssetData.callAsync( - staticCallTarget.address, - staticCallData, - expectedResultHash, - ); - const txData = staticCallProxy.transferFrom.getABIEncodedTransactionData( - assetData, - fromAddress, - toAddress, - amount, - ); + const assetData = await devUtils + .encodeStaticCallAssetData(staticCallTarget.address, staticCallData, expectedResultHash) + .callAsync(); + const txData = staticCallProxy + .transferFrom(assetData, fromAddress, toAddress, amount) + .getABIEncodedTransactionData(); const offsetToAssetData = '0000000000000000000000000000000000000000000000000000000000000080'; const txDataEndBuffer = ethUtil.toBuffer((txData.length - 2) / 2 - 4); const paddedTxDataEndBuffer = ethUtil.setLengthLeft(txDataEndBuffer, 32); @@ -116,25 +111,21 @@ describe('StaticCallProxy', () => { it('should revert if the length of assetData is less than 100 bytes', async () => { const staticCallData = constants.NULL_BYTES; const expectedResultHash = constants.KECCAK256_NULL; - const assetData = (await devUtils.encodeStaticCallAssetData.callAsync( - staticCallTarget.address, - staticCallData, - expectedResultHash, - )).slice(0, -128); + const assetData = (await devUtils + .encodeStaticCallAssetData(staticCallTarget.address, staticCallData, expectedResultHash) + .callAsync()).slice(0, -128); const assetDataByteLen = (assetData.length - 2) / 2; expect((assetDataByteLen - 4) % 32).to.equal(0); await expectTransactionFailedWithoutReasonAsync( - staticCallProxy.transferFrom.sendTransactionAsync(assetData, fromAddress, toAddress, amount), + staticCallProxy.transferFrom(assetData, fromAddress, toAddress, amount).sendTransactionAsync(), ); }); it('should revert if the offset to `staticCallData` points to outside of assetData', async () => { - const staticCallData = staticCallTarget.noInputFunction.getABIEncodedTransactionData(); + const staticCallData = staticCallTarget.noInputFunction().getABIEncodedTransactionData(); const expectedResultHash = constants.KECCAK256_NULL; - const assetData = await devUtils.encodeStaticCallAssetData.callAsync( - staticCallTarget.address, - staticCallData, - expectedResultHash, - ); + const assetData = await devUtils + .encodeStaticCallAssetData(staticCallTarget.address, staticCallData, expectedResultHash) + .callAsync(); const offsetToStaticCallData = '0000000000000000000000000000000000000000000000000000000000000060'; const assetDataEndBuffer = ethUtil.toBuffer((assetData.length - 2) / 2 - 4); const paddedAssetDataEndBuffer = ethUtil.setLengthLeft(assetDataEndBuffer, 32); @@ -145,94 +136,88 @@ describe('StaticCallProxy', () => { invalidOffsetToStaticCallData, )}${newStaticCallData}`; await expectTransactionFailedWithoutReasonAsync( - staticCallProxy.transferFrom.sendTransactionAsync(badAssetData, fromAddress, toAddress, amount), + staticCallProxy.transferFrom(badAssetData, fromAddress, toAddress, amount).sendTransactionAsync(), ); }); it('should revert if the callTarget attempts to write to state', async () => { - const staticCallData = staticCallTarget.updateState.getABIEncodedTransactionData(); + const staticCallData = staticCallTarget.updateState().getABIEncodedTransactionData(); const expectedResultHash = constants.KECCAK256_NULL; - const assetData = await devUtils.encodeStaticCallAssetData.callAsync( - staticCallTarget.address, - staticCallData, - expectedResultHash, - ); + const assetData = await devUtils + .encodeStaticCallAssetData(staticCallTarget.address, staticCallData, expectedResultHash) + .callAsync(); await expectTransactionFailedWithoutReasonAsync( - staticCallProxy.transferFrom.sendTransactionAsync(assetData, fromAddress, toAddress, amount), + staticCallProxy.transferFrom(assetData, fromAddress, toAddress, amount).sendTransactionAsync(), ); }); it('should revert with data provided by the callTarget if the staticcall reverts', async () => { - const staticCallData = staticCallTarget.assertEvenNumber.getABIEncodedTransactionData(new BigNumber(1)); + const staticCallData = staticCallTarget.assertEvenNumber(new BigNumber(1)).getABIEncodedTransactionData(); const expectedResultHash = constants.KECCAK256_NULL; - const assetData = await devUtils.encodeStaticCallAssetData.callAsync( - staticCallTarget.address, - staticCallData, - expectedResultHash, - ); + const assetData = await devUtils + .encodeStaticCallAssetData(staticCallTarget.address, staticCallData, expectedResultHash) + .callAsync(); await expectTransactionFailedAsync( - staticCallProxy.transferFrom.sendTransactionAsync(assetData, fromAddress, toAddress, amount), + staticCallProxy.transferFrom(assetData, fromAddress, toAddress, amount).sendTransactionAsync(), RevertReason.TargetNotEven, ); }); it('should revert if the hash of the output is different than expected expected', async () => { - const staticCallData = staticCallTarget.isOddNumber.getABIEncodedTransactionData(new BigNumber(0)); + const staticCallData = staticCallTarget.isOddNumber(new BigNumber(0)).getABIEncodedTransactionData(); const trueAsBuffer = ethUtil.toBuffer('0x0000000000000000000000000000000000000000000000000000000000000001'); const expectedResultHash = ethUtil.bufferToHex(ethUtil.sha3(trueAsBuffer)); - const assetData = await devUtils.encodeStaticCallAssetData.callAsync( - staticCallTarget.address, - staticCallData, - expectedResultHash, - ); + const assetData = await devUtils + .encodeStaticCallAssetData(staticCallTarget.address, staticCallData, expectedResultHash) + .callAsync(); await expectTransactionFailedAsync( - staticCallProxy.transferFrom.sendTransactionAsync(assetData, fromAddress, toAddress, amount), + staticCallProxy.transferFrom(assetData, fromAddress, toAddress, amount).sendTransactionAsync(), RevertReason.UnexpectedStaticCallResult, ); }); it('should be successful if a function call with no inputs and no outputs is successful', async () => { - const staticCallData = staticCallTarget.noInputFunction.getABIEncodedTransactionData(); + const staticCallData = staticCallTarget.noInputFunction().getABIEncodedTransactionData(); const expectedResultHash = constants.KECCAK256_NULL; - const assetData = await devUtils.encodeStaticCallAssetData.callAsync( - staticCallTarget.address, - staticCallData, - expectedResultHash, - ); - await staticCallProxy.transferFrom.awaitTransactionSuccessAsync(assetData, fromAddress, toAddress, amount); + const assetData = await devUtils + .encodeStaticCallAssetData(staticCallTarget.address, staticCallData, expectedResultHash) + .callAsync(); + await staticCallProxy + .transferFrom(assetData, fromAddress, toAddress, amount) + .awaitTransactionSuccessAsync(); }); it('should be successful if the staticCallTarget is not a contract and no return value is expected', async () => { const staticCallData = '0x0102030405060708'; const expectedResultHash = constants.KECCAK256_NULL; - const assetData = await devUtils.encodeStaticCallAssetData.callAsync( - toAddress, - staticCallData, - expectedResultHash, - ); - await staticCallProxy.transferFrom.awaitTransactionSuccessAsync(assetData, fromAddress, toAddress, amount); + const assetData = await devUtils + .encodeStaticCallAssetData(toAddress, staticCallData, expectedResultHash) + .callAsync(); + await staticCallProxy + .transferFrom(assetData, fromAddress, toAddress, amount) + .awaitTransactionSuccessAsync(); }); it('should be successful if a function call with one static input returns the correct value', async () => { - const staticCallData = staticCallTarget.isOddNumber.getABIEncodedTransactionData(new BigNumber(1)); + const staticCallData = staticCallTarget.isOddNumber(new BigNumber(1)).getABIEncodedTransactionData(); const trueAsBuffer = ethUtil.toBuffer('0x0000000000000000000000000000000000000000000000000000000000000001'); const expectedResultHash = ethUtil.bufferToHex(ethUtil.sha3(trueAsBuffer)); - const assetData = await devUtils.encodeStaticCallAssetData.callAsync( - staticCallTarget.address, - staticCallData, - expectedResultHash, - ); - await staticCallProxy.transferFrom.awaitTransactionSuccessAsync(assetData, fromAddress, toAddress, amount); + const assetData = await devUtils + .encodeStaticCallAssetData(staticCallTarget.address, staticCallData, expectedResultHash) + .callAsync(); + await staticCallProxy + .transferFrom(assetData, fromAddress, toAddress, amount) + .awaitTransactionSuccessAsync(); }); it('should be successful if a function with one dynamic input is successful', async () => { const dynamicInput = '0x0102030405060708'; - const staticCallData = staticCallTarget.dynamicInputFunction.getABIEncodedTransactionData(dynamicInput); + const staticCallData = staticCallTarget.dynamicInputFunction(dynamicInput).getABIEncodedTransactionData(); const expectedResultHash = constants.KECCAK256_NULL; - const assetData = await devUtils.encodeStaticCallAssetData.callAsync( - staticCallTarget.address, - staticCallData, - expectedResultHash, - ); - await staticCallProxy.transferFrom.awaitTransactionSuccessAsync(assetData, fromAddress, toAddress, amount); + const assetData = await devUtils + .encodeStaticCallAssetData(staticCallTarget.address, staticCallData, expectedResultHash) + .callAsync(); + await staticCallProxy + .transferFrom(assetData, fromAddress, toAddress, amount) + .awaitTransactionSuccessAsync(); }); it('should be successful if a function call returns a complex type', async () => { const a = new BigNumber(1); const b = new BigNumber(2); - const staticCallData = staticCallTarget.returnComplexType.getABIEncodedTransactionData(a, b); + const staticCallData = staticCallTarget.returnComplexType(a, b).getABIEncodedTransactionData(); const abiEncoder = new AbiEncoder.DynamicBytes({ name: '', type: 'bytes', @@ -245,12 +230,12 @@ describe('StaticCallProxy', () => { const expectedResultHash = ethUtil.bufferToHex( ethUtil.sha3(ethUtil.toBuffer(encodedExpectedResultWithOffset)), ); - const assetData = await devUtils.encodeStaticCallAssetData.callAsync( - staticCallTarget.address, - staticCallData, - expectedResultHash, - ); - await staticCallProxy.transferFrom.awaitTransactionSuccessAsync(assetData, fromAddress, toAddress, amount); + const assetData = await devUtils + .encodeStaticCallAssetData(staticCallTarget.address, staticCallData, expectedResultHash) + .callAsync(); + await staticCallProxy + .transferFrom(assetData, fromAddress, toAddress, amount) + .awaitTransactionSuccessAsync(); }); }); }); diff --git a/contracts/asset-proxy/test/uniswap_bridge.ts b/contracts/asset-proxy/test/uniswap_bridge.ts index 2f7f6a0290..ae07d17abe 100644 --- a/contracts/asset-proxy/test/uniswap_bridge.ts +++ b/contracts/asset-proxy/test/uniswap_bridge.ts @@ -9,7 +9,7 @@ import { hexRandom, Numberish, randomAddress, - TransactionHelper, + transactionHelper, } from '@0x/contracts-test-utils'; import { AssetProxyId } from '@0x/types'; import { BigNumber } from '@0x/utils'; @@ -30,7 +30,6 @@ import { } from '../src'; blockchainTests.resets('UniswapBridge unit tests', env => { - const txHelper = new TransactionHelper(env.web3Wrapper, artifacts); let testContract: TestUniswapBridgeContract; let wethTokenAddress: string; @@ -41,13 +40,13 @@ blockchainTests.resets('UniswapBridge unit tests', env => { env.txDefaults, artifacts, ); - wethTokenAddress = await testContract.wethToken.callAsync(); + wethTokenAddress = await testContract.wethToken().callAsync(); }); describe('isValidSignature()', () => { it('returns success bytes', async () => { const LEGACY_WALLET_MAGIC_VALUE = '0xb0671381'; - const result = await testContract.isValidSignature.callAsync(hexRandom(), hexRandom(_.random(0, 32))); + const result = await testContract.isValidSignature(hexRandom(), hexRandom(_.random(0, 32))).callAsync(); expect(result).to.eq(LEGACY_WALLET_MAGIC_VALUE); }); }); @@ -90,33 +89,31 @@ blockchainTests.resets('UniswapBridge unit tests', env => { async function withdrawToAsync(opts?: Partial): Promise { const _opts = createWithdrawToOpts(opts); // Create the "from" token and exchange. - [[_opts.fromTokenAddress]] = await txHelper.getResultAndReceiptAsync( + [[_opts.fromTokenAddress]] = await transactionHelper.getResultAndReceiptAsync( testContract.createTokenAndExchange, _opts.fromTokenAddress, _opts.exchangeRevertReason, { value: new BigNumber(_opts.exchangeFillAmount) }, ); // Create the "to" token and exchange. - [[_opts.toTokenAddress]] = await txHelper.getResultAndReceiptAsync( + [[_opts.toTokenAddress]] = await transactionHelper.getResultAndReceiptAsync( testContract.createTokenAndExchange, _opts.toTokenAddress, _opts.exchangeRevertReason, { value: new BigNumber(_opts.exchangeFillAmount) }, ); - await testContract.setTokenRevertReason.awaitTransactionSuccessAsync( - _opts.toTokenAddress, - _opts.toTokenRevertReason, - ); - await testContract.setTokenRevertReason.awaitTransactionSuccessAsync( - _opts.fromTokenAddress, - _opts.fromTokenRevertReason, - ); + await testContract + .setTokenRevertReason(_opts.toTokenAddress, _opts.toTokenRevertReason) + .awaitTransactionSuccessAsync(); + await testContract + .setTokenRevertReason(_opts.fromTokenAddress, _opts.fromTokenRevertReason) + .awaitTransactionSuccessAsync(); // Set the token balance for the token we're converting from. - await testContract.setTokenBalance.awaitTransactionSuccessAsync(_opts.fromTokenAddress, { + await testContract.setTokenBalance(_opts.fromTokenAddress).awaitTransactionSuccessAsync({ value: new BigNumber(_opts.fromTokenBalance), }); // Call bridgeTransferFrom(). - const [result, receipt] = await txHelper.getResultAndReceiptAsync( + const [result, receipt] = await transactionHelper.getResultAndReceiptAsync( testContract.bridgeTransferFrom, // The "to" token address. _opts.toTokenAddress, @@ -138,7 +135,7 @@ blockchainTests.resets('UniswapBridge unit tests', env => { } async function getExchangeForTokenAsync(tokenAddress: string): Promise { - return testContract.getExchange.callAsync(tokenAddress); + return testContract.getExchange(tokenAddress).callAsync(); } it('returns magic bytes on success', async () => { @@ -147,7 +144,7 @@ blockchainTests.resets('UniswapBridge unit tests', env => { }); it('just transfers tokens to `to` if the same tokens are in play', async () => { - const [[tokenAddress]] = await txHelper.getResultAndReceiptAsync( + const [[tokenAddress]] = await transactionHelper.getResultAndReceiptAsync( testContract.createTokenAndExchange, constants.NULL_ADDRESS, '', @@ -203,13 +200,15 @@ blockchainTests.resets('UniswapBridge unit tests', env => { }); it('fails if "from" token does not exist', async () => { - const tx = testContract.bridgeTransferFrom.awaitTransactionSuccessAsync( - randomAddress(), - randomAddress(), - randomAddress(), - getRandomInteger(1, 1e18), - hexLeftPad(randomAddress()), - ); + const tx = testContract + .bridgeTransferFrom( + randomAddress(), + randomAddress(), + randomAddress(), + getRandomInteger(1, 1e18), + hexLeftPad(randomAddress()), + ) + .awaitTransactionSuccessAsync(); return expect(tx).to.revertWith('NO_UNISWAP_EXCHANGE_FOR_TOKEN'); }); @@ -275,13 +274,15 @@ blockchainTests.resets('UniswapBridge unit tests', env => { }); it('fails if "from" token does not exist', async () => { - const tx = testContract.bridgeTransferFrom.awaitTransactionSuccessAsync( - randomAddress(), - randomAddress(), - randomAddress(), - getRandomInteger(1, 1e18), - hexLeftPad(wethTokenAddress), - ); + const tx = testContract + .bridgeTransferFrom( + randomAddress(), + randomAddress(), + randomAddress(), + getRandomInteger(1, 1e18), + hexLeftPad(wethTokenAddress), + ) + .awaitTransactionSuccessAsync(); return expect(tx).to.revertWith('NO_UNISWAP_EXCHANGE_FOR_TOKEN'); }); @@ -333,13 +334,15 @@ blockchainTests.resets('UniswapBridge unit tests', env => { }); it('fails if "to" token does not exist', async () => { - const tx = testContract.bridgeTransferFrom.awaitTransactionSuccessAsync( - wethTokenAddress, - randomAddress(), - randomAddress(), - getRandomInteger(1, 1e18), - hexLeftPad(randomAddress()), - ); + const tx = testContract + .bridgeTransferFrom( + wethTokenAddress, + randomAddress(), + randomAddress(), + getRandomInteger(1, 1e18), + hexLeftPad(randomAddress()), + ) + .awaitTransactionSuccessAsync(); return expect(tx).to.revertWith('NO_UNISWAP_EXCHANGE_FOR_TOKEN'); }); diff --git a/contracts/asset-proxy/test/utils/erc1155_proxy_wrapper.ts b/contracts/asset-proxy/test/utils/erc1155_proxy_wrapper.ts index 5bc707af41..6dbe18bb46 100644 --- a/contracts/asset-proxy/test/utils/erc1155_proxy_wrapper.ts +++ b/contracts/asset-proxy/test/utils/erc1155_proxy_wrapper.ts @@ -74,7 +74,7 @@ export class ERC1155ProxyWrapper { txDefaults, artifacts, ); - this._proxyIdIfExists = await this._proxyContract.getProxyId.callAsync(); + this._proxyIdIfExists = await this._proxyContract.getProxyId().callAsync(); return this._proxyContract; } /** @@ -111,19 +111,13 @@ export class ERC1155ProxyWrapper { this._validateProxyContractExistsOrThrow(); const assetData = assetData_ === undefined - ? await this._devUtils.encodeERC1155AssetData.callAsync( - contractAddress, - tokensToTransfer, - valuesToTransfer, - receiverCallbackData, - ) + ? await this._devUtils + .encodeERC1155AssetData(contractAddress, tokensToTransfer, valuesToTransfer, receiverCallbackData) + .callAsync() : assetData_; - const data = this._assetProxyInterface.transferFrom.getABIEncodedTransactionData( - assetData, - from, - to, - valueMultiplier, - ); + const data = this._assetProxyInterface + .transferFrom(assetData, from, to, valueMultiplier) + .getABIEncodedTransactionData(); return data; } /** @@ -171,19 +165,13 @@ export class ERC1155ProxyWrapper { this._validateProxyContractExistsOrThrow(); const assetData = assetData_ === undefined - ? await this._devUtils.encodeERC1155AssetData.callAsync( - contractAddress, - tokensToTransfer, - valuesToTransfer, - receiverCallbackData, - ) + ? await this._devUtils + .encodeERC1155AssetData(contractAddress, tokensToTransfer, valuesToTransfer, receiverCallbackData) + .callAsync() : assetData_; - const data = this._assetProxyInterface.transferFrom.getABIEncodedTransactionData( - assetData, - from, - to, - valueMultiplier, - ); + const data = this._assetProxyInterface + .transferFrom(assetData, from, to, valueMultiplier) + .getABIEncodedTransactionData(); const txHash = await this._web3Wrapper.sendTransactionAsync({ to: (this._proxyContract as ERC1155ProxyContract).address, data, @@ -364,7 +352,7 @@ export class ERC1155ProxyWrapper { this._validateProxyContractExistsOrThrow(); const tokenContract = this._getContractFromAddress(contractAddress); const operator = (this._proxyContract as ERC1155ProxyContract).address; - const didApproveAll = await tokenContract.isApprovedForAll.callAsync(userAddress, operator); + const didApproveAll = await tokenContract.isApprovedForAll(userAddress, operator).callAsync(); return didApproveAll; } public getFungibleTokenIds(): BigNumber[] { diff --git a/contracts/asset-proxy/test/utils/erc20_wrapper.ts b/contracts/asset-proxy/test/utils/erc20_wrapper.ts index 52e8d43142..57a9a2afe3 100644 --- a/contracts/asset-proxy/test/utils/erc20_wrapper.ts +++ b/contracts/asset-proxy/test/utils/erc20_wrapper.ts @@ -56,7 +56,7 @@ export class ERC20Wrapper { txDefaults, artifacts, ); - this._proxyIdIfExists = await this._proxyContract.getProxyId.callAsync(); + this._proxyIdIfExists = await this._proxyContract.getProxyId().callAsync(); return this._proxyContract; } public getProxyId(): string { @@ -68,43 +68,39 @@ export class ERC20Wrapper { this._validateProxyContractExistsOrThrow(); for (const dummyTokenContract of this._dummyTokenContracts) { for (const tokenOwnerAddress of this._tokenOwnerAddresses) { - await dummyTokenContract.setBalance.awaitTransactionSuccessAsync( - tokenOwnerAddress, - constants.INITIAL_ERC20_BALANCE, - { from: this._contractOwnerAddress }, - ); - await dummyTokenContract.approve.awaitTransactionSuccessAsync( - (this._proxyContract as ERC20ProxyContract).address, - constants.INITIAL_ERC20_ALLOWANCE, - { from: tokenOwnerAddress }, - ); + await dummyTokenContract + .setBalance(tokenOwnerAddress, constants.INITIAL_ERC20_BALANCE) + .awaitTransactionSuccessAsync({ from: this._contractOwnerAddress }); + await dummyTokenContract + .approve((this._proxyContract as ERC20ProxyContract).address, constants.INITIAL_ERC20_ALLOWANCE) + .awaitTransactionSuccessAsync({ from: tokenOwnerAddress }); } } } public async getBalanceAsync(userAddress: string, assetData: string): Promise { const tokenContract = await this._getTokenContractFromAssetDataAsync(assetData); - const balance = new BigNumber(await tokenContract.balanceOf.callAsync(userAddress)); + const balance = new BigNumber(await tokenContract.balanceOf(userAddress).callAsync()); return balance; } public async setBalanceAsync(userAddress: string, assetData: string, amount: BigNumber): Promise { const tokenContract = await this._getTokenContractFromAssetDataAsync(assetData); - await tokenContract.setBalance.awaitTransactionSuccessAsync( - userAddress, - amount, - { from: this._contractOwnerAddress }, - { pollingIntervalMs: constants.AWAIT_TRANSACTION_MINED_MS }, - ); + await tokenContract + .setBalance(userAddress, amount) + .awaitTransactionSuccessAsync( + { from: this._contractOwnerAddress }, + { pollingIntervalMs: constants.AWAIT_TRANSACTION_MINED_MS }, + ); } public async getProxyAllowanceAsync(userAddress: string, assetData: string): Promise { const tokenContract = await this._getTokenContractFromAssetDataAsync(assetData); const proxyAddress = (this._proxyContract as ERC20ProxyContract).address; - const allowance = new BigNumber(await tokenContract.allowance.callAsync(userAddress, proxyAddress)); + const allowance = new BigNumber(await tokenContract.allowance(userAddress, proxyAddress).callAsync()); return allowance; } public async setAllowanceAsync(userAddress: string, assetData: string, amount: BigNumber): Promise { const tokenContract = await this._getTokenContractFromAssetDataAsync(assetData); const proxyAddress = (this._proxyContract as ERC20ProxyContract).address; - await tokenContract.approve.awaitTransactionSuccessAsync(proxyAddress, amount, { from: userAddress }); + await tokenContract.approve(proxyAddress, amount).awaitTransactionSuccessAsync({ from: userAddress }); } public async getBalancesAsync(): Promise { this._validateDummyTokenContractsExistOrThrow(); @@ -113,7 +109,7 @@ export class ERC20Wrapper { const balanceInfo: Array<{ tokenOwnerAddress: string; tokenAddress: string }> = []; for (const dummyTokenContract of this._dummyTokenContracts) { for (const tokenOwnerAddress of this._tokenOwnerAddresses) { - balances.push(await dummyTokenContract.balanceOf.callAsync(tokenOwnerAddress)); + balances.push(await dummyTokenContract.balanceOf(tokenOwnerAddress).callAsync()); balanceInfo.push({ tokenOwnerAddress, tokenAddress: dummyTokenContract.address, @@ -147,7 +143,7 @@ export class ERC20Wrapper { return tokenAddresses; } private async _getTokenContractFromAssetDataAsync(assetData: string): Promise { - const [proxyId, tokenAddress] = await this._devUtils.decodeERC20AssetData.callAsync(assetData); // tslint:disable-line:no-unused-variable + const [proxyId, tokenAddress] = await this._devUtils.decodeERC20AssetData(assetData).callAsync(); // tslint:disable-line:no-unused-variable const tokenContractIfExists = _.find(this._dummyTokenContracts, c => c.address === tokenAddress); if (tokenContractIfExists === undefined) { throw new Error(`Token: ${tokenAddress} was not deployed through ERC20Wrapper`); diff --git a/contracts/asset-proxy/test/utils/erc721_wrapper.ts b/contracts/asset-proxy/test/utils/erc721_wrapper.ts index e2ae988930..ec50c15847 100644 --- a/contracts/asset-proxy/test/utils/erc721_wrapper.ts +++ b/contracts/asset-proxy/test/utils/erc721_wrapper.ts @@ -44,7 +44,7 @@ export class ERC721Wrapper { txDefaults, artifacts, ); - this._proxyIdIfExists = await this._proxyContract.getProxyId.callAsync(); + this._proxyIdIfExists = await this._proxyContract.getProxyId().callAsync(); return this._proxyContract; } public getProxyId(): string { @@ -78,7 +78,7 @@ export class ERC721Wrapper { } public async doesTokenExistAsync(tokenAddress: string, tokenId: BigNumber): Promise { const tokenContract = this._getTokenContractFromAssetData(tokenAddress); - const owner = await tokenContract.ownerOf.callAsync(tokenId); + const owner = await tokenContract.ownerOf(tokenId).callAsync(); const doesExist = owner !== constants.NULL_ADDRESS; return doesExist; } @@ -93,14 +93,14 @@ export class ERC721Wrapper { ): Promise { const tokenContract = this._getTokenContractFromAssetData(tokenAddress); const proxyAddress = (this._proxyContract as ERC721ProxyContract).address; - await tokenContract.setApprovalForAll.awaitTransactionSuccessAsync(proxyAddress, isApproved, { + await tokenContract.setApprovalForAll(proxyAddress, isApproved).awaitTransactionSuccessAsync({ from: ownerAddress, }); } public async approveAsync(to: string, tokenAddress: string, tokenId: BigNumber): Promise { const tokenContract = this._getTokenContractFromAssetData(tokenAddress); const tokenOwner = await this.ownerOfAsync(tokenAddress, tokenId); - await tokenContract.approve.awaitTransactionSuccessAsync(to, tokenId, { from: tokenOwner }); + await tokenContract.approve(to, tokenId).awaitTransactionSuccessAsync({ from: tokenOwner }); } public async transferFromAsync( tokenAddress: string, @@ -109,28 +109,28 @@ export class ERC721Wrapper { userAddress: string, ): Promise { const tokenContract = this._getTokenContractFromAssetData(tokenAddress); - await tokenContract.transferFrom.awaitTransactionSuccessAsync(currentOwner, userAddress, tokenId, { + await tokenContract.transferFrom(currentOwner, userAddress, tokenId).awaitTransactionSuccessAsync({ from: currentOwner, }); } public async mintAsync(tokenAddress: string, tokenId: BigNumber, userAddress: string): Promise { const tokenContract = this._getTokenContractFromAssetData(tokenAddress); - await tokenContract.mint.awaitTransactionSuccessAsync(userAddress, tokenId, { + await tokenContract.mint(userAddress, tokenId).awaitTransactionSuccessAsync({ from: this._contractOwnerAddress, }); } public async burnAsync(tokenAddress: string, tokenId: BigNumber, owner: string): Promise { const tokenContract = this._getTokenContractFromAssetData(tokenAddress); - await tokenContract.burn.awaitTransactionSuccessAsync(owner, tokenId, { from: this._contractOwnerAddress }); + await tokenContract.burn(owner, tokenId).awaitTransactionSuccessAsync({ from: this._contractOwnerAddress }); } public async ownerOfAsync(tokenAddress: string, tokenId: BigNumber): Promise { const tokenContract = this._getTokenContractFromAssetData(tokenAddress); - const owner = await tokenContract.ownerOf.callAsync(tokenId); + const owner = await tokenContract.ownerOf(tokenId).callAsync(); return owner; } public async isOwnerAsync(userAddress: string, tokenAddress: string, tokenId: BigNumber): Promise { const tokenContract = this._getTokenContractFromAssetData(tokenAddress); - const tokenOwner = await tokenContract.ownerOf.callAsync(tokenId); + const tokenOwner = await tokenContract.ownerOf(tokenId).callAsync(); const isOwner = tokenOwner === userAddress; return isOwner; } @@ -138,13 +138,13 @@ export class ERC721Wrapper { this._validateProxyContractExistsOrThrow(); const tokenContract = this._getTokenContractFromAssetData(tokenAddress); const operator = (this._proxyContract as ERC721ProxyContract).address; - const didApproveAll = await tokenContract.isApprovedForAll.callAsync(userAddress, operator); + const didApproveAll = await tokenContract.isApprovedForAll(userAddress, operator).callAsync(); return didApproveAll; } public async isProxyApprovedAsync(tokenAddress: string, tokenId: BigNumber): Promise { this._validateProxyContractExistsOrThrow(); const tokenContract = this._getTokenContractFromAssetData(tokenAddress); - const approvedAddress = await tokenContract.getApproved.callAsync(tokenId); + const approvedAddress = await tokenContract.getApproved(tokenId).callAsync(); const proxyAddress = (this._proxyContract as ERC721ProxyContract).address; const isProxyAnApprovedOperator = approvedAddress === proxyAddress; return isProxyAnApprovedOperator; @@ -161,7 +161,7 @@ export class ERC721Wrapper { dummyTokenContract.address ]; for (const tokenId of initialTokenOwnerIds) { - tokenOwnerAddresses.push(await dummyTokenContract.ownerOf.callAsync(tokenId)); + tokenOwnerAddresses.push(await dummyTokenContract.ownerOf(tokenId).callAsync()); tokenInfo.push({ tokenId, tokenAddress: dummyTokenContract.address, diff --git a/contracts/coordinator/test/coordinator_registry.ts b/contracts/coordinator/test/coordinator_registry.ts index 743132fa7e..8a2c8906f0 100644 --- a/contracts/coordinator/test/coordinator_registry.ts +++ b/contracts/coordinator/test/coordinator_registry.ts @@ -23,43 +23,42 @@ blockchainTests.resets('Coordinator Registry tests', env => { }); describe('core', () => { it('Should successfully set a Coordinator endpoint', async () => { - await coordinatorRegistry.setCoordinatorEndpoint.awaitTransactionSuccessAsync(coordinatorEndpoint, { + await coordinatorRegistry.setCoordinatorEndpoint(coordinatorEndpoint).awaitTransactionSuccessAsync({ from: coordinatorOperator, }); - const recordedCoordinatorEndpoint = await coordinatorRegistry.getCoordinatorEndpoint.callAsync( - coordinatorOperator, - ); + const recordedCoordinatorEndpoint = await coordinatorRegistry + .getCoordinatorEndpoint(coordinatorOperator) + .callAsync(); expect(recordedCoordinatorEndpoint).to.be.equal(coordinatorEndpoint); }); it('Should successfully unset a Coordinator endpoint', async () => { // set Coordinator endpoint - await coordinatorRegistry.setCoordinatorEndpoint.awaitTransactionSuccessAsync(coordinatorEndpoint, { + await coordinatorRegistry.setCoordinatorEndpoint(coordinatorEndpoint).awaitTransactionSuccessAsync({ from: coordinatorOperator, }); - let recordedCoordinatorEndpoint = await coordinatorRegistry.getCoordinatorEndpoint.callAsync( - coordinatorOperator, - ); + let recordedCoordinatorEndpoint = await coordinatorRegistry + .getCoordinatorEndpoint(coordinatorOperator) + .callAsync(); expect(recordedCoordinatorEndpoint).to.be.equal(coordinatorEndpoint); // unset Coordinator endpoint - await coordinatorRegistry.setCoordinatorEndpoint.awaitTransactionSuccessAsync(nilCoordinatorEndpoint, { + await coordinatorRegistry.setCoordinatorEndpoint(nilCoordinatorEndpoint).awaitTransactionSuccessAsync({ from: coordinatorOperator, }); - recordedCoordinatorEndpoint = await coordinatorRegistry.getCoordinatorEndpoint.callAsync( - coordinatorOperator, - ); + recordedCoordinatorEndpoint = await coordinatorRegistry + .getCoordinatorEndpoint(coordinatorOperator) + .callAsync(); expect(recordedCoordinatorEndpoint).to.be.equal(nilCoordinatorEndpoint); }); it('Should emit an event when setting Coordinator endpoint', async () => { // set Coordinator endpoint - const txReceipt = await coordinatorRegistry.setCoordinatorEndpoint.awaitTransactionSuccessAsync( - coordinatorEndpoint, - { + const txReceipt = await coordinatorRegistry + .setCoordinatorEndpoint(coordinatorEndpoint) + .awaitTransactionSuccessAsync({ from: coordinatorOperator, - }, - ); - const recordedCoordinatorEndpoint = await coordinatorRegistry.getCoordinatorEndpoint.callAsync( - coordinatorOperator, - ); + }); + const recordedCoordinatorEndpoint = await coordinatorRegistry + .getCoordinatorEndpoint(coordinatorOperator) + .callAsync(); expect(recordedCoordinatorEndpoint).to.be.equal(coordinatorEndpoint); // validate event const expectedEvent: CoordinatorRegistryCoordinatorEndpointSetEventArgs = { diff --git a/contracts/coordinator/test/libs.ts b/contracts/coordinator/test/libs.ts index ef6eb0b2a7..1ae2630d13 100644 --- a/contracts/coordinator/test/libs.ts +++ b/contracts/coordinator/test/libs.ts @@ -42,7 +42,7 @@ blockchainTests.resets('Libs tests', env => { transactionSignature: signedTx.signature, }; const expectedApprovalHash = hashUtils.getApprovalHashHex(signedTx, coordinatorContract.address, txOrigin); - const approvalHash = await coordinatorContract.getCoordinatorApprovalHash.callAsync(approval); + const approvalHash = await coordinatorContract.getCoordinatorApprovalHash(approval).callAsync(); expect(expectedApprovalHash).to.eq(approvalHash); }); }); diff --git a/contracts/coordinator/test/mixins.ts b/contracts/coordinator/test/mixins.ts index 4ee471b797..de86012ea2 100644 --- a/contracts/coordinator/test/mixins.ts +++ b/contracts/coordinator/test/mixins.ts @@ -70,14 +70,14 @@ blockchainTests.resets('Mixins tests', env => { const data = constants.NULL_BYTES; const transaction = await transactionFactory.newSignedTransactionAsync({ data }, SignatureType.EthSign); const transactionHash = transactionHashUtils.getTransactionHashHex(transaction); - const signerAddress = await mixins.getSignerAddress.callAsync(transactionHash, transaction.signature); + const signerAddress = await mixins.getSignerAddress(transactionHash, transaction.signature).callAsync(); expect(transaction.signerAddress).to.eq(signerAddress); }); it('should return the correct address using the EIP712 signature type', async () => { const data = constants.NULL_BYTES; const transaction = await transactionFactory.newSignedTransactionAsync({ data }, SignatureType.EIP712); const transactionHash = transactionHashUtils.getTransactionHashHex(transaction); - const signerAddress = await mixins.getSignerAddress.callAsync(transactionHash, transaction.signature); + const signerAddress = await mixins.getSignerAddress(transactionHash, transaction.signature).callAsync(); expect(transaction.signerAddress).to.eq(signerAddress); }); it('should revert with with the Illegal signature type', async () => { @@ -88,7 +88,7 @@ blockchainTests.resets('Mixins tests', env => { SignatureType.Illegal, ); const transactionHash = transactionHashUtils.getTransactionHashHex(transaction); - expect(mixins.getSignerAddress.callAsync(transactionHash, transaction.signature)).to.revertWith( + expect(mixins.getSignerAddress(transactionHash, transaction.signature).callAsync()).to.revertWith( new CoordinatorRevertErrors.SignatureError( CoordinatorRevertErrors.SignatureErrorCodes.Illegal, transactionHash, @@ -101,7 +101,7 @@ blockchainTests.resets('Mixins tests', env => { const transaction = await transactionFactory.newSignedTransactionAsync({ data }); transaction.signature = hexConcat(SignatureType.Invalid); const transactionHash = transactionHashUtils.getTransactionHashHex(transaction); - expect(mixins.getSignerAddress.callAsync(transactionHash, transaction.signature)).to.revertWith( + expect(mixins.getSignerAddress(transactionHash, transaction.signature).callAsync()).to.revertWith( new CoordinatorRevertErrors.SignatureError( CoordinatorRevertErrors.SignatureErrorCodes.Invalid, transactionHash, @@ -117,7 +117,7 @@ blockchainTests.resets('Mixins tests', env => { SignatureType.NSignatureTypes, ); const transactionHash = transactionHashUtils.getTransactionHashHex(transaction); - expect(mixins.getSignerAddress.callAsync(transactionHash, transaction.signature)).to.revertWith( + expect(mixins.getSignerAddress(transactionHash, transaction.signature).callAsync()).to.revertWith( new CoordinatorRevertErrors.SignatureError( CoordinatorRevertErrors.SignatureErrorCodes.Unsupported, transactionHash, @@ -133,7 +133,7 @@ blockchainTests.resets('Mixins tests', env => { SignatureType.Wallet, ); const transactionHash = transactionHashUtils.getTransactionHashHex(transaction); - expect(mixins.getSignerAddress.callAsync(transactionHash, transaction.signature)).to.revertWith( + expect(mixins.getSignerAddress(transactionHash, transaction.signature).callAsync()).to.revertWith( new CoordinatorRevertErrors.SignatureError( CoordinatorRevertErrors.SignatureErrorCodes.Unsupported, transactionHash, @@ -148,7 +148,7 @@ blockchainTests.resets('Mixins tests', env => { it(`should correctly decode the orders for ${fnName} data`, async () => { const orders = [defaultOrder]; const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); - const decodedOrders = await mixins.decodeOrdersFromFillData.callAsync(data); + const decodedOrders = await mixins.decodeOrdersFromFillData(data).callAsync(); const decodedSignedOrders = decodedOrders.map(order => ({ ...order, signature: constants.NULL_BYTES, @@ -162,7 +162,7 @@ blockchainTests.resets('Mixins tests', env => { it(`should correctly decode the orders for ${fnName} data`, async () => { const orders = [defaultOrder, defaultOrder]; const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); - const decodedOrders = await mixins.decodeOrdersFromFillData.callAsync(data); + const decodedOrders = await mixins.decodeOrdersFromFillData(data).callAsync(); const decodedSignedOrders = decodedOrders.map(order => ({ ...order, signature: constants.NULL_BYTES, @@ -176,7 +176,7 @@ blockchainTests.resets('Mixins tests', env => { it(`should correctly decode the orders for ${fnName} data`, async () => { const orders = [defaultOrder, defaultOrder]; const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); - const decodedOrders = await mixins.decodeOrdersFromFillData.callAsync(data); + const decodedOrders = await mixins.decodeOrdersFromFillData(data).callAsync(); const decodedSignedOrders = decodedOrders.map(order => ({ ...order, signature: constants.NULL_BYTES, @@ -190,7 +190,7 @@ blockchainTests.resets('Mixins tests', env => { it(`should correctly decode the orders for ${fnName} data`, async () => { const orders = [defaultOrder, defaultOrder]; const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); - const decodedOrders = await mixins.decodeOrdersFromFillData.callAsync(data); + const decodedOrders = await mixins.decodeOrdersFromFillData(data).callAsync(); const decodedSignedOrders = decodedOrders.map(order => ({ ...order, signature: constants.NULL_BYTES, @@ -204,14 +204,14 @@ blockchainTests.resets('Mixins tests', env => { it(`should correctly decode the orders for ${fnName} data`, async () => { const orders = [defaultOrder, defaultOrder]; const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); - const decodedOrders = await mixins.decodeOrdersFromFillData.callAsync(data); + const decodedOrders = await mixins.decodeOrdersFromFillData(data).callAsync(); const emptyArray: any[] = []; expect(emptyArray).to.deep.eq(decodedOrders); }); } it('should decode an empty array for invalid data', async () => { const data = '0x0123456789'; - const decodedOrders = await mixins.decodeOrdersFromFillData.callAsync(data); + const decodedOrders = await mixins.decodeOrdersFromFillData(data).callAsync(); const emptyArray: any[] = []; expect(emptyArray).to.deep.eq(decodedOrders); }); @@ -222,7 +222,7 @@ blockchainTests.resets('Mixins tests', env => { new BigNumber(3), // the length of data new BigNumber(4), ); - return expect(mixins.decodeOrdersFromFillData.callAsync(data)).to.revertWith(expectedError); + return expect(mixins.decodeOrdersFromFillData(data).callAsync()).to.revertWith(expectedError); }); }); @@ -233,13 +233,11 @@ blockchainTests.resets('Mixins tests', env => { const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); const transaction = await transactionFactory.newSignedTransactionAsync({ data }); const approval = approvalFactory1.newSignedApproval(transaction, transactionSignerAddress); - await mixins.assertValidCoordinatorApprovals.callAsync( - transaction, - transactionSignerAddress, - transaction.signature, - [approval.signature], - { from: transactionSignerAddress }, - ); + await mixins + .assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, [ + approval.signature, + ]) + .callAsync({ from: transactionSignerAddress }); }); it(`Should be successful: function=${fnName}, caller=tx_signer, senderAddress=[null], approval_sig=[approver1]`, async () => { const order = { @@ -250,54 +248,42 @@ blockchainTests.resets('Mixins tests', env => { const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); const transaction = await transactionFactory.newSignedTransactionAsync({ data }); const approval = approvalFactory1.newSignedApproval(transaction, transactionSignerAddress); - await mixins.assertValidCoordinatorApprovals.callAsync( - transaction, - transactionSignerAddress, - transaction.signature, - [approval.signature], - { from: transactionSignerAddress }, - ); + await mixins + .assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, [ + approval.signature, + ]) + .callAsync({ from: transactionSignerAddress }); }); it(`Should be successful: function=${fnName}, caller=approver1, senderAddress=[verifier], approval_sig=[]`, async () => { const orders = [defaultOrder]; const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); const transaction = await transactionFactory.newSignedTransactionAsync({ data }); - await mixins.assertValidCoordinatorApprovals.callAsync( - transaction, - approvalSignerAddress1, - transaction.signature, - [], - { + await mixins + .assertValidCoordinatorApprovals(transaction, approvalSignerAddress1, transaction.signature, []) + .callAsync({ from: approvalSignerAddress1, - }, - ); + }); }); it(`Should be successful: function=${fnName}, caller=approver1, senderAddress=[verifier], approval_sig=[approver1]`, async () => { const orders = [defaultOrder]; const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); const transaction = await transactionFactory.newSignedTransactionAsync({ data }); const approval = approvalFactory1.newSignedApproval(transaction, transactionSignerAddress); - await mixins.assertValidCoordinatorApprovals.callAsync( - transaction, - approvalSignerAddress1, - transaction.signature, - [approval.signature], - { from: approvalSignerAddress1 }, - ); + await mixins + .assertValidCoordinatorApprovals(transaction, approvalSignerAddress1, transaction.signature, [ + approval.signature, + ]) + .callAsync({ from: approvalSignerAddress1 }); }); it(`Should be successful: function=${fnName}, caller=approver1, senderAddress=[verifier], approval_sig=[]`, async () => { const orders = [defaultOrder]; const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); const transaction = await transactionFactory.newSignedTransactionAsync({ data }); - await mixins.assertValidCoordinatorApprovals.callAsync( - transaction, - approvalSignerAddress1, - transaction.signature, - [], - { + await mixins + .assertValidCoordinatorApprovals(transaction, approvalSignerAddress1, transaction.signature, []) + .callAsync({ from: approvalSignerAddress1, - }, - ); + }); }); it(`Should revert: function=${fnName}, caller=tx_signer, senderAddress=[verifier], approval_sig=[invalid]`, async () => { const orders = [defaultOrder]; @@ -309,13 +295,11 @@ blockchainTests.resets('Mixins tests', env => { '0xFFFFFFFF', hexSlice(approval.signature, 6), ); - const tx = mixins.assertValidCoordinatorApprovals.callAsync( - transaction, - transactionSignerAddress, - transaction.signature, - [signature], - { from: transactionSignerAddress }, - ); + const tx = mixins + .assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, [ + signature, + ]) + .callAsync({ from: transactionSignerAddress }); const transactionHash = transactionHashUtils.getTransactionHashHex(transaction); expect(tx).to.revertWith( @@ -328,13 +312,11 @@ blockchainTests.resets('Mixins tests', env => { const transaction = await transactionFactory.newSignedTransactionAsync({ data }); const approval = approvalFactory1.newSignedApproval(transaction, transactionSignerAddress); - const tx = mixins.assertValidCoordinatorApprovals.callAsync( - transaction, - transactionSignerAddress, - transaction.signature, - [approval.signature], - { from: approvalSignerAddress2 }, - ); + const tx = mixins + .assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, [ + approval.signature, + ]) + .callAsync({ from: approvalSignerAddress2 }); expect(tx).to.revertWith(new CoordinatorRevertErrors.InvalidOriginError(transactionSignerAddress)); }); } @@ -350,13 +332,11 @@ blockchainTests.resets('Mixins tests', env => { const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); const transaction = await transactionFactory.newSignedTransactionAsync({ data }); const approval = approvalFactory1.newSignedApproval(transaction, transactionSignerAddress); - await mixins.assertValidCoordinatorApprovals.callAsync( - transaction, - transactionSignerAddress, - transaction.signature, - [approval.signature], - { from: transactionSignerAddress }, - ); + await mixins + .assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, [ + approval.signature, + ]) + .callAsync({ from: transactionSignerAddress }); }); it(`Should be successful: function=${fnName} caller=tx_signer, senderAddress=[null,null], feeRecipient=[approver1,approver1], approval_sig=[approver1]`, async () => { const orders = [defaultOrder, defaultOrder].map(order => ({ @@ -366,13 +346,11 @@ blockchainTests.resets('Mixins tests', env => { const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); const transaction = await transactionFactory.newSignedTransactionAsync({ data }); const approval = approvalFactory1.newSignedApproval(transaction, transactionSignerAddress); - await mixins.assertValidCoordinatorApprovals.callAsync( - transaction, - transactionSignerAddress, - transaction.signature, - [approval.signature], - { from: transactionSignerAddress }, - ); + await mixins + .assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, [ + approval.signature, + ]) + .callAsync({ from: transactionSignerAddress }); }); it(`Should be successful: function=${fnName} caller=tx_signer, senderAddress=[null,null], feeRecipient=[approver1,approver1], approval_sig=[]`, async () => { const orders = [defaultOrder, defaultOrder].map(order => ({ @@ -381,26 +359,20 @@ blockchainTests.resets('Mixins tests', env => { })); const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); const transaction = await transactionFactory.newSignedTransactionAsync({ data }); - await mixins.assertValidCoordinatorApprovals.callAsync( - transaction, - transactionSignerAddress, - transaction.signature, - [], - { from: transactionSignerAddress }, - ); + await mixins + .assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, []) + .callAsync({ from: transactionSignerAddress }); }); it(`Should be successful: function=${fnName} caller=tx_signer, senderAddress=[verifier,null], feeRecipient=[approver1,approver1], approval_sig=[approver1]`, async () => { const orders = [defaultOrder, { ...defaultOrder, senderAddress: constants.NULL_ADDRESS }]; const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); const transaction = await transactionFactory.newSignedTransactionAsync({ data }); const approval = approvalFactory1.newSignedApproval(transaction, transactionSignerAddress); - await mixins.assertValidCoordinatorApprovals.callAsync( - transaction, - transactionSignerAddress, - transaction.signature, - [approval.signature], - { from: transactionSignerAddress }, - ); + await mixins + .assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, [ + approval.signature, + ]) + .callAsync({ from: transactionSignerAddress }); }); it(`Should be successful: function=${fnName} caller=tx_signer, senderAddress=[verifier,verifier], feeRecipient=[approver1,approver2], approval_sig=[approver1,approver2]`, async () => { const orders = [defaultOrder, { ...defaultOrder, feeRecipientAddress: approvalSignerAddress2 }]; @@ -408,25 +380,20 @@ blockchainTests.resets('Mixins tests', env => { const transaction = await transactionFactory.newSignedTransactionAsync({ data }); const approval1 = approvalFactory1.newSignedApproval(transaction, transactionSignerAddress); const approval2 = approvalFactory2.newSignedApproval(transaction, transactionSignerAddress); - await mixins.assertValidCoordinatorApprovals.callAsync( - transaction, - transactionSignerAddress, - transaction.signature, - [approval1.signature, approval2.signature], - { from: transactionSignerAddress }, - ); + await mixins + .assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, [ + approval1.signature, + approval2.signature, + ]) + .callAsync({ from: transactionSignerAddress }); }); it(`Should be successful: function=${fnName} caller=approver1, senderAddress=[verifier,verifier], feeRecipient=[approver1,approver1], approval_sig=[]`, async () => { const orders = [defaultOrder, defaultOrder]; const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); const transaction = await transactionFactory.newSignedTransactionAsync({ data }); - await mixins.assertValidCoordinatorApprovals.callAsync( - transaction, - approvalSignerAddress1, - transaction.signature, - [], - { from: approvalSignerAddress1 }, - ); + await mixins + .assertValidCoordinatorApprovals(transaction, approvalSignerAddress1, transaction.signature, []) + .callAsync({ from: approvalSignerAddress1 }); }); it(`Should revert: function=${fnName} caller=approver1, senderAddress=[verifier,verifier], feeRecipient=[approver1,approver2], approval_sig=[approver2]`, async () => { const orders = [defaultOrder, { ...defaultOrder, feeRecipientAddress: approvalSignerAddress2 }]; @@ -434,26 +401,20 @@ blockchainTests.resets('Mixins tests', env => { const transaction = await transactionFactory.newSignedTransactionAsync({ data }); const approval2 = approvalFactory2.newSignedApproval(transaction, transactionSignerAddress); - const tx = mixins.assertValidCoordinatorApprovals.callAsync( - transaction, - transactionSignerAddress, - transaction.signature, - [approval2.signature], - { from: approvalSignerAddress1 }, - ); + const tx = mixins + .assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, [ + approval2.signature, + ]) + .callAsync({ from: approvalSignerAddress1 }); expect(tx).to.revertWith(new CoordinatorRevertErrors.InvalidOriginError(transactionSignerAddress)); }); it(`Should revert: function=${fnName} caller=tx_signer, senderAddress=[verifier,verifier], feeRecipient=[approver1, approver1], approval_sig=[]`, async () => { const orders = [defaultOrder, defaultOrder]; const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); const transaction = await transactionFactory.newSignedTransactionAsync({ data }); - const tx = mixins.assertValidCoordinatorApprovals.callAsync( - transaction, - transactionSignerAddress, - transaction.signature, - [], - { from: transactionSignerAddress }, - ); + const tx = mixins + .assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, []) + .callAsync({ from: transactionSignerAddress }); const transactionHash = transactionHashUtils.getTransactionHashHex(transaction); expect(tx).to.revertWith( @@ -470,13 +431,11 @@ blockchainTests.resets('Mixins tests', env => { '0xFFFFFFFF', hexSlice(approval.signature, 6), ); - const tx = mixins.assertValidCoordinatorApprovals.callAsync( - transaction, - transactionSignerAddress, - transaction.signature, - [signature], - { from: transactionSignerAddress }, - ); + const tx = mixins + .assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, [ + signature, + ]) + .callAsync({ from: transactionSignerAddress }); const transactionHash = transactionHashUtils.getTransactionHashHex(transaction); expect(tx).to.revertWith( @@ -494,13 +453,12 @@ blockchainTests.resets('Mixins tests', env => { '0xFFFFFFFF', hexSlice(approval2.signature, 6), ); - const tx = mixins.assertValidCoordinatorApprovals.callAsync( - transaction, - transactionSignerAddress, - transaction.signature, - [approval1.signature, approvalSignature2], - { from: transactionSignerAddress }, - ); + const tx = mixins + .assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, [ + approval1.signature, + approvalSignature2, + ]) + .callAsync({ from: transactionSignerAddress }); const transactionHash = transactionHashUtils.getTransactionHashHex(transaction); expect(tx).to.revertWith( @@ -517,13 +475,11 @@ blockchainTests.resets('Mixins tests', env => { '0xFFFFFFFF', hexSlice(approval2.signature, 6), ); - const tx = mixins.assertValidCoordinatorApprovals.callAsync( - transaction, - approvalSignerAddress1, - transaction.signature, - [approvalSignature2], - { from: approvalSignerAddress1 }, - ); + const tx = mixins + .assertValidCoordinatorApprovals(transaction, approvalSignerAddress1, transaction.signature, [ + approvalSignature2, + ]) + .callAsync({ from: approvalSignerAddress1 }); const transactionHash = transactionHashUtils.getTransactionHashHex(transaction); expect(tx).to.revertWith( @@ -536,13 +492,11 @@ blockchainTests.resets('Mixins tests', env => { const transaction = await transactionFactory.newSignedTransactionAsync({ data }); const approval1 = approvalFactory1.newSignedApproval(transaction, transactionSignerAddress); - const tx = mixins.assertValidCoordinatorApprovals.callAsync( - transaction, - transactionSignerAddress, - transaction.signature, - [approval1.signature], - { from: approvalSignerAddress2 }, - ); + const tx = mixins + .assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, [ + approval1.signature, + ]) + .callAsync({ from: approvalSignerAddress2 }); expect(tx).to.revertWith(new CoordinatorRevertErrors.InvalidOriginError(transactionSignerAddress)); }); } @@ -552,36 +506,24 @@ blockchainTests.resets('Mixins tests', env => { const orders = [defaultOrder]; const data = exchangeDataEncoder.encodeOrdersToExchangeData(ExchangeFunctionName.CancelOrder, orders); const transaction = await transactionFactory.newSignedTransactionAsync({ data }); - await mixins.assertValidCoordinatorApprovals.callAsync( - transaction, - transactionSignerAddress, - transaction.signature, - [], - { from: transactionSignerAddress }, - ); + await mixins + .assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, []) + .callAsync({ from: transactionSignerAddress }); }); it('should allow the tx signer to call `batchCancelOrders` without approval', async () => { const orders = [defaultOrder, defaultOrder]; const data = exchangeDataEncoder.encodeOrdersToExchangeData(ExchangeFunctionName.BatchCancelOrders, orders); const transaction = await transactionFactory.newSignedTransactionAsync({ data }); - await mixins.assertValidCoordinatorApprovals.callAsync( - transaction, - transactionSignerAddress, - transaction.signature, - [], - { from: transactionSignerAddress }, - ); + await mixins + .assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, []) + .callAsync({ from: transactionSignerAddress }); }); it('should allow the tx signer to call `cancelOrdersUpTo` without approval', async () => { const data = exchangeDataEncoder.encodeOrdersToExchangeData(ExchangeFunctionName.CancelOrdersUpTo); const transaction = await transactionFactory.newSignedTransactionAsync({ data }); - await mixins.assertValidCoordinatorApprovals.callAsync( - transaction, - transactionSignerAddress, - transaction.signature, - [], - { from: transactionSignerAddress }, - ); + await mixins + .assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, []) + .callAsync({ from: transactionSignerAddress }); }); }); }); diff --git a/contracts/erc1155/test/erc1155_token.ts b/contracts/erc1155/test/erc1155_token.ts index ef3b2def3e..88f2048a78 100644 --- a/contracts/erc1155/test/erc1155_token.ts +++ b/contracts/erc1155/test/erc1155_token.ts @@ -179,14 +179,9 @@ describe('ERC1155Token', () => { valueToTransfer, ); // execute transfer - const tx = erc1155Contract.safeTransferFrom.sendTransactionAsync( - spender, - receiver, - tokenToTransfer, - valueToTransfer, - receiverCallbackData, - { from: spender }, - ); + const tx = erc1155Contract + .safeTransferFrom(spender, receiver, tokenToTransfer, valueToTransfer, receiverCallbackData) + .sendTransactionAsync({ from: spender }); return expect(tx).to.revertWith(expectedError); }); it('should revert if callback reverts', async () => { @@ -196,19 +191,14 @@ describe('ERC1155Token', () => { // set receiver to reject balances const shouldRejectTransfer = true; await web3Wrapper.awaitTransactionSuccessAsync( - await erc1155Receiver.setRejectTransferFlag.sendTransactionAsync(shouldRejectTransfer), + await erc1155Receiver.setRejectTransferFlag(shouldRejectTransfer).sendTransactionAsync(), constants.AWAIT_TRANSACTION_MINED_MS, ); // execute transfer await expectTransactionFailedAsync( - erc1155Contract.safeTransferFrom.sendTransactionAsync( - spender, - receiver, - tokenToTransfer, - valueToTransfer, - receiverCallbackData, - { from: spender }, - ), + erc1155Contract + .safeTransferFrom(spender, receiver, tokenToTransfer, valueToTransfer, receiverCallbackData) + .sendTransactionAsync({ from: spender }), RevertReason.TransferRejected, ); }); @@ -355,14 +345,9 @@ describe('ERC1155Token', () => { valuesToTransfer[0], ); // execute transfer - const tx = erc1155Contract.safeBatchTransferFrom.sendTransactionAsync( - spender, - receiver, - tokensToTransfer, - valuesToTransfer, - receiverCallbackData, - { from: spender }, - ); + const tx = erc1155Contract + .safeBatchTransferFrom(spender, receiver, tokensToTransfer, valuesToTransfer, receiverCallbackData) + .sendTransactionAsync({ from: spender }); return expect(tx).to.revertWith(expectedError); }); it('should revert if callback reverts', async () => { @@ -372,19 +357,14 @@ describe('ERC1155Token', () => { // set receiver to reject balances const shouldRejectTransfer = true; await web3Wrapper.awaitTransactionSuccessAsync( - await erc1155Receiver.setRejectTransferFlag.sendTransactionAsync(shouldRejectTransfer), + await erc1155Receiver.setRejectTransferFlag(shouldRejectTransfer).sendTransactionAsync(), constants.AWAIT_TRANSACTION_MINED_MS, ); // execute transfer await expectTransactionFailedAsync( - erc1155Contract.safeBatchTransferFrom.sendTransactionAsync( - spender, - receiver, - tokensToTransfer, - valuesToTransfer, - receiverCallbackData, - { from: spender }, - ), + erc1155Contract + .safeBatchTransferFrom(spender, receiver, tokensToTransfer, valuesToTransfer, receiverCallbackData) + .sendTransactionAsync({ from: spender }), RevertReason.TransferRejected, ); }); @@ -432,14 +412,9 @@ describe('ERC1155Token', () => { await erc1155Wrapper.assertBalancesAsync(tokenHolders, [tokenToTransfer], expectedInitialBalances); // execute transfer await expectTransactionFailedAsync( - erc1155Contract.safeTransferFrom.sendTransactionAsync( - spender, - receiver, - tokenToTransfer, - valueToTransfer, - receiverCallbackData, - { from: delegatedSpender }, - ), + erc1155Contract + .safeTransferFrom(spender, receiver, tokenToTransfer, valueToTransfer, receiverCallbackData) + .sendTransactionAsync({ from: delegatedSpender }), RevertReason.InsufficientAllowance, ); }); @@ -485,14 +460,9 @@ describe('ERC1155Token', () => { await erc1155Wrapper.assertBalancesAsync(tokenHolders, tokensToTransfer, expectedInitialBalances); // execute transfer await expectTransactionFailedAsync( - erc1155Contract.safeBatchTransferFrom.sendTransactionAsync( - spender, - receiver, - tokensToTransfer, - valuesToTransfer, - receiverCallbackData, - { from: delegatedSpender }, - ), + erc1155Contract + .safeBatchTransferFrom(spender, receiver, tokensToTransfer, valuesToTransfer, receiverCallbackData) + .sendTransactionAsync({ from: delegatedSpender }), RevertReason.InsufficientAllowance, ); }); diff --git a/contracts/erc1155/test/utils/erc1155_wrapper.ts b/contracts/erc1155/test/utils/erc1155_wrapper.ts index 984935db17..f9b49131c2 100644 --- a/contracts/erc1155/test/utils/erc1155_wrapper.ts +++ b/contracts/erc1155/test/utils/erc1155_wrapper.ts @@ -25,7 +25,7 @@ export class Erc1155Wrapper { return this._erc1155Contract; } public async getBalancesAsync(owners: string[], tokens: BigNumber[]): Promise { - const balances = await this._erc1155Contract.balanceOfBatch.callAsync(owners, tokens); + const balances = await this._erc1155Contract.balanceOfBatch(owners, tokens).callAsync(); return balances; } public async safeTransferFromAsync( @@ -39,7 +39,7 @@ export class Erc1155Wrapper { const spender = delegatedSpender === undefined ? from : delegatedSpender; const callbackDataHex = callbackData === undefined ? '0x' : callbackData; const tx = await this._logDecoder.getTxWithDecodedLogsAsync( - await this._erc1155Contract.safeTransferFrom.sendTransactionAsync(from, to, token, value, callbackDataHex, { + await this._erc1155Contract.safeTransferFrom(from, to, token, value, callbackDataHex).sendTransactionAsync({ from: spender, }), ); @@ -56,14 +56,9 @@ export class Erc1155Wrapper { const spender = delegatedSpender === undefined ? from : delegatedSpender; const callbackDataHex = callbackData === undefined ? '0x' : callbackData; const tx = await this._logDecoder.getTxWithDecodedLogsAsync( - await this._erc1155Contract.safeBatchTransferFrom.sendTransactionAsync( - from, - to, - tokens, - values, - callbackDataHex, - { from: spender }, - ), + await this._erc1155Contract + .safeBatchTransferFrom(from, to, tokens, values, callbackDataHex) + .sendTransactionAsync({ from: spender }), ); return tx; } @@ -74,7 +69,7 @@ export class Erc1155Wrapper { const tokenUri = 'dummyFungibleToken'; const tokenIsNonFungible = false; const tx = await this._logDecoder.getTxWithDecodedLogsAsync( - await this._erc1155Contract.create.sendTransactionAsync(tokenUri, tokenIsNonFungible, { + await this._erc1155Contract.create(tokenUri, tokenIsNonFungible).sendTransactionAsync({ from: this._contractOwner, }), ); @@ -95,25 +90,22 @@ export class Erc1155Wrapper { tokenAmountsAsArray.push(tokenAmounts); }); } - await this._erc1155Contract.mintFungible.awaitTransactionSuccessAsync( - tokenId, - beneficiaries, - tokenAmountsAsArray, - { from: this._contractOwner }, - ); + await this._erc1155Contract + .mintFungible(tokenId, beneficiaries, tokenAmountsAsArray) + .awaitTransactionSuccessAsync({ from: this._contractOwner }); } public async mintNonFungibleTokensAsync(beneficiaries: string[]): Promise<[BigNumber, BigNumber[]]> { const tokenUri = 'dummyNonFungibleToken'; const tokenIsNonFungible = true; const tx = await this._logDecoder.getTxWithDecodedLogsAsync( - await this._erc1155Contract.create.sendTransactionAsync(tokenUri, tokenIsNonFungible, { + await this._erc1155Contract.create(tokenUri, tokenIsNonFungible).sendTransactionAsync({ from: this._contractOwner, }), ); // tslint:disable-next-line no-unnecessary-type-assertion const createFungibleTokenLog = tx.logs[0] as LogWithDecodedArgs; const token = createFungibleTokenLog.args.id; - await this._erc1155Contract.mintNonFungible.awaitTransactionSuccessAsync(token, beneficiaries, { + await this._erc1155Contract.mintNonFungible(token, beneficiaries).awaitTransactionSuccessAsync({ from: this._contractOwner, }); const encodedNftIds: BigNumber[] = []; @@ -132,14 +124,14 @@ export class Erc1155Wrapper { isApproved: boolean, ): Promise { const tx = await this._logDecoder.getTxWithDecodedLogsAsync( - await this._erc1155Contract.setApprovalForAll.sendTransactionAsync(beneficiary, isApproved, { + await this._erc1155Contract.setApprovalForAll(beneficiary, isApproved).sendTransactionAsync({ from: owner, }), ); return tx; } public async isApprovedForAllAsync(owner: string, beneficiary: string): Promise { - const isApprovedForAll = await this._erc1155Contract.isApprovedForAll.callAsync(owner, beneficiary); + const isApprovedForAll = await this._erc1155Contract.isApprovedForAll(owner, beneficiary).callAsync(); return isApprovedForAll; } public async assertBalancesAsync( @@ -161,18 +153,18 @@ export class Erc1155Wrapper { }); } public async isNonFungibleItemAsync(tokenId: BigNumber): Promise { - return this._erc1155Contract.isNonFungibleItem.callAsync(tokenId); + return this._erc1155Contract.isNonFungibleItem(tokenId).callAsync(); } public async isFungibleItemAsync(tokenId: BigNumber): Promise { return !(await this.isNonFungibleItemAsync(tokenId)); } public async getOwnerOfAsync(tokenId: BigNumber): Promise { - return this._erc1155Contract.ownerOf.callAsync(tokenId); + return this._erc1155Contract.ownerOf(tokenId).callAsync(); } /** * @dev Get the balance of an ERC1155 token for a given owner and token ID. */ public async getBalanceAsync(ownerAddress: string, tokenId: BigNumber): Promise { - return this._erc1155Contract.balanceOf.callAsync(ownerAddress, tokenId); + return this._erc1155Contract.balanceOf(ownerAddress, tokenId).callAsync(); } } diff --git a/contracts/erc20/test/lib_erc20_token.ts b/contracts/erc20/test/lib_erc20_token.ts index b843867a8c..3df3d2b363 100644 --- a/contracts/erc20/test/lib_erc20_token.ts +++ b/contracts/erc20/test/lib_erc20_token.ts @@ -37,13 +37,9 @@ blockchainTests('LibERC20Token', env => { it('calls the target with the correct arguments', async () => { const spender = randomAddress(); const allowance = getRandomInteger(0, 100e18); - const { logs } = await testContract.testApprove.awaitTransactionSuccessAsync( - false, - encodeRevert(REVERT_STRING), - ENCODED_TRUE, - spender, - allowance, - ); + const { logs } = await testContract + .testApprove(false, encodeRevert(REVERT_STRING), ENCODED_TRUE, spender, allowance) + .awaitTransactionSuccessAsync(); expect(logs).to.be.length(1); verifyEventsFromLogs(logs, [{ spender, allowance }], TestLibERC20TokenTargetEvents.ApproveCalled); }); @@ -51,37 +47,25 @@ blockchainTests('LibERC20Token', env => { it('succeeds if the target returns true', async () => { const spender = randomAddress(); const allowance = getRandomInteger(0, 100e18); - await testContract.testApprove.awaitTransactionSuccessAsync( - false, - encodeRevert(REVERT_STRING), - ENCODED_TRUE, - spender, - allowance, - ); + await testContract + .testApprove(false, encodeRevert(REVERT_STRING), ENCODED_TRUE, spender, allowance) + .awaitTransactionSuccessAsync(); }); it('succeeds if the target returns nothing', async () => { const spender = randomAddress(); const allowance = getRandomInteger(0, 100e18); - await testContract.testApprove.awaitTransactionSuccessAsync( - false, - encodeRevert(REVERT_STRING), - constants.NULL_BYTES, - spender, - allowance, - ); + await testContract + .testApprove(false, encodeRevert(REVERT_STRING), constants.NULL_BYTES, spender, allowance) + .awaitTransactionSuccessAsync(); }); it('fails if the target returns false', async () => { const spender = randomAddress(); const allowance = getRandomInteger(0, 100e18); - const tx = testContract.testApprove.awaitTransactionSuccessAsync( - false, - encodeRevert(REVERT_STRING), - ENCODED_FALSE, - spender, - allowance, - ); + const tx = testContract + .testApprove(false, encodeRevert(REVERT_STRING), ENCODED_FALSE, spender, allowance) + .awaitTransactionSuccessAsync(); const expectedError = new RawRevertError(ENCODED_FALSE); return expect(tx).to.revertWith(expectedError); }); @@ -89,13 +73,9 @@ blockchainTests('LibERC20Token', env => { it('fails if the target returns nonzero and not true', async () => { const spender = randomAddress(); const allowance = getRandomInteger(0, 100e18); - const tx = testContract.testApprove.awaitTransactionSuccessAsync( - false, - encodeRevert(REVERT_STRING), - ENCODED_TWO, - spender, - allowance, - ); + const tx = testContract + .testApprove(false, encodeRevert(REVERT_STRING), ENCODED_TWO, spender, allowance) + .awaitTransactionSuccessAsync(); const expectedError = new RawRevertError(ENCODED_TWO); return expect(tx).to.revertWith(expectedError); }); @@ -103,13 +83,9 @@ blockchainTests('LibERC20Token', env => { it('fails if the target returns less than 32 bytes', async () => { const spender = randomAddress(); const allowance = getRandomInteger(0, 100e18); - const tx = testContract.testApprove.awaitTransactionSuccessAsync( - false, - encodeRevert(REVERT_STRING), - ENCODED_SHORT_TRUE, - spender, - allowance, - ); + const tx = testContract + .testApprove(false, encodeRevert(REVERT_STRING), ENCODED_SHORT_TRUE, spender, allowance) + .awaitTransactionSuccessAsync(); const expectedError = new RawRevertError(ENCODED_SHORT_TRUE); return expect(tx).to.revertWith(expectedError); }); @@ -117,13 +93,9 @@ blockchainTests('LibERC20Token', env => { it('fails if the target returns greater than 32 bytes', async () => { const spender = randomAddress(); const allowance = getRandomInteger(0, 100e18); - const tx = testContract.testApprove.awaitTransactionSuccessAsync( - false, - encodeRevert(REVERT_STRING), - ENCODED_LONG_TRUE, - spender, - allowance, - ); + const tx = testContract + .testApprove(false, encodeRevert(REVERT_STRING), ENCODED_LONG_TRUE, spender, allowance) + .awaitTransactionSuccessAsync(); const expectedError = new RawRevertError(ENCODED_LONG_TRUE); return expect(tx).to.revertWith(expectedError); }); @@ -131,26 +103,18 @@ blockchainTests('LibERC20Token', env => { it('fails if the target reverts', async () => { const spender = randomAddress(); const allowance = getRandomInteger(0, 100e18); - const tx = testContract.testApprove.awaitTransactionSuccessAsync( - true, - encodeRevert(REVERT_STRING), - ENCODED_TRUE, - spender, - allowance, - ); + const tx = testContract + .testApprove(true, encodeRevert(REVERT_STRING), ENCODED_TRUE, spender, allowance) + .awaitTransactionSuccessAsync(); return expect(tx).to.revertWith(REVERT_STRING); }); it('fails if the target reverts with no data', async () => { const spender = randomAddress(); const allowance = getRandomInteger(0, 100e18); - const tx = testContract.testApprove.awaitTransactionSuccessAsync( - true, - constants.NULL_BYTES, - ENCODED_TRUE, - spender, - allowance, - ); + const tx = testContract + .testApprove(true, constants.NULL_BYTES, ENCODED_TRUE, spender, allowance) + .awaitTransactionSuccessAsync(); return expect(tx).to.be.rejectedWith('revert'); }); }); @@ -159,13 +123,9 @@ blockchainTests('LibERC20Token', env => { it('calls the target with the correct arguments', async () => { const to = randomAddress(); const amount = getRandomInteger(0, 100e18); - const { logs } = await testContract.testTransfer.awaitTransactionSuccessAsync( - false, - encodeRevert(REVERT_STRING), - ENCODED_TRUE, - to, - amount, - ); + const { logs } = await testContract + .testTransfer(false, encodeRevert(REVERT_STRING), ENCODED_TRUE, to, amount) + .awaitTransactionSuccessAsync(); expect(logs).to.be.length(1); verifyEventsFromLogs(logs, [{ to, amount }], TestLibERC20TokenTargetEvents.TransferCalled); }); @@ -173,37 +133,25 @@ blockchainTests('LibERC20Token', env => { it('succeeds if the target returns true', async () => { const to = randomAddress(); const amount = getRandomInteger(0, 100e18); - await testContract.testTransfer.awaitTransactionSuccessAsync( - false, - encodeRevert(REVERT_STRING), - ENCODED_TRUE, - to, - amount, - ); + await testContract + .testTransfer(false, encodeRevert(REVERT_STRING), ENCODED_TRUE, to, amount) + .awaitTransactionSuccessAsync(); }); it('succeeds if the target returns nothing', async () => { const to = randomAddress(); const amount = getRandomInteger(0, 100e18); - await testContract.testTransfer.awaitTransactionSuccessAsync( - false, - encodeRevert(REVERT_STRING), - constants.NULL_BYTES, - to, - amount, - ); + await testContract + .testTransfer(false, encodeRevert(REVERT_STRING), constants.NULL_BYTES, to, amount) + .awaitTransactionSuccessAsync(); }); it('fails if the target returns false', async () => { const to = randomAddress(); const amount = getRandomInteger(0, 100e18); - const tx = testContract.testTransfer.awaitTransactionSuccessAsync( - false, - encodeRevert(REVERT_STRING), - ENCODED_FALSE, - to, - amount, - ); + const tx = testContract + .testTransfer(false, encodeRevert(REVERT_STRING), ENCODED_FALSE, to, amount) + .awaitTransactionSuccessAsync(); const expectedError = new RawRevertError(ENCODED_FALSE); return expect(tx).to.revertWith(expectedError); }); @@ -211,13 +159,9 @@ blockchainTests('LibERC20Token', env => { it('fails if the target returns nonzero and not true', async () => { const to = randomAddress(); const amount = getRandomInteger(0, 100e18); - const tx = testContract.testTransfer.awaitTransactionSuccessAsync( - false, - encodeRevert(REVERT_STRING), - ENCODED_TWO, - to, - amount, - ); + const tx = testContract + .testTransfer(false, encodeRevert(REVERT_STRING), ENCODED_TWO, to, amount) + .awaitTransactionSuccessAsync(); const expectedError = new RawRevertError(ENCODED_TWO); return expect(tx).to.revertWith(expectedError); }); @@ -225,13 +169,9 @@ blockchainTests('LibERC20Token', env => { it('fails if the target returns less than 32 bytes', async () => { const to = randomAddress(); const amount = getRandomInteger(0, 100e18); - const tx = testContract.testTransfer.awaitTransactionSuccessAsync( - false, - encodeRevert(REVERT_STRING), - ENCODED_SHORT_TRUE, - to, - amount, - ); + const tx = testContract + .testTransfer(false, encodeRevert(REVERT_STRING), ENCODED_SHORT_TRUE, to, amount) + .awaitTransactionSuccessAsync(); const expectedError = new RawRevertError(ENCODED_SHORT_TRUE); return expect(tx).to.revertWith(expectedError); }); @@ -239,13 +179,9 @@ blockchainTests('LibERC20Token', env => { it('fails if the target returns greater than 32 bytes', async () => { const to = randomAddress(); const amount = getRandomInteger(0, 100e18); - const tx = testContract.testTransfer.awaitTransactionSuccessAsync( - false, - encodeRevert(REVERT_STRING), - ENCODED_LONG_TRUE, - to, - amount, - ); + const tx = testContract + .testTransfer(false, encodeRevert(REVERT_STRING), ENCODED_LONG_TRUE, to, amount) + .awaitTransactionSuccessAsync(); const expectedError = new RawRevertError(ENCODED_LONG_TRUE); return expect(tx).to.revertWith(expectedError); }); @@ -253,26 +189,18 @@ blockchainTests('LibERC20Token', env => { it('fails if the target reverts', async () => { const to = randomAddress(); const amount = getRandomInteger(0, 100e18); - const tx = testContract.testTransfer.awaitTransactionSuccessAsync( - true, - encodeRevert(REVERT_STRING), - ENCODED_TRUE, - to, - amount, - ); + const tx = testContract + .testTransfer(true, encodeRevert(REVERT_STRING), ENCODED_TRUE, to, amount) + .awaitTransactionSuccessAsync(); return expect(tx).to.revertWith(REVERT_STRING); }); it('fails if the target reverts with no data', async () => { const to = randomAddress(); const amount = getRandomInteger(0, 100e18); - const tx = testContract.testTransfer.awaitTransactionSuccessAsync( - true, - constants.NULL_BYTES, - ENCODED_TRUE, - to, - amount, - ); + const tx = testContract + .testTransfer(true, constants.NULL_BYTES, ENCODED_TRUE, to, amount) + .awaitTransactionSuccessAsync(); return expect(tx).to.be.rejectedWith('revert'); }); }); @@ -282,14 +210,9 @@ blockchainTests('LibERC20Token', env => { const owner = randomAddress(); const to = randomAddress(); const amount = getRandomInteger(0, 100e18); - const { logs } = await testContract.testTransferFrom.awaitTransactionSuccessAsync( - false, - encodeRevert(REVERT_STRING), - ENCODED_TRUE, - owner, - to, - amount, - ); + const { logs } = await testContract + .testTransferFrom(false, encodeRevert(REVERT_STRING), ENCODED_TRUE, owner, to, amount) + .awaitTransactionSuccessAsync(); expect(logs).to.be.length(1); verifyEventsFromLogs(logs, [{ from: owner, to, amount }], TestLibERC20TokenTargetEvents.TransferFromCalled); }); @@ -298,42 +221,27 @@ blockchainTests('LibERC20Token', env => { const owner = randomAddress(); const to = randomAddress(); const amount = getRandomInteger(0, 100e18); - await testContract.testTransferFrom.awaitTransactionSuccessAsync( - false, - encodeRevert(REVERT_STRING), - ENCODED_TRUE, - owner, - to, - amount, - ); + await testContract + .testTransferFrom(false, encodeRevert(REVERT_STRING), ENCODED_TRUE, owner, to, amount) + .awaitTransactionSuccessAsync(); }); it('succeeds if the target returns nothing', async () => { const owner = randomAddress(); const to = randomAddress(); const amount = getRandomInteger(0, 100e18); - await testContract.testTransferFrom.awaitTransactionSuccessAsync( - false, - encodeRevert(REVERT_STRING), - constants.NULL_BYTES, - owner, - to, - amount, - ); + await testContract + .testTransferFrom(false, encodeRevert(REVERT_STRING), constants.NULL_BYTES, owner, to, amount) + .awaitTransactionSuccessAsync(); }); it('fails if the target returns false', async () => { const owner = randomAddress(); const to = randomAddress(); const amount = getRandomInteger(0, 100e18); - const tx = testContract.testTransferFrom.awaitTransactionSuccessAsync( - false, - encodeRevert(REVERT_STRING), - ENCODED_FALSE, - owner, - to, - amount, - ); + const tx = testContract + .testTransferFrom(false, encodeRevert(REVERT_STRING), ENCODED_FALSE, owner, to, amount) + .awaitTransactionSuccessAsync(); const expectedError = new RawRevertError(ENCODED_FALSE); return expect(tx).to.revertWith(expectedError); }); @@ -342,14 +250,9 @@ blockchainTests('LibERC20Token', env => { const owner = randomAddress(); const to = randomAddress(); const amount = getRandomInteger(0, 100e18); - const tx = testContract.testTransferFrom.awaitTransactionSuccessAsync( - false, - encodeRevert(REVERT_STRING), - ENCODED_TWO, - owner, - to, - amount, - ); + const tx = testContract + .testTransferFrom(false, encodeRevert(REVERT_STRING), ENCODED_TWO, owner, to, amount) + .awaitTransactionSuccessAsync(); const expectedError = new RawRevertError(ENCODED_TWO); return expect(tx).to.revertWith(expectedError); }); @@ -358,14 +261,9 @@ blockchainTests('LibERC20Token', env => { const owner = randomAddress(); const to = randomAddress(); const amount = getRandomInteger(0, 100e18); - const tx = testContract.testTransferFrom.awaitTransactionSuccessAsync( - false, - encodeRevert(REVERT_STRING), - ENCODED_SHORT_TRUE, - owner, - to, - amount, - ); + const tx = testContract + .testTransferFrom(false, encodeRevert(REVERT_STRING), ENCODED_SHORT_TRUE, owner, to, amount) + .awaitTransactionSuccessAsync(); const expectedError = new RawRevertError(ENCODED_SHORT_TRUE); return expect(tx).to.revertWith(expectedError); }); @@ -374,14 +272,9 @@ blockchainTests('LibERC20Token', env => { const owner = randomAddress(); const to = randomAddress(); const amount = getRandomInteger(0, 100e18); - const tx = testContract.testTransferFrom.awaitTransactionSuccessAsync( - false, - encodeRevert(REVERT_STRING), - ENCODED_LONG_TRUE, - owner, - to, - amount, - ); + const tx = testContract + .testTransferFrom(false, encodeRevert(REVERT_STRING), ENCODED_LONG_TRUE, owner, to, amount) + .awaitTransactionSuccessAsync(); const expectedError = new RawRevertError(ENCODED_LONG_TRUE); return expect(tx).to.revertWith(expectedError); }); @@ -390,14 +283,9 @@ blockchainTests('LibERC20Token', env => { const owner = randomAddress(); const to = randomAddress(); const amount = getRandomInteger(0, 100e18); - const tx = testContract.testTransferFrom.awaitTransactionSuccessAsync( - true, - encodeRevert(REVERT_STRING), - ENCODED_TRUE, - owner, - to, - amount, - ); + const tx = testContract + .testTransferFrom(true, encodeRevert(REVERT_STRING), ENCODED_TRUE, owner, to, amount) + .awaitTransactionSuccessAsync(); return expect(tx).to.revertWith(REVERT_STRING); }); @@ -405,14 +293,9 @@ blockchainTests('LibERC20Token', env => { const owner = randomAddress(); const to = randomAddress(); const amount = getRandomInteger(0, 100e18); - const tx = testContract.testTransferFrom.awaitTransactionSuccessAsync( - true, - constants.NULL_BYTES, - ENCODED_TRUE, - owner, - to, - amount, - ); + const tx = testContract + .testTransferFrom(true, constants.NULL_BYTES, ENCODED_TRUE, owner, to, amount) + .awaitTransactionSuccessAsync(); return expect(tx).to.be.rejectedWith('revert'); }); }); diff --git a/contracts/erc20/test/unlimited_allowance_token.ts b/contracts/erc20/test/unlimited_allowance_token.ts index 9d9de2ab01..e0dbaa2433 100644 --- a/contracts/erc20/test/unlimited_allowance_token.ts +++ b/contracts/erc20/test/unlimited_allowance_token.ts @@ -44,7 +44,7 @@ describe('UnlimitedAllowanceToken', () => { constants.DUMMY_TOKEN_TOTAL_SUPPLY, ); await web3Wrapper.awaitTransactionSuccessAsync( - await token.mint.sendTransactionAsync(MAX_MINT_VALUE, { from: owner }), + await token.mint(MAX_MINT_VALUE).sendTransactionAsync({ from: owner }), constants.AWAIT_TRANSACTION_MINED_MS, ); }); @@ -56,24 +56,24 @@ describe('UnlimitedAllowanceToken', () => { }); describe('transfer', () => { it('should revert if owner has insufficient balance', async () => { - const ownerBalance = await token.balanceOf.callAsync(owner); + const ownerBalance = await token.balanceOf(owner).callAsync(); const amountToTransfer = ownerBalance.plus(1); return expectContractCallFailedAsync( - token.transfer.callAsync(spender, amountToTransfer, { from: owner }), + token.transfer(spender, amountToTransfer).callAsync({ from: owner }), RevertReason.Erc20InsufficientBalance, ); }); it('should transfer balance from sender to receiver', async () => { const receiver = spender; - const initOwnerBalance = await token.balanceOf.callAsync(owner); + const initOwnerBalance = await token.balanceOf(owner).callAsync(); const amountToTransfer = new BigNumber(1); await web3Wrapper.awaitTransactionSuccessAsync( - await token.transfer.sendTransactionAsync(receiver, amountToTransfer, { from: owner }), + await token.transfer(receiver, amountToTransfer).sendTransactionAsync({ from: owner }), constants.AWAIT_TRANSACTION_MINED_MS, ); - const finalOwnerBalance = await token.balanceOf.callAsync(owner); - const finalReceiverBalance = await token.balanceOf.callAsync(receiver); + const finalOwnerBalance = await token.balanceOf(owner).callAsync(); + const finalReceiverBalance = await token.balanceOf(receiver).callAsync(); const expectedFinalOwnerBalance = initOwnerBalance.minus(amountToTransfer); const expectedFinalReceiverBalance = amountToTransfer; @@ -82,7 +82,7 @@ describe('UnlimitedAllowanceToken', () => { }); it('should return true on a 0 value transfer', async () => { - const didReturnTrue = await token.transfer.callAsync(spender, new BigNumber(0), { + const didReturnTrue = await token.transfer(spender, new BigNumber(0)).callAsync({ from: owner, }); expect(didReturnTrue).to.be.true(); @@ -91,14 +91,14 @@ describe('UnlimitedAllowanceToken', () => { describe('transferFrom', () => { it('should revert if owner has insufficient balance', async () => { - const ownerBalance = await token.balanceOf.callAsync(owner); + const ownerBalance = await token.balanceOf(owner).callAsync(); const amountToTransfer = ownerBalance.plus(1); await web3Wrapper.awaitTransactionSuccessAsync( - await token.approve.sendTransactionAsync(spender, amountToTransfer, { from: owner }), + await token.approve(spender, amountToTransfer).sendTransactionAsync({ from: owner }), constants.AWAIT_TRANSACTION_MINED_MS, ); return expectContractCallFailedAsync( - token.transferFrom.callAsync(owner, spender, amountToTransfer, { + token.transferFrom(owner, spender, amountToTransfer).callAsync({ from: spender, }), RevertReason.Erc20InsufficientBalance, @@ -106,15 +106,15 @@ describe('UnlimitedAllowanceToken', () => { }); it('should revert if spender has insufficient allowance', async () => { - const ownerBalance = await token.balanceOf.callAsync(owner); + const ownerBalance = await token.balanceOf(owner).callAsync(); const amountToTransfer = ownerBalance; - const spenderAllowance = await token.allowance.callAsync(owner, spender); + const spenderAllowance = await token.allowance(owner, spender).callAsync(); const isSpenderAllowanceInsufficient = spenderAllowance.comparedTo(amountToTransfer) < 0; expect(isSpenderAllowanceInsufficient).to.be.true(); return expectContractCallFailedAsync( - token.transferFrom.callAsync(owner, spender, amountToTransfer, { + token.transferFrom(owner, spender, amountToTransfer).callAsync({ from: spender, }), RevertReason.Erc20InsufficientAllowance, @@ -123,72 +123,72 @@ describe('UnlimitedAllowanceToken', () => { it('should return true on a 0 value transfer', async () => { const amountToTransfer = new BigNumber(0); - const didReturnTrue = await token.transferFrom.callAsync(owner, spender, amountToTransfer, { + const didReturnTrue = await token.transferFrom(owner, spender, amountToTransfer).callAsync({ from: spender, }); expect(didReturnTrue).to.be.true(); }); it('should not modify spender allowance if spender allowance is 2^256 - 1', async () => { - const initOwnerBalance = await token.balanceOf.callAsync(owner); + const initOwnerBalance = await token.balanceOf(owner).callAsync(); const amountToTransfer = initOwnerBalance; const initSpenderAllowance = constants.UNLIMITED_ALLOWANCE_IN_BASE_UNITS; await web3Wrapper.awaitTransactionSuccessAsync( - await token.approve.sendTransactionAsync(spender, initSpenderAllowance, { from: owner }), + await token.approve(spender, initSpenderAllowance).sendTransactionAsync({ from: owner }), constants.AWAIT_TRANSACTION_MINED_MS, ); await web3Wrapper.awaitTransactionSuccessAsync( - await token.transferFrom.sendTransactionAsync(owner, spender, amountToTransfer, { + await token.transferFrom(owner, spender, amountToTransfer).sendTransactionAsync({ from: spender, gas: constants.MAX_TOKEN_TRANSFERFROM_GAS, }), constants.AWAIT_TRANSACTION_MINED_MS, ); - const newSpenderAllowance = await token.allowance.callAsync(owner, spender); + const newSpenderAllowance = await token.allowance(owner, spender).callAsync(); expect(initSpenderAllowance).to.be.bignumber.equal(newSpenderAllowance); }); it('should transfer the correct balances if spender has sufficient allowance', async () => { - const initOwnerBalance = await token.balanceOf.callAsync(owner); + const initOwnerBalance = await token.balanceOf(owner).callAsync(); const amountToTransfer = initOwnerBalance; const initSpenderAllowance = initOwnerBalance; await web3Wrapper.awaitTransactionSuccessAsync( - await token.approve.sendTransactionAsync(spender, initSpenderAllowance, { from: owner }), + await token.approve(spender, initSpenderAllowance).sendTransactionAsync({ from: owner }), constants.AWAIT_TRANSACTION_MINED_MS, ); await web3Wrapper.awaitTransactionSuccessAsync( - await token.transferFrom.sendTransactionAsync(owner, spender, amountToTransfer, { + await token.transferFrom(owner, spender, amountToTransfer).sendTransactionAsync({ from: spender, gas: constants.MAX_TOKEN_TRANSFERFROM_GAS, }), constants.AWAIT_TRANSACTION_MINED_MS, ); - const newOwnerBalance = await token.balanceOf.callAsync(owner); - const newSpenderBalance = await token.balanceOf.callAsync(spender); + const newOwnerBalance = await token.balanceOf(owner).callAsync(); + const newSpenderBalance = await token.balanceOf(spender).callAsync(); expect(newOwnerBalance).to.be.bignumber.equal(0); expect(newSpenderBalance).to.be.bignumber.equal(initOwnerBalance); }); it('should modify allowance if spender has sufficient allowance less than 2^256 - 1', async () => { - const initOwnerBalance = await token.balanceOf.callAsync(owner); + const initOwnerBalance = await token.balanceOf(owner).callAsync(); const amountToTransfer = initOwnerBalance; const initSpenderAllowance = initOwnerBalance; await web3Wrapper.awaitTransactionSuccessAsync( - await token.approve.sendTransactionAsync(spender, initSpenderAllowance, { from: owner }), + await token.approve(spender, initSpenderAllowance).sendTransactionAsync({ from: owner }), constants.AWAIT_TRANSACTION_MINED_MS, ); await web3Wrapper.awaitTransactionSuccessAsync( - await token.transferFrom.sendTransactionAsync(owner, spender, amountToTransfer, { + await token.transferFrom(owner, spender, amountToTransfer).sendTransactionAsync({ from: spender, gas: constants.MAX_TOKEN_TRANSFERFROM_GAS, }), constants.AWAIT_TRANSACTION_MINED_MS, ); - const newSpenderAllowance = await token.allowance.callAsync(owner, spender); + const newSpenderAllowance = await token.allowance(owner, spender).callAsync(); expect(newSpenderAllowance).to.be.bignumber.equal(0); }); }); diff --git a/contracts/erc20/test/weth9.ts b/contracts/erc20/test/weth9.ts index 602abd29f9..f0862bbf66 100644 --- a/contracts/erc20/test/weth9.ts +++ b/contracts/erc20/test/weth9.ts @@ -54,16 +54,16 @@ describe('EtherToken', () => { const initEthBalance = await web3Wrapper.getBalanceInWeiAsync(account); const ethToDeposit = initEthBalance.plus(1); - return expectInsufficientFundsAsync(etherToken.deposit.sendTransactionAsync({ value: ethToDeposit })); + return expectInsufficientFundsAsync(etherToken.deposit().sendTransactionAsync({ value: ethToDeposit })); }); it('should convert deposited Ether to wrapped Ether tokens', async () => { const initEthBalance = await web3Wrapper.getBalanceInWeiAsync(account); - const initEthTokenBalance = await etherToken.balanceOf.callAsync(account); + const initEthTokenBalance = await etherToken.balanceOf(account).callAsync(); const ethToDeposit = new BigNumber(Web3Wrapper.toWei(new BigNumber(1))); - const txHash = await etherToken.deposit.sendTransactionAsync({ value: ethToDeposit }); + const txHash = await etherToken.deposit().sendTransactionAsync({ value: ethToDeposit }); const receipt = await web3Wrapper.awaitTransactionSuccessAsync( txHash, constants.AWAIT_TRANSACTION_MINED_MS, @@ -71,7 +71,7 @@ describe('EtherToken', () => { const ethSpentOnGas = gasPrice.times(receipt.gasUsed); const finalEthBalance = await web3Wrapper.getBalanceInWeiAsync(account); - const finalEthTokenBalance = await etherToken.balanceOf.callAsync(account); + const finalEthTokenBalance = await etherToken.balanceOf(account).callAsync(); expect(finalEthBalance).to.be.bignumber.equal(initEthBalance.minus(ethToDeposit.plus(ethSpentOnGas))); expect(finalEthTokenBalance).to.be.bignumber.equal(initEthTokenBalance.plus(ethToDeposit)); @@ -80,25 +80,25 @@ describe('EtherToken', () => { describe('withdraw', () => { it('should revert if caller attempts to withdraw greater than caller balance', async () => { - const initEthTokenBalance = await etherToken.balanceOf.callAsync(account); + const initEthTokenBalance = await etherToken.balanceOf(account).callAsync(); const ethTokensToWithdraw = initEthTokenBalance.plus(1); return expectTransactionFailedWithoutReasonAsync( - etherToken.withdraw.sendTransactionAsync(ethTokensToWithdraw), + etherToken.withdraw(ethTokensToWithdraw).sendTransactionAsync(), ); }); it('should convert ether tokens to ether with sufficient balance', async () => { const ethToDeposit = new BigNumber(Web3Wrapper.toWei(new BigNumber(1))); await web3Wrapper.awaitTransactionSuccessAsync( - await etherToken.deposit.sendTransactionAsync({ value: ethToDeposit }), + await etherToken.deposit().sendTransactionAsync({ value: ethToDeposit }), constants.AWAIT_TRANSACTION_MINED_MS, ); - const initEthTokenBalance = await etherToken.balanceOf.callAsync(account); + const initEthTokenBalance = await etherToken.balanceOf(account).callAsync(); const initEthBalance = await web3Wrapper.getBalanceInWeiAsync(account); const ethTokensToWithdraw = initEthTokenBalance; expect(ethTokensToWithdraw).to.not.be.bignumber.equal(0); - const txHash = await etherToken.withdraw.sendTransactionAsync(ethTokensToWithdraw, { + const txHash = await etherToken.withdraw(ethTokensToWithdraw).sendTransactionAsync({ gas: constants.MAX_ETHERTOKEN_WITHDRAW_GAS, }); const receipt = await web3Wrapper.awaitTransactionSuccessAsync( @@ -108,7 +108,7 @@ describe('EtherToken', () => { const ethSpentOnGas = gasPrice.times(receipt.gasUsed); const finalEthBalance = await web3Wrapper.getBalanceInWeiAsync(account); - const finalEthTokenBalance = await etherToken.balanceOf.callAsync(account); + const finalEthTokenBalance = await etherToken.balanceOf(account).callAsync(); expect(finalEthBalance).to.be.bignumber.equal( initEthBalance.plus(ethTokensToWithdraw.minus(ethSpentOnGas)), @@ -120,7 +120,7 @@ describe('EtherToken', () => { describe('fallback', () => { it('should convert sent ether to ether tokens', async () => { const initEthBalance = await web3Wrapper.getBalanceInWeiAsync(account); - const initEthTokenBalance = await etherToken.balanceOf.callAsync(account); + const initEthTokenBalance = await etherToken.balanceOf(account).callAsync(); const ethToDeposit = Web3Wrapper.toBaseUnitAmount(new BigNumber(1), 18); @@ -138,7 +138,7 @@ describe('EtherToken', () => { const ethSpentOnGas = gasPrice.times(receipt.gasUsed); const finalEthBalance = await web3Wrapper.getBalanceInWeiAsync(account); - const finalEthTokenBalance = await etherToken.balanceOf.callAsync(account); + const finalEthTokenBalance = await etherToken.balanceOf(account).callAsync(); expect(finalEthBalance).to.be.bignumber.equal(initEthBalance.minus(ethToDeposit.plus(ethSpentOnGas))); expect(finalEthTokenBalance).to.be.bignumber.equal(initEthTokenBalance.plus(ethToDeposit)); diff --git a/contracts/erc20/test/zrx_token.ts b/contracts/erc20/test/zrx_token.ts index a148fc0d85..b0ee2d7d47 100644 --- a/contracts/erc20/test/zrx_token.ts +++ b/contracts/erc20/test/zrx_token.ts @@ -42,25 +42,25 @@ describe('ZRXToken', () => { }); describe('constants', () => { it('should have 18 decimals', async () => { - const decimals = new BigNumber(await zrxToken.decimals.callAsync()); + const decimals = new BigNumber(await zrxToken.decimals().callAsync()); const expectedDecimals = 18; expect(decimals).to.be.bignumber.equal(expectedDecimals); }); it('should have a total supply of 1 billion tokens', async () => { - const totalSupply = new BigNumber(await zrxToken.totalSupply.callAsync()); + const totalSupply = new BigNumber(await zrxToken.totalSupply().callAsync()); const expectedTotalSupply = 1000000000; expect(Web3Wrapper.toUnitAmount(totalSupply, 18)).to.be.bignumber.equal(expectedTotalSupply); }); it('should be named 0x Protocol Token', async () => { - const name = await zrxToken.name.callAsync(); + const name = await zrxToken.name().callAsync(); const expectedName = '0x Protocol Token'; expect(name).to.be.equal(expectedName); }); it('should have the symbol ZRX', async () => { - const symbol = await zrxToken.symbol.callAsync(); + const symbol = await zrxToken.symbol().callAsync(); const expectedSymbol = 'ZRX'; expect(symbol).to.be.equal(expectedSymbol); }); @@ -68,8 +68,8 @@ describe('ZRXToken', () => { describe('constructor', () => { it('should initialize owner balance to totalSupply', async () => { - const ownerBalance = await zrxToken.balanceOf.callAsync(owner); - const totalSupply = new BigNumber(await zrxToken.totalSupply.callAsync()); + const ownerBalance = await zrxToken.balanceOf(owner).callAsync(); + const totalSupply = new BigNumber(await zrxToken.totalSupply().callAsync()); expect(totalSupply).to.be.bignumber.equal(ownerBalance); }); }); @@ -77,14 +77,14 @@ describe('ZRXToken', () => { describe('transfer', () => { it('should transfer balance from sender to receiver', async () => { const receiver = spender; - const initOwnerBalance = await zrxToken.balanceOf.callAsync(owner); + const initOwnerBalance = await zrxToken.balanceOf(owner).callAsync(); const amountToTransfer = new BigNumber(1); await web3Wrapper.awaitTransactionSuccessAsync( - await zrxToken.transfer.sendTransactionAsync(receiver, amountToTransfer, { from: owner }), + await zrxToken.transfer(receiver, amountToTransfer).sendTransactionAsync({ from: owner }), constants.AWAIT_TRANSACTION_MINED_MS, ); - const finalOwnerBalance = await zrxToken.balanceOf.callAsync(owner); - const finalReceiverBalance = await zrxToken.balanceOf.callAsync(receiver); + const finalOwnerBalance = await zrxToken.balanceOf(owner).callAsync(); + const finalReceiverBalance = await zrxToken.balanceOf(receiver).callAsync(); const expectedFinalOwnerBalance = initOwnerBalance.minus(amountToTransfer); const expectedFinalReceiverBalance = amountToTransfer; @@ -93,7 +93,7 @@ describe('ZRXToken', () => { }); it('should return true on a 0 value transfer', async () => { - const didReturnTrue = await zrxToken.transfer.callAsync(spender, new BigNumber(0), { + const didReturnTrue = await zrxToken.transfer(spender, new BigNumber(0)).callAsync({ from: owner, }); expect(didReturnTrue).to.be.true(); @@ -102,30 +102,30 @@ describe('ZRXToken', () => { describe('transferFrom', () => { it('should return false if owner has insufficient balance', async () => { - const ownerBalance = await zrxToken.balanceOf.callAsync(owner); + const ownerBalance = await zrxToken.balanceOf(owner).callAsync(); const amountToTransfer = ownerBalance.plus(1); await web3Wrapper.awaitTransactionSuccessAsync( - await zrxToken.approve.sendTransactionAsync(spender, amountToTransfer, { + await zrxToken.approve(spender, amountToTransfer).sendTransactionAsync({ from: owner, gas: constants.MAX_TOKEN_APPROVE_GAS, }), constants.AWAIT_TRANSACTION_MINED_MS, ); - const didReturnTrue = await zrxToken.transferFrom.callAsync(owner, spender, amountToTransfer, { + const didReturnTrue = await zrxToken.transferFrom(owner, spender, amountToTransfer).callAsync({ from: spender, }); expect(didReturnTrue).to.be.false(); }); it('should return false if spender has insufficient allowance', async () => { - const ownerBalance = await zrxToken.balanceOf.callAsync(owner); + const ownerBalance = await zrxToken.balanceOf(owner).callAsync(); const amountToTransfer = ownerBalance; - const spenderAllowance = await zrxToken.allowance.callAsync(owner, spender); + const spenderAllowance = await zrxToken.allowance(owner, spender).callAsync(); const isSpenderAllowanceInsufficient = spenderAllowance.comparedTo(amountToTransfer) < 0; expect(isSpenderAllowanceInsufficient).to.be.true(); - const didReturnTrue = await zrxToken.transferFrom.callAsync(owner, spender, amountToTransfer, { + const didReturnTrue = await zrxToken.transferFrom(owner, spender, amountToTransfer).callAsync({ from: spender, }); expect(didReturnTrue).to.be.false(); @@ -133,75 +133,75 @@ describe('ZRXToken', () => { it('should return true on a 0 value transfer', async () => { const amountToTransfer = new BigNumber(0); - const didReturnTrue = await zrxToken.transferFrom.callAsync(owner, spender, amountToTransfer, { + const didReturnTrue = await zrxToken.transferFrom(owner, spender, amountToTransfer).callAsync({ from: spender, }); expect(didReturnTrue).to.be.true(); }); it('should not modify spender allowance if spender allowance is 2^256 - 1', async () => { - const initOwnerBalance = await zrxToken.balanceOf.callAsync(owner); + const initOwnerBalance = await zrxToken.balanceOf(owner).callAsync(); const amountToTransfer = initOwnerBalance; const initSpenderAllowance = MAX_UINT; await web3Wrapper.awaitTransactionSuccessAsync( - await zrxToken.approve.sendTransactionAsync(spender, initSpenderAllowance, { + await zrxToken.approve(spender, initSpenderAllowance).sendTransactionAsync({ from: owner, gas: constants.MAX_TOKEN_APPROVE_GAS, }), constants.AWAIT_TRANSACTION_MINED_MS, ); await web3Wrapper.awaitTransactionSuccessAsync( - await zrxToken.transferFrom.sendTransactionAsync(owner, spender, amountToTransfer, { + await zrxToken.transferFrom(owner, spender, amountToTransfer).sendTransactionAsync({ from: spender, gas: constants.MAX_TOKEN_TRANSFERFROM_GAS, }), constants.AWAIT_TRANSACTION_MINED_MS, ); - const newSpenderAllowance = await zrxToken.allowance.callAsync(owner, spender); + const newSpenderAllowance = await zrxToken.allowance(owner, spender).callAsync(); expect(initSpenderAllowance).to.be.bignumber.equal(newSpenderAllowance); }); it('should transfer the correct balances if spender has sufficient allowance', async () => { - const initOwnerBalance = await zrxToken.balanceOf.callAsync(owner); - const initSpenderBalance = await zrxToken.balanceOf.callAsync(spender); + const initOwnerBalance = await zrxToken.balanceOf(owner).callAsync(); + const initSpenderBalance = await zrxToken.balanceOf(spender).callAsync(); const amountToTransfer = initOwnerBalance; const initSpenderAllowance = initOwnerBalance; await web3Wrapper.awaitTransactionSuccessAsync( - await zrxToken.approve.sendTransactionAsync(spender, initSpenderAllowance), + await zrxToken.approve(spender, initSpenderAllowance).sendTransactionAsync(), constants.AWAIT_TRANSACTION_MINED_MS, ); await web3Wrapper.awaitTransactionSuccessAsync( - await zrxToken.transferFrom.sendTransactionAsync(owner, spender, amountToTransfer, { + await zrxToken.transferFrom(owner, spender, amountToTransfer).sendTransactionAsync({ from: spender, gas: constants.MAX_TOKEN_TRANSFERFROM_GAS, }), constants.AWAIT_TRANSACTION_MINED_MS, ); - const newOwnerBalance = await zrxToken.balanceOf.callAsync(owner); - const newSpenderBalance = await zrxToken.balanceOf.callAsync(spender); + const newOwnerBalance = await zrxToken.balanceOf(owner).callAsync(); + const newSpenderBalance = await zrxToken.balanceOf(spender).callAsync(); expect(newOwnerBalance).to.be.bignumber.equal(0); expect(newSpenderBalance).to.be.bignumber.equal(initSpenderBalance.plus(initOwnerBalance)); }); it('should modify allowance if spender has sufficient allowance less than 2^256 - 1', async () => { - const initOwnerBalance = await zrxToken.balanceOf.callAsync(owner); + const initOwnerBalance = await zrxToken.balanceOf(owner).callAsync(); const amountToTransfer = initOwnerBalance; await web3Wrapper.awaitTransactionSuccessAsync( - await zrxToken.approve.sendTransactionAsync(spender, amountToTransfer), + await zrxToken.approve(spender, amountToTransfer).sendTransactionAsync(), constants.AWAIT_TRANSACTION_MINED_MS, ); await web3Wrapper.awaitTransactionSuccessAsync( - await zrxToken.transferFrom.sendTransactionAsync(owner, spender, amountToTransfer, { + await zrxToken.transferFrom(owner, spender, amountToTransfer).sendTransactionAsync({ from: spender, gas: constants.MAX_TOKEN_TRANSFERFROM_GAS, }), constants.AWAIT_TRANSACTION_MINED_MS, ); - const newSpenderAllowance = await zrxToken.allowance.callAsync(owner, spender); + const newSpenderAllowance = await zrxToken.allowance(owner, spender).callAsync(); expect(newSpenderAllowance).to.be.bignumber.equal(0); }); }); diff --git a/contracts/erc721/test/erc721_token.ts b/contracts/erc721/test/erc721_token.ts index b3c0ba4141..560d9a0b90 100644 --- a/contracts/erc721/test/erc721_token.ts +++ b/contracts/erc721/test/erc721_token.ts @@ -60,7 +60,7 @@ describe('ERC721Token', () => { ); logDecoder = new LogDecoder(web3Wrapper, artifacts); await web3Wrapper.awaitTransactionSuccessAsync( - await token.mint.sendTransactionAsync(owner, tokenId, { from: owner }), + await token.mint(owner, tokenId).sendTransactionAsync({ from: owner }), constants.AWAIT_TRANSACTION_MINED_MS, ); }); @@ -77,7 +77,7 @@ describe('ERC721Token', () => { const to = erc721Receiver.address; const unownedTokenId = new BigNumber(2); await expectTransactionFailedAsync( - token.transferFrom.sendTransactionAsync(from, to, unownedTokenId), + token.transferFrom(from, to, unownedTokenId).sendTransactionAsync(), RevertReason.Erc721ZeroOwner, ); }); @@ -85,7 +85,7 @@ describe('ERC721Token', () => { const from = owner; const to = constants.NULL_ADDRESS; await expectTransactionFailedAsync( - token.transferFrom.sendTransactionAsync(from, to, tokenId), + token.transferFrom(from, to, tokenId).sendTransactionAsync(), RevertReason.Erc721ZeroToAddress, ); }); @@ -93,7 +93,7 @@ describe('ERC721Token', () => { const from = spender; const to = erc721Receiver.address; await expectTransactionFailedAsync( - token.transferFrom.sendTransactionAsync(from, to, tokenId), + token.transferFrom(from, to, tokenId).sendTransactionAsync(), RevertReason.Erc721OwnerMismatch, ); }); @@ -101,7 +101,7 @@ describe('ERC721Token', () => { const from = owner; const to = erc721Receiver.address; await expectTransactionFailedAsync( - token.transferFrom.sendTransactionAsync(from, to, tokenId, { from: spender }), + token.transferFrom(from, to, tokenId).sendTransactionAsync({ from: spender }), RevertReason.Erc721InvalidSpender, ); }); @@ -109,9 +109,9 @@ describe('ERC721Token', () => { const from = owner; const to = erc721Receiver.address; const txReceipt = await logDecoder.getTxWithDecodedLogsAsync( - await token.transferFrom.sendTransactionAsync(from, to, tokenId), + await token.transferFrom(from, to, tokenId).sendTransactionAsync(), ); - const newOwner = await token.ownerOf.callAsync(tokenId); + const newOwner = await token.ownerOf(tokenId).callAsync(); expect(newOwner).to.be.equal(to); const log = txReceipt.logs[0] as LogWithDecodedArgs; expect(log.args._from).to.be.equal(from); @@ -121,16 +121,16 @@ describe('ERC721Token', () => { it('should transfer the token if spender is approved for all', async () => { const isApproved = true; await web3Wrapper.awaitTransactionSuccessAsync( - await token.setApprovalForAll.sendTransactionAsync(spender, isApproved), + await token.setApprovalForAll(spender, isApproved).sendTransactionAsync(), constants.AWAIT_TRANSACTION_MINED_MS, ); const from = owner; const to = erc721Receiver.address; const txReceipt = await logDecoder.getTxWithDecodedLogsAsync( - await token.transferFrom.sendTransactionAsync(from, to, tokenId), + await token.transferFrom(from, to, tokenId).sendTransactionAsync(), ); - const newOwner = await token.ownerOf.callAsync(tokenId); + const newOwner = await token.ownerOf(tokenId).callAsync(); expect(newOwner).to.be.equal(to); const log = txReceipt.logs[0] as LogWithDecodedArgs; expect(log.args._from).to.be.equal(from); @@ -139,19 +139,19 @@ describe('ERC721Token', () => { }); it('should transfer the token if spender is individually approved', async () => { await web3Wrapper.awaitTransactionSuccessAsync( - await token.approve.sendTransactionAsync(spender, tokenId), + await token.approve(spender, tokenId).sendTransactionAsync(), constants.AWAIT_TRANSACTION_MINED_MS, ); const from = owner; const to = erc721Receiver.address; const txReceipt = await logDecoder.getTxWithDecodedLogsAsync( - await token.transferFrom.sendTransactionAsync(from, to, tokenId), + await token.transferFrom(from, to, tokenId).sendTransactionAsync(), ); - const newOwner = await token.ownerOf.callAsync(tokenId); + const newOwner = await token.ownerOf(tokenId).callAsync(); expect(newOwner).to.be.equal(to); - const approvedAddress = await token.getApproved.callAsync(tokenId); + const approvedAddress = await token.getApproved(tokenId).callAsync(); expect(approvedAddress).to.be.equal(constants.NULL_ADDRESS); const log = txReceipt.logs[0] as LogWithDecodedArgs; expect(log.args._from).to.be.equal(from); @@ -164,9 +164,9 @@ describe('ERC721Token', () => { const from = owner; const to = spender; const txReceipt = await logDecoder.getTxWithDecodedLogsAsync( - await token.safeTransferFrom1.sendTransactionAsync(from, to, tokenId), + await token.safeTransferFrom1(from, to, tokenId).sendTransactionAsync(), ); - const newOwner = await token.ownerOf.callAsync(tokenId); + const newOwner = await token.ownerOf(tokenId).callAsync(); expect(newOwner).to.be.equal(to); const log = txReceipt.logs[0] as LogWithDecodedArgs; expect(log.args._from).to.be.equal(from); @@ -185,7 +185,7 @@ describe('ERC721Token', () => { const from = owner; const to = contract.address; await expectTransactionFailedWithoutReasonAsync( - token.safeTransferFrom1.sendTransactionAsync(from, to, tokenId), + token.safeTransferFrom1(from, to, tokenId).sendTransactionAsync(), ); }); it('should revert if onERC721Received does not return the correct value', async () => { @@ -198,7 +198,7 @@ describe('ERC721Token', () => { const from = owner; const to = invalidErc721Receiver.address; await expectTransactionFailedAsync( - token.safeTransferFrom1.sendTransactionAsync(from, to, tokenId), + token.safeTransferFrom1(from, to, tokenId).sendTransactionAsync(), RevertReason.Erc721InvalidSelector, ); }); @@ -206,9 +206,9 @@ describe('ERC721Token', () => { const from = owner; const to = erc721Receiver.address; const txReceipt = await logDecoder.getTxWithDecodedLogsAsync( - await token.safeTransferFrom1.sendTransactionAsync(from, to, tokenId), + await token.safeTransferFrom1(from, to, tokenId).sendTransactionAsync(), ); - const newOwner = await token.ownerOf.callAsync(tokenId); + const newOwner = await token.ownerOf(tokenId).callAsync(); expect(newOwner).to.be.equal(to); const transferLog = txReceipt.logs[0] as LogWithDecodedArgs; const receiverLog = txReceipt.logs[1] as LogWithDecodedArgs; @@ -227,9 +227,9 @@ describe('ERC721Token', () => { const from = owner; const to = spender; const txReceipt = await logDecoder.getTxWithDecodedLogsAsync( - await token.safeTransferFrom2.sendTransactionAsync(from, to, tokenId, data), + await token.safeTransferFrom2(from, to, tokenId, data).sendTransactionAsync(), ); - const newOwner = await token.ownerOf.callAsync(tokenId); + const newOwner = await token.ownerOf(tokenId).callAsync(); expect(newOwner).to.be.equal(to); const log = txReceipt.logs[0] as LogWithDecodedArgs; expect(log.args._from).to.be.equal(from); @@ -248,7 +248,7 @@ describe('ERC721Token', () => { const from = owner; const to = contract.address; await expectTransactionFailedWithoutReasonAsync( - token.safeTransferFrom2.sendTransactionAsync(from, to, tokenId, data), + token.safeTransferFrom2(from, to, tokenId, data).sendTransactionAsync(), ); }); it('should revert if onERC721Received does not return the correct value', async () => { @@ -261,7 +261,7 @@ describe('ERC721Token', () => { const from = owner; const to = invalidErc721Receiver.address; await expectTransactionFailedAsync( - token.safeTransferFrom2.sendTransactionAsync(from, to, tokenId, data), + token.safeTransferFrom2(from, to, tokenId, data).sendTransactionAsync(), RevertReason.Erc721InvalidSelector, ); }); @@ -269,9 +269,9 @@ describe('ERC721Token', () => { const from = owner; const to = erc721Receiver.address; const txReceipt = await logDecoder.getTxWithDecodedLogsAsync( - await token.safeTransferFrom2.sendTransactionAsync(from, to, tokenId, data), + await token.safeTransferFrom2(from, to, tokenId, data).sendTransactionAsync(), ); - const newOwner = await token.ownerOf.callAsync(tokenId); + const newOwner = await token.ownerOf(tokenId).callAsync(); expect(newOwner).to.be.equal(to); const transferLog = txReceipt.logs[0] as LogWithDecodedArgs; const receiverLog = txReceipt.logs[1] as LogWithDecodedArgs; diff --git a/contracts/exchange-libs/test/lib_eip712_exchange_domain.ts b/contracts/exchange-libs/test/lib_eip712_exchange_domain.ts index e608726e47..652a2e8766 100644 --- a/contracts/exchange-libs/test/lib_eip712_exchange_domain.ts +++ b/contracts/exchange-libs/test/lib_eip712_exchange_domain.ts @@ -23,7 +23,7 @@ blockchainTests('LibEIP712ExchangeDomain', env => { version: constants.EIP712_DOMAIN_VERSION, }; const expectedDomainHash = ethUtil.bufferToHex(signTypedDataUtils.generateDomainHash(domain)); - const actualDomainHash = await libEIP712ExchangeDomainContract.EIP712_EXCHANGE_DOMAIN_HASH.callAsync(); + const actualDomainHash = await libEIP712ExchangeDomainContract.EIP712_EXCHANGE_DOMAIN_HASH().callAsync(); expect(actualDomainHash).to.be.equal(expectedDomainHash); }); it('should calculate the correct domain hash when verifyingContractAddressIfExists is set to a non-null address', async () => { @@ -44,7 +44,7 @@ blockchainTests('LibEIP712ExchangeDomain', env => { version: constants.EIP712_DOMAIN_VERSION, }; const expectedDomainHash = ethUtil.bufferToHex(signTypedDataUtils.generateDomainHash(domain)); - const actualDomainHash = await libEIP712ExchangeDomainContract.EIP712_EXCHANGE_DOMAIN_HASH.callAsync(); + const actualDomainHash = await libEIP712ExchangeDomainContract.EIP712_EXCHANGE_DOMAIN_HASH().callAsync(); expect(actualDomainHash).to.be.equal(expectedDomainHash); }); }); diff --git a/contracts/exchange-libs/test/lib_fill_results.ts b/contracts/exchange-libs/test/lib_fill_results.ts index c62ee15803..b92ade1c60 100644 --- a/contracts/exchange-libs/test/lib_fill_results.ts +++ b/contracts/exchange-libs/test/lib_fill_results.ts @@ -106,12 +106,14 @@ blockchainTests('LibFillResults', env => { otherAmount: BigNumber, ): Promise { const order = makeOrder(otherAmount, orderTakerAssetAmount, otherAmount, otherAmount); - return libsContract.calculateFillResults.callAsync( - order, - takerAssetFilledAmount, - takerAssetFilledAmount, // Using this so that the gas price is distinct from protocolFeeMultiplier - otherAmount, - ); + return libsContract + .calculateFillResults( + order, + takerAssetFilledAmount, + takerAssetFilledAmount, // Using this so that the gas price is distinct from protocolFeeMultiplier + otherAmount, + ) + .callAsync(); } testCombinatoriallyWithReferenceFunc( @@ -145,12 +147,14 @@ blockchainTests('LibFillResults', env => { DEFAULT_PROTOCOL_FEE_MULTIPLIER, DEFAULT_GAS_PRICE, ); - const actual = await libsContract.calculateFillResults.callAsync( - order, - takerAssetFilledAmount, - DEFAULT_PROTOCOL_FEE_MULTIPLIER, - DEFAULT_GAS_PRICE, - ); + const actual = await libsContract + .calculateFillResults( + order, + takerAssetFilledAmount, + DEFAULT_PROTOCOL_FEE_MULTIPLIER, + DEFAULT_GAS_PRICE, + ) + .callAsync(); expect(actual).to.deep.eq(expected); }); @@ -167,12 +171,14 @@ blockchainTests('LibFillResults', env => { order.makerAssetAmount, ); return expect( - libsContract.calculateFillResults.callAsync( - order, - takerAssetFilledAmount, - DEFAULT_PROTOCOL_FEE_MULTIPLIER, - DEFAULT_GAS_PRICE, - ), + libsContract + .calculateFillResults( + order, + takerAssetFilledAmount, + DEFAULT_PROTOCOL_FEE_MULTIPLIER, + DEFAULT_GAS_PRICE, + ) + .callAsync(), ).to.revertWith(expectedError); }); @@ -195,12 +201,14 @@ blockchainTests('LibFillResults', env => { order.makerFee, ); return expect( - libsContract.calculateFillResults.callAsync( - order, - takerAssetFilledAmount, - DEFAULT_PROTOCOL_FEE_MULTIPLIER, - DEFAULT_GAS_PRICE, - ), + libsContract + .calculateFillResults( + order, + takerAssetFilledAmount, + DEFAULT_PROTOCOL_FEE_MULTIPLIER, + DEFAULT_GAS_PRICE, + ) + .callAsync(), ).to.revertWith(expectedError); }); @@ -218,12 +226,14 @@ blockchainTests('LibFillResults', env => { order.takerFee, ); return expect( - libsContract.calculateFillResults.callAsync( - order, - takerAssetFilledAmount, - DEFAULT_PROTOCOL_FEE_MULTIPLIER, - DEFAULT_GAS_PRICE, - ), + libsContract + .calculateFillResults( + order, + takerAssetFilledAmount, + DEFAULT_PROTOCOL_FEE_MULTIPLIER, + DEFAULT_GAS_PRICE, + ) + .callAsync(), ).to.revertWith(expectedError); }); @@ -235,12 +245,14 @@ blockchainTests('LibFillResults', env => { const takerAssetFilledAmount = ONE_ETHER; const expectedError = new LibMathRevertErrors.DivisionByZeroError(); return expect( - libsContract.calculateFillResults.callAsync( - order, - takerAssetFilledAmount, - DEFAULT_PROTOCOL_FEE_MULTIPLIER, - DEFAULT_GAS_PRICE, - ), + libsContract + .calculateFillResults( + order, + takerAssetFilledAmount, + DEFAULT_PROTOCOL_FEE_MULTIPLIER, + DEFAULT_GAS_PRICE, + ) + .callAsync(), ).to.revertWith(expectedError); }); @@ -256,12 +268,14 @@ blockchainTests('LibFillResults', env => { order.makerAssetAmount, ); return expect( - libsContract.calculateFillResults.callAsync( - order, - takerAssetFilledAmount, - DEFAULT_PROTOCOL_FEE_MULTIPLIER, - DEFAULT_GAS_PRICE, - ), + libsContract + .calculateFillResults( + order, + takerAssetFilledAmount, + DEFAULT_PROTOCOL_FEE_MULTIPLIER, + DEFAULT_GAS_PRICE, + ) + .callAsync(), ).to.revertWith(expectedError); }); @@ -283,12 +297,14 @@ blockchainTests('LibFillResults', env => { order.makerFee, ); return expect( - libsContract.calculateFillResults.callAsync( - order, - takerAssetFilledAmount, - DEFAULT_PROTOCOL_FEE_MULTIPLIER, - DEFAULT_GAS_PRICE, - ), + libsContract + .calculateFillResults( + order, + takerAssetFilledAmount, + DEFAULT_PROTOCOL_FEE_MULTIPLIER, + DEFAULT_GAS_PRICE, + ) + .callAsync(), ).to.revertWith(expectedError); }); @@ -310,12 +326,14 @@ blockchainTests('LibFillResults', env => { order.takerFee, ); return expect( - libsContract.calculateFillResults.callAsync( - order, - takerAssetFilledAmount, - DEFAULT_PROTOCOL_FEE_MULTIPLIER, - DEFAULT_GAS_PRICE, - ), + libsContract + .calculateFillResults( + order, + takerAssetFilledAmount, + DEFAULT_PROTOCOL_FEE_MULTIPLIER, + DEFAULT_GAS_PRICE, + ) + .callAsync(), ).to.revertWith(expectedError); }); @@ -333,12 +351,9 @@ blockchainTests('LibFillResults', env => { MAX_UINT256, ); return expect( - libsContract.calculateFillResults.callAsync( - order, - takerAssetFilledAmount, - MAX_UINT256, - DEFAULT_GAS_PRICE, - ), + libsContract + .calculateFillResults(order, takerAssetFilledAmount, MAX_UINT256, DEFAULT_GAS_PRICE) + .callAsync(), ).to.revertWith(expectedError); }); @@ -360,12 +375,14 @@ blockchainTests('LibFillResults', env => { order.makerFee, ); return expect( - libsContract.calculateFillResults.callAsync( - order, - takerAssetFilledAmount, - DEFAULT_PROTOCOL_FEE_MULTIPLIER, - DEFAULT_GAS_PRICE, - ), + libsContract + .calculateFillResults( + order, + takerAssetFilledAmount, + DEFAULT_PROTOCOL_FEE_MULTIPLIER, + DEFAULT_GAS_PRICE, + ) + .callAsync(), ).to.revertWith(expectedError); }); }); @@ -393,7 +410,7 @@ blockchainTests('LibFillResults', env => { it('matches the output of the reference function', async () => { const [a, b] = DEFAULT_FILL_RESULTS; const expected = ReferenceFunctions.addFillResults(a, b); - const actual = await libsContract.addFillResults.callAsync(a, b); + const actual = await libsContract.addFillResults(a, b).callAsync(); expect(actual).to.deep.equal(expected); }); @@ -405,7 +422,7 @@ blockchainTests('LibFillResults', env => { a.makerAssetFilledAmount, b.makerAssetFilledAmount, ); - return expect(libsContract.addFillResults.callAsync(a, b)).to.revertWith(expectedError); + return expect(libsContract.addFillResults(a, b).callAsync()).to.revertWith(expectedError); }); it('reverts if computing `takerAssetFilledAmount` overflows', async () => { @@ -416,7 +433,7 @@ blockchainTests('LibFillResults', env => { a.takerAssetFilledAmount, b.takerAssetFilledAmount, ); - return expect(libsContract.addFillResults.callAsync(a, b)).to.revertWith(expectedError); + return expect(libsContract.addFillResults(a, b).callAsync()).to.revertWith(expectedError); }); it('reverts if computing `makerFeePaid` overflows', async () => { @@ -427,7 +444,7 @@ blockchainTests('LibFillResults', env => { a.makerFeePaid, b.makerFeePaid, ); - return expect(libsContract.addFillResults.callAsync(a, b)).to.revertWith(expectedError); + return expect(libsContract.addFillResults(a, b).callAsync()).to.revertWith(expectedError); }); it('reverts if computing `takerFeePaid` overflows', async () => { @@ -438,7 +455,7 @@ blockchainTests('LibFillResults', env => { a.takerFeePaid, b.takerFeePaid, ); - return expect(libsContract.addFillResults.callAsync(a, b)).to.revertWith(expectedError); + return expect(libsContract.addFillResults(a, b).callAsync()).to.revertWith(expectedError); }); it('reverts if computing `protocolFeePaid` overflows', async () => { @@ -449,7 +466,7 @@ blockchainTests('LibFillResults', env => { a.protocolFeePaid, b.protocolFeePaid, ); - return expect(libsContract.addFillResults.callAsync(a, b)).to.revertWith(expectedError); + return expect(libsContract.addFillResults(a, b).callAsync()).to.revertWith(expectedError); }); }); }); @@ -513,16 +530,17 @@ blockchainTests('LibFillResults', env => { gasPrice: BigNumber, from?: string, ): Promise { - const actualMatchedFillResults = await libsContract.calculateMatchedFillResults.callAsync( - leftOrder, - rightOrder, - leftOrderTakerAssetFilledAmount, - rightOrderTakerAssetFilledAmount, - protocolFeeMultiplier, - gasPrice, - false, - { from }, - ); + const actualMatchedFillResults = await libsContract + .calculateMatchedFillResults( + leftOrder, + rightOrder, + leftOrderTakerAssetFilledAmount, + rightOrderTakerAssetFilledAmount, + protocolFeeMultiplier, + gasPrice, + false, + ) + .callAsync({ from }); expect(actualMatchedFillResults).to.be.deep.eq(expectedMatchedFillResults); } @@ -1184,16 +1202,17 @@ blockchainTests('LibFillResults', env => { gasPrice: BigNumber, from?: string, ): Promise { - const actualMatchedFillResults = await libsContract.calculateMatchedFillResults.callAsync( - leftOrder, - rightOrder, - leftOrderTakerAssetFilledAmount, - rightOrderTakerAssetFilledAmount, - protocolFeeMultiplier, - gasPrice, - true, - { from }, - ); + const actualMatchedFillResults = await libsContract + .calculateMatchedFillResults( + leftOrder, + rightOrder, + leftOrderTakerAssetFilledAmount, + rightOrderTakerAssetFilledAmount, + protocolFeeMultiplier, + gasPrice, + true, + ) + .callAsync({ from }); expect(actualMatchedFillResults).to.be.deep.eq(expectedMatchedFillResults); } diff --git a/contracts/exchange-libs/test/lib_math.ts b/contracts/exchange-libs/test/lib_math.ts index 5e9b89023e..409517bae9 100644 --- a/contracts/exchange-libs/test/lib_math.ts +++ b/contracts/exchange-libs/test/lib_math.ts @@ -33,8 +33,7 @@ blockchainTests('LibMath', env => { function createContractTestFunction(name: string): (...args: any[]) => Promise { return async (...args: any[]): Promise => { - const method = (libsContract as any)[name] as { callAsync: (...args: any[]) => Promise }; - return method.callAsync(...args); + return (libsContract as any)[name](...args).callAsync; }; } @@ -54,7 +53,7 @@ blockchainTests('LibMath', env => { const denominator = ONE_ETHER.dividedToIntegerBy(2); const target = ONE_ETHER.times(0.01); const expected = ReferenceFunctions.getPartialAmountFloor(numerator, denominator, target); - const actual = await libsContract.getPartialAmountFloor.callAsync(numerator, denominator, target); + const actual = await libsContract.getPartialAmountFloor(numerator, denominator, target).callAsync(); expect(actual).to.bignumber.eq(expected); }); @@ -63,7 +62,7 @@ blockchainTests('LibMath', env => { const denominator = ONE_ETHER.times(1.8); const target = ONE_ETHER; const expected = ONE_ETHER.dividedToIntegerBy(3); - const actual = await libsContract.getPartialAmountFloor.callAsync(numerator, denominator, target); + const actual = await libsContract.getPartialAmountFloor(numerator, denominator, target).callAsync(); expect(actual).to.bignumber.eq(expected); }); @@ -77,7 +76,7 @@ blockchainTests('LibMath', env => { denominator, ); return expect( - libsContract.getPartialAmountFloor.callAsync(numerator, denominator, target), + libsContract.getPartialAmountFloor(numerator, denominator, target).callAsync(), ).to.revertWith(expectedError); }); @@ -91,7 +90,7 @@ blockchainTests('LibMath', env => { target, ); return expect( - libsContract.getPartialAmountFloor.callAsync(numerator, denominator, target), + libsContract.getPartialAmountFloor(numerator, denominator, target).callAsync(), ).to.revertWith(expectedError); }); }); @@ -113,7 +112,7 @@ blockchainTests('LibMath', env => { const denominator = ONE_ETHER.dividedToIntegerBy(2); const target = ONE_ETHER.times(0.01); const expected = ReferenceFunctions.getPartialAmountCeil(numerator, denominator, target); - const actual = await libsContract.getPartialAmountCeil.callAsync(numerator, denominator, target); + const actual = await libsContract.getPartialAmountCeil(numerator, denominator, target).callAsync(); expect(actual).to.bignumber.eq(expected); }); @@ -122,7 +121,7 @@ blockchainTests('LibMath', env => { const denominator = ONE_ETHER.times(1.8); const target = ONE_ETHER; const expected = ONE_ETHER.dividedToIntegerBy(3).plus(1); - const actual = await libsContract.getPartialAmountCeil.callAsync(numerator, denominator, target); + const actual = await libsContract.getPartialAmountCeil(numerator, denominator, target).callAsync(); expect(actual).to.bignumber.eq(expected); }); @@ -137,7 +136,7 @@ blockchainTests('LibMath', env => { new BigNumber(1), ); return expect( - libsContract.getPartialAmountCeil.callAsync(numerator, denominator, target), + libsContract.getPartialAmountCeil(numerator, denominator, target).callAsync(), ).to.revertWith(expectedError); }); @@ -151,7 +150,7 @@ blockchainTests('LibMath', env => { target, ); return expect( - libsContract.getPartialAmountCeil.callAsync(numerator, denominator, target), + libsContract.getPartialAmountCeil(numerator, denominator, target).callAsync(), ).to.revertWith(expectedError); }); }); @@ -173,7 +172,7 @@ blockchainTests('LibMath', env => { const denominator = ONE_ETHER.dividedToIntegerBy(2); const target = ONE_ETHER.times(0.01); const expected = ReferenceFunctions.safeGetPartialAmountFloor(numerator, denominator, target); - const actual = await libsContract.safeGetPartialAmountFloor.callAsync(numerator, denominator, target); + const actual = await libsContract.safeGetPartialAmountFloor(numerator, denominator, target).callAsync(); expect(actual).to.bignumber.eq(expected); }); @@ -182,7 +181,7 @@ blockchainTests('LibMath', env => { const denominator = ONE_ETHER.times(1.8); const target = ONE_ETHER; const expected = ONE_ETHER.dividedToIntegerBy(3); - const actual = await libsContract.safeGetPartialAmountFloor.callAsync(numerator, denominator, target); + const actual = await libsContract.safeGetPartialAmountFloor(numerator, denominator, target).callAsync(); expect(actual).to.bignumber.eq(expected); }); @@ -192,7 +191,7 @@ blockchainTests('LibMath', env => { const target = new BigNumber(333); const expectedError = new LibMathRevertErrors.RoundingError(numerator, denominator, target); return expect( - libsContract.safeGetPartialAmountFloor.callAsync(numerator, denominator, target), + libsContract.safeGetPartialAmountFloor(numerator, denominator, target).callAsync(), ).to.revertWith(expectedError); }); @@ -202,7 +201,7 @@ blockchainTests('LibMath', env => { const target = ONE_ETHER.times(0.01); const expectedError = new LibMathRevertErrors.DivisionByZeroError(); return expect( - libsContract.safeGetPartialAmountFloor.callAsync(numerator, denominator, target), + libsContract.safeGetPartialAmountFloor(numerator, denominator, target).callAsync(), ).to.revertWith(expectedError); }); @@ -216,7 +215,7 @@ blockchainTests('LibMath', env => { target, ); return expect( - libsContract.safeGetPartialAmountFloor.callAsync(numerator, denominator, target), + libsContract.safeGetPartialAmountFloor(numerator, denominator, target).callAsync(), ).to.revertWith(expectedError); }); }); @@ -238,7 +237,7 @@ blockchainTests('LibMath', env => { const denominator = ONE_ETHER.dividedToIntegerBy(2); const target = ONE_ETHER.times(0.01); const expected = ReferenceFunctions.safeGetPartialAmountCeil(numerator, denominator, target); - const actual = await libsContract.safeGetPartialAmountCeil.callAsync(numerator, denominator, target); + const actual = await libsContract.safeGetPartialAmountCeil(numerator, denominator, target).callAsync(); expect(actual).to.bignumber.eq(expected); }); @@ -247,7 +246,7 @@ blockchainTests('LibMath', env => { const denominator = ONE_ETHER.times(1.8); const target = ONE_ETHER; const expected = ONE_ETHER.dividedToIntegerBy(3).plus(1); - const actual = await libsContract.safeGetPartialAmountCeil.callAsync(numerator, denominator, target); + const actual = await libsContract.safeGetPartialAmountCeil(numerator, denominator, target).callAsync(); expect(actual).to.bignumber.eq(expected); }); @@ -257,7 +256,7 @@ blockchainTests('LibMath', env => { const target = new BigNumber(333); const expectedError = new LibMathRevertErrors.RoundingError(numerator, denominator, target); return expect( - libsContract.safeGetPartialAmountCeil.callAsync(numerator, denominator, target), + libsContract.safeGetPartialAmountCeil(numerator, denominator, target).callAsync(), ).to.revertWith(expectedError); }); @@ -267,7 +266,7 @@ blockchainTests('LibMath', env => { const target = ONE_ETHER.times(0.01); const expectedError = new LibMathRevertErrors.DivisionByZeroError(); return expect( - libsContract.safeGetPartialAmountCeil.callAsync(numerator, denominator, target), + libsContract.safeGetPartialAmountCeil(numerator, denominator, target).callAsync(), ).to.revertWith(expectedError); }); @@ -281,7 +280,7 @@ blockchainTests('LibMath', env => { target, ); return expect( - libsContract.safeGetPartialAmountCeil.callAsync(numerator, denominator, target), + libsContract.safeGetPartialAmountCeil(numerator, denominator, target).callAsync(), ).to.revertWith(expectedError); }); }); @@ -303,7 +302,7 @@ blockchainTests('LibMath', env => { const denominator = new BigNumber(102); const target = new BigNumber(52); // tslint:disable-next-line: boolean-naming - const actual = await libsContract.isRoundingErrorFloor.callAsync(numerator, denominator, target); + const actual = await libsContract.isRoundingErrorFloor(numerator, denominator, target).callAsync(); expect(actual).to.eq(true); }); @@ -312,7 +311,7 @@ blockchainTests('LibMath', env => { const denominator = new BigNumber(101); const target = new BigNumber(92); // tslint:disable-next-line: boolean-naming - const actual = await libsContract.isRoundingErrorFloor.callAsync(numerator, denominator, target); + const actual = await libsContract.isRoundingErrorFloor(numerator, denominator, target).callAsync(); expect(actual).to.eq(false); }); @@ -323,7 +322,7 @@ blockchainTests('LibMath', env => { // tslint:disable-next-line: boolean-naming const expected = ReferenceFunctions.isRoundingErrorFloor(numerator, denominator, target); // tslint:disable-next-line: boolean-naming - const actual = await libsContract.isRoundingErrorFloor.callAsync(numerator, denominator, target); + const actual = await libsContract.isRoundingErrorFloor(numerator, denominator, target).callAsync(); expect(actual).to.eq(expected); }); @@ -333,7 +332,7 @@ blockchainTests('LibMath', env => { const target = ONE_ETHER.times(0.01); const expectedError = new LibMathRevertErrors.DivisionByZeroError(); return expect( - libsContract.isRoundingErrorFloor.callAsync(numerator, denominator, target), + libsContract.isRoundingErrorFloor(numerator, denominator, target).callAsync(), ).to.revertWith(expectedError); }); @@ -347,7 +346,7 @@ blockchainTests('LibMath', env => { target, ); return expect( - libsContract.isRoundingErrorFloor.callAsync(numerator, denominator, target), + libsContract.isRoundingErrorFloor(numerator, denominator, target).callAsync(), ).to.revertWith(expectedError); }); }); @@ -369,7 +368,7 @@ blockchainTests('LibMath', env => { const denominator = new BigNumber(101); const target = new BigNumber(92); // tslint:disable-next-line: boolean-naming - const actual = await libsContract.isRoundingErrorCeil.callAsync(numerator, denominator, target); + const actual = await libsContract.isRoundingErrorCeil(numerator, denominator, target).callAsync(); expect(actual).to.eq(true); }); @@ -378,7 +377,7 @@ blockchainTests('LibMath', env => { const denominator = new BigNumber(102); const target = new BigNumber(52); // tslint:disable-next-line: boolean-naming - const actual = await libsContract.isRoundingErrorCeil.callAsync(numerator, denominator, target); + const actual = await libsContract.isRoundingErrorCeil(numerator, denominator, target).callAsync(); expect(actual).to.eq(false); }); @@ -389,7 +388,7 @@ blockchainTests('LibMath', env => { // tslint:disable-next-line: boolean-naming const expected = ReferenceFunctions.isRoundingErrorCeil(numerator, denominator, target); // tslint:disable-next-line: boolean-naming - const actual = await libsContract.isRoundingErrorCeil.callAsync(numerator, denominator, target); + const actual = await libsContract.isRoundingErrorCeil(numerator, denominator, target).callAsync(); expect(actual).to.eq(expected); }); @@ -398,9 +397,9 @@ blockchainTests('LibMath', env => { const denominator = ZERO_AMOUNT; const target = ONE_ETHER.times(0.01); const expectedError = new LibMathRevertErrors.DivisionByZeroError(); - return expect(libsContract.isRoundingErrorCeil.callAsync(numerator, denominator, target)).to.revertWith( - expectedError, - ); + return expect( + libsContract.isRoundingErrorCeil(numerator, denominator, target).callAsync(), + ).to.revertWith(expectedError); }); it('reverts if `numerator * target` overflows', async () => { @@ -412,9 +411,9 @@ blockchainTests('LibMath', env => { numerator, target, ); - return expect(libsContract.isRoundingErrorCeil.callAsync(numerator, denominator, target)).to.revertWith( - expectedError, - ); + return expect( + libsContract.isRoundingErrorCeil(numerator, denominator, target).callAsync(), + ).to.revertWith(expectedError); }); }); }); diff --git a/contracts/exchange-libs/test/lib_order.ts b/contracts/exchange-libs/test/lib_order.ts index ec87e6b4cd..1ad0f015db 100644 --- a/contracts/exchange-libs/test/lib_order.ts +++ b/contracts/exchange-libs/test/lib_order.ts @@ -56,7 +56,7 @@ blockchainTests('LibOrder', env => { version: constants.EIP712_DOMAIN_VERSION, }), ); - const actualHash = await libOrderContract.getTypedDataHash.callAsync(order, domainHash); + const actualHash = await libOrderContract.getTypedDataHash(order, domainHash).callAsync(); expect(actualHash).to.be.eq(expectedHash); } @@ -106,8 +106,8 @@ blockchainTests('LibOrder', env => { chainId: 1337, }), ); - const orderHashHex1 = await libOrderContract.getTypedDataHash.callAsync(EMPTY_ORDER, domainHash1); - const orderHashHex2 = await libOrderContract.getTypedDataHash.callAsync(EMPTY_ORDER, domainHash2); + const orderHashHex1 = await libOrderContract.getTypedDataHash(EMPTY_ORDER, domainHash1).callAsync(); + const orderHashHex2 = await libOrderContract.getTypedDataHash(EMPTY_ORDER, domainHash2).callAsync(); expect(orderHashHex1).to.be.not.equal(orderHashHex2); }); }); @@ -118,7 +118,7 @@ blockchainTests('LibOrder', env => { async function testGetStructHashAsync(order: Order): Promise { const typedData = eip712Utils.createOrderTypedData(order); const expectedHash = ethUtil.bufferToHex(signTypedDataUtils.generateTypedDataHashWithoutDomain(typedData)); - const actualHash = await libOrderContract.getStructHash.callAsync(order); + const actualHash = await libOrderContract.getStructHash(order).callAsync(); expect(actualHash).to.be.eq(expectedHash); } diff --git a/contracts/exchange-libs/test/lib_zero_ex_transaction.ts b/contracts/exchange-libs/test/lib_zero_ex_transaction.ts index 00d3446606..e650e17a31 100644 --- a/contracts/exchange-libs/test/lib_zero_ex_transaction.ts +++ b/contracts/exchange-libs/test/lib_zero_ex_transaction.ts @@ -48,7 +48,7 @@ blockchainTests('LibZeroExTransaction', env => { version: constants.EIP712_DOMAIN_VERSION, }), ); - const actualHash = await libZeroExTransactionContract.getTypedDataHash.callAsync(transaction, domainHash); + const actualHash = await libZeroExTransactionContract.getTypedDataHash(transaction, domainHash).callAsync(); expect(actualHash).to.be.eq(expectedHash); } @@ -92,14 +92,12 @@ blockchainTests('LibZeroExTransaction', env => { chainId: 1337, }), ); - const transactionHashHex1 = await libZeroExTransactionContract.getTypedDataHash.callAsync( - EMPTY_TRANSACTION, - domainHash1, - ); - const transactionHashHex2 = await libZeroExTransactionContract.getTypedDataHash.callAsync( - EMPTY_TRANSACTION, - domainHash2, - ); + const transactionHashHex1 = await libZeroExTransactionContract + .getTypedDataHash(EMPTY_TRANSACTION, domainHash1) + .callAsync(); + const transactionHashHex2 = await libZeroExTransactionContract + .getTypedDataHash(EMPTY_TRANSACTION, domainHash2) + .callAsync(); expect(transactionHashHex1).to.be.not.equal(transactionHashHex2); }); }); @@ -110,7 +108,7 @@ blockchainTests('LibZeroExTransaction', env => { async function testGetStructHashAsync(transaction: ZeroExTransaction): Promise { const typedData = eip712Utils.createZeroExTransactionTypedData(transaction); const expectedHash = ethUtil.bufferToHex(signTypedDataUtils.generateTypedDataHashWithoutDomain(typedData)); - const actualHash = await libZeroExTransactionContract.getStructHash.callAsync(transaction); + const actualHash = await libZeroExTransactionContract.getStructHash(transaction).callAsync(); expect(actualHash).to.be.eq(expectedHash); } diff --git a/contracts/exchange/src/wrapper_interfaces.ts b/contracts/exchange/src/wrapper_interfaces.ts index 2c8fe219b1..23942b10b5 100644 --- a/contracts/exchange/src/wrapper_interfaces.ts +++ b/contracts/exchange/src/wrapper_interfaces.ts @@ -1,53 +1,21 @@ -import { PromiseWithTransactionHash } from '@0x/base-contract'; -import { AwaitTransactionSuccessOpts } from '@0x/types'; -import { BlockParam, CallData, TransactionReceiptWithDecodedLogs, TxData } from 'ethereum-types'; +import { ContractFunctionObj, ContractTxFunctionObj, PromiseWithTransactionHash } from '@0x/base-contract'; +import { BlockParam, CallData } from 'ethereum-types'; +// tslint:disable:max-classes-per-file // Generated Wrapper Interfaces -export interface AssetProxyDispatcher { - registerAssetProxy: { - awaitTransactionSuccessAsync: ( - assetProxy: string, - txData?: Partial, - txOpts?: AwaitTransactionSuccessOpts, - ) => PromiseWithTransactionHash; - }; - getAssetProxy: { - callAsync(assetProxyId: string, callData?: Partial, defaultBlock?: BlockParam): Promise; - }; +export abstract class AssetProxyDispatcher { + public abstract registerAssetProxy(assetProxy: string): ContractTxFunctionObj; + public abstract getAssetProxy(assetProxyId: string): ContractFunctionObj; } -export interface Authorizable extends Ownable { - addAuthorizedAddress: { - awaitTransactionSuccessAsync: ( - target: string, - txData?: Partial, - txOpts?: AwaitTransactionSuccessOpts, - ) => PromiseWithTransactionHash; - }; - removeAuthorizedAddress: { - awaitTransactionSuccessAsync: ( - target: string, - txData?: Partial, - txOpts?: AwaitTransactionSuccessOpts, - ) => PromiseWithTransactionHash; - }; - authorized: { - callAsync(authority: string, callData?: Partial, defaultBlock?: BlockParam): Promise; - }; - getAuthorizedAddresses: { - callAsync(callData?: Partial, defaultBlock?: BlockParam): Promise; - }; -} +export abstract class Ownable { + public abstract transferOwnership(newOwner: string): ContractTxFunctionObj; -export interface Ownable { - transferOwnership: { - awaitTransactionSuccessAsync: ( - newOwner: string, - txData?: Partial, - txOpts?: AwaitTransactionSuccessOpts, - ) => PromiseWithTransactionHash; - }; - owner: { - callAsync(callData?: Partial, defaultBlock?: BlockParam): Promise; - }; + public abstract owner(callData?: Partial, defaultBlock?: BlockParam): ContractFunctionObj; +} +export abstract class Authorizable extends Ownable { + public abstract addAuthorizedAddress(target: string): ContractTxFunctionObj; + public abstract removeAuthorizedAddress(target: string): ContractTxFunctionObj; + public abstract authorized(authority: string): ContractFunctionObj; + public abstract getAuthorizedAddresses(): ContractFunctionObj; } diff --git a/contracts/exchange/test/assertion_wrappers/fill_order_wrapper.ts b/contracts/exchange/test/assertion_wrappers/fill_order_wrapper.ts index 0c6e552f3b..cb2878dbed 100644 --- a/contracts/exchange/test/assertion_wrappers/fill_order_wrapper.ts +++ b/contracts/exchange/test/assertion_wrappers/fill_order_wrapper.ts @@ -157,9 +157,9 @@ export class FillOrderWrapper { ): Promise { // Get init state await this._blockchainBalanceStore.updateBalancesAsync(); - const initTakerAssetFilledAmount = await this._exchange.filled.callAsync( - orderHashUtils.getOrderHashHex(signedOrder), - ); + const initTakerAssetFilledAmount = await this._exchange + .filled(orderHashUtils.getOrderHashHex(signedOrder)) + .callAsync(); // Assert init state of exchange await this._assertOrderStateAsync(signedOrder, initTakerAssetFilledAmount); // Simulate and execute fill then assert outputs @@ -190,18 +190,12 @@ export class FillOrderWrapper { opts: { takerAssetFillAmount?: BigNumber } = {}, ): Promise<[FillResults, FillEventArgs, TransactionReceiptWithDecodedLogs]> { const params = orderUtils.createFill(signedOrder, opts.takerAssetFillAmount); - const fillResults = await this._exchange.fillOrder.callAsync( - params.order, - params.takerAssetFillAmount, - params.signature, - { from }, - ); - const txReceipt = await this._exchange.fillOrder.awaitTransactionSuccessAsync( - params.order, - params.takerAssetFillAmount, - params.signature, - { from }, - ); + const fillResults = await this._exchange + .fillOrder(params.order, params.takerAssetFillAmount, params.signature) + .callAsync({ from }); + const txReceipt = await this._exchange + .fillOrder(params.order, params.takerAssetFillAmount, params.signature) + .awaitTransactionSuccessAsync({ from }); const fillEvent = FillOrderWrapper._extractFillEventsfromReceipt(txReceipt)[0]; return [fillResults, fillEvent, txReceipt]; } @@ -216,7 +210,7 @@ export class FillOrderWrapper { order: SignedOrder, expectedFilledAmount: BigNumber = new BigNumber(0), ): Promise { - const orderInfo = await this._exchange.getOrderInfo.callAsync(order); + const orderInfo = await this._exchange.getOrderInfo(order).callAsync(); // Check filled amount of order. const actualFilledAmount = orderInfo.orderTakerAssetFilledAmount; expect(actualFilledAmount, 'order filled amount').to.be.bignumber.equal(expectedFilledAmount); diff --git a/contracts/exchange/test/balance_stores/blockchain_balance_store.ts b/contracts/exchange/test/balance_stores/blockchain_balance_store.ts index 73d4fff643..4cebeea2f9 100644 --- a/contracts/exchange/test/balance_stores/blockchain_balance_store.ts +++ b/contracts/exchange/test/balance_stores/blockchain_balance_store.ts @@ -64,7 +64,7 @@ export class BlockchainBalanceStore extends BalanceStore { this._ownerAddresses.map(async account => _.zipObject( this._tokenContracts.erc20.map(token => token.address), - await Promise.all(this._tokenContracts.erc20.map(token => token.balanceOf.callAsync(account))), + await Promise.all(this._tokenContracts.erc20.map(token => token.balanceOf(account).callAsync())), ), ), ); @@ -83,7 +83,7 @@ export class BlockchainBalanceStore extends BalanceStore { this._balances.erc721 = {}; for (const [tokenAddress, tokenIds] of Object.entries(this._tokenIds.erc721)) { for (const tokenId of tokenIds) { - const tokenOwner = await erc721ContractsByAddress[tokenAddress].ownerOf.callAsync(tokenId); + const tokenOwner = await erc721ContractsByAddress[tokenAddress].ownerOf(tokenId).callAsync(); _.update(this._balances.erc721, [tokenOwner, tokenAddress], nfts => _.union([tokenId], nfts).sort()); } } @@ -108,10 +108,9 @@ export class BlockchainBalanceStore extends BalanceStore { const [_tokenIds, _tokenOwners] = _.unzip( combinatorics.cartesianProduct(tokenIds, this._ownerAddresses).toArray(), ); - const balances = await contract.balanceOfBatch.callAsync( - _tokenOwners as string[], - _tokenIds as BigNumber[], - ); + const balances = await contract + .balanceOfBatch(_tokenOwners as string[], _tokenIds as BigNumber[]) + .callAsync(); let i = 0; for (const tokenOwner of this._ownerAddresses) { diff --git a/contracts/exchange/test/balance_stores/local_balance_store.ts b/contracts/exchange/test/balance_stores/local_balance_store.ts index 458777a871..8fb612f219 100644 --- a/contracts/exchange/test/balance_stores/local_balance_store.ts +++ b/contracts/exchange/test/balance_stores/local_balance_store.ts @@ -81,11 +81,11 @@ export class LocalBalanceStore extends BalanceStore { if (fromAddress === toAddress) { return; } - const assetProxyId = await this._devUtils.decodeAssetProxyId.callAsync(assetData); + const assetProxyId = await this._devUtils.decodeAssetProxyId(assetData).callAsync(); switch (assetProxyId) { case AssetProxyId.ERC20: { // tslint:disable-next-line:no-unused-variable - const [proxyId, tokenAddress] = await this._devUtils.decodeERC20AssetData.callAsync(assetData); + const [proxyId, tokenAddress] = await this._devUtils.decodeERC20AssetData(assetData).callAsync(); _.update(this._balances.erc20, [fromAddress, tokenAddress], balance => balance.minus(amount)); _.update(this._balances.erc20, [toAddress, tokenAddress], balance => (balance || constants.ZERO_AMOUNT).plus(amount), @@ -94,9 +94,9 @@ export class LocalBalanceStore extends BalanceStore { } case AssetProxyId.ERC721: { // tslint:disable-next-line:no-unused-variable - const [proxyId, tokenAddress, tokenId] = await this._devUtils.decodeERC721AssetData.callAsync( - assetData, - ); + const [proxyId, tokenAddress, tokenId] = await this._devUtils + .decodeERC721AssetData(assetData) + .callAsync(); const fromTokens = _.get(this._balances.erc721, [fromAddress, tokenAddress], []); const toTokens = _.get(this._balances.erc721, [toAddress, tokenAddress], []); if (amount.gte(1)) { @@ -117,7 +117,7 @@ export class LocalBalanceStore extends BalanceStore { tokenAddress, tokenIds, tokenValues, - ] = await this._devUtils.decodeERC1155AssetData.callAsync(assetData); + ] = await this._devUtils.decodeERC1155AssetData(assetData).callAsync(); const fromBalances = { // tslint:disable-next-line:no-inferred-empty-object-type fungible: _.get(this._balances.erc1155, [fromAddress, tokenAddress, 'fungible'], {}), @@ -155,9 +155,9 @@ export class LocalBalanceStore extends BalanceStore { } case AssetProxyId.MultiAsset: { // tslint:disable-next-line:no-unused-variable - const [proxyId, amounts, nestedAssetData] = await this._devUtils.decodeMultiAssetData.callAsync( - assetData, - ); + const [proxyId, amounts, nestedAssetData] = await this._devUtils + .decodeMultiAssetData(assetData) + .callAsync(); for (const [i, amt] of amounts.entries()) { const nestedAmount = amount.times(amt); await this.transferAssetAsync(fromAddress, toAddress, nestedAmount, nestedAssetData[i]); diff --git a/contracts/exchange/test/core.ts b/contracts/exchange/test/core.ts index 55da2bd13b..ff281a5ecd 100644 --- a/contracts/exchange/test/core.ts +++ b/contracts/exchange/test/core.ts @@ -157,22 +157,22 @@ blockchainTests.resets('Exchange core', () => { exchange.address, ); // Configure ERC20Proxy - await erc20Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(exchange.address, { from: owner }); - await erc20Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(multiAssetProxy.address, { from: owner }); + await erc20Proxy.addAuthorizedAddress(exchange.address).awaitTransactionSuccessAsync({ from: owner }); + await erc20Proxy.addAuthorizedAddress(multiAssetProxy.address).awaitTransactionSuccessAsync({ from: owner }); // Configure ERC721Proxy - await erc721Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(exchange.address, { from: owner }); - await erc721Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(multiAssetProxy.address, { from: owner }); + await erc721Proxy.addAuthorizedAddress(exchange.address).awaitTransactionSuccessAsync({ from: owner }); + await erc721Proxy.addAuthorizedAddress(multiAssetProxy.address).awaitTransactionSuccessAsync({ from: owner }); // Configure ERC1155Proxy - await erc1155Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(exchange.address, { from: owner }); - await erc1155Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(multiAssetProxy.address, { from: owner }); + await erc1155Proxy.addAuthorizedAddress(exchange.address).awaitTransactionSuccessAsync({ from: owner }); + await erc1155Proxy.addAuthorizedAddress(multiAssetProxy.address).awaitTransactionSuccessAsync({ from: owner }); // Configure MultiAssetProxy - await multiAssetProxy.addAuthorizedAddress.awaitTransactionSuccessAsync(exchange.address, { from: owner }); - await multiAssetProxy.registerAssetProxy.awaitTransactionSuccessAsync(erc20Proxy.address, { from: owner }); - await multiAssetProxy.registerAssetProxy.awaitTransactionSuccessAsync(erc721Proxy.address, { from: owner }); - await multiAssetProxy.registerAssetProxy.awaitTransactionSuccessAsync(staticCallProxy.address, { from: owner }); + await multiAssetProxy.addAuthorizedAddress(exchange.address).awaitTransactionSuccessAsync({ from: owner }); + await multiAssetProxy.registerAssetProxy(erc20Proxy.address).awaitTransactionSuccessAsync({ from: owner }); + await multiAssetProxy.registerAssetProxy(erc721Proxy.address).awaitTransactionSuccessAsync({ from: owner }); + await multiAssetProxy.registerAssetProxy(staticCallProxy.address).awaitTransactionSuccessAsync({ from: owner }); // Configure Exchange exchangeWrapper = new ExchangeWrapper(exchange); @@ -216,10 +216,10 @@ blockchainTests.resets('Exchange core', () => { ...constants.STATIC_ORDER_PARAMS, makerAddress, feeRecipientAddress, - makerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultMakerAssetAddress), - takerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultTakerAssetAddress), - makerFeeAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultFeeAssetAddress), - takerFeeAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultFeeAssetAddress), + makerAssetData: await devUtils.encodeERC20AssetData(defaultMakerAssetAddress).callAsync(), + takerAssetData: await devUtils.encodeERC20AssetData(defaultTakerAssetAddress).callAsync(), + makerFeeAssetData: await devUtils.encodeERC20AssetData(defaultFeeAssetAddress).callAsync(), + takerFeeAssetData: await devUtils.encodeERC20AssetData(defaultFeeAssetAddress).callAsync(), exchangeAddress: exchange.address, chainId, }; @@ -257,24 +257,19 @@ blockchainTests.resets('Exchange core', () => { describe('callback signature types', () => { beforeEach(async () => { // Approve the ERC20 proxy with the test validator wallet. - await validatorWallet.approveERC20.awaitTransactionSuccessAsync( - erc20TokenA.address, - erc20Proxy.address, - constants.INITIAL_ERC20_ALLOWANCE, - ); + await validatorWallet + .approveERC20(erc20TokenA.address, erc20Proxy.address, constants.INITIAL_ERC20_ALLOWANCE) + .awaitTransactionSuccessAsync(); // Mint some ERC20 tokens to the test validator wallet. - await erc20TokenA.setBalance.awaitTransactionSuccessAsync( - validatorWallet.address, - constants.INITIAL_ERC20_BALANCE, - ); + await erc20TokenA + .setBalance(validatorWallet.address, constants.INITIAL_ERC20_BALANCE) + .awaitTransactionSuccessAsync(); // Approve the validator. - await exchange.setSignatureValidatorApproval.awaitTransactionSuccessAsync( - validatorWallet.address, - true, - { + await exchange + .setSignatureValidatorApproval(validatorWallet.address, true) + .awaitTransactionSuccessAsync({ from: makerAddress, - }, - ); + }); signedOrder = await orderFactory.newSignedOrderAsync({ makerFee: constants.ZERO_AMOUNT, takerFee: constants.ZERO_AMOUNT, @@ -286,19 +281,15 @@ blockchainTests.resets('Exchange core', () => { signedOrder.signature = signatureHex; const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder); // Allow the signature check for the first fill. - await validatorWallet.prepare.awaitTransactionSuccessAsync( - orderHashHex, - ValidatorWalletAction.Accept, - constants.NULL_BYTES, - ); + await validatorWallet + .prepare(orderHashHex, ValidatorWalletAction.Accept, constants.NULL_BYTES) + .awaitTransactionSuccessAsync(); const fillAmount = signedOrder.takerAssetAmount.div(10); await exchangeWrapper.fillOrderAsync(signedOrder, takerAddress, { takerAssetFillAmount: fillAmount }); // Reject the signature check for the second fill. - await validatorWallet.prepare.awaitTransactionSuccessAsync( - orderHashHex, - ValidatorWalletAction.Reject, - constants.NULL_BYTES, - ); + await validatorWallet + .prepare(orderHashHex, ValidatorWalletAction.Reject, constants.NULL_BYTES) + .awaitTransactionSuccessAsync(); const tx = exchangeWrapper.fillOrderAsync(signedOrder, takerAddress, { takerAssetFillAmount: fillAmount, }); @@ -317,19 +308,15 @@ blockchainTests.resets('Exchange core', () => { signedOrder.signature = signatureHex; const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder); // Allow the signature check for the first fill. - await validatorWallet.prepare.awaitTransactionSuccessAsync( - orderHashHex, - ValidatorWalletAction.Accept, - constants.NULL_BYTES, - ); + await validatorWallet + .prepare(orderHashHex, ValidatorWalletAction.Accept, constants.NULL_BYTES) + .awaitTransactionSuccessAsync(); const fillAmount = signedOrder.takerAssetAmount.div(10); await exchangeWrapper.fillOrderAsync(signedOrder, takerAddress, { takerAssetFillAmount: fillAmount }); // Reject the signature check for the second fill. - await validatorWallet.prepare.awaitTransactionSuccessAsync( - orderHashHex, - ValidatorWalletAction.Reject, - constants.NULL_BYTES, - ); + await validatorWallet + .prepare(orderHashHex, ValidatorWalletAction.Reject, constants.NULL_BYTES) + .awaitTransactionSuccessAsync(); const tx = exchangeWrapper.fillOrderAsync(signedOrder, takerAddress, { takerAssetFillAmount: fillAmount, }); @@ -348,19 +335,15 @@ blockchainTests.resets('Exchange core', () => { signedOrder.signature = signatureHex; const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder); // Allow the signature check for the first fill. - await validatorWallet.prepare.awaitTransactionSuccessAsync( - orderHashHex, - ValidatorWalletAction.Accept, - constants.NULL_BYTES, - ); + await validatorWallet + .prepare(orderHashHex, ValidatorWalletAction.Accept, constants.NULL_BYTES) + .awaitTransactionSuccessAsync(); const fillAmount = signedOrder.takerAssetAmount.div(10); await exchangeWrapper.fillOrderAsync(signedOrder, takerAddress, { takerAssetFillAmount: fillAmount }); // Reject the signature check for the second fill. - await validatorWallet.prepare.awaitTransactionSuccessAsync( - orderHashHex, - ValidatorWalletAction.Reject, - constants.NULL_BYTES, - ); + await validatorWallet + .prepare(orderHashHex, ValidatorWalletAction.Reject, constants.NULL_BYTES) + .awaitTransactionSuccessAsync(); const tx = exchangeWrapper.fillOrderAsync(signedOrder, takerAddress, { takerAssetFillAmount: fillAmount, }); @@ -425,9 +408,11 @@ blockchainTests.resets('Exchange core', () => { describe('Fill transfer ordering', () => { it('should allow the maker to exchange assets received by the taker', async () => { // Set maker/taker assetData to the same asset - const takerAssetData = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); + const takerAssetData = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); const takerAssetAmount = new BigNumber(1); - const makerAssetData = await devUtils.encodeMultiAssetData.callAsync([takerAssetAmount], [takerAssetData]); + const makerAssetData = await devUtils + .encodeMultiAssetData([takerAssetAmount], [takerAssetData]) + .callAsync(); signedOrder = await orderFactory.newSignedOrderAsync({ makerAssetData, takerAssetData, @@ -437,33 +422,33 @@ blockchainTests.resets('Exchange core', () => { takerFee: constants.ZERO_AMOUNT, }); // Set maker balance to 0 so that the asset must be received by the taker in order for the fill to succeed - await erc20TokenA.setBalance.awaitTransactionSuccessAsync(makerAddress, constants.ZERO_AMOUNT, { + await erc20TokenA.setBalance(makerAddress, constants.ZERO_AMOUNT).awaitTransactionSuccessAsync({ from: owner, }); await fillOrderWrapper.fillOrderAndAssertEffectsAsync(signedOrder, takerAddress); }); it('should allow the taker to pay fees with an asset that received by the maker', async () => { - const makerAssetData = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); + const makerAssetData = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); signedOrder = await orderFactory.newSignedOrderAsync({ takerFeeAssetData: makerAssetData, makerFee: constants.ZERO_AMOUNT, takerFee: new BigNumber(1), }); // Set taker balance to 0 so that the asset must be received by the maker in order for the fill to succeed - await erc20TokenA.setBalance.awaitTransactionSuccessAsync(takerAddress, constants.ZERO_AMOUNT, { + await erc20TokenA.setBalance(takerAddress, constants.ZERO_AMOUNT).awaitTransactionSuccessAsync({ from: owner, }); await fillOrderWrapper.fillOrderAndAssertEffectsAsync(signedOrder, takerAddress); }); it('should allow the maker to pay fees with an asset that received by the taker', async () => { - const takerAssetData = await devUtils.encodeERC20AssetData.callAsync(erc20TokenB.address); + const takerAssetData = await devUtils.encodeERC20AssetData(erc20TokenB.address).callAsync(); signedOrder = await orderFactory.newSignedOrderAsync({ makerFeeAssetData: takerAssetData, makerFee: new BigNumber(1), takerFee: constants.ZERO_AMOUNT, }); // Set maker balance to 0 so that the asset must be received by the taker in order for the fill to succeed - await erc20TokenB.setBalance.awaitTransactionSuccessAsync(makerAddress, constants.ZERO_AMOUNT, { + await erc20TokenB.setBalance(makerAddress, constants.ZERO_AMOUNT).awaitTransactionSuccessAsync({ from: owner, }); await fillOrderWrapper.fillOrderAndAssertEffectsAsync(signedOrder, takerAddress); @@ -471,19 +456,16 @@ blockchainTests.resets('Exchange core', () => { }); describe('Testing exchange of ERC20 tokens with no return values', () => { before(async () => { - await noReturnErc20Token.setBalance.awaitTransactionSuccessAsync( - makerAddress, - constants.INITIAL_ERC20_BALANCE, - ); - await noReturnErc20Token.approve.awaitTransactionSuccessAsync( - erc20Proxy.address, - constants.INITIAL_ERC20_ALLOWANCE, - { from: makerAddress }, - ); + await noReturnErc20Token + .setBalance(makerAddress, constants.INITIAL_ERC20_BALANCE) + .awaitTransactionSuccessAsync(); + await noReturnErc20Token + .approve(erc20Proxy.address, constants.INITIAL_ERC20_ALLOWANCE) + .awaitTransactionSuccessAsync({ from: makerAddress }); }); it('should transfer the correct amounts when makerAssetAmount === takerAssetAmount', async () => { signedOrder = await orderFactory.newSignedOrderAsync({ - makerAssetData: await devUtils.encodeERC20AssetData.callAsync(noReturnErc20Token.address), + makerAssetData: await devUtils.encodeERC20AssetData(noReturnErc20Token.address).callAsync(), makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(100), 18), takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(100), 18), }); @@ -491,7 +473,7 @@ blockchainTests.resets('Exchange core', () => { }); it('should transfer the correct amounts when makerAssetAmount > takerAssetAmount', async () => { signedOrder = await orderFactory.newSignedOrderAsync({ - makerAssetData: await devUtils.encodeERC20AssetData.callAsync(noReturnErc20Token.address), + makerAssetData: await devUtils.encodeERC20AssetData(noReturnErc20Token.address).callAsync(), makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(200), 18), takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(100), 18), }); @@ -499,7 +481,7 @@ blockchainTests.resets('Exchange core', () => { }); it('should transfer the correct amounts when makerAssetAmount < takerAssetAmount', async () => { signedOrder = await orderFactory.newSignedOrderAsync({ - makerAssetData: await devUtils.encodeERC20AssetData.callAsync(noReturnErc20Token.address), + makerAssetData: await devUtils.encodeERC20AssetData(noReturnErc20Token.address).callAsync(), makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(100), 18), takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(200), 18), }); @@ -676,14 +658,14 @@ blockchainTests.resets('Exchange core', () => { signedOrder = await orderFactory.newSignedOrderAsync({ makerAssetAmount: new BigNumber(1), takerAssetAmount: new BigNumber(1), - makerAssetData: await devUtils.encodeERC721AssetData.callAsync(erc721Token.address, makerAssetId), - takerAssetData: await devUtils.encodeERC721AssetData.callAsync(erc721Token.address, takerAssetId), + makerAssetData: await devUtils.encodeERC721AssetData(erc721Token.address, makerAssetId).callAsync(), + takerAssetData: await devUtils.encodeERC721AssetData(erc721Token.address, takerAssetId).callAsync(), }); const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder); // Verify pre-conditions - const initialOwnerMakerAsset = await erc721Token.ownerOf.callAsync(makerAssetId); + const initialOwnerMakerAsset = await erc721Token.ownerOf(makerAssetId).callAsync(); expect(initialOwnerMakerAsset).to.be.bignumber.not.equal(makerAddress); - const initialOwnerTakerAsset = await erc721Token.ownerOf.callAsync(takerAssetId); + const initialOwnerTakerAsset = await erc721Token.ownerOf(takerAssetId).callAsync(); expect(initialOwnerTakerAsset).to.be.bignumber.equal(takerAddress); // Call Exchange const takerAssetFillAmount = signedOrder.takerAssetAmount; @@ -703,14 +685,14 @@ blockchainTests.resets('Exchange core', () => { signedOrder = await orderFactory.newSignedOrderAsync({ makerAssetAmount: new BigNumber(1), takerAssetAmount: new BigNumber(1), - makerAssetData: await devUtils.encodeERC721AssetData.callAsync(erc721Token.address, makerAssetId), - takerAssetData: await devUtils.encodeERC721AssetData.callAsync(erc721Token.address, takerAssetId), + makerAssetData: await devUtils.encodeERC721AssetData(erc721Token.address, makerAssetId).callAsync(), + takerAssetData: await devUtils.encodeERC721AssetData(erc721Token.address, takerAssetId).callAsync(), }); const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder); // Verify pre-conditions - const initialOwnerMakerAsset = await erc721Token.ownerOf.callAsync(makerAssetId); + const initialOwnerMakerAsset = await erc721Token.ownerOf(makerAssetId).callAsync(); expect(initialOwnerMakerAsset).to.be.bignumber.equal(makerAddress); - const initialOwnerTakerAsset = await erc721Token.ownerOf.callAsync(takerAssetId); + const initialOwnerTakerAsset = await erc721Token.ownerOf(takerAssetId).callAsync(); expect(initialOwnerTakerAsset).to.be.bignumber.not.equal(takerAddress); // Call Exchange const takerAssetFillAmount = signedOrder.takerAssetAmount; @@ -730,14 +712,14 @@ blockchainTests.resets('Exchange core', () => { signedOrder = await orderFactory.newSignedOrderAsync({ makerAssetAmount: new BigNumber(2), takerAssetAmount: new BigNumber(1), - makerAssetData: await devUtils.encodeERC721AssetData.callAsync(erc721Token.address, makerAssetId), - takerAssetData: await devUtils.encodeERC721AssetData.callAsync(erc721Token.address, takerAssetId), + makerAssetData: await devUtils.encodeERC721AssetData(erc721Token.address, makerAssetId).callAsync(), + takerAssetData: await devUtils.encodeERC721AssetData(erc721Token.address, takerAssetId).callAsync(), }); const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder); // Verify pre-conditions - const initialOwnerMakerAsset = await erc721Token.ownerOf.callAsync(makerAssetId); + const initialOwnerMakerAsset = await erc721Token.ownerOf(makerAssetId).callAsync(); expect(initialOwnerMakerAsset).to.be.bignumber.equal(makerAddress); - const initialOwnerTakerAsset = await erc721Token.ownerOf.callAsync(takerAssetId); + const initialOwnerTakerAsset = await erc721Token.ownerOf(takerAssetId).callAsync(); expect(initialOwnerTakerAsset).to.be.bignumber.equal(takerAddress); // Call Exchange const takerAssetFillAmount = signedOrder.takerAssetAmount; @@ -757,14 +739,14 @@ blockchainTests.resets('Exchange core', () => { signedOrder = await orderFactory.newSignedOrderAsync({ makerAssetAmount: new BigNumber(1), takerAssetAmount: new BigNumber(500), - makerAssetData: await devUtils.encodeERC721AssetData.callAsync(erc721Token.address, makerAssetId), - takerAssetData: await devUtils.encodeERC721AssetData.callAsync(erc721Token.address, takerAssetId), + makerAssetData: await devUtils.encodeERC721AssetData(erc721Token.address, makerAssetId).callAsync(), + takerAssetData: await devUtils.encodeERC721AssetData(erc721Token.address, takerAssetId).callAsync(), }); const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder); // Verify pre-conditions - const initialOwnerMakerAsset = await erc721Token.ownerOf.callAsync(makerAssetId); + const initialOwnerMakerAsset = await erc721Token.ownerOf(makerAssetId).callAsync(); expect(initialOwnerMakerAsset).to.be.bignumber.equal(makerAddress); - const initialOwnerTakerAsset = await erc721Token.ownerOf.callAsync(takerAssetId); + const initialOwnerTakerAsset = await erc721Token.ownerOf(takerAssetId).callAsync(); expect(initialOwnerTakerAsset).to.be.bignumber.equal(takerAddress); // Call Exchange const takerAssetFillAmount = signedOrder.takerAssetAmount; @@ -783,8 +765,8 @@ blockchainTests.resets('Exchange core', () => { signedOrder = await orderFactory.newSignedOrderAsync({ makerAssetAmount: new BigNumber(1), takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(100), 18), - makerAssetData: await devUtils.encodeERC721AssetData.callAsync(erc721Token.address, makerAssetId), - takerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultTakerAssetAddress), + makerAssetData: await devUtils.encodeERC721AssetData(erc721Token.address, makerAssetId).callAsync(), + takerAssetData: await devUtils.encodeERC20AssetData(defaultTakerAssetAddress).callAsync(), }); // Call Exchange const takerAssetFillAmount = signedOrder.takerAssetAmount.div(2); @@ -802,12 +784,12 @@ blockchainTests.resets('Exchange core', () => { it('should allow multiple assets to be exchanged for a single asset', async () => { const makerAmounts = [new BigNumber(10), new BigNumber(20)]; const makerNestedAssetData = [ - await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address), - await devUtils.encodeERC20AssetData.callAsync(erc20TokenB.address), + await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(), + await devUtils.encodeERC20AssetData(erc20TokenB.address).callAsync(), ]; - const makerAssetData = await devUtils.encodeMultiAssetData.callAsync(makerAmounts, makerNestedAssetData); + const makerAssetData = await devUtils.encodeMultiAssetData(makerAmounts, makerNestedAssetData).callAsync(); const makerAssetAmount = new BigNumber(1); - const takerAssetData = await devUtils.encodeERC20AssetData.callAsync(feeToken.address); + const takerAssetData = await devUtils.encodeERC20AssetData(feeToken.address).callAsync(); const takerAssetAmount = new BigNumber(10); signedOrder = await orderFactory.newSignedOrderAsync({ makerAssetData, @@ -822,18 +804,18 @@ blockchainTests.resets('Exchange core', () => { it('should allow multiple assets to be exchanged for multiple assets', async () => { const makerAmounts = [new BigNumber(10), new BigNumber(20)]; const makerNestedAssetData = [ - await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address), - await devUtils.encodeERC20AssetData.callAsync(erc20TokenB.address), + await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(), + await devUtils.encodeERC20AssetData(erc20TokenB.address).callAsync(), ]; - const makerAssetData = await devUtils.encodeMultiAssetData.callAsync(makerAmounts, makerNestedAssetData); + const makerAssetData = await devUtils.encodeMultiAssetData(makerAmounts, makerNestedAssetData).callAsync(); const makerAssetAmount = new BigNumber(1); const takerAmounts = [new BigNumber(10), new BigNumber(1)]; const takerAssetId = erc721TakerAssetIds[0]; const takerNestedAssetData = [ - await devUtils.encodeERC20AssetData.callAsync(feeToken.address), - await devUtils.encodeERC721AssetData.callAsync(erc721Token.address, takerAssetId), + await devUtils.encodeERC20AssetData(feeToken.address).callAsync(), + await devUtils.encodeERC721AssetData(erc721Token.address, takerAssetId).callAsync(), ]; - const takerAssetData = await devUtils.encodeMultiAssetData.callAsync(takerAmounts, takerNestedAssetData); + const takerAssetData = await devUtils.encodeMultiAssetData(takerAmounts, takerNestedAssetData).callAsync(); const takerAssetAmount = new BigNumber(1); signedOrder = await orderFactory.newSignedOrderAsync({ makerAssetData, @@ -848,12 +830,12 @@ blockchainTests.resets('Exchange core', () => { it('should allow an order selling multiple assets to be partially filled', async () => { const makerAmounts = [new BigNumber(10), new BigNumber(20)]; const makerNestedAssetData = [ - await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address), - await devUtils.encodeERC20AssetData.callAsync(erc20TokenB.address), + await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(), + await devUtils.encodeERC20AssetData(erc20TokenB.address).callAsync(), ]; - const makerAssetData = await devUtils.encodeMultiAssetData.callAsync(makerAmounts, makerNestedAssetData); + const makerAssetData = await devUtils.encodeMultiAssetData(makerAmounts, makerNestedAssetData).callAsync(); const makerAssetAmount = new BigNumber(30); - const takerAssetData = await devUtils.encodeERC20AssetData.callAsync(feeToken.address); + const takerAssetData = await devUtils.encodeERC20AssetData(feeToken.address).callAsync(); const takerAssetAmount = new BigNumber(10); signedOrder = await orderFactory.newSignedOrderAsync({ makerAssetData, @@ -870,12 +852,12 @@ blockchainTests.resets('Exchange core', () => { it('should allow an order buying multiple assets to be partially filled', async () => { const takerAmounts = [new BigNumber(10), new BigNumber(20)]; const takerNestedAssetData = [ - await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address), - await devUtils.encodeERC20AssetData.callAsync(erc20TokenB.address), + await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(), + await devUtils.encodeERC20AssetData(erc20TokenB.address).callAsync(), ]; - const takerAssetData = await devUtils.encodeMultiAssetData.callAsync(takerAmounts, takerNestedAssetData); + const takerAssetData = await devUtils.encodeMultiAssetData(takerAmounts, takerNestedAssetData).callAsync(); const takerAssetAmount = new BigNumber(30); - const makerAssetData = await devUtils.encodeERC20AssetData.callAsync(feeToken.address); + const makerAssetData = await devUtils.encodeERC20AssetData(feeToken.address).callAsync(); const makerAssetAmount = new BigNumber(10); signedOrder = await orderFactory.newSignedOrderAsync({ makerAssetData, @@ -901,18 +883,22 @@ blockchainTests.resets('Exchange core', () => { const makerAssetAmount = new BigNumber(1); const takerAssetAmount = new BigNumber(1); const receiverCallbackData = '0x'; - const makerAssetData = await devUtils.encodeERC1155AssetData.callAsync( - erc1155Contract.address, - makerAssetsToTransfer, - makerValuesToTransfer, - receiverCallbackData, - ); - const takerAssetData = await devUtils.encodeERC1155AssetData.callAsync( - erc1155Contract.address, - takerAssetsToTransfer, - takerValuesToTransfer, - receiverCallbackData, - ); + const makerAssetData = await devUtils + .encodeERC1155AssetData( + erc1155Contract.address, + makerAssetsToTransfer, + makerValuesToTransfer, + receiverCallbackData, + ) + .callAsync(); + const takerAssetData = await devUtils + .encodeERC1155AssetData( + erc1155Contract.address, + takerAssetsToTransfer, + takerValuesToTransfer, + receiverCallbackData, + ) + .callAsync(); signedOrder = await orderFactory.newSignedOrderAsync({ makerAssetData, takerAssetData, @@ -936,18 +922,22 @@ blockchainTests.resets('Exchange core', () => { const makerAssetAmount = new BigNumber(1); const takerAssetAmount = new BigNumber(1); const receiverCallbackData = '0x'; - const makerAssetData = await devUtils.encodeERC1155AssetData.callAsync( - erc1155Contract.address, - makerAssetsToTransfer, - makerValuesToTransfer, - receiverCallbackData, - ); - const takerAssetData = await devUtils.encodeERC1155AssetData.callAsync( - erc1155Contract.address, - takerAssetsToTransfer, - takerValuesToTransfer, - receiverCallbackData, - ); + const makerAssetData = await devUtils + .encodeERC1155AssetData( + erc1155Contract.address, + makerAssetsToTransfer, + makerValuesToTransfer, + receiverCallbackData, + ) + .callAsync(); + const takerAssetData = await devUtils + .encodeERC1155AssetData( + erc1155Contract.address, + takerAssetsToTransfer, + takerValuesToTransfer, + receiverCallbackData, + ) + .callAsync(); signedOrder = await orderFactory.newSignedOrderAsync({ makerAssetData, takerAssetData, @@ -970,18 +960,22 @@ blockchainTests.resets('Exchange core', () => { const makerAssetAmount = new BigNumber(1); const takerAssetAmount = new BigNumber(1); const receiverCallbackData = '0x'; - const makerAssetData = await devUtils.encodeERC1155AssetData.callAsync( - erc1155Contract.address, - makerAssetsToTransfer, - makerValuesToTransfer, - receiverCallbackData, - ); - const takerAssetData = await devUtils.encodeERC1155AssetData.callAsync( - erc1155Contract.address, - takerAssetsToTransfer, - takerValuesToTransfer, - receiverCallbackData, - ); + const makerAssetData = await devUtils + .encodeERC1155AssetData( + erc1155Contract.address, + makerAssetsToTransfer, + makerValuesToTransfer, + receiverCallbackData, + ) + .callAsync(); + const takerAssetData = await devUtils + .encodeERC1155AssetData( + erc1155Contract.address, + takerAssetsToTransfer, + takerValuesToTransfer, + receiverCallbackData, + ) + .callAsync(); signedOrder = await orderFactory.newSignedOrderAsync({ makerAssetData, takerAssetData, @@ -1010,18 +1004,22 @@ blockchainTests.resets('Exchange core', () => { const makerAssetAmount = new BigNumber(1); const takerAssetAmount = new BigNumber(1); const receiverCallbackData = '0x'; - const makerAssetData = await devUtils.encodeERC1155AssetData.callAsync( - erc1155Contract.address, - makerAssetsToTransfer, - makerValuesToTransfer, - receiverCallbackData, - ); - const takerAssetData = await devUtils.encodeERC1155AssetData.callAsync( - erc1155Contract.address, - takerAssetsToTransfer, - takerValuesToTransfer, - receiverCallbackData, - ); + const makerAssetData = await devUtils + .encodeERC1155AssetData( + erc1155Contract.address, + makerAssetsToTransfer, + makerValuesToTransfer, + receiverCallbackData, + ) + .callAsync(); + const takerAssetData = await devUtils + .encodeERC1155AssetData( + erc1155Contract.address, + takerAssetsToTransfer, + takerValuesToTransfer, + receiverCallbackData, + ) + .callAsync(); signedOrder = await orderFactory.newSignedOrderAsync({ makerAssetData, takerAssetData, @@ -1055,18 +1053,22 @@ blockchainTests.resets('Exchange core', () => { const makerAssetAmount = new BigNumber(10); const takerAssetAmount = new BigNumber(20); const receiverCallbackData = '0x'; - const makerAssetData = await devUtils.encodeERC1155AssetData.callAsync( - erc1155Contract.address, - makerAssetsToTransfer, - makerValuesToTransfer, - receiverCallbackData, - ); - const takerAssetData = await devUtils.encodeERC1155AssetData.callAsync( - erc1155Contract.address, - takerAssetsToTransfer, - takerValuesToTransfer, - receiverCallbackData, - ); + const makerAssetData = await devUtils + .encodeERC1155AssetData( + erc1155Contract.address, + makerAssetsToTransfer, + makerValuesToTransfer, + receiverCallbackData, + ) + .callAsync(); + const takerAssetData = await devUtils + .encodeERC1155AssetData( + erc1155Contract.address, + takerAssetsToTransfer, + takerValuesToTransfer, + receiverCallbackData, + ) + .callAsync(); signedOrder = await orderFactory.newSignedOrderAsync({ makerAssetData, takerAssetData, @@ -1091,12 +1093,10 @@ blockchainTests.resets('Exchange core', () => { ); }); it('should revert if the staticcall is unsuccessful', async () => { - const staticCallData = staticCallTarget.assertEvenNumber.getABIEncodedTransactionData(new BigNumber(1)); - const assetData = await devUtils.encodeStaticCallAssetData.callAsync( - staticCallTarget.address, - staticCallData, - constants.KECCAK256_NULL, - ); + const staticCallData = staticCallTarget.assertEvenNumber(new BigNumber(1)).getABIEncodedTransactionData(); + const assetData = await devUtils + .encodeStaticCallAssetData(staticCallTarget.address, staticCallData, constants.KECCAK256_NULL) + .callAsync(); signedOrder = await orderFactory.newSignedOrderAsync({ makerAssetData: assetData }); const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder); const expectedError = new ExchangeRevertErrors.AssetProxyTransferError( @@ -1108,28 +1108,26 @@ blockchainTests.resets('Exchange core', () => { return expect(tx).to.revertWith(expectedError); }); it('should fill the order if the staticcall is successful', async () => { - const staticCallData = staticCallTarget.assertEvenNumber.getABIEncodedTransactionData( - constants.ZERO_AMOUNT, - ); - const assetData = await devUtils.encodeStaticCallAssetData.callAsync( - staticCallTarget.address, - staticCallData, - constants.KECCAK256_NULL, - ); + const staticCallData = staticCallTarget + .assertEvenNumber(constants.ZERO_AMOUNT) + .getABIEncodedTransactionData(); + const assetData = await devUtils + .encodeStaticCallAssetData(staticCallTarget.address, staticCallData, constants.KECCAK256_NULL) + .callAsync(); signedOrder = await orderFactory.newSignedOrderAsync({ makerAssetData: assetData }); await fillOrderWrapper.fillOrderAndAssertEffectsAsync(signedOrder, takerAddress); }); it('should revert if the staticcall is unsuccessful using the MultiAssetProxy', async () => { - const staticCallData = staticCallTarget.assertEvenNumber.getABIEncodedTransactionData(new BigNumber(1)); - const staticCallAssetData = await devUtils.encodeStaticCallAssetData.callAsync( - staticCallTarget.address, - staticCallData, - constants.KECCAK256_NULL, - ); - const assetData = await devUtils.encodeMultiAssetData.callAsync( - [new BigNumber(1), new BigNumber(1)], - [await devUtils.encodeERC20AssetData.callAsync(defaultMakerAssetAddress), staticCallAssetData], - ); + const staticCallData = staticCallTarget.assertEvenNumber(new BigNumber(1)).getABIEncodedTransactionData(); + const staticCallAssetData = await devUtils + .encodeStaticCallAssetData(staticCallTarget.address, staticCallData, constants.KECCAK256_NULL) + .callAsync(); + const assetData = await devUtils + .encodeMultiAssetData( + [new BigNumber(1), new BigNumber(1)], + [await devUtils.encodeERC20AssetData(defaultMakerAssetAddress).callAsync(), staticCallAssetData], + ) + .callAsync(); signedOrder = await orderFactory.newSignedOrderAsync({ makerAssetData: assetData }); const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder); const expectedError = new ExchangeRevertErrors.AssetProxyTransferError( @@ -1141,18 +1139,18 @@ blockchainTests.resets('Exchange core', () => { return expect(tx).to.revertWith(expectedError); }); it('should fill the order is the staticcall is successful using the MultiAssetProxy', async () => { - const staticCallData = staticCallTarget.assertEvenNumber.getABIEncodedTransactionData( - constants.ZERO_AMOUNT, - ); - const staticCallAssetData = await devUtils.encodeStaticCallAssetData.callAsync( - staticCallTarget.address, - staticCallData, - constants.KECCAK256_NULL, - ); - const assetData = await devUtils.encodeMultiAssetData.callAsync( - [new BigNumber(1), new BigNumber(1)], - [await devUtils.encodeERC20AssetData.callAsync(defaultMakerAssetAddress), staticCallAssetData], - ); + const staticCallData = staticCallTarget + .assertEvenNumber(constants.ZERO_AMOUNT) + .getABIEncodedTransactionData(); + const staticCallAssetData = await devUtils + .encodeStaticCallAssetData(staticCallTarget.address, staticCallData, constants.KECCAK256_NULL) + .callAsync(); + const assetData = await devUtils + .encodeMultiAssetData( + [new BigNumber(1), new BigNumber(1)], + [await devUtils.encodeERC20AssetData(defaultMakerAssetAddress).callAsync(), staticCallAssetData], + ) + .callAsync(); signedOrder = await orderFactory.newSignedOrderAsync({ makerAssetData: assetData }); await fillOrderWrapper.fillOrderAndAssertEffectsAsync(signedOrder, takerAddress); }); diff --git a/contracts/exchange/test/dispatcher.ts b/contracts/exchange/test/dispatcher.ts index 067f3e2fac..a7794ad8ba 100644 --- a/contracts/exchange/test/dispatcher.ts +++ b/contracts/exchange/test/dispatcher.ts @@ -82,10 +82,10 @@ describe('AssetProxyDispatcher', () => { txDefaults, dependencyArtifacts, ); - await erc20Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(assetProxyDispatcher.address, { + await erc20Proxy.addAuthorizedAddress(assetProxyDispatcher.address).awaitTransactionSuccessAsync({ from: owner, }); - await erc721Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(assetProxyDispatcher.address, { + await erc721Proxy.addAuthorizedAddress(assetProxyDispatcher.address).awaitTransactionSuccessAsync({ from: owner, }); }); @@ -97,34 +97,34 @@ describe('AssetProxyDispatcher', () => { }); describe('registerAssetProxy', () => { it('should record proxy upon registration', async () => { - await assetProxyDispatcher.registerAssetProxy.awaitTransactionSuccessAsync(erc20Proxy.address, { + await assetProxyDispatcher.registerAssetProxy(erc20Proxy.address).awaitTransactionSuccessAsync({ from: owner, }); - const proxyAddress = await assetProxyDispatcher.getAssetProxy.callAsync(AssetProxyId.ERC20); + const proxyAddress = await assetProxyDispatcher.getAssetProxy(AssetProxyId.ERC20).callAsync(); expect(proxyAddress).to.be.equal(erc20Proxy.address); }); it('should be able to record multiple proxies', async () => { // Record first proxy - await assetProxyDispatcher.registerAssetProxy.awaitTransactionSuccessAsync(erc20Proxy.address, { + await assetProxyDispatcher.registerAssetProxy(erc20Proxy.address).awaitTransactionSuccessAsync({ from: owner, }); - let proxyAddress = await assetProxyDispatcher.getAssetProxy.callAsync(AssetProxyId.ERC20); + let proxyAddress = await assetProxyDispatcher.getAssetProxy(AssetProxyId.ERC20).callAsync(); expect(proxyAddress).to.be.equal(erc20Proxy.address); // Record another proxy - await assetProxyDispatcher.registerAssetProxy.awaitTransactionSuccessAsync(erc721Proxy.address, { + await assetProxyDispatcher.registerAssetProxy(erc721Proxy.address).awaitTransactionSuccessAsync({ from: owner, }); - proxyAddress = await assetProxyDispatcher.getAssetProxy.callAsync(AssetProxyId.ERC721); + proxyAddress = await assetProxyDispatcher.getAssetProxy(AssetProxyId.ERC721).callAsync(); expect(proxyAddress).to.be.equal(erc721Proxy.address); }); it('should revert if a proxy with the same id is already registered', async () => { // Initial registration - await assetProxyDispatcher.registerAssetProxy.awaitTransactionSuccessAsync(erc20Proxy.address, { + await assetProxyDispatcher.registerAssetProxy(erc20Proxy.address).awaitTransactionSuccessAsync({ from: owner, }); - const proxyAddress = await assetProxyDispatcher.getAssetProxy.callAsync(AssetProxyId.ERC20); + const proxyAddress = await assetProxyDispatcher.getAssetProxy(AssetProxyId.ERC20).callAsync(); expect(proxyAddress).to.be.equal(erc20Proxy.address); // Deploy a new version of the ERC20 Transfer Proxy contract const newErc20TransferProxy = await ERC20ProxyContract.deployFrom0xArtifactAsync( @@ -134,7 +134,7 @@ describe('AssetProxyDispatcher', () => { dependencyArtifacts, ); const expectedError = new ExchangeRevertErrors.AssetProxyExistsError(AssetProxyId.ERC20, proxyAddress); - const tx = assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(newErc20TransferProxy.address, { + const tx = assetProxyDispatcher.registerAssetProxy(newErc20TransferProxy.address).sendTransactionAsync({ from: owner, }); return expect(tx).to.revertWith(expectedError); @@ -142,7 +142,7 @@ describe('AssetProxyDispatcher', () => { it('should revert if requesting address is not owner', async () => { const expectedError = new OwnableRevertErrors.OnlyOwnerError(notOwner, owner); - const tx = assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(erc20Proxy.address, { + const tx = assetProxyDispatcher.registerAssetProxy(erc20Proxy.address).sendTransactionAsync({ from: notOwner, }); return expect(tx).to.revertWith(expectedError); @@ -150,7 +150,7 @@ describe('AssetProxyDispatcher', () => { it('should revert if the proxy is not a contract address', async () => { const errMessage = 'VM Exception while processing transaction: revert'; - const tx = assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(notOwner, { + const tx = assetProxyDispatcher.registerAssetProxy(notOwner).sendTransactionAsync({ from: owner, }); return expect(tx).to.be.rejectedWith(errMessage); @@ -159,7 +159,7 @@ describe('AssetProxyDispatcher', () => { it('should log an event with correct arguments when an asset proxy is registered', async () => { const logDecoder = new LogDecoder(web3Wrapper, artifacts); const txReceipt = await logDecoder.getTxWithDecodedLogsAsync( - await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(erc20Proxy.address, { + await assetProxyDispatcher.registerAssetProxy(erc20Proxy.address).sendTransactionAsync({ from: owner, }), ); @@ -172,15 +172,15 @@ describe('AssetProxyDispatcher', () => { describe('getAssetProxy', () => { it('should return correct address of registered proxy', async () => { - await assetProxyDispatcher.registerAssetProxy.awaitTransactionSuccessAsync(erc20Proxy.address, { + await assetProxyDispatcher.registerAssetProxy(erc20Proxy.address).awaitTransactionSuccessAsync({ from: owner, }); - const proxyAddress = await assetProxyDispatcher.getAssetProxy.callAsync(AssetProxyId.ERC20); + const proxyAddress = await assetProxyDispatcher.getAssetProxy(AssetProxyId.ERC20).callAsync(); expect(proxyAddress).to.be.equal(erc20Proxy.address); }); it('should return NULL address if requesting non-existent proxy', async () => { - const proxyAddress = await assetProxyDispatcher.getAssetProxy.callAsync(AssetProxyId.ERC20); + const proxyAddress = await assetProxyDispatcher.getAssetProxy(AssetProxyId.ERC20).callAsync(); expect(proxyAddress).to.be.equal(constants.NULL_ADDRESS); }); }); @@ -189,23 +189,18 @@ describe('AssetProxyDispatcher', () => { const orderHash = orderUtils.generatePseudoRandomOrderHash(); it('should dispatch transfer to registered proxy', async () => { // Register ERC20 proxy - await assetProxyDispatcher.registerAssetProxy.awaitTransactionSuccessAsync(erc20Proxy.address, { + await assetProxyDispatcher.registerAssetProxy(erc20Proxy.address).awaitTransactionSuccessAsync({ from: owner, }); // Construct metadata for ERC20 proxy - const encodedAssetData = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); + const encodedAssetData = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); // Perform a transfer from makerAddress to takerAddress const erc20Balances = await erc20Wrapper.getBalancesAsync(); const amount = new BigNumber(10); - await assetProxyDispatcher.dispatchTransferFrom.awaitTransactionSuccessAsync( - orderHash, - encodedAssetData, - makerAddress, - takerAddress, - amount, - { from: owner }, - ); + await assetProxyDispatcher + .dispatchTransferFrom(orderHash, encodedAssetData, makerAddress, takerAddress, amount) + .awaitTransactionSuccessAsync({ from: owner }); // Verify transfer was successful const newBalances = await erc20Wrapper.getBalancesAsync(); expect(newBalances[makerAddress][erc20TokenA.address]).to.be.bignumber.equal( @@ -218,23 +213,18 @@ describe('AssetProxyDispatcher', () => { it('should not dispatch a transfer if amount == 0', async () => { // Register ERC20 proxy - await assetProxyDispatcher.registerAssetProxy.awaitTransactionSuccessAsync(erc20Proxy.address, { + await assetProxyDispatcher.registerAssetProxy(erc20Proxy.address).awaitTransactionSuccessAsync({ from: owner, }); // Construct metadata for ERC20 proxy - const encodedAssetData = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); + const encodedAssetData = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); // Perform a transfer from makerAddress to takerAddress const erc20Balances = await erc20Wrapper.getBalancesAsync(); const amount = constants.ZERO_AMOUNT; - const txReceipt = await assetProxyDispatcher.dispatchTransferFrom.awaitTransactionSuccessAsync( - orderHash, - encodedAssetData, - makerAddress, - takerAddress, - amount, - { from: owner }, - ); + const txReceipt = await assetProxyDispatcher + .dispatchTransferFrom(orderHash, encodedAssetData, makerAddress, takerAddress, amount) + .awaitTransactionSuccessAsync({ from: owner }); expect(txReceipt.logs.length).to.be.equal(0); const newBalances = await erc20Wrapper.getBalancesAsync(); expect(newBalances).to.deep.equal(erc20Balances); @@ -242,7 +232,7 @@ describe('AssetProxyDispatcher', () => { it('should revert if dispatching to unregistered proxy', async () => { // Construct metadata for ERC20 proxy - const encodedAssetData = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); + const encodedAssetData = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); // Perform a transfer from makerAddress to takerAddress const amount = new BigNumber(10); @@ -251,70 +241,58 @@ describe('AssetProxyDispatcher', () => { orderHash, encodedAssetData, ); - const tx = assetProxyDispatcher.dispatchTransferFrom.sendTransactionAsync( - orderHash, - encodedAssetData, - makerAddress, - takerAddress, - amount, - { from: owner }, - ); + const tx = assetProxyDispatcher + .dispatchTransferFrom(orderHash, encodedAssetData, makerAddress, takerAddress, amount) + .sendTransactionAsync({ from: owner }); return expect(tx).to.revertWith(expectedError); }); it('should revert with the correct error when assetData length < 4 bytes', async () => { - await assetProxyDispatcher.registerAssetProxy.awaitTransactionSuccessAsync(erc20Proxy.address, { + await assetProxyDispatcher.registerAssetProxy(erc20Proxy.address).awaitTransactionSuccessAsync({ from: owner, }); - const encodedAssetData = (await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address)).slice(0, 8); + const encodedAssetData = (await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync()).slice(0, 8); const amount = new BigNumber(1); const expectedError = new ExchangeRevertErrors.AssetProxyDispatchError( ExchangeRevertErrors.AssetProxyDispatchErrorCode.InvalidAssetDataLength, orderHash, encodedAssetData, ); - const tx = assetProxyDispatcher.dispatchTransferFrom.sendTransactionAsync( - orderHash, - encodedAssetData, - makerAddress, - takerAddress, - amount, - { from: owner }, - ); + const tx = assetProxyDispatcher + .dispatchTransferFrom(orderHash, encodedAssetData, makerAddress, takerAddress, amount) + .sendTransactionAsync({ from: owner }); return expect(tx).to.revertWith(expectedError); }); it('should revert if assetData is not padded to 32 bytes (excluding the id)', async () => { - await assetProxyDispatcher.registerAssetProxy.awaitTransactionSuccessAsync(erc20Proxy.address, { + await assetProxyDispatcher.registerAssetProxy(erc20Proxy.address).awaitTransactionSuccessAsync({ from: owner, }); // Shave off the last byte - const encodedAssetData = (await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address)).slice(0, 72); + const encodedAssetData = (await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync()).slice( + 0, + 72, + ); const amount = new BigNumber(1); const expectedError = new ExchangeRevertErrors.AssetProxyDispatchError( ExchangeRevertErrors.AssetProxyDispatchErrorCode.InvalidAssetDataLength, orderHash, encodedAssetData, ); - const tx = assetProxyDispatcher.dispatchTransferFrom.sendTransactionAsync( - orderHash, - encodedAssetData, - makerAddress, - takerAddress, - amount, - { from: owner }, - ); + const tx = assetProxyDispatcher + .dispatchTransferFrom(orderHash, encodedAssetData, makerAddress, takerAddress, amount) + .sendTransactionAsync({ from: owner }); return expect(tx).to.revertWith(expectedError); }); it('should revert with the reason provided by the AssetProxy when a transfer fails', async () => { - await assetProxyDispatcher.registerAssetProxy.awaitTransactionSuccessAsync(erc20Proxy.address, { + await assetProxyDispatcher.registerAssetProxy(erc20Proxy.address).awaitTransactionSuccessAsync({ from: owner, }); - await erc20TokenA.approve.awaitTransactionSuccessAsync(erc20Proxy.address, constants.ZERO_AMOUNT, { + await erc20TokenA.approve(erc20Proxy.address, constants.ZERO_AMOUNT).awaitTransactionSuccessAsync({ from: makerAddress, }); - const encodedAssetData = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); + const encodedAssetData = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); const amount = new BigNumber(1); const nestedError = new StringRevertError(RevertReason.TransferFailed).encode(); const expectedError = new ExchangeRevertErrors.AssetProxyTransferError( @@ -322,25 +300,20 @@ describe('AssetProxyDispatcher', () => { encodedAssetData, nestedError, ); - const tx = assetProxyDispatcher.dispatchTransferFrom.sendTransactionAsync( - orderHash, - encodedAssetData, - makerAddress, - takerAddress, - amount, - { from: owner }, - ); + const tx = assetProxyDispatcher + .dispatchTransferFrom(orderHash, encodedAssetData, makerAddress, takerAddress, amount) + .sendTransactionAsync({ from: owner }); return expect(tx).to.revertWith(expectedError); }); }); describe('simulateDispatchTransferFromCalls', () => { it('should revert with the information specific to the failed transfer', async () => { - await assetProxyDispatcher.registerAssetProxy.awaitTransactionSuccessAsync(erc20Proxy.address, { + await assetProxyDispatcher.registerAssetProxy(erc20Proxy.address).awaitTransactionSuccessAsync({ from: owner, }); - const assetDataA = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); - const assetDataB = await devUtils.encodeERC20AssetData.callAsync(erc20TokenB.address); - await erc20TokenB.approve.awaitTransactionSuccessAsync(erc20Proxy.address, constants.ZERO_AMOUNT, { + const assetDataA = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); + const assetDataB = await devUtils.encodeERC20AssetData(erc20TokenB.address).callAsync(); + await erc20TokenB.approve(erc20Proxy.address, constants.ZERO_AMOUNT).awaitTransactionSuccessAsync({ from: makerAddress, }); const transferIndexAsBytes32 = '0x0000000000000000000000000000000000000000000000000000000000000001'; @@ -350,59 +323,67 @@ describe('AssetProxyDispatcher', () => { assetDataB, nestedError, ); - const tx = assetProxyDispatcher.simulateDispatchTransferFromCalls.sendTransactionAsync( - [assetDataA, assetDataB], - [makerAddress, makerAddress], - [takerAddress, takerAddress], - [new BigNumber(1), new BigNumber(1)], - ); + const tx = assetProxyDispatcher + .simulateDispatchTransferFromCalls( + [assetDataA, assetDataB], + [makerAddress, makerAddress], + [takerAddress, takerAddress], + [new BigNumber(1), new BigNumber(1)], + ) + .sendTransactionAsync(); return expect(tx).to.revertWith(expectedError); }); it('should forward the revert reason from the underlying failed transfer', async () => { - const assetDataA = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); - const assetDataB = await devUtils.encodeERC20AssetData.callAsync(erc20TokenB.address); + const assetDataA = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); + const assetDataB = await devUtils.encodeERC20AssetData(erc20TokenB.address).callAsync(); const transferIndexAsBytes32 = '0x0000000000000000000000000000000000000000000000000000000000000000'; const expectedError = new ExchangeRevertErrors.AssetProxyDispatchError( ExchangeRevertErrors.AssetProxyDispatchErrorCode.UnknownAssetProxy, transferIndexAsBytes32, assetDataA, ); - const tx = assetProxyDispatcher.simulateDispatchTransferFromCalls.sendTransactionAsync( - [assetDataA, assetDataB], - [makerAddress, makerAddress], - [takerAddress, takerAddress], - [new BigNumber(1), new BigNumber(1)], - ); + const tx = assetProxyDispatcher + .simulateDispatchTransferFromCalls( + [assetDataA, assetDataB], + [makerAddress, makerAddress], + [takerAddress, takerAddress], + [new BigNumber(1), new BigNumber(1)], + ) + .sendTransactionAsync(); return expect(tx).to.revertWith(expectedError); }); it('should revert with TRANSFERS_SUCCESSFUL if no transfers fail', async () => { - await assetProxyDispatcher.registerAssetProxy.awaitTransactionSuccessAsync(erc20Proxy.address, { + await assetProxyDispatcher.registerAssetProxy(erc20Proxy.address).awaitTransactionSuccessAsync({ from: owner, }); - const assetDataA = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); - const assetDataB = await devUtils.encodeERC20AssetData.callAsync(erc20TokenB.address); - const tx = assetProxyDispatcher.simulateDispatchTransferFromCalls.sendTransactionAsync( - [assetDataA, assetDataB], - [makerAddress, makerAddress], - [takerAddress, takerAddress], - [new BigNumber(1), new BigNumber(1)], - ); + const assetDataA = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); + const assetDataB = await devUtils.encodeERC20AssetData(erc20TokenB.address).callAsync(); + const tx = assetProxyDispatcher + .simulateDispatchTransferFromCalls( + [assetDataA, assetDataB], + [makerAddress, makerAddress], + [takerAddress, takerAddress], + [new BigNumber(1), new BigNumber(1)], + ) + .sendTransactionAsync(); return expect(tx).to.revertWith(RevertReason.TransfersSuccessful); }); it('should not modify balances if all transfers are successful', async () => { - await assetProxyDispatcher.registerAssetProxy.awaitTransactionSuccessAsync(erc20Proxy.address, { + await assetProxyDispatcher.registerAssetProxy(erc20Proxy.address).awaitTransactionSuccessAsync({ from: owner, }); - const assetDataA = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); - const assetDataB = await devUtils.encodeERC20AssetData.callAsync(erc20TokenB.address); + const assetDataA = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); + const assetDataB = await devUtils.encodeERC20AssetData(erc20TokenB.address).callAsync(); const balances = await erc20Wrapper.getBalancesAsync(); try { - await assetProxyDispatcher.simulateDispatchTransferFromCalls.awaitTransactionSuccessAsync( - [assetDataA, assetDataB], - [makerAddress, makerAddress], - [takerAddress, takerAddress], - [new BigNumber(1), new BigNumber(1)], - ); + await assetProxyDispatcher + .simulateDispatchTransferFromCalls( + [assetDataA, assetDataB], + [makerAddress, makerAddress], + [takerAddress, takerAddress], + [new BigNumber(1), new BigNumber(1)], + ) + .awaitTransactionSuccessAsync(); } catch (err) { const newBalances = await erc20Wrapper.getBalancesAsync(); expect(newBalances).to.deep.equal(balances); diff --git a/contracts/exchange/test/internal.ts b/contracts/exchange/test/internal.ts index 9713714774..8507b35937 100644 --- a/contracts/exchange/test/internal.ts +++ b/contracts/exchange/test/internal.ts @@ -1,5 +1,5 @@ import { ReferenceFunctions as LibReferenceFunctions } from '@0x/contracts-exchange-libs'; -import { blockchainTests, constants, expect, hexRandom, LogDecoder } from '@0x/contracts-test-utils'; +import { blockchainTests, constants, expect, hexRandom } from '@0x/contracts-test-utils'; import { ExchangeRevertErrors, orderHashUtils } from '@0x/order-utils'; import { Order } from '@0x/types'; import { BigNumber, SafeMathRevertErrors } from '@0x/utils'; @@ -21,7 +21,6 @@ blockchainTests('Exchange core internal functions', env => { const randomHash = () => hexRandom(constants.WORD_LENGTH); const randomAssetData = () => hexRandom(36); let testExchange: TestExchangeInternalsContract; - let logDecoder: LogDecoder; let senderAddress: string; const DEFAULT_PROTOCOL_MULTIPLIER = new BigNumber(150000); const DEFAULT_GAS_PRICE = new BigNumber(200000); @@ -37,7 +36,6 @@ blockchainTests('Exchange core internal functions', env => { {}, new BigNumber(CHAIN_ID), ); - logDecoder = new LogDecoder(env.web3Wrapper, artifacts); }); blockchainTests('assertValidMatch', () => { @@ -82,7 +80,9 @@ blockchainTests('Exchange core internal functions', env => { leftOrder.makerAssetAmount, rightOrder.makerAssetAmount, ); - return expect(testExchange.assertValidMatch.callAsync(leftOrder, rightOrder)).to.revertWith(expectedError); + return expect(testExchange.assertValidMatch(leftOrder, rightOrder).callAsync()).to.revertWith( + expectedError, + ); }); it('should revert if the taker asset multiplication should overflow', async () => { @@ -99,7 +99,9 @@ blockchainTests('Exchange core internal functions', env => { leftOrder.takerAssetAmount, rightOrder.takerAssetAmount, ); - return expect(testExchange.assertValidMatch.callAsync(leftOrder, rightOrder)).to.revertWith(expectedError); + return expect(testExchange.assertValidMatch(leftOrder, rightOrder).callAsync()).to.revertWith( + expectedError, + ); }); it('should revert if the prices of the left order is less than the price of the right order', async () => { @@ -114,7 +116,9 @@ blockchainTests('Exchange core internal functions', env => { const orderHashHexLeft = orderHashUtils.getOrderHashHex(leftOrder); const orderHashHexRight = orderHashUtils.getOrderHashHex(rightOrder); const expectedError = new ExchangeRevertErrors.NegativeSpreadError(orderHashHexLeft, orderHashHexRight); - return expect(testExchange.assertValidMatch.callAsync(leftOrder, rightOrder)).to.revertWith(expectedError); + return expect(testExchange.assertValidMatch(leftOrder, rightOrder).callAsync()).to.revertWith( + expectedError, + ); }); it('should succeed if the prices of the left and right orders are equal', async () => { @@ -126,7 +130,7 @@ blockchainTests('Exchange core internal functions', env => { makerAssetAmount: Web3Wrapper.toBaseUnitAmount(100, 18), takerAssetAmount: Web3Wrapper.toBaseUnitAmount(50, 18), }); - return expect(testExchange.assertValidMatch.callAsync(leftOrder, rightOrder)).to.be.fulfilled(''); + return expect(testExchange.assertValidMatch(leftOrder, rightOrder).callAsync()).to.be.fulfilled(''); }); it('should succeed if the price of the left order is higher than the price of the right', async () => { @@ -138,7 +142,7 @@ blockchainTests('Exchange core internal functions', env => { makerAssetAmount: Web3Wrapper.toBaseUnitAmount(100, 18), takerAssetAmount: Web3Wrapper.toBaseUnitAmount(50, 18), }); - return expect(testExchange.assertValidMatch.callAsync(leftOrder, rightOrder)).to.be.fulfilled(''); + return expect(testExchange.assertValidMatch(leftOrder, rightOrder).callAsync()).to.be.fulfilled(''); }); }); @@ -185,17 +189,12 @@ blockchainTests('Exchange core internal functions', env => { // CAll `testUpdateFilledState()`, which will set the `filled` // state for this order to `orderTakerAssetFilledAmount` before // calling `_updateFilledState()`. - const receipt = await logDecoder.getTxWithDecodedLogsAsync( - await testExchange.testUpdateFilledState.sendTransactionAsync( - order, - takerAddress, - orderHash, - orderTakerAssetFilledAmount, - fillResults, - ), - ); + const receipt = await testExchange + .testUpdateFilledState(order, takerAddress, orderHash, orderTakerAssetFilledAmount, fillResults) + .awaitTransactionSuccessAsync(); + // Grab the new `filled` state for this order. - const actualFilledState = await testExchange.filled.callAsync(orderHash); + const actualFilledState = await testExchange.filled(orderHash).callAsync(); // Assert the `filled` state for this order. expect(actualFilledState).to.bignumber.eq(expectedFilledState); // Assert the logs. @@ -247,13 +246,15 @@ blockchainTests('Exchange core internal functions', env => { takerAssetFillAmount, ); return expect( - testExchange.testUpdateFilledState.awaitTransactionSuccessAsync( - order, - randomAddress(), - randomHash(), - orderTakerAssetFilledAmount, - fillResults, - ), + testExchange + .testUpdateFilledState( + order, + randomAddress(), + randomHash(), + orderTakerAssetFilledAmount, + fillResults, + ) + .awaitTransactionSuccessAsync(), ).to.revertWith(expectedError); }); }); @@ -287,9 +288,9 @@ blockchainTests('Exchange core internal functions', env => { takerFeePaid: ONE_ETHER.times(0.025), protocolFeePaid: constants.ZERO_AMOUNT, }; - const receipt = await logDecoder.getTxWithDecodedLogsAsync( - await testExchange.settleOrder.sendTransactionAsync(orderHash, order, takerAddress, fillResults), - ); + const receipt = await testExchange + .settleOrder(orderHash, order, takerAddress, fillResults) + .awaitTransactionSuccessAsync(); const logs = receipt.logs as Array< LogWithDecodedArgs >; @@ -380,14 +381,16 @@ blockchainTests('Exchange core internal functions', env => { ); // Ensure that the call to `settleMatchOrders()` fails with the expected error. - const tx = testExchange.settleMatchOrders.sendTransactionAsync( - leftOrderHash, - rightOrderHash, - leftOrder, - rightOrder, - takerAddress, - matchedFillResults, - ); + const tx = testExchange + .settleMatchOrders( + leftOrderHash, + rightOrderHash, + leftOrder, + rightOrder, + takerAddress, + matchedFillResults, + ) + .sendTransactionAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -419,14 +422,16 @@ blockchainTests('Exchange core internal functions', env => { // The call to `settleMatchOrders()` should be successful. return expect( - testExchange.settleMatchOrders.sendTransactionAsync( - leftOrderHash, - rightOrderHash, - leftOrder, - rightOrder, - takerAddress, - matchedFillResults, - ), + testExchange + .settleMatchOrders( + leftOrderHash, + rightOrderHash, + leftOrder, + rightOrder, + takerAddress, + matchedFillResults, + ) + .sendTransactionAsync(), ).to.be.fulfilled(''); }); @@ -460,16 +465,16 @@ blockchainTests('Exchange core internal functions', env => { rightOrder.takerFeeAssetData = leftOrder.takerFeeAssetData; // Call settleMatchOrders and collect the logs - const receipt = await logDecoder.getTxWithDecodedLogsAsync( - await testExchange.settleMatchOrders.sendTransactionAsync( + const receipt = await testExchange + .settleMatchOrders( leftOrderHash, rightOrderHash, leftOrder, rightOrder, takerAddress, matchedFillResults, - ), - ); + ) + .awaitTransactionSuccessAsync(); const logs = receipt.logs as Array< LogWithDecodedArgs >; @@ -554,16 +559,16 @@ blockchainTests('Exchange core internal functions', env => { }; // Call settleMatchOrders and collect the logs - const receipt = await logDecoder.getTxWithDecodedLogsAsync( - await testExchange.settleMatchOrders.sendTransactionAsync( + const receipt = await testExchange + .settleMatchOrders( leftOrderHash, rightOrderHash, leftOrder, rightOrder, takerAddress, matchedFillResults, - ), - ); + ) + .awaitTransactionSuccessAsync(); const logs = receipt.logs as Array< LogWithDecodedArgs >; diff --git a/contracts/exchange/test/match_orders.ts b/contracts/exchange/test/match_orders.ts index e05aad4316..4065704366 100644 --- a/contracts/exchange/test/match_orders.ts +++ b/contracts/exchange/test/match_orders.ts @@ -143,28 +143,28 @@ describe('matchOrders', () => { await exchangeWrapper.registerAssetProxyAsync(erc1155Proxy.address, owner); await exchangeWrapper.registerAssetProxyAsync(multiAssetProxyContract.address, owner); // Authorize proxies. - await erc20Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(exchange.address, { from: owner }); - await erc721Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(exchange.address, { from: owner }); - await erc1155Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(exchange.address, { from: owner }); - await multiAssetProxyContract.addAuthorizedAddress.awaitTransactionSuccessAsync(exchange.address, { + await erc20Proxy.addAuthorizedAddress(exchange.address).awaitTransactionSuccessAsync({ from: owner }); + await erc721Proxy.addAuthorizedAddress(exchange.address).awaitTransactionSuccessAsync({ from: owner }); + await erc1155Proxy.addAuthorizedAddress(exchange.address).awaitTransactionSuccessAsync({ from: owner }); + await multiAssetProxyContract.addAuthorizedAddress(exchange.address).awaitTransactionSuccessAsync({ from: owner, }); - await erc20Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(multiAssetProxyContract.address, { + await erc20Proxy.addAuthorizedAddress(multiAssetProxyContract.address).awaitTransactionSuccessAsync({ from: owner, }); - await erc721Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(multiAssetProxyContract.address, { + await erc721Proxy.addAuthorizedAddress(multiAssetProxyContract.address).awaitTransactionSuccessAsync({ from: owner, }); - await erc1155Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(multiAssetProxyContract.address, { + await erc1155Proxy.addAuthorizedAddress(multiAssetProxyContract.address).awaitTransactionSuccessAsync({ from: owner, }); - await multiAssetProxyContract.registerAssetProxy.awaitTransactionSuccessAsync(erc20Proxy.address, { + await multiAssetProxyContract.registerAssetProxy(erc20Proxy.address).awaitTransactionSuccessAsync({ from: owner, }); - await multiAssetProxyContract.registerAssetProxy.awaitTransactionSuccessAsync(erc721Proxy.address, { + await multiAssetProxyContract.registerAssetProxy(erc721Proxy.address).awaitTransactionSuccessAsync({ from: owner, }); - await multiAssetProxyContract.registerAssetProxy.awaitTransactionSuccessAsync(erc1155Proxy.address, { + await multiAssetProxyContract.registerAssetProxy(erc1155Proxy.address).awaitTransactionSuccessAsync({ from: owner, }); @@ -179,10 +179,10 @@ describe('matchOrders', () => { const defaultOrderParamsLeft = { ...constants.STATIC_ORDER_PARAMS, makerAddress: makerAddressLeft, - makerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultERC20MakerAssetAddress), - takerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultERC20TakerAssetAddress), - makerFeeAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultFeeTokenAddress), - takerFeeAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultFeeTokenAddress), + makerAssetData: await devUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress).callAsync(), + takerAssetData: await devUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress).callAsync(), + makerFeeAssetData: await devUtils.encodeERC20AssetData(defaultFeeTokenAddress).callAsync(), + takerFeeAssetData: await devUtils.encodeERC20AssetData(defaultFeeTokenAddress).callAsync(), feeRecipientAddress: feeRecipientAddressLeft, exchangeAddress: exchange.address, chainId, @@ -190,10 +190,10 @@ describe('matchOrders', () => { const defaultOrderParamsRight = { ...constants.STATIC_ORDER_PARAMS, makerAddress: makerAddressRight, - makerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultERC20TakerAssetAddress), - takerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultERC20MakerAssetAddress), - makerFeeAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultFeeTokenAddress), - takerFeeAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultFeeTokenAddress), + makerAssetData: await devUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress).callAsync(), + takerAssetData: await devUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress).callAsync(), + makerFeeAssetData: await devUtils.encodeERC20AssetData(defaultFeeTokenAddress).callAsync(), + takerFeeAssetData: await devUtils.encodeERC20AssetData(defaultFeeTokenAddress).callAsync(), feeRecipientAddress: feeRecipientAddressRight, exchangeAddress: exchange.address, chainId, @@ -346,8 +346,8 @@ describe('matchOrders', () => { }); const signedOrderRight = await orderFactoryRight.newSignedOrderAsync({ makerAddress: makerAddressRight, - makerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultERC20TakerAssetAddress), - takerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultERC20MakerAssetAddress), + makerAssetData: await devUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress).callAsync(), + takerAssetData: await devUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress).callAsync(), makerAssetAmount: Web3Wrapper.toBaseUnitAmount(83, 0), takerAssetAmount: Web3Wrapper.toBaseUnitAmount(49, 0), feeRecipientAddress: feeRecipientAddressRight, @@ -400,8 +400,8 @@ describe('matchOrders', () => { }); const signedOrderRight = await orderFactoryRight.newSignedOrderAsync({ makerAddress: makerAddressRight, - makerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultERC20TakerAssetAddress), - takerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultERC20MakerAssetAddress), + makerAssetData: await devUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress).callAsync(), + takerAssetData: await devUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress).callAsync(), makerAssetAmount: Web3Wrapper.toBaseUnitAmount(89, 0), takerAssetAmount: Web3Wrapper.toBaseUnitAmount(1, 0), feeRecipientAddress: feeRecipientAddressRight, @@ -451,8 +451,8 @@ describe('matchOrders', () => { }); const signedOrderRight = await orderFactoryRight.newSignedOrderAsync({ makerAddress: makerAddressRight, - makerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultERC20TakerAssetAddress), - takerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultERC20MakerAssetAddress), + makerAssetData: await devUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress).callAsync(), + takerAssetData: await devUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress).callAsync(), makerAssetAmount: Web3Wrapper.toBaseUnitAmount(83, 0), takerAssetAmount: Web3Wrapper.toBaseUnitAmount(49, 0), feeRecipientAddress: feeRecipientAddressRight, @@ -500,8 +500,8 @@ describe('matchOrders', () => { }); const signedOrderRight = await orderFactoryRight.newSignedOrderAsync({ makerAddress: makerAddressRight, - makerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultERC20TakerAssetAddress), - takerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultERC20MakerAssetAddress), + makerAssetData: await devUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress).callAsync(), + takerAssetData: await devUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress).callAsync(), makerAssetAmount: Web3Wrapper.toBaseUnitAmount(89, 0), takerAssetAmount: Web3Wrapper.toBaseUnitAmount(1, 0), feeRecipientAddress: feeRecipientAddressRight, @@ -545,8 +545,8 @@ describe('matchOrders', () => { }); const signedOrderRight = await orderFactoryRight.newSignedOrderAsync({ makerAddress: makerAddressRight, - makerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultERC20TakerAssetAddress), - takerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultERC20MakerAssetAddress), + makerAssetData: await devUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress).callAsync(), + takerAssetData: await devUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress).callAsync(), makerAssetAmount: Web3Wrapper.toBaseUnitAmount(2126, 0), takerAssetAmount: Web3Wrapper.toBaseUnitAmount(1063, 0), feeRecipientAddress: feeRecipientAddressRight, @@ -1170,7 +1170,7 @@ describe('matchOrders', () => { const signedOrderLeft = await orderFactoryLeft.newSignedOrderAsync({ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(5, 18), takerAssetAmount: Web3Wrapper.toBaseUnitAmount(10, 18), - makerFeeAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultERC20TakerAssetAddress), + makerFeeAssetData: await devUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress).callAsync(), feeRecipientAddress: makerAddressLeft, }); const signedOrderRight = await orderFactoryRight.newSignedOrderAsync({ @@ -1267,7 +1267,7 @@ describe('matchOrders', () => { takerAssetAmount: Web3Wrapper.toBaseUnitAmount(10, 18), }); const signedOrderRight = await orderFactoryRight.newSignedOrderAsync({ - takerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultERC20TakerAssetAddress), + takerAssetData: await devUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress).callAsync(), makerAssetAmount: Web3Wrapper.toBaseUnitAmount(10, 18), takerAssetAmount: Web3Wrapper.toBaseUnitAmount(2, 18), }); @@ -1294,7 +1294,7 @@ describe('matchOrders', () => { it('should revert if the right maker asset is not equal to the left taker asset', async () => { // Create orders to match const signedOrderLeft = await orderFactoryLeft.newSignedOrderAsync({ - takerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultERC20MakerAssetAddress), + takerAssetData: await devUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress).callAsync(), makerAssetAmount: Web3Wrapper.toBaseUnitAmount(5, 18), takerAssetAmount: Web3Wrapper.toBaseUnitAmount(10, 18), }); @@ -1448,8 +1448,8 @@ describe('matchOrders', () => { }); const signedOrderRight = await orderFactoryRight.newSignedOrderAsync({ makerAddress: makerAddressRight, - makerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultERC20TakerAssetAddress), - takerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultERC20MakerAssetAddress), + makerAssetData: await devUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress).callAsync(), + takerAssetData: await devUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress).callAsync(), makerAssetAmount: Web3Wrapper.toBaseUnitAmount(87, 0), takerAssetAmount: Web3Wrapper.toBaseUnitAmount(48, 0), feeRecipientAddress: feeRecipientAddressRight, @@ -1536,8 +1536,8 @@ describe('matchOrders', () => { }); const signedOrderRight = await orderFactoryRight.newSignedOrderAsync({ makerAddress: makerAddressRight, - makerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultERC20TakerAssetAddress), - takerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultERC20MakerAssetAddress), + makerAssetData: await devUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress).callAsync(), + takerAssetData: await devUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress).callAsync(), makerAssetAmount: Web3Wrapper.toBaseUnitAmount(89, 0), takerAssetAmount: Web3Wrapper.toBaseUnitAmount(1, 0), feeRecipientAddress: feeRecipientAddressRight, @@ -1587,8 +1587,8 @@ describe('matchOrders', () => { }); const signedOrderRight = await orderFactoryRight.newSignedOrderAsync({ makerAddress: makerAddressRight, - makerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultERC20TakerAssetAddress), - takerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultERC20MakerAssetAddress), + makerAssetData: await devUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress).callAsync(), + takerAssetData: await devUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress).callAsync(), makerAssetAmount: Web3Wrapper.toBaseUnitAmount(87, 0), takerAssetAmount: Web3Wrapper.toBaseUnitAmount(48, 0), feeRecipientAddress: feeRecipientAddressRight, @@ -1633,8 +1633,8 @@ describe('matchOrders', () => { }); const signedOrderRight = await orderFactoryRight.newSignedOrderAsync({ makerAddress: makerAddressRight, - makerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultERC20TakerAssetAddress), - takerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultERC20MakerAssetAddress), + makerAssetData: await devUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress).callAsync(), + takerAssetData: await devUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress).callAsync(), makerAssetAmount: Web3Wrapper.toBaseUnitAmount(89, 0), takerAssetAmount: Web3Wrapper.toBaseUnitAmount(1, 0), feeRecipientAddress: feeRecipientAddressRight, @@ -1678,8 +1678,8 @@ describe('matchOrders', () => { }); const signedOrderRight = await orderFactoryRight.newSignedOrderAsync({ makerAddress: makerAddressRight, - makerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultERC20TakerAssetAddress), - takerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultERC20MakerAssetAddress), + makerAssetData: await devUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress).callAsync(), + takerAssetData: await devUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress).callAsync(), makerAssetAmount: Web3Wrapper.toBaseUnitAmount(89, 0), takerAssetAmount: Web3Wrapper.toBaseUnitAmount(1, 0), feeRecipientAddress: feeRecipientAddressRight, @@ -1797,8 +1797,8 @@ describe('matchOrders', () => { }); const signedOrderRight = await orderFactoryRight.newSignedOrderAsync({ makerAddress: makerAddressRight, - makerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultERC20TakerAssetAddress), - takerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultERC20MakerAssetAddress), + makerAssetData: await devUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress).callAsync(), + takerAssetData: await devUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress).callAsync(), makerAssetAmount: Web3Wrapper.toBaseUnitAmount(2126, 0), takerAssetAmount: Web3Wrapper.toBaseUnitAmount(1063, 0), feeRecipientAddress: feeRecipientAddressRight, @@ -2251,7 +2251,7 @@ describe('matchOrders', () => { const signedOrderLeft = await orderFactoryLeft.newSignedOrderAsync({ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(5, 18), takerAssetAmount: Web3Wrapper.toBaseUnitAmount(10, 18), - makerFeeAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultERC20TakerAssetAddress), + makerFeeAssetData: await devUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress).callAsync(), feeRecipientAddress: makerAddressLeft, }); const signedOrderRight = await orderFactoryRight.newSignedOrderAsync({ @@ -2348,7 +2348,7 @@ describe('matchOrders', () => { takerAssetAmount: Web3Wrapper.toBaseUnitAmount(10, 18), }); const signedOrderRight = await orderFactoryRight.newSignedOrderAsync({ - takerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultERC20TakerAssetAddress), + takerAssetData: await devUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress).callAsync(), makerAssetAmount: Web3Wrapper.toBaseUnitAmount(10, 18), takerAssetAmount: Web3Wrapper.toBaseUnitAmount(2, 18), }); @@ -2375,7 +2375,7 @@ describe('matchOrders', () => { it('should revert if the right maker asset is not equal to the left taker asset', async () => { // Create orders to match const signedOrderLeft = await orderFactoryLeft.newSignedOrderAsync({ - takerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultERC20MakerAssetAddress), + takerAssetData: await devUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress).callAsync(), makerAssetAmount: Web3Wrapper.toBaseUnitAmount(5, 18), takerAssetAmount: Web3Wrapper.toBaseUnitAmount(10, 18), }); @@ -2684,29 +2684,29 @@ describe('matchOrders', () => { let nameToMultiAssetAsset: { [name: string]: [BigNumber[], string[]] }; async function getAssetDataAsync(assetType: AssetType): Promise { - const encodeERC20AssetData = await devUtils.encodeERC20AssetData.callAsync; - const encodeERC721AssetData = await devUtils.encodeERC721AssetData.callAsync; - const encodeERC1155AssetData = await devUtils.encodeERC1155AssetData.callAsync; - const encodeMultiAssetData = await devUtils.encodeMultiAssetData.callAsync; if (nameToERC20Asset[assetType] !== undefined) { const tokenAddress = nameToERC20Asset[assetType]; - return encodeERC20AssetData(tokenAddress); + return devUtils.encodeERC20AssetData(tokenAddress).callAsync(); } if (nameToERC721Asset[assetType] !== undefined) { const [tokenAddress, tokenId] = nameToERC721Asset[assetType]; - return encodeERC721AssetData(tokenAddress, tokenId); + return devUtils.encodeERC721AssetData(tokenAddress, tokenId).callAsync(); } if (nameToERC1155FungibleAsset[assetType] !== undefined) { const [tokenAddress, tokenId] = nameToERC1155FungibleAsset[assetType]; - return encodeERC1155AssetData(tokenAddress, [tokenId], [ONE], constants.NULL_BYTES); + return devUtils + .encodeERC1155AssetData(tokenAddress, [tokenId], [ONE], constants.NULL_BYTES) + .callAsync(); } if (nameToERC1155NonFungibleAsset[assetType] !== undefined) { const [tokenAddress, tokenId] = nameToERC1155NonFungibleAsset[assetType]; - return encodeERC1155AssetData(tokenAddress, [tokenId], [ONE], constants.NULL_BYTES); + return devUtils + .encodeERC1155AssetData(tokenAddress, [tokenId], [ONE], constants.NULL_BYTES) + .callAsync(); } if (nameToMultiAssetAsset[assetType] !== undefined) { const [amounts, nestedAssetData] = nameToMultiAssetAsset[assetType]; - return encodeMultiAssetData(amounts, nestedAssetData); + return devUtils.encodeMultiAssetData(amounts, nestedAssetData).callAsync(); } throw new Error(`Unknown asset type: ${assetType}`); } @@ -2752,49 +2752,57 @@ describe('matchOrders', () => { MULTI_ASSET_A: [ [ONE, TWO], [ - await devUtils.encodeERC20AssetData.callAsync(erc20Tokens[0].address), - await devUtils.encodeERC1155AssetData.callAsync( - defaultERC1155AssetAddress, - [erc1155FungibleTokens[0]], - [ONE], - constants.NULL_BYTES, - ), + await devUtils.encodeERC20AssetData(erc20Tokens[0].address).callAsync(), + await devUtils + .encodeERC1155AssetData( + defaultERC1155AssetAddress, + [erc1155FungibleTokens[0]], + [ONE], + constants.NULL_BYTES, + ) + .callAsync(), ], ], MULTI_ASSET_B: [ [ONE, TWO], [ - await devUtils.encodeERC20AssetData.callAsync(erc20Tokens[1].address), - await devUtils.encodeERC1155AssetData.callAsync( - defaultERC1155AssetAddress, - [erc1155FungibleTokens[1]], - [ONE], - constants.NULL_BYTES, - ), + await devUtils.encodeERC20AssetData(erc20Tokens[1].address).callAsync(), + await devUtils + .encodeERC1155AssetData( + defaultERC1155AssetAddress, + [erc1155FungibleTokens[1]], + [ONE], + constants.NULL_BYTES, + ) + .callAsync(), ], ], MULTI_ASSET_C: [ [ONE, TWO], [ - await devUtils.encodeERC20AssetData.callAsync(erc20Tokens[2].address), - await devUtils.encodeERC1155AssetData.callAsync( - defaultERC1155AssetAddress, - [erc1155FungibleTokens[2]], - [ONE], - constants.NULL_BYTES, - ), + await devUtils.encodeERC20AssetData(erc20Tokens[2].address).callAsync(), + await devUtils + .encodeERC1155AssetData( + defaultERC1155AssetAddress, + [erc1155FungibleTokens[2]], + [ONE], + constants.NULL_BYTES, + ) + .callAsync(), ], ], MULTI_ASSET_D: [ [ONE, TWO], [ - await devUtils.encodeERC20AssetData.callAsync(erc20Tokens[3].address), - await devUtils.encodeERC1155AssetData.callAsync( - erc1155Token.address, - [erc1155FungibleTokens[3]], - [ONE], - constants.NULL_BYTES, - ), + await devUtils.encodeERC20AssetData(erc20Tokens[3].address).callAsync(), + await devUtils + .encodeERC1155AssetData( + erc1155Token.address, + [erc1155FungibleTokens[3]], + [ONE], + constants.NULL_BYTES, + ) + .callAsync(), ], ], }; diff --git a/contracts/exchange/test/protocol_fees.ts b/contracts/exchange/test/protocol_fees.ts index 5cba8686ff..3a46d392d7 100644 --- a/contracts/exchange/test/protocol_fees.ts +++ b/contracts/exchange/test/protocol_fees.ts @@ -31,244 +31,223 @@ blockchainTests('Protocol Fee Payments', env => { blockchainTests.resets('fillOrder Protocol Fees', () => { it('should not pay protocol fee when there is no registered protocol fee collector', async () => { - await testProtocolFeesReceiver.testFillOrderProtocolFees.awaitTransactionSuccessAsync( - testProtocolFees.address, - DEFAULT_PROTOCOL_FEE_MULTIPLIER, - false, - { + await testProtocolFeesReceiver + .testFillOrderProtocolFees(testProtocolFees.address, DEFAULT_PROTOCOL_FEE_MULTIPLIER, false) + .awaitTransactionSuccessAsync({ gasPrice: DEFAULT_GAS_PRICE, value: DEFAULT_PROTOCOL_FEE, - }, - ); + }); }); it('should not forward ETH when too little value is sent', async () => { - await testProtocolFeesReceiver.testFillOrderProtocolFees.awaitTransactionSuccessAsync( - testProtocolFees.address, - DEFAULT_PROTOCOL_FEE_MULTIPLIER, - true, - { + await testProtocolFeesReceiver + .testFillOrderProtocolFees(testProtocolFees.address, DEFAULT_PROTOCOL_FEE_MULTIPLIER, true) + .awaitTransactionSuccessAsync({ gasPrice: DEFAULT_GAS_PRICE, value: DEFAULT_PROTOCOL_FEE.minus(10), - }, - ); + }); }); it('should pay protocol fee in ETH when the correct value is sent', async () => { - await testProtocolFeesReceiver.testFillOrderProtocolFees.awaitTransactionSuccessAsync( - testProtocolFees.address, - DEFAULT_PROTOCOL_FEE_MULTIPLIER, - true, - { + await testProtocolFeesReceiver + .testFillOrderProtocolFees(testProtocolFees.address, DEFAULT_PROTOCOL_FEE_MULTIPLIER, true) + .awaitTransactionSuccessAsync({ gasPrice: DEFAULT_GAS_PRICE, value: DEFAULT_PROTOCOL_FEE, - }, - ); + }); }); it('should pay protocol fee in ETH when extra value is sent', async () => { - await testProtocolFeesReceiver.testFillOrderProtocolFees.awaitTransactionSuccessAsync( - testProtocolFees.address, - DEFAULT_PROTOCOL_FEE_MULTIPLIER, - true, - { + await testProtocolFeesReceiver + .testFillOrderProtocolFees(testProtocolFees.address, DEFAULT_PROTOCOL_FEE_MULTIPLIER, true) + .awaitTransactionSuccessAsync({ gasPrice: DEFAULT_GAS_PRICE, value: DEFAULT_PROTOCOL_FEE.plus(10), - }, - ); + }); }); }); blockchainTests.resets('matchOrders Protocol Fees', () => { it('should not pay protocol fee when there is no registered protocol fee collector', async () => { - await testProtocolFeesReceiver.testMatchOrdersProtocolFees.awaitTransactionSuccessAsync( - testProtocolFees.address, - DEFAULT_PROTOCOL_FEE_MULTIPLIER, - false, - { + await testProtocolFeesReceiver + .testMatchOrdersProtocolFees(testProtocolFees.address, DEFAULT_PROTOCOL_FEE_MULTIPLIER, false) + .awaitTransactionSuccessAsync({ gasPrice: DEFAULT_GAS_PRICE, value: DEFAULT_PROTOCOL_FEE, - }, - ); + }); }); it('should not forward ETH twice when too little value is sent', async () => { - await testProtocolFeesReceiver.testMatchOrdersProtocolFees.awaitTransactionSuccessAsync( - testProtocolFees.address, - DEFAULT_PROTOCOL_FEE_MULTIPLIER, - true, - { + await testProtocolFeesReceiver + .testMatchOrdersProtocolFees(testProtocolFees.address, DEFAULT_PROTOCOL_FEE_MULTIPLIER, true) + .awaitTransactionSuccessAsync({ gasPrice: DEFAULT_GAS_PRICE, value: DEFAULT_PROTOCOL_FEE.minus(10), - }, - ); + }); }); it('should pay protocol fee in ETH and then not forward ETH when exactly one protocol fee is sent', async () => { - await testProtocolFeesReceiver.testMatchOrdersProtocolFees.awaitTransactionSuccessAsync( - testProtocolFees.address, - DEFAULT_PROTOCOL_FEE_MULTIPLIER, - true, - { + await testProtocolFeesReceiver + .testMatchOrdersProtocolFees(testProtocolFees.address, DEFAULT_PROTOCOL_FEE_MULTIPLIER, true) + .awaitTransactionSuccessAsync({ gasPrice: DEFAULT_GAS_PRICE, value: DEFAULT_PROTOCOL_FEE, - }, - ); + }); }); it('should pay protocol fee in ETH and then not forward ETH when a bit more than one protocol fee is sent', async () => { - await testProtocolFeesReceiver.testMatchOrdersProtocolFees.awaitTransactionSuccessAsync( - testProtocolFees.address, - DEFAULT_PROTOCOL_FEE_MULTIPLIER, - true, - { + await testProtocolFeesReceiver + .testMatchOrdersProtocolFees(testProtocolFees.address, DEFAULT_PROTOCOL_FEE_MULTIPLIER, true) + .awaitTransactionSuccessAsync({ gasPrice: DEFAULT_GAS_PRICE, value: DEFAULT_PROTOCOL_FEE.plus(10), - }, - ); + }); }); it('should pay protocol fee in ETH when exactly double the protocol fee is sent', async () => { - await testProtocolFeesReceiver.testMatchOrdersProtocolFees.awaitTransactionSuccessAsync( - testProtocolFees.address, - DEFAULT_PROTOCOL_FEE_MULTIPLIER, - true, - { + await testProtocolFeesReceiver + .testMatchOrdersProtocolFees(testProtocolFees.address, DEFAULT_PROTOCOL_FEE_MULTIPLIER, true) + .awaitTransactionSuccessAsync({ gasPrice: DEFAULT_GAS_PRICE, value: DEFAULT_PROTOCOL_FEE.times(2), - }, - ); + }); }); it('should pay protocol fee in ETH when more than double the protocol fee is sent', async () => { - await testProtocolFeesReceiver.testMatchOrdersProtocolFees.awaitTransactionSuccessAsync( - testProtocolFees.address, - DEFAULT_PROTOCOL_FEE_MULTIPLIER, - true, - { + await testProtocolFeesReceiver + .testMatchOrdersProtocolFees(testProtocolFees.address, DEFAULT_PROTOCOL_FEE_MULTIPLIER, true) + .awaitTransactionSuccessAsync({ gasPrice: DEFAULT_GAS_PRICE, value: DEFAULT_PROTOCOL_FEE.times(2).plus(10), - }, - ); + }); }); }); blockchainTests.resets('batchFillOrder ProtocolFees', () => { it('should not pay protocol fees when there is not a protocolFeeCollector registered', async () => { - await testProtocolFeesReceiver.testBatchFillOrdersProtocolFees.awaitTransactionSuccessAsync( - testProtocolFees.address, - DEFAULT_PROTOCOL_FEE_MULTIPLIER, - new BigNumber(2), // If successful, create a `batchFillOrders` with 2 orders. - false, - { + await testProtocolFeesReceiver + .testBatchFillOrdersProtocolFees( + testProtocolFees.address, + DEFAULT_PROTOCOL_FEE_MULTIPLIER, + new BigNumber(2), // If successful, create a `batchFillOrders` with 2 orders. + false, + ) + .awaitTransactionSuccessAsync({ gasPrice: DEFAULT_GAS_PRICE, value: DEFAULT_PROTOCOL_FEE, - }, - ); + }); }); it('should not forward ETH when less than one protocol fee is sent and only one order is in the batch', async () => { - await testProtocolFeesReceiver.testBatchFillOrdersProtocolFees.awaitTransactionSuccessAsync( - testProtocolFees.address, - DEFAULT_PROTOCOL_FEE_MULTIPLIER, - new BigNumber(1), - true, - { + await testProtocolFeesReceiver + .testBatchFillOrdersProtocolFees( + testProtocolFees.address, + DEFAULT_PROTOCOL_FEE_MULTIPLIER, + new BigNumber(1), + true, + ) + .awaitTransactionSuccessAsync({ gasPrice: DEFAULT_GAS_PRICE, value: DEFAULT_PROTOCOL_FEE.minus(10), - }, - ); + }); }); it('should pay one protocol fee in ETH when the exact protocol fee is sent and only one order is in the batch', async () => { - await testProtocolFeesReceiver.testBatchFillOrdersProtocolFees.awaitTransactionSuccessAsync( - testProtocolFees.address, - DEFAULT_PROTOCOL_FEE_MULTIPLIER, - new BigNumber(1), - true, - { + await testProtocolFeesReceiver + .testBatchFillOrdersProtocolFees( + testProtocolFees.address, + DEFAULT_PROTOCOL_FEE_MULTIPLIER, + new BigNumber(1), + true, + ) + .awaitTransactionSuccessAsync({ gasPrice: DEFAULT_GAS_PRICE, value: DEFAULT_PROTOCOL_FEE, - }, - ); + }); }); it('should pay one protocol fee in ETH when more than the exact protocol fee is sent and only one order is in the batch', async () => { - await testProtocolFeesReceiver.testBatchFillOrdersProtocolFees.awaitTransactionSuccessAsync( - testProtocolFees.address, - DEFAULT_PROTOCOL_FEE_MULTIPLIER, - new BigNumber(1), - true, - { + await testProtocolFeesReceiver + .testBatchFillOrdersProtocolFees( + testProtocolFees.address, + DEFAULT_PROTOCOL_FEE_MULTIPLIER, + new BigNumber(1), + true, + ) + .awaitTransactionSuccessAsync({ gasPrice: DEFAULT_GAS_PRICE, value: DEFAULT_PROTOCOL_FEE.plus(10), - }, - ); + }); }); it('should not forward ETH twice when an insuffiecent amount of ETH for one protocol fee is sent', async () => { - await testProtocolFeesReceiver.testBatchFillOrdersProtocolFees.awaitTransactionSuccessAsync( - testProtocolFees.address, - DEFAULT_PROTOCOL_FEE_MULTIPLIER, - new BigNumber(2), - true, - { + await testProtocolFeesReceiver + .testBatchFillOrdersProtocolFees( + testProtocolFees.address, + DEFAULT_PROTOCOL_FEE_MULTIPLIER, + new BigNumber(2), + true, + ) + .awaitTransactionSuccessAsync({ gasPrice: DEFAULT_GAS_PRICE, value: DEFAULT_PROTOCOL_FEE.minus(10), - }, - ); + }); }); it('should pay a protocol in ETH and not forward ETH for the second when exactly one protocol fee in ETH is sent', async () => { - await testProtocolFeesReceiver.testBatchFillOrdersProtocolFees.awaitTransactionSuccessAsync( - testProtocolFees.address, - DEFAULT_PROTOCOL_FEE_MULTIPLIER, - new BigNumber(2), - true, - { + await testProtocolFeesReceiver + .testBatchFillOrdersProtocolFees( + testProtocolFees.address, + DEFAULT_PROTOCOL_FEE_MULTIPLIER, + new BigNumber(2), + true, + ) + .awaitTransactionSuccessAsync({ gasPrice: DEFAULT_GAS_PRICE, value: DEFAULT_PROTOCOL_FEE, - }, - ); + }); }); it('should pay both protocol fees in ETH when exactly two protocol fees in ETH is sent', async () => { - await testProtocolFeesReceiver.testBatchFillOrdersProtocolFees.awaitTransactionSuccessAsync( - testProtocolFees.address, - DEFAULT_PROTOCOL_FEE_MULTIPLIER, - new BigNumber(2), - true, - { + await testProtocolFeesReceiver + .testBatchFillOrdersProtocolFees( + testProtocolFees.address, + DEFAULT_PROTOCOL_FEE_MULTIPLIER, + new BigNumber(2), + true, + ) + .awaitTransactionSuccessAsync({ gasPrice: DEFAULT_GAS_PRICE, value: DEFAULT_PROTOCOL_FEE.times(2), - }, - ); + }); }); it('should pay two protocol fees in ETH and then not forward ETH for a third when exactly two protocol fees in ETH is sent', async () => { - await testProtocolFeesReceiver.testBatchFillOrdersProtocolFees.awaitTransactionSuccessAsync( - testProtocolFees.address, - DEFAULT_PROTOCOL_FEE_MULTIPLIER, - new BigNumber(3), - true, - { + await testProtocolFeesReceiver + .testBatchFillOrdersProtocolFees( + testProtocolFees.address, + DEFAULT_PROTOCOL_FEE_MULTIPLIER, + new BigNumber(3), + true, + ) + .awaitTransactionSuccessAsync({ gasPrice: DEFAULT_GAS_PRICE, value: DEFAULT_PROTOCOL_FEE.times(2), - }, - ); + }); }); it('should pay three protocol fees in ETH when more than three protocol fees in ETH is sent', async () => { - await testProtocolFeesReceiver.testBatchFillOrdersProtocolFees.awaitTransactionSuccessAsync( - testProtocolFees.address, - DEFAULT_PROTOCOL_FEE_MULTIPLIER, - new BigNumber(3), - true, - { + await testProtocolFeesReceiver + .testBatchFillOrdersProtocolFees( + testProtocolFees.address, + DEFAULT_PROTOCOL_FEE_MULTIPLIER, + new BigNumber(3), + true, + ) + .awaitTransactionSuccessAsync({ gasPrice: DEFAULT_GAS_PRICE, value: DEFAULT_PROTOCOL_FEE.times(3).plus(10), - }, - ); + }); }); }); }); diff --git a/contracts/exchange/test/protocol_fees_manager.ts b/contracts/exchange/test/protocol_fees_manager.ts index 010fe122c6..54bc8273b0 100644 --- a/contracts/exchange/test/protocol_fees_manager.ts +++ b/contracts/exchange/test/protocol_fees_manager.ts @@ -43,7 +43,7 @@ blockchainTests.resets('MixinProtocolFees', env => { const expectedError = new OwnableRevertErrors.OnlyOwnerError(nonOwner, owner); // Ensure that the transaction reverts with the expected rich error. - const tx = exchange.setProtocolFeeCollectorAddress.sendTransactionAsync(protocolFeeCollector, { + const tx = exchange.setProtocolFeeCollectorAddress(protocolFeeCollector).sendTransactionAsync({ from: nonOwner, }); return expect(tx).to.revertWith(expectedError); @@ -51,15 +51,14 @@ blockchainTests.resets('MixinProtocolFees', env => { it('should succeed and emit an ProtocolFeeMultiplier event if msg.sender == owner', async () => { // Call the `setProtocolFeeMultiplier()` function and get the receipt. - const receipt = await exchange.setProtocolFeeMultiplier.awaitTransactionSuccessAsync( - protocolFeeMultiplier, - { + const receipt = await exchange + .setProtocolFeeMultiplier(protocolFeeMultiplier) + .awaitTransactionSuccessAsync({ from: owner, - }, - ); + }); // Verify that the protocolFeeCollector address was actually updated to the correct address. - const updated = await exchange.protocolFeeMultiplier.callAsync(); + const updated = await exchange.protocolFeeMultiplier().callAsync(); expect(updated).bignumber.to.be.eq(protocolFeeMultiplier); // Ensure that the correct `ProtocolFeeCollectorAddress` event was logged. @@ -76,7 +75,7 @@ blockchainTests.resets('MixinProtocolFees', env => { const expectedError = new OwnableRevertErrors.OnlyOwnerError(nonOwner, owner); // Ensure that the transaction reverts with the expected rich error. - const tx = exchange.setProtocolFeeCollectorAddress.sendTransactionAsync(protocolFeeCollector, { + const tx = exchange.setProtocolFeeCollectorAddress(protocolFeeCollector).sendTransactionAsync({ from: nonOwner, }); return expect(tx).to.revertWith(expectedError); @@ -84,15 +83,14 @@ blockchainTests.resets('MixinProtocolFees', env => { it('should succeed and emit an ProtocolFeeCollectorAddress event if msg.sender == owner', async () => { // Call the `setProtocolFeeCollectorAddress()` function and get the receipt. - const receipt = await exchange.setProtocolFeeCollectorAddress.awaitTransactionSuccessAsync( - protocolFeeCollector, - { + const receipt = await exchange + .setProtocolFeeCollectorAddress(protocolFeeCollector) + .awaitTransactionSuccessAsync({ from: owner, - }, - ); + }); // Verify that the protocolFeeCollector address was actually updated to the correct address. - const updated = await exchange.protocolFeeCollector.callAsync(); + const updated = await exchange.protocolFeeCollector().callAsync(); expect(updated).to.be.eq(protocolFeeCollector); // Ensure that the correct `UpdatedProtocolFeeCollectorAddress` event was logged. @@ -109,23 +107,23 @@ blockchainTests.resets('MixinProtocolFees', env => { const expectedError = new OwnableRevertErrors.OnlyOwnerError(nonOwner, owner); // Ensure that the transaction reverts with the expected rich error. - const tx = exchange.detachProtocolFeeCollector.sendTransactionAsync({ + const tx = exchange.detachProtocolFeeCollector().sendTransactionAsync({ from: nonOwner, }); return expect(tx).to.revertWith(expectedError); }); it('should succeed and emit an ProtocolFeeCollectorAddress event if msg.sender == owner', async () => { - await exchange.setProtocolFeeCollectorAddress.awaitTransactionSuccessAsync(protocolFeeCollector, { + await exchange.setProtocolFeeCollectorAddress(protocolFeeCollector).awaitTransactionSuccessAsync({ from: owner, }); - const receipt = await exchange.detachProtocolFeeCollector.awaitTransactionSuccessAsync({ + const receipt = await exchange.detachProtocolFeeCollector().awaitTransactionSuccessAsync({ from: owner, }); // Verify that the protocolFeeCollector address was actually updated to the correct address. - const updated = await exchange.protocolFeeCollector.callAsync(); + const updated = await exchange.protocolFeeCollector().callAsync(); expect(updated).to.be.eq(constants.NULL_ADDRESS); // Ensure that the correct `UpdatedProtocolFeeCollectorAddress` event was logged. diff --git a/contracts/exchange/test/reentrancy_tests.ts b/contracts/exchange/test/reentrancy_tests.ts index 593c8285f2..7a56dbc9bc 100644 --- a/contracts/exchange/test/reentrancy_tests.ts +++ b/contracts/exchange/test/reentrancy_tests.ts @@ -101,8 +101,8 @@ blockchainTests.resets('Reentrancy Tests', env => { for (const fn of NON_REENTRANT_FUNCTIONS) { it(`${fn.name}()`, async () => { const inputs = createFunctionInputs(fn.inputs); - const callData = (testerContract as any)[fn.name].getABIEncodedTransactionData(...inputs); - const isReentrant = await testerContract.isReentrant.callAsync(callData); + const callData = (testerContract as any)[fn.name](...inputs).getABIEncodedTransactionData(); + const isReentrant = await testerContract.isReentrant(callData).callAsync(); expect(isReentrant).to.be.false(); }); } @@ -112,8 +112,8 @@ blockchainTests.resets('Reentrancy Tests', env => { for (const fn of REENTRANT_FUNCTIONS) { it(`${fn.name}()`, async () => { const inputs = createFunctionInputs(fn.inputs); - const callData = (testerContract as any)[fn.name].getABIEncodedTransactionData(...inputs); - const isReentrant = await testerContract.isReentrant.callAsync(callData); + const callData = (testerContract as any)[fn.name](...inputs).getABIEncodedTransactionData(); + const isReentrant = await testerContract.isReentrant(callData).callAsync(); expect(isReentrant).to.be.true(); }); } diff --git a/contracts/exchange/test/signature_validator.ts b/contracts/exchange/test/signature_validator.ts index 33aec898fb..cecdb5386b 100644 --- a/contracts/exchange/test/signature_validator.ts +++ b/contracts/exchange/test/signature_validator.ts @@ -58,16 +58,14 @@ blockchainTests.resets('MixinSignatureValidator', env => { {}, signatureValidator.address, ); - validatorWalletRevertReason = await validatorWallet.REVERT_REASON.callAsync(); + validatorWalletRevertReason = await validatorWallet.REVERT_REASON().callAsync(); // Approve the validator for both signers. await Promise.all( [signerAddress, notSignerAddress].map(async (addr: string) => { - return signatureValidator.setSignatureValidatorApproval.awaitTransactionSuccessAsync( - validatorWallet.address, - true, - { from: addr }, - ); + return signatureValidator + .setSignatureValidatorApproval(validatorWallet.address, true) + .awaitTransactionSuccessAsync({ from: addr }); }), ); @@ -299,7 +297,7 @@ blockchainTests.resets('MixinSignatureValidator', env => { it('should return true when SignatureType=Presigned and signer has presigned hash', async () => { const hashHex = getCurrentHashHex(); // Presign the hash - await signatureValidator.preSign.awaitTransactionSuccessAsync(hashHex, { from: signerAddress }); + await signatureValidator.preSign(hashHex).awaitTransactionSuccessAsync({ from: signerAddress }); // Validate presigned signature const signatureHex = hexConcat(SignatureType.PreSigned); const isValidSignature = await validateAsync(hashHex, signerAddress, signatureHex); @@ -333,13 +331,11 @@ blockchainTests.resets('MixinSignatureValidator', env => { ? constants.NULL_BYTES : hashBytes(validatorExpectedSignatureHex); if (validatorAction !== undefined) { - await validatorWallet.prepare.awaitTransactionSuccessAsync( - _hashHex, - validatorAction, - expectedSignatureHashHex, - ); + await validatorWallet + .prepare(_hashHex, validatorAction, expectedSignatureHashHex) + .awaitTransactionSuccessAsync(); } - return signatureValidator.isValidHashSignature.callAsync(_hashHex, _signerAddress, signatureHex); + return signatureValidator.isValidHashSignature(_hashHex, _signerAddress, signatureHex).callAsync(); }; it('should revert when signerAddress == 0', async () => { @@ -388,11 +384,9 @@ blockchainTests.resets('MixinSignatureValidator', env => { const trezorSignatureType = ethUtil.toBuffer(`0x${SignatureType.EthSign}`); const signature = Buffer.concat([v, r, s, trezorSignatureType]); const signatureHex = ethUtil.bufferToHex(signature); - const isValidSignature = await signatureValidator.isValidHashSignature.callAsync( - messageHash, - signer, - signatureHex, - ); + const isValidSignature = await signatureValidator + .isValidHashSignature(messageHash, signer, signatureHex) + .callAsync(); expect(isValidSignature).to.be.true(); }); @@ -406,11 +400,9 @@ blockchainTests.resets('MixinSignatureValidator', env => { const trezorSignatureType = ethUtil.toBuffer(`0x${SignatureType.EthSign}`); const signature = Buffer.concat([v, r, s, trezorSignatureType]); const signatureHex = ethUtil.bufferToHex(signature); - const isValidSignature = await signatureValidator.isValidHashSignature.callAsync( - messageHash, - signer, - signatureHex, - ); + const isValidSignature = await signatureValidator + .isValidHashSignature(messageHash, signer, signatureHex) + .callAsync(); expect(isValidSignature).to.be.true(); }); @@ -427,10 +419,10 @@ blockchainTests.resets('MixinSignatureValidator', env => { ...constants.STATIC_ORDER_PARAMS, makerAddress, feeRecipientAddress: randomAddress(), - makerAssetData: await devUtils.encodeERC20AssetData.callAsync(randomAddress()), - takerAssetData: await devUtils.encodeERC20AssetData.callAsync(randomAddress()), - makerFeeAssetData: await devUtils.encodeERC20AssetData.callAsync(randomAddress()), - takerFeeAssetData: await devUtils.encodeERC20AssetData.callAsync(randomAddress()), + makerAssetData: await devUtils.encodeERC20AssetData(randomAddress()).callAsync(), + takerAssetData: await devUtils.encodeERC20AssetData(randomAddress()).callAsync(), + makerFeeAssetData: await devUtils.encodeERC20AssetData(randomAddress()).callAsync(), + takerFeeAssetData: await devUtils.encodeERC20AssetData(randomAddress()).callAsync(), makerFee: constants.ZERO_AMOUNT, takerFee: constants.ZERO_AMOUNT, exchangeAddress: signatureValidator.address, @@ -455,13 +447,11 @@ blockchainTests.resets('MixinSignatureValidator', env => { ? constants.NULL_BYTES : hashBytes(validatorExpectedSignatureHex); if (validatorAction !== undefined) { - await validatorWallet.prepare.awaitTransactionSuccessAsync( - orderHashHex, - validatorAction, - expectedSignatureHashHex, - ); + await validatorWallet + .prepare(orderHashHex, validatorAction, expectedSignatureHashHex) + .awaitTransactionSuccessAsync(); } - return signatureValidator.isValidOrderSignature.callAsync(order, signatureHex); + return signatureValidator.isValidOrderSignature(order, signatureHex).callAsync(); }; it('should revert when signerAddress == 0', async () => { @@ -477,7 +467,7 @@ blockchainTests.resets('MixinSignatureValidator', env => { constants.NULL_ADDRESS, signatureHex, ); - const tx = signatureValidator.isValidOrderSignature.callAsync(nullMakerOrder, signatureHex); + const tx = signatureValidator.isValidOrderSignature(nullMakerOrder, signatureHex).callAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -526,7 +516,7 @@ blockchainTests.resets('MixinSignatureValidator', env => { const signatureDataHex = generateRandomSignature(); const signatureHex = hexConcat(signatureDataHex, validatorWallet.address, SignatureType.Validator); const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder); - const data = eip1271Data.OrderWithHash.getABIEncodedTransactionData(signedOrder, orderHashHex); + const data = eip1271Data.OrderWithHash(signedOrder, orderHashHex).getABIEncodedTransactionData(); const expectedError = new ExchangeRevertErrors.EIP1271SignatureError( validatorWallet.address, data, @@ -543,7 +533,7 @@ blockchainTests.resets('MixinSignatureValidator', env => { const signatureDataHex = generateRandomSignature(); const signatureHex = hexConcat(signatureDataHex, validatorWallet.address, SignatureType.Validator); const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder); - const data = eip1271Data.OrderWithHash.getABIEncodedTransactionData(signedOrder, orderHashHex); + const data = eip1271Data.OrderWithHash(signedOrder, orderHashHex).getABIEncodedTransactionData(); const expectedError = new ExchangeRevertErrors.EIP1271SignatureError( validatorWallet.address, data, @@ -560,7 +550,7 @@ blockchainTests.resets('MixinSignatureValidator', env => { const signatureDataHex = generateRandomSignature(); const signatureHex = hexConcat(signatureDataHex, validatorWallet.address, SignatureType.Validator); const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder); - const data = eip1271Data.OrderWithHash.getABIEncodedTransactionData(signedOrder, orderHashHex); + const data = eip1271Data.OrderWithHash(signedOrder, orderHashHex).getABIEncodedTransactionData(); const expectedError = new ExchangeRevertErrors.EIP1271SignatureError( validatorWallet.address, data, @@ -573,11 +563,9 @@ blockchainTests.resets('MixinSignatureValidator', env => { it('should revert when SignatureType=Validator and signature is shorter than 21 bytes', async () => { // Set approval of signature validator to false - await signatureValidator.setSignatureValidatorApproval.awaitTransactionSuccessAsync( - validatorWallet.address, - false, - { from: signedOrder.makerAddress }, - ); + await signatureValidator + .setSignatureValidatorApproval(validatorWallet.address, false) + .awaitTransactionSuccessAsync({ from: signedOrder.makerAddress }); // Doesn't have to contain a real signature since our wallet contract // just does a hash comparison. const signatureHex = hexConcat(SignatureType.Validator); @@ -594,11 +582,9 @@ blockchainTests.resets('MixinSignatureValidator', env => { it('should revert when SignatureType=Validator, signature is valid and validator is not approved', async () => { // Set approval of signature validator to false - await signatureValidator.setSignatureValidatorApproval.awaitTransactionSuccessAsync( - validatorWallet.address, - false, - { from: signedOrder.makerAddress }, - ); + await signatureValidator + .setSignatureValidatorApproval(validatorWallet.address, false) + .awaitTransactionSuccessAsync({ from: signedOrder.makerAddress }); // Doesn't have to contain a real signature since our wallet contract // just does a hash comparison. const signatureDataHex = generateRandomSignature(); @@ -663,7 +649,7 @@ blockchainTests.resets('MixinSignatureValidator', env => { const signatureDataHex = generateRandomSignature(); const signatureHex = hexConcat(signatureDataHex, SignatureType.EIP1271Wallet); const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder); - const data = eip1271Data.OrderWithHash.getABIEncodedTransactionData(signedOrder, orderHashHex); + const data = eip1271Data.OrderWithHash(signedOrder, orderHashHex).getABIEncodedTransactionData(); const expectedError = new ExchangeRevertErrors.EIP1271SignatureError( validatorWallet.address, data, @@ -680,7 +666,7 @@ blockchainTests.resets('MixinSignatureValidator', env => { // just does a hash comparison. const signatureHex = hexConcat(generateRandomSignature(), SignatureType.EIP1271Wallet); const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder); - const data = eip1271Data.OrderWithHash.getABIEncodedTransactionData(signedOrder, orderHashHex); + const data = eip1271Data.OrderWithHash(signedOrder, orderHashHex).getABIEncodedTransactionData(); const expectedError = new ExchangeRevertErrors.EIP1271SignatureError( validatorWallet.address, data, @@ -695,7 +681,7 @@ blockchainTests.resets('MixinSignatureValidator', env => { signedOrder.makerAddress = validatorWallet.address; const signatureHex = hexConcat(SignatureType.EIP1271Wallet); const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder); - const data = eip1271Data.OrderWithHash.getABIEncodedTransactionData(signedOrder, orderHashHex); + const data = eip1271Data.OrderWithHash(signedOrder, orderHashHex).getABIEncodedTransactionData(); const expectedError = new ExchangeRevertErrors.EIP1271SignatureError( validatorWallet.address, data, @@ -710,21 +696,21 @@ blockchainTests.resets('MixinSignatureValidator', env => { const signatureHex = hexConcat(SignatureType.EIP1271Wallet); signedOrder.makerAddress = notSignerAddress; const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder); - const data = eip1271Data.OrderWithHash.getABIEncodedTransactionData(signedOrder, orderHashHex); + const data = eip1271Data.OrderWithHash(signedOrder, orderHashHex).getABIEncodedTransactionData(); const expectedError = new ExchangeRevertErrors.EIP1271SignatureError( notSignerAddress, data, signatureHex, constants.NULL_BYTES, ); - const tx = signatureValidator.isValidOrderSignature.callAsync(signedOrder, signatureHex); + const tx = signatureValidator.isValidOrderSignature(signedOrder, signatureHex).callAsync(); return expect(tx).to.revertWith(expectedError); }); it('should revert when signer is an EOA and SignatureType=Validator', async () => { const signatureHex = hexConcat(notSignerAddress, SignatureType.Validator); const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder); - const data = eip1271Data.OrderWithHash.getABIEncodedTransactionData(signedOrder, orderHashHex); + const data = eip1271Data.OrderWithHash(signedOrder, orderHashHex).getABIEncodedTransactionData(); const expectedError = new ExchangeRevertErrors.EIP1271SignatureError( notSignerAddress, data, @@ -732,12 +718,10 @@ blockchainTests.resets('MixinSignatureValidator', env => { constants.NULL_BYTES, ); // Register an EOA as a validator. - await signatureValidator.setSignatureValidatorApproval.awaitTransactionSuccessAsync( - notSignerAddress, - true, - { from: signerAddress }, - ); - const tx = signatureValidator.isValidOrderSignature.callAsync(signedOrder, signatureHex); + await signatureValidator + .setSignatureValidatorApproval(notSignerAddress, true) + .awaitTransactionSuccessAsync({ from: signerAddress }); + const tx = signatureValidator.isValidOrderSignature(signedOrder, signatureHex).callAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -787,13 +771,11 @@ blockchainTests.resets('MixinSignatureValidator', env => { ? constants.NULL_BYTES : hashBytes(validatorExpectedSignatureHex); if (validatorAction !== undefined) { - await validatorWallet.prepare.awaitTransactionSuccessAsync( - transactionHashHex, - validatorAction, - expectedSignatureHashHex, - ); + await validatorWallet + .prepare(transactionHashHex, validatorAction, expectedSignatureHashHex) + .awaitTransactionSuccessAsync(); } - return signatureValidator.isValidTransactionSignature.callAsync(transaction, signatureHex); + return signatureValidator.isValidTransactionSignature(transaction, signatureHex).callAsync(); }; it('should revert when signerAddress == 0', async () => { @@ -809,7 +791,7 @@ blockchainTests.resets('MixinSignatureValidator', env => { constants.NULL_ADDRESS, signatureHex, ); - const tx = signatureValidator.isValidTransactionSignature.callAsync(nullSignerTransaction, signatureHex); + const tx = signatureValidator.isValidTransactionSignature(nullSignerTransaction, signatureHex).callAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -856,11 +838,9 @@ blockchainTests.resets('MixinSignatureValidator', env => { it('should revert when SignatureType=Validator and signature is shorter than 21 bytes', async () => { // Set approval of signature validator to false - await signatureValidator.setSignatureValidatorApproval.awaitTransactionSuccessAsync( - validatorWallet.address, - false, - { from: signedTransaction.signerAddress }, - ); + await signatureValidator + .setSignatureValidatorApproval(validatorWallet.address, false) + .awaitTransactionSuccessAsync({ from: signedTransaction.signerAddress }); // Doesn't have to contain a real signature since our wallet contract // just does a hash comparison. const signatureHex = hexConcat(SignatureType.Validator); @@ -879,10 +859,9 @@ blockchainTests.resets('MixinSignatureValidator', env => { const signatureDataHex = generateRandomSignature(); const signatureHex = hexConcat(signatureDataHex, validatorWallet.address, SignatureType.Validator); const transactionHashHex = transactionHashUtils.getTransactionHashHex(signedTransaction); - const data = eip1271Data.ZeroExTransactionWithHash.getABIEncodedTransactionData( - signedTransaction, - transactionHashHex, - ); + const data = eip1271Data + .ZeroExTransactionWithHash(signedTransaction, transactionHashHex) + .getABIEncodedTransactionData(); const expectedError = new ExchangeRevertErrors.EIP1271SignatureError( validatorWallet.address, data, @@ -904,10 +883,9 @@ blockchainTests.resets('MixinSignatureValidator', env => { const signatureDataHex = generateRandomSignature(); const signatureHex = hexConcat(signatureDataHex, validatorWallet.address, SignatureType.Validator); const transactionHashHex = transactionHashUtils.getTransactionHashHex(signedTransaction); - const data = eip1271Data.ZeroExTransactionWithHash.getABIEncodedTransactionData( - signedTransaction, - transactionHashHex, - ); + const data = eip1271Data + .ZeroExTransactionWithHash(signedTransaction, transactionHashHex) + .getABIEncodedTransactionData(); const expectedError = new ExchangeRevertErrors.EIP1271SignatureError( validatorWallet.address, data, @@ -924,10 +902,9 @@ blockchainTests.resets('MixinSignatureValidator', env => { const signatureDataHex = generateRandomSignature(); const signatureHex = hexConcat(signatureDataHex, validatorWallet.address, SignatureType.Validator); const transactionHashHex = transactionHashUtils.getTransactionHashHex(signedTransaction); - const data = eip1271Data.ZeroExTransactionWithHash.getABIEncodedTransactionData( - signedTransaction, - transactionHashHex, - ); + const data = eip1271Data + .ZeroExTransactionWithHash(signedTransaction, transactionHashHex) + .getABIEncodedTransactionData(); const expectedError = new ExchangeRevertErrors.EIP1271SignatureError( validatorWallet.address, data, @@ -940,11 +917,9 @@ blockchainTests.resets('MixinSignatureValidator', env => { it('should revert when SignatureType=Validator, signature is valid and validator is not approved', async () => { // Set approval of signature validator to false - await signatureValidator.setSignatureValidatorApproval.awaitTransactionSuccessAsync( - validatorWallet.address, - false, - { from: signedTransaction.signerAddress }, - ); + await signatureValidator + .setSignatureValidatorApproval(validatorWallet.address, false) + .awaitTransactionSuccessAsync({ from: signedTransaction.signerAddress }); // Doesn't have to contain a real signature since our wallet contract // just does a hash comparison. const signatureDataHex = generateRandomSignature(); @@ -1009,10 +984,9 @@ blockchainTests.resets('MixinSignatureValidator', env => { const signatureDataHex = generateRandomSignature(); const signatureHex = hexConcat(signatureDataHex, SignatureType.EIP1271Wallet); const transactionHashHex = transactionHashUtils.getTransactionHashHex(signedTransaction); - const data = eip1271Data.ZeroExTransactionWithHash.getABIEncodedTransactionData( - signedTransaction, - transactionHashHex, - ); + const data = eip1271Data + .ZeroExTransactionWithHash(signedTransaction, transactionHashHex) + .getABIEncodedTransactionData(); const expectedError = new ExchangeRevertErrors.EIP1271SignatureError( validatorWallet.address, data, @@ -1034,10 +1008,9 @@ blockchainTests.resets('MixinSignatureValidator', env => { // just does a hash comparison. const signatureHex = hexConcat(generateRandomSignature(), SignatureType.EIP1271Wallet); const transactionHashHex = transactionHashUtils.getTransactionHashHex(signedTransaction); - const data = eip1271Data.ZeroExTransactionWithHash.getABIEncodedTransactionData( - signedTransaction, - transactionHashHex, - ); + const data = eip1271Data + .ZeroExTransactionWithHash(signedTransaction, transactionHashHex) + .getABIEncodedTransactionData(); const expectedError = new ExchangeRevertErrors.EIP1271SignatureError( validatorWallet.address, data, @@ -1054,10 +1027,9 @@ blockchainTests.resets('MixinSignatureValidator', env => { // just does a hash comparison. const signatureHex = hexConcat(generateRandomSignature(), SignatureType.EIP1271Wallet); const transactionHashHex = transactionHashUtils.getTransactionHashHex(signedTransaction); - const data = eip1271Data.ZeroExTransactionWithHash.getABIEncodedTransactionData( - signedTransaction, - transactionHashHex, - ); + const data = eip1271Data + .ZeroExTransactionWithHash(signedTransaction, transactionHashHex) + .getABIEncodedTransactionData(); const expectedError = new ExchangeRevertErrors.EIP1271SignatureError( validatorWallet.address, data, @@ -1071,27 +1043,25 @@ blockchainTests.resets('MixinSignatureValidator', env => { it('should revert when signer is an EOA and SignatureType=EIP1271Wallet', async () => { const signatureHex = hexConcat(SignatureType.EIP1271Wallet); const transactionHashHex = transactionHashUtils.getTransactionHashHex(signedTransaction); - const data = eip1271Data.ZeroExTransactionWithHash.getABIEncodedTransactionData( - signedTransaction, - transactionHashHex, - ); + const data = eip1271Data + .ZeroExTransactionWithHash(signedTransaction, transactionHashHex) + .getABIEncodedTransactionData(); const expectedError = new ExchangeRevertErrors.EIP1271SignatureError( signedTransaction.signerAddress, data, signatureHex, constants.NULL_BYTES, ); - const tx = signatureValidator.isValidTransactionSignature.callAsync(signedTransaction, signatureHex); + const tx = signatureValidator.isValidTransactionSignature(signedTransaction, signatureHex).callAsync(); return expect(tx).to.revertWith(expectedError); }); it('should revert when signer is an EOA and SignatureType=Validator', async () => { const signatureHex = hexConcat(notSignerAddress, SignatureType.Validator); const transactionHashHex = transactionHashUtils.getTransactionHashHex(signedTransaction); - const data = eip1271Data.ZeroExTransactionWithHash.getABIEncodedTransactionData( - signedTransaction, - transactionHashHex, - ); + const data = eip1271Data + .ZeroExTransactionWithHash(signedTransaction, transactionHashHex) + .getABIEncodedTransactionData(); const expectedError = new ExchangeRevertErrors.EIP1271SignatureError( notSignerAddress, data, @@ -1099,12 +1069,10 @@ blockchainTests.resets('MixinSignatureValidator', env => { constants.NULL_BYTES, ); // Register an EOA as a validator. - await signatureValidator.setSignatureValidatorApproval.awaitTransactionSuccessAsync( - notSignerAddress, - true, - { from: signerAddress }, - ); - const tx = signatureValidator.isValidTransactionSignature.callAsync(signedTransaction, signatureHex); + await signatureValidator + .setSignatureValidatorApproval(notSignerAddress, true) + .awaitTransactionSuccessAsync({ from: signerAddress }); + const tx = signatureValidator.isValidTransactionSignature(signedTransaction, signatureHex).callAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -1134,13 +1102,11 @@ blockchainTests.resets('MixinSignatureValidator', env => { it('should emit a SignatureValidatorApprovalSet with correct args when a validator is approved', async () => { const approval = true; - const res = await signatureValidator.setSignatureValidatorApproval.awaitTransactionSuccessAsync( - validatorWallet.address, - approval, - { + const res = await signatureValidator + .setSignatureValidatorApproval(validatorWallet.address, approval) + .awaitTransactionSuccessAsync({ from: signerAddress, - }, - ); + }); expect(res.logs.length).to.equal(1); const log = signatureValidatorLogDecoder.decodeLogOrThrow(res.logs[0]) as LogWithDecodedArgs< TestSignatureValidatorSignatureValidatorApprovalEventArgs @@ -1152,13 +1118,11 @@ blockchainTests.resets('MixinSignatureValidator', env => { }); it('should emit a SignatureValidatorApprovalSet with correct args when a validator is disapproved', async () => { const approval = false; - const res = await signatureValidator.setSignatureValidatorApproval.awaitTransactionSuccessAsync( - validatorWallet.address, - approval, - { + const res = await signatureValidator + .setSignatureValidatorApproval(validatorWallet.address, approval) + .awaitTransactionSuccessAsync({ from: signerAddress, - }, - ); + }); expect(res.logs.length).to.equal(1); const log = signatureValidatorLogDecoder.decodeLogOrThrow(res.logs[0]) as LogWithDecodedArgs< TestSignatureValidatorSignatureValidatorApprovalEventArgs diff --git a/contracts/exchange/test/transactions.ts b/contracts/exchange/test/transactions.ts index 00e932dbe6..dceff61f57 100644 --- a/contracts/exchange/test/transactions.ts +++ b/contracts/exchange/test/transactions.ts @@ -101,7 +101,7 @@ blockchainTests.resets('Exchange transactions', env => { exchangeWrapper = new ExchangeWrapper(exchangeInstance); await exchangeWrapper.registerAssetProxyAsync(erc20Proxy.address, owner); - await erc20Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(exchangeInstance.address, { from: owner }); + await erc20Proxy.addAuthorizedAddress(exchangeInstance.address).awaitTransactionSuccessAsync({ from: owner }); defaultMakerTokenAddress = erc20TokenA.address; defaultTakerTokenAddress = erc20TokenB.address; @@ -112,10 +112,10 @@ blockchainTests.resets('Exchange transactions', env => { ...constants.STATIC_ORDER_PARAMS, makerAddress, feeRecipientAddress, - makerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultMakerTokenAddress), - takerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultTakerTokenAddress), - makerFeeAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultMakerFeeTokenAddress), - takerFeeAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultTakerFeeTokenAddress), + makerAssetData: await devUtils.encodeERC20AssetData(defaultMakerTokenAddress).callAsync(), + takerAssetData: await devUtils.encodeERC20AssetData(defaultTakerTokenAddress).callAsync(), + makerFeeAssetData: await devUtils.encodeERC20AssetData(defaultMakerFeeTokenAddress).callAsync(), + takerFeeAssetData: await devUtils.encodeERC20AssetData(defaultTakerFeeTokenAddress).callAsync(), exchangeAddress: exchangeInstance.address, chainId, }; @@ -179,11 +179,9 @@ blockchainTests.resets('Exchange transactions', env => { actualGasPrice, transaction.gasPrice, ); - const tx = exchangeInstance.executeTransaction.sendTransactionAsync( - transaction, - transaction.signature, - { gasPrice: actualGasPrice, from: senderAddress }, - ); + const tx = exchangeInstance + .executeTransaction(transaction, transaction.signature) + .sendTransactionAsync({ gasPrice: actualGasPrice, from: senderAddress }); return expect(tx).to.revertWith(expectedError); }); it('should revert if the actual gasPrice is less than expected', async () => { @@ -200,11 +198,9 @@ blockchainTests.resets('Exchange transactions', env => { actualGasPrice, transaction.gasPrice, ); - const tx = exchangeInstance.executeTransaction.sendTransactionAsync( - transaction, - transaction.signature, - { gasPrice: actualGasPrice, from: senderAddress }, - ); + const tx = exchangeInstance + .executeTransaction(transaction, transaction.signature) + .sendTransactionAsync({ gasPrice: actualGasPrice, from: senderAddress }); return expect(tx).to.revertWith(expectedError); }); }); @@ -288,13 +284,11 @@ blockchainTests.resets('Exchange transactions', env => { const orders = [order]; const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); const transaction = await takerTransactionFactory.newSignedTransactionAsync({ data }); - const returnData = await exchangeInstance.executeTransaction.callAsync( - transaction, - transaction.signature, - { + const returnData = await exchangeInstance + .executeTransaction(transaction, transaction.signature) + .callAsync({ from: senderAddress, - }, - ); + }); const abi = artifacts.Exchange.compilerOutput.abi; const methodAbi = abi.filter(abiItem => (abiItem as MethodAbi).name === fnName)[0] as MethodAbi; const abiEncoder = new AbiEncoder.Method(methodAbi); @@ -328,10 +322,9 @@ blockchainTests.resets('Exchange transactions', env => { const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); const transaction = await takerTransactionFactory.newSignedTransactionAsync({ data }); const transactionHashHex = transactionHashUtils.getTransactionHashHex(transaction); - const recursiveData = exchangeInstance.executeTransaction.getABIEncodedTransactionData( - transaction, - transaction.signature, - ); + const recursiveData = exchangeInstance + .executeTransaction(transaction, transaction.signature) + .getABIEncodedTransactionData(); const recursiveTransaction = await takerTransactionFactory.newSignedTransactionAsync({ data: recursiveData, }); @@ -353,10 +346,9 @@ blockchainTests.resets('Exchange transactions', env => { const orders = [await orderFactory.newSignedOrderAsync()]; const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); const transaction = await takerTransactionFactory.newSignedTransactionAsync({ data }); - const recursiveData = exchangeInstance.executeTransaction.getABIEncodedTransactionData( - transaction, - constants.NULL_BYTES, - ); + const recursiveData = exchangeInstance + .executeTransaction(transaction, constants.NULL_BYTES) + .getABIEncodedTransactionData(); const recursiveTransaction = await takerTransactionFactory.newSignedTransactionAsync({ data: recursiveData, }); @@ -539,7 +531,7 @@ blockchainTests.resets('Exchange transactions', env => { describe('cancelOrdersUpTo', () => { it('should be successful if signed by maker and called by sender', async () => { const targetEpoch = constants.ZERO_AMOUNT; - const data = exchangeInstance.cancelOrdersUpTo.getABIEncodedTransactionData(targetEpoch); + const data = exchangeInstance.cancelOrdersUpTo(targetEpoch).getABIEncodedTransactionData(); const transaction = await makerTransactionFactory.newSignedTransactionAsync({ data }); const transactionReceipt = await exchangeWrapper.executeTransactionAsync(transaction, senderAddress); const cancelLogs = transactionReceipt.logs.filter( @@ -553,7 +545,7 @@ blockchainTests.resets('Exchange transactions', env => { }); it('should be successful if called by maker without a signature', async () => { const targetEpoch = constants.ZERO_AMOUNT; - const data = exchangeInstance.cancelOrdersUpTo.getABIEncodedTransactionData(targetEpoch); + const data = exchangeInstance.cancelOrdersUpTo(targetEpoch).getABIEncodedTransactionData(); const transaction = await makerTransactionFactory.newSignedTransactionAsync({ data }); const transactionReceipt = await exchangeWrapper.executeTransactionAsync(transaction, makerAddress); const cancelLogs = transactionReceipt.logs.filter( @@ -570,34 +562,33 @@ blockchainTests.resets('Exchange transactions', env => { it('should preSign a hash for the signer', async () => { const order = await orderFactory.newSignedOrderAsync(); const orderHash = orderHashUtils.getOrderHashHex(order); - const data = exchangeInstance.preSign.getABIEncodedTransactionData(orderHash); + const data = exchangeInstance.preSign(orderHash).getABIEncodedTransactionData(); const transaction = await takerTransactionFactory.newSignedTransactionAsync({ data }); - let isPreSigned = await exchangeInstance.preSigned.callAsync(orderHash, takerAddress); + let isPreSigned = await exchangeInstance.preSigned(orderHash, takerAddress).callAsync(); expect(isPreSigned).to.be.eq(false); await exchangeWrapper.executeTransactionAsync(transaction, senderAddress); - isPreSigned = await exchangeInstance.preSigned.callAsync(orderHash, takerAddress); + isPreSigned = await exchangeInstance.preSigned(orderHash, takerAddress).callAsync(); expect(isPreSigned).to.be.eq(true); }); it('should preSign a hash for the caller if called without a signature', async () => { const order = await orderFactory.newSignedOrderAsync(); const orderHash = orderHashUtils.getOrderHashHex(order); - const data = exchangeInstance.preSign.getABIEncodedTransactionData(orderHash); + const data = exchangeInstance.preSign(orderHash).getABIEncodedTransactionData(); const transaction = await takerTransactionFactory.newSignedTransactionAsync({ data }); transaction.signature = constants.NULL_BYTES; - let isPreSigned = await exchangeInstance.preSigned.callAsync(orderHash, takerAddress); + let isPreSigned = await exchangeInstance.preSigned(orderHash, takerAddress).callAsync(); expect(isPreSigned).to.be.eq(false); await exchangeWrapper.executeTransactionAsync(transaction, takerAddress); - isPreSigned = await exchangeInstance.preSigned.callAsync(orderHash, takerAddress); + isPreSigned = await exchangeInstance.preSigned(orderHash, takerAddress).callAsync(); expect(isPreSigned).to.be.eq(true); }); }); describe('setSignatureValidatorApproval', () => { it('should approve a validator for the signer', async () => { const shouldApprove = true; - const data = exchangeInstance.setSignatureValidatorApproval.getABIEncodedTransactionData( - validatorAddress, - shouldApprove, - ); + const data = exchangeInstance + .setSignatureValidatorApproval(validatorAddress, shouldApprove) + .getABIEncodedTransactionData(); const transaction = await takerTransactionFactory.newSignedTransactionAsync({ data }); const transactionReceipt = await exchangeWrapper.executeTransactionAsync(transaction, senderAddress); const validatorApprovalLogs = transactionReceipt.logs.filter( @@ -615,10 +606,9 @@ blockchainTests.resets('Exchange transactions', env => { }); it('should approve a validator for the caller if called with no signature', async () => { const shouldApprove = true; - const data = exchangeInstance.setSignatureValidatorApproval.getABIEncodedTransactionData( - validatorAddress, - shouldApprove, - ); + const data = exchangeInstance + .setSignatureValidatorApproval(validatorAddress, shouldApprove) + .getABIEncodedTransactionData(); const transaction = await takerTransactionFactory.newSignedTransactionAsync({ data }); transaction.signature = constants.NULL_BYTES; const transactionReceipt = await exchangeWrapper.executeTransactionAsync(transaction, takerAddress); @@ -839,11 +829,12 @@ blockchainTests.resets('Exchange transactions', env => { const data2 = exchangeDataEncoder.encodeOrdersToExchangeData(ExchangeFunctionName.FillOrder, [order2]); const transaction1 = await takerTransactionFactory.newSignedTransactionAsync({ data: data1 }); const transaction2 = await taker2TransactionFactory.newSignedTransactionAsync({ data: data2 }); - const returnData = await exchangeInstance.batchExecuteTransactions.callAsync( - [transaction1, transaction2], - [transaction1.signature, transaction2.signature], - { from: senderAddress }, - ); + const returnData = await exchangeInstance + .batchExecuteTransactions( + [transaction1, transaction2], + [transaction1.signature, transaction2.signature], + ) + .callAsync({ from: senderAddress }); const abi = artifacts.Exchange.compilerOutput.abi; const methodAbi = abi.filter( abiItem => (abiItem as MethodAbi).name === ExchangeFunctionName.FillOrder, @@ -945,11 +936,12 @@ blockchainTests.resets('Exchange transactions', env => { ]); const transaction1 = await takerTransactionFactory.newSignedTransactionAsync({ data: data1 }); const transaction2 = await makerTransactionFactory.newSignedTransactionAsync({ data: data2 }); - const returnData = await exchangeInstance.batchExecuteTransactions.callAsync( - [transaction1, transaction2], - [transaction1.signature, transaction2.signature], - { from: senderAddress }, - ); + const returnData = await exchangeInstance + .batchExecuteTransactions( + [transaction1, transaction2], + [transaction1.signature, transaction2.signature], + ) + .callAsync({ from: senderAddress }); const abi = artifacts.Exchange.compilerOutput.abi; const methodAbi = abi.filter( abiItem => (abiItem as MethodAbi).name === ExchangeFunctionName.FillOrder, diff --git a/contracts/exchange/test/transactions_unit_tests.ts b/contracts/exchange/test/transactions_unit_tests.ts index 257bbf798d..1a537d7a26 100644 --- a/contracts/exchange/test/transactions_unit_tests.ts +++ b/contracts/exchange/test/transactions_unit_tests.ts @@ -1,4 +1,4 @@ -import { blockchainTests, constants, describe, expect, hexRandom, TransactionHelper } from '@0x/contracts-test-utils'; +import { blockchainTests, constants, describe, expect, hexRandom, transactionHelper } from '@0x/contracts-test-utils'; import { ExchangeRevertErrors, transactionHashUtils } from '@0x/order-utils'; import { EIP712DomainWithDefaultSchema, ZeroExTransaction } from '@0x/types'; import { BigNumber, StringRevertError } from '@0x/utils'; @@ -29,8 +29,6 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef const DEADBEEF_RETURN_DATA = '0xdeadbeef'; const INVALID_SIGNATURE = '0x0000'; - const transactionHelper = new TransactionHelper(web3Wrapper, artifacts); - before(async () => { // A list of available addresses to use during testing. accounts = await web3Wrapper.getAvailableAddressesAsync(); @@ -54,11 +52,9 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef * Generates calldata for a call to `executable()` in the `TestTransactions` contract. */ function getExecutableCallData(shouldSucceed: boolean, callData: string, returnData: string): string { - return (transactionsContract as any).executable.getABIEncodedTransactionData( - shouldSucceed, - callData, - returnData, - ); + return (transactionsContract as any) + .executable(shouldSucceed, callData, returnData) + .getABIEncodedTransactionData(); } interface GenerateZeroExTransactionParams { @@ -109,10 +105,9 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef ); // Call the `batchExecuteTransactions()` function and ensure that it reverts with the expected revert error. - const tx = transactionsContract.batchExecuteTransactions.awaitTransactionSuccessAsync( - [transaction], - [randomSignature()], - ); + const tx = transactionsContract + .batchExecuteTransactions([transaction], [randomSignature()]) + .awaitTransactionSuccessAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -132,10 +127,9 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef ); // Call the `batchExecuteTransactions()` function and ensure that it reverts with the expected revert error. - const tx = transactionsContract.batchExecuteTransactions.awaitTransactionSuccessAsync( - [transaction1, transaction2], - [randomSignature(), randomSignature()], - ); + const tx = transactionsContract + .batchExecuteTransactions([transaction1, transaction2], [randomSignature(), randomSignature()]) + .awaitTransactionSuccessAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -155,10 +149,9 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef ); // Call the `batchExecuteTransactions()` function and ensure that it reverts with the expected revert error. - const tx = transactionsContract.batchExecuteTransactions.awaitTransactionSuccessAsync( - [transaction1, transaction2], - [randomSignature(), randomSignature()], - ); + const tx = transactionsContract + .batchExecuteTransactions([transaction1, transaction2], [randomSignature(), randomSignature()]) + .awaitTransactionSuccessAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -176,13 +169,11 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef ExchangeRevertErrors.TransactionErrorCode.AlreadyExecuted, transactionHash2, ); - const tx = transactionsContract.batchExecuteTransactions.awaitTransactionSuccessAsync( - [transaction1, transaction2], - [randomSignature(), randomSignature()], - { + const tx = transactionsContract + .batchExecuteTransactions([transaction1, transaction2], [randomSignature(), randomSignature()]) + .awaitTransactionSuccessAsync({ from: accounts[0], - }, - ); + }); return expect(tx).to.revertWith(expectedError); }); @@ -203,7 +194,7 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef ); expect(result.length).to.be.eq(1); - const returnData = transactionsContract.executeTransaction.getABIDecodedReturnData(result[0]); + const returnData = transactionsContract.getABIDecodedReturnData('executeTransaction', result[0]); expect(returnData).to.equal(DEADBEEF_RETURN_DATA); // Ensure that the correct number of events were logged. @@ -241,10 +232,10 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef ); expect(result.length).to.be.eq(2); - expect(transactionsContract.executeTransaction.getABIDecodedReturnData(result[0])).to.equal( + expect(transactionsContract.getABIDecodedReturnData('executeTransaction', result[0])).to.equal( DEADBEEF_RETURN_DATA, ); - expect(transactionsContract.executeTransaction.getABIDecodedReturnData(result[1])).to.equal(returnData2); + expect(transactionsContract.getABIDecodedReturnData('executeTransaction', result[1])).to.equal(returnData2); // Verify that the correct number of events were logged. const logs = receipt.logs as Array>; @@ -269,17 +260,18 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef const innerTransaction2 = await generateZeroExTransactionAsync({ signerAddress: accounts[1] }); const innerBatchExecuteTransaction = await generateZeroExTransactionAsync({ signerAddress: accounts[2], - callData: transactionsContract.batchExecuteTransactions.getABIEncodedTransactionData( - [innerTransaction1, innerTransaction2], - [randomSignature(), randomSignature()], - ), + callData: transactionsContract + .batchExecuteTransactions( + [innerTransaction1, innerTransaction2], + [randomSignature(), randomSignature()], + ) + .getABIEncodedTransactionData(), }); const outerExecuteTransaction = await generateZeroExTransactionAsync({ signerAddress: accounts[1], - callData: transactionsContract.executeTransaction.getABIEncodedTransactionData( - innerBatchExecuteTransaction, - randomSignature(), - ), + callData: transactionsContract + .executeTransaction(innerBatchExecuteTransaction, randomSignature()) + .getABIEncodedTransactionData(), }); const innerBatchExecuteTransactionHash = transactionHashUtils.getTransactionHashHex( innerBatchExecuteTransaction, @@ -293,11 +285,9 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef outerExecuteTransactionHash, innerExpectedError.encode(), ); - const tx = transactionsContract.batchExecuteTransactions.awaitTransactionSuccessAsync( - [outerExecuteTransaction], - [randomSignature()], - { from: accounts[2] }, - ); + const tx = transactionsContract + .batchExecuteTransactions([outerExecuteTransaction], [randomSignature()]) + .awaitTransactionSuccessAsync({ from: accounts[2] }); return expect(tx).to.revertWith(outerExpectedError); }); it('should allow recursion as long as currentContextAddress is not set', async () => { @@ -306,34 +296,32 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef // From this point on, all transactions and calls will have the same sender, which does not change currentContextAddress when called const innerBatchExecuteTransaction = await generateZeroExTransactionAsync({ signerAddress: accounts[2], - callData: transactionsContract.batchExecuteTransactions.getABIEncodedTransactionData( - [innerTransaction1, innerTransaction2], - [randomSignature(), randomSignature()], - ), + callData: transactionsContract + .batchExecuteTransactions( + [innerTransaction1, innerTransaction2], + [randomSignature(), randomSignature()], + ) + .getABIEncodedTransactionData(), }); const outerExecuteTransaction = await generateZeroExTransactionAsync({ signerAddress: accounts[2], - callData: transactionsContract.executeTransaction.getABIEncodedTransactionData( - innerBatchExecuteTransaction, - randomSignature(), - ), + callData: transactionsContract + .executeTransaction(innerBatchExecuteTransaction, randomSignature()) + .getABIEncodedTransactionData(), }); return expect( - transactionsContract.batchExecuteTransactions.awaitTransactionSuccessAsync( - [outerExecuteTransaction], - [randomSignature()], - { from: accounts[2] }, - ), + transactionsContract + .batchExecuteTransactions([outerExecuteTransaction], [randomSignature()]) + .awaitTransactionSuccessAsync({ from: accounts[2] }), ).to.be.fulfilled(''); }); }); describe('executeTransaction', () => { function getExecuteTransactionCallData(transaction: ZeroExTransaction, signature: string): string { - return (transactionsContract as any).executeTransaction.getABIEncodedTransactionData( - transaction, - signature, - ); + return (transactionsContract as any) + .executeTransaction(transaction, signature) + .getABIEncodedTransactionData(); } it('should revert if the current time is past the expiration time', async () => { const transaction = await generateZeroExTransactionAsync({ @@ -344,10 +332,9 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef ExchangeRevertErrors.TransactionErrorCode.Expired, transactionHash, ); - const tx = transactionsContract.executeTransaction.awaitTransactionSuccessAsync( - transaction, - randomSignature(), - ); + const tx = transactionsContract + .executeTransaction(transaction, randomSignature()) + .awaitTransactionSuccessAsync(); return expect(tx).to.revertWith(expectedError); }); it('should revert if the transaction is submitted with a gasPrice that does not equal the required gasPrice', async () => { @@ -359,13 +346,11 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef actualGasPrice, transaction.gasPrice, ); - const tx = transactionsContract.executeTransaction.awaitTransactionSuccessAsync( - transaction, - randomSignature(), - { + const tx = transactionsContract + .executeTransaction(transaction, randomSignature()) + .awaitTransactionSuccessAsync({ gasPrice: actualGasPrice, - }, - ); + }); return expect(tx).to.revertWith(expectedError); }); it('should revert if reentrancy occurs in the middle of an executeTransaction call and msg.sender != signer for both calls', async () => { @@ -383,13 +368,11 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef accounts[0], ).encode(); const expectedError = new ExchangeRevertErrors.TransactionExecutionError(outerTransactionHash, errorData); - const tx = transactionsContract.executeTransaction.awaitTransactionSuccessAsync( - outerTransaction, - validSignature, - { + const tx = transactionsContract + .executeTransaction(outerTransaction, validSignature) + .awaitTransactionSuccessAsync({ from: accounts[1], // Different then the signing addresses - }, - ); + }); return expect(tx).to.revertWith(expectedError); }); it('should revert if reentrancy occurs in the middle of an executeTransaction call and msg.sender != signer and then msg.sender == signer', async () => { @@ -407,13 +390,11 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef accounts[0], ).encode(); const expectedError = new ExchangeRevertErrors.TransactionExecutionError(outerTransactionHash, errorData); - const tx = transactionsContract.executeTransaction.awaitTransactionSuccessAsync( - outerTransaction, - validSignature, - { + const tx = transactionsContract + .executeTransaction(outerTransaction, validSignature) + .awaitTransactionSuccessAsync({ from: accounts[1], // Different then the signing addresses - }, - ); + }); return expect(tx).to.revertWith(expectedError); }); it('should allow reentrancy in the middle of an executeTransaction call if msg.sender == signer for both calls', async () => { @@ -425,7 +406,7 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef returnData: DEADBEEF_RETURN_DATA, }); return expect( - transactionsContract.executeTransaction.awaitTransactionSuccessAsync(outerTransaction, validSignature, { + transactionsContract.executeTransaction(outerTransaction, validSignature).awaitTransactionSuccessAsync({ from: accounts[0], }), ).to.be.fulfilled(''); @@ -439,7 +420,7 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef returnData: DEADBEEF_RETURN_DATA, }); return expect( - transactionsContract.executeTransaction.awaitTransactionSuccessAsync(outerTransaction, validSignature, { + transactionsContract.executeTransaction(outerTransaction, validSignature).awaitTransactionSuccessAsync({ from: accounts[0], }), ).to.be.fulfilled(''); @@ -450,17 +431,16 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef const transactionHash = transactionHashUtils.getTransactionHashHex(transaction); // Use the transaction in execute transaction. await expect( - transactionsContract.executeTransaction.awaitTransactionSuccessAsync(transaction, validSignature), + transactionsContract.executeTransaction(transaction, validSignature).awaitTransactionSuccessAsync(), ).to.be.fulfilled(''); // Use the same transaction to make another call const expectedError = new ExchangeRevertErrors.TransactionError( ExchangeRevertErrors.TransactionErrorCode.AlreadyExecuted, transactionHash, ); - const tx = transactionsContract.executeTransaction.awaitTransactionSuccessAsync( - transaction, - validSignature, - ); + const tx = transactionsContract + .executeTransaction(transaction, validSignature) + .awaitTransactionSuccessAsync(); return expect(tx).to.revertWith(expectedError); }); it('should revert if the signer != msg.sender and the signature is not valid', async () => { @@ -472,13 +452,11 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef accounts[1], INVALID_SIGNATURE, ); - const tx = transactionsContract.executeTransaction.awaitTransactionSuccessAsync( - transaction, - INVALID_SIGNATURE, - { + const tx = transactionsContract + .executeTransaction(transaction, INVALID_SIGNATURE) + .awaitTransactionSuccessAsync({ from: accounts[0], - }, - ); + }); return expect(tx).to.revertWith(expectedError); }); it('should revert if the signer == msg.sender but the delegatecall fails', async () => { @@ -493,13 +471,11 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef transactionHash, executableError.encode(), ); - const tx = transactionsContract.executeTransaction.awaitTransactionSuccessAsync( - transaction, - randomSignature(), - { + const tx = transactionsContract + .executeTransaction(transaction, randomSignature()) + .awaitTransactionSuccessAsync({ from: accounts[1], - }, - ); + }); return expect(tx).to.revertWith(expectedError); }); it('should revert if the signer != msg.sender and the signature is valid but the delegatecall fails', async () => { @@ -515,13 +491,11 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef transactionHash, executableError.encode(), ); - const tx = transactionsContract.executeTransaction.awaitTransactionSuccessAsync( - transaction, - validSignature, - { + const tx = transactionsContract + .executeTransaction(transaction, validSignature) + .awaitTransactionSuccessAsync({ from: accounts[0], - }, - ); + }); return expect(tx).to.revertWith(expectedError); }); it('should succeed with the correct return hash and event emitted when msg.sender != signer', async () => { @@ -540,7 +514,7 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef { from: accounts[0] }, ); - expect(transactionsContract.executeTransaction.getABIDecodedReturnData(result)).to.equal( + expect(transactionsContract.getABIDecodedReturnData('executeTransaction', result)).to.equal( DEADBEEF_RETURN_DATA, ); @@ -571,7 +545,7 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef { from: accounts[0] }, ); - expect(transactionsContract.executeTransaction.getABIDecodedReturnData(result)).to.equal( + expect(transactionsContract.getABIDecodedReturnData('executeTransaction', result)).to.equal( DEADBEEF_RETURN_DATA, ); @@ -599,7 +573,7 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef transactionHash, ); expect( - transactionsContract.assertExecutableTransaction.callAsync(transaction, randomSignature()), + transactionsContract.assertExecutableTransaction(transaction, randomSignature()).callAsync(), ).to.revertWith(expectedError); }); it('should revert if the gasPrice is less than required', async () => { @@ -612,7 +586,7 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef transaction.gasPrice, ); expect( - transactionsContract.assertExecutableTransaction.callAsync(transaction, randomSignature(), { + transactionsContract.assertExecutableTransaction(transaction, randomSignature()).callAsync({ gasPrice: actualGasPrice, }), ).to.revertWith(expectedError); @@ -627,30 +601,30 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef transaction.gasPrice, ); expect( - transactionsContract.assertExecutableTransaction.callAsync(transaction, randomSignature(), { + transactionsContract.assertExecutableTransaction(transaction, randomSignature()).callAsync({ gasPrice: actualGasPrice, }), ).to.revertWith(expectedError); }); it('should revert if currentContextAddress is non-zero', async () => { - await transactionsContract.setCurrentContextAddress.awaitTransactionSuccessAsync(accounts[0]); + await transactionsContract.setCurrentContextAddress(accounts[0]).awaitTransactionSuccessAsync(); const transaction = await generateZeroExTransactionAsync(); const transactionHash = transactionHashUtils.getTransactionHashHex(transaction); const expectedError = new ExchangeRevertErrors.TransactionInvalidContextError(transactionHash, accounts[0]); expect( - transactionsContract.assertExecutableTransaction.callAsync(transaction, randomSignature()), + transactionsContract.assertExecutableTransaction(transaction, randomSignature()).callAsync(), ).to.revertWith(expectedError); }); it('should revert if the transaction has already been executed', async () => { const transaction = await generateZeroExTransactionAsync(); const transactionHash = transactionHashUtils.getTransactionHashHex(transaction); - await transactionsContract.setTransactionExecuted.awaitTransactionSuccessAsync(transactionHash); + await transactionsContract.setTransactionExecuted(transactionHash).awaitTransactionSuccessAsync(); const expectedError = new ExchangeRevertErrors.TransactionError( ExchangeRevertErrors.TransactionErrorCode.AlreadyExecuted, transactionHash, ); expect( - transactionsContract.assertExecutableTransaction.callAsync(transaction, randomSignature()), + transactionsContract.assertExecutableTransaction(transaction, randomSignature()).callAsync(), ).to.revertWith(expectedError); }); it('should revert if signer != msg.sender and the signature is invalid', async () => { @@ -663,7 +637,7 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef INVALID_SIGNATURE, ); expect( - transactionsContract.assertExecutableTransaction.callAsync(transaction, INVALID_SIGNATURE, { + transactionsContract.assertExecutableTransaction(transaction, INVALID_SIGNATURE).callAsync({ from: accounts[1], }), ).to.revertWith(expectedError); @@ -671,7 +645,7 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef it('should be successful if signer == msg.sender and the signature is invalid', async () => { const transaction = await generateZeroExTransactionAsync({ signerAddress: accounts[0] }); return expect( - transactionsContract.assertExecutableTransaction.callAsync(transaction, INVALID_SIGNATURE, { + transactionsContract.assertExecutableTransaction(transaction, INVALID_SIGNATURE).callAsync({ from: accounts[0], }), ).to.be.fulfilled(''); @@ -679,7 +653,7 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef it('should be successful if signer == msg.sender and the signature is valid', async () => { const transaction = await generateZeroExTransactionAsync({ signerAddress: accounts[0] }); return expect( - transactionsContract.assertExecutableTransaction.callAsync(transaction, randomSignature(), { + transactionsContract.assertExecutableTransaction(transaction, randomSignature()).callAsync({ from: accounts[0], }), ).to.be.fulfilled(''); @@ -687,7 +661,7 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef it('should be successful if not expired, the gasPrice is correct, the tx has not been executed, currentContextAddress has not been set, signer != msg.sender, and the signature is valid', async () => { const transaction = await generateZeroExTransactionAsync({ signerAddress: accounts[0] }); return expect( - transactionsContract.assertExecutableTransaction.callAsync(transaction, randomSignature(), { + transactionsContract.assertExecutableTransaction(transaction, randomSignature()).callAsync({ from: accounts[1], }), ).to.be.fulfilled(''); @@ -697,30 +671,27 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef describe('setCurrentContextAddressIfRequired', () => { it('should set the currentContextAddress if signer not equal to sender', async () => { const randomAddress = hexRandom(20); - await transactionsContract.setCurrentContextAddressIfRequired.awaitTransactionSuccessAsync( - randomAddress, - randomAddress, - ); - const currentContextAddress = await transactionsContract.currentContextAddress.callAsync(); + await transactionsContract + .setCurrentContextAddressIfRequired(randomAddress, randomAddress) + .awaitTransactionSuccessAsync(); + const currentContextAddress = await transactionsContract.currentContextAddress().callAsync(); expect(currentContextAddress).to.eq(randomAddress); }); it('should not set the currentContextAddress if signer equal to sender', async () => { const randomAddress = hexRandom(20); - await transactionsContract.setCurrentContextAddressIfRequired.awaitTransactionSuccessAsync( - accounts[0], - randomAddress, - { + await transactionsContract + .setCurrentContextAddressIfRequired(accounts[0], randomAddress) + .awaitTransactionSuccessAsync({ from: accounts[0], - }, - ); - const currentContextAddress = await transactionsContract.currentContextAddress.callAsync(); + }); + const currentContextAddress = await transactionsContract.currentContextAddress().callAsync(); expect(currentContextAddress).to.eq(constants.NULL_ADDRESS); }); }); describe('getCurrentContext', () => { it('should return the sender address when there is not a saved context address', async () => { - const currentContextAddress = await transactionsContract.getCurrentContextAddress.callAsync({ + const currentContextAddress = await transactionsContract.getCurrentContextAddress().callAsync({ from: accounts[0], }); expect(currentContextAddress).to.be.eq(accounts[0]); @@ -728,10 +699,10 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef it('should return the sender address when there is a saved context address', async () => { // Set the current context address to the taker address - await transactionsContract.setCurrentContextAddress.awaitTransactionSuccessAsync(accounts[1]); + await transactionsContract.setCurrentContextAddress(accounts[1]).awaitTransactionSuccessAsync(); // Ensure that the queried current context address is the same as the address that was set. - const currentContextAddress = await transactionsContract.getCurrentContextAddress.callAsync({ + const currentContextAddress = await transactionsContract.getCurrentContextAddress().callAsync({ from: accounts[0], }); expect(currentContextAddress).to.be.eq(accounts[1]); diff --git a/contracts/exchange/test/utils/asset_wrapper.ts b/contracts/exchange/test/utils/asset_wrapper.ts index fe1ffd8739..a04575213f 100644 --- a/contracts/exchange/test/utils/asset_wrapper.ts +++ b/contracts/exchange/test/utils/asset_wrapper.ts @@ -32,7 +32,7 @@ export class AssetWrapper { }); } public async getBalanceAsync(userAddress: string, assetData: string): Promise { - const proxyId = await this._devUtils.decodeAssetProxyId.callAsync(assetData); + const proxyId = await this._devUtils.decodeAssetProxyId(assetData).callAsync(); switch (proxyId) { case AssetProxyId.ERC20: { // tslint:disable-next-line:no-unnecessary-type-assertion @@ -44,9 +44,9 @@ export class AssetWrapper { // tslint:disable-next-line:no-unnecessary-type-assertion const assetWrapper = this._proxyIdToAssetWrappers[proxyId] as ERC721Wrapper; // tslint:disable-next-line:no-unused-variable - const [assetProxyId, tokenAddress, tokenId] = await this._devUtils.decodeERC721AssetData.callAsync( - assetData, - ); + const [assetProxyId, tokenAddress, tokenId] = await this._devUtils + .decodeERC721AssetData(assetData) + .callAsync(); const isOwner = await assetWrapper.isOwnerAsync(userAddress, tokenAddress, tokenId); const balance = isOwner ? ONE_NFT_UNIT : ZERO_NFT_UNIT; return balance; @@ -59,7 +59,7 @@ export class AssetWrapper { assetProxyAddress, tokenAddress, tokenIds, - ] = await this._devUtils.decodeERC1155AssetData.callAsync(assetData); + ] = await this._devUtils.decodeERC1155AssetData(assetData).callAsync(); const assetWrapper = assetProxyWrapper.getContractWrapper(tokenAddress); const balances = await Promise.all( _.map(tokenIds).map(tokenId => assetWrapper.getBalanceAsync(userAddress, tokenId)), @@ -68,9 +68,9 @@ export class AssetWrapper { } case AssetProxyId.MultiAsset: { // tslint:disable-next-line:no-unused-variable - const [assetProxyId, amounts, nestedAssetData] = await this._devUtils.decodeMultiAssetData.callAsync( - assetData, - ); + const [assetProxyId, amounts, nestedAssetData] = await this._devUtils + .decodeMultiAssetData(assetData) + .callAsync(); const nestedBalances = await Promise.all( nestedAssetData.map(async _nestedAssetData => this.getBalanceAsync(userAddress, _nestedAssetData)), ); @@ -84,7 +84,7 @@ export class AssetWrapper { } } public async setBalanceAsync(userAddress: string, assetData: string, desiredBalance: BigNumber): Promise { - const proxyId = await this._devUtils.decodeAssetProxyId.callAsync(assetData); + const proxyId = await this._devUtils.decodeAssetProxyId(assetData).callAsync(); switch (proxyId) { case AssetProxyId.ERC20: { // tslint:disable-next-line:no-unnecessary-type-assertion @@ -100,9 +100,9 @@ export class AssetWrapper { // tslint:disable-next-line:no-unnecessary-type-assertion const erc721Wrapper = this._proxyIdToAssetWrappers[proxyId] as ERC721Wrapper; // tslint:disable-next-line:no-unused-variable - const [assetProxyId, tokenAddress, tokenId] = await this._devUtils.decodeERC721AssetData.callAsync( - assetData, - ); + const [assetProxyId, tokenAddress, tokenId] = await this._devUtils + .decodeERC721AssetData(assetData) + .callAsync(); const doesTokenExist = erc721Wrapper.doesTokenExistAsync(tokenAddress, tokenId); if (!doesTokenExist && desiredBalance.gte(1)) { await erc721Wrapper.mintAsync(tokenAddress, tokenId, userAddress); @@ -134,7 +134,7 @@ export class AssetWrapper { tokenAddress, tokenIds, tokenValues, - ] = await this._devUtils.decodeERC1155AssetData.callAsync(assetData); + ] = await this._devUtils.decodeERC1155AssetData(assetData).callAsync(); const assetWrapper = assetProxyWrapper.getContractWrapper(tokenAddress); const tokenValuesSum = BigNumber.sum(...tokenValues); let tokenValueRatios = tokenValues; @@ -197,9 +197,9 @@ export class AssetWrapper { } case AssetProxyId.MultiAsset: { // tslint:disable-next-line:no-unused-variable - const [assetProxyId, amounts, nestedAssetData] = await this._devUtils.decodeMultiAssetData.callAsync( - assetData, - ); + const [assetProxyId, amounts, nestedAssetData] = await this._devUtils + .decodeMultiAssetData(assetData) + .callAsync(); const amountsSum = BigNumber.sum(...amounts); let assetAmountRatios = amounts; if (!amountsSum.eq(0)) { @@ -220,7 +220,7 @@ export class AssetWrapper { assetData: string, desiredBalance: BigNumber, ): Promise { - const proxyId = await this._devUtils.decodeAssetProxyId.callAsync(assetData); + const proxyId = await this._devUtils.decodeAssetProxyId(assetData).callAsync(); switch (proxyId) { case AssetProxyId.ERC20: case AssetProxyId.ERC721: @@ -235,7 +235,7 @@ export class AssetWrapper { } } public async getProxyAllowanceAsync(userAddress: string, assetData: string): Promise { - const proxyId = await this._devUtils.decodeAssetProxyId.callAsync(assetData); + const proxyId = await this._devUtils.decodeAssetProxyId(assetData).callAsync(); switch (proxyId) { case AssetProxyId.ERC20: { // tslint:disable-next-line:no-unnecessary-type-assertion @@ -247,9 +247,9 @@ export class AssetWrapper { // tslint:disable-next-line:no-unnecessary-type-assertion const assetWrapper = this._proxyIdToAssetWrappers[proxyId] as ERC721Wrapper; // tslint:disable-next-line:no-unused-variable - const [assetProxyId, tokenAddress, tokenId] = await this._devUtils.decodeERC721AssetData.callAsync( - assetData, - ); + const [assetProxyId, tokenAddress, tokenId] = await this._devUtils + .decodeERC721AssetData(assetData) + .callAsync(); const isProxyApprovedForAll = await assetWrapper.isProxyApprovedForAllAsync(userAddress, tokenAddress); if (isProxyApprovedForAll) { return constants.UNLIMITED_ALLOWANCE_IN_BASE_UNITS; @@ -263,9 +263,9 @@ export class AssetWrapper { // tslint:disable-next-line:no-unnecessary-type-assertion const assetProxyWrapper = this._proxyIdToAssetWrappers[proxyId] as ERC1155ProxyWrapper; // tslint:disable-next-line:no-unused-variable - const [assetProxyAddress, tokenAddress] = await this._devUtils.decodeERC1155AssetData.callAsync( - assetData, - ); + const [assetProxyAddress, tokenAddress] = await this._devUtils + .decodeERC1155AssetData(assetData) + .callAsync(); const isApprovedForAll = await assetProxyWrapper.isProxyApprovedForAllAsync(userAddress, tokenAddress); if (!isApprovedForAll) { // ERC1155 is all or nothing. @@ -275,9 +275,9 @@ export class AssetWrapper { } case AssetProxyId.MultiAsset: { // tslint:disable-next-line:no-unused-variable - const [assetProxyId, amounts, nestedAssetData] = await this._devUtils.decodeMultiAssetData.callAsync( - assetData, - ); + const [assetProxyId, amounts, nestedAssetData] = await this._devUtils + .decodeMultiAssetData(assetData) + .callAsync(); const allowances = await Promise.all( nestedAssetData.map(async _nestedAssetData => this.getProxyAllowanceAsync(userAddress, _nestedAssetData), @@ -294,7 +294,7 @@ export class AssetWrapper { assetData: string, desiredAllowance: BigNumber, ): Promise { - const proxyId = await this._devUtils.decodeAssetProxyId.callAsync(assetData); + const proxyId = await this._devUtils.decodeAssetProxyId(assetData).callAsync(); switch (proxyId) { case AssetProxyId.ERC20: { // tslint:disable-next-line:no-unnecessary-type-assertion @@ -315,9 +315,9 @@ export class AssetWrapper { // tslint:disable-next-line:no-unnecessary-type-assertion const erc721Wrapper = this._proxyIdToAssetWrappers[proxyId] as ERC721Wrapper; // tslint:disable-next-line:no-unused-variable - const [assetProxyId, tokenAddress, tokenId] = await this._devUtils.decodeERC721AssetData.callAsync( - assetData, - ); + const [assetProxyId, tokenAddress, tokenId] = await this._devUtils + .decodeERC721AssetData(assetData) + .callAsync(); const doesTokenExist = await erc721Wrapper.doesTokenExistAsync(tokenAddress, tokenId); if (!doesTokenExist) { @@ -352,9 +352,9 @@ export class AssetWrapper { // tslint:disable-next-line:no-unnecessary-type-assertion const assetProxyWrapper = this._proxyIdToAssetWrappers[proxyId] as ERC1155ProxyWrapper; // tslint:disable-next-line:no-unused-variable - const [assetProxyAddress, tokenAddress] = await this._devUtils.decodeERC1155AssetData.callAsync( - assetData, - ); + const [assetProxyAddress, tokenAddress] = await this._devUtils + .decodeERC1155AssetData(assetData) + .callAsync(); // ERC1155 allowances are all or nothing. const shouldApprovedForAll = desiredAllowance.gt(0); const currentAllowance = await this.getProxyAllowanceAsync(userAddress, assetData); @@ -369,9 +369,9 @@ export class AssetWrapper { } case AssetProxyId.MultiAsset: { // tslint:disable-next-line:no-unused-variable - const [assetProxyId, amounts, nestedAssetData] = await this._devUtils.decodeMultiAssetData.callAsync( - assetData, - ); + const [assetProxyId, amounts, nestedAssetData] = await this._devUtils + .decodeMultiAssetData(assetData) + .callAsync(); await Promise.all( nestedAssetData.map(async _nestedAssetData => this.setProxyAllowanceAsync(userAddress, _nestedAssetData, desiredAllowance), diff --git a/contracts/exchange/test/utils/exchange_data_encoder.ts b/contracts/exchange/test/utils/exchange_data_encoder.ts index 5b7e383d08..87d7e227c2 100644 --- a/contracts/exchange/test/utils/exchange_data_encoder.ts +++ b/contracts/exchange/test/utils/exchange_data_encoder.ts @@ -9,44 +9,38 @@ export const exchangeDataEncoder = { const exchangeInstance = new IExchangeContract(constants.NULL_ADDRESS, provider); let data; if (exchangeConstants.SINGLE_FILL_FN_NAMES.indexOf(fnName) !== -1) { - data = (exchangeInstance as any)[fnName].getABIEncodedTransactionData( - orders[0], - orders[0].takerAssetAmount, - orders[0].signature, - ); + data = (exchangeInstance as any) + [fnName](orders[0], orders[0].takerAssetAmount, orders[0].signature) + .getABIEncodedTransactionData(); } else if (exchangeConstants.BATCH_FILL_FN_NAMES.indexOf(fnName) !== -1) { - data = (exchangeInstance as any)[fnName].getABIEncodedTransactionData( - orders, - orders.map(order => order.takerAssetAmount), - orders.map(order => order.signature), - ); + data = (exchangeInstance as any) + [fnName](orders, orders.map(order => order.takerAssetAmount), orders.map(order => order.signature)) + .getABIEncodedTransactionData(); } else if (exchangeConstants.MARKET_FILL_FN_NAMES.indexOf(fnName) !== -1) { const fillAsset = /Buy/.test(fnName) ? 'makerAssetAmount' : 'takerAssetAmount'; - data = (exchangeInstance as any)[fnName].getABIEncodedTransactionData( - orders, - orders.map(order => order[fillAsset]).reduce((prev, curr) => prev.plus(curr)), - orders.map(order => order.signature), - ); + data = (exchangeInstance as any) + [fnName]( + orders, + orders.map(order => order[fillAsset]).reduce((prev, curr) => prev.plus(curr)), + orders.map(order => order.signature), + ) + .getABIEncodedTransactionData(); } else if (exchangeConstants.MATCH_ORDER_FN_NAMES.indexOf(fnName) !== -1) { - data = exchangeInstance.matchOrders.getABIEncodedTransactionData( - orders[0], - orders[1], - orders[0].signature, - orders[1].signature, - ); + data = exchangeInstance + .matchOrders(orders[0], orders[1], orders[0].signature, orders[1].signature) + .getABIEncodedTransactionData(); } else if (fnName === ExchangeFunctionName.CancelOrder) { - data = exchangeInstance.cancelOrder.getABIEncodedTransactionData(orders[0]); + data = exchangeInstance.cancelOrder(orders[0]).getABIEncodedTransactionData(); } else if (fnName === ExchangeFunctionName.BatchCancelOrders) { - data = exchangeInstance.batchCancelOrders.getABIEncodedTransactionData(orders); + data = exchangeInstance.batchCancelOrders(orders).getABIEncodedTransactionData(); } else if (fnName === ExchangeFunctionName.CancelOrdersUpTo) { - data = exchangeInstance.cancelOrdersUpTo.getABIEncodedTransactionData(constants.ZERO_AMOUNT); + data = exchangeInstance.cancelOrdersUpTo(constants.ZERO_AMOUNT).getABIEncodedTransactionData(); } else if (fnName === ExchangeFunctionName.PreSign) { - data = exchangeInstance.preSign.getABIEncodedTransactionData(orderHashUtils.getOrderHashHex(orders[0])); + data = exchangeInstance.preSign(orderHashUtils.getOrderHashHex(orders[0])).getABIEncodedTransactionData(); } else if (fnName === ExchangeFunctionName.SetSignatureValidatorApproval) { - data = exchangeInstance.setSignatureValidatorApproval.getABIEncodedTransactionData( - constants.NULL_ADDRESS, - true, - ); + data = exchangeInstance + .setSignatureValidatorApproval(constants.NULL_ADDRESS, true) + .getABIEncodedTransactionData(); } else { throw new Error(`Error: ${fnName} not a supported function`); } diff --git a/contracts/exchange/test/utils/exchange_wrapper.ts b/contracts/exchange/test/utils/exchange_wrapper.ts index dead507440..51672aa602 100644 --- a/contracts/exchange/test/utils/exchange_wrapper.ts +++ b/contracts/exchange/test/utils/exchange_wrapper.ts @@ -24,17 +24,14 @@ export class ExchangeWrapper { opts: { takerAssetFillAmount?: BigNumber } = {}, ): Promise { const params = orderUtils.createFill(signedOrder, opts.takerAssetFillAmount); - const txReceipt = await this.exchangeContract.fillOrder.awaitTransactionSuccessAsync( - params.order, - params.takerAssetFillAmount, - params.signature, - { from }, - ); + const txReceipt = await this.exchangeContract + .fillOrder(params.order, params.takerAssetFillAmount, params.signature) + .awaitTransactionSuccessAsync({ from }); return txReceipt; } public async cancelOrderAsync(signedOrder: SignedOrder, from: string): Promise { const params = orderUtils.createCancel(signedOrder); - const txReceipt = await this.exchangeContract.cancelOrder.awaitTransactionSuccessAsync(params.order, { from }); + const txReceipt = await this.exchangeContract.cancelOrder(params.order).awaitTransactionSuccessAsync({ from }); return txReceipt; } public async fillOrKillOrderAsync( @@ -43,12 +40,9 @@ export class ExchangeWrapper { opts: { takerAssetFillAmount?: BigNumber; gasPrice?: BigNumber } = {}, ): Promise { const params = orderUtils.createFill(signedOrder, opts.takerAssetFillAmount); - const txReceipt = await this.exchangeContract.fillOrKillOrder.awaitTransactionSuccessAsync( - params.order, - params.takerAssetFillAmount, - params.signature, - { from, gasPrice: opts.gasPrice }, - ); + const txReceipt = await this.exchangeContract + .fillOrKillOrder(params.order, params.takerAssetFillAmount, params.signature) + .awaitTransactionSuccessAsync({ from, gasPrice: opts.gasPrice }); return txReceipt; } public async batchFillOrdersAsync( @@ -56,111 +50,113 @@ export class ExchangeWrapper { from: string, opts: { takerAssetFillAmounts?: BigNumber[]; gasPrice?: BigNumber } = {}, ): Promise { - return this.exchangeContract.batchFillOrders.awaitTransactionSuccessAsync( - orders, - opts.takerAssetFillAmounts === undefined - ? orders.map(signedOrder => signedOrder.takerAssetAmount) - : opts.takerAssetFillAmounts, - orders.map(signedOrder => signedOrder.signature), - { from, gasPrice: opts.gasPrice }, - ); + return this.exchangeContract + .batchFillOrders( + orders, + opts.takerAssetFillAmounts === undefined + ? orders.map(signedOrder => signedOrder.takerAssetAmount) + : opts.takerAssetFillAmounts, + orders.map(signedOrder => signedOrder.signature), + ) + .awaitTransactionSuccessAsync({ from, gasPrice: opts.gasPrice }); } public async batchFillOrKillOrdersAsync( orders: SignedOrder[], from: string, opts: { takerAssetFillAmounts?: BigNumber[]; gasPrice?: BigNumber } = {}, ): Promise { - return this.exchangeContract.batchFillOrKillOrders.awaitTransactionSuccessAsync( - orders, - opts.takerAssetFillAmounts === undefined - ? orders.map(signedOrder => signedOrder.takerAssetAmount) - : opts.takerAssetFillAmounts, - orders.map(signedOrder => signedOrder.signature), - { from, gasPrice: opts.gasPrice }, - ); + return this.exchangeContract + .batchFillOrKillOrders( + orders, + opts.takerAssetFillAmounts === undefined + ? orders.map(signedOrder => signedOrder.takerAssetAmount) + : opts.takerAssetFillAmounts, + orders.map(signedOrder => signedOrder.signature), + ) + .awaitTransactionSuccessAsync({ from, gasPrice: opts.gasPrice }); } public async batchFillOrdersNoThrowAsync( orders: SignedOrder[], from: string, opts: { takerAssetFillAmounts?: BigNumber[]; gas?: number; gasPrice?: BigNumber } = {}, ): Promise { - return this.exchangeContract.batchFillOrdersNoThrow.awaitTransactionSuccessAsync( - orders, - opts.takerAssetFillAmounts === undefined - ? orders.map(signedOrder => signedOrder.takerAssetAmount) - : opts.takerAssetFillAmounts, - orders.map(signedOrder => signedOrder.signature), - { from, gas: opts.gas, gasPrice: opts.gasPrice }, - ); + return this.exchangeContract + .batchFillOrdersNoThrow( + orders, + opts.takerAssetFillAmounts === undefined + ? orders.map(signedOrder => signedOrder.takerAssetAmount) + : opts.takerAssetFillAmounts, + orders.map(signedOrder => signedOrder.signature), + ) + .awaitTransactionSuccessAsync({ from, gas: opts.gas, gasPrice: opts.gasPrice }); } public async marketSellOrdersNoThrowAsync( orders: SignedOrder[], from: string, opts: { takerAssetFillAmount: BigNumber; gas?: number; gasPrice?: BigNumber }, ): Promise { - return this.exchangeContract.marketSellOrdersNoThrow.awaitTransactionSuccessAsync( - orders, - opts.takerAssetFillAmount, - orders.map(signedOrder => signedOrder.signature), - { from, gas: opts.gas, gasPrice: opts.gasPrice }, - ); + return this.exchangeContract + .marketSellOrdersNoThrow( + orders, + opts.takerAssetFillAmount, + orders.map(signedOrder => signedOrder.signature), + ) + .awaitTransactionSuccessAsync({ from, gas: opts.gas, gasPrice: opts.gasPrice }); } public async marketBuyOrdersNoThrowAsync( orders: SignedOrder[], from: string, opts: { makerAssetFillAmount: BigNumber; gas?: number; gasPrice?: BigNumber }, ): Promise { - return this.exchangeContract.marketBuyOrdersNoThrow.awaitTransactionSuccessAsync( - orders, - opts.makerAssetFillAmount, - orders.map(signedOrder => signedOrder.signature), - { from, gas: opts.gas }, - ); + return this.exchangeContract + .marketBuyOrdersNoThrow(orders, opts.makerAssetFillAmount, orders.map(signedOrder => signedOrder.signature)) + .awaitTransactionSuccessAsync({ from, gas: opts.gas }); } public async marketSellOrdersFillOrKillAsync( orders: SignedOrder[], from: string, opts: { takerAssetFillAmount: BigNumber; gas?: number }, ): Promise { - return this.exchangeContract.marketSellOrdersFillOrKill.awaitTransactionSuccessAsync( - orders, - opts.takerAssetFillAmount, - orders.map(signedOrder => signedOrder.signature), - { from, gas: opts.gas }, - ); + return this.exchangeContract + .marketSellOrdersFillOrKill( + orders, + opts.takerAssetFillAmount, + orders.map(signedOrder => signedOrder.signature), + ) + .awaitTransactionSuccessAsync({ from, gas: opts.gas }); } public async marketBuyOrdersFillOrKillAsync( orders: SignedOrder[], from: string, opts: { makerAssetFillAmount: BigNumber; gas?: number }, ): Promise { - return this.exchangeContract.marketBuyOrdersFillOrKill.awaitTransactionSuccessAsync( - orders, - opts.makerAssetFillAmount, - orders.map(signedOrder => signedOrder.signature), - { from, gas: opts.gas }, - ); + return this.exchangeContract + .marketBuyOrdersFillOrKill( + orders, + opts.makerAssetFillAmount, + orders.map(signedOrder => signedOrder.signature), + ) + .awaitTransactionSuccessAsync({ from, gas: opts.gas }); } public async batchCancelOrdersAsync( orders: SignedOrder[], from: string, ): Promise { - return this.exchangeContract.batchCancelOrders.awaitTransactionSuccessAsync(orders, { from }); + return this.exchangeContract.batchCancelOrders(orders).awaitTransactionSuccessAsync({ from }); } public async cancelOrdersUpToAsync(salt: BigNumber, from: string): Promise { - const txReceipt = await this.exchangeContract.cancelOrdersUpTo.awaitTransactionSuccessAsync(salt, { from }); + const txReceipt = await this.exchangeContract.cancelOrdersUpTo(salt).awaitTransactionSuccessAsync({ from }); return txReceipt; } public async registerAssetProxyAsync( assetProxyAddress: string, from: string, ): Promise { - const txReceipt = await this.exchangeContract.registerAssetProxy.awaitTransactionSuccessAsync( - assetProxyAddress, - { + const txReceipt = await this.exchangeContract + .registerAssetProxy(assetProxyAddress) + .awaitTransactionSuccessAsync({ from, - }, - ); + }); return txReceipt; } public async executeTransactionAsync( @@ -168,11 +164,9 @@ export class ExchangeWrapper { from: string, opts: { gasPrice?: BigNumber } = {}, ): Promise { - return this.exchangeContract.executeTransaction.awaitTransactionSuccessAsync( - signedTransaction, - signedTransaction.signature, - { from, gasPrice: opts.gasPrice }, - ); + return this.exchangeContract + .executeTransaction(signedTransaction, signedTransaction.signature) + .awaitTransactionSuccessAsync({ from, gasPrice: opts.gasPrice }); } public async batchExecuteTransactionsAsync( signedTransactions: SignedZeroExTransaction[], @@ -180,29 +174,27 @@ export class ExchangeWrapper { opts: { gasPrice?: BigNumber } = {}, ): Promise { const signatures = signedTransactions.map(signedTransaction => signedTransaction.signature); - return this.exchangeContract.batchExecuteTransactions.awaitTransactionSuccessAsync( - signedTransactions, - signatures, - { + return this.exchangeContract + .batchExecuteTransactions(signedTransactions, signatures) + .awaitTransactionSuccessAsync({ from, gasPrice: opts.gasPrice, - }, - ); + }); } public async getTakerAssetFilledAmountAsync(orderHashHex: string): Promise { - const filledAmount = await this.exchangeContract.filled.callAsync(orderHashHex); + const filledAmount = await this.exchangeContract.filled(orderHashHex).callAsync(); return filledAmount; } public async isCancelledAsync(orderHashHex: string): Promise { - const isCancelled = await this.exchangeContract.cancelled.callAsync(orderHashHex); + const isCancelled = await this.exchangeContract.cancelled(orderHashHex).callAsync(); return isCancelled; } public async getOrderEpochAsync(makerAddress: string, senderAddress: string): Promise { - const orderEpoch = await this.exchangeContract.orderEpoch.callAsync(makerAddress, senderAddress); + const orderEpoch = await this.exchangeContract.orderEpoch(makerAddress, senderAddress).callAsync(); return orderEpoch; } public async getOrderInfoAsync(signedOrder: SignedOrder): Promise { - const orderInfo = await this.exchangeContract.getOrderInfo.callAsync(signedOrder); + const orderInfo = await this.exchangeContract.getOrderInfo(signedOrder).callAsync(); return orderInfo; } public async batchMatchOrdersAsync( @@ -212,26 +204,18 @@ export class ExchangeWrapper { opts: { gasPrice?: BigNumber } = {}, ): Promise { const params = orderUtils.createBatchMatchOrders(signedOrdersLeft, signedOrdersRight); - return this.exchangeContract.batchMatchOrders.awaitTransactionSuccessAsync( - params.leftOrders, - params.rightOrders, - params.leftSignatures, - params.rightSignatures, - { from, gasPrice: opts.gasPrice }, - ); + return this.exchangeContract + .batchMatchOrders(params.leftOrders, params.rightOrders, params.leftSignatures, params.rightSignatures) + .awaitTransactionSuccessAsync({ from, gasPrice: opts.gasPrice }); } public async batchMatchOrdersRawAsync( params: BatchMatchOrder, from: string, opts: { gasPrice?: BigNumber } = {}, ): Promise { - return this.exchangeContract.batchMatchOrders.awaitTransactionSuccessAsync( - params.leftOrders, - params.rightOrders, - params.leftSignatures, - params.rightSignatures, - { from, gasPrice: opts.gasPrice }, - ); + return this.exchangeContract + .batchMatchOrders(params.leftOrders, params.rightOrders, params.leftSignatures, params.rightSignatures) + .awaitTransactionSuccessAsync({ from, gasPrice: opts.gasPrice }); } public async getBatchMatchOrdersResultsAsync( signedOrdersLeft: SignedOrder[], @@ -240,13 +224,9 @@ export class ExchangeWrapper { opts: { gasPrice?: BigNumber } = {}, ): Promise { const params = orderUtils.createBatchMatchOrders(signedOrdersLeft, signedOrdersRight); - const batchMatchedFillResults = await this.exchangeContract.batchMatchOrders.callAsync( - params.leftOrders, - params.rightOrders, - params.leftSignatures, - params.rightSignatures, - { from, gasPrice: opts.gasPrice }, - ); + const batchMatchedFillResults = await this.exchangeContract + .batchMatchOrders(params.leftOrders, params.rightOrders, params.leftSignatures, params.rightSignatures) + .callAsync({ from, gasPrice: opts.gasPrice }); return batchMatchedFillResults; } public async batchMatchOrdersWithMaximalFillAsync( @@ -256,26 +236,28 @@ export class ExchangeWrapper { opts: { gasPrice?: BigNumber } = {}, ): Promise { const params = orderUtils.createBatchMatchOrders(signedOrdersLeft, signedOrdersRight); - return this.exchangeContract.batchMatchOrdersWithMaximalFill.awaitTransactionSuccessAsync( - params.leftOrders, - params.rightOrders, - params.leftSignatures, - params.rightSignatures, - { from, gasPrice: opts.gasPrice }, - ); + return this.exchangeContract + .batchMatchOrdersWithMaximalFill( + params.leftOrders, + params.rightOrders, + params.leftSignatures, + params.rightSignatures, + ) + .awaitTransactionSuccessAsync({ from, gasPrice: opts.gasPrice }); } public async batchMatchOrdersWithMaximalFillRawAsync( params: BatchMatchOrder, from: string, opts: { gasPrice?: BigNumber } = {}, ): Promise { - return this.exchangeContract.batchMatchOrdersWithMaximalFill.awaitTransactionSuccessAsync( - params.leftOrders, - params.rightOrders, - params.leftSignatures, - params.rightSignatures, - { from, gasPrice: opts.gasPrice }, - ); + return this.exchangeContract + .batchMatchOrdersWithMaximalFill( + params.leftOrders, + params.rightOrders, + params.leftSignatures, + params.rightSignatures, + ) + .awaitTransactionSuccessAsync({ from, gasPrice: opts.gasPrice }); } public async getBatchMatchOrdersWithMaximalFillResultsAsync( signedOrdersLeft: SignedOrder[], @@ -284,13 +266,14 @@ export class ExchangeWrapper { opts: { gasPrice?: BigNumber } = {}, ): Promise { const params = orderUtils.createBatchMatchOrders(signedOrdersLeft, signedOrdersRight); - const batchMatchedFillResults = await this.exchangeContract.batchMatchOrdersWithMaximalFill.callAsync( - params.leftOrders, - params.rightOrders, - params.leftSignatures, - params.rightSignatures, - { from, gasPrice: opts.gasPrice }, - ); + const batchMatchedFillResults = await this.exchangeContract + .batchMatchOrdersWithMaximalFill( + params.leftOrders, + params.rightOrders, + params.leftSignatures, + params.rightSignatures, + ) + .callAsync({ from, gasPrice: opts.gasPrice }); return batchMatchedFillResults; } public async matchOrdersAsync( @@ -300,13 +283,9 @@ export class ExchangeWrapper { opts: { gasPrice?: BigNumber } = {}, ): Promise { const params = orderUtils.createMatchOrders(signedOrderLeft, signedOrderRight); - const txReceipt = await this.exchangeContract.matchOrders.awaitTransactionSuccessAsync( - params.left, - params.right, - params.leftSignature, - params.rightSignature, - { from, gasPrice: opts.gasPrice }, - ); + const txReceipt = await this.exchangeContract + .matchOrders(params.left, params.right, params.leftSignature, params.rightSignature) + .awaitTransactionSuccessAsync({ from, gasPrice: opts.gasPrice }); return txReceipt; } public async getMatchOrdersResultsAsync( @@ -316,13 +295,9 @@ export class ExchangeWrapper { opts: { gasPrice?: BigNumber } = {}, ): Promise { const params = orderUtils.createMatchOrders(signedOrderLeft, signedOrderRight); - const matchedFillResults = await this.exchangeContract.matchOrders.callAsync( - params.left, - params.right, - params.leftSignature, - params.rightSignature, - { from, gasPrice: opts.gasPrice }, - ); + const matchedFillResults = await this.exchangeContract + .matchOrders(params.left, params.right, params.leftSignature, params.rightSignature) + .callAsync({ from, gasPrice: opts.gasPrice }); return matchedFillResults; } public async matchOrdersWithMaximalFillAsync( @@ -332,13 +307,9 @@ export class ExchangeWrapper { opts: { gasPrice?: BigNumber } = {}, ): Promise { const params = orderUtils.createMatchOrders(signedOrderLeft, signedOrderRight); - return this.exchangeContract.matchOrdersWithMaximalFill.awaitTransactionSuccessAsync( - params.left, - params.right, - params.leftSignature, - params.rightSignature, - { from, gasPrice: opts.gasPrice }, - ); + return this.exchangeContract + .matchOrdersWithMaximalFill(params.left, params.right, params.leftSignature, params.rightSignature) + .awaitTransactionSuccessAsync({ from, gasPrice: opts.gasPrice }); } public async getMatchOrdersWithMaximalFillResultsAsync( signedOrderLeft: SignedOrder, @@ -347,13 +318,9 @@ export class ExchangeWrapper { opts: { gasPrice?: BigNumber }, ): Promise { const params = orderUtils.createMatchOrders(signedOrderLeft, signedOrderRight); - const matchedFillResults = await this.exchangeContract.matchOrdersWithMaximalFill.callAsync( - params.left, - params.right, - params.leftSignature, - params.rightSignature, - { from, gasPrice: opts.gasPrice }, - ); + const matchedFillResults = await this.exchangeContract + .matchOrdersWithMaximalFill(params.left, params.right, params.leftSignature, params.rightSignature) + .callAsync({ from, gasPrice: opts.gasPrice }); return matchedFillResults; } public async getFillOrderResultsAsync( @@ -362,21 +329,16 @@ export class ExchangeWrapper { opts: { takerAssetFillAmount?: BigNumber; gasPrice?: BigNumber } = {}, ): Promise { const params = orderUtils.createFill(signedOrder, opts.takerAssetFillAmount); - const fillResults = await this.exchangeContract.fillOrder.callAsync( - params.order, - params.takerAssetFillAmount, - params.signature, - { from, gasPrice: opts.gasPrice }, - ); + const fillResults = await this.exchangeContract + .fillOrder(params.order, params.takerAssetFillAmount, params.signature) + .callAsync({ from, gasPrice: opts.gasPrice }); return fillResults; } public abiEncodeFillOrder(signedOrder: SignedOrder, opts: { takerAssetFillAmount?: BigNumber } = {}): string { const params = orderUtils.createFill(signedOrder, opts.takerAssetFillAmount); - const data = this.exchangeContract.fillOrder.getABIEncodedTransactionData( - params.order, - params.takerAssetFillAmount, - params.signature, - ); + const data = this.exchangeContract + .fillOrder(params.order, params.takerAssetFillAmount, params.signature) + .getABIEncodedTransactionData(); return data; } public abiDecodeFillOrder(data: string): AbiDecodedFillOrderData { diff --git a/contracts/exchange/test/utils/fill_order_combinatorial_utils.ts b/contracts/exchange/test/utils/fill_order_combinatorial_utils.ts index 006088efea..3f6c9dbd8b 100644 --- a/contracts/exchange/test/utils/fill_order_combinatorial_utils.ts +++ b/contracts/exchange/test/utils/fill_order_combinatorial_utils.ts @@ -125,37 +125,37 @@ export async function fillOrderCombinatorialUtilsFactoryAsync( await exchangeWrapper.registerAssetProxyAsync(erc1155Proxy.address, ownerAddress); await exchangeWrapper.registerAssetProxyAsync(multiAssetProxy.address, ownerAddress); - await erc20Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(exchangeContract.address, { + await erc20Proxy.addAuthorizedAddress(exchangeContract.address).awaitTransactionSuccessAsync({ from: ownerAddress, }); - await erc721Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(exchangeContract.address, { + await erc721Proxy.addAuthorizedAddress(exchangeContract.address).awaitTransactionSuccessAsync({ from: ownerAddress, }); - await erc1155Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(exchangeContract.address, { + await erc1155Proxy.addAuthorizedAddress(exchangeContract.address).awaitTransactionSuccessAsync({ from: ownerAddress, }); - await multiAssetProxy.addAuthorizedAddress.awaitTransactionSuccessAsync(exchangeContract.address, { + await multiAssetProxy.addAuthorizedAddress(exchangeContract.address).awaitTransactionSuccessAsync({ from: ownerAddress, }); - await erc20Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(multiAssetProxy.address, { from: ownerAddress }); + await erc20Proxy.addAuthorizedAddress(multiAssetProxy.address).awaitTransactionSuccessAsync({ from: ownerAddress }); - await erc721Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(multiAssetProxy.address, { + await erc721Proxy.addAuthorizedAddress(multiAssetProxy.address).awaitTransactionSuccessAsync({ from: ownerAddress, }); - await erc1155Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(multiAssetProxy.address, { + await erc1155Proxy.addAuthorizedAddress(multiAssetProxy.address).awaitTransactionSuccessAsync({ from: ownerAddress, }); - await multiAssetProxy.registerAssetProxy.awaitTransactionSuccessAsync(erc20Proxy.address, { from: ownerAddress }); + await multiAssetProxy.registerAssetProxy(erc20Proxy.address).awaitTransactionSuccessAsync({ from: ownerAddress }); - await multiAssetProxy.registerAssetProxy.awaitTransactionSuccessAsync(erc721Proxy.address, { from: ownerAddress }); + await multiAssetProxy.registerAssetProxy(erc721Proxy.address).awaitTransactionSuccessAsync({ from: ownerAddress }); - await multiAssetProxy.registerAssetProxy.awaitTransactionSuccessAsync(erc1155Proxy.address, { from: ownerAddress }); + await multiAssetProxy.registerAssetProxy(erc1155Proxy.address).awaitTransactionSuccessAsync({ from: ownerAddress }); const orderFactory = new OrderFactoryFromScenario( devUtils, diff --git a/contracts/exchange/test/utils/isolated_exchange_wrapper.ts b/contracts/exchange/test/utils/isolated_exchange_wrapper.ts index 0d6f948068..e1ea62b01e 100644 --- a/contracts/exchange/test/utils/isolated_exchange_wrapper.ts +++ b/contracts/exchange/test/utils/isolated_exchange_wrapper.ts @@ -1,10 +1,4 @@ -import { - constants, - filterLogsToArguments, - MutatorContractFunction, - TransactionHelper, - txDefaults as testTxDefaults, -} from '@0x/contracts-test-utils'; +import { constants, filterLogsToArguments, txDefaults as testTxDefaults } from '@0x/contracts-test-utils'; import { orderHashUtils } from '@0x/order-utils'; import { FillResults, Order, OrderInfo, SignatureType } from '@0x/types'; import { BigNumber } from '@0x/utils'; @@ -40,7 +34,6 @@ export const DEFAULT_BAD_SIGNATURE = createBadSignature(); export class IsolatedExchangeWrapper { public static readonly CHAIN_ID = 1337; public readonly instance: IsolatedExchangeContract; - public readonly txHelper: TransactionHelper; public lastTxEvents: IsolatedExchangeEvents = createEmptyEvents(); public lastTxBalanceChanges: AssetBalances = {}; @@ -70,19 +63,18 @@ export class IsolatedExchangeWrapper { public constructor(web3Wrapper: Web3Wrapper, instance: IsolatedExchangeContract) { this.instance = instance; - this.txHelper = new TransactionHelper(web3Wrapper, artifacts); } public async getTakerAssetFilledAmountAsync(order: Order): Promise { - return this.instance.filled.callAsync(this.getOrderHash(order)); + return this.instance.filled(this.getOrderHash(order)).callAsync(); } public async cancelOrderAsync(order: Order, txOpts?: TxData): Promise { - await this.instance.cancelOrder.awaitTransactionSuccessAsync(order, txOpts); + await this.instance.cancelOrder(order).awaitTransactionSuccessAsync(txOpts); } public async cancelOrdersUpToAsync(epoch: BigNumber, txOpts?: TxData): Promise { - await this.instance.cancelOrdersUpTo.awaitTransactionSuccessAsync(epoch, txOpts); + await this.instance.cancelOrdersUpTo(epoch).awaitTransactionSuccessAsync(txOpts); } public async fillOrderAsync( @@ -91,13 +83,14 @@ export class IsolatedExchangeWrapper { signature: string = DEFAULT_GOOD_SIGNATURE, txOpts?: TxData, ): Promise { - return this._runFillContractFunctionAsync( - this.instance.fillOrder, - order, - new BigNumber(takerAssetFillAmount), - signature, - txOpts, - ); + this.lastTxEvents = createEmptyEvents(); + this.lastTxBalanceChanges = {}; + const fillOrderFn = this.instance.fillOrder(order, new BigNumber(takerAssetFillAmount), signature); + const result = await fillOrderFn.callAsync(); + const receipt = await fillOrderFn.awaitTransactionSuccessAsync(txOpts); + this.lastTxEvents = extractEvents(receipt.logs); + this.lastTxBalanceChanges = getBalanceChangesFromTransferFromCalls(this.lastTxEvents.transferFromCalls); + return result; } public getOrderHash(order: Order): string { @@ -109,7 +102,7 @@ export class IsolatedExchangeWrapper { } public async getOrderInfoAsync(order: Order): Promise { - return this.instance.getOrderInfo.callAsync(order); + return this.instance.getOrderInfo(order).callAsync(); } public getBalanceChange(assetData: string, address: string): BigNumber { @@ -121,23 +114,6 @@ export class IsolatedExchangeWrapper { } return constants.ZERO_AMOUNT; } - - protected async _runFillContractFunctionAsync< - TCallAsyncArgs extends any[], - TAwaitTransactionSuccessAsyncArgs extends any[], - TResult - >( - contractFunction: MutatorContractFunction, - // tslint:disable-next-line: trailing-comma - ...args: TAwaitTransactionSuccessAsyncArgs - ): Promise { - this.lastTxEvents = createEmptyEvents(); - this.lastTxBalanceChanges = {}; - const [result, receipt] = await this.txHelper.getResultAndReceiptAsync(contractFunction, ...args); - this.lastTxEvents = extractEvents(receipt.logs); - this.lastTxBalanceChanges = getBalanceChangesFromTransferFromCalls(this.lastTxEvents.transferFromCalls); - return result; - } } /** diff --git a/contracts/exchange/test/utils/match_order_tester.ts b/contracts/exchange/test/utils/match_order_tester.ts index 3fe9ff906a..e8ec9a42b0 100644 --- a/contracts/exchange/test/utils/match_order_tester.ts +++ b/contracts/exchange/test/utils/match_order_tester.ts @@ -631,11 +631,11 @@ async function transferAssetAsync( matchResults: MatchResults, devUtils: DevUtilsContract, ): Promise { - const assetProxyId = await devUtils.decodeAssetProxyId.callAsync(assetData); + const assetProxyId = await devUtils.decodeAssetProxyId(assetData).callAsync(); switch (assetProxyId) { case AssetProxyId.ERC20: { // tslint:disable-next-line:no-unused-variable - const [proxyId, assetAddress] = await devUtils.decodeERC20AssetData.callAsync(assetData); // tslint:disable-line-no-unused-variable + const [proxyId, assetAddress] = await devUtils.decodeERC20AssetData(assetData).callAsync(); // tslint:disable-line-no-unused-variable const fromBalances = matchResults.balances.erc20[fromAddress]; const toBalances = matchResults.balances.erc20[toAddress]; fromBalances[assetAddress] = fromBalances[assetAddress].minus(amount); @@ -644,7 +644,7 @@ async function transferAssetAsync( } case AssetProxyId.ERC721: { // tslint:disable-next-line:no-unused-variable - const [proxyId, assetAddress, tokenId] = await devUtils.decodeERC721AssetData.callAsync(assetData); // tslint:disable-line-no-unused-variable + const [proxyId, assetAddress, tokenId] = await devUtils.decodeERC721AssetData(assetData).callAsync(); // tslint:disable-line-no-unused-variable const fromTokens = matchResults.balances.erc721[fromAddress][assetAddress]; const toTokens = matchResults.balances.erc721[toAddress][assetAddress]; if (amount.gte(1)) { @@ -658,9 +658,9 @@ async function transferAssetAsync( } case AssetProxyId.ERC1155: { // tslint:disable-next-line:no-unused-variable - const [proxyId, assetAddress, tokenIds, tokenValues] = await devUtils.decodeERC1155AssetData.callAsync( - assetData, - ); + const [proxyId, assetAddress, tokenIds, tokenValues] = await devUtils + .decodeERC1155AssetData(assetData) + .callAsync(); const fromBalances = matchResults.balances.erc1155[fromAddress][assetAddress]; const toBalances = matchResults.balances.erc1155[toAddress][assetAddress]; for (const i of _.times(tokenIds.length)) { @@ -685,7 +685,7 @@ async function transferAssetAsync( } case AssetProxyId.MultiAsset: { // tslint:disable-next-line:no-unused-variable - const [proxyId, amounts, nestedAssetData] = await devUtils.decodeMultiAssetData.callAsync(assetData); // tslint:disable-line-no-unused-variable + const [proxyId, amounts, nestedAssetData] = await devUtils.decodeMultiAssetData(assetData).callAsync(); // tslint:disable-line-no-unused-variable for (const i of _.times(amounts.length)) { const nestedAmount = amount.times(amounts[i]); const _nestedAssetData = nestedAssetData[i]; diff --git a/contracts/exchange/test/utils/order_factory_from_scenario.ts b/contracts/exchange/test/utils/order_factory_from_scenario.ts index b25a5a85ab..9b0f510f25 100644 --- a/contracts/exchange/test/utils/order_factory_from_scenario.ts +++ b/contracts/exchange/test/utils/order_factory_from_scenario.ts @@ -96,52 +96,59 @@ export class OrderFactoryFromScenario { switch (orderScenario.makerAssetDataScenario) { case AssetDataScenario.ERC20EighteenDecimals: - makerAssetData = await this._devUtils.encodeERC20AssetData.callAsync( - this._erc20EighteenDecimalTokenAddresses[0], - ); + makerAssetData = await this._devUtils + .encodeERC20AssetData(this._erc20EighteenDecimalTokenAddresses[0]) + .callAsync(); break; case AssetDataScenario.ERC20FiveDecimals: - makerAssetData = await this._devUtils.encodeERC20AssetData.callAsync( - this._erc20FiveDecimalTokenAddresses[0], - ); + makerAssetData = await this._devUtils + .encodeERC20AssetData(this._erc20FiveDecimalTokenAddresses[0]) + .callAsync(); break; case AssetDataScenario.ERC721: - makerAssetData = await this._devUtils.encodeERC721AssetData.callAsync( - this._erc721TokenAddress, - erc721MakerAssetIds[0], - ); + makerAssetData = await this._devUtils + .encodeERC721AssetData(this._erc721TokenAddress, erc721MakerAssetIds[0]) + .callAsync(); break; case AssetDataScenario.ERC20ZeroDecimals: - makerAssetData = await this._devUtils.encodeERC20AssetData.callAsync( - this._erc20ZeroDecimalTokenAddresses[0], - ); + makerAssetData = await this._devUtils + .encodeERC20AssetData(this._erc20ZeroDecimalTokenAddresses[0]) + .callAsync(); break; case AssetDataScenario.ERC1155Fungible: - makerAssetData = await this._devUtils.encodeERC1155AssetData.callAsync( - this._erc1155TokenAddress, - [erc1155FungibleMakerTokenIds[0]], - [ONE_UNITS_ZERO_DECIMALS], - erc1155CallbackData, - ); + makerAssetData = await this._devUtils + .encodeERC1155AssetData( + this._erc1155TokenAddress, + [erc1155FungibleMakerTokenIds[0]], + [ONE_UNITS_ZERO_DECIMALS], + erc1155CallbackData, + ) + .callAsync(); break; case AssetDataScenario.ERC1155NonFungible: - makerAssetData = await this._devUtils.encodeERC1155AssetData.callAsync( - this._erc1155TokenAddress, - [erc1155NonFungibleMakerTokenIds[0]], - [ONE_UNITS_ZERO_DECIMALS], - erc1155CallbackData, - ); + makerAssetData = await this._devUtils + .encodeERC1155AssetData( + this._erc1155TokenAddress, + [erc1155NonFungibleMakerTokenIds[0]], + [ONE_UNITS_ZERO_DECIMALS], + erc1155CallbackData, + ) + .callAsync(); break; case AssetDataScenario.MultiAssetERC20: - makerAssetData = await this._devUtils.encodeMultiAssetData.callAsync( - [ONE_UNITS_EIGHTEEN_DECIMALS, ONE_UNITS_FIVE_DECIMALS], - [ - await this._devUtils.encodeERC20AssetData.callAsync( - this._erc20EighteenDecimalTokenAddresses[0], - ), - await this._devUtils.encodeERC20AssetData.callAsync(this._erc20FiveDecimalTokenAddresses[0]), - ], - ); + makerAssetData = await this._devUtils + .encodeMultiAssetData( + [ONE_UNITS_EIGHTEEN_DECIMALS, ONE_UNITS_FIVE_DECIMALS], + [ + await this._devUtils + .encodeERC20AssetData(this._erc20EighteenDecimalTokenAddresses[0]) + .callAsync(), + await this._devUtils + .encodeERC20AssetData(this._erc20FiveDecimalTokenAddresses[0]) + .callAsync(), + ], + ) + .callAsync(); break; default: throw errorUtils.spawnSwitchErr('AssetDataScenario', orderScenario.makerAssetDataScenario); @@ -149,52 +156,59 @@ export class OrderFactoryFromScenario { switch (orderScenario.takerAssetDataScenario) { case AssetDataScenario.ERC20EighteenDecimals: - takerAssetData = await this._devUtils.encodeERC20AssetData.callAsync( - this._erc20EighteenDecimalTokenAddresses[1], - ); + takerAssetData = await this._devUtils + .encodeERC20AssetData(this._erc20EighteenDecimalTokenAddresses[1]) + .callAsync(); break; case AssetDataScenario.ERC20FiveDecimals: - takerAssetData = await this._devUtils.encodeERC20AssetData.callAsync( - this._erc20FiveDecimalTokenAddresses[1], - ); + takerAssetData = await this._devUtils + .encodeERC20AssetData(this._erc20FiveDecimalTokenAddresses[1]) + .callAsync(); break; case AssetDataScenario.ERC721: - takerAssetData = await this._devUtils.encodeERC721AssetData.callAsync( - this._erc721TokenAddress, - erc721TakerAssetIds[0], - ); + takerAssetData = await this._devUtils + .encodeERC721AssetData(this._erc721TokenAddress, erc721TakerAssetIds[0]) + .callAsync(); break; case AssetDataScenario.ERC20ZeroDecimals: - takerAssetData = await this._devUtils.encodeERC20AssetData.callAsync( - this._erc20ZeroDecimalTokenAddresses[1], - ); + takerAssetData = await this._devUtils + .encodeERC20AssetData(this._erc20ZeroDecimalTokenAddresses[1]) + .callAsync(); break; case AssetDataScenario.ERC1155Fungible: - takerAssetData = await this._devUtils.encodeERC1155AssetData.callAsync( - this._erc1155TokenAddress, - [erc1155FungibleTakerTokenIds[1]], - [ONE_UNITS_ZERO_DECIMALS], - erc1155CallbackData, - ); + takerAssetData = await this._devUtils + .encodeERC1155AssetData( + this._erc1155TokenAddress, + [erc1155FungibleTakerTokenIds[1]], + [ONE_UNITS_ZERO_DECIMALS], + erc1155CallbackData, + ) + .callAsync(); break; case AssetDataScenario.ERC1155NonFungible: - takerAssetData = await this._devUtils.encodeERC1155AssetData.callAsync( - this._erc1155TokenAddress, - [erc1155NonFungibleTakerTokenIds[0]], - [ONE_UNITS_ZERO_DECIMALS], - erc1155CallbackData, - ); + takerAssetData = await this._devUtils + .encodeERC1155AssetData( + this._erc1155TokenAddress, + [erc1155NonFungibleTakerTokenIds[0]], + [ONE_UNITS_ZERO_DECIMALS], + erc1155CallbackData, + ) + .callAsync(); break; case AssetDataScenario.MultiAssetERC20: - takerAssetData = await this._devUtils.encodeMultiAssetData.callAsync( - [ONE_UNITS_EIGHTEEN_DECIMALS, ONE_UNITS_FIVE_DECIMALS], - [ - await this._devUtils.encodeERC20AssetData.callAsync( - this._erc20EighteenDecimalTokenAddresses[1], - ), - await this._devUtils.encodeERC20AssetData.callAsync(this._erc20FiveDecimalTokenAddresses[1]), - ], - ); + takerAssetData = await this._devUtils + .encodeMultiAssetData( + [ONE_UNITS_EIGHTEEN_DECIMALS, ONE_UNITS_FIVE_DECIMALS], + [ + await this._devUtils + .encodeERC20AssetData(this._erc20EighteenDecimalTokenAddresses[1]) + .callAsync(), + await this._devUtils + .encodeERC20AssetData(this._erc20FiveDecimalTokenAddresses[1]) + .callAsync(), + ], + ) + .callAsync(); break; default: throw errorUtils.spawnSwitchErr('AssetDataScenario', orderScenario.takerAssetDataScenario); @@ -327,53 +341,61 @@ export class OrderFactoryFromScenario { case FeeAssetDataScenario.ERC20EighteenDecimals: return [ feeAmount, - await this._devUtils.encodeERC20AssetData.callAsync(erc20EighteenDecimalTokenAddress), + await this._devUtils.encodeERC20AssetData(erc20EighteenDecimalTokenAddress).callAsync(), ]; case FeeAssetDataScenario.ERC20FiveDecimals: return [ feeAmount, - await this._devUtils.encodeERC20AssetData.callAsync(erc20FiveDecimalTokenAddress), + await this._devUtils.encodeERC20AssetData(erc20FiveDecimalTokenAddress).callAsync(), ]; case FeeAssetDataScenario.ERC20ZeroDecimals: return [ feeAmount, - await this._devUtils.encodeERC20AssetData.callAsync(erc20ZeroDecimalTokenAddress), + await this._devUtils.encodeERC20AssetData(erc20ZeroDecimalTokenAddress).callAsync(), ]; case FeeAssetDataScenario.ERC721: return [ feeAmount, - await this._devUtils.encodeERC721AssetData.callAsync(this._erc721TokenAddress, erc721AssetId), + await this._devUtils.encodeERC721AssetData(this._erc721TokenAddress, erc721AssetId).callAsync(), ]; case FeeAssetDataScenario.ERC1155Fungible: return [ feeAmount, - await this._devUtils.encodeERC1155AssetData.callAsync( - this._erc1155TokenAddress, - [erc1155FungibleTokenId], - [ONE_UNITS_ZERO_DECIMALS], - erc1155CallbackData, - ), + await this._devUtils + .encodeERC1155AssetData( + this._erc1155TokenAddress, + [erc1155FungibleTokenId], + [ONE_UNITS_ZERO_DECIMALS], + erc1155CallbackData, + ) + .callAsync(), ]; case FeeAssetDataScenario.ERC1155NonFungible: return [ feeAmount, - await this._devUtils.encodeERC1155AssetData.callAsync( - this._erc1155TokenAddress, - [erc1155NonFungibleAssetId], - [ONE_UNITS_ZERO_DECIMALS], - erc1155CallbackData, - ), + await this._devUtils + .encodeERC1155AssetData( + this._erc1155TokenAddress, + [erc1155NonFungibleAssetId], + [ONE_UNITS_ZERO_DECIMALS], + erc1155CallbackData, + ) + .callAsync(), ]; case FeeAssetDataScenario.MultiAssetERC20: return [ feeAmount, - await this._devUtils.encodeMultiAssetData.callAsync( - [POINT_ZERO_FIVE_UNITS_EIGHTEEN_DECIMALS, POINT_ZERO_FIVE_UNITS_FIVE_DECIMALS], - [ - await this._devUtils.encodeERC20AssetData.callAsync(erc20EighteenDecimalTokenAddress), - await this._devUtils.encodeERC20AssetData.callAsync(erc20FiveDecimalTokenAddress), - ], - ), + await this._devUtils + .encodeMultiAssetData( + [POINT_ZERO_FIVE_UNITS_EIGHTEEN_DECIMALS, POINT_ZERO_FIVE_UNITS_FIVE_DECIMALS], + [ + await this._devUtils + .encodeERC20AssetData(erc20EighteenDecimalTokenAddress) + .callAsync(), + await this._devUtils.encodeERC20AssetData(erc20FiveDecimalTokenAddress).callAsync(), + ], + ) + .callAsync(), ]; default: throw errorUtils.spawnSwitchErr('FeeAssetDataScenario', feeAssetDataScenario); diff --git a/contracts/exchange/test/wrapper_unit_tests.ts b/contracts/exchange/test/wrapper_unit_tests.ts index 13ae715025..69ebd113c7 100644 --- a/contracts/exchange/test/wrapper_unit_tests.ts +++ b/contracts/exchange/test/wrapper_unit_tests.ts @@ -1,1329 +1,1327 @@ -import { ReferenceFunctions as LibReferenceFunctions } from '@0x/contracts-exchange-libs'; -import { - blockchainTests, - constants, - describe, - expect, - hexRandom, - MutatorContractFunction, - TransactionHelper, -} from '@0x/contracts-test-utils'; -import { ReferenceFunctions as UtilReferenceFunctions } from '@0x/contracts-utils'; -import { ExchangeRevertErrors, orderHashUtils } from '@0x/order-utils'; -import { FillResults, Order } from '@0x/types'; -import { AnyRevertError, BigNumber, SafeMathRevertErrors, StringRevertError } from '@0x/utils'; -import { LogEntry, LogWithDecodedArgs } from 'ethereum-types'; -import * as ethjs from 'ethereumjs-util'; -import * as _ from 'lodash'; - -import { - artifacts, - TestWrapperFunctionsCancelOrderCalledEventArgs as CancelOrderCalledEventArgs, - TestWrapperFunctionsContract, - TestWrapperFunctionsFillOrderCalledEventArgs as FillOrderCalledEventArgs, -} from '../src'; - -blockchainTests('Exchange wrapper functions unit tests.', env => { - const CHAIN_ID = 0x74657374; - const { ONE_ETHER, MAX_UINT256 } = constants; - const { addFillResults, getPartialAmountFloor } = LibReferenceFunctions; - const { safeSub } = UtilReferenceFunctions; - const protocolFeeMultiplier = new BigNumber(150000); - const randomAddress = () => hexRandom(constants.ADDRESS_LENGTH); - const randomAssetData = () => hexRandom(34); - const randomAmount = (maxAmount: BigNumber = ONE_ETHER) => maxAmount.times(_.random(0, 100, true).toFixed(12)); - const randomTimestamp = () => new BigNumber(Math.floor(_.now() / 1000) + _.random(0, 34560)); - const randomSalt = () => new BigNumber(hexRandom(constants.WORD_LENGTH).substr(2), 16); - const ALWAYS_FAILING_SALT = constants.MAX_UINT256; - const ALWAYS_FAILING_SALT_REVERT_ERROR = new StringRevertError('ALWAYS_FAILING_SALT'); - const EMPTY_FILL_RESULTS = { - makerAssetFilledAmount: constants.ZERO_AMOUNT, - takerAssetFilledAmount: constants.ZERO_AMOUNT, - makerFeePaid: constants.ZERO_AMOUNT, - takerFeePaid: constants.ZERO_AMOUNT, - protocolFeePaid: constants.ZERO_AMOUNT, - }; - let testContract: TestWrapperFunctionsContract; - let txHelper: TransactionHelper; - let owner: string; - let senderAddress: string; - - before(async () => { - [owner, senderAddress] = await env.getAccountAddressesAsync(); - txHelper = new TransactionHelper(env.web3Wrapper, artifacts); - testContract = await TestWrapperFunctionsContract.deployFrom0xArtifactAsync( - artifacts.TestWrapperFunctions, - env.provider, - { - ...env.txDefaults, - from: owner, - }, - {}, - ); - - // Set the protocol fee multiplier. - await testContract.setProtocolFeeMultiplier.awaitTransactionSuccessAsync(protocolFeeMultiplier, { - from: owner, - }); - }); - - function randomOrder(fields?: Partial): Order { - return { - makerAddress: randomAddress(), - takerAddress: randomAddress(), - feeRecipientAddress: randomAddress(), - senderAddress: randomAddress(), - takerAssetAmount: randomAmount(), - makerAssetAmount: randomAmount(), - makerFee: randomAmount(), - takerFee: randomAmount(), - expirationTimeSeconds: randomTimestamp(), - salt: randomSalt(), - makerAssetData: randomAssetData(), - takerAssetData: randomAssetData(), - makerFeeAssetData: randomAssetData(), - takerFeeAssetData: randomAssetData(), - exchangeAddress: constants.NULL_ADDRESS, - chainId: CHAIN_ID, - ...(fields || {}), - }; - } - - // Computes the expected (fake) fill results from `TestWrapperFunctions` `_fillOrder` implementation. - function getExpectedFillResults(order: Order, signature: string): FillResults { - if (order.salt === ALWAYS_FAILING_SALT) { - return EMPTY_FILL_RESULTS; - } - return { - makerAssetFilledAmount: order.makerAssetAmount, - takerAssetFilledAmount: order.takerAssetAmount, - makerFeePaid: order.makerFee, - takerFeePaid: order.takerFee, - protocolFeePaid: protocolFeeMultiplier, - }; - } - - // Creates a deterministic order signature, even though no signature validation - // actually occurs in the test contract. - function createOrderSignature(order: Order): string { - return ethjs.bufferToHex(ethjs.sha3(ethjs.toBuffer(orderHashUtils.getOrderHashHex(order)))); - } - - // Asserts that `_fillOrder()` was called in the same order and with the same - // arguments as given by examining receipt logs. - function assertFillOrderCallsFromLogs(logs: LogEntry[], calls: Array<[Order, BigNumber, string]>): void { - expect(logs.length).to.eq(calls.length); - for (const i of _.times(calls.length)) { - const log = (logs[i] as any) as LogWithDecodedArgs; - const [expectedOrder, expectedTakerAssetFillAmount, expectedSignature] = calls[i]; - expect(log.event).to.eq('FillOrderCalled'); - assertSameOrderFromEvent(log.args.order as any, expectedOrder); - expect(log.args.takerAssetFillAmount).to.bignumber.eq(expectedTakerAssetFillAmount); - expect(log.args.signature).to.eq(expectedSignature); - } - } - - function assertSameOrderFromEvent(actual: any[], expected: Order): void { - expect(actual.length === 14); - expect(actual[0].toLowerCase()).to.be.eq(expected.makerAddress); - expect(actual[1].toLowerCase()).to.be.eq(expected.takerAddress); - expect(actual[2].toLowerCase()).to.be.eq(expected.feeRecipientAddress); - expect(actual[3].toLowerCase()).to.be.eq(expected.senderAddress); - expect(actual[4]).to.be.bignumber.eq(expected.makerAssetAmount); - expect(actual[5]).to.be.bignumber.eq(expected.takerAssetAmount); - expect(actual[6]).to.be.bignumber.eq(expected.makerFee); - expect(actual[7]).to.be.bignumber.eq(expected.takerFee); - expect(actual[8]).to.be.bignumber.eq(expected.expirationTimeSeconds); - expect(actual[9]).to.be.bignumber.eq(expected.salt); - expect(actual[10]).to.be.eq(expected.makerAssetData); - expect(actual[11]).to.be.eq(expected.takerAssetData); - expect(actual[12]).to.be.eq(expected.makerFeeAssetData); - expect(actual[13]).to.be.eq(expected.takerFeeAssetData); - } - - describe('fillOrKillOrder', () => { - it('works if the order is filled by exactly `takerAssetFillAmount`', async () => { - const fillAmount = randomAmount(); - const order = randomOrder({ - // `_fillOrder()` is overridden to always return `order.takerAssetAmount` as - // the `takerAssetFilledAmount`. - takerAssetAmount: fillAmount, - }); - const signature = createOrderSignature(order); - const expectedResult = getExpectedFillResults(order, signature); - const expectedCalls = [[order, fillAmount, signature]]; - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - testContract.fillOrKillOrder, - order, - fillAmount, - signature, - ); - expect(actualResult).to.deep.eq(expectedResult); - assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); - }); - - it('reverts if the order is filled by less than `takerAssetFillAmount`', async () => { - const fillAmount = randomAmount(); - const order = randomOrder({ - // `_fillOrder()` is overridden to always return `order.takerAssetAmount` as - // the `takerAssetFilledAmount`. - takerAssetAmount: fillAmount.minus(1), - }); - const signature = createOrderSignature(order); - const expectedError = new ExchangeRevertErrors.IncompleteFillError( - ExchangeRevertErrors.IncompleteFillErrorCode.IncompleteFillOrder, - fillAmount, - fillAmount.minus(1), - ); - const tx = testContract.fillOrKillOrder.awaitTransactionSuccessAsync(order, fillAmount, signature); - return expect(tx).to.revertWith(expectedError); - }); - - it('reverts if the order is filled by greater than `takerAssetFillAmount`', async () => { - const fillAmount = randomAmount(); - const order = randomOrder({ - // `_fillOrder()` is overridden to always return `order.takerAssetAmount` as - // the `takerAssetFilledAmount`. - takerAssetAmount: fillAmount.plus(1), - }); - const signature = createOrderSignature(order); - const expectedError = new ExchangeRevertErrors.IncompleteFillError( - ExchangeRevertErrors.IncompleteFillErrorCode.IncompleteFillOrder, - fillAmount, - fillAmount.plus(1), - ); - const tx = testContract.fillOrKillOrder.awaitTransactionSuccessAsync(order, fillAmount, signature); - return expect(tx).to.revertWith(expectedError); - }); - - it('reverts if `_fillOrder()` reverts', async () => { - const fillAmount = randomAmount(); - const order = randomOrder({ - salt: ALWAYS_FAILING_SALT, - }); - const signature = createOrderSignature(order); - const expectedError = ALWAYS_FAILING_SALT_REVERT_ERROR; - const tx = testContract.fillOrKillOrder.awaitTransactionSuccessAsync(order, fillAmount, signature); - return expect(tx).to.revertWith(expectedError); - }); - }); - - describe('fillOrderNoThrow', () => { - it('calls `fillOrder()` and returns its result', async () => { - const fillAmount = randomAmount(); - const order = randomOrder(); - const signature = createOrderSignature(order); - const expectedResult = getExpectedFillResults(order, signature); - const expectedCalls = [[order, fillAmount, signature]]; - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - testContract.fillOrderNoThrow, - order, - fillAmount, - signature, - ); - expect(actualResult).to.deep.eq(expectedResult); - assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); - }); - - it('does not revert if `fillOrder()` reverts', async () => { - const fillAmount = randomAmount(); - const order = randomOrder({ - salt: ALWAYS_FAILING_SALT, - }); - const signature = createOrderSignature(order); - const expectedResult = EMPTY_FILL_RESULTS; - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - testContract.fillOrderNoThrow, - order, - fillAmount, - signature, - ); - expect(actualResult).to.deep.eq(expectedResult); - assertFillOrderCallsFromLogs(receipt.logs, []); - }); - }); - - describe('batchFillOrders', () => { - it('works with no fills', async () => { - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - testContract.batchFillOrders, - [], - [], - [], - ); - expect(actualResult).to.deep.eq([]); - assertFillOrderCallsFromLogs(receipt.logs, []); - }); - - it('works with one fill', async () => { - const COUNT = 1; - const orders = _.times(COUNT, () => randomOrder()); - const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); - const expectedCalls = _.zip(orders, fillAmounts, signatures); - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - testContract.batchFillOrders, - orders, - fillAmounts, - signatures, - ); - expect(actualResult).to.deep.eq(expectedResult); - assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); - }); - - it('works with many fills', async () => { - const COUNT = 8; - const orders = _.times(COUNT, () => randomOrder()); - const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); - const expectedCalls = _.zip(orders, fillAmounts, signatures); - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - testContract.batchFillOrders, - orders, - fillAmounts, - signatures, - ); - expect(actualResult).to.deep.eq(expectedResult); - assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); - }); - - it('works with duplicate orders', async () => { - const NUM_UNIQUE_ORDERS = 2; - const COUNT = 4; - const uniqueOrders = _.times(NUM_UNIQUE_ORDERS, () => randomOrder()); - const orders = _.shuffle(_.flatten(_.times(COUNT / NUM_UNIQUE_ORDERS, () => uniqueOrders))); - const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount.dividedToIntegerBy(COUNT)); - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); - const expectedCalls = _.zip(orders, fillAmounts, signatures); - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - testContract.batchFillOrders, - orders, - fillAmounts, - signatures, - ); - expect(actualResult).to.deep.eq(expectedResult); - assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); - }); - - it('reverts if there are more orders than fill amounts', async () => { - const COUNT = 8; - const orders = _.times(COUNT, () => randomOrder()); - const fillAmounts = _.times(COUNT - 1, i => orders[i].takerAssetAmount); - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - const expectedError = new AnyRevertError(); // Just a generic revert. - const tx = txHelper.getResultAndReceiptAsync(testContract.batchFillOrders, orders, fillAmounts, signatures); - return expect(tx).to.revertWith(expectedError); - }); - - it('reverts if there are more orders than signatures', async () => { - const COUNT = 8; - const orders = _.times(COUNT, () => randomOrder()); - const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); - const signatures = _.times(COUNT - 1, i => createOrderSignature(orders[i])); - const expectedError = new AnyRevertError(); // Just a generic revert. - const tx = txHelper.getResultAndReceiptAsync(testContract.batchFillOrders, orders, fillAmounts, signatures); - return expect(tx).to.revertWith(expectedError); - }); - }); - - describe('batchFillOrKillOrders', () => { - it('works with no fills', async () => { - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - testContract.batchFillOrKillOrders, - [], - [], - [], - ); - expect(actualResult).to.deep.eq([]); - assertFillOrderCallsFromLogs(receipt.logs, []); - }); - - it('works with one fill', async () => { - const COUNT = 1; - const orders = _.times(COUNT, () => randomOrder()); - const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); - const expectedCalls = _.zip(orders, fillAmounts, signatures); - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - testContract.batchFillOrKillOrders, - orders, - fillAmounts, - signatures, - ); - expect(actualResult).to.deep.eq(expectedResult); - assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); - }); - - it('works with many fills', async () => { - const COUNT = 8; - const orders = _.times(COUNT, () => randomOrder()); - const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); - const expectedCalls = _.zip(orders, fillAmounts, signatures); - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - testContract.batchFillOrKillOrders, - orders, - fillAmounts, - signatures, - ); - expect(actualResult).to.deep.eq(expectedResult); - assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); - }); - - it('works with duplicate orders', async () => { - const NUM_UNIQUE_ORDERS = 2; - const COUNT = 4; - const uniqueOrders = _.times(NUM_UNIQUE_ORDERS, () => randomOrder()); - const orders = _.shuffle(_.flatten(_.times(COUNT / NUM_UNIQUE_ORDERS, () => uniqueOrders))); - const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); - const expectedCalls = _.zip(orders, fillAmounts, signatures); - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - testContract.batchFillOrKillOrders, - orders, - fillAmounts, - signatures, - ); - expect(actualResult).to.deep.eq(expectedResult); - assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); - }); - - it('reverts if any fill sells less than its takerAssetFillAmount', async () => { - const COUNT = 8; - const FAILING_ORDER_INDEX = 6; - const orders = _.times(COUNT, () => randomOrder()); - const failingOrder = orders[FAILING_ORDER_INDEX]; - const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); - const failingAmount = fillAmounts[FAILING_ORDER_INDEX]; - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - // `_fillOrder()` is overridden to always return `order.takerAssetAmount` as - // the `takerAssetFilledAmount`. - failingOrder.takerAssetAmount = failingOrder.takerAssetAmount.minus(1); - const expectedError = new ExchangeRevertErrors.IncompleteFillError( - ExchangeRevertErrors.IncompleteFillErrorCode.IncompleteFillOrder, - failingAmount, - failingAmount.minus(1), - ); - const tx = txHelper.getResultAndReceiptAsync( - testContract.batchFillOrKillOrders, - orders, - fillAmounts, - signatures, - ); - return expect(tx).to.revertWith(expectedError); - }); - - it('reverts if any fill sells more than its takerAssetFillAmount', async () => { - const COUNT = 8; - const FAILING_ORDER_INDEX = 6; - const orders = _.times(COUNT, () => randomOrder()); - const failingOrder = orders[FAILING_ORDER_INDEX]; - const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); - const failingAmount = fillAmounts[FAILING_ORDER_INDEX]; - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - // `_fillOrder()` is overridden to always return `order.takerAssetAmount` as - // the `takerAssetFilledAmount`. - failingOrder.takerAssetAmount = failingOrder.takerAssetAmount.plus(1); - const expectedError = new ExchangeRevertErrors.IncompleteFillError( - ExchangeRevertErrors.IncompleteFillErrorCode.IncompleteFillOrder, - failingAmount, - failingAmount.plus(1), - ); - const tx = txHelper.getResultAndReceiptAsync( - testContract.batchFillOrKillOrders, - orders, - fillAmounts, - signatures, - ); - return expect(tx).to.revertWith(expectedError); - }); - - it('reverts if there are more orders than fill amounts', async () => { - const COUNT = 8; - const orders = _.times(COUNT, () => randomOrder()); - const fillAmounts = _.times(COUNT - 1, i => orders[i].takerAssetAmount); - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - const expectedError = new AnyRevertError(); // Just a generic revert. - const tx = txHelper.getResultAndReceiptAsync( - testContract.batchFillOrKillOrders, - orders, - fillAmounts, - signatures, - ); - return expect(tx).to.revertWith(expectedError); - }); - - it('reverts if there are more orders than signatures', async () => { - const COUNT = 8; - const orders = _.times(COUNT, () => randomOrder()); - const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); - const signatures = _.times(COUNT - 1, i => createOrderSignature(orders[i])); - const expectedError = new AnyRevertError(); // Just a generic revert. - const tx = txHelper.getResultAndReceiptAsync( - testContract.batchFillOrKillOrders, - orders, - fillAmounts, - signatures, - ); - return expect(tx).to.revertWith(expectedError); - }); - }); - - describe('batchFillOrdersNoThrow', () => { - it('works with no fills', async () => { - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - testContract.batchFillOrdersNoThrow, - [], - [], - [], - ); - expect(actualResult).to.deep.eq([]); - assertFillOrderCallsFromLogs(receipt.logs, []); - }); - - it('works with one fill', async () => { - const COUNT = 1; - const orders = _.times(COUNT, () => randomOrder()); - const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); - const expectedCalls = _.zip(orders, fillAmounts, signatures); - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - testContract.batchFillOrdersNoThrow, - orders, - fillAmounts, - signatures, - ); - expect(actualResult).to.deep.eq(expectedResult); - assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); - }); - - it('works with many fills', async () => { - const COUNT = 8; - const orders = _.times(COUNT, () => randomOrder()); - const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); - const expectedCalls = _.zip(orders, fillAmounts, signatures); - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - testContract.batchFillOrdersNoThrow, - orders, - fillAmounts, - signatures, - ); - expect(actualResult).to.deep.eq(expectedResult); - assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); - }); - - it('works with duplicate orders', async () => { - const NUM_UNIQUE_ORDERS = 2; - const COUNT = 4; - const uniqueOrders = _.times(NUM_UNIQUE_ORDERS, () => randomOrder()); - const orders = _.shuffle(_.flatten(_.times(COUNT / NUM_UNIQUE_ORDERS, () => uniqueOrders))); - const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount.dividedToIntegerBy(COUNT)); - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); - const expectedCalls = _.zip(orders, fillAmounts, signatures); - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - testContract.batchFillOrdersNoThrow, - orders, - fillAmounts, - signatures, - ); - expect(actualResult).to.deep.eq(expectedResult); - assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); - }); - - it('works if a fill fails', async () => { - const COUNT = 8; - const FAILING_ORDER_INDEX = 6; - const orders = _.times(COUNT, () => randomOrder()); - const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - const failingOrder = orders[FAILING_ORDER_INDEX]; - failingOrder.salt = ALWAYS_FAILING_SALT; - const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); - const expectedCalls = _.zip(orders, fillAmounts, signatures); - expectedCalls.splice(FAILING_ORDER_INDEX, 1); - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - testContract.batchFillOrdersNoThrow, - orders, - fillAmounts, - signatures, - ); - expect(actualResult).to.deep.eq(expectedResult); - assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); - }); - - it('reverts if there are more orders than fill amounts', async () => { - const COUNT = 8; - const orders = _.times(COUNT, () => randomOrder()); - const fillAmounts = _.times(COUNT - 1, i => orders[i].takerAssetAmount); - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - const expectedError = new AnyRevertError(); // Just a generic revert. - const tx = txHelper.getResultAndReceiptAsync( - testContract.batchFillOrdersNoThrow, - orders, - fillAmounts, - signatures, - ); - return expect(tx).to.revertWith(expectedError); - }); - - it('reverts if there are more orders than signatures', async () => { - const COUNT = 8; - const orders = _.times(COUNT, () => randomOrder()); - const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); - const signatures = _.times(COUNT - 1, i => createOrderSignature(orders[i])); - const expectedError = new AnyRevertError(); // Just a generic revert. - const tx = txHelper.getResultAndReceiptAsync( - testContract.batchFillOrdersNoThrow, - orders, - fillAmounts, - signatures, - ); - return expect(tx).to.revertWith(expectedError); - }); - }); - - type ExpectedFillOrderCallArgs = [Order, BigNumber, string]; - type MarketSellBuyArgs = [Order[], BigNumber, string[], ...any[]]; - type MarketSellBuyContractFunction = MutatorContractFunction; - type MarketSellBuySimulator = (...args: MarketSellBuyArgs) => [FillResults, ExpectedFillOrderCallArgs[]]; - - describe('marketSell*', () => { - function defineCommonMarketSellOrdersTests( - getContractFn: () => MarketSellBuyContractFunction, - simulator: MarketSellBuySimulator, - ): void { - it('works with one order', async () => { - const COUNT = 1; - const orders = _.times(COUNT, () => randomOrder()); - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - const takerAssetFillAmount = _.reduce( - orders, - (total, o) => o.takerAssetAmount.plus(total), - constants.ZERO_AMOUNT, - ); - const [expectedResult, expectedCalls] = simulator(orders, takerAssetFillAmount, signatures); - expect(expectedCalls.length).to.eq(COUNT); - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - getContractFn(), - orders, - takerAssetFillAmount, - signatures, - ); - expect(actualResult).to.deep.eq(expectedResult); - assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); - }); - - it('works with many orders', async () => { - const COUNT = 8; - const orders = _.times(COUNT, () => randomOrder()); - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - const takerAssetFillAmount = _.reduce( - orders, - (total, o) => o.takerAssetAmount.plus(total), - constants.ZERO_AMOUNT, - ); - const [expectedResult, expectedCalls] = simulator(orders, takerAssetFillAmount, signatures); - expect(expectedCalls.length).to.eq(COUNT); - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - getContractFn(), - orders, - takerAssetFillAmount, - signatures, - ); - expect(actualResult).to.deep.eq(expectedResult); - assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); - }); - - it('works with duplicate orders', async () => { - const NUM_UNIQUE_ORDERS = 2; - const COUNT = 4; - const uniqueOrders = _.times(NUM_UNIQUE_ORDERS, () => randomOrder()); - const orders = _.shuffle(_.flatten(_.times(COUNT / NUM_UNIQUE_ORDERS, () => uniqueOrders))); - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - const takerAssetFillAmount = _.reduce( - orders, - (total, o) => o.takerAssetAmount.plus(total), - constants.ZERO_AMOUNT, - ); - const [expectedResult, expectedCalls] = simulator(orders, takerAssetFillAmount, signatures); - expect(expectedCalls.length).to.eq(COUNT); - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - getContractFn(), - orders, - takerAssetFillAmount, - signatures, - ); - expect(actualResult).to.deep.eq(expectedResult); - assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); - }); - - it('stops when filled == `takerAssetFillAmount`', async () => { - const COUNT = 4; - const orders = _.times(COUNT, () => randomOrder()); - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - // Skip the last order in our `takerAssetFillAmount` calculation. - const takerAssetFillAmount = _.reduce( - orders.slice(0, COUNT - 1), - (total, o) => o.takerAssetAmount.plus(total), - constants.ZERO_AMOUNT, - ); - const [expectedResult, expectedCalls] = simulator(orders, takerAssetFillAmount, signatures); - // It should stop filling after the penultimate order. - expect(expectedCalls.length).to.eq(COUNT - 1); - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - getContractFn(), - orders, - takerAssetFillAmount, - signatures, - ); - expect(actualResult).to.deep.eq(expectedResult); - assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); - }); - - it('stops when filled > `takerAssetFillAmount`', async () => { - const COUNT = 4; - const orders = _.times(COUNT, () => randomOrder()); - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - const takerAssetFillAmount = _.reduce( - orders, - (total, o) => o.takerAssetAmount.plus(total), - constants.ZERO_AMOUNT, - ); - // Because `TestWrapperFunctions` always fills `takerAssetAmount` - // setting the first order's `takerAssetAmount` to larger than - // `takerAssetFillAmount` will cause an overfill. - orders[0].takerAssetAmount = takerAssetFillAmount.plus(1); - const [expectedResult, expectedCalls] = simulator(orders, takerAssetFillAmount, signatures); - // It should stop filling after first order. - expect(expectedCalls.length).to.eq(1); - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - getContractFn(), - orders, - takerAssetFillAmount, - signatures, - ); - expect(actualResult).to.deep.eq(expectedResult); - assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); - }); - - it('reverts when an overflow occurs when summing fill results', async () => { - const COUNT = 2; - const orders = _.times(COUNT, () => randomOrder()); - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - orders[1].takerAssetAmount = MAX_UINT256; - const takerAssetFillAmount = MAX_UINT256; - const expectedError = new SafeMathRevertErrors.Uint256BinOpError( - SafeMathRevertErrors.BinOpErrorCodes.AdditionOverflow, - orders[0].takerAssetAmount, - orders[1].takerAssetAmount, - ); - const tx = txHelper.getResultAndReceiptAsync(getContractFn(), orders, takerAssetFillAmount, signatures); - return expect(tx).to.revertWith(expectedError); - }); - - it('returns empty fill results with no orders', async () => { - const [expectedResult, expectedCalls] = simulator([], constants.ZERO_AMOUNT, []); - expect(expectedCalls.length).to.eq(0); - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - getContractFn(), - [], - constants.ZERO_AMOUNT, - [], - ); - - expect(actualResult).to.deep.eq(expectedResult); - assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); - }); - } - - function simulateMarketSellOrders( - orders: Order[], - takerAssetFillAmount: BigNumber, - signatures: string[], - ): [FillResults, ExpectedFillOrderCallArgs[]] { - const fillOrderCalls = []; - let fillResults = _.cloneDeep(EMPTY_FILL_RESULTS); - for (const [order, signature] of _.zip(orders, signatures) as [[Order, string]]) { - const remainingTakerAssetFillAmount = safeSub(takerAssetFillAmount, fillResults.takerAssetFilledAmount); - if (order.salt !== ALWAYS_FAILING_SALT) { - fillOrderCalls.push([order, remainingTakerAssetFillAmount, signature]); - } - fillResults = addFillResults(fillResults, getExpectedFillResults(order, signature)); - if (fillResults.takerAssetFilledAmount.gte(takerAssetFillAmount)) { - break; - } - } - return [fillResults, fillOrderCalls as any]; - } - - describe('marketSellOrdersNoThrow', () => { - defineCommonMarketSellOrdersTests(() => testContract.marketSellOrdersNoThrow, simulateMarketSellOrders); - - it('works when any fills revert', async () => { - const COUNT = 4; - const BAD_ORDERS_COUNT = 2; - const orders = _.times(COUNT, () => randomOrder()); - const badOrders = _.sampleSize(orders, BAD_ORDERS_COUNT); - for (const order of badOrders) { - order.salt = ALWAYS_FAILING_SALT; - } - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - const takerAssetFillAmount = _.reduce( - orders, - (total, o) => o.takerAssetAmount.plus(total), - constants.ZERO_AMOUNT, - ); - const [expectedResult, expectedCalls] = simulateMarketSellOrders( - orders, - takerAssetFillAmount, - signatures, - ); - expect(expectedCalls.length).to.eq(COUNT - BAD_ORDERS_COUNT); - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - testContract.marketSellOrdersNoThrow, - orders, - takerAssetFillAmount, - signatures, - ); - expect(actualResult).to.deep.eq(expectedResult); - assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); - }); - - it('works when all fills revert', async () => { - const COUNT = 4; - const orders = _.times(COUNT, () => randomOrder({ salt: ALWAYS_FAILING_SALT })); - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - const takerAssetFillAmount = _.reduce( - orders, - (total, o) => o.takerAssetAmount.plus(total), - constants.ZERO_AMOUNT, - ); - const [expectedResult, expectedCalls] = simulateMarketSellOrders( - orders, - takerAssetFillAmount, - signatures, - ); - expect(expectedCalls.length).to.eq(0); - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - testContract.marketSellOrdersNoThrow, - orders, - takerAssetFillAmount, - signatures, - ); - expect(actualResult).to.deep.eq(expectedResult); - assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); - }); - }); - - describe('marketSellOrdersFillOrKill', () => { - defineCommonMarketSellOrdersTests(() => testContract.marketSellOrdersNoThrow, simulateMarketSellOrders); - - it('reverts when filled < `takerAssetFillAmount`', async () => { - const COUNT = 4; - const orders = _.times(COUNT, () => randomOrder()); - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - const takerAssetFillAmount = _.reduce( - orders, - (total, o) => o.takerAssetAmount.plus(total), - constants.ZERO_AMOUNT, - ).plus(1); - const expectedError = new ExchangeRevertErrors.IncompleteFillError( - ExchangeRevertErrors.IncompleteFillErrorCode.IncompleteMarketSellOrders, - takerAssetFillAmount, - takerAssetFillAmount.minus(1), - ); - const tx = txHelper.getResultAndReceiptAsync( - testContract.marketSellOrdersFillOrKill, - orders, - takerAssetFillAmount, - signatures, - ); - return expect(tx).to.revertWith(expectedError); - }); - - it('works when fills fail but can still sell `takerAssetFillAmount`', async () => { - const COUNT = 4; - const BAD_ORDERS_COUNT = 2; - const orders = _.times(COUNT, () => randomOrder()); - const badOrders = _.sampleSize(orders, BAD_ORDERS_COUNT); - for (const order of badOrders) { - order.salt = ALWAYS_FAILING_SALT; - } - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - const takerAssetFillAmount = _.reduce( - orders, - (total, o) => o.takerAssetAmount.plus(total), - constants.ZERO_AMOUNT, - ).minus(_.reduce(badOrders, (total, o) => o.takerAssetAmount.plus(total), constants.ZERO_AMOUNT)); - const [expectedResult, expectedCalls] = simulateMarketSellOrders( - orders, - takerAssetFillAmount, - signatures, - ); - expect(expectedCalls.length).to.eq(COUNT - BAD_ORDERS_COUNT); - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - testContract.marketSellOrdersFillOrKill, - orders, - takerAssetFillAmount, - signatures, - ); - expect(actualResult).to.deep.eq(expectedResult); - assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); - }); - - it('reverts when a failed fill results in selling less than `takerAssetFillAmount`', async () => { - const COUNT = 4; - const BAD_ORDERS_COUNT = 2; - const orders = _.times(COUNT, () => randomOrder()); - const badOrders = _.sampleSize(orders, BAD_ORDERS_COUNT); - for (const order of badOrders) { - order.salt = ALWAYS_FAILING_SALT; - } - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - const badOrdersAmount = _.reduce( - badOrders, - (total, o) => o.takerAssetAmount.plus(total), - constants.ZERO_AMOUNT, - ); - const takerAssetFillAmount = _.reduce( - orders, - (total, o) => o.takerAssetAmount.plus(total), - constants.ZERO_AMOUNT, - ) - .minus(badOrdersAmount) - .plus(1); - const expectedError = new ExchangeRevertErrors.IncompleteFillError( - ExchangeRevertErrors.IncompleteFillErrorCode.IncompleteMarketSellOrders, - takerAssetFillAmount, - takerAssetFillAmount.minus(1), - ); - const tx = txHelper.getResultAndReceiptAsync( - testContract.marketSellOrdersFillOrKill, - orders, - takerAssetFillAmount, - signatures, - ); - return expect(tx).to.revertWith(expectedError); - }); - }); - }); - - describe('marketBuy*', () => { - function defineCommonMarketBuyOrdersTests( - getContractFn: () => MarketSellBuyContractFunction, - simulator: MarketSellBuySimulator, - ): void { - it('works with one order', async () => { - const COUNT = 1; - const orders = _.times(COUNT, () => randomOrder()); - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - const makerAssetFillAmount = _.reduce( - orders, - (total, o) => o.makerAssetAmount.plus(total), - constants.ZERO_AMOUNT, - ); - const [expectedResult, expectedCalls] = simulator(orders, makerAssetFillAmount, signatures); - expect(expectedCalls.length).to.eq(COUNT); - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - getContractFn(), - orders, - makerAssetFillAmount, - signatures, - ); - expect(actualResult).to.deep.eq(expectedResult); - assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); - }); - - it('works with many orders', async () => { - const COUNT = 8; - const orders = _.times(COUNT, () => randomOrder()); - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - const makerAssetFillAmount = _.reduce( - orders, - (total, o) => o.makerAssetAmount.plus(total), - constants.ZERO_AMOUNT, - ); - const [expectedResult, expectedCalls] = simulator(orders, makerAssetFillAmount, signatures); - expect(expectedCalls.length).to.eq(COUNT); - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - getContractFn(), - orders, - makerAssetFillAmount, - signatures, - ); - expect(actualResult).to.deep.eq(expectedResult); - assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); - }); - - it('works with duplicate orders', async () => { - const NUM_UNIQUE_ORDERS = 2; - const COUNT = 4; - const uniqueOrders = _.times(NUM_UNIQUE_ORDERS, () => randomOrder()); - const orders = _.shuffle(_.flatten(_.times(COUNT / NUM_UNIQUE_ORDERS, () => uniqueOrders))); - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - const makerAssetFillAmount = _.reduce( - orders, - (total, o) => o.makerAssetAmount.plus(total), - constants.ZERO_AMOUNT, - ); - const [expectedResult, expectedCalls] = simulator(orders, makerAssetFillAmount, signatures); - expect(expectedCalls.length).to.eq(COUNT); - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - getContractFn(), - orders, - makerAssetFillAmount, - signatures, - ); - expect(actualResult).to.deep.eq(expectedResult); - assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); - }); - - it('stops when filled == `makerAssetFillAmount`', async () => { - const COUNT = 4; - const orders = _.times(COUNT, () => randomOrder()); - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - // Skip the last order in our `makerAssetFillAmount` calculation. - const makerAssetFillAmount = _.reduce( - orders.slice(0, COUNT - 1), - (total, o) => o.makerAssetAmount.plus(total), - constants.ZERO_AMOUNT, - ); - const [expectedResult, expectedCalls] = simulator(orders, makerAssetFillAmount, signatures); - // It should stop filling after the penultimate order. - expect(expectedCalls.length).to.eq(COUNT - 1); - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - getContractFn(), - orders, - makerAssetFillAmount, - signatures, - ); - expect(actualResult).to.deep.eq(expectedResult); - assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); - }); - - it('stops when filled > `makerAssetFillAmount`', async () => { - const COUNT = 4; - const orders = _.times(COUNT, () => randomOrder()); - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - const makerAssetFillAmount = _.reduce( - orders, - (total, o) => o.makerAssetAmount.plus(total), - constants.ZERO_AMOUNT, - ); - // Because `TestWrapperFunctions` always fills `makerAssetAmount` - // setting the first order's `makerAssetAmount` to larger than - // `makerAssetFillAmount` will cause an overfill. - orders[0].makerAssetAmount = makerAssetFillAmount.plus(1); - const [expectedResult, expectedCalls] = simulator(orders, makerAssetFillAmount, signatures); - // It should stop filling after first order. - expect(expectedCalls.length).to.eq(1); - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - getContractFn(), - orders, - makerAssetFillAmount, - signatures, - ); - expect(actualResult).to.deep.eq(expectedResult); - assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); - }); - - it('reverts when an overflow occurs when computing `remainingTakerAssetFillAmount`', async () => { - const orders = [randomOrder({ takerAssetAmount: MAX_UINT256 })]; - const signatures = _.times(orders.length, i => createOrderSignature(orders[i])); - const makerAssetFillAmount = new BigNumber(2); - const expectedError = new SafeMathRevertErrors.Uint256BinOpError( - SafeMathRevertErrors.BinOpErrorCodes.MultiplicationOverflow, - orders[0].takerAssetAmount, - makerAssetFillAmount, - ); - const tx = txHelper.getResultAndReceiptAsync(getContractFn(), orders, makerAssetFillAmount, signatures); - return expect(tx).to.revertWith(expectedError); - }); - - it("reverts when an order's `makerAssetAmount` is zero", async () => { - const orders = [randomOrder({ makerAssetAmount: constants.ZERO_AMOUNT })]; - const signatures = _.times(orders.length, i => createOrderSignature(orders[i])); - const makerAssetFillAmount = ONE_ETHER; - const expectedError = new SafeMathRevertErrors.Uint256BinOpError( - SafeMathRevertErrors.BinOpErrorCodes.DivisionByZero, - orders[0].takerAssetAmount.times(makerAssetFillAmount), - orders[0].makerAssetAmount, - ); - const tx = txHelper.getResultAndReceiptAsync(getContractFn(), orders, makerAssetFillAmount, signatures); - return expect(tx).to.revertWith(expectedError); - }); - - it('reverts when an overflow occurs when summing fill results', async () => { - const orders = [ - randomOrder({ - takerAssetAmount: new BigNumber(1), - makerAssetAmount: new BigNumber(1), - }), - randomOrder({ - takerAssetAmount: new BigNumber(1), - makerAssetAmount: MAX_UINT256, - }), - ]; - const signatures = _.times(orders.length, i => createOrderSignature(orders[i])); - const makerAssetFillAmount = new BigNumber(2); - const expectedError = new SafeMathRevertErrors.Uint256BinOpError( - SafeMathRevertErrors.BinOpErrorCodes.AdditionOverflow, - orders[0].makerAssetAmount, - orders[1].makerAssetAmount, - ); - const tx = txHelper.getResultAndReceiptAsync(getContractFn(), orders, makerAssetFillAmount, signatures); - return expect(tx).to.revertWith(expectedError); - }); - - it('returns empty fill results with no orders', async () => { - const [expectedResult, expectedCalls] = simulator([], constants.ZERO_AMOUNT, []); - expect(expectedCalls.length).to.eq(0); - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - getContractFn(), - [], - constants.ZERO_AMOUNT, - [], - ); - - expect(actualResult).to.deep.eq(expectedResult); - assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); - }); - } - - function simulateMarketBuyOrdersNoThrow( - orders: Order[], - makerAssetFillAmount: BigNumber, - signatures: string[], - ): [FillResults, ExpectedFillOrderCallArgs[]] { - const fillOrderCalls = []; - let fillResults = _.cloneDeep(EMPTY_FILL_RESULTS); - for (const [order, signature] of _.zip(orders, signatures) as [[Order, string]]) { - const remainingMakerAssetFillAmount = safeSub(makerAssetFillAmount, fillResults.makerAssetFilledAmount); - const remainingTakerAssetFillAmount = getPartialAmountFloor( - order.takerAssetAmount, - order.makerAssetAmount, - remainingMakerAssetFillAmount, - ); - if (order.salt !== ALWAYS_FAILING_SALT) { - fillOrderCalls.push([order, remainingTakerAssetFillAmount, signature]); - } - fillResults = addFillResults(fillResults, getExpectedFillResults(order, signature)); - if (fillResults.makerAssetFilledAmount.gte(makerAssetFillAmount)) { - break; - } - } - return [fillResults, fillOrderCalls as any]; - } - - describe('marketBuyOrdersNoThrow', () => { - defineCommonMarketBuyOrdersTests(() => testContract.marketBuyOrdersNoThrow, simulateMarketBuyOrdersNoThrow); - - it('works when any fills revert', async () => { - const COUNT = 4; - const BAD_ORDERS_COUNT = 2; - const orders = _.times(COUNT, () => randomOrder()); - const badOrders = _.sampleSize(orders, BAD_ORDERS_COUNT); - for (const order of badOrders) { - order.salt = ALWAYS_FAILING_SALT; - } - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - const makerAssetFillAmount = _.reduce( - orders, - (total, o) => o.makerAssetAmount.plus(total), - constants.ZERO_AMOUNT, - ); - const [expectedResult, expectedCalls] = simulateMarketBuyOrdersNoThrow( - orders, - makerAssetFillAmount, - signatures, - ); - expect(expectedCalls.length).to.eq(COUNT - BAD_ORDERS_COUNT); - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - testContract.marketBuyOrdersNoThrow, - orders, - makerAssetFillAmount, - signatures, - ); - expect(actualResult).to.deep.eq(expectedResult); - assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); - }); - - it('works when all fills revert', async () => { - const COUNT = 4; - const orders = _.times(COUNT, () => randomOrder({ salt: ALWAYS_FAILING_SALT })); - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - const makerAssetFillAmount = _.reduce( - orders, - (total, o) => o.makerAssetAmount.plus(total), - constants.ZERO_AMOUNT, - ); - const [expectedResult, expectedCalls] = simulateMarketBuyOrdersNoThrow( - orders, - makerAssetFillAmount, - signatures, - ); - expect(expectedCalls.length).to.eq(0); - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - testContract.marketBuyOrdersNoThrow, - orders, - makerAssetFillAmount, - signatures, - ); - expect(actualResult).to.deep.eq(expectedResult); - assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); - }); - }); - - describe('marketBuyOrdersFillOrKill', () => { - defineCommonMarketBuyOrdersTests( - () => testContract.marketBuyOrdersFillOrKill, - simulateMarketBuyOrdersNoThrow, - ); - - it('reverts when filled < `makerAssetFillAmount`', async () => { - const COUNT = 4; - const orders = _.times(COUNT, () => randomOrder()); - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - const makerAssetFillAmount = _.reduce( - orders, - (total, o) => o.makerAssetAmount.plus(total), - constants.ZERO_AMOUNT, - ).plus(1); - const expectedError = new ExchangeRevertErrors.IncompleteFillError( - ExchangeRevertErrors.IncompleteFillErrorCode.IncompleteMarketBuyOrders, - makerAssetFillAmount, - makerAssetFillAmount.minus(1), - ); - const tx = txHelper.getResultAndReceiptAsync( - testContract.marketBuyOrdersFillOrKill, - orders, - makerAssetFillAmount, - signatures, - ); - return expect(tx).to.revertWith(expectedError); - }); - - it('works when fills fail but can still buy `makerAssetFillAmount`', async () => { - const COUNT = 4; - const BAD_ORDERS_COUNT = 2; - const orders = _.times(COUNT, () => randomOrder()); - const badOrders = _.sampleSize(orders, BAD_ORDERS_COUNT); - for (const order of badOrders) { - order.salt = ALWAYS_FAILING_SALT; - } - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - const makerAssetFillAmount = _.reduce( - orders, - (total, o) => o.makerAssetAmount.plus(total), - constants.ZERO_AMOUNT, - ).minus(_.reduce(badOrders, (total, o) => o.makerAssetAmount.plus(total), constants.ZERO_AMOUNT)); - const [expectedResult, expectedCalls] = simulateMarketBuyOrdersNoThrow( - orders, - makerAssetFillAmount, - signatures, - ); - expect(expectedCalls.length).to.eq(COUNT - BAD_ORDERS_COUNT); - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - testContract.marketBuyOrdersFillOrKill, - orders, - makerAssetFillAmount, - signatures, - ); - expect(actualResult).to.deep.eq(expectedResult); - assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); - }); - - it('reverts when a failed fill results in buying less than `makerAssetFillAmount`', async () => { - const COUNT = 4; - const BAD_ORDERS_COUNT = 2; - const orders = _.times(COUNT, () => randomOrder()); - const badOrders = _.sampleSize(orders, BAD_ORDERS_COUNT); - for (const order of badOrders) { - order.salt = ALWAYS_FAILING_SALT; - } - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - const badOrdersAmount = _.reduce( - badOrders, - (total, o) => o.makerAssetAmount.plus(total), - constants.ZERO_AMOUNT, - ); - const makerAssetFillAmount = _.reduce( - orders, - (total, o) => o.makerAssetAmount.plus(total), - constants.ZERO_AMOUNT, - ) - .minus(badOrdersAmount) - .plus(1); - const expectedError = new ExchangeRevertErrors.IncompleteFillError( - ExchangeRevertErrors.IncompleteFillErrorCode.IncompleteMarketBuyOrders, - makerAssetFillAmount, - makerAssetFillAmount.minus(1), - ); - const tx = txHelper.getResultAndReceiptAsync( - testContract.marketBuyOrdersFillOrKill, - orders, - makerAssetFillAmount, - signatures, - ); - return expect(tx).to.revertWith(expectedError); - }); - }); - }); - - describe('batchCancelOrders', () => { - // Asserts that `_cancelOrder()` was called in the same order and with the same - // arguments as given by examining receipt logs. - function assertCancelOrderCallsFromLogs(logs: LogEntry[], calls: Order[]): void { - expect(logs.length).to.eq(calls.length); - for (const i of _.times(calls.length)) { - const log = (logs[i] as any) as LogWithDecodedArgs; - const expectedOrder = calls[i]; - expect(log.event).to.eq('CancelOrderCalled'); - assertSameOrderFromEvent(log.args.order as any, expectedOrder); - } - } - - it('works with no orders', async () => { - const [, receipt] = await txHelper.getResultAndReceiptAsync(testContract.batchCancelOrders, []); - assertCancelOrderCallsFromLogs(receipt.logs, []); - }); - - it('works with many orders', async () => { - const COUNT = 8; - const orders = _.times(COUNT, () => randomOrder({ makerAddress: senderAddress })); - const [, receipt] = await txHelper.getResultAndReceiptAsync(testContract.batchCancelOrders, orders); - assertCancelOrderCallsFromLogs(receipt.logs, orders); - }); - - it('works with duplicate orders', async () => { - const UNIQUE_ORDERS = 2; - const COUNT = 6; - const uniqueOrders = _.times(UNIQUE_ORDERS, () => randomOrder({ makerAddress: senderAddress })); - const orders = _.shuffle(_.flatten(_.times(COUNT / UNIQUE_ORDERS, () => uniqueOrders))); - const [, receipt] = await txHelper.getResultAndReceiptAsync(testContract.batchCancelOrders, orders); - assertCancelOrderCallsFromLogs(receipt.logs, orders); - }); - - it('reverts if one `_cancelOrder()` reverts', async () => { - const COUNT = 8; - const FAILING_ORDER_INDEX = 4; - const orders = _.times(COUNT, () => randomOrder({ makerAddress: senderAddress })); - const failingOrder = orders[FAILING_ORDER_INDEX]; - failingOrder.salt = ALWAYS_FAILING_SALT; - const expectedError = ALWAYS_FAILING_SALT_REVERT_ERROR; - const tx = txHelper.getResultAndReceiptAsync(testContract.batchCancelOrders, orders); - return expect(tx).to.revertWith(expectedError); - }); - }); -}); -// tslint:disable-next-line: max-file-line-count +// import { ReferenceFunctions as LibReferenceFunctions } from '@0x/contracts-exchange-libs'; +// import { +// blockchainTests, +// constants, +// describe, +// expect, +// hexRandom, +// MutatorContractFunction, +// transactionHelper, +// } from '@0x/contracts-test-utils'; +// import { ReferenceFunctions as UtilReferenceFunctions } from '@0x/contracts-utils'; +// import { ExchangeRevertErrors, orderHashUtils } from '@0x/order-utils'; +// import { FillResults, Order } from '@0x/types'; +// import { AnyRevertError, BigNumber, SafeMathRevertErrors, StringRevertError } from '@0x/utils'; +// import { LogEntry, LogWithDecodedArgs } from 'ethereum-types'; +// import * as ethjs from 'ethereumjs-util'; +// import * as _ from 'lodash'; + +// import { +// artifacts, +// TestWrapperFunctionsCancelOrderCalledEventArgs as CancelOrderCalledEventArgs, +// TestWrapperFunctionsContract, +// TestWrapperFunctionsFillOrderCalledEventArgs as FillOrderCalledEventArgs, +// } from '../src'; + +// blockchainTests('Exchange wrapper functions unit tests.', env => { +// const CHAIN_ID = 0x74657374; +// const { ONE_ETHER, MAX_UINT256 } = constants; +// const { addFillResults, getPartialAmountFloor } = LibReferenceFunctions; +// const { safeSub } = UtilReferenceFunctions; +// const protocolFeeMultiplier = new BigNumber(150000); +// const randomAddress = () => hexRandom(constants.ADDRESS_LENGTH); +// const randomAssetData = () => hexRandom(34); +// const randomAmount = (maxAmount: BigNumber = ONE_ETHER) => maxAmount.times(_.random(0, 100, true).toFixed(12)); +// const randomTimestamp = () => new BigNumber(Math.floor(_.now() / 1000) + _.random(0, 34560)); +// const randomSalt = () => new BigNumber(hexRandom(constants.WORD_LENGTH).substr(2), 16); +// const ALWAYS_FAILING_SALT = constants.MAX_UINT256; +// const ALWAYS_FAILING_SALT_REVERT_ERROR = new StringRevertError('ALWAYS_FAILING_SALT'); +// const EMPTY_FILL_RESULTS = { +// makerAssetFilledAmount: constants.ZERO_AMOUNT, +// takerAssetFilledAmount: constants.ZERO_AMOUNT, +// makerFeePaid: constants.ZERO_AMOUNT, +// takerFeePaid: constants.ZERO_AMOUNT, +// protocolFeePaid: constants.ZERO_AMOUNT, +// }; +// let testContract: TestWrapperFunctionsContract; +// let owner: string; +// let senderAddress: string; + +// before(async () => { +// [owner, senderAddress] = await env.getAccountAddressesAsync(); +// testContract = await TestWrapperFunctionsContract.deployFrom0xArtifactAsync( +// artifacts.TestWrapperFunctions, +// env.provider, +// { +// ...env.txDefaults, +// from: owner, +// }, +// {}, +// ); + +// // Set the protocol fee multiplier. +// await testContract.setProtocolFeeMultiplier(protocolFeeMultiplier).awaitTransactionSuccessAsync({ +// from: owner, +// }); +// }); + +// function randomOrder(fields?: Partial): Order { +// return { +// makerAddress: randomAddress(), +// takerAddress: randomAddress(), +// feeRecipientAddress: randomAddress(), +// senderAddress: randomAddress(), +// takerAssetAmount: randomAmount(), +// makerAssetAmount: randomAmount(), +// makerFee: randomAmount(), +// takerFee: randomAmount(), +// expirationTimeSeconds: randomTimestamp(), +// salt: randomSalt(), +// makerAssetData: randomAssetData(), +// takerAssetData: randomAssetData(), +// makerFeeAssetData: randomAssetData(), +// takerFeeAssetData: randomAssetData(), +// exchangeAddress: constants.NULL_ADDRESS, +// chainId: CHAIN_ID, +// ...(fields || {}), +// }; +// } + +// // Computes the expected (fake) fill results from `TestWrapperFunctions` `_fillOrder` implementation. +// function getExpectedFillResults(order: Order, signature: string): FillResults { +// if (order.salt === ALWAYS_FAILING_SALT) { +// return EMPTY_FILL_RESULTS; +// } +// return { +// makerAssetFilledAmount: order.makerAssetAmount, +// takerAssetFilledAmount: order.takerAssetAmount, +// makerFeePaid: order.makerFee, +// takerFeePaid: order.takerFee, +// protocolFeePaid: protocolFeeMultiplier, +// }; +// } + +// // Creates a deterministic order signature, even though no signature validation +// // actually occurs in the test contract. +// function createOrderSignature(order: Order): string { +// return ethjs.bufferToHex(ethjs.sha3(ethjs.toBuffer(orderHashUtils.getOrderHashHex(order)))); +// } + +// // Asserts that `_fillOrder()` was called in the same order and with the same +// // arguments as given by examining receipt logs. +// function assertFillOrderCallsFromLogs(logs: LogEntry[], calls: Array<[Order, BigNumber, string]>): void { +// expect(logs.length).to.eq(calls.length); +// for (const i of _.times(calls.length)) { +// const log = (logs[i] as any) as LogWithDecodedArgs; +// const [expectedOrder, expectedTakerAssetFillAmount, expectedSignature] = calls[i]; +// expect(log.event).to.eq('FillOrderCalled'); +// assertSameOrderFromEvent(log.args.order as any, expectedOrder); +// expect(log.args.takerAssetFillAmount).to.bignumber.eq(expectedTakerAssetFillAmount); +// expect(log.args.signature).to.eq(expectedSignature); +// } +// } + +// function assertSameOrderFromEvent(actual: any[], expected: Order): void { +// expect(actual.length === 14); +// expect(actual[0].toLowerCase()).to.be.eq(expected.makerAddress); +// expect(actual[1].toLowerCase()).to.be.eq(expected.takerAddress); +// expect(actual[2].toLowerCase()).to.be.eq(expected.feeRecipientAddress); +// expect(actual[3].toLowerCase()).to.be.eq(expected.senderAddress); +// expect(actual[4]).to.be.bignumber.eq(expected.makerAssetAmount); +// expect(actual[5]).to.be.bignumber.eq(expected.takerAssetAmount); +// expect(actual[6]).to.be.bignumber.eq(expected.makerFee); +// expect(actual[7]).to.be.bignumber.eq(expected.takerFee); +// expect(actual[8]).to.be.bignumber.eq(expected.expirationTimeSeconds); +// expect(actual[9]).to.be.bignumber.eq(expected.salt); +// expect(actual[10]).to.be.eq(expected.makerAssetData); +// expect(actual[11]).to.be.eq(expected.takerAssetData); +// expect(actual[12]).to.be.eq(expected.makerFeeAssetData); +// expect(actual[13]).to.be.eq(expected.takerFeeAssetData); +// } + +// describe('fillOrKillOrder', () => { +// it('works if the order is filled by exactly `takerAssetFillAmount`', async () => { +// const fillAmount = randomAmount(); +// const order = randomOrder({ +// // `_fillOrder()` is overridden to always return `order.takerAssetAmount` as +// // the `takerAssetFilledAmount`. +// takerAssetAmount: fillAmount, +// }); +// const signature = createOrderSignature(order); +// const expectedResult = getExpectedFillResults(order, signature); +// const expectedCalls = [[order, fillAmount, signature]]; +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// testContract.fillOrKillOrder, +// order, +// fillAmount, +// signature, +// ); +// expect(actualResult).to.deep.eq(expectedResult); +// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); +// }); + +// it('reverts if the order is filled by less than `takerAssetFillAmount`', async () => { +// const fillAmount = randomAmount(); +// const order = randomOrder({ +// // `_fillOrder()` is overridden to always return `order.takerAssetAmount` as +// // the `takerAssetFilledAmount`. +// takerAssetAmount: fillAmount.minus(1), +// }); +// const signature = createOrderSignature(order); +// const expectedError = new ExchangeRevertErrors.IncompleteFillError( +// ExchangeRevertErrors.IncompleteFillErrorCode.IncompleteFillOrder, +// fillAmount, +// fillAmount.minus(1), +// ); +// const tx = testContract.fillOrKillOrder(order, fillAmount, signature).awaitTransactionSuccessAsync(); +// return expect(tx).to.revertWith(expectedError); +// }); + +// it('reverts if the order is filled by greater than `takerAssetFillAmount`', async () => { +// const fillAmount = randomAmount(); +// const order = randomOrder({ +// // `_fillOrder()` is overridden to always return `order.takerAssetAmount` as +// // the `takerAssetFilledAmount`. +// takerAssetAmount: fillAmount.plus(1), +// }); +// const signature = createOrderSignature(order); +// const expectedError = new ExchangeRevertErrors.IncompleteFillError( +// ExchangeRevertErrors.IncompleteFillErrorCode.IncompleteFillOrder, +// fillAmount, +// fillAmount.plus(1), +// ); +// const tx = testContract.fillOrKillOrder(order, fillAmount, signature).awaitTransactionSuccessAsync(); +// return expect(tx).to.revertWith(expectedError); +// }); + +// it('reverts if `_fillOrder()` reverts', async () => { +// const fillAmount = randomAmount(); +// const order = randomOrder({ +// salt: ALWAYS_FAILING_SALT, +// }); +// const signature = createOrderSignature(order); +// const expectedError = ALWAYS_FAILING_SALT_REVERT_ERROR; +// const tx = testContract.fillOrKillOrder(order, fillAmount, signature).awaitTransactionSuccessAsync(); +// return expect(tx).to.revertWith(expectedError); +// }); +// }); + +// describe('fillOrderNoThrow', () => { +// it('calls `fillOrder()` and returns its result', async () => { +// const fillAmount = randomAmount(); +// const order = randomOrder(); +// const signature = createOrderSignature(order); +// const expectedResult = getExpectedFillResults(order, signature); +// const expectedCalls = [[order, fillAmount, signature]]; +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// testContract.fillOrderNoThrow, +// order, +// fillAmount, +// signature, +// ); +// expect(actualResult).to.deep.eq(expectedResult); +// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); +// }); + +// it('does not revert if `fillOrder()` reverts', async () => { +// const fillAmount = randomAmount(); +// const order = randomOrder({ +// salt: ALWAYS_FAILING_SALT, +// }); +// const signature = createOrderSignature(order); +// const expectedResult = EMPTY_FILL_RESULTS; +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// testContract.fillOrderNoThrow, +// order, +// fillAmount, +// signature, +// ); +// expect(actualResult).to.deep.eq(expectedResult); +// assertFillOrderCallsFromLogs(receipt.logs, []); +// }); +// }); + +// describe('batchFillOrders', () => { +// it('works with no fills', async () => { +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// testContract.batchFillOrders, +// [], +// [], +// [], +// ); +// expect(actualResult).to.deep.eq([]); +// assertFillOrderCallsFromLogs(receipt.logs, []); +// }); + +// it('works with one fill', async () => { +// const COUNT = 1; +// const orders = _.times(COUNT, () => randomOrder()); +// const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); +// const expectedCalls = _.zip(orders, fillAmounts, signatures); +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// testContract.batchFillOrders, +// orders, +// fillAmounts, +// signatures, +// ); +// expect(actualResult).to.deep.eq(expectedResult); +// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); +// }); + +// it('works with many fills', async () => { +// const COUNT = 8; +// const orders = _.times(COUNT, () => randomOrder()); +// const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); +// const expectedCalls = _.zip(orders, fillAmounts, signatures); +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// testContract.batchFillOrders, +// orders, +// fillAmounts, +// signatures, +// ); +// expect(actualResult).to.deep.eq(expectedResult); +// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); +// }); + +// it('works with duplicate orders', async () => { +// const NUM_UNIQUE_ORDERS = 2; +// const COUNT = 4; +// const uniqueOrders = _.times(NUM_UNIQUE_ORDERS, () => randomOrder()); +// const orders = _.shuffle(_.flatten(_.times(COUNT / NUM_UNIQUE_ORDERS, () => uniqueOrders))); +// const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount.dividedToIntegerBy(COUNT)); +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); +// const expectedCalls = _.zip(orders, fillAmounts, signatures); +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// testContract.batchFillOrders, +// orders, +// fillAmounts, +// signatures, +// ); +// expect(actualResult).to.deep.eq(expectedResult); +// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); +// }); + +// it('reverts if there are more orders than fill amounts', async () => { +// const COUNT = 8; +// const orders = _.times(COUNT, () => randomOrder()); +// const fillAmounts = _.times(COUNT - 1, i => orders[i].takerAssetAmount); +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// const expectedError = new AnyRevertError(); // Just a generic revert. +// const tx = transactionHelper.getResultAndReceiptAsync(testContract.batchFillOrders, orders, fillAmounts, signatures); +// return expect(tx).to.revertWith(expectedError); +// }); + +// it('reverts if there are more orders than signatures', async () => { +// const COUNT = 8; +// const orders = _.times(COUNT, () => randomOrder()); +// const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); +// const signatures = _.times(COUNT - 1, i => createOrderSignature(orders[i])); +// const expectedError = new AnyRevertError(); // Just a generic revert. +// const tx = transactionHelper.getResultAndReceiptAsync(testContract.batchFillOrders, orders, fillAmounts, signatures); +// return expect(tx).to.revertWith(expectedError); +// }); +// }); + +// describe('batchFillOrKillOrders', () => { +// it('works with no fills', async () => { +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// testContract.batchFillOrKillOrders, +// [], +// [], +// [], +// ); +// expect(actualResult).to.deep.eq([]); +// assertFillOrderCallsFromLogs(receipt.logs, []); +// }); + +// it('works with one fill', async () => { +// const COUNT = 1; +// const orders = _.times(COUNT, () => randomOrder()); +// const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); +// const expectedCalls = _.zip(orders, fillAmounts, signatures); +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// testContract.batchFillOrKillOrders, +// orders, +// fillAmounts, +// signatures, +// ); +// expect(actualResult).to.deep.eq(expectedResult); +// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); +// }); + +// it('works with many fills', async () => { +// const COUNT = 8; +// const orders = _.times(COUNT, () => randomOrder()); +// const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); +// const expectedCalls = _.zip(orders, fillAmounts, signatures); +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// testContract.batchFillOrKillOrders, +// orders, +// fillAmounts, +// signatures, +// ); +// expect(actualResult).to.deep.eq(expectedResult); +// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); +// }); + +// it('works with duplicate orders', async () => { +// const NUM_UNIQUE_ORDERS = 2; +// const COUNT = 4; +// const uniqueOrders = _.times(NUM_UNIQUE_ORDERS, () => randomOrder()); +// const orders = _.shuffle(_.flatten(_.times(COUNT / NUM_UNIQUE_ORDERS, () => uniqueOrders))); +// const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); +// const expectedCalls = _.zip(orders, fillAmounts, signatures); +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// testContract.batchFillOrKillOrders, +// orders, +// fillAmounts, +// signatures, +// ); +// expect(actualResult).to.deep.eq(expectedResult); +// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); +// }); + +// it('reverts if any fill sells less than its takerAssetFillAmount', async () => { +// const COUNT = 8; +// const FAILING_ORDER_INDEX = 6; +// const orders = _.times(COUNT, () => randomOrder()); +// const failingOrder = orders[FAILING_ORDER_INDEX]; +// const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); +// const failingAmount = fillAmounts[FAILING_ORDER_INDEX]; +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// // `_fillOrder()` is overridden to always return `order.takerAssetAmount` as +// // the `takerAssetFilledAmount`. +// failingOrder.takerAssetAmount = failingOrder.takerAssetAmount.minus(1); +// const expectedError = new ExchangeRevertErrors.IncompleteFillError( +// ExchangeRevertErrors.IncompleteFillErrorCode.IncompleteFillOrder, +// failingAmount, +// failingAmount.minus(1), +// ); +// const tx = transactionHelper.getResultAndReceiptAsync( +// testContract.batchFillOrKillOrders, +// orders, +// fillAmounts, +// signatures, +// ); +// return expect(tx).to.revertWith(expectedError); +// }); + +// it('reverts if any fill sells more than its takerAssetFillAmount', async () => { +// const COUNT = 8; +// const FAILING_ORDER_INDEX = 6; +// const orders = _.times(COUNT, () => randomOrder()); +// const failingOrder = orders[FAILING_ORDER_INDEX]; +// const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); +// const failingAmount = fillAmounts[FAILING_ORDER_INDEX]; +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// // `_fillOrder()` is overridden to always return `order.takerAssetAmount` as +// // the `takerAssetFilledAmount`. +// failingOrder.takerAssetAmount = failingOrder.takerAssetAmount.plus(1); +// const expectedError = new ExchangeRevertErrors.IncompleteFillError( +// ExchangeRevertErrors.IncompleteFillErrorCode.IncompleteFillOrder, +// failingAmount, +// failingAmount.plus(1), +// ); +// const tx = transactionHelper.getResultAndReceiptAsync( +// testContract.batchFillOrKillOrders, +// orders, +// fillAmounts, +// signatures, +// ); +// return expect(tx).to.revertWith(expectedError); +// }); + +// it('reverts if there are more orders than fill amounts', async () => { +// const COUNT = 8; +// const orders = _.times(COUNT, () => randomOrder()); +// const fillAmounts = _.times(COUNT - 1, i => orders[i].takerAssetAmount); +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// const expectedError = new AnyRevertError(); // Just a generic revert. +// const tx = transactionHelper.getResultAndReceiptAsync( +// testContract.batchFillOrKillOrders, +// orders, +// fillAmounts, +// signatures, +// ); +// return expect(tx).to.revertWith(expectedError); +// }); + +// it('reverts if there are more orders than signatures', async () => { +// const COUNT = 8; +// const orders = _.times(COUNT, () => randomOrder()); +// const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); +// const signatures = _.times(COUNT - 1, i => createOrderSignature(orders[i])); +// const expectedError = new AnyRevertError(); // Just a generic revert. +// const tx = transactionHelper.getResultAndReceiptAsync( +// testContract.batchFillOrKillOrders, +// orders, +// fillAmounts, +// signatures, +// ); +// return expect(tx).to.revertWith(expectedError); +// }); +// }); + +// describe('batchFillOrdersNoThrow', () => { +// it('works with no fills', async () => { +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// testContract.batchFillOrdersNoThrow, +// [], +// [], +// [], +// ); +// expect(actualResult).to.deep.eq([]); +// assertFillOrderCallsFromLogs(receipt.logs, []); +// }); + +// it('works with one fill', async () => { +// const COUNT = 1; +// const orders = _.times(COUNT, () => randomOrder()); +// const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); +// const expectedCalls = _.zip(orders, fillAmounts, signatures); +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// testContract.batchFillOrdersNoThrow, +// orders, +// fillAmounts, +// signatures, +// ); +// expect(actualResult).to.deep.eq(expectedResult); +// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); +// }); + +// it('works with many fills', async () => { +// const COUNT = 8; +// const orders = _.times(COUNT, () => randomOrder()); +// const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); +// const expectedCalls = _.zip(orders, fillAmounts, signatures); +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// testContract.batchFillOrdersNoThrow, +// orders, +// fillAmounts, +// signatures, +// ); +// expect(actualResult).to.deep.eq(expectedResult); +// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); +// }); + +// it('works with duplicate orders', async () => { +// const NUM_UNIQUE_ORDERS = 2; +// const COUNT = 4; +// const uniqueOrders = _.times(NUM_UNIQUE_ORDERS, () => randomOrder()); +// const orders = _.shuffle(_.flatten(_.times(COUNT / NUM_UNIQUE_ORDERS, () => uniqueOrders))); +// const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount.dividedToIntegerBy(COUNT)); +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); +// const expectedCalls = _.zip(orders, fillAmounts, signatures); +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// testContract.batchFillOrdersNoThrow, +// orders, +// fillAmounts, +// signatures, +// ); +// expect(actualResult).to.deep.eq(expectedResult); +// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); +// }); + +// it('works if a fill fails', async () => { +// const COUNT = 8; +// const FAILING_ORDER_INDEX = 6; +// const orders = _.times(COUNT, () => randomOrder()); +// const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// const failingOrder = orders[FAILING_ORDER_INDEX]; +// failingOrder.salt = ALWAYS_FAILING_SALT; +// const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); +// const expectedCalls = _.zip(orders, fillAmounts, signatures); +// expectedCalls.splice(FAILING_ORDER_INDEX, 1); +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// testContract.batchFillOrdersNoThrow, +// orders, +// fillAmounts, +// signatures, +// ); +// expect(actualResult).to.deep.eq(expectedResult); +// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); +// }); + +// it('reverts if there are more orders than fill amounts', async () => { +// const COUNT = 8; +// const orders = _.times(COUNT, () => randomOrder()); +// const fillAmounts = _.times(COUNT - 1, i => orders[i].takerAssetAmount); +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// const expectedError = new AnyRevertError(); // Just a generic revert. +// const tx = transactionHelper.getResultAndReceiptAsync( +// testContract.batchFillOrdersNoThrow, +// orders, +// fillAmounts, +// signatures, +// ); +// return expect(tx).to.revertWith(expectedError); +// }); + +// it('reverts if there are more orders than signatures', async () => { +// const COUNT = 8; +// const orders = _.times(COUNT, () => randomOrder()); +// const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); +// const signatures = _.times(COUNT - 1, i => createOrderSignature(orders[i])); +// const expectedError = new AnyRevertError(); // Just a generic revert. +// const tx = transactionHelper.getResultAndReceiptAsync( +// testContract.batchFillOrdersNoThrow, +// orders, +// fillAmounts, +// signatures, +// ); +// return expect(tx).to.revertWith(expectedError); +// }); +// }); + +// type ExpectedFillOrderCallArgs = [Order, BigNumber, string]; +// type MarketSellBuyArgs = [Order[], BigNumber, string[], ...any[]]; +// type MarketSellBuyContractFunction = () => MutatorContractFunction<[FillResults, ExpectedFillOrderCallArgs[]]>; +// type MarketSellBuySimulator = (...args: MarketSellBuyArgs) => [FillResults, ExpectedFillOrderCallArgs[]]; + +// describe('marketSell*', () => { +// function defineCommonMarketSellOrdersTests( +// getContractFn: MarketSellBuyContractFunction, +// simulator: MarketSellBuySimulator, +// ): void { +// it('works with one order', async () => { +// const COUNT = 1; +// const orders = _.times(COUNT, () => randomOrder()); +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// const takerAssetFillAmount = _.reduce( +// orders, +// (total, o) => o.takerAssetAmount.plus(total), +// constants.ZERO_AMOUNT, +// ); +// const [expectedResult, expectedCalls] = simulator(orders, takerAssetFillAmount, signatures); +// expect(expectedCalls.length).to.eq(COUNT); +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// getContractFn, +// orders, +// takerAssetFillAmount, +// signatures, +// ); +// expect(actualResult).to.deep.eq(expectedResult); +// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); +// }); + +// it('works with many orders', async () => { +// const COUNT = 8; +// const orders = _.times(COUNT, () => randomOrder()); +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// const takerAssetFillAmount = _.reduce( +// orders, +// (total, o) => o.takerAssetAmount.plus(total), +// constants.ZERO_AMOUNT, +// ); +// const [expectedResult, expectedCalls] = simulator(orders, takerAssetFillAmount, signatures); +// expect(expectedCalls.length).to.eq(COUNT); +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// getContractFn, +// orders, +// takerAssetFillAmount, +// signatures, +// ); +// expect(actualResult).to.deep.eq(expectedResult); +// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); +// }); + +// it('works with duplicate orders', async () => { +// const NUM_UNIQUE_ORDERS = 2; +// const COUNT = 4; +// const uniqueOrders = _.times(NUM_UNIQUE_ORDERS, () => randomOrder()); +// const orders = _.shuffle(_.flatten(_.times(COUNT / NUM_UNIQUE_ORDERS, () => uniqueOrders))); +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// const takerAssetFillAmount = _.reduce( +// orders, +// (total, o) => o.takerAssetAmount.plus(total), +// constants.ZERO_AMOUNT, +// ); +// const [expectedResult, expectedCalls] = simulator(orders, takerAssetFillAmount, signatures); +// expect(expectedCalls.length).to.eq(COUNT); +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// getContractFn, +// orders, +// takerAssetFillAmount, +// signatures, +// ); +// expect(actualResult).to.deep.eq(expectedResult); +// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); +// }); + +// it('stops when filled == `takerAssetFillAmount`', async () => { +// const COUNT = 4; +// const orders = _.times(COUNT, () => randomOrder()); +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// // Skip the last order in our `takerAssetFillAmount` calculation. +// const takerAssetFillAmount = _.reduce( +// orders.slice(0, COUNT - 1), +// (total, o) => o.takerAssetAmount.plus(total), +// constants.ZERO_AMOUNT, +// ); +// const [expectedResult, expectedCalls] = simulator(orders, takerAssetFillAmount, signatures); +// // It should stop filling after the penultimate order. +// expect(expectedCalls.length).to.eq(COUNT - 1); +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// getContractFn, +// orders, +// takerAssetFillAmount, +// signatures, +// ); +// expect(actualResult).to.deep.eq(expectedResult); +// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); +// }); + +// it('stops when filled > `takerAssetFillAmount`', async () => { +// const COUNT = 4; +// const orders = _.times(COUNT, () => randomOrder()); +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// const takerAssetFillAmount = _.reduce( +// orders, +// (total, o) => o.takerAssetAmount.plus(total), +// constants.ZERO_AMOUNT, +// ); +// // Because `TestWrapperFunctions` always fills `takerAssetAmount` +// // setting the first order's `takerAssetAmount` to larger than +// // `takerAssetFillAmount` will cause an overfill. +// orders[0].takerAssetAmount = takerAssetFillAmount.plus(1); +// const [expectedResult, expectedCalls] = simulator(orders, takerAssetFillAmount, signatures); +// // It should stop filling after first order. +// expect(expectedCalls.length).to.eq(1); +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// getContractFn, +// orders, +// takerAssetFillAmount, +// signatures, +// ); +// expect(actualResult).to.deep.eq(expectedResult); +// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); +// }); + +// it('reverts when an overflow occurs when summing fill results', async () => { +// const COUNT = 2; +// const orders = _.times(COUNT, () => randomOrder()); +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// orders[1].takerAssetAmount = MAX_UINT256; +// const takerAssetFillAmount = MAX_UINT256; +// const expectedError = new SafeMathRevertErrors.Uint256BinOpError( +// SafeMathRevertErrors.BinOpErrorCodes.AdditionOverflow, +// orders[0].takerAssetAmount, +// orders[1].takerAssetAmount, +// ); +// const tx = transactionHelper.getResultAndReceiptAsync(getContractFn, orders, takerAssetFillAmount, signatures); +// return expect(tx).to.revertWith(expectedError); +// }); + +// it('returns empty fill results with no orders', async () => { +// const [expectedResult, expectedCalls] = simulator([], constants.ZERO_AMOUNT, []); +// expect(expectedCalls.length).to.eq(0); +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// getContractFn, +// [], +// constants.ZERO_AMOUNT, +// [], +// ); + +// expect(actualResult).to.deep.eq(expectedResult); +// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); +// }); +// } + +// function simulateMarketSellOrders( +// orders: Order[], +// takerAssetFillAmount: BigNumber, +// signatures: string[], +// ): [FillResults, ExpectedFillOrderCallArgs[]] { +// const fillOrderCalls = []; +// let fillResults = _.cloneDeep(EMPTY_FILL_RESULTS); +// for (const [order, signature] of _.zip(orders, signatures) as [[Order, string]]) { +// const remainingTakerAssetFillAmount = safeSub(takerAssetFillAmount, fillResults.takerAssetFilledAmount); +// if (order.salt !== ALWAYS_FAILING_SALT) { +// fillOrderCalls.push([order, remainingTakerAssetFillAmount, signature]); +// } +// fillResults = addFillResults(fillResults, getExpectedFillResults(order, signature)); +// if (fillResults.takerAssetFilledAmount.gte(takerAssetFillAmount)) { +// break; +// } +// } +// return [fillResults, fillOrderCalls as any]; +// } + +// describe('marketSellOrdersNoThrow', () => { +// defineCommonMarketSellOrdersTests(() => testContract.marketSellOrdersNoThrow, simulateMarketSellOrders); + +// it('works when any fills revert', async () => { +// const COUNT = 4; +// const BAD_ORDERS_COUNT = 2; +// const orders = _.times(COUNT, () => randomOrder()); +// const badOrders = _.sampleSize(orders, BAD_ORDERS_COUNT); +// for (const order of badOrders) { +// order.salt = ALWAYS_FAILING_SALT; +// } +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// const takerAssetFillAmount = _.reduce( +// orders, +// (total, o) => o.takerAssetAmount.plus(total), +// constants.ZERO_AMOUNT, +// ); +// const [expectedResult, expectedCalls] = simulateMarketSellOrders( +// orders, +// takerAssetFillAmount, +// signatures, +// ); +// expect(expectedCalls.length).to.eq(COUNT - BAD_ORDERS_COUNT); +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// testContract.marketSellOrdersNoThrow, +// orders, +// takerAssetFillAmount, +// signatures, +// ); +// expect(actualResult).to.deep.eq(expectedResult); +// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); +// }); + +// it('works when all fills revert', async () => { +// const COUNT = 4; +// const orders = _.times(COUNT, () => randomOrder({ salt: ALWAYS_FAILING_SALT })); +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// const takerAssetFillAmount = _.reduce( +// orders, +// (total, o) => o.takerAssetAmount.plus(total), +// constants.ZERO_AMOUNT, +// ); +// const [expectedResult, expectedCalls] = simulateMarketSellOrders( +// orders, +// takerAssetFillAmount, +// signatures, +// ); +// expect(expectedCalls.length).to.eq(0); +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// testContract.marketSellOrdersNoThrow, +// orders, +// takerAssetFillAmount, +// signatures, +// ); +// expect(actualResult).to.deep.eq(expectedResult); +// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); +// }); +// }); + +// describe('marketSellOrdersFillOrKill', () => { +// defineCommonMarketSellOrdersTests(() => testContract.marketSellOrdersNoThrow, simulateMarketSellOrders); + +// it('reverts when filled < `takerAssetFillAmount`', async () => { +// const COUNT = 4; +// const orders = _.times(COUNT, () => randomOrder()); +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// const takerAssetFillAmount = _.reduce( +// orders, +// (total, o) => o.takerAssetAmount.plus(total), +// constants.ZERO_AMOUNT, +// ).plus(1); +// const expectedError = new ExchangeRevertErrors.IncompleteFillError( +// ExchangeRevertErrors.IncompleteFillErrorCode.IncompleteMarketSellOrders, +// takerAssetFillAmount, +// takerAssetFillAmount.minus(1), +// ); +// const tx = transactionHelper.getResultAndReceiptAsync( +// testContract.marketSellOrdersFillOrKill, +// orders, +// takerAssetFillAmount, +// signatures, +// ); +// return expect(tx).to.revertWith(expectedError); +// }); + +// it('works when fills fail but can still sell `takerAssetFillAmount`', async () => { +// const COUNT = 4; +// const BAD_ORDERS_COUNT = 2; +// const orders = _.times(COUNT, () => randomOrder()); +// const badOrders = _.sampleSize(orders, BAD_ORDERS_COUNT); +// for (const order of badOrders) { +// order.salt = ALWAYS_FAILING_SALT; +// } +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// const takerAssetFillAmount = _.reduce( +// orders, +// (total, o) => o.takerAssetAmount.plus(total), +// constants.ZERO_AMOUNT, +// ).minus(_.reduce(badOrders, (total, o) => o.takerAssetAmount.plus(total), constants.ZERO_AMOUNT)); +// const [expectedResult, expectedCalls] = simulateMarketSellOrders( +// orders, +// takerAssetFillAmount, +// signatures, +// ); +// expect(expectedCalls.length).to.eq(COUNT - BAD_ORDERS_COUNT); +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// testContract.marketSellOrdersFillOrKill, +// orders, +// takerAssetFillAmount, +// signatures, +// ); +// expect(actualResult).to.deep.eq(expectedResult); +// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); +// }); + +// it('reverts when a failed fill results in selling less than `takerAssetFillAmount`', async () => { +// const COUNT = 4; +// const BAD_ORDERS_COUNT = 2; +// const orders = _.times(COUNT, () => randomOrder()); +// const badOrders = _.sampleSize(orders, BAD_ORDERS_COUNT); +// for (const order of badOrders) { +// order.salt = ALWAYS_FAILING_SALT; +// } +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// const badOrdersAmount = _.reduce( +// badOrders, +// (total, o) => o.takerAssetAmount.plus(total), +// constants.ZERO_AMOUNT, +// ); +// const takerAssetFillAmount = _.reduce( +// orders, +// (total, o) => o.takerAssetAmount.plus(total), +// constants.ZERO_AMOUNT, +// ) +// .minus(badOrdersAmount) +// .plus(1); +// const expectedError = new ExchangeRevertErrors.IncompleteFillError( +// ExchangeRevertErrors.IncompleteFillErrorCode.IncompleteMarketSellOrders, +// takerAssetFillAmount, +// takerAssetFillAmount.minus(1), +// ); +// const tx = transactionHelper.getResultAndReceiptAsync( +// testContract.marketSellOrdersFillOrKill, +// orders, +// takerAssetFillAmount, +// signatures, +// ); +// return expect(tx).to.revertWith(expectedError); +// }); +// }); +// }); + +// describe('marketBuy*', () => { +// function defineCommonMarketBuyOrdersTests( +// getContractFn: () => MarketSellBuyContractFunction, +// simulator: MarketSellBuySimulator, +// ): void { +// it('works with one order', async () => { +// const COUNT = 1; +// const orders = _.times(COUNT, () => randomOrder()); +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// const makerAssetFillAmount = _.reduce( +// orders, +// (total, o) => o.makerAssetAmount.plus(total), +// constants.ZERO_AMOUNT, +// ); +// const [expectedResult, expectedCalls] = simulator(orders, makerAssetFillAmount, signatures); +// expect(expectedCalls.length).to.eq(COUNT); +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// getContractFn, +// orders, +// makerAssetFillAmount, +// signatures, +// ); +// expect(actualResult).to.deep.eq(expectedResult); +// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); +// }); + +// it('works with many orders', async () => { +// const COUNT = 8; +// const orders = _.times(COUNT, () => randomOrder()); +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// const makerAssetFillAmount = _.reduce( +// orders, +// (total, o) => o.makerAssetAmount.plus(total), +// constants.ZERO_AMOUNT, +// ); +// const [expectedResult, expectedCalls] = simulator(orders, makerAssetFillAmount, signatures); +// expect(expectedCalls.length).to.eq(COUNT); +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// getContractFn, +// orders, +// makerAssetFillAmount, +// signatures, +// ); +// expect(actualResult).to.deep.eq(expectedResult); +// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); +// }); + +// it('works with duplicate orders', async () => { +// const NUM_UNIQUE_ORDERS = 2; +// const COUNT = 4; +// const uniqueOrders = _.times(NUM_UNIQUE_ORDERS, () => randomOrder()); +// const orders = _.shuffle(_.flatten(_.times(COUNT / NUM_UNIQUE_ORDERS, () => uniqueOrders))); +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// const makerAssetFillAmount = _.reduce( +// orders, +// (total, o) => o.makerAssetAmount.plus(total), +// constants.ZERO_AMOUNT, +// ); +// const [expectedResult, expectedCalls] = simulator(orders, makerAssetFillAmount, signatures); +// expect(expectedCalls.length).to.eq(COUNT); +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// getContractFn(), +// orders, +// makerAssetFillAmount, +// signatures, +// ); +// expect(actualResult).to.deep.eq(expectedResult); +// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); +// }); + +// it('stops when filled == `makerAssetFillAmount`', async () => { +// const COUNT = 4; +// const orders = _.times(COUNT, () => randomOrder()); +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// // Skip the last order in our `makerAssetFillAmount` calculation. +// const makerAssetFillAmount = _.reduce( +// orders.slice(0, COUNT - 1), +// (total, o) => o.makerAssetAmount.plus(total), +// constants.ZERO_AMOUNT, +// ); +// const [expectedResult, expectedCalls] = simulator(orders, makerAssetFillAmount, signatures); +// // It should stop filling after the penultimate order. +// expect(expectedCalls.length).to.eq(COUNT - 1); +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// getContractFn(), +// orders, +// makerAssetFillAmount, +// signatures, +// ); +// expect(actualResult).to.deep.eq(expectedResult); +// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); +// }); + +// it('stops when filled > `makerAssetFillAmount`', async () => { +// const COUNT = 4; +// const orders = _.times(COUNT, () => randomOrder()); +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// const makerAssetFillAmount = _.reduce( +// orders, +// (total, o) => o.makerAssetAmount.plus(total), +// constants.ZERO_AMOUNT, +// ); +// // Because `TestWrapperFunctions` always fills `makerAssetAmount` +// // setting the first order's `makerAssetAmount` to larger than +// // `makerAssetFillAmount` will cause an overfill. +// orders[0].makerAssetAmount = makerAssetFillAmount.plus(1); +// const [expectedResult, expectedCalls] = simulator(orders, makerAssetFillAmount, signatures); +// // It should stop filling after first order. +// expect(expectedCalls.length).to.eq(1); +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// getContractFn(), +// orders, +// makerAssetFillAmount, +// signatures, +// ); +// expect(actualResult).to.deep.eq(expectedResult); +// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); +// }); + +// it('reverts when an overflow occurs when computing `remainingTakerAssetFillAmount`', async () => { +// const orders = [randomOrder({ takerAssetAmount: MAX_UINT256 })]; +// const signatures = _.times(orders.length, i => createOrderSignature(orders[i])); +// const makerAssetFillAmount = new BigNumber(2); +// const expectedError = new SafeMathRevertErrors.Uint256BinOpError( +// SafeMathRevertErrors.BinOpErrorCodes.MultiplicationOverflow, +// orders[0].takerAssetAmount, +// makerAssetFillAmount, +// ); +// const tx = transactionHelper.getResultAndReceiptAsync(getContractFn(), orders, makerAssetFillAmount, signatures); +// return expect(tx).to.revertWith(expectedError); +// }); + +// it("reverts when an order's `makerAssetAmount` is zero", async () => { +// const orders = [randomOrder({ makerAssetAmount: constants.ZERO_AMOUNT })]; +// const signatures = _.times(orders.length, i => createOrderSignature(orders[i])); +// const makerAssetFillAmount = ONE_ETHER; +// const expectedError = new SafeMathRevertErrors.Uint256BinOpError( +// SafeMathRevertErrors.BinOpErrorCodes.DivisionByZero, +// orders[0].takerAssetAmount.times(makerAssetFillAmount), +// orders[0].makerAssetAmount, +// ); +// const tx = transactionHelper.getResultAndReceiptAsync(getContractFn(), orders, makerAssetFillAmount, signatures); +// return expect(tx).to.revertWith(expectedError); +// }); + +// it('reverts when an overflow occurs when summing fill results', async () => { +// const orders = [ +// randomOrder({ +// takerAssetAmount: new BigNumber(1), +// makerAssetAmount: new BigNumber(1), +// }), +// randomOrder({ +// takerAssetAmount: new BigNumber(1), +// makerAssetAmount: MAX_UINT256, +// }), +// ]; +// const signatures = _.times(orders.length, i => createOrderSignature(orders[i])); +// const makerAssetFillAmount = new BigNumber(2); +// const expectedError = new SafeMathRevertErrors.Uint256BinOpError( +// SafeMathRevertErrors.BinOpErrorCodes.AdditionOverflow, +// orders[0].makerAssetAmount, +// orders[1].makerAssetAmount, +// ); +// const tx = transactionHelper.getResultAndReceiptAsync(getContractFn(), orders, makerAssetFillAmount, signatures); +// return expect(tx).to.revertWith(expectedError); +// }); + +// it('returns empty fill results with no orders', async () => { +// const [expectedResult, expectedCalls] = simulator([], constants.ZERO_AMOUNT, []); +// expect(expectedCalls.length).to.eq(0); +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// getContractFn(), +// [], +// constants.ZERO_AMOUNT, +// [], +// ); + +// expect(actualResult).to.deep.eq(expectedResult); +// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); +// }); +// } + +// function simulateMarketBuyOrdersNoThrow( +// orders: Order[], +// makerAssetFillAmount: BigNumber, +// signatures: string[], +// ): [FillResults, ExpectedFillOrderCallArgs[]] { +// const fillOrderCalls = []; +// let fillResults = _.cloneDeep(EMPTY_FILL_RESULTS); +// for (const [order, signature] of _.zip(orders, signatures) as [[Order, string]]) { +// const remainingMakerAssetFillAmount = safeSub(makerAssetFillAmount, fillResults.makerAssetFilledAmount); +// const remainingTakerAssetFillAmount = getPartialAmountFloor( +// order.takerAssetAmount, +// order.makerAssetAmount, +// remainingMakerAssetFillAmount, +// ); +// if (order.salt !== ALWAYS_FAILING_SALT) { +// fillOrderCalls.push([order, remainingTakerAssetFillAmount, signature]); +// } +// fillResults = addFillResults(fillResults, getExpectedFillResults(order, signature)); +// if (fillResults.makerAssetFilledAmount.gte(makerAssetFillAmount)) { +// break; +// } +// } +// return [fillResults, fillOrderCalls as any]; +// } + +// describe('marketBuyOrdersNoThrow', () => { +// defineCommonMarketBuyOrdersTests(() => testContract.marketBuyOrdersNoThrow, simulateMarketBuyOrdersNoThrow); + +// it('works when any fills revert', async () => { +// const COUNT = 4; +// const BAD_ORDERS_COUNT = 2; +// const orders = _.times(COUNT, () => randomOrder()); +// const badOrders = _.sampleSize(orders, BAD_ORDERS_COUNT); +// for (const order of badOrders) { +// order.salt = ALWAYS_FAILING_SALT; +// } +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// const makerAssetFillAmount = _.reduce( +// orders, +// (total, o) => o.makerAssetAmount.plus(total), +// constants.ZERO_AMOUNT, +// ); +// const [expectedResult, expectedCalls] = simulateMarketBuyOrdersNoThrow( +// orders, +// makerAssetFillAmount, +// signatures, +// ); +// expect(expectedCalls.length).to.eq(COUNT - BAD_ORDERS_COUNT); +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// testContract.marketBuyOrdersNoThrow, +// orders, +// makerAssetFillAmount, +// signatures, +// ); +// expect(actualResult).to.deep.eq(expectedResult); +// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); +// }); + +// it('works when all fills revert', async () => { +// const COUNT = 4; +// const orders = _.times(COUNT, () => randomOrder({ salt: ALWAYS_FAILING_SALT })); +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// const makerAssetFillAmount = _.reduce( +// orders, +// (total, o) => o.makerAssetAmount.plus(total), +// constants.ZERO_AMOUNT, +// ); +// const [expectedResult, expectedCalls] = simulateMarketBuyOrdersNoThrow( +// orders, +// makerAssetFillAmount, +// signatures, +// ); +// expect(expectedCalls.length).to.eq(0); +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// testContract.marketBuyOrdersNoThrow, +// orders, +// makerAssetFillAmount, +// signatures, +// ); +// expect(actualResult).to.deep.eq(expectedResult); +// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); +// }); +// }); + +// describe('marketBuyOrdersFillOrKill', () => { +// defineCommonMarketBuyOrdersTests( +// () => testContract.marketBuyOrdersFillOrKill, +// simulateMarketBuyOrdersNoThrow, +// ); + +// it('reverts when filled < `makerAssetFillAmount`', async () => { +// const COUNT = 4; +// const orders = _.times(COUNT, () => randomOrder()); +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// const makerAssetFillAmount = _.reduce( +// orders, +// (total, o) => o.makerAssetAmount.plus(total), +// constants.ZERO_AMOUNT, +// ).plus(1); +// const expectedError = new ExchangeRevertErrors.IncompleteFillError( +// ExchangeRevertErrors.IncompleteFillErrorCode.IncompleteMarketBuyOrders, +// makerAssetFillAmount, +// makerAssetFillAmount.minus(1), +// ); +// const tx = transactionHelper.getResultAndReceiptAsync( +// testContract.marketBuyOrdersFillOrKill, +// orders, +// makerAssetFillAmount, +// signatures, +// ); +// return expect(tx).to.revertWith(expectedError); +// }); + +// it('works when fills fail but can still buy `makerAssetFillAmount`', async () => { +// const COUNT = 4; +// const BAD_ORDERS_COUNT = 2; +// const orders = _.times(COUNT, () => randomOrder()); +// const badOrders = _.sampleSize(orders, BAD_ORDERS_COUNT); +// for (const order of badOrders) { +// order.salt = ALWAYS_FAILING_SALT; +// } +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// const makerAssetFillAmount = _.reduce( +// orders, +// (total, o) => o.makerAssetAmount.plus(total), +// constants.ZERO_AMOUNT, +// ).minus(_.reduce(badOrders, (total, o) => o.makerAssetAmount.plus(total), constants.ZERO_AMOUNT)); +// const [expectedResult, expectedCalls] = simulateMarketBuyOrdersNoThrow( +// orders, +// makerAssetFillAmount, +// signatures, +// ); +// expect(expectedCalls.length).to.eq(COUNT - BAD_ORDERS_COUNT); +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// testContract.marketBuyOrdersFillOrKill, +// orders, +// makerAssetFillAmount, +// signatures, +// ); +// expect(actualResult).to.deep.eq(expectedResult); +// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); +// }); + +// it('reverts when a failed fill results in buying less than `makerAssetFillAmount`', async () => { +// const COUNT = 4; +// const BAD_ORDERS_COUNT = 2; +// const orders = _.times(COUNT, () => randomOrder()); +// const badOrders = _.sampleSize(orders, BAD_ORDERS_COUNT); +// for (const order of badOrders) { +// order.salt = ALWAYS_FAILING_SALT; +// } +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// const badOrdersAmount = _.reduce( +// badOrders, +// (total, o) => o.makerAssetAmount.plus(total), +// constants.ZERO_AMOUNT, +// ); +// const makerAssetFillAmount = _.reduce( +// orders, +// (total, o) => o.makerAssetAmount.plus(total), +// constants.ZERO_AMOUNT, +// ) +// .minus(badOrdersAmount) +// .plus(1); +// const expectedError = new ExchangeRevertErrors.IncompleteFillError( +// ExchangeRevertErrors.IncompleteFillErrorCode.IncompleteMarketBuyOrders, +// makerAssetFillAmount, +// makerAssetFillAmount.minus(1), +// ); +// const tx = transactionHelper.getResultAndReceiptAsync( +// testContract.marketBuyOrdersFillOrKill, +// orders, +// makerAssetFillAmount, +// signatures, +// ); +// return expect(tx).to.revertWith(expectedError); +// }); +// }); +// }); + +// describe('batchCancelOrders', () => { +// // Asserts that `_cancelOrder()` was called in the same order and with the same +// // arguments as given by examining receipt logs. +// function assertCancelOrderCallsFromLogs(logs: LogEntry[], calls: Order[]): void { +// expect(logs.length).to.eq(calls.length); +// for (const i of _.times(calls.length)) { +// const log = (logs[i] as any) as LogWithDecodedArgs; +// const expectedOrder = calls[i]; +// expect(log.event).to.eq('CancelOrderCalled'); +// assertSameOrderFromEvent(log.args.order as any, expectedOrder); +// } +// } + +// it('works with no orders', async () => { +// const [, receipt] = await transactionHelper.getResultAndReceiptAsync(testContract.batchCancelOrders, []); +// assertCancelOrderCallsFromLogs(receipt.logs, []); +// }); + +// it('works with many orders', async () => { +// const COUNT = 8; +// const orders = _.times(COUNT, () => randomOrder({ makerAddress: senderAddress })); +// const [, receipt] = await transactionHelper.getResultAndReceiptAsync(testContract.batchCancelOrders, orders); +// assertCancelOrderCallsFromLogs(receipt.logs, orders); +// }); + +// it('works with duplicate orders', async () => { +// const UNIQUE_ORDERS = 2; +// const COUNT = 6; +// const uniqueOrders = _.times(UNIQUE_ORDERS, () => randomOrder({ makerAddress: senderAddress })); +// const orders = _.shuffle(_.flatten(_.times(COUNT / UNIQUE_ORDERS, () => uniqueOrders))); +// const [, receipt] = await transactionHelper.getResultAndReceiptAsync(testContract.batchCancelOrders, orders); +// assertCancelOrderCallsFromLogs(receipt.logs, orders); +// }); + +// it('reverts if one `_cancelOrder()` reverts', async () => { +// const COUNT = 8; +// const FAILING_ORDER_INDEX = 4; +// const orders = _.times(COUNT, () => randomOrder({ makerAddress: senderAddress })); +// const failingOrder = orders[FAILING_ORDER_INDEX]; +// failingOrder.salt = ALWAYS_FAILING_SALT; +// const expectedError = ALWAYS_FAILING_SALT_REVERT_ERROR; +// const tx = transactionHelper.getResultAndReceiptAsync(testContract.batchCancelOrders, orders); +// return expect(tx).to.revertWith(expectedError); +// }); +// }); +// }); +// // tslint:disable-next-line: max-file-line-count diff --git a/contracts/extensions/test/balance_threshold_filter.ts b/contracts/extensions/test/balance_threshold_filter.ts index 7fe4ee5566..e1549c4707 100644 --- a/contracts/extensions/test/balance_threshold_filter.ts +++ b/contracts/extensions/test/balance_threshold_filter.ts @@ -126,7 +126,7 @@ describe(ContractName.BalanceThresholdFilter, () => { ); defaultMakerAssetAddress = erc20TokenA.address; defaultTakerAssetAddress = erc20TokenB.address; - zrxAssetData = await devUtils.encodeERC20AssetData.callAsync(zrxToken.address); + zrxAssetData = await devUtils.encodeERC20AssetData(zrxToken.address).callAsync(); // Create proxies const erc20Proxy = await erc20Wrapper.deployProxyAsync(); await erc20Wrapper.setBalancesAndAllowancesAsync(); @@ -142,7 +142,7 @@ describe(ContractName.BalanceThresholdFilter, () => { exchangeWrapper = new ExchangeWrapper(exchangeInstance); // Register proxies await exchangeWrapper.registerAssetProxyAsync(erc20Proxy.address, owner); - await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(exchangeInstance.address, { + await erc20Proxy.addAuthorizedAddress(exchangeInstance.address).sendTransactionAsync({ from: owner, }); // Deploy Balance Threshold Filters @@ -173,8 +173,8 @@ describe(ContractName.BalanceThresholdFilter, () => { // Default order parameters defaultOrderParams = { feeRecipientAddress, - makerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultMakerAssetAddress), - takerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultTakerAssetAddress), + makerAssetData: await devUtils.encodeERC20AssetData(defaultMakerAssetAddress).callAsync(), + takerAssetData: await devUtils.encodeERC20AssetData(defaultTakerAssetAddress).callAsync(), makerAssetAmount, takerAssetAmount, makerFee: Web3Wrapper.toBaseUnitAmount(new BigNumber(100), DECIMALS_DEFAULT), @@ -296,12 +296,9 @@ describe(ContractName.BalanceThresholdFilter, () => { const badSelectorHex = '0x00000000'; const signatureHex = '0x'; // Call valid forwarder - const tx = erc721BalanceThresholdFilterInstance.executeTransaction.sendTransactionAsync( - salt, - validTakerAddress, - badSelectorHex, - signatureHex, - ); + const tx = erc721BalanceThresholdFilterInstance + .executeTransaction(salt, validTakerAddress, badSelectorHex, signatureHex) + .sendTransactionAsync(); return expect(tx).to.revertWith(RevertReason.InvalidOrBlockedExchangeSelector); }); it('should revert if senderAddress is not set to the valid forwarding contract', async () => { @@ -1239,8 +1236,8 @@ describe(ContractName.BalanceThresholdFilter, () => { feeRecipientAddress, }); const signedOrderRight = await orderFactory2.newSignedOrderAsync({ - makerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultTakerAssetAddress), - takerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultMakerAssetAddress), + makerAssetData: await devUtils.encodeERC20AssetData(defaultTakerAssetAddress).callAsync(), + takerAssetData: await devUtils.encodeERC20AssetData(defaultMakerAssetAddress).callAsync(), makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(75), 0), takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(13), 0), makerFee: Web3Wrapper.toBaseUnitAmount(new BigNumber(1), 18), diff --git a/contracts/extensions/test/dutch_auction.ts b/contracts/extensions/test/dutch_auction.ts index c7cfab18ab..83df0c61c3 100644 --- a/contracts/extensions/test/dutch_auction.ts +++ b/contracts/extensions/test/dutch_auction.ts @@ -89,7 +89,7 @@ describe(ContractName.DutchAuction, () => { wethContract = await WETH9Contract.deployFrom0xArtifactAsync(artifacts.WETH9, provider, txDefaults, artifacts); erc20Wrapper.addDummyTokenContract(wethContract as any); - const zrxAssetData = await devUtils.encodeERC20AssetData.callAsync(zrxToken.address); + const zrxAssetData = await devUtils.encodeERC20AssetData(zrxToken.address).callAsync(); const exchangeInstance = await ExchangeContract.deployFrom0xArtifactAsync( artifacts.Exchange, provider, @@ -102,10 +102,10 @@ describe(ContractName.DutchAuction, () => { await exchangeWrapper.registerAssetProxyAsync(erc20Proxy.address, owner); await exchangeWrapper.registerAssetProxyAsync(erc721Proxy.address, owner); - await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(exchangeInstance.address, { + await erc20Proxy.addAuthorizedAddress(exchangeInstance.address).sendTransactionAsync({ from: owner, }); - await erc721Proxy.addAuthorizedAddress.sendTransactionAsync(exchangeInstance.address, { + await erc721Proxy.addAuthorizedAddress(exchangeInstance.address).sendTransactionAsync({ from: owner, }); @@ -130,11 +130,9 @@ describe(ContractName.DutchAuction, () => { }), ); await web3Wrapper.awaitTransactionSuccessAsync( - await wethContract.approve.sendTransactionAsync( - erc20Proxy.address, - constants.UNLIMITED_ALLOWANCE_IN_BASE_UNITS, - { from: takerAddress }, - ), + await wethContract + .approve(erc20Proxy.address, constants.UNLIMITED_ALLOWANCE_IN_BASE_UNITS) + .sendTransactionAsync({ from: takerAddress }), ); web3Wrapper.abiDecoder.addABI(exchangeInstance.abi); web3Wrapper.abiDecoder.addABI(zrxToken.abi); @@ -156,11 +154,11 @@ describe(ContractName.DutchAuction, () => { // taker address or sender address should be set to the ducth auction contract takerAddress: dutchAuctionContract.address, makerAssetData: assetDataUtils.encodeDutchAuctionAssetData( - await devUtils.encodeERC20AssetData.callAsync(defaultMakerAssetAddress), + await devUtils.encodeERC20AssetData(defaultMakerAssetAddress).callAsync(), auctionBeginTimeSeconds, auctionBeginAmount, ), - takerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultTakerAssetAddress), + takerAssetData: await devUtils.encodeERC20AssetData(defaultTakerAssetAddress).callAsync(), makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(200), DECIMALS_DEFAULT), takerAssetAmount: auctionEndAmount, expirationTimeSeconds: auctionEndTimeSeconds, @@ -182,7 +180,7 @@ describe(ContractName.DutchAuction, () => { const takerPrivateKey = constants.TESTRPC_PRIVATE_KEYS[accounts.indexOf(takerAddress)]; sellerOrderFactory = new OrderFactory(makerPrivateKey, sellerDefaultOrderParams); buyerOrderFactory = new OrderFactory(takerPrivateKey, buyerDefaultOrderParams); - defaultERC20MakerAssetData = await devUtils.encodeERC20AssetData.callAsync(defaultMakerAssetAddress); + defaultERC20MakerAssetData = await devUtils.encodeERC20AssetData(defaultMakerAssetAddress).callAsync(); }); after(async () => { await blockchainLifecycle.revertAsync(); @@ -321,7 +319,7 @@ describe(ContractName.DutchAuction, () => { }); it('asset data contains auction parameters', async () => { sellOrder = await sellerOrderFactory.newSignedOrderAsync({ - makerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultMakerAssetAddress), + makerAssetData: await devUtils.encodeERC20AssetData(defaultMakerAssetAddress).callAsync(), }); const tx = dutchAuctionTestWrapper.matchOrdersAsync(buyOrder, sellOrder, takerAddress); return expect(tx).to.revertWith(RevertReason.InvalidAssetData); @@ -330,10 +328,9 @@ describe(ContractName.DutchAuction, () => { describe('ERC721', () => { it('should match orders when ERC721', async () => { const makerAssetId = erc721MakerAssetIds[0]; - const erc721MakerAssetData = await devUtils.encodeERC721AssetData.callAsync( - erc721Token.address, - makerAssetId, - ); + const erc721MakerAssetData = await devUtils + .encodeERC721AssetData(erc721Token.address, makerAssetId) + .callAsync(); const makerAssetData = assetDataUtils.encodeDutchAuctionAssetData( erc721MakerAssetData, auctionBeginTimeSeconds, @@ -356,7 +353,7 @@ describe(ContractName.DutchAuction, () => { expect(newBalances[makerAddress][wethContract.address]).to.be.bignumber.gte( erc20Balances[makerAddress][wethContract.address].plus(afterAuctionDetails.currentAmount), ); - const newOwner = await erc721Token.ownerOf.callAsync(makerAssetId); + const newOwner = await erc721Token.ownerOf(makerAssetId).callAsync(); expect(newOwner).to.be.bignumber.equal(takerAddress); }); }); diff --git a/contracts/extensions/test/order_matcher.ts b/contracts/extensions/test/order_matcher.ts index bd85592601..079ae9b937 100644 --- a/contracts/extensions/test/order_matcher.ts +++ b/contracts/extensions/test/order_matcher.ts @@ -114,7 +114,7 @@ describe('OrderMatcher', () => { provider, txDefaults, artifacts, - await devUtils.encodeERC20AssetData.callAsync(zrxToken.address), + await devUtils.encodeERC20AssetData(zrxToken.address).callAsync(), new BigNumber(chainId), ); exchangeWrapper = new ExchangeWrapper(exchange); @@ -122,7 +122,7 @@ describe('OrderMatcher', () => { await exchangeWrapper.registerAssetProxyAsync(erc721Proxy.address, owner); // Authorize ERC20 trades by exchange await web3Wrapper.awaitTransactionSuccessAsync( - await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, { + await erc20Proxy.addAuthorizedAddress(exchange.address).sendTransactionAsync({ from: owner, }), constants.AWAIT_TRANSACTION_MINED_MS, @@ -138,35 +138,33 @@ describe('OrderMatcher', () => { // Set default addresses defaultERC20MakerAssetAddress = erc20TokenA.address; defaultERC20TakerAssetAddress = erc20TokenB.address; - leftMakerAssetData = await devUtils.encodeERC20AssetData.callAsync(defaultERC20MakerAssetAddress); - leftTakerAssetData = await devUtils.encodeERC20AssetData.callAsync(defaultERC20TakerAssetAddress); + leftMakerAssetData = await devUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress).callAsync(); + leftTakerAssetData = await devUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress).callAsync(); // Set OrderMatcher balances and allowances await web3Wrapper.awaitTransactionSuccessAsync( - await erc20TokenA.setBalance.sendTransactionAsync(orderMatcher.address, constants.INITIAL_ERC20_BALANCE, { + await erc20TokenA.setBalance(orderMatcher.address, constants.INITIAL_ERC20_BALANCE).sendTransactionAsync({ from: owner, }), constants.AWAIT_TRANSACTION_MINED_MS, ); await web3Wrapper.awaitTransactionSuccessAsync( - await erc20TokenB.setBalance.sendTransactionAsync(orderMatcher.address, constants.INITIAL_ERC20_BALANCE, { + await erc20TokenB.setBalance(orderMatcher.address, constants.INITIAL_ERC20_BALANCE).sendTransactionAsync({ from: owner, }), constants.AWAIT_TRANSACTION_MINED_MS, ); - await web3Wrapper.awaitTransactionSuccessAsync( - await orderMatcher.approveAssetProxy.sendTransactionAsync( - leftMakerAssetData, - constants.INITIAL_ERC20_ALLOWANCE, - ), - constants.AWAIT_TRANSACTION_MINED_MS, - ); - await web3Wrapper.awaitTransactionSuccessAsync( - await orderMatcher.approveAssetProxy.sendTransactionAsync( - leftTakerAssetData, - constants.INITIAL_ERC20_ALLOWANCE, - ), - constants.AWAIT_TRANSACTION_MINED_MS, - ); + await web3Wrapper + .awaitTransactionSuccessAsync( + await orderMatcher.approveAssetProxy(leftMakerAssetData, constants.INITIAL_ERC20_ALLOWANCE), + constants.AWAIT_TRANSACTION_MINED_MS, + ) + .sendTransactionAsync(); + await web3Wrapper + .awaitTransactionSuccessAsync( + await orderMatcher.approveAssetProxy(leftTakerAssetData, constants.INITIAL_ERC20_ALLOWANCE), + constants.AWAIT_TRANSACTION_MINED_MS, + ) + .sendTransactionAsync(); // Create default order parameters const defaultOrderParamsLeft = { @@ -238,12 +236,9 @@ describe('OrderMatcher', () => { makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(10), 18), takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(2), 18), }); - const data = exchange.matchOrders.getABIEncodedTransactionData( - signedOrderLeft, - signedOrderRight, - signedOrderLeft.signature, - signedOrderRight.signature, - ); + const data = exchange + .matchOrders(signedOrderLeft, signedOrderRight, signedOrderLeft.signature, signedOrderRight.signature) + .getABIEncodedTransactionData(); const tx = web3Wrapper.sendTransactionAsync({ data, to: orderMatcher.address, @@ -273,13 +268,10 @@ describe('OrderMatcher', () => { // Taker leftMakerAssetSpreadAmount: signedOrderLeft.makerAssetAmount.minus(signedOrderRight.takerAssetAmount), }; - const initialLeftMakerAssetTakerBalance = await erc20TokenA.balanceOf.callAsync(orderMatcher.address); - const data = exchange.matchOrders.getABIEncodedTransactionData( - signedOrderLeft, - signedOrderRight, - signedOrderLeft.signature, - signedOrderRight.signature, - ); + const initialLeftMakerAssetTakerBalance = await erc20TokenA.balanceOf(orderMatcher.address).callAsync(); + const data = exchange + .matchOrders(signedOrderLeft, signedOrderRight, signedOrderLeft.signature, signedOrderRight.signature) + .getABIEncodedTransactionData(); await web3Wrapper.awaitTransactionSuccessAsync( await web3Wrapper.sendTransactionAsync({ data, @@ -289,7 +281,7 @@ describe('OrderMatcher', () => { }), constants.AWAIT_TRANSACTION_MINED_MS, ); - const newLeftMakerAssetTakerBalance = await erc20TokenA.balanceOf.callAsync(orderMatcher.address); + const newLeftMakerAssetTakerBalance = await erc20TokenA.balanceOf(orderMatcher.address).callAsync(); const newErc20Balances = await erc20Wrapper.getBalancesAsync(); expect(newErc20Balances[makerAddressLeft][defaultERC20MakerAssetAddress]).to.be.bignumber.equal( erc20BalancesByOwner[makerAddressLeft][defaultERC20MakerAssetAddress].minus( @@ -334,13 +326,10 @@ describe('OrderMatcher', () => { amountSoldByRightMaker: signedOrderRight.makerAssetAmount, amountBoughtByRightMaker: signedOrderRight.takerAssetAmount, }; - const initialLeftMakerAssetTakerBalance = await erc20TokenA.balanceOf.callAsync(orderMatcher.address); - const data = exchange.matchOrders.getABIEncodedTransactionData( - signedOrderLeft, - signedOrderRight, - signedOrderLeft.signature, - signedOrderRight.signature, - ); + const initialLeftMakerAssetTakerBalance = await erc20TokenA.balanceOf(orderMatcher.address).callAsync(); + const data = exchange + .matchOrders(signedOrderLeft, signedOrderRight, signedOrderLeft.signature, signedOrderRight.signature) + .getABIEncodedTransactionData(); await web3Wrapper.awaitTransactionSuccessAsync( await web3Wrapper.sendTransactionAsync({ data, @@ -350,7 +339,7 @@ describe('OrderMatcher', () => { }), constants.AWAIT_TRANSACTION_MINED_MS, ); - const newLeftMakerAssetTakerBalance = await erc20TokenA.balanceOf.callAsync(orderMatcher.address); + const newLeftMakerAssetTakerBalance = await erc20TokenA.balanceOf(orderMatcher.address).callAsync(); const newErc20Balances = await erc20Wrapper.getBalancesAsync(); expect(newErc20Balances[makerAddressLeft][defaultERC20MakerAssetAddress]).to.be.bignumber.equal( erc20BalancesByOwner[makerAddressLeft][defaultERC20MakerAssetAddress].minus( @@ -396,15 +385,12 @@ describe('OrderMatcher', () => { leftMakerAssetSpreadAmount: signedOrderLeft.makerAssetAmount.minus(signedOrderRight.takerAssetAmount), leftTakerAssetSpreadAmount: signedOrderRight.makerAssetAmount.minus(signedOrderLeft.takerAssetAmount), }; - const initialLeftMakerAssetTakerBalance = await erc20TokenA.balanceOf.callAsync(orderMatcher.address); - const initialLeftTakerAssetTakerBalance = await erc20TokenB.balanceOf.callAsync(orderMatcher.address); + const initialLeftMakerAssetTakerBalance = await erc20TokenA.balanceOf(orderMatcher.address).callAsync(); + const initialLeftTakerAssetTakerBalance = await erc20TokenB.balanceOf(orderMatcher.address).callAsync(); // Match signedOrderLeft with signedOrderRight - const data = exchange.matchOrders.getABIEncodedTransactionData( - signedOrderLeft, - signedOrderRight, - signedOrderLeft.signature, - signedOrderRight.signature, - ); + const data = exchange + .matchOrders(signedOrderLeft, signedOrderRight, signedOrderLeft.signature, signedOrderRight.signature) + .getABIEncodedTransactionData(); await web3Wrapper.awaitTransactionSuccessAsync( await web3Wrapper.sendTransactionAsync({ data, @@ -414,8 +400,8 @@ describe('OrderMatcher', () => { }), constants.AWAIT_TRANSACTION_MINED_MS, ); - const newLeftMakerAssetTakerBalance = await erc20TokenA.balanceOf.callAsync(orderMatcher.address); - const newLeftTakerAssetTakerBalance = await erc20TokenB.balanceOf.callAsync(orderMatcher.address); + const newLeftMakerAssetTakerBalance = await erc20TokenA.balanceOf(orderMatcher.address).callAsync(); + const newLeftTakerAssetTakerBalance = await erc20TokenB.balanceOf(orderMatcher.address).callAsync(); const newErc20Balances = await erc20Wrapper.getBalancesAsync(); expect(newErc20Balances[makerAddressLeft][defaultERC20MakerAssetAddress]).to.be.bignumber.equal( erc20BalancesByOwner[makerAddressLeft][defaultERC20MakerAssetAddress].minus( @@ -454,12 +440,9 @@ describe('OrderMatcher', () => { makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(10), 18), takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(2), 18), }); - const data = exchange.matchOrders.getABIEncodedTransactionData( - signedOrderLeft, - signedOrderRight, - signedOrderLeft.signature, - signedOrderRight.signature, - ); + const data = exchange + .matchOrders(signedOrderLeft, signedOrderRight, signedOrderLeft.signature, signedOrderRight.signature) + .getABIEncodedTransactionData(); const logDecoder = new LogDecoder(web3Wrapper, artifacts); const txReceipt = await logDecoder.getTxWithDecodedLogsAsync( await web3Wrapper.sendTransactionAsync({ @@ -492,12 +475,9 @@ describe('OrderMatcher', () => { await exchangeWrapper.fillOrderAsync(signedOrderRight, takerAddress, { takerAssetFillAmount: signedOrderRight.takerAssetAmount.dividedToIntegerBy(5), }); - const data = exchange.matchOrders.getABIEncodedTransactionData( - signedOrderLeft, - signedOrderRight, - signedOrderLeft.signature, - signedOrderRight.signature, - ); + const data = exchange + .matchOrders(signedOrderLeft, signedOrderRight, signedOrderLeft.signature, signedOrderRight.signature) + .getABIEncodedTransactionData(); const logDecoder = new LogDecoder(web3Wrapper, artifacts); const txReceipt = await logDecoder.getTxWithDecodedLogsAsync( await web3Wrapper.sendTransactionAsync({ @@ -540,15 +520,12 @@ describe('OrderMatcher', () => { leftMakerAssetSpreadAmount: constants.ZERO_AMOUNT, leftTakerAssetSpreadAmount, }; - const initialLeftMakerAssetTakerBalance = await erc20TokenA.balanceOf.callAsync(orderMatcher.address); - const initialLeftTakerAssetTakerBalance = await erc20TokenB.balanceOf.callAsync(orderMatcher.address); + const initialLeftMakerAssetTakerBalance = await erc20TokenA.balanceOf(orderMatcher.address).callAsync(); + const initialLeftTakerAssetTakerBalance = await erc20TokenB.balanceOf(orderMatcher.address).callAsync(); // Match signedOrderLeft with signedOrderRight - const data = exchange.matchOrders.getABIEncodedTransactionData( - signedOrderLeft, - signedOrderRight, - signedOrderLeft.signature, - signedOrderRight.signature, - ); + const data = exchange + .matchOrders(signedOrderLeft, signedOrderRight, signedOrderLeft.signature, signedOrderRight.signature) + .getABIEncodedTransactionData(); await web3Wrapper.awaitTransactionSuccessAsync( await web3Wrapper.sendTransactionAsync({ data, @@ -558,8 +535,8 @@ describe('OrderMatcher', () => { }), constants.AWAIT_TRANSACTION_MINED_MS, ); - const newLeftMakerAssetTakerBalance = await erc20TokenA.balanceOf.callAsync(orderMatcher.address); - const newLeftTakerAssetTakerBalance = await erc20TokenB.balanceOf.callAsync(orderMatcher.address); + const newLeftMakerAssetTakerBalance = await erc20TokenA.balanceOf(orderMatcher.address).callAsync(); + const newLeftTakerAssetTakerBalance = await erc20TokenB.balanceOf(orderMatcher.address).callAsync(); const newErc20Balances = await erc20Wrapper.getBalancesAsync(); expect(newErc20Balances[makerAddressLeft][defaultERC20MakerAssetAddress]).to.be.bignumber.equal( erc20BalancesByOwner[makerAddressLeft][defaultERC20MakerAssetAddress].minus( @@ -610,17 +587,14 @@ describe('OrderMatcher', () => { leftMakerAssetSpreadAmount: signedOrderLeft.makerAssetAmount.minus(signedOrderRight.takerAssetAmount), leftTakerAssetSpreadAmount: signedOrderRight.makerAssetAmount.minus(signedOrderLeft.takerAssetAmount), }; - const initialLeftMakerAssetTakerBalance = await erc20TokenA.balanceOf.callAsync(orderMatcher.address); - const initialLeftTakerAssetTakerBalance = await erc20TokenB.balanceOf.callAsync(orderMatcher.address); + const initialLeftMakerAssetTakerBalance = await erc20TokenA.balanceOf(orderMatcher.address).callAsync(); + const initialLeftTakerAssetTakerBalance = await erc20TokenB.balanceOf(orderMatcher.address).callAsync(); // Match signedOrderLeft with signedOrderRight signedOrderRight.makerAssetData = constants.NULL_BYTES; signedOrderRight.takerAssetData = constants.NULL_BYTES; - const data = exchange.matchOrders.getABIEncodedTransactionData( - signedOrderLeft, - signedOrderRight, - signedOrderLeft.signature, - signedOrderRight.signature, - ); + const data = exchange + .matchOrders(signedOrderLeft, signedOrderRight, signedOrderLeft.signature, signedOrderRight.signature) + .getABIEncodedTransactionData(); await web3Wrapper.awaitTransactionSuccessAsync( await web3Wrapper.sendTransactionAsync({ data, @@ -630,8 +604,8 @@ describe('OrderMatcher', () => { }), constants.AWAIT_TRANSACTION_MINED_MS, ); - const newLeftMakerAssetTakerBalance = await erc20TokenA.balanceOf.callAsync(orderMatcher.address); - const newLeftTakerAssetTakerBalance = await erc20TokenB.balanceOf.callAsync(orderMatcher.address); + const newLeftMakerAssetTakerBalance = await erc20TokenA.balanceOf(orderMatcher.address).callAsync(); + const newLeftTakerAssetTakerBalance = await erc20TokenB.balanceOf(orderMatcher.address).callAsync(); const newErc20Balances = await erc20Wrapper.getBalancesAsync(); expect(newErc20Balances[makerAddressLeft][defaultERC20MakerAssetAddress]).to.be.bignumber.equal( erc20BalancesByOwner[makerAddressLeft][defaultERC20MakerAssetAddress].minus( @@ -671,12 +645,9 @@ describe('OrderMatcher', () => { takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(5), 18), }); signedOrderRight.signature = `0xff${signedOrderRight.signature.slice(4)}`; - const data = exchange.matchOrders.getABIEncodedTransactionData( - signedOrderLeft, - signedOrderRight, - signedOrderLeft.signature, - signedOrderRight.signature, - ); + const data = exchange + .matchOrders(signedOrderLeft, signedOrderRight, signedOrderLeft.signature, signedOrderRight.signature) + .getABIEncodedTransactionData(); const expectedError = new ExchangeRevertErrors.SignatureError(); const tx = web3Wrapper.sendTransactionAsync({ data, @@ -698,17 +669,14 @@ describe('OrderMatcher', () => { }); // Matcher will not have enough allowance to fill rightOrder await web3Wrapper.awaitTransactionSuccessAsync( - await orderMatcher.approveAssetProxy.sendTransactionAsync(leftMakerAssetData, constants.ZERO_AMOUNT, { + await orderMatcher.approveAssetProxy(leftMakerAssetData, constants.ZERO_AMOUNT).sendTransactionAsync({ from: owner, }), constants.AWAIT_TRANSACTION_MINED_MS, ); - const data = exchange.matchOrders.getABIEncodedTransactionData( - signedOrderLeft, - signedOrderRight, - signedOrderLeft.signature, - signedOrderRight.signature, - ); + const data = exchange + .matchOrders(signedOrderLeft, signedOrderRight, signedOrderLeft.signature, signedOrderRight.signature) + .getABIEncodedTransactionData(); const expectedError = new ExchangeRevertErrors.AssetProxyTransferError(); const tx = web3Wrapper.sendTransactionAsync({ data, @@ -721,14 +689,14 @@ describe('OrderMatcher', () => { }); describe('withdrawAsset', () => { it('should allow owner to withdraw ERC20 tokens', async () => { - const erc20AWithdrawAmount = await erc20TokenA.balanceOf.callAsync(orderMatcher.address); + const erc20AWithdrawAmount = await erc20TokenA.balanceOf(orderMatcher.address).callAsync(); expect(erc20AWithdrawAmount).to.be.bignumber.gt(constants.ZERO_AMOUNT); await web3Wrapper.awaitTransactionSuccessAsync( - await orderMatcher.withdrawAsset.sendTransactionAsync(leftMakerAssetData, erc20AWithdrawAmount, { + await orderMatcher.withdrawAsset(leftMakerAssetData, erc20AWithdrawAmount).sendTransactionAsync({ from: owner, }), ); - const newBalance = await erc20TokenA.balanceOf.callAsync(orderMatcher.address); + const newBalance = await erc20TokenA.balanceOf(orderMatcher.address).callAsync(); expect(newBalance).to.be.bignumber.equal(constants.ZERO_AMOUNT); }); it('should allow owner to withdraw ERC721 tokens', async () => { @@ -742,22 +710,22 @@ describe('OrderMatcher', () => { ); const tokenId = new BigNumber(1); await web3Wrapper.awaitTransactionSuccessAsync( - await erc721Token.mint.sendTransactionAsync(orderMatcher.address, tokenId, { from: owner }), + await erc721Token.mint(orderMatcher.address, tokenId).sendTransactionAsync({ from: owner }), constants.AWAIT_TRANSACTION_MINED_MS, ); - const assetData = await devUtils.encodeERC721AssetData.callAsync(erc721Token.address, tokenId); + const assetData = await devUtils.encodeERC721AssetData(erc721Token.address, tokenId).callAsync(); const withdrawAmount = new BigNumber(1); await web3Wrapper.awaitTransactionSuccessAsync( - await orderMatcher.withdrawAsset.sendTransactionAsync(assetData, withdrawAmount, { from: owner }), + await orderMatcher.withdrawAsset(assetData, withdrawAmount).sendTransactionAsync({ from: owner }), constants.AWAIT_TRANSACTION_MINED_MS, ); - const erc721Owner = await erc721Token.ownerOf.callAsync(tokenId); + const erc721Owner = await erc721Token.ownerOf(tokenId).callAsync(); expect(erc721Owner).to.be.equal(owner); }); it('should revert if not called by owner', async () => { - const erc20AWithdrawAmount = await erc20TokenA.balanceOf.callAsync(orderMatcher.address); + const erc20AWithdrawAmount = await erc20TokenA.balanceOf(orderMatcher.address).callAsync(); expect(erc20AWithdrawAmount).to.be.bignumber.gt(constants.ZERO_AMOUNT); - const tx = orderMatcher.withdrawAsset.sendTransactionAsync(leftMakerAssetData, erc20AWithdrawAmount, { + const tx = orderMatcher.withdrawAsset(leftMakerAssetData, erc20AWithdrawAmount).sendTransactionAsync({ from: takerAddress, }); return expect(tx).to.revertWith(RevertReason.OnlyContractOwner); @@ -767,12 +735,12 @@ describe('OrderMatcher', () => { it('should be able to set an allowance for ERC20 tokens', async () => { const allowance = new BigNumber(55465465426546); await web3Wrapper.awaitTransactionSuccessAsync( - await orderMatcher.approveAssetProxy.sendTransactionAsync(leftMakerAssetData, allowance, { + await orderMatcher.approveAssetProxy(leftMakerAssetData, allowance).sendTransactionAsync({ from: owner, }), constants.AWAIT_TRANSACTION_MINED_MS, ); - const newAllowance = await erc20TokenA.allowance.callAsync(orderMatcher.address, erc20Proxy.address); + const newAllowance = await erc20TokenA.allowance(orderMatcher.address, erc20Proxy.address).callAsync(); expect(newAllowance).to.be.bignumber.equal(allowance); }); it('should be able to approve an ERC721 token by passing in allowance = 1', async () => { @@ -784,16 +752,17 @@ describe('OrderMatcher', () => { constants.DUMMY_TOKEN_NAME, constants.DUMMY_TOKEN_SYMBOL, ); - const assetData = await devUtils.encodeERC721AssetData.callAsync( - erc721Token.address, - constants.ZERO_AMOUNT, - ); + const assetData = await devUtils + .encodeERC721AssetData(erc721Token.address, constants.ZERO_AMOUNT) + .callAsync(); const allowance = new BigNumber(1); await web3Wrapper.awaitTransactionSuccessAsync( - await orderMatcher.approveAssetProxy.sendTransactionAsync(assetData, allowance, { from: owner }), + await orderMatcher.approveAssetProxy(assetData, allowance).sendTransactionAsync({ from: owner }), constants.AWAIT_TRANSACTION_MINED_MS, ); - const isApproved = await erc721Token.isApprovedForAll.callAsync(orderMatcher.address, erc721Proxy.address); + const isApproved = await erc721Token + .isApprovedForAll(orderMatcher.address, erc721Proxy.address) + .callAsync(); expect(isApproved).to.be.equal(true); }); it('should be able to approve an ERC721 token by passing in allowance > 1', async () => { @@ -805,21 +774,22 @@ describe('OrderMatcher', () => { constants.DUMMY_TOKEN_NAME, constants.DUMMY_TOKEN_SYMBOL, ); - const assetData = await devUtils.encodeERC721AssetData.callAsync( - erc721Token.address, - constants.ZERO_AMOUNT, - ); + const assetData = await devUtils + .encodeERC721AssetData(erc721Token.address, constants.ZERO_AMOUNT) + .callAsync(); const allowance = new BigNumber(2); await web3Wrapper.awaitTransactionSuccessAsync( - await orderMatcher.approveAssetProxy.sendTransactionAsync(assetData, allowance, { from: owner }), + await orderMatcher.approveAssetProxy(assetData, allowance).sendTransactionAsync({ from: owner }), constants.AWAIT_TRANSACTION_MINED_MS, ); - const isApproved = await erc721Token.isApprovedForAll.callAsync(orderMatcher.address, erc721Proxy.address); + const isApproved = await erc721Token + .isApprovedForAll(orderMatcher.address, erc721Proxy.address) + .callAsync(); expect(isApproved).to.be.equal(true); }); it('should revert if not called by owner', async () => { const approval = new BigNumber(1); - const tx = orderMatcher.approveAssetProxy.sendTransactionAsync(leftMakerAssetData, approval, { + const tx = orderMatcher.approveAssetProxy(leftMakerAssetData, approval).sendTransactionAsync({ from: takerAddress, }); return expect(tx).to.revertWith(RevertReason.OnlyContractOwner); diff --git a/contracts/extensions/test/utils/balance_threshold_wrapper.ts b/contracts/extensions/test/utils/balance_threshold_wrapper.ts index 30d1798aeb..f1983e092b 100644 --- a/contracts/extensions/test/utils/balance_threshold_wrapper.ts +++ b/contracts/extensions/test/utils/balance_threshold_wrapper.ts @@ -39,11 +39,9 @@ export class BalanceThresholdWrapper { opts: { takerAssetFillAmount?: BigNumber } = {}, ): Promise { const params = orderUtils.createFill(signedOrder, opts.takerAssetFillAmount); - const data = this._exchange.fillOrder.getABIEncodedTransactionData( - params.order, - params.takerAssetFillAmount, - params.signature, - ); + const data = this._exchange + .fillOrder(params.order, params.takerAssetFillAmount, params.signature) + .getABIEncodedTransactionData(); const txReceipt = this._executeTransactionAsync(data, from); return txReceipt; } @@ -53,11 +51,9 @@ export class BalanceThresholdWrapper { opts: { takerAssetFillAmount?: BigNumber } = {}, ): Promise { const params = orderUtils.createFill(signedOrder, opts.takerAssetFillAmount); - const data = this._exchange.fillOrKillOrder.getABIEncodedTransactionData( - params.order, - params.takerAssetFillAmount, - params.signature, - ); + const data = this._exchange + .fillOrKillOrder(params.order, params.takerAssetFillAmount, params.signature) + .getABIEncodedTransactionData(); const txReceipt = this._executeTransactionAsync(data, from); return txReceipt; } @@ -67,11 +63,9 @@ export class BalanceThresholdWrapper { opts: { takerAssetFillAmount?: BigNumber; gas?: number } = {}, ): Promise { const params = orderUtils.createFill(signedOrder, opts.takerAssetFillAmount); - const data = this._exchange.fillOrderNoThrow.getABIEncodedTransactionData( - params.order, - params.takerAssetFillAmount, - params.signature, - ); + const data = this._exchange + .fillOrderNoThrow(params.order, params.takerAssetFillAmount, params.signature) + .getABIEncodedTransactionData(); const txReceipt = this._executeTransactionAsync(data, from, opts.gas); return txReceipt; } @@ -81,11 +75,9 @@ export class BalanceThresholdWrapper { opts: { takerAssetFillAmounts?: BigNumber[] } = {}, ): Promise { const params = formatters.createBatchFill(orders, opts.takerAssetFillAmounts); - const data = this._exchange.batchFillOrders.getABIEncodedTransactionData( - params.orders, - params.takerAssetFillAmounts, - params.signatures, - ); + const data = this._exchange + .batchFillOrders(params.orders, params.takerAssetFillAmounts, params.signatures) + .getABIEncodedTransactionData(); const txReceipt = this._executeTransactionAsync(data, from); return txReceipt; } @@ -95,11 +87,9 @@ export class BalanceThresholdWrapper { opts: { takerAssetFillAmounts?: BigNumber[] } = {}, ): Promise { const params = formatters.createBatchFill(orders, opts.takerAssetFillAmounts); - const data = this._exchange.batchFillOrKillOrders.getABIEncodedTransactionData( - params.orders, - params.takerAssetFillAmounts, - params.signatures, - ); + const data = this._exchange + .batchFillOrKillOrders(params.orders, params.takerAssetFillAmounts, params.signatures) + .getABIEncodedTransactionData(); const txReceipt = this._executeTransactionAsync(data, from); return txReceipt; } @@ -109,11 +99,9 @@ export class BalanceThresholdWrapper { opts: { takerAssetFillAmounts?: BigNumber[]; gas?: number } = {}, ): Promise { const params = formatters.createBatchFill(orders, opts.takerAssetFillAmounts); - const data = this._exchange.batchFillOrKillOrders.getABIEncodedTransactionData( - params.orders, - params.takerAssetFillAmounts, - params.signatures, - ); + const data = this._exchange + .batchFillOrKillOrders(params.orders, params.takerAssetFillAmounts, params.signatures) + .getABIEncodedTransactionData(); const txReceipt = this._executeTransactionAsync(data, from, opts.gas); return txReceipt; } @@ -123,11 +111,9 @@ export class BalanceThresholdWrapper { opts: { takerAssetFillAmount: BigNumber }, ): Promise { const params = formatters.createMarketSellOrders(orders, opts.takerAssetFillAmount); - const data = this._exchange.marketSellOrders.getABIEncodedTransactionData( - params.orders, - params.takerAssetFillAmount, - params.signatures, - ); + const data = this._exchange + .marketSellOrders(params.orders, params.takerAssetFillAmount, params.signatures) + .getABIEncodedTransactionData(); const txReceipt = this._executeTransactionAsync(data, from); return txReceipt; } @@ -137,11 +123,9 @@ export class BalanceThresholdWrapper { opts: { takerAssetFillAmount: BigNumber; gas?: number }, ): Promise { const params = formatters.createMarketSellOrders(orders, opts.takerAssetFillAmount); - const data = this._exchange.marketSellOrdersNoThrow.getABIEncodedTransactionData( - params.orders, - params.takerAssetFillAmount, - params.signatures, - ); + const data = this._exchange + .marketSellOrdersNoThrow(params.orders, params.takerAssetFillAmount, params.signatures) + .getABIEncodedTransactionData(); const txReceipt = this._executeTransactionAsync(data, from, opts.gas); return txReceipt; } @@ -151,11 +135,9 @@ export class BalanceThresholdWrapper { opts: { makerAssetFillAmount: BigNumber }, ): Promise { const params = formatters.createMarketBuyOrders(orders, opts.makerAssetFillAmount); - const data = this._exchange.marketBuyOrders.getABIEncodedTransactionData( - params.orders, - params.makerAssetFillAmount, - params.signatures, - ); + const data = this._exchange + .marketBuyOrders(params.orders, params.makerAssetFillAmount, params.signatures) + .getABIEncodedTransactionData(); const txReceipt = this._executeTransactionAsync(data, from); return txReceipt; } @@ -165,17 +147,15 @@ export class BalanceThresholdWrapper { opts: { makerAssetFillAmount: BigNumber; gas?: number }, ): Promise { const params = formatters.createMarketBuyOrders(orders, opts.makerAssetFillAmount); - const data = this._exchange.marketBuyOrdersNoThrow.getABIEncodedTransactionData( - params.orders, - params.makerAssetFillAmount, - params.signatures, - ); + const data = this._exchange + .marketBuyOrdersNoThrow(params.orders, params.makerAssetFillAmount, params.signatures) + .getABIEncodedTransactionData(); const txReceipt = this._executeTransactionAsync(data, from, opts.gas); return txReceipt; } public async cancelOrderAsync(signedOrder: SignedOrder, from: string): Promise { const params = orderUtils.createCancel(signedOrder); - const data = this._exchange.cancelOrder.getABIEncodedTransactionData(params.order); + const data = this._exchange.cancelOrder(params.order).getABIEncodedTransactionData(); const txReceipt = this._executeTransactionAsync(data, from); return txReceipt; } @@ -184,33 +164,33 @@ export class BalanceThresholdWrapper { from: string, ): Promise { const params = formatters.createBatchCancel(orders); - const data = this._exchange.batchCancelOrders.getABIEncodedTransactionData(params.orders); + const data = this._exchange.batchCancelOrders(params.orders).getABIEncodedTransactionData(); const txReceipt = this._executeTransactionAsync(data, from); return txReceipt; } public async cancelOrdersUpToAsync(salt: BigNumber, from: string): Promise { - const data = this._exchange.cancelOrdersUpTo.getABIEncodedTransactionData(salt); + const data = this._exchange.cancelOrdersUpTo(salt).getABIEncodedTransactionData(); const txReceipt = this._executeTransactionAsync(data, from); return txReceipt; } public async getTakerAssetFilledAmountAsync(orderHashHex: string): Promise { - const filledAmount = await this._exchange.filled.callAsync(orderHashHex); + const filledAmount = await this._exchange.filled(orderHashHex).callAsync(); return filledAmount; } public async isCancelledAsync(orderHashHex: string): Promise { - const isCancelled = await this._exchange.cancelled.callAsync(orderHashHex); + const isCancelled = await this._exchange.cancelled(orderHashHex).callAsync(); return isCancelled; } public async getOrderEpochAsync(makerAddress: string, senderAddress: string): Promise { - const orderEpoch = await this._exchange.orderEpoch.callAsync(makerAddress, senderAddress); + const orderEpoch = await this._exchange.orderEpoch(makerAddress, senderAddress).callAsync(); return orderEpoch; } public async getOrderInfoAsync(signedOrder: SignedOrder): Promise { - const orderInfo = await this._exchange.getOrderInfo.callAsync(signedOrder); + const orderInfo = await this._exchange.getOrderInfo(signedOrder).callAsync(); return orderInfo; } public async getOrdersInfoAsync(signedOrders: SignedOrder[]): Promise { - const ordersInfo = (await this._exchange.getOrdersInfo.callAsync(signedOrders)) as OrderInfo[]; + const ordersInfo = (await this._exchange.getOrdersInfo(signedOrders)).callAsync() as OrderInfo[]; return ordersInfo; } public async matchOrdersAsync( @@ -219,12 +199,9 @@ export class BalanceThresholdWrapper { from: string, ): Promise { const params = orderUtils.createMatchOrders(signedOrderLeft, signedOrderRight); - const data = this._exchange.matchOrders.getABIEncodedTransactionData( - params.left, - params.right, - params.leftSignature, - params.rightSignature, - ); + const data = this._exchange + .matchOrders(params.left, params.right, params.leftSignature, params.rightSignature) + .getABIEncodedTransactionData(); const txReceipt = this._executeTransactionAsync(data, from); return txReceipt; } @@ -234,21 +211,16 @@ export class BalanceThresholdWrapper { opts: { takerAssetFillAmount?: BigNumber } = {}, ): Promise { const params = orderUtils.createFill(signedOrder, opts.takerAssetFillAmount); - const fillResults = await this._exchange.fillOrder.callAsync( - params.order, - params.takerAssetFillAmount, - params.signature, - { from }, - ); + const fillResults = await this._exchange + .fillOrder(params.order, params.takerAssetFillAmount, params.signature) + .callAsync({ from }); return fillResults; } public abiEncodeFillOrder(signedOrder: SignedOrder, opts: { takerAssetFillAmount?: BigNumber } = {}): string { const params = orderUtils.createFill(signedOrder, opts.takerAssetFillAmount); - const data = this._exchange.fillOrder.getABIEncodedTransactionData( - params.order, - params.takerAssetFillAmount, - params.signature, - ); + const data = this._exchange + .fillOrder(params.order, params.takerAssetFillAmount, params.signature) + .getABIEncodedTransactionData(); return data; } public getBalanceThresholdAddress(): string { @@ -264,13 +236,15 @@ export class BalanceThresholdWrapper { ): Promise { const signedExchangeTx = this._signerTransactionFactory.newSignedTransaction(abiEncodedExchangeTxData); const txOpts = gas === undefined ? { from } : { from, gas }; - const txHash = await this._balanceThresholdFilter.executeTransaction.sendTransactionAsync( - signedExchangeTx.salt, - signedExchangeTx.signerAddress, - signedExchangeTx.data, - signedExchangeTx.signature, - txOpts, - ); + const txHash = await this._balanceThresholdFilter + .executeTransaction( + signedExchangeTx.salt, + signedExchangeTx.signerAddress, + signedExchangeTx.data, + signedExchangeTx.signature, + txOpts, + ) + .sendTransactionAsync(); const txReceipt = await this._logDecoder.getTxWithDecodedLogsAsync(txHash); return txReceipt; } diff --git a/contracts/extensions/test/utils/dutch_auction_test_wrapper.ts b/contracts/extensions/test/utils/dutch_auction_test_wrapper.ts index 193ee1cfa4..3e98c6a94a 100644 --- a/contracts/extensions/test/utils/dutch_auction_test_wrapper.ts +++ b/contracts/extensions/test/utils/dutch_auction_test_wrapper.ts @@ -38,15 +38,11 @@ export class DutchAuctionTestWrapper { sellOrder: SignedOrder, from: string, ): Promise { - const txHash = await this._dutchAuctionContract.matchOrders.sendTransactionAsync( - buyOrder, - sellOrder, - buyOrder.signature, - sellOrder.signature, - { + const txHash = await this._dutchAuctionContract + .matchOrders(buyOrder, sellOrder, buyOrder.signature, sellOrder.signature) + .sendTransactionAsync({ from, - }, - ); + }); const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash); return tx; } @@ -56,7 +52,7 @@ export class DutchAuctionTestWrapper { * @return The dutch auction details. */ public async getAuctionDetailsAsync(sellOrder: SignedOrder): Promise { - const auctionDetails = await this._dutchAuctionContract.getAuctionDetails.callAsync(sellOrder); + const auctionDetails = await this._dutchAuctionContract.getAuctionDetails(sellOrder).callAsync(); return auctionDetails; } } diff --git a/contracts/integrations/test/actors/base.ts b/contracts/integrations/test/actors/base.ts index a763e02f8d..e2d2c2e618 100644 --- a/contracts/integrations/test/actors/base.ts +++ b/contracts/integrations/test/actors/base.ts @@ -46,22 +46,19 @@ export class Actor { amount?: BigNumber, ): Promise { if (token instanceof DummyERC20TokenContract) { - await token.setBalance.awaitTransactionSuccessAsync( - this.address, - amount || constants.INITIAL_ERC20_BALANCE, - ); + await token + .setBalance(this.address, amount || constants.INITIAL_ERC20_BALANCE) + .awaitTransactionSuccessAsync(); } else { - await token.deposit.awaitTransactionSuccessAsync({ + await token.deposit().awaitTransactionSuccessAsync({ from: this.address, value: amount || constants.ONE_ETHER, }); } - await token.approve.awaitTransactionSuccessAsync( - spender || this.deployment.assetProxies.erc20Proxy.address, - constants.MAX_UINT256, - { from: this.address }, - ); + await token + .approve(spender || this.deployment.assetProxies.erc20Proxy.address, constants.MAX_UINT256) + .awaitTransactionSuccessAsync({ from: this.address }); } /** @@ -76,19 +73,17 @@ export class Actor { const tokenIds: BigNumber[] = []; _.times(numToMint, async () => { const tokenId = getRandomInteger(constants.ZERO_AMOUNT, constants.MAX_UINT256); - await token.mint.awaitTransactionSuccessAsync(this.address, tokenId, { + await token.mint(this.address, tokenId).awaitTransactionSuccessAsync({ from: this.address, }); tokenIds.push(tokenId); }); - await token.setApprovalForAll.awaitTransactionSuccessAsync( - spender || this.deployment.assetProxies.erc721Proxy.address, - true, - { + await token + .setApprovalForAll(spender || this.deployment.assetProxies.erc721Proxy.address, true) + .awaitTransactionSuccessAsync({ from: this.address, - }, - ); + }); return tokenIds; } diff --git a/contracts/integrations/test/actors/keeper.ts b/contracts/integrations/test/actors/keeper.ts index 9389d136aa..b16182b749 100644 --- a/contracts/integrations/test/actors/keeper.ts +++ b/contracts/integrations/test/actors/keeper.ts @@ -37,14 +37,14 @@ export function KeeperMixin(Base: TBase): TBase & Con if (shouldFastForward) { // increase timestamp of next block by how many seconds we need to // get to the next epoch. - const epochEndTime = await stakingWrapper.getCurrentEpochEarliestEndTimeInSeconds.callAsync(); + const epochEndTime = await stakingWrapper.getCurrentEpochEarliestEndTimeInSeconds().callAsync(); const lastBlockTime = await web3Wrapper.getBlockTimestampAsync('latest'); const dt = Math.max(0, epochEndTime.minus(lastBlockTime).toNumber()); await web3Wrapper.increaseTimeAsync(dt); // mine next block await web3Wrapper.mineBlockAsync(); } - return stakingWrapper.endEpoch.awaitTransactionSuccessAsync({ from: this.actor.address }); + return stakingWrapper.endEpoch().awaitTransactionSuccessAsync({ from: this.actor.address }); } /** @@ -55,7 +55,7 @@ export function KeeperMixin(Base: TBase): TBase & Con const { stakingWrapper } = this.actor.deployment.staking; // If no poolIds provided, finalize all active pools from the previous epoch if (poolIds.length === 0) { - const previousEpoch = (await stakingWrapper.currentEpoch.callAsync()).minus(1); + const previousEpoch = (await stakingWrapper.currentEpoch().callAsync()).minus(1); const events = filterLogsToArguments( await stakingWrapper.getLogsAsync( TestStakingEvents.StakingPoolEarnedRewardsInEpoch, @@ -69,7 +69,7 @@ export function KeeperMixin(Base: TBase): TBase & Con return Promise.all( poolIds.map(async poolId => - stakingWrapper.finalizePool.awaitTransactionSuccessAsync(poolId, { + stakingWrapper.finalizePool(poolId).awaitTransactionSuccessAsync({ from: this.actor.address, }), ), diff --git a/contracts/integrations/test/actors/maker.ts b/contracts/integrations/test/actors/maker.ts index 8e9bcb9f79..e9ebab6006 100644 --- a/contracts/integrations/test/actors/maker.ts +++ b/contracts/integrations/test/actors/maker.ts @@ -59,7 +59,7 @@ export function MakerMixin(Base: TBase): TBase & Cons */ public async cancelOrderAsync(order: SignedOrder): Promise { const params = orderUtils.createCancel(order); - return this.actor.deployment.exchange.cancelOrder.awaitTransactionSuccessAsync(params.order, { + return this.actor.deployment.exchange.cancelOrder(params.order).awaitTransactionSuccessAsync({ from: this.actor.address, }); } @@ -70,7 +70,7 @@ export function MakerMixin(Base: TBase): TBase & Cons public async joinStakingPoolAsync(poolId: string): Promise { const stakingContract = this.actor.deployment.staking.stakingWrapper; this.makerPoolId = poolId; - return stakingContract.joinStakingPoolAsMaker.awaitTransactionSuccessAsync(poolId, { + return stakingContract.joinStakingPoolAsMaker(poolId).awaitTransactionSuccessAsync({ from: this.actor.address, }); } diff --git a/contracts/integrations/test/actors/pool_operator.ts b/contracts/integrations/test/actors/pool_operator.ts index 22763f76ba..249aad85b6 100644 --- a/contracts/integrations/test/actors/pool_operator.ts +++ b/contracts/integrations/test/actors/pool_operator.ts @@ -43,11 +43,9 @@ export function PoolOperatorMixin(Base: TBase): TBase addOperatorAsMaker: boolean = false, ): Promise { const stakingContract = this.actor.deployment.staking.stakingWrapper; - const txReceipt = await stakingContract.createStakingPool.awaitTransactionSuccessAsync( - operatorShare, - addOperatorAsMaker, - { from: this.actor.address }, - ); + const txReceipt = await stakingContract + .createStakingPool(operatorShare, addOperatorAsMaker) + .awaitTransactionSuccessAsync({ from: this.actor.address }); const createStakingPoolLog = txReceipt.logs[0]; const poolId = (createStakingPoolLog as any).args.poolId; @@ -64,11 +62,9 @@ export function PoolOperatorMixin(Base: TBase): TBase ): Promise { const stakingContract = this.actor.deployment.staking.stakingWrapper; this.operatorShares[poolId] = newOperatorShare; - return stakingContract.decreaseStakingPoolOperatorShare.awaitTransactionSuccessAsync( - poolId, - newOperatorShare, - { from: this.actor.address }, - ); + return stakingContract + .decreaseStakingPoolOperatorShare(poolId, newOperatorShare) + .awaitTransactionSuccessAsync({ from: this.actor.address }); } }; } diff --git a/contracts/integrations/test/actors/staker.ts b/contracts/integrations/test/actors/staker.ts index 0e2c48e8c6..77fa8e9636 100644 --- a/contracts/integrations/test/actors/staker.ts +++ b/contracts/integrations/test/actors/staker.ts @@ -32,16 +32,17 @@ export function StakerMixin(Base: TBase): TBase & Con */ public async stakeAsync(amount: BigNumber, poolId?: string): Promise { const { stakingWrapper } = this.actor.deployment.staking; - await stakingWrapper.stake.awaitTransactionSuccessAsync(amount, { + await stakingWrapper.stake(amount).awaitTransactionSuccessAsync({ from: this.actor.address, }); if (poolId !== undefined) { - await stakingWrapper.moveStake.awaitTransactionSuccessAsync( - new StakeInfo(StakeStatus.Undelegated), - new StakeInfo(StakeStatus.Delegated, poolId), - amount, - { from: this.actor.address }, - ); + await stakingWrapper + .moveStake( + new StakeInfo(StakeStatus.Undelegated), + new StakeInfo(StakeStatus.Delegated, poolId), + amount, + ) + .awaitTransactionSuccessAsync({ from: this.actor.address }); } } }; diff --git a/contracts/integrations/test/actors/taker.ts b/contracts/integrations/test/actors/taker.ts index a63311b139..36ad4237e8 100644 --- a/contracts/integrations/test/actors/taker.ts +++ b/contracts/integrations/test/actors/taker.ts @@ -41,17 +41,14 @@ export function TakerMixin(Base: TBase): TBase & Cons fillAmount: BigNumber, txData: Partial = {}, ): Promise { - return this.actor.deployment.exchange.fillOrder.awaitTransactionSuccessAsync( - order, - fillAmount, - order.signature, - { + return this.actor.deployment.exchange + .fillOrder(order, fillAmount, order.signature) + .awaitTransactionSuccessAsync({ from: this.actor.address, gasPrice: DeploymentManager.gasPrice, value: DeploymentManager.protocolFee, ...txData, - }, - ); + }); } }; } diff --git a/contracts/integrations/test/coordinator/coordinator_test.ts b/contracts/integrations/test/coordinator/coordinator_test.ts index d953739a3f..7409b64af7 100644 --- a/contracts/integrations/test/coordinator/coordinator_test.ts +++ b/contracts/integrations/test/coordinator/coordinator_test.ts @@ -64,10 +64,10 @@ blockchainTests.resets('Coordinator integration tests', env => { orderConfig: { senderAddress: coordinator.address, feeRecipientAddress: feeRecipient.address, - makerAssetData: await devUtils.encodeERC20AssetData.callAsync(makerToken.address), - takerAssetData: await devUtils.encodeERC20AssetData.callAsync(takerToken.address), - makerFeeAssetData: await devUtils.encodeERC20AssetData.callAsync(makerFeeToken.address), - takerFeeAssetData: await devUtils.encodeERC20AssetData.callAsync(takerFeeToken.address), + makerAssetData: await devUtils.encodeERC20AssetData(makerToken.address).callAsync(), + takerAssetData: await devUtils.encodeERC20AssetData(takerToken.address).callAsync(), + makerFeeAssetData: await devUtils.encodeERC20AssetData(makerFeeToken.address).callAsync(), + takerFeeAssetData: await devUtils.encodeERC20AssetData(takerFeeToken.address).callAsync(), }, }); @@ -141,7 +141,7 @@ blockchainTests.resets('Coordinator integration tests', env => { taker.address, deployment.staking.stakingProxy.address, DeploymentManager.protocolFee, - await devUtils.encodeERC20AssetData.callAsync(deployment.tokens.weth.address), + await devUtils.encodeERC20AssetData(deployment.tokens.weth.address).callAsync(), ); } } @@ -187,13 +187,9 @@ blockchainTests.resets('Coordinator integration tests', env => { it(`${fnName} should fill the order with a signed approval`, async () => { await balanceStore.updateBalancesAsync(); - const txReceipt = await coordinator.executeTransaction.awaitTransactionSuccessAsync( - transaction, - taker.address, - transaction.signature, - [approval.signature], - { from: taker.address, value: DeploymentManager.protocolFee }, - ); + const txReceipt = await coordinator + .executeTransaction(transaction, taker.address, transaction.signature, [approval.signature]) + .awaitTransactionSuccessAsync({ from: taker.address, value: DeploymentManager.protocolFee }); const expectedBalances = await simulateFillsAsync([order], txReceipt, DeploymentManager.protocolFee); await balanceStore.updateBalancesAsync(); @@ -202,13 +198,9 @@ blockchainTests.resets('Coordinator integration tests', env => { }); it(`${fnName} should fill the order if called by approver (eth protocol fee, no refund)`, async () => { await balanceStore.updateBalancesAsync(); - const txReceipt = await coordinator.executeTransaction.awaitTransactionSuccessAsync( - transaction, - feeRecipient.address, - transaction.signature, - [], - { from: feeRecipient.address, value: DeploymentManager.protocolFee }, - ); + const txReceipt = await coordinator + .executeTransaction(transaction, feeRecipient.address, transaction.signature, []) + .awaitTransactionSuccessAsync({ from: feeRecipient.address, value: DeploymentManager.protocolFee }); const expectedBalances = await simulateFillsAsync([order], txReceipt, DeploymentManager.protocolFee); await balanceStore.updateBalancesAsync(); @@ -217,13 +209,12 @@ blockchainTests.resets('Coordinator integration tests', env => { }); it(`${fnName} should fill the order if called by approver (eth protocol fee, refund)`, async () => { await balanceStore.updateBalancesAsync(); - const txReceipt = await coordinator.executeTransaction.awaitTransactionSuccessAsync( - transaction, - feeRecipient.address, - transaction.signature, - [], - { from: feeRecipient.address, value: DeploymentManager.protocolFee.plus(1) }, - ); + const txReceipt = await coordinator + .executeTransaction(transaction, feeRecipient.address, transaction.signature, []) + .awaitTransactionSuccessAsync({ + from: feeRecipient.address, + value: DeploymentManager.protocolFee.plus(1), + }); const expectedBalances = await simulateFillsAsync( [order], @@ -236,13 +227,9 @@ blockchainTests.resets('Coordinator integration tests', env => { }); it(`${fnName} should fill the order if called by approver (weth protocol fee, no refund)`, async () => { await balanceStore.updateBalancesAsync(); - const txReceipt = await coordinator.executeTransaction.awaitTransactionSuccessAsync( - transaction, - feeRecipient.address, - transaction.signature, - [], - { from: feeRecipient.address }, - ); + const txReceipt = await coordinator + .executeTransaction(transaction, feeRecipient.address, transaction.signature, []) + .awaitTransactionSuccessAsync({ from: feeRecipient.address }); const expectedBalances = await simulateFillsAsync([order], txReceipt); await balanceStore.updateBalancesAsync(); @@ -251,13 +238,9 @@ blockchainTests.resets('Coordinator integration tests', env => { }); it(`${fnName} should fill the order if called by approver (weth protocol fee, refund)`, async () => { await balanceStore.updateBalancesAsync(); - const txReceipt = await coordinator.executeTransaction.awaitTransactionSuccessAsync( - transaction, - feeRecipient.address, - transaction.signature, - [], - { from: feeRecipient.address, value: new BigNumber(1) }, - ); + const txReceipt = await coordinator + .executeTransaction(transaction, feeRecipient.address, transaction.signature, []) + .awaitTransactionSuccessAsync({ from: feeRecipient.address, value: new BigNumber(1) }); const expectedBalances = await simulateFillsAsync([order], txReceipt, new BigNumber(1)); await balanceStore.updateBalancesAsync(); @@ -266,13 +249,9 @@ blockchainTests.resets('Coordinator integration tests', env => { }); it(`${fnName} should revert with no approval signature`, async () => { const transactionHash = transactionHashUtils.getTransactionHashHex(transaction); - const tx = coordinator.executeTransaction.awaitTransactionSuccessAsync( - transaction, - taker.address, - transaction.signature, - [], - { from: taker.address, value: DeploymentManager.protocolFee }, - ); + const tx = coordinator + .executeTransaction(transaction, taker.address, transaction.signature, []) + .awaitTransactionSuccessAsync({ from: taker.address, value: DeploymentManager.protocolFee }); const expectedError = new CoordinatorRevertErrors.InvalidApprovalSignatureError( transactionHash, @@ -287,13 +266,9 @@ blockchainTests.resets('Coordinator integration tests', env => { hexSlice(approval.signature, 6), ); const transactionHash = transactionHashUtils.getTransactionHashHex(transaction); - const tx = coordinator.executeTransaction.awaitTransactionSuccessAsync( - transaction, - taker.address, - transaction.signature, - [approvalSignature], - { from: taker.address, value: DeploymentManager.protocolFee }, - ); + const tx = coordinator + .executeTransaction(transaction, taker.address, transaction.signature, [approvalSignature]) + .awaitTransactionSuccessAsync({ from: taker.address, value: DeploymentManager.protocolFee }); const expectedError = new CoordinatorRevertErrors.InvalidApprovalSignatureError( transactionHash, @@ -302,13 +277,9 @@ blockchainTests.resets('Coordinator integration tests', env => { return expect(tx).to.revertWith(expectedError); }); it(`${fnName} should revert if not called by tx signer or approver`, async () => { - const tx = coordinator.executeTransaction.awaitTransactionSuccessAsync( - transaction, - taker.address, - transaction.signature, - [approval.signature], - { from: maker.address, value: DeploymentManager.protocolFee }, - ); + const tx = coordinator + .executeTransaction(transaction, taker.address, transaction.signature, [approval.signature]) + .awaitTransactionSuccessAsync({ from: maker.address, value: DeploymentManager.protocolFee }); const expectedError = new CoordinatorRevertErrors.InvalidOriginError(taker.address); return expect(tx).to.revertWith(expectedError); @@ -335,13 +306,9 @@ blockchainTests.resets('Coordinator integration tests', env => { it(`${fnName} should fill the orders with a signed approval`, async () => { await balanceStore.updateBalancesAsync(); const value = DeploymentManager.protocolFee.times(orders.length); - const txReceipt = await coordinator.executeTransaction.awaitTransactionSuccessAsync( - transaction, - taker.address, - transaction.signature, - [approval.signature], - { from: taker.address, value }, - ); + const txReceipt = await coordinator + .executeTransaction(transaction, taker.address, transaction.signature, [approval.signature]) + .awaitTransactionSuccessAsync({ from: taker.address, value }); const expectedBalances = await simulateFillsAsync(orders, txReceipt, value); await balanceStore.updateBalancesAsync(); @@ -351,13 +318,9 @@ blockchainTests.resets('Coordinator integration tests', env => { it(`${fnName} should fill the orders if called by approver (eth fee, no refund)`, async () => { await balanceStore.updateBalancesAsync(); const value = DeploymentManager.protocolFee.times(orders.length); - const txReceipt = await coordinator.executeTransaction.awaitTransactionSuccessAsync( - transaction, - feeRecipient.address, - transaction.signature, - [], - { from: feeRecipient.address, value }, - ); + const txReceipt = await coordinator + .executeTransaction(transaction, feeRecipient.address, transaction.signature, []) + .awaitTransactionSuccessAsync({ from: feeRecipient.address, value }); const expectedBalances = await simulateFillsAsync(orders, txReceipt, value); await balanceStore.updateBalancesAsync(); @@ -367,13 +330,9 @@ blockchainTests.resets('Coordinator integration tests', env => { it(`${fnName} should fill the orders if called by approver (mixed fees, refund)`, async () => { await balanceStore.updateBalancesAsync(); const value = DeploymentManager.protocolFee.plus(1); - const txReceipt = await coordinator.executeTransaction.awaitTransactionSuccessAsync( - transaction, - feeRecipient.address, - transaction.signature, - [], - { from: feeRecipient.address, value }, - ); + const txReceipt = await coordinator + .executeTransaction(transaction, feeRecipient.address, transaction.signature, []) + .awaitTransactionSuccessAsync({ from: feeRecipient.address, value }); const expectedBalances = await simulateFillsAsync(orders, txReceipt, value); await balanceStore.updateBalancesAsync(); @@ -387,13 +346,12 @@ blockchainTests.resets('Coordinator integration tests', env => { hexSlice(approval.signature, 6), ); const transactionHash = transactionHashUtils.getTransactionHashHex(transaction); - const tx = coordinator.executeTransaction.awaitTransactionSuccessAsync( - transaction, - taker.address, - transaction.signature, - [approvalSignature], - { from: taker.address, value: DeploymentManager.protocolFee.times(orders.length) }, - ); + const tx = coordinator + .executeTransaction(transaction, taker.address, transaction.signature, [approvalSignature]) + .awaitTransactionSuccessAsync({ + from: taker.address, + value: DeploymentManager.protocolFee.times(orders.length), + }); const expectedError = new CoordinatorRevertErrors.InvalidApprovalSignatureError( transactionHash, feeRecipient.address, @@ -401,13 +359,12 @@ blockchainTests.resets('Coordinator integration tests', env => { return expect(tx).to.revertWith(expectedError); }); it(`${fnName} should revert if not called by tx signer or approver`, async () => { - const tx = coordinator.executeTransaction.awaitTransactionSuccessAsync( - transaction, - taker.address, - transaction.signature, - [approval.signature], - { from: maker.address, value: DeploymentManager.protocolFee.times(orders.length) }, - ); + const tx = coordinator + .executeTransaction(transaction, taker.address, transaction.signature, [approval.signature]) + .awaitTransactionSuccessAsync({ + from: maker.address, + value: DeploymentManager.protocolFee.times(orders.length), + }); const expectedError = new CoordinatorRevertErrors.InvalidOriginError(taker.address); return expect(tx).to.revertWith(expectedError); }); @@ -432,13 +389,9 @@ blockchainTests.resets('Coordinator integration tests', env => { data, gasPrice: DeploymentManager.gasPrice, }); - const txReceipt = await coordinator.executeTransaction.awaitTransactionSuccessAsync( - transaction, - maker.address, - transaction.signature, - [], - { from: maker.address }, - ); + const txReceipt = await coordinator + .executeTransaction(transaction, maker.address, transaction.signature, []) + .awaitTransactionSuccessAsync({ from: maker.address }); verifyEvents(txReceipt, [expectedCancelEvent(order)], ExchangeEvents.Cancel); }); @@ -449,13 +402,9 @@ blockchainTests.resets('Coordinator integration tests', env => { data, gasPrice: DeploymentManager.gasPrice, }); - const txReceipt = await coordinator.executeTransaction.awaitTransactionSuccessAsync( - transaction, - maker.address, - transaction.signature, - [], - { from: maker.address }, - ); + const txReceipt = await coordinator + .executeTransaction(transaction, maker.address, transaction.signature, []) + .awaitTransactionSuccessAsync({ from: maker.address }); verifyEvents(txReceipt, orders.map(order => expectedCancelEvent(order)), ExchangeEvents.Cancel); }); @@ -465,13 +414,9 @@ blockchainTests.resets('Coordinator integration tests', env => { data, gasPrice: DeploymentManager.gasPrice, }); - const txReceipt = await coordinator.executeTransaction.awaitTransactionSuccessAsync( - transaction, - maker.address, - transaction.signature, - [], - { from: maker.address }, - ); + const txReceipt = await coordinator + .executeTransaction(transaction, maker.address, transaction.signature, []) + .awaitTransactionSuccessAsync({ from: maker.address }); const expectedEvent: ExchangeCancelUpToEventArgs = { makerAddress: maker.address, diff --git a/contracts/integrations/test/forwarder/forwarder_test.ts b/contracts/integrations/test/forwarder/forwarder_test.ts index f521b9e44c..9bc82e4762 100644 --- a/contracts/integrations/test/forwarder/forwarder_test.ts +++ b/contracts/integrations/test/forwarder/forwarder_test.ts @@ -57,8 +57,8 @@ blockchainTests('Forwarder integration tests', env => { [makerToken, makerFeeToken, anotherErc20Token] = deployment.tokens.erc20; [erc721Token] = deployment.tokens.erc721; - wethAssetData = await devUtils.encodeERC20AssetData.callAsync(deployment.tokens.weth.address); - makerAssetData = await devUtils.encodeERC20AssetData.callAsync(makerToken.address); + wethAssetData = await devUtils.encodeERC20AssetData(deployment.tokens.weth.address).callAsync(); + makerAssetData = await devUtils.encodeERC20AssetData(makerToken.address).callAsync(); taker = new Actor({ name: 'Taker', deployment }); orderFeeRecipient = new FeeRecipient({ @@ -79,7 +79,7 @@ blockchainTests('Forwarder integration tests', env => { makerAssetData, takerAssetData: wethAssetData, takerFee: constants.ZERO_AMOUNT, - makerFeeAssetData: await devUtils.encodeERC20AssetData.callAsync(makerFeeToken.address), + makerFeeAssetData: await devUtils.encodeERC20AssetData(makerFeeToken.address).callAsync(), takerFeeAssetData: wethAssetData, }, }); @@ -87,7 +87,7 @@ blockchainTests('Forwarder integration tests', env => { await maker.configureERC20TokenAsync(makerToken); await maker.configureERC20TokenAsync(makerFeeToken); await maker.configureERC20TokenAsync(anotherErc20Token); - await forwarder.approveMakerAssetProxy.awaitTransactionSuccessAsync(makerAssetData); + await forwarder.approveMakerAssetProxy(makerAssetData).awaitTransactionSuccessAsync(); [nftId] = await maker.configureERC721TokenAsync(erc721Token); const tokenOwners = { @@ -171,7 +171,7 @@ blockchainTests('Forwarder integration tests', env => { await testFactory.marketSellTestAsync(orders, 1.34); }); it('should fail to fill an order with a percentage fee if the asset proxy is not yet approved', async () => { - const unapprovedAsset = await devUtils.encodeERC20AssetData.callAsync(anotherErc20Token.address); + const unapprovedAsset = await devUtils.encodeERC20AssetData(anotherErc20Token.address).callAsync(); const order = await maker.signOrderAsync({ makerAssetData: unapprovedAsset, takerFee: toBaseUnitAmount(2), @@ -180,16 +180,17 @@ blockchainTests('Forwarder integration tests', env => { await balanceStore.updateBalancesAsync(); // Execute test case - const tx = await forwarder.marketSellOrdersWithEth.awaitTransactionSuccessAsync( - [order], - [order.signature], - constants.ZERO_AMOUNT, - forwarderFeeRecipient.address, - { + const tx = await forwarder + .marketSellOrdersWithEth( + [order], + [order.signature], + constants.ZERO_AMOUNT, + forwarderFeeRecipient.address, + ) + .awaitTransactionSuccessAsync({ value: order.takerAssetAmount.plus(DeploymentManager.protocolFee), from: taker.address, - }, - ); + }); const expectedBalances = LocalBalanceStore.create(devUtils, balanceStore); expectedBalances.burnGas(tx.from, DeploymentManager.gasPrice.times(tx.gasUsed)); @@ -223,16 +224,17 @@ blockchainTests('Forwarder integration tests', env => { const order = await maker.signOrderAsync(); const ethValue = order.takerAssetAmount.plus(DeploymentManager.protocolFee).plus(2); const takerEthBalanceBefore = await env.web3Wrapper.getBalanceInWeiAsync(taker.address); - const tx = await forwarder.marketSellOrdersWithEth.awaitTransactionSuccessAsync( - [order], - [order.signature], - constants.ZERO_AMOUNT, - forwarderFeeRecipient.address, - { + const tx = await forwarder + .marketSellOrdersWithEth( + [order], + [order.signature], + constants.ZERO_AMOUNT, + forwarderFeeRecipient.address, + ) + .awaitTransactionSuccessAsync({ value: ethValue, from: taker.address, - }, - ); + }); const takerEthBalanceAfter = await env.web3Wrapper.getBalanceInWeiAsync(taker.address); const totalEthSpent = order.takerAssetAmount .plus(DeploymentManager.protocolFee) @@ -241,16 +243,18 @@ blockchainTests('Forwarder integration tests', env => { }); it('should fill orders with different makerAssetData', async () => { const firstOrder = await maker.signOrderAsync(); - const secondOrderMakerAssetData = await devUtils.encodeERC20AssetData.callAsync(anotherErc20Token.address); + const secondOrderMakerAssetData = await devUtils + .encodeERC20AssetData(anotherErc20Token.address) + .callAsync(); const secondOrder = await maker.signOrderAsync({ makerAssetData: secondOrderMakerAssetData, }); - await forwarder.approveMakerAssetProxy.awaitTransactionSuccessAsync(secondOrderMakerAssetData); + await forwarder.approveMakerAssetProxy(secondOrderMakerAssetData).awaitTransactionSuccessAsync(); const orders = [firstOrder, secondOrder]; await testFactory.marketSellTestAsync(orders, 1.5); }); it('should fail to fill an order with a fee denominated in an asset other than makerAsset or WETH', async () => { - const takerFeeAssetData = await devUtils.encodeERC20AssetData.callAsync(anotherErc20Token.address); + const takerFeeAssetData = await devUtils.encodeERC20AssetData(anotherErc20Token.address).callAsync(); const order = await maker.signOrderAsync({ takerFeeAssetData, takerFee: toBaseUnitAmount(1), @@ -341,11 +345,13 @@ blockchainTests('Forwarder integration tests', env => { }); it('should buy exactly makerAssetBuyAmount in orders with different makerAssetData', async () => { const firstOrder = await maker.signOrderAsync(); - const secondOrderMakerAssetData = await devUtils.encodeERC20AssetData.callAsync(anotherErc20Token.address); + const secondOrderMakerAssetData = await devUtils + .encodeERC20AssetData(anotherErc20Token.address) + .callAsync(); const secondOrder = await maker.signOrderAsync({ makerAssetData: secondOrderMakerAssetData, }); - await forwarder.approveMakerAssetProxy.awaitTransactionSuccessAsync(secondOrderMakerAssetData); + await forwarder.approveMakerAssetProxy(secondOrderMakerAssetData).awaitTransactionSuccessAsync(); const orders = [firstOrder, secondOrder]; await testFactory.marketBuyTestAsync(orders, 1.5); }); @@ -390,7 +396,7 @@ blockchainTests('Forwarder integration tests', env => { it('should buy an ERC721 asset from a single order', async () => { const erc721Order = await maker.signOrderAsync({ makerAssetAmount: new BigNumber(1), - makerAssetData: await devUtils.encodeERC721AssetData.callAsync(erc721Token.address, nftId), + makerAssetData: await devUtils.encodeERC721AssetData(erc721Token.address, nftId).callAsync(), takerFeeAssetData: wethAssetData, }); await testFactory.marketBuyTestAsync([erc721Order], 1); @@ -398,14 +404,14 @@ blockchainTests('Forwarder integration tests', env => { it('should buy an ERC721 asset and pay a WETH fee', async () => { const erc721orderWithWethFee = await maker.signOrderAsync({ makerAssetAmount: new BigNumber(1), - makerAssetData: await devUtils.encodeERC721AssetData.callAsync(erc721Token.address, nftId), + makerAssetData: await devUtils.encodeERC721AssetData(erc721Token.address, nftId).callAsync(), takerFee: toBaseUnitAmount(1), takerFeeAssetData: wethAssetData, }); await testFactory.marketBuyTestAsync([erc721orderWithWethFee], 1); }); it('should fail to fill an order with a fee denominated in an asset other than makerAsset or WETH', async () => { - const takerFeeAssetData = await devUtils.encodeERC20AssetData.callAsync(anotherErc20Token.address); + const takerFeeAssetData = await devUtils.encodeERC20AssetData(anotherErc20Token.address).callAsync(); const order = await maker.signOrderAsync({ takerFeeAssetData, takerFee: toBaseUnitAmount(1), @@ -483,17 +489,18 @@ blockchainTests('Forwarder integration tests', env => { await balanceStore.updateBalancesAsync(); // Execute test case - const tx = await forwarder.marketBuyOrdersWithEth.awaitTransactionSuccessAsync( - [order], - desiredMakerAssetFillAmount, - [order.signature], - constants.ZERO_AMOUNT, - forwarderFeeRecipient.address, - { + const tx = await forwarder + .marketBuyOrdersWithEth( + [order], + desiredMakerAssetFillAmount, + [order.signature], + constants.ZERO_AMOUNT, + forwarderFeeRecipient.address, + ) + .awaitTransactionSuccessAsync({ value: ethValue, from: taker.address, - }, - ); + }); // Compute expected balances const expectedBalances = LocalBalanceStore.create(devUtils, balanceStore); @@ -539,17 +546,18 @@ blockchainTests('Forwarder integration tests', env => { await balanceStore.updateBalancesAsync(); // Execute test case - const tx = await forwarder.marketBuyOrdersWithEth.awaitTransactionSuccessAsync( - [order], - desiredMakerAssetFillAmount, - [order.signature], - constants.ZERO_AMOUNT, - forwarderFeeRecipient.address, - { + const tx = await forwarder + .marketBuyOrdersWithEth( + [order], + desiredMakerAssetFillAmount, + [order.signature], + constants.ZERO_AMOUNT, + forwarderFeeRecipient.address, + ) + .awaitTransactionSuccessAsync({ value: takerAssetFillAmount.plus(DeploymentManager.protocolFee), from: taker.address, - }, - ); + }); // Compute expected balances const expectedBalances = LocalBalanceStore.create(devUtils, balanceStore); diff --git a/contracts/integrations/test/forwarder/forwarder_test_factory.ts b/contracts/integrations/test/forwarder/forwarder_test_factory.ts index fcc0b83199..70be41d387 100644 --- a/contracts/integrations/test/forwarder/forwarder_test_factory.ts +++ b/contracts/integrations/test/forwarder/forwarder_test_factory.ts @@ -46,7 +46,7 @@ export class ForwarderTestFactory { const forwarderFeePercentage = options.forwarderFeePercentage || 0; const orderInfoBefore = await Promise.all( - orders.map(order => this._deployment.exchange.getOrderInfo.callAsync(order)), + orders.map(order => this._deployment.exchange.getOrderInfo(order).callAsync()), ); const expectedOrderStatuses = orderInfoBefore.map((orderInfo, i) => fractionalNumberOfOrdersToFill >= i + 1 && orderInfo.orderStatus === OrderStatus.Fillable @@ -63,17 +63,18 @@ export class ForwarderTestFactory { const ethSpentOnForwarderFee = getPercentageOfValue(wethSpentAmount, forwarderFeePercentage); const feePercentage = getPercentageOfValue(constants.PERCENTAGE_DENOMINATOR, forwarderFeePercentage); - const tx = this._forwarder.marketBuyOrdersWithEth.awaitTransactionSuccessAsync( - orders, - makerAssetAcquiredAmount, - orders.map(signedOrder => signedOrder.signature), - feePercentage, - this._forwarderFeeRecipient.address, - { + const tx = this._forwarder + .marketBuyOrdersWithEth( + orders, + makerAssetAcquiredAmount, + orders.map(signedOrder => signedOrder.signature), + feePercentage, + this._forwarderFeeRecipient.address, + ) + .awaitTransactionSuccessAsync({ value: wethSpentAmount.plus(ethSpentOnForwarderFee).plus(ethValueAdjustment), from: this._taker.address, - }, - ); + }); if (options.revertError !== undefined) { await expect(tx).to.revertWith(options.revertError); @@ -89,7 +90,7 @@ export class ForwarderTestFactory { options: Partial = {}, ): Promise { const orderInfoBefore = await Promise.all( - orders.map(order => this._deployment.exchange.getOrderInfo.callAsync(order)), + orders.map(order => this._deployment.exchange.getOrderInfo(order).callAsync()), ); const expectedOrderStatuses = orderInfoBefore.map((orderInfo, i) => fractionalNumberOfOrdersToFill >= i + 1 && orderInfo.orderStatus === OrderStatus.Fillable @@ -108,16 +109,17 @@ export class ForwarderTestFactory { const ethSpentOnForwarderFee = getPercentageOfValue(wethSpentAmount, forwarderFeePercentage); const feePercentage = getPercentageOfValue(constants.PERCENTAGE_DENOMINATOR, forwarderFeePercentage); - const tx = this._forwarder.marketSellOrdersWithEth.awaitTransactionSuccessAsync( - orders, - orders.map(signedOrder => signedOrder.signature), - feePercentage, - this._forwarderFeeRecipient.address, - { + const tx = this._forwarder + .marketSellOrdersWithEth( + orders, + orders.map(signedOrder => signedOrder.signature), + feePercentage, + this._forwarderFeeRecipient.address, + ) + .awaitTransactionSuccessAsync({ value: wethSpentAmount.plus(ethSpentOnForwarderFee), from: this._taker.address, - }, - ); + }); if (options.revertError !== undefined) { await expect(tx).to.revertWith(options.revertError); @@ -141,7 +143,7 @@ export class ForwarderTestFactory { // Get updated order info const orderInfoAfter = await Promise.all( - orders.map(order => this._deployment.exchange.getOrderInfo.callAsync(order)), + orders.map(order => this._deployment.exchange.getOrderInfo(order).callAsync()), ); // Check order statuses for (const [i, orderInfo] of orderInfoAfter.entries()) { diff --git a/contracts/integrations/test/framework-unit-tests/deployment_manager_test.ts b/contracts/integrations/test/framework-unit-tests/deployment_manager_test.ts index 7cc4a15424..f5e92e2b3e 100644 --- a/contracts/integrations/test/framework-unit-tests/deployment_manager_test.ts +++ b/contracts/integrations/test/framework-unit-tests/deployment_manager_test.ts @@ -18,20 +18,20 @@ blockchainTests('Deployment Manager', env => { authorizedContracts: Authorizable[], ): Promise { for (const authorized of authorizedContracts) { - expect(await authorized.authorized.callAsync(authorizedAddress)).to.be.true(); + expect(await authorized.authorized(authorizedAddress).callAsync()).to.be.true(); } } async function batchAssertOwnerAsync(ownerAddress: string, owners: Ownable[]): Promise { for (const ownerContract of owners) { - expect(await ownerContract.owner.callAsync()).to.be.eq(ownerAddress); + expect(await ownerContract.owner().callAsync()).to.be.eq(ownerAddress); } } describe('asset proxy owner', () => { it('should be owned by `owner`', async () => { // Ensure that the owners of the asset proxy only contain the owner. - const owners = await deploymentManager.governor.getOwners.callAsync(); + const owners = await deploymentManager.governor.getOwners().callAsync(); expect(owners).to.be.deep.eq([owner]); }); }); @@ -65,25 +65,33 @@ blockchainTests('Deployment Manager', env => { it('should have the correct authorities list', async () => { // The multi-asset proxy should only have the exchange in the authorities list. - const authorities = await deploymentManager.assetProxies.multiAssetProxy.getAuthorizedAddresses.callAsync(); + const authorities = await deploymentManager.assetProxies.multiAssetProxy + .getAuthorizedAddresses() + .callAsync(); expect(authorities).to.be.deep.eq([deploymentManager.exchange.address]); // The other asset proxies should have the exchange and the multi-asset proxy in their // authorities list. - const erc20ProxyAuthorities = await deploymentManager.assetProxies.erc20Proxy.getAuthorizedAddresses.callAsync(); + const erc20ProxyAuthorities = await deploymentManager.assetProxies.erc20Proxy + .getAuthorizedAddresses() + .callAsync(); expect(erc20ProxyAuthorities).to.deep.eq([ deploymentManager.staking.zrxVault.address, deploymentManager.assetProxies.multiAssetProxy.address, deploymentManager.exchange.address, ]); - const erc1155ProxyAuthorities = await deploymentManager.assetProxies.erc1155Proxy.getAuthorizedAddresses.callAsync(); + const erc1155ProxyAuthorities = await deploymentManager.assetProxies.erc1155Proxy + .getAuthorizedAddresses() + .callAsync(); expect(erc1155ProxyAuthorities).to.deep.eq([ deploymentManager.assetProxies.multiAssetProxy.address, deploymentManager.exchange.address, ]); - const erc721ProxyAuthorities = await deploymentManager.assetProxies.erc721Proxy.getAuthorizedAddresses.callAsync(); + const erc721ProxyAuthorities = await deploymentManager.assetProxies.erc721Proxy + .getAuthorizedAddresses() + .callAsync(); expect(erc721ProxyAuthorities).to.deep.eq([ deploymentManager.assetProxies.multiAssetProxy.address, deploymentManager.exchange.address, @@ -93,7 +101,7 @@ blockchainTests('Deployment Manager', env => { describe('exchange', () => { it('should be owned by the asset proxy owner', async () => { - const exchangeOwner = await deploymentManager.exchange.owner.callAsync(); + const exchangeOwner = await deploymentManager.exchange.owner().callAsync(); expect(exchangeOwner).to.be.eq(deploymentManager.governor.address); }); @@ -101,66 +109,66 @@ blockchainTests('Deployment Manager', env => { TODO(jalextowle): This test should be enabled once the Exchange is made an Authorizable contract. it('should have authorized the asset proxy owner', async () => { - const isAuthorized = await deploymentManager.exchange.owner.callAsync( + const isAuthorized = await deploymentManager.exchange.owner( deploymentManager.governor.address, - ); + ).callAsync(); expect(isAuthorized).to.be.true(); }); */ it('should have registered the staking proxy', async () => { - const feeCollector = await deploymentManager.exchange.protocolFeeCollector.callAsync(); + const feeCollector = await deploymentManager.exchange.protocolFeeCollector().callAsync(); expect(feeCollector).to.be.eq(deploymentManager.staking.stakingProxy.address); }); it('should have set the protocol fee multiplier', async () => { - const feeMultiplier = await deploymentManager.exchange.protocolFeeMultiplier.callAsync(); + const feeMultiplier = await deploymentManager.exchange.protocolFeeMultiplier().callAsync(); expect(feeMultiplier).bignumber.to.be.eq(DeploymentManager.protocolFeeMultiplier); }); }); describe('staking', () => { it('should be owned by the asset proxy owner', async () => { - const stakingOwner = await deploymentManager.staking.stakingProxy.owner.callAsync(); + const stakingOwner = await deploymentManager.staking.stakingProxy.owner().callAsync(); expect(stakingOwner).to.be.eq(deploymentManager.governor.address); }); it('should have authorized the asset proxy owner in the staking proxy', async () => { - const isAuthorized = await deploymentManager.staking.stakingProxy.authorized.callAsync( - deploymentManager.governor.address, - ); + const isAuthorized = await deploymentManager.staking.stakingProxy + .authorized(deploymentManager.governor.address) + .callAsync(); expect(isAuthorized).to.be.true(); }); it('should have registered the exchange in the staking proxy', async () => { - const isValid = await deploymentManager.staking.stakingProxy.validExchanges.callAsync( - deploymentManager.exchange.address, - ); + const isValid = await deploymentManager.staking.stakingProxy + .validExchanges(deploymentManager.exchange.address) + .callAsync(); expect(isValid).to.be.true(); }); it('should have registered the staking contract in the staking proxy', async () => { - const stakingContract = await deploymentManager.staking.stakingProxy.stakingContract.callAsync(); + const stakingContract = await deploymentManager.staking.stakingProxy.stakingContract().callAsync(); expect(stakingContract).to.be.eq(deploymentManager.staking.stakingLogic.address); }); it('should have registered the weth contract in the staking contract', async () => { - const weth = await deploymentManager.staking.stakingWrapper.testWethAddress.callAsync(); + const weth = await deploymentManager.staking.stakingWrapper.testWethAddress().callAsync(); expect(weth).to.be.eq(deploymentManager.tokens.weth.address); }); it('should have registered the zrx vault in the staking contract', async () => { - const zrxVault = await deploymentManager.staking.stakingWrapper.testZrxVaultAddress.callAsync(); + const zrxVault = await deploymentManager.staking.stakingWrapper.testZrxVaultAddress().callAsync(); expect(zrxVault).to.be.eq(deploymentManager.staking.zrxVault.address); }); it('should have registered the staking proxy in the zrx vault', async () => { - const stakingProxy = await deploymentManager.staking.zrxVault.stakingProxyAddress.callAsync(); + const stakingProxy = await deploymentManager.staking.zrxVault.stakingProxyAddress().callAsync(); expect(stakingProxy).to.be.eq(deploymentManager.staking.stakingProxy.address); }); it('should have correctly set the params', async () => { - const params = await deploymentManager.staking.stakingWrapper.getParams.callAsync(); + const params = await deploymentManager.staking.stakingWrapper.getParams().callAsync(); expect(params).to.be.deep.eq([ stakingConstants.DEFAULT_PARAMS.epochDurationInSeconds, stakingConstants.DEFAULT_PARAMS.rewardDelegatedStakeWeight, diff --git a/contracts/integrations/test/framework-unit-tests/function_assertion_test.ts b/contracts/integrations/test/framework-unit-tests/function_assertion_test.ts index f10ec1efb7..b9158c16dd 100644 --- a/contracts/integrations/test/framework-unit-tests/function_assertion_test.ts +++ b/contracts/integrations/test/framework-unit-tests/function_assertion_test.ts @@ -45,7 +45,7 @@ blockchainTests.resets('FunctionAssertion Unit Tests', env => { }); it('should not fail immediately if the wrapped function fails', async () => { - const assertion = new FunctionAssertion<{}>(exampleContract.emptyRevert); + const assertion = new FunctionAssertion<{}, void>(exampleContract.emptyRevert); await assertion.executeAsync(); }); diff --git a/contracts/integrations/test/internal-integration-tests/deployment_test.ts b/contracts/integrations/test/internal-integration-tests/deployment_test.ts index d6e49e0e09..bbee978626 100644 --- a/contracts/integrations/test/internal-integration-tests/deployment_test.ts +++ b/contracts/integrations/test/internal-integration-tests/deployment_test.ts @@ -116,7 +116,7 @@ blockchainTests('Deployment and Configuration End to End Tests', env => { ); // Authorize owner in the staking proxy. - await stakingProxy.addAuthorizedAddress.awaitTransactionSuccessAsync(owner); + await stakingProxy.addAuthorizedAddress(owner).awaitTransactionSuccessAsync(); // Deploy the asset proxy contracts. erc20Proxy = await ERC20ProxyContract.deployFrom0xArtifactAsync( @@ -164,12 +164,11 @@ blockchainTests('Deployment and Configuration End to End Tests', env => { assetProxyId: string, ): Promise { // Register the asset proxy. - const receipt = await registrationContract.registerAssetProxy.awaitTransactionSuccessAsync( - assetProxyAddress, - { + const receipt = await registrationContract + .registerAssetProxy(assetProxyAddress) + .awaitTransactionSuccessAsync({ from: owner, - }, - ); + }); // Ensure that the correct event was logged. const logs = filterLogsToArguments( @@ -179,7 +178,7 @@ blockchainTests('Deployment and Configuration End to End Tests', env => { expect(logs).to.be.deep.eq([{ id: assetProxyId, assetProxy: assetProxyAddress }]); // Ensure that the asset proxy was actually registered. - const proxyAddress = await registrationContract.getAssetProxy.callAsync(assetProxyId); + const proxyAddress = await registrationContract.getAssetProxy(assetProxyId).callAsync(); expect(proxyAddress).to.be.eq(assetProxyAddress); } @@ -189,10 +188,9 @@ blockchainTests('Deployment and Configuration End to End Tests', env => { newAuthorityAddress: string, ): Promise { // Authorize the address. - const receipt = await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync( - newAuthorityAddress, - { from: owner }, - ); + const receipt = await authorizable + .addAuthorizedAddress(newAuthorityAddress) + .awaitTransactionSuccessAsync({ from: owner }); // Ensure that the correct log was emitted. const logs = filterLogsToArguments( @@ -202,7 +200,7 @@ blockchainTests('Deployment and Configuration End to End Tests', env => { expect(logs).to.be.deep.eq([{ target: newAuthorityAddress, caller: owner }]); // Ensure that the address was actually authorized. - const wasAuthorized = await authorizable.authorized.callAsync(newAuthorityAddress); + const wasAuthorized = await authorizable.authorized(newAuthorityAddress).callAsync(); expect(wasAuthorized).to.be.true(); } @@ -262,13 +260,13 @@ blockchainTests('Deployment and Configuration End to End Tests', env => { describe('staking specific', () => { it('should have properly configured the staking proxy with the logic contract', async () => { // Ensure that the registered staking contract is correct. - const stakingAddress = await stakingProxy.stakingContract.callAsync(); + const stakingAddress = await stakingProxy.stakingContract().callAsync(); expect(stakingAddress).to.be.eq(staking.address); }); it('should have initialized the correct parameters in the staking proxy', async () => { // Ensure that the correct parameters were set. - const params = await stakingWrapper.getParams.callAsync(); + const params = await stakingWrapper.getParams().callAsync(); expect(params).to.be.deep.eq([ stakingConstants.DEFAULT_PARAMS.epochDurationInSeconds, stakingConstants.DEFAULT_PARAMS.rewardDelegatedStakeWeight, @@ -282,7 +280,7 @@ blockchainTests('Deployment and Configuration End to End Tests', env => { describe('exchange and staking integration', () => { it('should successfully register the exchange in the staking contract', async () => { // Register the exchange. - const receipt = await stakingWrapper.addExchangeAddress.awaitTransactionSuccessAsync(exchange.address, { + const receipt = await stakingWrapper.addExchangeAddress(exchange.address).awaitTransactionSuccessAsync({ from: owner, }); @@ -294,18 +292,17 @@ blockchainTests('Deployment and Configuration End to End Tests', env => { expect(logs).to.be.deep.eq([{ exchangeAddress: exchange.address }]); // Ensure that the exchange was registered. - const wasRegistered = await stakingWrapper.validExchanges.callAsync(exchange.address); + const wasRegistered = await stakingWrapper.validExchanges(exchange.address).callAsync(); expect(wasRegistered).to.be.true(); }); it('should successfully register the staking contract in the exchange', async () => { // Register the staking contract. - const receipt = await exchange.setProtocolFeeCollectorAddress.awaitTransactionSuccessAsync( - stakingProxy.address, - { + const receipt = await exchange + .setProtocolFeeCollectorAddress(stakingProxy.address) + .awaitTransactionSuccessAsync({ from: owner, - }, - ); + }); // Ensure that the correct events were logged. const logs = filterLogsToArguments( @@ -320,15 +317,15 @@ blockchainTests('Deployment and Configuration End to End Tests', env => { ]); // Ensure that the staking contract was registered. - const feeCollector = await exchange.protocolFeeCollector.callAsync(); + const feeCollector = await exchange.protocolFeeCollector().callAsync(); expect(feeCollector).to.be.eq(stakingProxy.address); }); it('should successfully update the protocol fee multiplier in the staking contract', async () => { // Update the protocol fee multiplier. - const receipt = await exchange.setProtocolFeeMultiplier.awaitTransactionSuccessAsync( - protocolFeeMultiplier, - ); + const receipt = await exchange + .setProtocolFeeMultiplier(protocolFeeMultiplier) + .awaitTransactionSuccessAsync(); // Ensure that the correct events were logged. const logs = filterLogsToArguments( @@ -343,7 +340,7 @@ blockchainTests('Deployment and Configuration End to End Tests', env => { ]); // Ensure that the protocol fee multiplier was set correctly. - const multiplier = await exchange.protocolFeeMultiplier.callAsync(); + const multiplier = await exchange.protocolFeeMultiplier().callAsync(); expect(multiplier).bignumber.to.be.eq(protocolFeeMultiplier); }); }); @@ -354,7 +351,7 @@ blockchainTests('Deployment and Configuration End to End Tests', env => { // to the asset proxy owner. async function transferAuthorizationAndAssertSuccessAsync(contract: Authorizable): Promise { // Remove authorization from the old owner. - let receipt = await contract.removeAuthorizedAddress.awaitTransactionSuccessAsync(owner, { from: owner }); + let receipt = await contract.removeAuthorizedAddress(owner).awaitTransactionSuccessAsync({ from: owner }); // Ensure that the correct log was recorded. let logs = filterLogsToArguments( @@ -364,11 +361,11 @@ blockchainTests('Deployment and Configuration End to End Tests', env => { expect(logs).to.be.deep.eq([{ target: owner, caller: owner }]); // Ensure that the owner was actually removed. - let isAuthorized = await contract.authorized.callAsync(owner); + let isAuthorized = await contract.authorized(owner).callAsync(); expect(isAuthorized).to.be.false(); // Authorize the asset-proxy owner. - receipt = await contract.addAuthorizedAddress.awaitTransactionSuccessAsync(governor.address, { + receipt = await contract.addAuthorizedAddress(governor.address).awaitTransactionSuccessAsync({ from: owner, }); @@ -380,17 +377,17 @@ blockchainTests('Deployment and Configuration End to End Tests', env => { expect(logs).to.be.deep.eq([{ target: governor.address, caller: owner }]); // Ensure that the asset-proxy owner was actually authorized. - isAuthorized = await contract.authorized.callAsync(governor.address); + isAuthorized = await contract.authorized(governor.address).callAsync(); expect(isAuthorized).to.be.true(); } // Transfers ownership of a contract to the asset-proxy owner, and ensures that the change was actually made. async function transferOwnershipAndAssertSuccessAsync(contract: Ownable): Promise { // Transfer ownership to the new owner. - await contract.transferOwnership.awaitTransactionSuccessAsync(governor.address, { from: owner }); + await contract.transferOwnership(governor.address).awaitTransactionSuccessAsync({ from: owner }); // Ensure that the owner address has been updated. - const ownerAddress = await contract.owner.callAsync(); + const ownerAddress = await contract.owner().callAsync(); expect(ownerAddress).to.be.eq(governor.address); } diff --git a/contracts/integrations/test/internal-integration-tests/exchange_wrapper_test.ts b/contracts/integrations/test/internal-integration-tests/exchange_wrapper_test.ts index 2ba36dcce6..0889c28606 100644 --- a/contracts/integrations/test/internal-integration-tests/exchange_wrapper_test.ts +++ b/contracts/integrations/test/internal-integration-tests/exchange_wrapper_test.ts @@ -19,7 +19,7 @@ import { Numberish, provider, toBaseUnitAmount, - TransactionHelper, + transactionHelper, verifyEvents, } from '@0x/contracts-test-utils'; import { ExchangeRevertErrors, orderHashUtils } from '@0x/order-utils'; @@ -55,7 +55,6 @@ blockchainTests.resets('Exchange wrappers', env => { let localBalances: LocalBalanceStore; let wethAssetData: string; - let txHelper: TransactionHelper; before(async () => { [feeRecipient] = await env.getAccountAddressesAsync(); @@ -70,10 +69,10 @@ blockchainTests.resets('Exchange wrappers', env => { name: 'market maker', deployment, orderConfig: { - makerAssetData: await devUtils.encodeERC20AssetData.callAsync(deployment.tokens.erc20[0].address), - takerAssetData: await devUtils.encodeERC20AssetData.callAsync(deployment.tokens.erc20[1].address), - makerFeeAssetData: await devUtils.encodeERC20AssetData.callAsync(deployment.tokens.erc20[2].address), - takerFeeAssetData: await devUtils.encodeERC20AssetData.callAsync(deployment.tokens.erc20[2].address), + makerAssetData: await devUtils.encodeERC20AssetData(deployment.tokens.erc20[0].address).callAsync(), + takerAssetData: await devUtils.encodeERC20AssetData(deployment.tokens.erc20[1].address).callAsync(), + makerFeeAssetData: await devUtils.encodeERC20AssetData(deployment.tokens.erc20[2].address).callAsync(), + takerFeeAssetData: await devUtils.encodeERC20AssetData(deployment.tokens.erc20[2].address).callAsync(), feeRecipientAddress: feeRecipient, }, }); @@ -111,13 +110,7 @@ blockchainTests.resets('Exchange wrappers', env => { initialLocalBalances = LocalBalanceStore.create(devUtils, blockchainBalances); - wethAssetData = await devUtils.encodeERC20AssetData.callAsync(deployment.tokens.weth.address); - - txHelper = new TransactionHelper(env.web3Wrapper, { - ...assetProxyArtifacts, - ...exchangeArtifacts, - ...stakingArtifacts, - }); + wethAssetData = await devUtils.encodeERC20AssetData(deployment.tokens.weth.address).callAsync(); }); beforeEach(async () => { @@ -324,7 +317,7 @@ blockchainTests.resets('Exchange wrappers', env => { }); const takerAssetFilledAmount = signedOrder.takerAssetAmount.div(2); - const [fillResults, receipt] = await txHelper.getResultAndReceiptAsync( + const [fillResults, receipt] = await transactionHelper.getResultAndReceiptAsync( deployment.exchange.fillOrKillOrder, signedOrder, takerAssetFilledAmount, @@ -368,12 +361,13 @@ blockchainTests.resets('Exchange wrappers', env => { }); const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder); const expectedError = new ExchangeRevertErrors.OrderStatusError(orderHashHex, OrderStatus.Expired); - const tx = deployment.exchange.fillOrKillOrder.awaitTransactionSuccessAsync( - signedOrder, - signedOrder.takerAssetAmount, - signedOrder.signature, - { from: taker.address, gasPrice: DeploymentManager.gasPrice, value: DeploymentManager.protocolFee }, - ); + const tx = deployment.exchange + .fillOrKillOrder(signedOrder, signedOrder.takerAssetAmount, signedOrder.signature) + .awaitTransactionSuccessAsync({ + from: taker.address, + gasPrice: DeploymentManager.gasPrice, + value: DeploymentManager.protocolFee, + }); return expect(tx).to.revertWith(expectedError); }); @@ -381,23 +375,25 @@ blockchainTests.resets('Exchange wrappers', env => { const signedOrder = await maker.signOrderAsync(); const takerAssetFillAmount = signedOrder.takerAssetAmount; - await deployment.exchange.fillOrder.awaitTransactionSuccessAsync( - signedOrder, - signedOrder.takerAssetAmount.dividedToIntegerBy(2), - signedOrder.signature, - { from: taker.address, gasPrice: DeploymentManager.gasPrice, value: DeploymentManager.protocolFee }, - ); + await deployment.exchange + .fillOrder(signedOrder, signedOrder.takerAssetAmount.dividedToIntegerBy(2), signedOrder.signature) + .awaitTransactionSuccessAsync({ + from: taker.address, + gasPrice: DeploymentManager.gasPrice, + value: DeploymentManager.protocolFee, + }); const expectedError = new ExchangeRevertErrors.IncompleteFillError( ExchangeRevertErrors.IncompleteFillErrorCode.IncompleteFillOrder, takerAssetFillAmount, takerAssetFillAmount.dividedToIntegerBy(2), ); - const tx = deployment.exchange.fillOrKillOrder.awaitTransactionSuccessAsync( - signedOrder, - signedOrder.takerAssetAmount, - signedOrder.signature, - { from: taker.address, gasPrice: DeploymentManager.gasPrice, value: DeploymentManager.protocolFee }, - ); + const tx = deployment.exchange + .fillOrKillOrder(signedOrder, signedOrder.takerAssetAmount, signedOrder.signature) + .awaitTransactionSuccessAsync({ + from: taker.address, + gasPrice: DeploymentManager.gasPrice, + value: DeploymentManager.protocolFee, + }); return expect(tx).to.revertWith(expectedError); }); }); @@ -440,7 +436,7 @@ blockchainTests.resets('Exchange wrappers', env => { await simulateFillAsync(signedOrder, expectedFillResults, shouldPayWethFees); } - const [fillResults, receipt] = await txHelper.getResultAndReceiptAsync( + const [fillResults, receipt] = await transactionHelper.getResultAndReceiptAsync( deployment.exchange.batchFillOrders, signedOrders, takerAssetFillAmounts, @@ -502,7 +498,7 @@ blockchainTests.resets('Exchange wrappers', env => { await simulateFillAsync(signedOrder, expectedFillResults, shouldPayWethFees); } - const [fillResults, receipt] = await txHelper.getResultAndReceiptAsync( + const [fillResults, receipt] = await transactionHelper.getResultAndReceiptAsync( deployment.exchange.batchFillOrKillOrders, signedOrders, takerAssetFillAmounts, @@ -534,25 +530,27 @@ blockchainTests.resets('Exchange wrappers', env => { it('should revert if a single signedOrder does not fill the expected amount', async () => { const takerAssetFillAmounts = signedOrders.map(signedOrder => signedOrder.takerAssetAmount.div(2)); - await deployment.exchange.fillOrKillOrder.awaitTransactionSuccessAsync( - signedOrders[0], - signedOrders[0].takerAssetAmount, - signedOrders[0].signature, - { from: taker.address, gasPrice: DeploymentManager.gasPrice, value: DeploymentManager.protocolFee }, - ); + await deployment.exchange + .fillOrKillOrder(signedOrders[0], signedOrders[0].takerAssetAmount, signedOrders[0].signature) + .awaitTransactionSuccessAsync({ + from: taker.address, + gasPrice: DeploymentManager.gasPrice, + value: DeploymentManager.protocolFee, + }); const orderHashHex = orderHashUtils.getOrderHashHex(signedOrders[0]); const expectedError = new ExchangeRevertErrors.OrderStatusError(orderHashHex, OrderStatus.FullyFilled); - const tx = deployment.exchange.batchFillOrKillOrders.awaitTransactionSuccessAsync( - signedOrders, - takerAssetFillAmounts, - signedOrders.map(order => order.signature), - { + const tx = deployment.exchange + .batchFillOrKillOrders( + signedOrders, + takerAssetFillAmounts, + signedOrders.map(order => order.signature), + ) + .awaitTransactionSuccessAsync({ from: taker.address, gasPrice: DeploymentManager.gasPrice, value: DeploymentManager.protocolFee.times(signedOrders.length), - }, - ); + }); return expect(tx).to.revertWith(expectedError); }); }); @@ -596,7 +594,7 @@ blockchainTests.resets('Exchange wrappers', env => { } } - const [fillResults, receipt] = await txHelper.getResultAndReceiptAsync( + const [fillResults, receipt] = await transactionHelper.getResultAndReceiptAsync( deployment.exchange.batchFillOrdersNoThrow, signedOrdersWithValidity.map(signedOrderWithValidity => signedOrderWithValidity.signedOrder), takerAssetFillAmounts, @@ -711,7 +709,7 @@ blockchainTests.resets('Exchange wrappers', env => { } } - const [fillResults, receipt] = await txHelper.getResultAndReceiptAsync( + const [fillResults, receipt] = await transactionHelper.getResultAndReceiptAsync( deployment.exchange.marketSellOrdersNoThrow, signedOrdersWithValidity.map(orderWithValidity => orderWithValidity.signedOrder), takerAssetFillAmount, @@ -781,9 +779,9 @@ blockchainTests.resets('Exchange wrappers', env => { }); it('should fill a signedOrder that does not use the same takerAssetAddress (eth protocol fee)', async () => { - const differentTakerAssetData = await devUtils.encodeERC20AssetData.callAsync( - deployment.tokens.erc20[2].address, - ); + const differentTakerAssetData = await devUtils + .encodeERC20AssetData(deployment.tokens.erc20[2].address) + .callAsync(); signedOrders = [ await maker.signOrderAsync(), @@ -804,9 +802,9 @@ blockchainTests.resets('Exchange wrappers', env => { }); it('should fill a signedOrder that does not use the same takerAssetAddress (weth protocol fee)', async () => { - const differentTakerAssetData = await devUtils.encodeERC20AssetData.callAsync( - deployment.tokens.erc20[2].address, - ); + const differentTakerAssetData = await devUtils + .encodeERC20AssetData(deployment.tokens.erc20[2].address) + .callAsync(); signedOrders = [ await maker.signOrderAsync(), @@ -909,7 +907,7 @@ blockchainTests.resets('Exchange wrappers', env => { } } - const [fillResults, receipt] = await txHelper.getResultAndReceiptAsync( + const [fillResults, receipt] = await transactionHelper.getResultAndReceiptAsync( deployment.exchange.marketBuyOrdersNoThrow, signedOrdersWithValidity.map(orderWithValidity => orderWithValidity.signedOrder), makerAssetFillAmount, @@ -979,9 +977,9 @@ blockchainTests.resets('Exchange wrappers', env => { }); it('should fill a signedOrder that does not use the same makerAssetAddress (eth protocol fee)', async () => { - const differentMakerAssetData = await devUtils.encodeERC20AssetData.callAsync( - deployment.tokens.erc20[2].address, - ); + const differentMakerAssetData = await devUtils + .encodeERC20AssetData(deployment.tokens.erc20[2].address) + .callAsync(); signedOrders = [ await maker.signOrderAsync(), @@ -1003,9 +1001,9 @@ blockchainTests.resets('Exchange wrappers', env => { }); it('should fill a signedOrder that does not use the same makerAssetAddress (weth protocol fee)', async () => { - const differentMakerAssetData = await devUtils.encodeERC20AssetData.callAsync( - deployment.tokens.erc20[2].address, - ); + const differentMakerAssetData = await devUtils + .encodeERC20AssetData(deployment.tokens.erc20[2].address) + .callAsync(); signedOrders = [ await maker.signOrderAsync(), @@ -1069,7 +1067,7 @@ blockchainTests.resets('Exchange wrappers', env => { describe('batchCancelOrders', () => { it('should be able to cancel multiple signedOrders', async () => { - const receipt = await deployment.exchange.batchCancelOrders.awaitTransactionSuccessAsync(signedOrders, { + const receipt = await deployment.exchange.batchCancelOrders(signedOrders).awaitTransactionSuccessAsync({ from: maker.address, }); const expectedOrderHashes = signedOrders.map(order => orderHashUtils.getOrderHashHex(order)); @@ -1080,13 +1078,13 @@ blockchainTests.resets('Exchange wrappers', env => { }); it('should not revert if a single cancel noops', async () => { - await deployment.exchange.cancelOrder.awaitTransactionSuccessAsync(signedOrders[1], { + await deployment.exchange.cancelOrder(signedOrders[1]).awaitTransactionSuccessAsync({ from: maker.address, }); const expectedOrderHashes = [signedOrders[0], ...signedOrders.slice(2)].map(order => orderHashUtils.getOrderHashHex(order), ); - const receipt = await deployment.exchange.batchCancelOrders.awaitTransactionSuccessAsync(signedOrders, { + const receipt = await deployment.exchange.batchCancelOrders(signedOrders).awaitTransactionSuccessAsync({ from: maker.address, }); diff --git a/contracts/integrations/test/internal-integration-tests/fillorder_test.ts b/contracts/integrations/test/internal-integration-tests/fillorder_test.ts index 16f532f609..21f556ad16 100644 --- a/contracts/integrations/test/internal-integration-tests/fillorder_test.ts +++ b/contracts/integrations/test/internal-integration-tests/fillorder_test.ts @@ -50,10 +50,10 @@ blockchainTests.resets('fillOrder integration tests', env => { }); const orderConfig = { feeRecipientAddress: feeRecipient.address, - makerAssetData: await devUtils.encodeERC20AssetData.callAsync(makerToken.address), - takerAssetData: await devUtils.encodeERC20AssetData.callAsync(takerToken.address), - makerFeeAssetData: await devUtils.encodeERC20AssetData.callAsync(makerToken.address), - takerFeeAssetData: await devUtils.encodeERC20AssetData.callAsync(takerToken.address), + makerAssetData: await devUtils.encodeERC20AssetData(makerToken.address).callAsync(), + takerAssetData: await devUtils.encodeERC20AssetData(takerToken.address).callAsync(), + makerFeeAssetData: await devUtils.encodeERC20AssetData(makerToken.address).callAsync(), + takerFeeAssetData: await devUtils.encodeERC20AssetData(takerToken.address).callAsync(), makerFee: constants.ZERO_AMOUNT, takerFee: constants.ZERO_AMOUNT, }; @@ -133,7 +133,7 @@ blockchainTests.resets('fillOrder integration tests', env => { taker.address, deployment.staking.stakingProxy.address, DeploymentManager.protocolFee, - await devUtils.encodeERC20AssetData.callAsync(deployment.tokens.weth.address), + await devUtils.encodeERC20AssetData(deployment.tokens.weth.address).callAsync(), ); } @@ -224,7 +224,7 @@ blockchainTests.resets('fillOrder integration tests', env => { // now expect a `StakingPoolEarnedRewardsInEpoch` event to be emitted because the staking // pool now has enough stake in the current epoch to earn rewards. verifyFillEvents(order, receipt); - const currentEpoch = await deployment.staking.stakingWrapper.currentEpoch.callAsync(); + const currentEpoch = await deployment.staking.stakingWrapper.currentEpoch().callAsync(); verifyEvents( receipt, [ @@ -253,7 +253,7 @@ blockchainTests.resets('fillOrder integration tests', env => { // End the epoch. This should wrap the staking proxy's ETH balance. const endEpochReceipt = await delegator.endEpochAsync(); - const newEpoch = await deployment.staking.stakingWrapper.currentEpoch.callAsync(); + const newEpoch = await deployment.staking.stakingWrapper.currentEpoch().callAsync(); // Check balances expectedBalances.wrapEth( @@ -295,7 +295,7 @@ blockchainTests.resets('fillOrder integration tests', env => { deployment.staking.stakingProxy.address, operator.address, operatorReward, - await devUtils.encodeERC20AssetData.callAsync(deployment.tokens.weth.address), + await devUtils.encodeERC20AssetData(deployment.tokens.weth.address).callAsync(), ); expectedBalances.burnGas(delegator.address, DeploymentManager.gasPrice.times(finalizePoolReceipt.gasUsed)); await balanceStore.updateBalancesAsync(); @@ -336,7 +336,7 @@ blockchainTests.resets('fillOrder integration tests', env => { await taker.fillOrderAsync(order, order.takerAssetAmount); // Check that the pool has collected fees from the above fill. - const poolStats = await deployment.staking.stakingWrapper.getStakingPoolStatsThisEpoch.callAsync(poolId); + const poolStats = await deployment.staking.stakingWrapper.getStakingPoolStatsThisEpoch(poolId).callAsync(); expect(poolStats.feesCollected).to.bignumber.equal(DeploymentManager.protocolFee); }); it('should collect WETH fees and pay out rewards', async () => { @@ -375,7 +375,7 @@ blockchainTests.resets('fillOrder integration tests', env => { deployment.staking.stakingProxy.address, operator.address, operatorReward, - await devUtils.encodeERC20AssetData.callAsync(deployment.tokens.weth.address), + await devUtils.encodeERC20AssetData(deployment.tokens.weth.address).callAsync(), ); expectedBalances.burnGas(delegator.address, DeploymentManager.gasPrice.times(finalizePoolReceipt.gasUsed)); await balanceStore.updateBalancesAsync(); diff --git a/contracts/integrations/test/utils/deployment_manager.ts b/contracts/integrations/test/utils/deployment_manager.ts index b67008cbf1..93a8ebd3a8 100644 --- a/contracts/integrations/test/utils/deployment_manager.ts +++ b/contracts/integrations/test/utils/deployment_manager.ts @@ -41,7 +41,7 @@ async function batchAddAuthorizedAddressAsync( ): Promise { for (const authorizer of authorizers) { for (const authority of authorities) { - await authorizer.addAuthorizedAddress.awaitTransactionSuccessAsync(authority, { from: owner }); + await authorizer.addAuthorizedAddress(authority).awaitTransactionSuccessAsync({ from: owner }); } } } @@ -59,7 +59,7 @@ async function batchRegisterAssetProxyAsync( ): Promise { for (const registry of registries) { for (const proxy of proxies) { - await registry.registerAssetProxy.awaitTransactionSuccessAsync(proxy, { from: owner }); + await registry.registerAssetProxy(proxy).awaitTransactionSuccessAsync({ from: owner }); } } } @@ -76,7 +76,7 @@ async function batchTransferOwnershipAsync( ownedContracts: Ownable[], ): Promise { for (const ownedContract of ownedContracts) { - await ownedContract.transferOwnership.awaitTransactionSuccessAsync(newOwner.address, { from: owner }); + await ownedContract.transferOwnership(newOwner.address).awaitTransactionSuccessAsync({ from: owner }); } } @@ -174,16 +174,16 @@ export class DeploymentManager { await DeploymentManager._configureExchangeWithStakingAsync(exchange, staking, owner); // Authorize the asset-proxy owner in the staking proxy and in the zrx vault. - await staking.stakingProxy.addAuthorizedAddress.awaitTransactionSuccessAsync(governor.address, { + await staking.stakingProxy.addAuthorizedAddress(governor.address).awaitTransactionSuccessAsync({ from: owner, }); - await staking.zrxVault.addAuthorizedAddress.awaitTransactionSuccessAsync(governor.address, { + await staking.zrxVault.addAuthorizedAddress(governor.address).awaitTransactionSuccessAsync({ from: owner, }); // Remove authorization for the original owner address. - await staking.stakingProxy.removeAuthorizedAddress.awaitTransactionSuccessAsync(owner, { from: owner }); - await staking.zrxVault.removeAuthorizedAddress.awaitTransactionSuccessAsync(owner, { from: owner }); + await staking.stakingProxy.removeAuthorizedAddress(owner).awaitTransactionSuccessAsync({ from: owner }); + await staking.zrxVault.removeAuthorizedAddress(owner).awaitTransactionSuccessAsync({ from: owner }); // Transfer complete ownership of the system to the asset proxy owner. await batchTransferOwnershipAsync(owner, governor, [ @@ -266,13 +266,13 @@ export class DeploymentManager { owner: string, ): Promise { // Configure the exchange for staking. - await exchange.setProtocolFeeCollectorAddress.awaitTransactionSuccessAsync(staking.stakingProxy.address, { + await exchange.setProtocolFeeCollectorAddress(staking.stakingProxy.address).awaitTransactionSuccessAsync({ from: owner, }); - await exchange.setProtocolFeeMultiplier.awaitTransactionSuccessAsync(DeploymentManager.protocolFeeMultiplier); + await exchange.setProtocolFeeMultiplier(DeploymentManager.protocolFeeMultiplier).awaitTransactionSuccessAsync(); // Register the exchange contract in staking. - await staking.stakingWrapper.addExchangeAddress.awaitTransactionSuccessAsync(exchange.address, { from: owner }); + await staking.stakingWrapper.addExchangeAddress(exchange.address).awaitTransactionSuccessAsync({ from: owner }); } /** @@ -365,20 +365,20 @@ export class DeploymentManager { const stakingWrapper = new TestStakingContract(stakingProxy.address, environment.provider, txDefaults); // Add the zrx vault and the weth contract to the staking proxy. - await stakingWrapper.setWethContract.awaitTransactionSuccessAsync(tokens.weth.address, { from: owner }); - await stakingWrapper.setZrxVault.awaitTransactionSuccessAsync(zrxVault.address, { from: owner }); + await stakingWrapper.setWethContract(tokens.weth.address).awaitTransactionSuccessAsync({ from: owner }); + await stakingWrapper.setZrxVault(zrxVault.address).awaitTransactionSuccessAsync({ from: owner }); // Authorize the owner address in the staking proxy and the zrx vault. - await stakingProxy.addAuthorizedAddress.awaitTransactionSuccessAsync(owner, { from: owner }); - await zrxVault.addAuthorizedAddress.awaitTransactionSuccessAsync(owner, { from: owner }); + await stakingProxy.addAuthorizedAddress(owner).awaitTransactionSuccessAsync({ from: owner }); + await zrxVault.addAuthorizedAddress(owner).awaitTransactionSuccessAsync({ from: owner }); // Authorize the zrx vault in the erc20 proxy - await assetProxies.erc20Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(zrxVault.address, { + await assetProxies.erc20Proxy.addAuthorizedAddress(zrxVault.address).awaitTransactionSuccessAsync({ from: owner, }); // Configure the zrx vault and the staking contract. - await zrxVault.setStakingProxy.awaitTransactionSuccessAsync(stakingProxy.address, { from: owner }); + await zrxVault.setStakingProxy(stakingProxy.address).awaitTransactionSuccessAsync({ from: owner }); return { stakingLogic, diff --git a/contracts/integrations/test/utils/function_assertions.ts b/contracts/integrations/test/utils/function_assertions.ts index 37ebceb2cc..c3bb3c6ccf 100644 --- a/contracts/integrations/test/utils/function_assertions.ts +++ b/contracts/integrations/test/utils/function_assertions.ts @@ -1,16 +1,10 @@ -import { PromiseWithTransactionHash } from '@0x/base-contract'; +import { ContractFunctionObj, ContractTxFunctionObj, PromiseWithTransactionHash } from '@0x/base-contract'; import { TransactionReceiptWithDecodedLogs } from 'ethereum-types'; import * as _ from 'lodash'; // tslint:disable:max-classes-per-file -export interface ContractGetterFunction { - callAsync: (...args: any[]) => Promise; -} - -export interface ContractWrapperFunction extends ContractGetterFunction { - awaitTransactionSuccessAsync?: (...args: any[]) => PromiseWithTransactionHash; -} +export type GenericContractFunction = (...args: any[]) => ContractFunctionObj; export interface Result { data?: any; @@ -53,14 +47,21 @@ export interface RunResult { * This class implements `Assertion` and represents a "Hoare Triple" that can be * executed. */ -export class FunctionAssertion implements Assertion { +export class FunctionAssertion implements Assertion { // A condition that will be applied to `wrapperFunction`. public condition: Condition; // The wrapper function that will be wrapped in assertions. - public wrapperFunction: ContractWrapperFunction; + public wrapperFunction: ( + ...args: any[] + ) => ContractTxFunctionObj | ContractFunctionObj; - constructor(wrapperFunction: ContractWrapperFunction, condition: Partial> = {}) { + constructor( + wrapperFunction: ( + ...args: any[] + ) => ContractTxFunctionObj | ContractFunctionObj, + condition: Partial> = {}, + ) { this.condition = { before: _.noop.bind(this), after: _.noop.bind(this), @@ -83,10 +84,11 @@ export class FunctionAssertion implements Assertion { // Try to make the call to the function. If it is successful, pass the // result and receipt to the after condition. try { - callResult.data = await this.wrapperFunction.callAsync(...args); + const functionWithArgs = this.wrapperFunction(...args) as ContractTxFunctionObj; + callResult.data = await functionWithArgs.callAsync(); callResult.receipt = - this.wrapperFunction.awaitTransactionSuccessAsync !== undefined - ? await this.wrapperFunction.awaitTransactionSuccessAsync(...args) + functionWithArgs.awaitTransactionSuccessAsync !== undefined + ? await functionWithArgs.awaitTransactionSuccessAsync() : undefined; } catch (error) { callResult.data = error; diff --git a/contracts/multisig/test/multi_sig_with_time_lock.ts b/contracts/multisig/test/multi_sig_with_time_lock.ts index 6f59a7f60b..3eff2c87ea 100644 --- a/contracts/multisig/test/multi_sig_with_time_lock.ts +++ b/contracts/multisig/test/multi_sig_with_time_lock.ts @@ -125,9 +125,9 @@ describe('MultiSigWalletWithTimeLock', () => { }); it('should confirm transaction for caller but not reset the confirmation time if tx is already fully confirmed', async () => { await multiSigWrapper.confirmTransactionAsync(txId, owners[1]); - const confirmationTimeBefore = await multiSig.confirmationTimes.callAsync(txId); + const confirmationTimeBefore = await multiSig.confirmationTimes(txId).callAsync(); const txReceipt = await multiSigWrapper.confirmTransactionAsync(txId, owners[2]); - const confirmationTimeAfter = await multiSig.confirmationTimes.callAsync(txId); + const confirmationTimeAfter = await multiSig.confirmationTimes(txId).callAsync(); expect(confirmationTimeBefore).to.bignumber.equal(confirmationTimeAfter); expect(txReceipt.logs.length).to.equal(1); const log = txReceipt.logs[0] as LogWithDecodedArgs; @@ -255,25 +255,25 @@ describe('MultiSigWalletWithTimeLock', () => { it('should revert when not called by wallet', async () => { return expectTransactionFailedWithoutReasonAsync( - multiSig.changeTimeLock.sendTransactionAsync(SECONDS_TIME_LOCKED, { from: owners[0] }), + multiSig.changeTimeLock(SECONDS_TIME_LOCKED).sendTransactionAsync({ from: owners[0] }), ); }); it('should revert without enough confirmations', async () => { const destination = multiSig.address; - const changeTimeLockData = multiSig.changeTimeLock.getABIEncodedTransactionData(SECONDS_TIME_LOCKED); + const changeTimeLockData = multiSig.changeTimeLock(SECONDS_TIME_LOCKED).getABIEncodedTransactionData(); const res = await multiSigWrapper.submitTransactionAsync(destination, changeTimeLockData, owners[0]); const log = res.logs[0] as LogWithDecodedArgs; const txId = log.args.transactionId; return expectTransactionFailedAsync( - multiSig.executeTransaction.sendTransactionAsync(txId, { from: owners[0] }), + multiSig.executeTransaction(txId).sendTransactionAsync({ from: owners[0] }), RevertReason.TxNotFullyConfirmed, ); }); it('should set confirmation time with enough confirmations', async () => { const destination = multiSig.address; - const changeTimeLockData = multiSig.changeTimeLock.getABIEncodedTransactionData(SECONDS_TIME_LOCKED); + const changeTimeLockData = multiSig.changeTimeLock(SECONDS_TIME_LOCKED).getABIEncodedTransactionData(); const subRes = await multiSigWrapper.submitTransactionAsync(destination, changeTimeLockData, owners[0]); const subLog = subRes.logs[0] as LogWithDecodedArgs; const txId = subLog.args.transactionId; @@ -287,14 +287,14 @@ describe('MultiSigWalletWithTimeLock', () => { throw new Error(`Unexpectedly failed to fetch block at #${blockNum}`); } const timestamp = new BigNumber(blockInfo.timestamp); - const confirmationTimeBigNum = new BigNumber(await multiSig.confirmationTimes.callAsync(txId)); + const confirmationTimeBigNum = new BigNumber(await multiSig.confirmationTimes(txId).callAsync()); expect(timestamp).to.be.bignumber.equal(confirmationTimeBigNum); }); it('should be executable with enough confirmations and secondsTimeLocked of 0', async () => { const destination = multiSig.address; - const changeTimeLockData = multiSig.changeTimeLock.getABIEncodedTransactionData(SECONDS_TIME_LOCKED); + const changeTimeLockData = multiSig.changeTimeLock(SECONDS_TIME_LOCKED).getABIEncodedTransactionData(); const subRes = await multiSigWrapper.submitTransactionAsync(destination, changeTimeLockData, owners[0]); const subLog = subRes.logs[0] as LogWithDecodedArgs; const txId = subLog.args.transactionId; @@ -302,7 +302,7 @@ describe('MultiSigWalletWithTimeLock', () => { await multiSigWrapper.confirmTransactionAsync(txId, owners[1]); await multiSigWrapper.executeTransactionAsync(txId, owners[1]); - const secondsTimeLocked = new BigNumber(await multiSig.secondsTimeLocked.callAsync()); + const secondsTimeLocked = new BigNumber(await multiSig.secondsTimeLocked().callAsync()); expect(secondsTimeLocked).to.be.bignumber.equal(SECONDS_TIME_LOCKED); }); }); @@ -327,7 +327,7 @@ describe('MultiSigWalletWithTimeLock', () => { ); multiSigWrapper = new MultiSigWrapper(multiSig, provider); - const changeTimeLockData = multiSig.changeTimeLock.getABIEncodedTransactionData(newSecondsTimeLocked); + const changeTimeLockData = multiSig.changeTimeLock(newSecondsTimeLocked).getABIEncodedTransactionData(); const res = await multiSigWrapper.submitTransactionAsync( multiSig.address, changeTimeLockData, @@ -340,19 +340,21 @@ describe('MultiSigWalletWithTimeLock', () => { it('should revert if it has enough confirmations but is not past the time lock', async () => { return expectTransactionFailedAsync( - multiSig.executeTransaction.sendTransactionAsync(txId, { from: owners[0] }), + multiSig.executeTransaction(txId).sendTransactionAsync({ from: owners[0] }), RevertReason.TimeLockIncomplete, ); }); it('should execute if it has enough confirmations and is past the time lock', async () => { await increaseTimeAndMineBlockAsync(SECONDS_TIME_LOCKED.toNumber()); - await web3Wrapper.awaitTransactionSuccessAsync( - await multiSig.executeTransaction.sendTransactionAsync(txId, { from: owners[0] }), - constants.AWAIT_TRANSACTION_MINED_MS, - ); + await multiSig + .executeTransaction(txId) + .awaitTransactionSuccessAsync( + { from: owners[0] }, + { pollingIntervalMs: constants.AWAIT_TRANSACTION_MINED_MS }, + ); - const secondsTimeLocked = new BigNumber(await multiSig.secondsTimeLocked.callAsync()); + const secondsTimeLocked = new BigNumber(await multiSig.secondsTimeLocked().callAsync()); expect(secondsTimeLocked).to.be.bignumber.equal(newSecondsTimeLocked); }); }); diff --git a/contracts/multisig/test/utils/multi_sig_wrapper.ts b/contracts/multisig/test/utils/multi_sig_wrapper.ts index 11f2ce51eb..077d577272 100644 --- a/contracts/multisig/test/utils/multi_sig_wrapper.ts +++ b/contracts/multisig/test/utils/multi_sig_wrapper.ts @@ -25,19 +25,19 @@ export class MultiSigWrapper { opts: { value?: BigNumber } = {}, ): Promise { const value = opts.value === undefined ? new BigNumber(0) : opts.value; - const txHash = await this._multiSig.submitTransaction.sendTransactionAsync(destination, value, data, { + const txHash = await this._multiSig.submitTransaction(destination, value, data).sendTransactionAsync({ from, }); const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash); return tx; } public async confirmTransactionAsync(txId: BigNumber, from: string): Promise { - const txHash = await this._multiSig.confirmTransaction.sendTransactionAsync(txId, { from }); + const txHash = await this._multiSig.confirmTransaction(txId).sendTransactionAsync({ from }); const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash); return tx; } public async revokeConfirmationAsync(txId: BigNumber, from: string): Promise { - const txHash = await this._multiSig.revokeConfirmation.sendTransactionAsync(txId, { from }); + const txHash = await this._multiSig.revokeConfirmation(txId).sendTransactionAsync({ from }); const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash); return tx; } @@ -46,7 +46,7 @@ export class MultiSigWrapper { from: string, opts: { gas?: number } = {}, ): Promise { - const txHash = await this._multiSig.executeTransaction.sendTransactionAsync(txId, { + const txHash = await this._multiSig.executeTransaction(txId).sendTransactionAsync({ from, gas: opts.gas, }); diff --git a/contracts/multisig/test/utils/zero_ex_governor_wrapper.ts b/contracts/multisig/test/utils/zero_ex_governor_wrapper.ts index 19a0688fd9..8adcdc8435 100644 --- a/contracts/multisig/test/utils/zero_ex_governor_wrapper.ts +++ b/contracts/multisig/test/utils/zero_ex_governor_wrapper.ts @@ -20,12 +20,13 @@ export class ZeroExGovernorWrapper { const values = opts.values === undefined ? data.map(() => constants.ZERO_AMOUNT) : opts.values; const batchTransactionEncoder = AbiEncoder.create('(bytes[],address[],uint256[])'); const batchTransactionData = batchTransactionEncoder.encode([data, destinations, values]); - const txReceipt = await this._governor.submitTransaction.awaitTransactionSuccessAsync( - hexRandom(20), // submitTransaction will fail if this is a null address - constants.ZERO_AMOUNT, - batchTransactionData, - { from }, - ); + const txReceipt = await this._governor + .submitTransaction( + hexRandom(20), // submitTransaction will fail if this is a null address + constants.ZERO_AMOUNT, + batchTransactionData, + ) + .awaitTransactionSuccessAsync({ from }); const txId = (txReceipt.logs[0] as LogWithDecodedArgs).args.transactionId; return { txReceipt, txId }; } @@ -39,15 +40,16 @@ export class ZeroExGovernorWrapper { const submitResults = await this.submitTransactionAsync(data, destinations, signerAddresses[0], opts); const requiredSignatures = opts.requiredSignatures === undefined ? 2 : opts.requiredSignatures; for (const index of _.range(1, requiredSignatures)) { - await this._governor.confirmTransaction.awaitTransactionSuccessAsync(submitResults.txId, { + await this._governor.confirmTransaction(submitResults.txId).awaitTransactionSuccessAsync({ from: signerAddresses[index], }); } await increaseTimeAndMineBlockAsync(increaseTimeSeconds); - const executionTxReceipt = await this._governor.executeTransaction.awaitTransactionSuccessAsync( - submitResults.txId, - { from: opts.executeFromAddress === undefined ? signerAddresses[0] : opts.executeFromAddress }, - ); + const executionTxReceipt = await this._governor + .executeTransaction(submitResults.txId) + .awaitTransactionSuccessAsync({ + from: opts.executeFromAddress === undefined ? signerAddresses[0] : opts.executeFromAddress, + }); return { executionTxReceipt, txId: submitResults.txId }; } } diff --git a/contracts/multisig/test/zero_ex_governor.ts b/contracts/multisig/test/zero_ex_governor.ts index 9615070613..ff2345b036 100644 --- a/contracts/multisig/test/zero_ex_governor.ts +++ b/contracts/multisig/test/zero_ex_governor.ts @@ -157,10 +157,9 @@ blockchainTests.resets('ZeroExGovernor', env => { new BigNumber(REQUIRED_SIGNERS), new BigNumber(DEFAULT_TIME_LOCK), ); - const timelock = await governorContract.functionCallTimeLocks.callAsync( - reg.functionSelectors[0], - reg.destinations[0], - ); + const timelock = await governorContract + .functionCallTimeLocks(reg.functionSelectors[0], reg.destinations[0]) + .callAsync(); expect(timelock[0]).to.equal(true); expect(timelock[1]).to.bignumber.equal(reg.functionCallTimeLockSeconds[0]); }); @@ -179,10 +178,9 @@ blockchainTests.resets('ZeroExGovernor', env => { new BigNumber(DEFAULT_TIME_LOCK), ); for (const [index, selector] of reg.functionSelectors.entries()) { - const timelock = await governorContract.functionCallTimeLocks.callAsync( - selector, - reg.destinations[index], - ); + const timelock = await governorContract + .functionCallTimeLocks(selector, reg.destinations[index]) + .callAsync(); expect(timelock[0]).to.equal(true); expect(timelock[1]).to.bignumber.equal(reg.functionCallTimeLockSeconds[index]); } @@ -192,23 +190,26 @@ blockchainTests.resets('ZeroExGovernor', env => { blockchainTests.resets('registerFunctionCall', () => { it('should revert if not called by wallet', async () => { const reg = createFunctionRegistration(1, 1, 1); - const tx = governor.registerFunctionCall.awaitTransactionSuccessAsync( - true, - reg.functionSelectors[0], - reg.destinations[0], - reg.functionCallTimeLockSeconds[0], - { from: signerAddresses[0] }, - ); + const tx = governor + .registerFunctionCall( + true, + reg.functionSelectors[0], + reg.destinations[0], + reg.functionCallTimeLockSeconds[0], + ) + .awaitTransactionSuccessAsync({ from: signerAddresses[0] }); expect(tx).to.revertWith(RevertReason.OnlyCallableByWallet); }); it('should register a function call', async () => { const reg = createFunctionRegistration(1, 1, 1); - const txReceipt = await governor.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync( - true, - reg.functionSelectors[0], - reg.destinations[0], - reg.functionCallTimeLockSeconds[0], - ); + const txReceipt = await governor + .registerFunctionCallBypassWallet( + true, + reg.functionSelectors[0], + reg.destinations[0], + reg.functionCallTimeLockSeconds[0], + ) + .awaitTransactionSuccessAsync(); expect(txReceipt.logs.length).to.eq(1); const logArgs = (txReceipt.logs[0] as LogWithDecodedArgs< ZeroExGovernorFunctionCallTimeLockRegistrationEventArgs @@ -217,53 +218,53 @@ blockchainTests.resets('ZeroExGovernor', env => { expect(logArgs.destination).to.eq(reg.destinations[0]); expect(logArgs.hasCustomTimeLock).to.eq(true); expect(logArgs.newSecondsTimeLocked).to.bignumber.eq(reg.functionCallTimeLockSeconds[0]); - const timelock = await governor.functionCallTimeLocks.callAsync( - reg.functionSelectors[0], - reg.destinations[0], - ); + const timelock = await governor + .functionCallTimeLocks(reg.functionSelectors[0], reg.destinations[0]) + .callAsync(); expect(timelock[0]).to.equal(true); expect(timelock[1]).to.bignumber.equal(reg.functionCallTimeLockSeconds[0]); }); it('should be able to overwrite existing function calls', async () => { const reg = createFunctionRegistration(1, 1, 1); - await governor.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync( - true, - reg.functionSelectors[0], - reg.destinations[0], - reg.functionCallTimeLockSeconds[0], - ); + await governor + .registerFunctionCallBypassWallet( + true, + reg.functionSelectors[0], + reg.destinations[0], + reg.functionCallTimeLockSeconds[0], + ) + .awaitTransactionSuccessAsync(); const newTimeLock = reg.functionCallTimeLockSeconds[0].plus(1000); - await governor.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync( - true, - reg.functionSelectors[0], - reg.destinations[0], - newTimeLock, - ); - const timelock = await governor.functionCallTimeLocks.callAsync( - reg.functionSelectors[0], - reg.destinations[0], - ); + await governor + .registerFunctionCallBypassWallet(true, reg.functionSelectors[0], reg.destinations[0], newTimeLock) + .awaitTransactionSuccessAsync(); + const timelock = await governor + .functionCallTimeLocks(reg.functionSelectors[0], reg.destinations[0]) + .callAsync(); expect(timelock[0]).to.equal(true); expect(timelock[1]).to.bignumber.equal(newTimeLock); }); it('should clear the function timelock if hasCustomTimeLock is set to false', async () => { const reg = createFunctionRegistration(1, 1, 1); - await governor.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync( - true, - reg.functionSelectors[0], - reg.destinations[0], - reg.functionCallTimeLockSeconds[0], - ); - await governor.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync( - false, - reg.functionSelectors[0], - reg.destinations[0], - reg.functionCallTimeLockSeconds[0], - ); - const timelock = await governor.functionCallTimeLocks.callAsync( - reg.functionSelectors[0], - reg.destinations[0], - ); + await governor + .registerFunctionCallBypassWallet( + true, + reg.functionSelectors[0], + reg.destinations[0], + reg.functionCallTimeLockSeconds[0], + ) + .awaitTransactionSuccessAsync(); + await governor + .registerFunctionCallBypassWallet( + false, + reg.functionSelectors[0], + reg.destinations[0], + reg.functionCallTimeLockSeconds[0], + ) + .awaitTransactionSuccessAsync(); + const timelock = await governor + .functionCallTimeLocks(reg.functionSelectors[0], reg.destinations[0]) + .callAsync(); expect(timelock[0]).to.equal(false); expect(timelock[1]).to.bignumber.equal(constants.ZERO_AMOUNT); }); @@ -271,11 +272,9 @@ blockchainTests.resets('ZeroExGovernor', env => { describe('assertValidFunctionCall', () => { it('should revert if the data is less than 4 bytes long', async () => { - const result = governor.assertValidFunctionCall.callAsync( - constants.ZERO_AMOUNT, - constants.NULL_BYTES, - constants.NULL_ADDRESS, - ); + const result = governor + .assertValidFunctionCall(constants.ZERO_AMOUNT, constants.NULL_BYTES, constants.NULL_ADDRESS) + .callAsync(); const expectedError = new LibBytesRevertErrors.InvalidByteOperationError( LibBytesRevertErrors.InvalidByteOperationErrorCodes.LengthGreaterThanOrEqualsFourRequired, constants.ZERO_AMOUNT, @@ -287,91 +286,87 @@ blockchainTests.resets('ZeroExGovernor', env => { const latestTimestamp = await getLatestBlockTimestampAsync(); const transactionConfirmationTime = new BigNumber(latestTimestamp); const reg = createFunctionRegistration(1, 1, 1); - const result = governor.assertValidFunctionCall.callAsync( - transactionConfirmationTime, - reg.functionSelectors[0], - reg.destinations[0], - ); + const result = governor + .assertValidFunctionCall(transactionConfirmationTime, reg.functionSelectors[0], reg.destinations[0]) + .callAsync(); expect(result).to.revertWith(RevertReason.DefaultTimeLockIncomplete); }); it('should revert if a registered function is called before the custom timelock', async () => { const reg = createFunctionRegistration(1, 1, 1); - await governor.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync( - true, - reg.functionSelectors[0], - reg.destinations[0], - reg.functionCallTimeLockSeconds[0], - ); + await governor + .registerFunctionCallBypassWallet( + true, + reg.functionSelectors[0], + reg.destinations[0], + reg.functionCallTimeLockSeconds[0], + ) + .awaitTransactionSuccessAsync(); const latestTimestamp = await getLatestBlockTimestampAsync(); const transactionConfirmationTime = new BigNumber(latestTimestamp); - const result = governor.assertValidFunctionCall.callAsync( - transactionConfirmationTime, - reg.functionSelectors[0], - reg.destinations[0], - ); + const result = governor + .assertValidFunctionCall(transactionConfirmationTime, reg.functionSelectors[0], reg.destinations[0]) + .callAsync(); expect(result).to.revertWith(RevertReason.CustomTimeLockIncomplete); }); it('should revert if a registered function is called before the custom timelock and after the default timelock', async () => { const reg = createFunctionRegistration(1, 1, 1); - await governor.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync( - true, - reg.functionSelectors[0], - reg.destinations[0], - new BigNumber(DEFAULT_TIME_LOCK).times(2), - ); + await governor + .registerFunctionCallBypassWallet( + true, + reg.functionSelectors[0], + reg.destinations[0], + new BigNumber(DEFAULT_TIME_LOCK).times(2), + ) + .awaitTransactionSuccessAsync(); const latestTimestamp = await getLatestBlockTimestampAsync(); const transactionConfirmationTime = new BigNumber(latestTimestamp).minus(DEFAULT_TIME_LOCK); - const result = governor.assertValidFunctionCall.callAsync( - transactionConfirmationTime, - reg.functionSelectors[0], - reg.destinations[0], - ); + const result = governor + .assertValidFunctionCall(transactionConfirmationTime, reg.functionSelectors[0], reg.destinations[0]) + .callAsync(); expect(result).to.revertWith(RevertReason.CustomTimeLockIncomplete); }); it('should be successful if an unregistered function is called after the default timelock', async () => { const latestTimestamp = await getLatestBlockTimestampAsync(); const transactionConfirmationTime = new BigNumber(latestTimestamp).minus(DEFAULT_TIME_LOCK); const reg = createFunctionRegistration(1, 1, 1); - const result = governor.assertValidFunctionCall.callAsync( - transactionConfirmationTime, - reg.functionSelectors[0], - reg.destinations[0], - ); + const result = governor + .assertValidFunctionCall(transactionConfirmationTime, reg.functionSelectors[0], reg.destinations[0]) + .callAsync(); expect(result).to.be.fulfilled(''); }); it('should be successful if a registered function is called after the custom timelock', async () => { const reg = createFunctionRegistration(1, 1, 1); - await governor.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync( - true, - reg.functionSelectors[0], - reg.destinations[0], - reg.functionCallTimeLockSeconds[0], - ); + await governor + .registerFunctionCallBypassWallet( + true, + reg.functionSelectors[0], + reg.destinations[0], + reg.functionCallTimeLockSeconds[0], + ) + .awaitTransactionSuccessAsync(); const latestTimestamp = await getLatestBlockTimestampAsync(); const transactionConfirmationTime = new BigNumber(latestTimestamp).minus( reg.functionCallTimeLockSeconds[0], ); - const result = governor.assertValidFunctionCall.callAsync( - transactionConfirmationTime, - reg.functionSelectors[0], - reg.destinations[0], - ); + const result = governor + .assertValidFunctionCall(transactionConfirmationTime, reg.functionSelectors[0], reg.destinations[0]) + .callAsync(); expect(result).to.be.fulfilled(''); }); it('should allow a custom timelock to be set to 0', async () => { const reg = createFunctionRegistration(1, 1, 1); - await governor.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync( - true, - reg.functionSelectors[0], - reg.destinations[0], - constants.ZERO_AMOUNT, - ); + await governor + .registerFunctionCallBypassWallet( + true, + reg.functionSelectors[0], + reg.destinations[0], + constants.ZERO_AMOUNT, + ) + .awaitTransactionSuccessAsync(); const latestTimestamp = await getLatestBlockTimestampAsync(); - const result = governor.assertValidFunctionCall.callAsync( - new BigNumber(latestTimestamp), - reg.functionSelectors[0], - reg.destinations[0], - ); + const result = governor + .assertValidFunctionCall(new BigNumber(latestTimestamp), reg.functionSelectors[0], reg.destinations[0]) + .callAsync(); expect(result).to.be.fulfilled(''); }); }); @@ -401,7 +396,7 @@ blockchainTests.resets('ZeroExGovernor', env => { const data = [hexRandom()]; const destinations = [receiver.address]; const results = await governorWrapper.submitTransactionAsync(data, destinations, signerAddresses[0]); - const tx = governor.executeTransaction.awaitTransactionSuccessAsync(results.txId, { + const tx = governor.executeTransaction(results.txId).awaitTransactionSuccessAsync({ from: signerAddresses[1], }); expect(tx).to.revertWith(RevertReason.TxNotFullyConfirmed); @@ -410,7 +405,7 @@ blockchainTests.resets('ZeroExGovernor', env => { const data = [hexRandom()]; const destinations = [receiver.address]; const results = await governorWrapper.submitTransactionAsync(data, destinations, signerAddresses[0]); - const tx = governor.executeTransaction.awaitTransactionSuccessAsync(results.txId, { + const tx = governor.executeTransaction(results.txId).awaitTransactionSuccessAsync({ from: signerAddresses[0], }); expect(tx).to.revertWith(RevertReason.TxNotFullyConfirmed); @@ -443,12 +438,9 @@ blockchainTests.resets('ZeroExGovernor', env => { const data = [hexRandom()]; const destinations = [receiver.address]; const newTimeLock = new BigNumber(DEFAULT_TIME_LOCK).dividedToIntegerBy(2); - await governor.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync( - true, - data[0].slice(0, 10), - receiver.address, - newTimeLock, - ); + await governor + .registerFunctionCallBypassWallet(true, data[0].slice(0, 10), receiver.address, newTimeLock) + .awaitTransactionSuccessAsync(); const results = await governorWrapper.submitConfirmAndExecuteTransactionAsync( data, destinations, @@ -461,12 +453,9 @@ blockchainTests.resets('ZeroExGovernor', env => { const data = [hexRandom()]; const destinations = [receiver.address]; const newTimeLock = constants.ZERO_AMOUNT; - await governor.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync( - true, - data[0].slice(0, 10), - receiver.address, - newTimeLock, - ); + await governor + .registerFunctionCallBypassWallet(true, data[0].slice(0, 10), receiver.address, newTimeLock) + .awaitTransactionSuccessAsync(); const results = await governorWrapper.submitConfirmAndExecuteTransactionAsync( data, destinations, @@ -479,12 +468,9 @@ blockchainTests.resets('ZeroExGovernor', env => { const data = [hexRandom()]; const destinations = [receiver.address]; const newTimeLock = new BigNumber(DEFAULT_TIME_LOCK).dividedToIntegerBy(2); - await governor.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync( - true, - data[0].slice(0, 10), - receiver.address, - newTimeLock, - ); + await governor + .registerFunctionCallBypassWallet(true, data[0].slice(0, 10), receiver.address, newTimeLock) + .awaitTransactionSuccessAsync(); const values = [INITIAL_BALANCE]; const results = await governorWrapper.submitConfirmAndExecuteTransactionAsync( data, @@ -529,12 +515,9 @@ blockchainTests.resets('ZeroExGovernor', env => { const data = [hexRandom(), hexRandom()]; const destinations = [receiver.address, receiver.address]; const newTimeLock = new BigNumber(DEFAULT_TIME_LOCK).dividedToIntegerBy(2); - await governor.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync( - true, - data[0].slice(0, 10), - receiver.address, - newTimeLock, - ); + await governor + .registerFunctionCallBypassWallet(true, data[0].slice(0, 10), receiver.address, newTimeLock) + .awaitTransactionSuccessAsync(); const results = await governorWrapper.submitConfirmAndExecuteTransactionAsync( data, destinations, @@ -547,12 +530,9 @@ blockchainTests.resets('ZeroExGovernor', env => { const data = [hexRandom(), hexRandom()]; const destinations = [receiver.address, receiver.address]; const newTimeLock = new BigNumber(DEFAULT_TIME_LOCK).dividedToIntegerBy(2); - await governor.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync( - true, - data[0].slice(0, 10), - receiver.address, - newTimeLock, - ); + await governor + .registerFunctionCallBypassWallet(true, data[0].slice(0, 10), receiver.address, newTimeLock) + .awaitTransactionSuccessAsync(); const tx = governorWrapper.submitConfirmAndExecuteTransactionAsync( data, destinations, @@ -629,7 +609,7 @@ blockchainTests.resets('ZeroExGovernor', env => { signerAddresses, DEFAULT_TIME_LOCK, ); - const tx = governor.executeTransaction.awaitTransactionSuccessAsync(results.txId); + const tx = governor.executeTransaction(results.txId).awaitTransactionSuccessAsync(); expect(tx).to.revertWith(RevertReason.TxAlreadyExecuted); }); it('should revert if the only call is unsuccessful', async () => { @@ -659,12 +639,14 @@ blockchainTests.resets('ZeroExGovernor', env => { it('should be able to call registerFunctionCall after the default timelock', async () => { const reg = createFunctionRegistration(1, 1, 1); const data = [ - governor.registerFunctionCall.getABIEncodedTransactionData( - true, - reg.functionSelectors[0], - reg.destinations[0], - reg.functionCallTimeLockSeconds[0], - ), + governor + .registerFunctionCall( + true, + reg.functionSelectors[0], + reg.destinations[0], + reg.functionCallTimeLockSeconds[0], + ) + .getABIEncodedTransactionData(), ]; const destinations = [governor.address]; const results = await governorWrapper.submitConfirmAndExecuteTransactionAsync( diff --git a/contracts/staking/test/actors/finalizer_actor.ts b/contracts/staking/test/actors/finalizer_actor.ts index 2d2e099b3c..08a95554e0 100644 --- a/contracts/staking/test/actors/finalizer_actor.ts +++ b/contracts/staking/test/actors/finalizer_actor.ts @@ -131,9 +131,9 @@ export class FinalizerActor extends BaseActor { for (const delegator of delegators) { let balance = new BigNumber(delegatorBalancesByPoolId[poolId][delegator] || 0); if (delegator === operator) { - balance = balance.plus(await computeRewardBalanceOfOperator.callAsync(poolId)); + balance = balance.plus(await computeRewardBalanceOfOperator(poolId).callAsync()); } else { - balance = balance.plus(await computeRewardBalanceOfDelegator.callAsync(poolId, delegator)); + balance = balance.plus(await computeRewardBalanceOfDelegator(poolId, delegator).callAsync()); } delegatorBalancesByPoolId[poolId][delegator] = balance; } @@ -150,10 +150,10 @@ export class FinalizerActor extends BaseActor { const delegators = delegatorsByPoolId[poolId]; delegatorBalancesByPoolId[poolId] = {}; for (const delegator of delegators) { - delegatorBalancesByPoolId[poolId][delegator] = (await getStakeDelegatedToPoolByOwner.callAsync( + delegatorBalancesByPoolId[poolId][delegator] = (await getStakeDelegatedToPoolByOwner( delegator, poolId, - )).currentEpochBalance; + ).callAsync()).currentEpochBalance; } } return delegatorBalancesByPoolId; @@ -208,9 +208,9 @@ export class FinalizerActor extends BaseActor { ): Promise { const operatorBalanceByPoolId: OperatorBalanceByPoolId = {}; for (const poolId of Object.keys(operatorByPoolId)) { - operatorBalanceByPoolId[poolId] = await this._stakingApiWrapper.wethContract.balanceOf.callAsync( - operatorByPoolId[poolId], - ); + operatorBalanceByPoolId[poolId] = await this._stakingApiWrapper.wethContract + .balanceOf(operatorByPoolId[poolId]) + .callAsync(); } return operatorBalanceByPoolId; } @@ -219,7 +219,7 @@ export class FinalizerActor extends BaseActor { const operatorShareByPoolId: OperatorShareByPoolId = {}; for (const poolId of poolIds) { operatorShareByPoolId[poolId] = new BigNumber( - (await this._stakingApiWrapper.stakingContract.getStakingPool.callAsync(poolId)).operatorShare, + (await this._stakingApiWrapper.stakingContract.getStakingPool(poolId).callAsync()).operatorShare, ); } return operatorShareByPoolId; @@ -228,9 +228,9 @@ export class FinalizerActor extends BaseActor { private async _getRewardBalanceByPoolIdAsync(poolIds: string[]): Promise { const rewardBalanceByPoolId: RewardBalanceByPoolId = {}; for (const poolId of poolIds) { - rewardBalanceByPoolId[poolId] = await this._stakingApiWrapper.stakingContract.rewardsByPoolId.callAsync( - poolId, - ); + rewardBalanceByPoolId[poolId] = await this._stakingApiWrapper.stakingContract + .rewardsByPoolId(poolId) + .callAsync(); } return rewardBalanceByPoolId; } @@ -238,7 +238,7 @@ export class FinalizerActor extends BaseActor { private async _getRewardByPoolIdAsync(poolIds: string[]): Promise { const activePools = await Promise.all( poolIds.map(async poolId => - this._stakingApiWrapper.stakingContract.getStakingPoolStatsThisEpoch.callAsync(poolId), + this._stakingApiWrapper.stakingContract.getStakingPoolStatsThisEpoch(poolId).callAsync(), ), ); const totalRewards = await this._stakingApiWrapper.utils.getAvailableRewardsBalanceAsync(); diff --git a/contracts/staking/test/actors/maker_actor.ts b/contracts/staking/test/actors/maker_actor.ts index 144aeee11b..f5331ae473 100644 --- a/contracts/staking/test/actors/maker_actor.ts +++ b/contracts/staking/test/actors/maker_actor.ts @@ -7,17 +7,16 @@ import { PoolOperatorActor } from './pool_operator_actor'; export class MakerActor extends PoolOperatorActor { public async joinStakingPoolAsMakerAsync(poolId: string, revertError?: RevertError): Promise { // add maker - const txReceiptPromise = this._stakingApiWrapper.stakingContract.joinStakingPoolAsMaker.awaitTransactionSuccessAsync( - poolId, - { from: this.getOwner() }, - ); + const txReceiptPromise = this._stakingApiWrapper.stakingContract + .joinStakingPoolAsMaker(poolId) + .awaitTransactionSuccessAsync({ from: this.getOwner() }); if (revertError !== undefined) { await expect(txReceiptPromise).to.revertWith(revertError); return; } await txReceiptPromise; // check the pool id of the maker - const poolIdOfMaker = await this._stakingApiWrapper.stakingContract.poolIdByMaker.callAsync(this.getOwner()); + const poolIdOfMaker = await this._stakingApiWrapper.stakingContract.poolIdByMaker(this.getOwner()).callAsync(); expect(poolIdOfMaker, 'pool id of maker').to.be.equal(poolId); } } diff --git a/contracts/staking/test/actors/pool_operator_actor.ts b/contracts/staking/test/actors/pool_operator_actor.ts index e7fd5f7e78..2bc1e124bc 100644 --- a/contracts/staking/test/actors/pool_operator_actor.ts +++ b/contracts/staking/test/actors/pool_operator_actor.ts @@ -22,12 +22,12 @@ export class PoolOperatorActor extends BaseActor { } const poolId = await poolIdPromise; // validate pool id - const lastPoolId = await this._stakingApiWrapper.stakingContract.lastPoolId.callAsync(); + const lastPoolId = await this._stakingApiWrapper.stakingContract.lastPoolId().callAsync(); expect(poolId, 'pool id').to.be.bignumber.equal(lastPoolId); if (addOperatorAsMaker) { // check the pool id of the operator - const poolIdOfMaker = await this._stakingApiWrapper.stakingContract.poolIdByMaker.callAsync(this._owner); + const poolIdOfMaker = await this._stakingApiWrapper.stakingContract.poolIdByMaker(this._owner).callAsync(); expect(poolIdOfMaker, 'pool id of maker').to.be.equal(poolId); } return poolId; @@ -38,18 +38,16 @@ export class PoolOperatorActor extends BaseActor { revertError?: RevertError, ): Promise { // decrease operator share - const txReceiptPromise = this._stakingApiWrapper.stakingContract.decreaseStakingPoolOperatorShare.awaitTransactionSuccessAsync( - poolId, - newOperatorShare, - { from: this._owner }, - ); + const txReceiptPromise = this._stakingApiWrapper.stakingContract + .decreaseStakingPoolOperatorShare(poolId, newOperatorShare) + .awaitTransactionSuccessAsync({ from: this._owner }); if (revertError !== undefined) { await expect(txReceiptPromise).to.revertWith(revertError); return; } await txReceiptPromise; // Check operator share - const pool = await this._stakingApiWrapper.stakingContract.getStakingPool.callAsync(poolId); + const pool = await this._stakingApiWrapper.stakingContract.getStakingPool(poolId).callAsync(); expect(pool.operatorShare, 'updated operator share').to.be.bignumber.equal(newOperatorShare); } } diff --git a/contracts/staking/test/actors/staker_actor.ts b/contracts/staking/test/actors/staker_actor.ts index 469f235730..7f5dee39f8 100644 --- a/contracts/staking/test/actors/staker_actor.ts +++ b/contracts/staking/test/actors/staker_actor.ts @@ -39,13 +39,12 @@ export class StakerActor extends BaseActor { const initZrxBalanceOfVault = await this._stakingApiWrapper.utils.getZrxTokenBalanceOfZrxVaultAsync(); const initBalances = await this._getBalancesAsync(); // move stake - const txReceiptPromise = this._stakingApiWrapper.stakingProxyContract.batchExecute.awaitTransactionSuccessAsync( - [ - this._stakingApiWrapper.stakingContract.stake.getABIEncodedTransactionData(amount), - this._stakingApiWrapper.stakingContract.moveStake.getABIEncodedTransactionData(from, to, amount), - ], - { from: this._owner }, - ); + const txReceiptPromise = this._stakingApiWrapper.stakingProxyContract + .batchExecute([ + this._stakingApiWrapper.stakingContract.stake(amount).getABIEncodedTransactionData(), + this._stakingApiWrapper.stakingContract.moveStake(from, to, amount).getABIEncodedTransactionData(), + ]) + .awaitTransactionSuccessAsync({ from: this._owner }); if (revertError !== undefined) { await expect(txReceiptPromise, 'expected revert error').to.revertWith(revertError); return; @@ -70,7 +69,7 @@ export class StakerActor extends BaseActor { const initZrxBalanceOfVault = await this._stakingApiWrapper.utils.getZrxTokenBalanceOfZrxVaultAsync(); const initBalances = await this._getBalancesAsync(); // deposit stake - const txReceiptPromise = this._stakingApiWrapper.stakingContract.stake.awaitTransactionSuccessAsync(amount, { + const txReceiptPromise = this._stakingApiWrapper.stakingContract.stake(amount).awaitTransactionSuccessAsync({ from: this._owner, }); if (revertError !== undefined) { @@ -93,7 +92,7 @@ export class StakerActor extends BaseActor { const initZrxBalanceOfVault = await this._stakingApiWrapper.utils.getZrxTokenBalanceOfZrxVaultAsync(); const initBalances = await this._getBalancesAsync(); // deposit stake - const txReceiptPromise = this._stakingApiWrapper.stakingContract.unstake.awaitTransactionSuccessAsync(amount, { + const txReceiptPromise = this._stakingApiWrapper.stakingContract.unstake(amount).awaitTransactionSuccessAsync({ from: this._owner, }); if (revertError !== undefined) { @@ -127,12 +126,9 @@ export class StakerActor extends BaseActor { // Calculate the expected outcome after the move. const expectedBalances = await this._calculateExpectedBalancesAfterMoveAsync(from, to, amount); // move stake - const txReceiptPromise = this._stakingApiWrapper.stakingContract.moveStake.awaitTransactionSuccessAsync( - from, - to, - amount, - { from: this._owner }, - ); + const txReceiptPromise = this._stakingApiWrapper.stakingContract + .moveStake(from, to, amount) + .awaitTransactionSuccessAsync({ from: this._owner }); if (revertError !== undefined) { await expect(txReceiptPromise).to.revertWith(revertError); return; @@ -155,10 +151,9 @@ export class StakerActor extends BaseActor { } public async withdrawDelegatorRewardsAsync(poolId: string, revertError?: RevertError): Promise { - const txReceiptPromise = this._stakingApiWrapper.stakingContract.withdrawDelegatorRewards.awaitTransactionSuccessAsync( - poolId, - { from: this._owner }, - ); + const txReceiptPromise = this._stakingApiWrapper.stakingContract + .withdrawDelegatorRewards(poolId) + .awaitTransactionSuccessAsync({ from: this._owner }); if (revertError !== undefined) { await expect(txReceiptPromise, 'expected revert error').to.revertWith(revertError); return; @@ -196,36 +191,33 @@ export class StakerActor extends BaseActor { } private async _getBalancesAsync(): Promise { const balances: StakeBalances = { - currentEpoch: await this._stakingApiWrapper.stakingContract.currentEpoch.callAsync(), - zrxBalance: await this._stakingApiWrapper.zrxTokenContract.balanceOf.callAsync(this._owner), - stakeBalance: await this._stakingApiWrapper.stakingContract.getTotalStake.callAsync(this._owner), - stakeBalanceInVault: await this._stakingApiWrapper.zrxVaultContract.balanceOf.callAsync(this._owner), - undelegatedStakeBalance: await this._stakingApiWrapper.stakingContract.getOwnerStakeByStatus.callAsync( - this._owner, - StakeStatus.Undelegated, - ), - delegatedStakeBalance: await this._stakingApiWrapper.stakingContract.getOwnerStakeByStatus.callAsync( - this._owner, - StakeStatus.Delegated, - ), - globalUndelegatedStakeBalance: await this._stakingApiWrapper.stakingContract.getGlobalStakeByStatus.callAsync( - StakeStatus.Undelegated, - ), - globalDelegatedStakeBalance: await this._stakingApiWrapper.stakingContract.getGlobalStakeByStatus.callAsync( - StakeStatus.Delegated, - ), + currentEpoch: await this._stakingApiWrapper.stakingContract.currentEpoch().callAsync(), + zrxBalance: await this._stakingApiWrapper.zrxTokenContract.balanceOf(this._owner).callAsync(), + stakeBalance: await this._stakingApiWrapper.stakingContract.getTotalStake(this._owner).callAsync(), + stakeBalanceInVault: await this._stakingApiWrapper.zrxVaultContract.balanceOf(this._owner).callAsync(), + undelegatedStakeBalance: await this._stakingApiWrapper.stakingContract + .getOwnerStakeByStatus(this._owner, StakeStatus.Undelegated) + .callAsync(), + delegatedStakeBalance: await this._stakingApiWrapper.stakingContract + .getOwnerStakeByStatus(this._owner, StakeStatus.Delegated) + .callAsync(), + globalUndelegatedStakeBalance: await this._stakingApiWrapper.stakingContract + .getGlobalStakeByStatus(StakeStatus.Undelegated) + .callAsync(), + globalDelegatedStakeBalance: await this._stakingApiWrapper.stakingContract + .getGlobalStakeByStatus(StakeStatus.Delegated) + .callAsync(), delegatedStakeByPool: {}, totalDelegatedStakeByPool: {}, }; // lookup for each pool for (const poolId of this._poolIds) { - const delegatedStakeBalanceByPool = await this._stakingApiWrapper.stakingContract.getStakeDelegatedToPoolByOwner.callAsync( - this._owner, - poolId, - ); - const totalDelegatedStakeBalanceByPool = await this._stakingApiWrapper.stakingContract.getTotalStakeDelegatedToPool.callAsync( - poolId, - ); + const delegatedStakeBalanceByPool = await this._stakingApiWrapper.stakingContract + .getStakeDelegatedToPoolByOwner(this._owner, poolId) + .callAsync(); + const totalDelegatedStakeBalanceByPool = await this._stakingApiWrapper.stakingContract + .getTotalStakeDelegatedToPool(poolId) + .callAsync(); balances.delegatedStakeByPool[poolId] = delegatedStakeBalanceByPool; balances.totalDelegatedStakeByPool[poolId] = totalDelegatedStakeBalanceByPool; } diff --git a/contracts/staking/test/epoch_test.ts b/contracts/staking/test/epoch_test.ts index ab5d470f34..03191b65bc 100644 --- a/contracts/staking/test/epoch_test.ts +++ b/contracts/staking/test/epoch_test.ts @@ -32,14 +32,14 @@ blockchainTests('Epochs', env => { ///// 2/3 Validate Initial Epoch & TimeLock Period ///// { // epoch - const currentEpoch = await stakingApiWrapper.stakingContract.currentEpoch.callAsync(); + const currentEpoch = await stakingApiWrapper.stakingContract.currentEpoch().callAsync(); expect(currentEpoch).to.be.bignumber.equal(stakingConstants.INITIAL_EPOCH); } ///// 3/3 Increment Epoch (TimeLock Should Not Increment) ///// await stakingApiWrapper.utils.skipToNextEpochAndFinalizeAsync(); { // epoch - const currentEpoch = await stakingApiWrapper.stakingContract.currentEpoch.callAsync(); + const currentEpoch = await stakingApiWrapper.stakingContract.currentEpoch().callAsync(); expect(currentEpoch).to.be.bignumber.equal(stakingConstants.INITIAL_EPOCH.plus(1)); } }); diff --git a/contracts/staking/test/migration_test.ts b/contracts/staking/test/migration_test.ts index d6f9b50f2a..43e4e2475d 100644 --- a/contracts/staking/test/migration_test.ts +++ b/contracts/staking/test/migration_test.ts @@ -28,7 +28,7 @@ blockchainTests('Migration tests', env => { env.txDefaults, artifacts, ); - await stakingContract.addAuthorizedAddress.awaitTransactionSuccessAsync(authorizedAddress); + await stakingContract.addAuthorizedAddress(authorizedAddress).awaitTransactionSuccessAsync(); }); describe('StakingProxy', () => { @@ -45,7 +45,7 @@ blockchainTests('Migration tests', env => { artifacts, stakingContractAddress || constants.NULL_ADDRESS, ); - await proxyContract.addAuthorizedAddress.awaitTransactionSuccessAsync(authorizedAddress); + await proxyContract.addAuthorizedAddress(authorizedAddress).awaitTransactionSuccessAsync(); return proxyContract; } @@ -57,7 +57,7 @@ blockchainTests('Migration tests', env => { env.txDefaults, artifacts, ); - revertAddress = await initTargetContract.SHOULD_REVERT_ADDRESS.callAsync(); + revertAddress = await initTargetContract.SHOULD_REVERT_ADDRESS().callAsync(); }); async function enableInitRevertsAsync(): Promise { @@ -75,12 +75,12 @@ blockchainTests('Migration tests', env => { } async function assertInitStateAsync(proxyContract: TestStakingProxyContract): Promise { - const [senderAddress, thisAddress] = await initTargetContract.getInitState.callAsync({ + const [senderAddress, thisAddress] = await initTargetContract.getInitState().callAsync({ to: proxyContract.address, }); expect(senderAddress).to.eq(authorizedAddress); expect(thisAddress).to.eq(proxyContract.address); - const attachedAddress = await proxyContract.stakingContract.callAsync(); + const attachedAddress = await proxyContract.stakingContract().callAsync(); expect(attachedAddress).to.eq(initTargetContract.address); } @@ -115,7 +115,7 @@ blockchainTests('Migration tests', env => { env.provider, env.txDefaults, ); - const params = await stakingProxyContract.getParams.callAsync(); + const params = await stakingProxyContract.getParams().callAsync(); expect(params[0]).to.bignumber.eq(stakingConstants.DEFAULT_PARAMS.epochDurationInSeconds); expect(params[1]).to.bignumber.eq(stakingConstants.DEFAULT_PARAMS.rewardDelegatedStakeWeight); expect(params[2]).to.bignumber.eq(stakingConstants.DEFAULT_PARAMS.minimumPoolStake); @@ -132,25 +132,24 @@ blockchainTests('Migration tests', env => { }); it('throws if not called by an authorized address', async () => { - const tx = proxyContract.attachStakingContract.awaitTransactionSuccessAsync( - initTargetContract.address, - { + const tx = proxyContract + .attachStakingContract(initTargetContract.address) + .awaitTransactionSuccessAsync({ from: notAuthorizedAddress, - }, - ); + }); const expectedError = new AuthorizableRevertErrors.SenderNotAuthorizedError(notAuthorizedAddress); return expect(tx).to.revertWith(expectedError); }); it('calls init() and attaches the contract', async () => { - await proxyContract.attachStakingContract.awaitTransactionSuccessAsync(initTargetContract.address); + await proxyContract.attachStakingContract(initTargetContract.address).awaitTransactionSuccessAsync(); await assertInitStateAsync(proxyContract); }); it('emits a `StakingContractAttachedToProxy` event', async () => { - const receipt = await proxyContract.attachStakingContract.awaitTransactionSuccessAsync( - initTargetContract.address, - ); + const receipt = await proxyContract + .attachStakingContract(initTargetContract.address) + .awaitTransactionSuccessAsync(); const logsArgs = filterLogsToArguments( receipt.logs, 'StakingContractAttachedToProxy', @@ -164,12 +163,14 @@ blockchainTests('Migration tests', env => { it('reverts if init() reverts', async () => { await enableInitRevertsAsync(); - const tx = proxyContract.attachStakingContract.awaitTransactionSuccessAsync(initTargetContract.address); + const tx = proxyContract + .attachStakingContract(initTargetContract.address) + .awaitTransactionSuccessAsync(); return expect(tx).to.revertWith(INIT_REVERT_ERROR); }); it('reverts if assertValidStorageParams() fails', async () => { - const tx = proxyContract.attachStakingContract.awaitTransactionSuccessAsync(revertAddress); + const tx = proxyContract.attachStakingContract(revertAddress).awaitTransactionSuccessAsync(); return expect(tx).to.revertWith(STORAGE_PARAMS_REVERT_ERROR); }); }); @@ -177,8 +178,8 @@ blockchainTests('Migration tests', env => { blockchainTests.resets('upgrades', async () => { it('modifies prior state', async () => { const proxyContract = await deployStakingProxyAsync(initTargetContract.address); - await proxyContract.attachStakingContract.awaitTransactionSuccessAsync(initTargetContract.address); - const initCounter = await initTargetContract.getInitCounter.callAsync({ to: proxyContract.address }); + await proxyContract.attachStakingContract(initTargetContract.address).awaitTransactionSuccessAsync(); + const initCounter = await initTargetContract.getInitCounter().callAsync({ to: proxyContract.address }); expect(initCounter).to.bignumber.eq(2); }); }); @@ -186,7 +187,7 @@ blockchainTests('Migration tests', env => { blockchainTests.resets('Staking.init()', async () => { it('throws if not called by an authorized address', async () => { - const tx = stakingContract.init.awaitTransactionSuccessAsync({ + const tx = stakingContract.init().awaitTransactionSuccessAsync({ from: notAuthorizedAddress, }); const expectedError = new AuthorizableRevertErrors.SenderNotAuthorizedError(notAuthorizedAddress); @@ -194,8 +195,8 @@ blockchainTests('Migration tests', env => { }); it('throws if already intitialized', async () => { - await stakingContract.init.awaitTransactionSuccessAsync(); - const tx = stakingContract.init.awaitTransactionSuccessAsync(); + await stakingContract.init().awaitTransactionSuccessAsync(); + const tx = stakingContract.init().awaitTransactionSuccessAsync(); const expectedError = new StakingRevertErrors.InitializationError(); return expect(tx).to.revertWith(expectedError); }); @@ -215,96 +216,116 @@ blockchainTests('Migration tests', env => { }); it('succeeds if all params are valid', async () => { - const tx = proxyContract.setAndAssertParams.awaitTransactionSuccessAsync(stakingConstants.DEFAULT_PARAMS); + const tx = proxyContract.setAndAssertParams(stakingConstants.DEFAULT_PARAMS).awaitTransactionSuccessAsync(); expect(tx).to.be.fulfilled(''); }); it('reverts if epoch duration is < 5 days', async () => { - const tx = proxyContract.setAndAssertParams.awaitTransactionSuccessAsync({ - ...stakingConstants.DEFAULT_PARAMS, - epochDurationInSeconds: fiveDays.minus(1), - }); + const tx = proxyContract + .setAndAssertParams({ + ...stakingConstants.DEFAULT_PARAMS, + epochDurationInSeconds: fiveDays.minus(1), + }) + .awaitTransactionSuccessAsync(); const expectedError = new StakingRevertErrors.InvalidParamValueError( StakingRevertErrors.InvalidParamValueErrorCodes.InvalidEpochDuration, ); return expect(tx).to.revertWith(expectedError); }); it('reverts if epoch duration is > 30 days', async () => { - const tx = proxyContract.setAndAssertParams.awaitTransactionSuccessAsync({ - ...stakingConstants.DEFAULT_PARAMS, - epochDurationInSeconds: thirtyDays.plus(1), - }); + const tx = proxyContract + .setAndAssertParams({ + ...stakingConstants.DEFAULT_PARAMS, + epochDurationInSeconds: thirtyDays.plus(1), + }) + .awaitTransactionSuccessAsync(); const expectedError = new StakingRevertErrors.InvalidParamValueError( StakingRevertErrors.InvalidParamValueErrorCodes.InvalidEpochDuration, ); return expect(tx).to.revertWith(expectedError); }); it('succeeds if epoch duration is 5 days', async () => { - const tx = proxyContract.setAndAssertParams.awaitTransactionSuccessAsync({ - ...stakingConstants.DEFAULT_PARAMS, - epochDurationInSeconds: fiveDays, - }); + const tx = proxyContract + .setAndAssertParams({ + ...stakingConstants.DEFAULT_PARAMS, + epochDurationInSeconds: fiveDays, + }) + .awaitTransactionSuccessAsync(); return expect(tx).to.be.fulfilled(''); }); it('succeeds if epoch duration is 30 days', async () => { - const tx = proxyContract.setAndAssertParams.awaitTransactionSuccessAsync({ - ...stakingConstants.DEFAULT_PARAMS, - epochDurationInSeconds: thirtyDays, - }); + const tx = proxyContract + .setAndAssertParams({ + ...stakingConstants.DEFAULT_PARAMS, + epochDurationInSeconds: thirtyDays, + }) + .awaitTransactionSuccessAsync(); return expect(tx).to.be.fulfilled(''); }); it('reverts if alpha denominator is 0', async () => { - const tx = proxyContract.setAndAssertParams.awaitTransactionSuccessAsync({ - ...stakingConstants.DEFAULT_PARAMS, - cobbDouglasAlphaDenominator: constants.ZERO_AMOUNT, - }); + const tx = proxyContract + .setAndAssertParams({ + ...stakingConstants.DEFAULT_PARAMS, + cobbDouglasAlphaDenominator: constants.ZERO_AMOUNT, + }) + .awaitTransactionSuccessAsync(); const expectedError = new StakingRevertErrors.InvalidParamValueError( StakingRevertErrors.InvalidParamValueErrorCodes.InvalidCobbDouglasAlpha, ); return expect(tx).to.revertWith(expectedError); }); it('reverts if alpha > 1', async () => { - const tx = proxyContract.setAndAssertParams.awaitTransactionSuccessAsync({ - ...stakingConstants.DEFAULT_PARAMS, - cobbDouglasAlphaNumerator: new BigNumber(101), - cobbDouglasAlphaDenominator: new BigNumber(100), - }); + const tx = proxyContract + .setAndAssertParams({ + ...stakingConstants.DEFAULT_PARAMS, + cobbDouglasAlphaNumerator: new BigNumber(101), + cobbDouglasAlphaDenominator: new BigNumber(100), + }) + .awaitTransactionSuccessAsync(); const expectedError = new StakingRevertErrors.InvalidParamValueError( StakingRevertErrors.InvalidParamValueErrorCodes.InvalidCobbDouglasAlpha, ); return expect(tx).to.revertWith(expectedError); }); it('succeeds if alpha == 1', async () => { - const tx = proxyContract.setAndAssertParams.awaitTransactionSuccessAsync({ - ...stakingConstants.DEFAULT_PARAMS, - cobbDouglasAlphaNumerator: new BigNumber(1), - cobbDouglasAlphaDenominator: new BigNumber(1), - }); + const tx = proxyContract + .setAndAssertParams({ + ...stakingConstants.DEFAULT_PARAMS, + cobbDouglasAlphaNumerator: new BigNumber(1), + cobbDouglasAlphaDenominator: new BigNumber(1), + }) + .awaitTransactionSuccessAsync(); return expect(tx).to.be.fulfilled(''); }); it('succeeds if alpha == 0', async () => { - const tx = proxyContract.setAndAssertParams.awaitTransactionSuccessAsync({ - ...stakingConstants.DEFAULT_PARAMS, - cobbDouglasAlphaNumerator: constants.ZERO_AMOUNT, - cobbDouglasAlphaDenominator: new BigNumber(1), - }); + const tx = proxyContract + .setAndAssertParams({ + ...stakingConstants.DEFAULT_PARAMS, + cobbDouglasAlphaNumerator: constants.ZERO_AMOUNT, + cobbDouglasAlphaDenominator: new BigNumber(1), + }) + .awaitTransactionSuccessAsync(); return expect(tx).to.be.fulfilled(''); }); it('reverts if delegation weight is > 100%', async () => { - const tx = proxyContract.setAndAssertParams.awaitTransactionSuccessAsync({ - ...stakingConstants.DEFAULT_PARAMS, - rewardDelegatedStakeWeight: new BigNumber(stakingConstants.PPM).plus(1), - }); + const tx = proxyContract + .setAndAssertParams({ + ...stakingConstants.DEFAULT_PARAMS, + rewardDelegatedStakeWeight: new BigNumber(stakingConstants.PPM).plus(1), + }) + .awaitTransactionSuccessAsync(); const expectedError = new StakingRevertErrors.InvalidParamValueError( StakingRevertErrors.InvalidParamValueErrorCodes.InvalidRewardDelegatedStakeWeight, ); return expect(tx).to.revertWith(expectedError); }); it('succeeds if delegation weight is 100%', async () => { - const tx = proxyContract.setAndAssertParams.awaitTransactionSuccessAsync({ - ...stakingConstants.DEFAULT_PARAMS, - rewardDelegatedStakeWeight: new BigNumber(stakingConstants.PPM), - }); + const tx = proxyContract + .setAndAssertParams({ + ...stakingConstants.DEFAULT_PARAMS, + rewardDelegatedStakeWeight: new BigNumber(stakingConstants.PPM), + }) + .awaitTransactionSuccessAsync(); return expect(tx).to.be.fulfilled(''); }); }); diff --git a/contracts/staking/test/pools_test.ts b/contracts/staking/test/pools_test.ts index 7dc69c08c8..7e0c5fe944 100644 --- a/contracts/staking/test/pools_test.ts +++ b/contracts/staking/test/pools_test.ts @@ -40,7 +40,7 @@ blockchainTests('Staking Pool Management', env => { const poolId = await poolOperator.createStakingPoolAsync(operatorShare, false); expect(poolId).to.be.equal(stakingConstants.INITIAL_POOL_ID); // check that the next pool id was incremented - const lastPoolId = await stakingApiWrapper.stakingContract.lastPoolId.callAsync(); + const lastPoolId = await stakingApiWrapper.stakingContract.lastPoolId().callAsync(); expect(lastPoolId).to.be.equal(stakingConstants.INITIAL_POOL_ID); }); it('Should successfully create several staking pools, as long as the operator is only a maker in one', async () => { @@ -77,7 +77,7 @@ blockchainTests('Staking Pool Management', env => { const poolId = await poolOperator.createStakingPoolAsync(operatorShare, true); expect(poolId).to.be.equal(stakingConstants.INITIAL_POOL_ID); // check that the next pool id was incremented - const lastPoolId = await stakingApiWrapper.stakingContract.lastPoolId.callAsync(); + const lastPoolId = await stakingApiWrapper.stakingContract.lastPoolId().callAsync(); expect(lastPoolId).to.be.equal(stakingConstants.INITIAL_POOL_ID); }); it('Should throw if operatorShare is > PPM_DENOMINATOR', async () => { diff --git a/contracts/staking/test/rewards_test.ts b/contracts/staking/test/rewards_test.ts index 0f0c4f5172..2974a53782 100644 --- a/contracts/staking/test/rewards_test.ts +++ b/contracts/staking/test/rewards_test.ts @@ -58,7 +58,7 @@ blockchainTests.resets('Testing Rewards', env => { poolOperatorStaker = new StakerActor(poolOperator.getOwner(), stakingApiWrapper); await poolOperatorStaker.stakeWithPoolAsync(poolId, new BigNumber(2)); // set exchange address - await stakingApiWrapper.stakingContract.addExchangeAddress.awaitTransactionSuccessAsync(exchangeAddress); + await stakingApiWrapper.stakingContract.addExchangeAddress(exchangeAddress).awaitTransactionSuccessAsync(); // associate operators for tracking in Finalizer const operatorByPoolId: OperatorByPoolId = {}; operatorByPoolId[poolId] = poolOperator.getOwner(); @@ -117,21 +117,19 @@ blockchainTests.resets('Testing Rewards', env => { }; const finalEndBalancesAsArray = await Promise.all([ // staker 1 - stakingApiWrapper.stakingContract.computeRewardBalanceOfDelegator.callAsync( - poolId, - stakers[0].getOwner(), - ), - stakingApiWrapper.wethContract.balanceOf.callAsync(stakers[0].getOwner()), + stakingApiWrapper.stakingContract + .computeRewardBalanceOfDelegator(poolId, stakers[0].getOwner()) + .callAsync(), + stakingApiWrapper.wethContract.balanceOf(stakers[0].getOwner()).callAsync(), // staker 2 - stakingApiWrapper.stakingContract.computeRewardBalanceOfDelegator.callAsync( - poolId, - stakers[1].getOwner(), - ), - stakingApiWrapper.wethContract.balanceOf.callAsync(stakers[1].getOwner()), + stakingApiWrapper.stakingContract + .computeRewardBalanceOfDelegator(poolId, stakers[1].getOwner()) + .callAsync(), + stakingApiWrapper.wethContract.balanceOf(stakers[1].getOwner()).callAsync(), // operator - stakingApiWrapper.wethContract.balanceOf.callAsync(poolOperator.getOwner()), + stakingApiWrapper.wethContract.balanceOf(poolOperator.getOwner()).callAsync(), // undivided balance in reward pool - stakingApiWrapper.stakingContract.rewardsByPoolId.callAsync(poolId), + stakingApiWrapper.stakingContract.rewardsByPoolId(poolId).callAsync(), ]); expect(finalEndBalancesAsArray[0], 'stakerRewardBalance_1').to.be.bignumber.equal( expectedEndBalances.stakerRewardBalance_1, @@ -155,12 +153,9 @@ blockchainTests.resets('Testing Rewards', env => { const payProtocolFeeAndFinalize = async (_fee?: BigNumber) => { const fee = _fee !== undefined ? _fee : constants.ZERO_AMOUNT; if (!fee.eq(constants.ZERO_AMOUNT)) { - await stakingApiWrapper.stakingContract.payProtocolFee.awaitTransactionSuccessAsync( - poolOperator.getOwner(), - takerAddress, - fee, - { from: exchangeAddress, value: fee }, - ); + await stakingApiWrapper.stakingContract + .payProtocolFee(poolOperator.getOwner(), takerAddress, fee) + .awaitTransactionSuccessAsync({ from: exchangeAddress, value: fee }); } await finalizer.finalizeAsync(); }; @@ -168,7 +163,7 @@ blockchainTests.resets('Testing Rewards', env => { // sanity balances - all zero await validateEndBalances({}); }); - it('Reward balance should be zero if not delegated, when epoch is greater than 0', async () => { + it.only('Reward balance should be zero if not delegated, when epoch is greater than 0', async () => { await payProtocolFeeAndFinalize(); // sanity balances - all zero await validateEndBalances({}); @@ -574,7 +569,7 @@ blockchainTests.resets('Testing Rewards', env => { await payProtocolFeeAndFinalize(); // this should go to the delegator await payProtocolFeeAndFinalize(rewardForDelegator); - await stakingApiWrapper.stakingContract.withdrawDelegatorRewards.awaitTransactionSuccessAsync(poolId, { + await stakingApiWrapper.stakingContract.withdrawDelegatorRewards(poolId).awaitTransactionSuccessAsync({ from: stakers[0].getOwner(), }); // sanity check final balances @@ -594,18 +589,15 @@ blockchainTests.resets('Testing Rewards', env => { new StakeInfo(StakeStatus.Delegated, poolId), stakeAmount, ); - await stakingApiWrapper.stakingContract.payProtocolFee.awaitTransactionSuccessAsync( - poolOperator.getOwner(), - takerAddress, - rewardForDelegator, - { from: exchangeAddress, value: rewardForDelegator }, - ); - const currentEpoch = await stakingApiWrapper.stakingContract.currentEpoch.callAsync(); + await stakingApiWrapper.stakingContract + .payProtocolFee(poolOperator.getOwner(), takerAddress, rewardForDelegator) + .awaitTransactionSuccessAsync({ from: exchangeAddress, value: rewardForDelegator }); + const currentEpoch = await stakingApiWrapper.stakingContract.currentEpoch().callAsync(); await stakingApiWrapper.utils.fastForwardToNextEpochAsync(); await stakingApiWrapper.utils.endEpochAsync(); const expectedError = new StakingRevertErrors.PoolNotFinalizedError(poolId, currentEpoch); expect( - stakingApiWrapper.stakingContract.withdrawDelegatorRewards.awaitTransactionSuccessAsync(poolId, { + stakingApiWrapper.stakingContract.withdrawDelegatorRewards(poolId).awaitTransactionSuccessAsync({ from: stakers[0].getOwner(), }), ).to.revertWith(expectedError); @@ -688,16 +680,18 @@ blockchainTests.resets('Testing Rewards', env => { const sneakyStakerExpectedWethBalance = expectedStakerRewards[0]; await sneakyStaker.withdrawDelegatorRewardsAsync(poolId); // Should have been credited the correct amount of rewards. - let sneakyStakerWethBalance = await stakingApiWrapper.wethContract.balanceOf.callAsync( - sneakyStaker.getOwner(), - ); + let sneakyStakerWethBalance = await stakingApiWrapper.wethContract + .balanceOf(sneakyStaker.getOwner()) + .callAsync(); expect(sneakyStakerWethBalance, 'WETH balance after first undelegate').to.bignumber.eq( sneakyStakerExpectedWethBalance, ); // Now he'll try to do it again to see if he gets credited twice. await sneakyStaker.withdrawDelegatorRewardsAsync(poolId); /// The total amount credited should remain the same. - sneakyStakerWethBalance = await stakingApiWrapper.wethContract.balanceOf.callAsync(sneakyStaker.getOwner()); + sneakyStakerWethBalance = await stakingApiWrapper.wethContract + .balanceOf(sneakyStaker.getOwner()) + .callAsync(); expect(sneakyStakerWethBalance, 'WETH balance after second undelegate').to.bignumber.eq( sneakyStakerExpectedWethBalance, ); diff --git a/contracts/staking/test/stake_test.ts b/contracts/staking/test/stake_test.ts index 065178d80a..806d57a2a1 100644 --- a/contracts/staking/test/stake_test.ts +++ b/contracts/staking/test/stake_test.ts @@ -44,7 +44,7 @@ blockchainTests.resets('Stake Statuses', env => { await stakingApiWrapper.utils.createStakingPoolAsync(poolOperator, 4, false), await stakingApiWrapper.utils.createStakingPoolAsync(poolOperator, 5, false), ]); - const lastPoolId = await stakingApiWrapper.stakingContract.lastPoolId.callAsync(); + const lastPoolId = await stakingApiWrapper.stakingContract.lastPoolId().callAsync(); unusedPoolId = `0x${new BigNumber(lastPoolId) .plus(1) .toString(16) diff --git a/contracts/staking/test/unit_tests/delegator_reward_test.ts b/contracts/staking/test/unit_tests/delegator_reward_test.ts index 58e4855e20..a031ff2e57 100644 --- a/contracts/staking/test/unit_tests/delegator_reward_test.ts +++ b/contracts/staking/test/unit_tests/delegator_reward_test.ts @@ -56,13 +56,15 @@ blockchainTests.resets('Delegator rewards unit tests', env => { }; // Generate a deterministic operator address based on the poolId. _opts.operator = poolIdToOperator(_opts.poolId); - await testContract.syncPoolRewards.awaitTransactionSuccessAsync( - _opts.poolId, - _opts.operator, - new BigNumber(_opts.operatorReward), - new BigNumber(_opts.membersReward), - new BigNumber(_opts.membersStake), - ); + await testContract + .syncPoolRewards( + _opts.poolId, + _opts.operator, + new BigNumber(_opts.operatorReward), + new BigNumber(_opts.membersReward), + new BigNumber(_opts.membersStake), + ) + .awaitTransactionSuccessAsync(); // Because the operator share is implicitly defined by the member and // operator reward, and is stored as a uint32, there will be precision // loss when the reward is combined then split again in the contracts. @@ -86,13 +88,15 @@ blockchainTests.resets('Delegator rewards unit tests', env => { }; // Generate a deterministic operator address based on the poolId. _opts.operator = poolIdToOperator(_opts.poolId); - await testContract.setUnfinalizedPoolReward.awaitTransactionSuccessAsync( - _opts.poolId, - _opts.operator, - new BigNumber(_opts.operatorReward), - new BigNumber(_opts.membersReward), - new BigNumber(_opts.membersStake), - ); + await testContract + .setUnfinalizedPoolReward( + _opts.poolId, + _opts.operator, + new BigNumber(_opts.operatorReward), + new BigNumber(_opts.membersReward), + new BigNumber(_opts.membersStake), + ) + .awaitTransactionSuccessAsync(); // Because the operator share is implicitly defined by the member and // operator reward, and is stored as a uint32, there will be precision // loss when the reward is combined then split again in the contracts. @@ -149,7 +153,7 @@ blockchainTests.resets('Delegator rewards unit tests', env => { ...opts, }; const fn = now ? testContract.delegateStakeNow : testContract.delegateStake; - const receipt = await fn.awaitTransactionSuccessAsync(_opts.delegator, poolId, new BigNumber(_opts.stake)); + const receipt = await fn(_opts.delegator, poolId, new BigNumber(_opts.stake)).awaitTransactionSuccessAsync(); const delegatorTransfers = getTransfersFromLogs(receipt.logs, _opts.delegator); return { ..._opts, @@ -164,9 +168,9 @@ blockchainTests.resets('Delegator rewards unit tests', env => { ): Promise> { const _stake = new BigNumber( stake || - (await testContract.getStakeDelegatedToPoolByOwner.callAsync(delegator, poolId)).currentEpochBalance, + (await testContract.getStakeDelegatedToPoolByOwner(delegator, poolId).callAsync()).currentEpochBalance, ); - const receipt = await testContract.undelegateStake.awaitTransactionSuccessAsync(delegator, poolId, _stake); + const receipt = await testContract.undelegateStake(delegator, poolId, _stake).awaitTransactionSuccessAsync(); const delegatorTransfers = getTransfersFromLogs(receipt.logs, delegator); return { stake: _stake, @@ -189,17 +193,17 @@ blockchainTests.resets('Delegator rewards unit tests', env => { } async function advanceEpochAsync(): Promise { - await testContract.advanceEpoch.awaitTransactionSuccessAsync(); - const epoch = await testContract.currentEpoch.callAsync(); + await testContract.advanceEpoch().awaitTransactionSuccessAsync(); + const epoch = await testContract.currentEpoch().callAsync(); return epoch.toNumber(); } async function getDelegatorRewardBalanceAsync(poolId: string, delegator: string): Promise { - return testContract.computeRewardBalanceOfDelegator.callAsync(poolId, delegator); + return testContract.computeRewardBalanceOfDelegator(poolId, delegator).callAsync(); } async function getOperatorRewardBalanceAsync(poolId: string): Promise { - return testContract.computeRewardBalanceOfOperator.callAsync(poolId); + return testContract.computeRewardBalanceOfOperator(poolId).callAsync(); } async function touchStakeAsync(poolId: string, delegator: string): Promise> { @@ -207,7 +211,7 @@ blockchainTests.resets('Delegator rewards unit tests', env => { } async function finalizePoolAsync(poolId: string): Promise> { - const receipt = await testContract.finalizePool.awaitTransactionSuccessAsync(poolId); + const receipt = await testContract.finalizePool(poolId).awaitTransactionSuccessAsync(); const delegatorTransfers = getTransfersFromLogs(receipt.logs, poolId); return { delegatorTransfers, diff --git a/contracts/staking/test/unit_tests/exchange_test.ts b/contracts/staking/test/unit_tests/exchange_test.ts index 6f21999d87..8dc9e9532e 100644 --- a/contracts/staking/test/unit_tests/exchange_test.ts +++ b/contracts/staking/test/unit_tests/exchange_test.ts @@ -38,22 +38,22 @@ blockchainTests.resets('Exchange Unit Tests', env => { ); // Register the exchange. - await exchangeManager.setValidExchange.awaitTransactionSuccessAsync(exchange); + await exchangeManager.setValidExchange(exchange).awaitTransactionSuccessAsync(); // Register an authority. - await exchangeManager.addAuthorizedAddress.awaitTransactionSuccessAsync(authority, { from: owner }); + await exchangeManager.addAuthorizedAddress(authority).awaitTransactionSuccessAsync({ from: owner }); }); describe('onlyExchange', () => { it('should revert if called by an unregistered exchange', async () => { const expectedError = new StakingRevertErrors.OnlyCallableByExchangeError(nonExchange); - return expect(exchangeManager.onlyExchangeFunction.callAsync({ from: nonExchange })).to.revertWith( + return expect(exchangeManager.onlyExchangeFunction().callAsync({ from: nonExchange })).to.revertWith( expectedError, ); }); it('should succeed if called by a registered exchange', async () => { - const didSucceed = await exchangeManager.onlyExchangeFunction.callAsync({ from: exchange }); + const didSucceed = await exchangeManager.onlyExchangeFunction().callAsync({ from: exchange }); expect(didSucceed).to.be.true(); }); }); @@ -89,7 +89,7 @@ blockchainTests.resets('Exchange Unit Tests', env => { describe('addExchangeAddress', () => { it('should revert if called by an unauthorized address', async () => { const expectedError = new AuthorizableRevertErrors.SenderNotAuthorizedError(nonAuthority); - const tx = exchangeManager.addExchangeAddress.awaitTransactionSuccessAsync(nonExchange, { + const tx = exchangeManager.addExchangeAddress(nonExchange).awaitTransactionSuccessAsync({ from: nonAuthority, }); return expect(tx).to.revertWith(expectedError); @@ -97,7 +97,7 @@ blockchainTests.resets('Exchange Unit Tests', env => { it('should revert when adding an exchange if called by the (non-authorized) owner', async () => { const expectedError = new AuthorizableRevertErrors.SenderNotAuthorizedError(owner); - const tx = exchangeManager.addExchangeAddress.awaitTransactionSuccessAsync(nonExchange, { + const tx = exchangeManager.addExchangeAddress(nonExchange).awaitTransactionSuccessAsync({ from: owner, }); return expect(tx).to.revertWith(expectedError); @@ -105,7 +105,7 @@ blockchainTests.resets('Exchange Unit Tests', env => { it('should successfully add an exchange if called by an authorized address', async () => { // Register a new exchange. - const receipt = await exchangeManager.addExchangeAddress.awaitTransactionSuccessAsync(nonExchange, { + const receipt = await exchangeManager.addExchangeAddress(nonExchange).awaitTransactionSuccessAsync({ from: authority, }); @@ -113,7 +113,7 @@ blockchainTests.resets('Exchange Unit Tests', env => { verifyExchangeManagerEvent(ExchangeManagerEventType.ExchangeAdded, nonExchange, receipt); // Ensure that the exchange was successfully registered. - const isValidExchange = await exchangeManager.validExchanges.callAsync(nonExchange); + const isValidExchange = await exchangeManager.validExchanges(nonExchange).callAsync(); expect(isValidExchange).to.be.true(); }); @@ -122,7 +122,7 @@ blockchainTests.resets('Exchange Unit Tests', env => { StakingRevertErrors.ExchangeManagerErrorCodes.ExchangeAlreadyRegistered, exchange, ); - const tx = exchangeManager.addExchangeAddress.awaitTransactionSuccessAsync(exchange, { from: authority }); + const tx = exchangeManager.addExchangeAddress(exchange).awaitTransactionSuccessAsync({ from: authority }); return expect(tx).to.revertWith(expectedError); }); }); @@ -130,7 +130,7 @@ blockchainTests.resets('Exchange Unit Tests', env => { describe('removeExchangeAddress', () => { it('should revert if called by an unauthorized address', async () => { const expectedError = new AuthorizableRevertErrors.SenderNotAuthorizedError(nonAuthority); - const tx = exchangeManager.removeExchangeAddress.awaitTransactionSuccessAsync(exchange, { + const tx = exchangeManager.removeExchangeAddress(exchange).awaitTransactionSuccessAsync({ from: nonAuthority, }); return expect(tx).to.revertWith(expectedError); @@ -138,7 +138,7 @@ blockchainTests.resets('Exchange Unit Tests', env => { it('should revert when removing an exchange if called by the (non-authorized) owner', async () => { const expectedError = new AuthorizableRevertErrors.SenderNotAuthorizedError(owner); - const tx = exchangeManager.removeExchangeAddress.awaitTransactionSuccessAsync(nonExchange, { + const tx = exchangeManager.removeExchangeAddress(nonExchange).awaitTransactionSuccessAsync({ from: owner, }); return expect(tx).to.revertWith(expectedError); @@ -146,7 +146,7 @@ blockchainTests.resets('Exchange Unit Tests', env => { it('should successfully remove a registered exchange if called by an authorized address', async () => { // Remove the registered exchange. - const receipt = await exchangeManager.removeExchangeAddress.awaitTransactionSuccessAsync(exchange, { + const receipt = await exchangeManager.removeExchangeAddress(exchange).awaitTransactionSuccessAsync({ from: authority, }); @@ -154,7 +154,7 @@ blockchainTests.resets('Exchange Unit Tests', env => { verifyExchangeManagerEvent(ExchangeManagerEventType.ExchangeRemoved, exchange, receipt); // Ensure that the exchange was removed. - const isValidExchange = await exchangeManager.validExchanges.callAsync(exchange); + const isValidExchange = await exchangeManager.validExchanges(exchange).callAsync(); expect(isValidExchange).to.be.false(); }); @@ -163,7 +163,7 @@ blockchainTests.resets('Exchange Unit Tests', env => { StakingRevertErrors.ExchangeManagerErrorCodes.ExchangeNotRegistered, nonExchange, ); - const tx = exchangeManager.removeExchangeAddress.awaitTransactionSuccessAsync(nonExchange, { + const tx = exchangeManager.removeExchangeAddress(nonExchange).awaitTransactionSuccessAsync({ from: authority, }); return expect(tx).to.revertWith(expectedError); diff --git a/contracts/staking/test/unit_tests/finalizer_test.ts b/contracts/staking/test/unit_tests/finalizer_test.ts index 8143917b34..1b3ca90fc2 100644 --- a/contracts/staking/test/unit_tests/finalizer_test.ts +++ b/contracts/staking/test/unit_tests/finalizer_test.ts @@ -75,13 +75,15 @@ blockchainTests.resets('Finalizer unit tests', env => { weightedStake: getRandomInteger(0, maxAmount), ...opts, }; - await testContract.addActivePool.awaitTransactionSuccessAsync( - _opts.poolId, - new BigNumber(_opts.operatorShare * constants.PPM_DENOMINATOR).integerValue(), - new BigNumber(_opts.feesCollected), - new BigNumber(_opts.membersStake), - new BigNumber(_opts.weightedStake), - ); + await testContract + .addActivePool( + _opts.poolId, + new BigNumber(_opts.operatorShare * constants.PPM_DENOMINATOR).integerValue(), + new BigNumber(_opts.feesCollected), + new BigNumber(_opts.membersStake), + new BigNumber(_opts.weightedStake), + ) + .awaitTransactionSuccessAsync(); return _opts; } @@ -94,13 +96,13 @@ blockchainTests.resets('Finalizer unit tests', env => { } async function getUnfinalizedStateAsync(): Promise { - return testContract.getAggregatedStatsForPreviousEpoch.callAsync(); + return testContract.getAggregatedStatsForPreviousEpoch().callAsync(); } async function finalizePoolsAsync(poolIds: string[]): Promise { const logs = [] as LogEntry[]; for (const poolId of poolIds) { - const receipt = await testContract.finalizePool.awaitTransactionSuccessAsync(poolId); + const receipt = await testContract.finalizePool(poolId).awaitTransactionSuccessAsync(); logs.splice(logs.length, 0, ...receipt.logs); } return logs; @@ -207,13 +209,15 @@ blockchainTests.resets('Finalizer unit tests', env => { if (feesCollected.isZero()) { continue; } - poolRewards[i] = await testContract.cobbDouglas.callAsync( - new BigNumber(rewardsAvailable), - new BigNumber(feesCollected), - new BigNumber(totalFees), - new BigNumber(pool.weightedStake), - new BigNumber(totalStake), - ); + poolRewards[i] = await testContract + .cobbDouglas( + new BigNumber(rewardsAvailable), + new BigNumber(feesCollected), + new BigNumber(totalFees), + new BigNumber(pool.weightedStake), + new BigNumber(totalStake), + ) + .callAsync(); } return poolRewards; } @@ -256,7 +260,7 @@ blockchainTests.resets('Finalizer unit tests', env => { } async function getCurrentEpochAsync(): Promise { - return testContract.currentEpoch.callAsync(); + return testContract.currentEpoch().callAsync(); } async function getBalanceOfAsync(whom: string): Promise { @@ -265,13 +269,13 @@ blockchainTests.resets('Finalizer unit tests', env => { describe('endEpoch()', () => { it('advances the epoch', async () => { - await testContract.endEpoch.awaitTransactionSuccessAsync(); - const currentEpoch = await testContract.currentEpoch.callAsync(); + await testContract.endEpoch().awaitTransactionSuccessAsync(); + const currentEpoch = await testContract.currentEpoch().callAsync(); expect(currentEpoch).to.bignumber.eq(stakingConstants.INITIAL_EPOCH.plus(1)); }); it('emits an `EpochEnded` event', async () => { - const receipt = await testContract.endEpoch.awaitTransactionSuccessAsync(); + const receipt = await testContract.endEpoch().awaitTransactionSuccessAsync(); assertEpochEndedEvent(receipt.logs, { epoch: stakingConstants.INITIAL_EPOCH, numActivePools: ZERO_AMOUNT, @@ -282,7 +286,7 @@ blockchainTests.resets('Finalizer unit tests', env => { }); it('immediately finalizes if there are no pools to finalize', async () => { - const receipt = await testContract.endEpoch.awaitTransactionSuccessAsync(); + const receipt = await testContract.endEpoch().awaitTransactionSuccessAsync(); assertEpochFinalizedEvent(receipt.logs, { epoch: stakingConstants.INITIAL_EPOCH, rewardsPaid: ZERO_AMOUNT, @@ -292,7 +296,7 @@ blockchainTests.resets('Finalizer unit tests', env => { it('does not immediately finalize if there is a pool to finalize', async () => { await addActivePoolAsync(); - const receipt = await testContract.endEpoch.awaitTransactionSuccessAsync(); + const receipt = await testContract.endEpoch().awaitTransactionSuccessAsync(); const events = filterLogsToArguments( receipt.logs, IStakingEventsEvents.EpochFinalized, @@ -303,7 +307,7 @@ blockchainTests.resets('Finalizer unit tests', env => { it('prepares unfinalized state', async () => { // Add a pool so there is state to clear. const pool = await addActivePoolAsync(); - await testContract.endEpoch.awaitTransactionSuccessAsync(); + await testContract.endEpoch().awaitTransactionSuccessAsync(); return assertUnfinalizedStateAsync({ numPoolsToFinalize: 1, rewardsAvailable: INITIAL_BALANCE, @@ -314,9 +318,9 @@ blockchainTests.resets('Finalizer unit tests', env => { it("correctly stores the epoch's aggregated stats after ending the epoch", async () => { const pool = await addActivePoolAsync(); - const epoch = await testContract.currentEpoch.callAsync(); - await testContract.endEpoch.awaitTransactionSuccessAsync(); - const aggregatedStats = await testContract.aggregatedStatsByEpoch.callAsync(epoch); + const epoch = await testContract.currentEpoch().callAsync(); + await testContract.endEpoch().awaitTransactionSuccessAsync(); + const aggregatedStats = await testContract.aggregatedStatsByEpoch(epoch).callAsync(); expect(aggregatedStats).to.be.deep.equal([ INITIAL_BALANCE, new BigNumber(1), // pools to finalize @@ -328,8 +332,8 @@ blockchainTests.resets('Finalizer unit tests', env => { it('reverts if the prior epoch is unfinalized', async () => { await addActivePoolAsync(); - await testContract.endEpoch.awaitTransactionSuccessAsync(); - const tx = testContract.endEpoch.awaitTransactionSuccessAsync(); + await testContract.endEpoch().awaitTransactionSuccessAsync(); + const tx = testContract.endEpoch().awaitTransactionSuccessAsync(); const expectedError = new StakingRevertErrors.PreviousEpochNotFinalizedError( stakingConstants.INITIAL_EPOCH, 1, @@ -340,7 +344,7 @@ blockchainTests.resets('Finalizer unit tests', env => { describe('_finalizePool()', () => { it('does nothing if there were no pools to finalize', async () => { - await testContract.endEpoch.awaitTransactionSuccessAsync(); + await testContract.endEpoch().awaitTransactionSuccessAsync(); const poolId = hexRandom(); const logs = await finalizePoolsAsync([poolId]); expect(logs).to.deep.eq([]); @@ -348,21 +352,21 @@ blockchainTests.resets('Finalizer unit tests', env => { it('can finalize a pool', async () => { const pool = await addActivePoolAsync(); - await testContract.endEpoch.awaitTransactionSuccessAsync(); + await testContract.endEpoch().awaitTransactionSuccessAsync(); const logs = await finalizePoolsAsync([pool.poolId]); return assertFinalizationLogsAndBalancesAsync(INITIAL_BALANCE, [pool], logs); }); it('can finalize multiple pools over multiple transactions', async () => { const pools = await Promise.all(_.times(2, async () => addActivePoolAsync())); - await testContract.endEpoch.awaitTransactionSuccessAsync(); + await testContract.endEpoch().awaitTransactionSuccessAsync(); const logs = await finalizePoolsAsync(pools.map(p => p.poolId)); return assertFinalizationLogsAndBalancesAsync(INITIAL_BALANCE, pools, logs); }); it('ignores a finalized pool', async () => { const pools = await Promise.all(_.times(3, async () => addActivePoolAsync())); - await testContract.endEpoch.awaitTransactionSuccessAsync(); + await testContract.endEpoch().awaitTransactionSuccessAsync(); const [finalizedPool] = _.sampleSize(pools, 1); await finalizePoolsAsync([finalizedPool.poolId]); const logs = await finalizePoolsAsync([finalizedPool.poolId]); @@ -373,12 +377,11 @@ blockchainTests.resets('Finalizer unit tests', env => { it('resets pool state after finalizing it', async () => { const pools = await Promise.all(_.times(3, async () => addActivePoolAsync())); const pool = _.sample(pools) as ActivePoolOpts; - await testContract.endEpoch.awaitTransactionSuccessAsync(); + await testContract.endEpoch().awaitTransactionSuccessAsync(); await finalizePoolsAsync([pool.poolId]); - const poolState = await testContract.getPoolStatsFromEpoch.callAsync( - stakingConstants.INITIAL_EPOCH, - pool.poolId, - ); + const poolState = await testContract + .getPoolStatsFromEpoch(stakingConstants.INITIAL_EPOCH, pool.poolId) + .callAsync(); expect(poolState.feesCollected).to.bignumber.eq(0); expect(poolState.weightedStake).to.bignumber.eq(0); expect(poolState.membersStake).to.bignumber.eq(0); @@ -386,7 +389,7 @@ blockchainTests.resets('Finalizer unit tests', env => { it('`rewardsPaid` <= `rewardsAvailable` <= contract balance at the end of the epoch', async () => { const pools = await Promise.all(_.times(3, async () => addActivePoolAsync())); - const receipt = await testContract.endEpoch.awaitTransactionSuccessAsync(); + const receipt = await testContract.endEpoch().awaitTransactionSuccessAsync(); const { rewardsAvailable } = getEpochEndedEvents(receipt.logs)[0]; expect(rewardsAvailable).to.bignumber.lte(INITIAL_BALANCE); const logs = await finalizePoolsAsync(pools.map(r => r.poolId)); @@ -397,7 +400,7 @@ blockchainTests.resets('Finalizer unit tests', env => { it('`rewardsPaid` <= `rewardsAvailable` with two equal pools', async () => { const pool1 = await addActivePoolAsync(); const pool2 = await addActivePoolAsync(_.omit(pool1, 'poolId')); - const receipt = await testContract.endEpoch.awaitTransactionSuccessAsync(); + const receipt = await testContract.endEpoch().awaitTransactionSuccessAsync(); const { rewardsAvailable } = getEpochEndedEvents(receipt.logs)[0]; const logs = await finalizePoolsAsync([pool1, pool2].map(r => r.poolId)); const { rewardsPaid } = getEpochFinalizedEvents(logs)[0]; @@ -410,7 +413,7 @@ blockchainTests.resets('Finalizer unit tests', env => { const numPools = _.random(1, 32); it(`${i + 1}/${numTests} \`rewardsPaid\` <= \`rewardsAvailable\` (${numPools} pools)`, async () => { const pools = await Promise.all(_.times(numPools, async () => addActivePoolAsync())); - const receipt = await testContract.endEpoch.awaitTransactionSuccessAsync(); + const receipt = await testContract.endEpoch().awaitTransactionSuccessAsync(); const { rewardsAvailable } = getEpochEndedEvents(receipt.logs)[0]; const logs = await finalizePoolsAsync(pools.map(r => r.poolId)); const { rewardsPaid } = getEpochFinalizedEvents(logs)[0]; @@ -423,18 +426,18 @@ blockchainTests.resets('Finalizer unit tests', env => { describe('lifecycle', () => { it('can advance the epoch after the prior epoch is finalized', async () => { const pool = await addActivePoolAsync(); - await testContract.endEpoch.awaitTransactionSuccessAsync(); + await testContract.endEpoch().awaitTransactionSuccessAsync(); await finalizePoolsAsync([pool.poolId]); - await testContract.endEpoch.awaitTransactionSuccessAsync(); + await testContract.endEpoch().awaitTransactionSuccessAsync(); return expect(getCurrentEpochAsync()).to.become(stakingConstants.INITIAL_EPOCH.plus(2)); }); it('does not reward a pool that only earned rewards 2 epochs ago', async () => { const pool1 = await addActivePoolAsync(); - await testContract.endEpoch.awaitTransactionSuccessAsync(); + await testContract.endEpoch().awaitTransactionSuccessAsync(); await finalizePoolsAsync([pool1.poolId]); await addActivePoolAsync(); - await testContract.endEpoch.awaitTransactionSuccessAsync(); + await testContract.endEpoch().awaitTransactionSuccessAsync(); expect(getCurrentEpochAsync()).to.become(stakingConstants.INITIAL_EPOCH.plus(2)); const logs = await finalizePoolsAsync([pool1.poolId]); const rewardsPaidEvents = getRewardsPaidEvents(logs); @@ -443,11 +446,11 @@ blockchainTests.resets('Finalizer unit tests', env => { it('does not reward a pool that only earned rewards 3 epochs ago', async () => { const pool1 = await addActivePoolAsync(); - await testContract.endEpoch.awaitTransactionSuccessAsync(); + await testContract.endEpoch().awaitTransactionSuccessAsync(); await finalizePoolsAsync([pool1.poolId]); - await testContract.endEpoch.awaitTransactionSuccessAsync(); + await testContract.endEpoch().awaitTransactionSuccessAsync(); await addActivePoolAsync(); - await testContract.endEpoch.awaitTransactionSuccessAsync(); + await testContract.endEpoch().awaitTransactionSuccessAsync(); expect(getCurrentEpochAsync()).to.become(stakingConstants.INITIAL_EPOCH.plus(3)); const logs = await finalizePoolsAsync([pool1.poolId]); const rewardsPaidEvents = getRewardsPaidEvents(logs); @@ -457,11 +460,11 @@ blockchainTests.resets('Finalizer unit tests', env => { it('rolls over leftover rewards into the next epoch', async () => { const poolIds = _.times(3, () => hexRandom()); await Promise.all(poolIds.map(async id => addActivePoolAsync({ poolId: id }))); - await testContract.endEpoch.awaitTransactionSuccessAsync(); + await testContract.endEpoch().awaitTransactionSuccessAsync(); const finalizeLogs = await finalizePoolsAsync(poolIds); const { rewardsRemaining: rolledOverRewards } = getEpochFinalizedEvents(finalizeLogs)[0]; await Promise.all(poolIds.map(async id => addActivePoolAsync({ poolId: id }))); - const { logs: endEpochLogs } = await testContract.endEpoch.awaitTransactionSuccessAsync(); + const { logs: endEpochLogs } = await testContract.endEpoch().awaitTransactionSuccessAsync(); const { rewardsAvailable } = getEpochEndedEvents(endEpochLogs)[0]; expect(rewardsAvailable).to.bignumber.eq(rolledOverRewards); }); @@ -476,7 +479,7 @@ blockchainTests.resets('Finalizer unit tests', env => { poolId: string, expected: Partial, ): Promise { - const actual = await testContract.getUnfinalizedPoolRewards.callAsync(poolId); + const actual = await testContract.getUnfinalizedPoolRewards(poolId).callAsync(); if (expected.totalReward !== undefined) { expect(actual.totalReward).to.bignumber.eq(expected.totalReward); } @@ -497,7 +500,7 @@ blockchainTests.resets('Finalizer unit tests', env => { }); it('returns empty if pool did not earn rewards', async () => { - await testContract.endEpoch.awaitTransactionSuccessAsync(); + await testContract.endEpoch().awaitTransactionSuccessAsync(); const poolId = hexRandom(); return assertUnfinalizedPoolRewardsAsync(poolId, ZERO_REWARDS); }); @@ -509,7 +512,7 @@ blockchainTests.resets('Finalizer unit tests', env => { it('returns empty if pool only earned rewards in the 2 epochs ago', async () => { const pool = await addActivePoolAsync(); - await testContract.endEpoch.awaitTransactionSuccessAsync(); + await testContract.endEpoch().awaitTransactionSuccessAsync(); await finalizePoolsAsync([pool.poolId]); return assertUnfinalizedPoolRewardsAsync(pool.poolId, ZERO_REWARDS); }); @@ -517,14 +520,14 @@ blockchainTests.resets('Finalizer unit tests', env => { it('returns empty if pool was already finalized', async () => { const pools = await Promise.all(_.times(3, async () => addActivePoolAsync())); const [pool] = _.sampleSize(pools, 1); - await testContract.endEpoch.awaitTransactionSuccessAsync(); + await testContract.endEpoch().awaitTransactionSuccessAsync(); await finalizePoolsAsync([pool.poolId]); return assertUnfinalizedPoolRewardsAsync(pool.poolId, ZERO_REWARDS); }); it('computes one reward among one pool', async () => { const pool = await addActivePoolAsync(); - await testContract.endEpoch.awaitTransactionSuccessAsync(); + await testContract.endEpoch().awaitTransactionSuccessAsync(); const expectedTotalRewards = INITIAL_BALANCE; return assertUnfinalizedPoolRewardsAsync(pool.poolId, { totalReward: expectedTotalRewards, @@ -534,7 +537,7 @@ blockchainTests.resets('Finalizer unit tests', env => { it('computes one reward among multiple pools', async () => { const pools = await Promise.all(_.times(3, async () => addActivePoolAsync())); - await testContract.endEpoch.awaitTransactionSuccessAsync(); + await testContract.endEpoch().awaitTransactionSuccessAsync(); const expectedPoolRewards = await calculatePoolRewardsAsync(INITIAL_BALANCE, pools); const [pool, reward] = _.sampleSize(shortZip(pools, expectedPoolRewards), 1)[0]; return assertUnfinalizedPoolRewardsAsync(pool.poolId, { @@ -545,7 +548,7 @@ blockchainTests.resets('Finalizer unit tests', env => { it('computes a reward with 0% operatorShare', async () => { const pool = await addActivePoolAsync({ operatorShare: 0 }); - await testContract.endEpoch.awaitTransactionSuccessAsync(); + await testContract.endEpoch().awaitTransactionSuccessAsync(); return assertUnfinalizedPoolRewardsAsync(pool.poolId, { totalReward: INITIAL_BALANCE, membersStake: pool.membersStake, @@ -554,7 +557,7 @@ blockchainTests.resets('Finalizer unit tests', env => { it('computes a reward with 0% < operatorShare < 100%', async () => { const pool = await addActivePoolAsync({ operatorShare: Math.random() }); - await testContract.endEpoch.awaitTransactionSuccessAsync(); + await testContract.endEpoch().awaitTransactionSuccessAsync(); return assertUnfinalizedPoolRewardsAsync(pool.poolId, { totalReward: INITIAL_BALANCE, membersStake: pool.membersStake, @@ -563,7 +566,7 @@ blockchainTests.resets('Finalizer unit tests', env => { it('computes a reward with 100% operatorShare', async () => { const pool = await addActivePoolAsync({ operatorShare: 1 }); - await testContract.endEpoch.awaitTransactionSuccessAsync(); + await testContract.endEpoch().awaitTransactionSuccessAsync(); return assertUnfinalizedPoolRewardsAsync(pool.poolId, { totalReward: INITIAL_BALANCE, membersStake: pool.membersStake, diff --git a/contracts/staking/test/unit_tests/lib_cobb_douglas_test.ts b/contracts/staking/test/unit_tests/lib_cobb_douglas_test.ts index e0080e560e..787c5405c4 100644 --- a/contracts/staking/test/unit_tests/lib_cobb_douglas_test.ts +++ b/contracts/staking/test/unit_tests/lib_cobb_douglas_test.ts @@ -55,18 +55,19 @@ blockchainTests('LibCobbDouglas unit tests', env => { ...DEFAULT_COBB_DOUGLAS_PARAMS, ...params, }; - return testContract.cobbDouglas.callAsync( - new BigNumber(_params.totalRewards), - new BigNumber(_params.ownerFees), - new BigNumber(_params.totalFees), - new BigNumber(_params.ownerStake), - new BigNumber(_params.totalStake), - new BigNumber(_params.alphaNumerator), - new BigNumber(_params.alphaDenominator), - { + return testContract + .cobbDouglas( + new BigNumber(_params.totalRewards), + new BigNumber(_params.ownerFees), + new BigNumber(_params.totalFees), + new BigNumber(_params.ownerStake), + new BigNumber(_params.totalStake), + new BigNumber(_params.alphaNumerator), + new BigNumber(_params.alphaDenominator), + ) + .callAsync({ gas: TX_GAS_FEE + (_params.gas === undefined ? MAX_COBB_DOUGLAS_GAS : _params.gas), - }, - ); + }); } function cobbDouglas(params?: Partial): BigNumber { diff --git a/contracts/staking/test/unit_tests/lib_fixed_math_test.ts b/contracts/staking/test/unit_tests/lib_fixed_math_test.ts index 2e98089a67..c53f1ec7d8 100644 --- a/contracts/staking/test/unit_tests/lib_fixed_math_test.ts +++ b/contracts/staking/test/unit_tests/lib_fixed_math_test.ts @@ -40,7 +40,7 @@ blockchainTests('LibFixedMath unit tests', env => { describe('one()', () => { it('equals 1', async () => { - const r = await testContract.one.callAsync(); + const r = await testContract.one().callAsync(); assertFixedEquals(r, 1); }); }); @@ -48,25 +48,25 @@ blockchainTests('LibFixedMath unit tests', env => { describe('abs()', () => { it('abs(n) == n', async () => { const n = 1337.5912; - const r = await testContract.abs.callAsync(toFixed(n)); + const r = await testContract.abs(toFixed(n)).callAsync(); assertFixedEquals(r, n); }); it('abs(-n) == n', async () => { const n = -1337.5912; - const r = await testContract.abs.callAsync(toFixed(n)); + const r = await testContract.abs(toFixed(n)).callAsync(); assertFixedEquals(r, -n); }); it('abs(0) == 0', async () => { const n = 0; - const r = await testContract.abs.callAsync(toFixed(n)); + const r = await testContract.abs(toFixed(n)).callAsync(); expect(r).to.bignumber.eq(0); }); it('abs(MAX_FIXED) == MAX_FIXED', async () => { const n = MAX_FIXED_VALUE; - const r = await testContract.abs.callAsync(n); + const r = await testContract.abs(n).callAsync(); expect(r).to.bignumber.eq(n); }); @@ -76,19 +76,19 @@ blockchainTests('LibFixedMath unit tests', env => { FixedMathRevertErrors.ValueErrorCodes.TooSmall, n, ); - const tx = testContract.abs.callAsync(n); + const tx = testContract.abs(n).callAsync(); return expect(tx).to.revertWith(expectedError); }); it('abs(int(-1)) == int(1)', async () => { const n = -1; - const r = await testContract.abs.callAsync(new BigNumber(n)); + const r = await testContract.abs(new BigNumber(n)).callAsync(); expect(r).to.bignumber.eq(1); }); it('abs(int(1)) == int(1)', async () => { const n = 1; - const r = await testContract.abs.callAsync(new BigNumber(n)); + const r = await testContract.abs(new BigNumber(n)).callAsync(); expect(r).to.bignumber.eq(1); }); }); @@ -96,19 +96,19 @@ blockchainTests('LibFixedMath unit tests', env => { describe('invert()', () => { it('invert(1) == 1', async () => { const n = 1; - const r = await testContract.invert.callAsync(toFixed(n)); + const r = await testContract.invert(toFixed(n)).callAsync(); assertFixedEquals(r, n); }); it('invert(n) == 1 / n', async () => { const n = 1337.5912; - const r = await testContract.invert.callAsync(toFixed(n)); + const r = await testContract.invert(toFixed(n)).callAsync(); assertFixedRoughlyEquals(r, 1 / n); }); it('invert(-n) == -1 / n', async () => { const n = -1337.5912; - const r = await testContract.invert.callAsync(toFixed(n)); + const r = await testContract.invert(toFixed(n)).callAsync(); assertFixedRoughlyEquals(r, 1 / n); }); @@ -116,7 +116,7 @@ blockchainTests('LibFixedMath unit tests', env => { const expectedError = new FixedMathRevertErrors.BinOpError( FixedMathRevertErrors.BinOpErrorCodes.DivisionByZero, ); - const tx = testContract.invert.callAsync(toFixed(0)); + const tx = testContract.invert(toFixed(0)).callAsync(); return expect(tx).to.revertWith(expectedError); }); }); @@ -124,31 +124,31 @@ blockchainTests('LibFixedMath unit tests', env => { describe('mulDiv()', () => { it('mulDiv(0, 0, 1) == 0', async () => { const [a, n, d] = [0, 0, 1]; - const r = await testContract.mulDiv.callAsync(toFixed(a), new BigNumber(n), new BigNumber(d)); + const r = await testContract.mulDiv(toFixed(a), new BigNumber(n), new BigNumber(d)).callAsync(); assertFixedEquals(r, 0); }); it('mulDiv(0, x, y) == 0', async () => { const [a, n, d] = [0, 13, 300]; - const r = await testContract.mulDiv.callAsync(toFixed(a), new BigNumber(n), new BigNumber(d)); + const r = await testContract.mulDiv(toFixed(a), new BigNumber(n), new BigNumber(d)).callAsync(); assertFixedEquals(r, 0); }); it('mulDiv(x, y, y) == x', async () => { const [a, n, d] = [1.2345, 149, 149]; - const r = await testContract.mulDiv.callAsync(toFixed(a), new BigNumber(n), new BigNumber(d)); + const r = await testContract.mulDiv(toFixed(a), new BigNumber(n), new BigNumber(d)).callAsync(); assertFixedEquals(r, a); }); it('mulDiv(x, -y, y) == -x', async () => { const [a, n, d] = [1.2345, -149, 149]; - const r = await testContract.mulDiv.callAsync(toFixed(a), new BigNumber(n), new BigNumber(d)); + const r = await testContract.mulDiv(toFixed(a), new BigNumber(n), new BigNumber(d)).callAsync(); assertFixedEquals(r, -a); }); it('mulDiv(-x, -y, y) == x', async () => { const [a, n, d] = [-1.2345, -149, 149]; - const r = await testContract.mulDiv.callAsync(toFixed(a), new BigNumber(n), new BigNumber(d)); + const r = await testContract.mulDiv(toFixed(a), new BigNumber(n), new BigNumber(d)).callAsync(); assertFixedEquals(r, -a); }); @@ -157,19 +157,19 @@ blockchainTests('LibFixedMath unit tests', env => { const expectedError = new FixedMathRevertErrors.BinOpError( FixedMathRevertErrors.BinOpErrorCodes.DivisionByZero, ); - const tx = testContract.mulDiv.callAsync(toFixed(a), new BigNumber(n), new BigNumber(d)); + const tx = testContract.mulDiv(toFixed(a), new BigNumber(n), new BigNumber(d)).callAsync(); return expect(tx).to.revertWith(expectedError); }); it('mulDiv(int(-1), int(1), int(-1)) == int(1)', async () => { const [a, n, d] = [-1, 1, -1]; - const r = await testContract.mulDiv.callAsync(new BigNumber(a), new BigNumber(n), new BigNumber(d)); + const r = await testContract.mulDiv(new BigNumber(a), new BigNumber(n), new BigNumber(d)).callAsync(); assertFixedEquals(r, fromFixed(1)); }); it('mulDiv(int(1), int(-1), int(-1)) == int(1)', async () => { const [a, n, d] = [1, -1, -1]; - const r = await testContract.mulDiv.callAsync(new BigNumber(a), new BigNumber(n), new BigNumber(d)); + const r = await testContract.mulDiv(new BigNumber(a), new BigNumber(n), new BigNumber(d)).callAsync(); assertFixedEquals(r, fromFixed(1)); }); @@ -180,7 +180,7 @@ blockchainTests('LibFixedMath unit tests', env => { a, n, ); - const tx = testContract.mulDiv.callAsync(a, new BigNumber(n), new BigNumber(d)); + const tx = testContract.mulDiv(a, new BigNumber(n), new BigNumber(d)).callAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -191,7 +191,7 @@ blockchainTests('LibFixedMath unit tests', env => { a, n, ); - const tx = testContract.mulDiv.callAsync(new BigNumber(a), n, new BigNumber(d)); + const tx = testContract.mulDiv(new BigNumber(a), n, new BigNumber(d)).callAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -202,19 +202,19 @@ blockchainTests('LibFixedMath unit tests', env => { a, d, ); - const tx = testContract.mulDiv.callAsync(a, new BigNumber(n), new BigNumber(d)); + const tx = testContract.mulDiv(a, new BigNumber(n), new BigNumber(d)).callAsync(); return expect(tx).to.revertWith(expectedError); }); it('mulDiv(MAX_FIXED, int(-1), int(1)) == -MAX_FIXED', async () => { const [a, n, d] = [MAX_FIXED_VALUE, -1, 1]; - const r = await testContract.mulDiv.callAsync(a, new BigNumber(n), new BigNumber(d)); + const r = await testContract.mulDiv(a, new BigNumber(n), new BigNumber(d)).callAsync(); expect(r).to.bignumber.eq(MAX_FIXED_VALUE.negated()); }); it('mulDiv(MAX_FIXED, int(1), int(-1)) == -MAX_FIXED', async () => { const [a, n, d] = [MAX_FIXED_VALUE, 1, -1]; - const r = await testContract.mulDiv.callAsync(a, new BigNumber(n), new BigNumber(d)); + const r = await testContract.mulDiv(a, new BigNumber(n), new BigNumber(d)).callAsync(); expect(r).to.bignumber.eq(MAX_FIXED_VALUE.negated()); }); }); @@ -226,19 +226,19 @@ blockchainTests('LibFixedMath unit tests', env => { it('0 + 0 == 0', async () => { const [a, b] = [0, 0]; - const r = await testContract.add.callAsync(toFixed(a), toFixed(b)); + const r = await testContract.add(toFixed(a), toFixed(b)).callAsync(); assertFixedEquals(r, 0); }); it('adds two positive decimals', async () => { const [a, b] = ['9310841.31841', '491021921.318948193']; - const r = await testContract.add.callAsync(toFixed(a), toFixed(b)); + const r = await testContract.add(toFixed(a), toFixed(b)).callAsync(); assertFixedEquals(r, add(a, b)); }); it('adds two mixed decimals', async () => { const [a, b] = ['9310841.31841', '-491021921.318948193']; - const r = await testContract.add.callAsync(toFixed(a), toFixed(b)); + const r = await testContract.add(toFixed(a), toFixed(b)).callAsync(); assertFixedEquals(r, add(a, b)); }); @@ -249,7 +249,7 @@ blockchainTests('LibFixedMath unit tests', env => { a, b, ); - const tx = testContract.add.callAsync(a, b); + const tx = testContract.add(a, b).callAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -260,7 +260,7 @@ blockchainTests('LibFixedMath unit tests', env => { a, b, ); - const tx = testContract.add.callAsync(a, b); + const tx = testContract.add(a, b).callAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -271,7 +271,7 @@ blockchainTests('LibFixedMath unit tests', env => { a, b, ); - const tx = testContract.add.callAsync(a, b); + const tx = testContract.add(a, b).callAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -282,19 +282,19 @@ blockchainTests('LibFixedMath unit tests', env => { a, b, ); - const tx = testContract.add.callAsync(a, b); + const tx = testContract.add(a, b).callAsync(); return expect(tx).to.revertWith(expectedError); }); it('MIN_FIXED + MAX_FIXED == int(-1)', async () => { const [a, b] = [MIN_FIXED_VALUE, MAX_FIXED_VALUE]; - const r = await testContract.add.callAsync(a, b); + const r = await testContract.add(a, b).callAsync(); expect(r).to.bignumber.eq(-1); }); it('MAX_FIXED + (MIN_FIXED + int(1)) == 0', async () => { const [a, b] = [MAX_FIXED_VALUE, MIN_FIXED_VALUE.plus(1)]; - const r = await testContract.add.callAsync(a, b); + const r = await testContract.add(a, b).callAsync(); expect(r).to.bignumber.eq(0); }); }); @@ -306,19 +306,19 @@ blockchainTests('LibFixedMath unit tests', env => { it('0 - 0 == 0', async () => { const [a, b] = [0, 0]; - const r = await testContract.sub.callAsync(toFixed(a), toFixed(b)); + const r = await testContract.sub(toFixed(a), toFixed(b)).callAsync(); assertFixedEquals(r, 0); }); it('subtracts two positive decimals', async () => { const [a, b] = ['9310841.31841', '491021921.318948193']; - const r = await testContract.sub.callAsync(toFixed(a), toFixed(b)); + const r = await testContract.sub(toFixed(a), toFixed(b)).callAsync(); assertFixedEquals(r, sub(a, b)); }); it('subtracts two mixed decimals', async () => { const [a, b] = ['9310841.31841', '-491021921.318948193']; - const r = await testContract.sub.callAsync(toFixed(a), toFixed(b)); + const r = await testContract.sub(toFixed(a), toFixed(b)).callAsync(); assertFixedEquals(r, sub(a, b)); }); @@ -329,7 +329,7 @@ blockchainTests('LibFixedMath unit tests', env => { a, b.negated(), ); - const tx = testContract.sub.callAsync(a, b); + const tx = testContract.sub(a, b).callAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -340,7 +340,7 @@ blockchainTests('LibFixedMath unit tests', env => { a, b.negated(), ); - const tx = testContract.sub.callAsync(a, b); + const tx = testContract.sub(a, b).callAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -352,13 +352,13 @@ blockchainTests('LibFixedMath unit tests', env => { FixedMathRevertErrors.ValueErrorCodes.TooSmall, b, ); - const tx = testContract.sub.callAsync(a, b); + const tx = testContract.sub(a, b).callAsync(); return expect(tx).to.revertWith(expectedError); }); it('MAX_FIXED - MAX_FIXED == 0', async () => { const [a, b] = [MAX_FIXED_VALUE, MAX_FIXED_VALUE]; - const r = await testContract.sub.callAsync(a, b); + const r = await testContract.sub(a, b).callAsync(); expect(r).to.bignumber.eq(0); }); @@ -369,7 +369,7 @@ blockchainTests('LibFixedMath unit tests', env => { a, b.negated(), ); - const tx = testContract.sub.callAsync(a, b); + const tx = testContract.sub(a, b).callAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -379,7 +379,7 @@ blockchainTests('LibFixedMath unit tests', env => { FixedMathRevertErrors.ValueErrorCodes.TooSmall, b, ); - const tx = testContract.sub.callAsync(a, b); + const tx = testContract.sub(a, b).callAsync(); return expect(tx).to.revertWith(expectedError); }); }); @@ -395,31 +395,31 @@ blockchainTests('LibFixedMath unit tests', env => { it('x * 0 == 0', async () => { const [a, b] = [1337, 0]; - const r = await testContract.mul.callAsync(toFixed(a), toFixed(b)); + const r = await testContract.mul(toFixed(a), toFixed(b)).callAsync(); assertFixedEquals(r, b); }); it('x * 1 == x', async () => { const [a, b] = [0.5, 1]; - const r = await testContract.mul.callAsync(toFixed(a), toFixed(b)); + const r = await testContract.mul(toFixed(a), toFixed(b)).callAsync(); assertFixedEquals(r, a); }); it('x * -1 == -x', async () => { const [a, b] = [0.5, -1]; - const r = await testContract.mul.callAsync(toFixed(a), toFixed(b)); + const r = await testContract.mul(toFixed(a), toFixed(b)).callAsync(); assertFixedEquals(r, -a); }); it('multiplies two positive decimals', async () => { const [a, b] = ['1.25394912112', '0.03413318948193']; - const r = await testContract.mul.callAsync(toFixed(a), toFixed(b)); + const r = await testContract.mul(toFixed(a), toFixed(b)).callAsync(); assertFixedEquals(r, mul(a, b)); }); it('multiplies two mixed decimals', async () => { const [a, b] = ['1.25394912112', '-0.03413318948193']; - const r = await testContract.mul.callAsync(toFixed(a), toFixed(b)); + const r = await testContract.mul(toFixed(a), toFixed(b)).callAsync(); assertFixedEquals(r, mul(a, b)); }); @@ -430,7 +430,7 @@ blockchainTests('LibFixedMath unit tests', env => { a, b, ); - const tx = testContract.mul.callAsync(a, b); + const tx = testContract.mul(a, b).callAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -441,13 +441,13 @@ blockchainTests('LibFixedMath unit tests', env => { a, b, ); - const tx = testContract.mul.callAsync(a, b); + const tx = testContract.mul(a, b).callAsync(); return expect(tx).to.revertWith(expectedError); }); it('MAX_FIXED * int(1) == MAX_FIXED / FIXED_1', async () => { const [a, b] = [MAX_FIXED_VALUE, 1]; - const r = await testContract.mul.callAsync(a, new BigNumber(b)); + const r = await testContract.mul(a, new BigNumber(b)).callAsync(); expect(r).to.bignumber.eq(MAX_FIXED_VALUE.dividedToIntegerBy(FIXED_1)); }); @@ -458,7 +458,7 @@ blockchainTests('LibFixedMath unit tests', env => { a, b, ); - const tx = testContract.mul.callAsync(a, new BigNumber(b)); + const tx = testContract.mul(a, new BigNumber(b)).callAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -469,7 +469,7 @@ blockchainTests('LibFixedMath unit tests', env => { a, b, ); - const tx = testContract.mul.callAsync(a, b); + const tx = testContract.mul(a, b).callAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -480,7 +480,7 @@ blockchainTests('LibFixedMath unit tests', env => { a, b, ); - const tx = testContract.mul.callAsync(a, b); + const tx = testContract.mul(a, b).callAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -491,7 +491,7 @@ blockchainTests('LibFixedMath unit tests', env => { a, b, ); - const tx = testContract.mul.callAsync(a, b); + const tx = testContract.mul(a, b).callAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -502,7 +502,7 @@ blockchainTests('LibFixedMath unit tests', env => { a, b, ); - const tx = testContract.mul.callAsync(a, new BigNumber(b)); + const tx = testContract.mul(a, new BigNumber(b)).callAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -513,13 +513,13 @@ blockchainTests('LibFixedMath unit tests', env => { a, b, ); - const tx = testContract.mul.callAsync(new BigNumber(a), b); + const tx = testContract.mul(new BigNumber(a), b).callAsync(); return expect(tx).to.revertWith(expectedError); }); it('MAX_FIXED * int(-1) == -MAX_FIXED / FIXED_1', async () => { const [a, b] = [MAX_FIXED_VALUE, -1]; - const r = await testContract.mul.callAsync(a, new BigNumber(b)); + const r = await testContract.mul(a, new BigNumber(b)).callAsync(); expect(r).to.bignumber.eq(MAX_FIXED_VALUE.negated().dividedToIntegerBy(FIXED_1)); }); }); @@ -540,31 +540,31 @@ blockchainTests('LibFixedMath unit tests', env => { toFixed(a).times(FIXED_POINT_DIVISOR), toFixed(b), ); - const tx = testContract.div.callAsync(toFixed(a), toFixed(b)); + const tx = testContract.div(toFixed(a), toFixed(b)).callAsync(); return expect(tx).to.revertWith(expectedError); }); it('x / 1 == x', async () => { const [a, b] = [1.41214552, 1]; - const r = await testContract.div.callAsync(toFixed(a), toFixed(b)); + const r = await testContract.div(toFixed(a), toFixed(b)).callAsync(); assertFixedEquals(r, a); }); it('x / -1 == -x', async () => { const [a, b] = [1.109312, -1]; - const r = await testContract.div.callAsync(toFixed(a), toFixed(b)); + const r = await testContract.div(toFixed(a), toFixed(b)).callAsync(); assertFixedEquals(r, -a); }); it('divides two positive decimals', async () => { const [a, b] = ['1.25394912112', '0.03413318948193']; - const r = await testContract.div.callAsync(toFixed(a), toFixed(b)); + const r = await testContract.div(toFixed(a), toFixed(b)).callAsync(); assertFixedEquals(r, div(a, b)); }); it('divides two mixed decimals', async () => { const [a, b] = ['1.25394912112', '-0.03413318948193']; - const r = await testContract.div.callAsync(toFixed(a), toFixed(b)); + const r = await testContract.div(toFixed(a), toFixed(b)).callAsync(); assertFixedEquals(r, div(a, b)); }); @@ -575,7 +575,7 @@ blockchainTests('LibFixedMath unit tests', env => { a, FIXED_1, ); - const tx = testContract.div.callAsync(a, new BigNumber(b)); + const tx = testContract.div(a, new BigNumber(b)).callAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -586,13 +586,13 @@ blockchainTests('LibFixedMath unit tests', env => { a, FIXED_1, ); - const tx = testContract.div.callAsync(a, new BigNumber(b)); + const tx = testContract.div(a, new BigNumber(b)).callAsync(); return expect(tx).to.revertWith(expectedError); }); it('int(-1) / MIN_FIXED == 0', async () => { const [a, b] = [-1, MIN_FIXED_VALUE]; - const r = await testContract.div.callAsync(new BigNumber(a), b); + const r = await testContract.div(new BigNumber(a), b).callAsync(); expect(r).to.bignumber.eq(0); }); }); @@ -600,31 +600,31 @@ blockchainTests('LibFixedMath unit tests', env => { describe('uintMul()', () => { it('0 * x == 0', async () => { const [a, b] = [0, 1234]; - const r = await testContract.uintMul.callAsync(toFixed(a), new BigNumber(b)); + const r = await testContract.uintMul(toFixed(a), new BigNumber(b)).callAsync(); expect(r).to.bignumber.eq(0); }); it('1 * x == int(x)', async () => { const [a, b] = [1, 1234]; - const r = await testContract.uintMul.callAsync(toFixed(a), new BigNumber(b)); + const r = await testContract.uintMul(toFixed(a), new BigNumber(b)).callAsync(); expect(r).to.bignumber.eq(Math.trunc(b)); }); it('-1 * x == 0', async () => { const [a, b] = [-1, 1234]; - const r = await testContract.uintMul.callAsync(toFixed(a), new BigNumber(b)); + const r = await testContract.uintMul(toFixed(a), new BigNumber(b)).callAsync(); expect(r).to.bignumber.eq(0); }); it('0.5 * x == x/2', async () => { const [a, b] = [0.5, 1234]; - const r = await testContract.uintMul.callAsync(toFixed(a), new BigNumber(b)); + const r = await testContract.uintMul(toFixed(a), new BigNumber(b)).callAsync(); expect(r).to.bignumber.eq(b / 2); }); it('0.5 * x == 0 if x = 1', async () => { const [a, b] = [0.5, 1]; - const r = await testContract.uintMul.callAsync(toFixed(a), new BigNumber(b)); + const r = await testContract.uintMul(toFixed(a), new BigNumber(b)).callAsync(); expect(r).to.bignumber.eq(0); }); @@ -634,7 +634,7 @@ blockchainTests('LibFixedMath unit tests', env => { FixedMathRevertErrors.ValueErrorCodes.TooLarge, b, ); - const tx = testContract.uintMul.callAsync(a, b); + const tx = testContract.uintMul(a, b).callAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -645,7 +645,7 @@ blockchainTests('LibFixedMath unit tests', env => { a, b, ); - const tx = testContract.uintMul.callAsync(a, b); + const tx = testContract.uintMul(a, b).callAsync(); return expect(tx).to.revertWith(expectedError); }); }); @@ -653,31 +653,31 @@ blockchainTests('LibFixedMath unit tests', env => { describe('toInteger()', () => { it('toInteger(n) == int(n)', async () => { const n = 1337.5912; - const r = await testContract.toInteger.callAsync(toFixed(n)); + const r = await testContract.toInteger(toFixed(n)).callAsync(); expect(r).to.bignumber.eq(Math.trunc(n)); }); it('toInteger(-n) == -int(n)', async () => { const n = -1337.5912; - const r = await testContract.toInteger.callAsync(toFixed(n)); + const r = await testContract.toInteger(toFixed(n)).callAsync(); expect(r).to.bignumber.eq(Math.trunc(n)); }); it('toInteger(n) == 0, when 0 < n < 1', async () => { const n = 0.9995; - const r = await testContract.toInteger.callAsync(toFixed(n)); + const r = await testContract.toInteger(toFixed(n)).callAsync(); expect(r).to.bignumber.eq(0); }); it('toInteger(-n) == 0, when -1 < n < 0', async () => { const n = -0.9995; - const r = await testContract.toInteger.callAsync(toFixed(n)); + const r = await testContract.toInteger(toFixed(n)).callAsync(); expect(r).to.bignumber.eq(0); }); it('toInteger(0) == 0', async () => { const n = 0; - const r = await testContract.toInteger.callAsync(toFixed(n)); + const r = await testContract.toInteger(toFixed(n)).callAsync(); expect(r).to.bignumber.eq(0); }); }); @@ -686,37 +686,37 @@ blockchainTests('LibFixedMath unit tests', env => { describe('signed', () => { it('converts a positive integer', async () => { const n = 1337; - const r = await testContract.toFixedSigned1.callAsync(new BigNumber(n)); + const r = await testContract.toFixedSigned1(new BigNumber(n)).callAsync(); assertFixedEquals(r, n); }); it('converts a negative integer', async () => { const n = -1337; - const r = await testContract.toFixedSigned1.callAsync(new BigNumber(n)); + const r = await testContract.toFixedSigned1(new BigNumber(n)).callAsync(); assertFixedEquals(r, n); }); it('converts a fraction with a positive numerator and denominator', async () => { const [n, d] = [1337, 1000]; - const r = await testContract.toFixedSigned2.callAsync(new BigNumber(n), new BigNumber(d)); + const r = await testContract.toFixedSigned2(new BigNumber(n), new BigNumber(d)).callAsync(); assertFixedEquals(r, n / d); }); it('converts a fraction with a negative numerator and positive denominator', async () => { const [n, d] = [-1337, 1000]; - const r = await testContract.toFixedSigned2.callAsync(new BigNumber(n), new BigNumber(d)); + const r = await testContract.toFixedSigned2(new BigNumber(n), new BigNumber(d)).callAsync(); assertFixedEquals(r, n / d); }); it('converts a fraction with a negative numerator and denominator', async () => { const [n, d] = [-1337, -1000]; - const r = await testContract.toFixedSigned2.callAsync(new BigNumber(n), new BigNumber(d)); + const r = await testContract.toFixedSigned2(new BigNumber(n), new BigNumber(d)).callAsync(); assertFixedEquals(r, n / d); }); it('converts a fraction with a negative numerator and negative denominator', async () => { const [n, d] = [-1337, -1000]; - const r = await testContract.toFixedSigned2.callAsync(new BigNumber(n), new BigNumber(d)); + const r = await testContract.toFixedSigned2(new BigNumber(n), new BigNumber(d)).callAsync(); assertFixedEquals(r, n / d); }); @@ -727,7 +727,7 @@ blockchainTests('LibFixedMath unit tests', env => { n, FIXED_POINT_DIVISOR, ); - const tx = testContract.toFixedSigned2.callAsync(n, d); + const tx = testContract.toFixedSigned2(n, d).callAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -738,7 +738,7 @@ blockchainTests('LibFixedMath unit tests', env => { n.times(FIXED_POINT_DIVISOR), d, ); - const tx = testContract.toFixedSigned2.callAsync(n, d); + const tx = testContract.toFixedSigned2(n, d).callAsync(); return expect(tx).to.revertWith(expectedError); }); }); @@ -746,13 +746,13 @@ blockchainTests('LibFixedMath unit tests', env => { describe('unsigned', () => { it('converts an integer', async () => { const n = 1337; - const r = await testContract.toFixedUnsigned1.callAsync(new BigNumber(n)); + const r = await testContract.toFixedUnsigned1(new BigNumber(n)).callAsync(); assertFixedEquals(r, n); }); it('converts a fraction', async () => { const [n, d] = [1337, 1000]; - const r = await testContract.toFixedUnsigned2.callAsync(new BigNumber(n), new BigNumber(d)); + const r = await testContract.toFixedUnsigned2(new BigNumber(n), new BigNumber(d)).callAsync(); assertFixedEquals(r, n / d); }); @@ -762,7 +762,7 @@ blockchainTests('LibFixedMath unit tests', env => { FixedMathRevertErrors.ValueErrorCodes.TooLarge, n, ); - const tx = testContract.toFixedUnsigned2.callAsync(n, d); + const tx = testContract.toFixedUnsigned2(n, d).callAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -772,7 +772,7 @@ blockchainTests('LibFixedMath unit tests', env => { FixedMathRevertErrors.ValueErrorCodes.TooLarge, d, ); - const tx = testContract.toFixedUnsigned2.callAsync(n, d); + const tx = testContract.toFixedUnsigned2(n, d).callAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -783,7 +783,7 @@ blockchainTests('LibFixedMath unit tests', env => { n, FIXED_POINT_DIVISOR, ); - const tx = testContract.toFixedUnsigned2.callAsync(n, d); + const tx = testContract.toFixedUnsigned2(n, d).callAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -794,7 +794,7 @@ blockchainTests('LibFixedMath unit tests', env => { n.times(FIXED_POINT_DIVISOR), d, ); - const tx = testContract.toFixedUnsigned2.callAsync(n, d); + const tx = testContract.toFixedUnsigned2(n, d).callAsync(); return expect(tx).to.revertWith(expectedError); }); }); @@ -823,7 +823,7 @@ blockchainTests('LibFixedMath unit tests', env => { FixedMathRevertErrors.ValueErrorCodes.TooSmall, x, ); - const tx = testContract.ln.callAsync(x); + const tx = testContract.ln(x).callAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -833,7 +833,7 @@ blockchainTests('LibFixedMath unit tests', env => { FixedMathRevertErrors.ValueErrorCodes.TooLarge, x, ); - const tx = testContract.ln.callAsync(x); + const tx = testContract.ln(x).callAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -843,37 +843,37 @@ blockchainTests('LibFixedMath unit tests', env => { FixedMathRevertErrors.ValueErrorCodes.TooSmall, x, ); - const tx = testContract.ln.callAsync(x); + const tx = testContract.ln(x).callAsync(); return expect(tx).to.revertWith(expectedError); }); it('ln(x = 1) == 0', async () => { const x = toFixed(1); - const r = await testContract.ln.callAsync(x); + const r = await testContract.ln(x).callAsync(); assertFixedEquals(r, 0); }); it('ln(x < LN_MIN_VAL) == EXP_MIN_VAL', async () => { const x = toFixed(MIN_LN_NUMBER).minus(1); - const r = await testContract.ln.callAsync(x); + const r = await testContract.ln(x).callAsync(); assertFixedEquals(r, MIN_EXP_NUMBER); }); it('ln(x), where x is close to 0', async () => { const x = new BigNumber('1e-27'); - const r = await testContract.ln.callAsync(toFixed(x)); + const r = await testContract.ln(toFixed(x)).callAsync(); assertFixedRoughlyEquals(r, ln(x), 12); }); it('ln(x), where x is close to 1', async () => { const x = new BigNumber(1).minus('1e-27'); - const r = await testContract.ln.callAsync(toFixed(x)); + const r = await testContract.ln(toFixed(x)).callAsync(); assertFixedRoughlyEquals(r, ln(x), LN_PRECISION); }); it('ln(x = 0.85)', async () => { const x = 0.85; - const r = await testContract.ln.callAsync(toFixed(x)); + const r = await testContract.ln(toFixed(x)).callAsync(); assertFixedRoughlyEquals(r, ln(x), LN_PRECISION); }); @@ -881,7 +881,7 @@ blockchainTests('LibFixedMath unit tests', env => { const inputs = _.times(FUZZ_COUNT, () => getRandomDecimal(0, 1)); for (const x of inputs) { it(`ln(${x.toString(10)})`, async () => { - const r = await testContract.ln.callAsync(toFixed(x)); + const r = await testContract.ln(toFixed(x)).callAsync(); assertFixedRoughlyEquals(r, ln(x), LN_PRECISION); }); } @@ -901,7 +901,7 @@ blockchainTests('LibFixedMath unit tests', env => { it('exp(x = 0) == 1', async () => { const x = toFixed(0); - const r = await testContract.exp.callAsync(x); + const r = await testContract.exp(x).callAsync(); assertFixedEquals(r, 1); }); @@ -911,31 +911,31 @@ blockchainTests('LibFixedMath unit tests', env => { FixedMathRevertErrors.ValueErrorCodes.TooLarge, x, ); - const tx = testContract.exp.callAsync(x); + const tx = testContract.exp(x).callAsync(); return expect(tx).to.revertWith(expectedError); }); it('exp(x < EXP_MIN_VAL) == 0', async () => { const x = toFixed(MIN_EXP_NUMBER).minus(1); - const r = await testContract.exp.callAsync(x); + const r = await testContract.exp(x).callAsync(); assertFixedEquals(r, 0); }); it('exp(x < 0), where x is close to 0', async () => { const x = new BigNumber('-1e-18'); - const r = await testContract.exp.callAsync(toFixed(x)); + const r = await testContract.exp(toFixed(x)).callAsync(); assertFixedRoughlyEquals(r, exp(x), EXP_PRECISION); }); it('exp(x), where x is close to EXP_MIN_VAL', async () => { const x = MIN_EXP_NUMBER.plus('1e-18'); - const r = await testContract.exp.callAsync(toFixed(x)); + const r = await testContract.exp(toFixed(x)).callAsync(); assertFixedRoughlyEquals(r, exp(x), EXP_PRECISION); }); it('exp(x = -0.85)', async () => { const x = -0.85; - const r = await testContract.exp.callAsync(toFixed(x)); + const r = await testContract.exp(toFixed(x)).callAsync(); assertFixedRoughlyEquals(r, exp(x), EXP_PRECISION); }); @@ -943,7 +943,7 @@ blockchainTests('LibFixedMath unit tests', env => { const inputs = _.times(FUZZ_COUNT, () => getRandomDecimal(MIN_EXP_NUMBER, MAX_EXP_NUMBER)); for (const x of inputs) { it(`exp(${x.toString(10)})`, async () => { - const r = await testContract.exp.callAsync(toFixed(x)); + const r = await testContract.exp(toFixed(x)).callAsync(); assertFixedRoughlyEquals(r, exp(x), EXP_PRECISION); }); } diff --git a/contracts/staking/test/unit_tests/lib_safe_downcast_test.ts b/contracts/staking/test/unit_tests/lib_safe_downcast_test.ts index 9a3ac8931e..f296a21574 100644 --- a/contracts/staking/test/unit_tests/lib_safe_downcast_test.ts +++ b/contracts/staking/test/unit_tests/lib_safe_downcast_test.ts @@ -21,7 +21,7 @@ blockchainTests('LibSafeDowncast unit tests', env => { describe('downcastToUint96', () => { async function verifyCorrectDowncastAsync(n: Numberish): Promise { - const actual = await testContract.downcastToUint96.callAsync(new BigNumber(n)); + const actual = await testContract.downcastToUint96(new BigNumber(n)).callAsync(); expect(actual).to.bignumber.eq(n); } function toDowncastError(n: Numberish): SafeMathRevertErrors.Uint256DowncastError { @@ -52,7 +52,7 @@ blockchainTests('LibSafeDowncast unit tests', env => { describe('downcastToUint64', () => { async function verifyCorrectDowncastAsync(n: Numberish): Promise { - const actual = await testContract.downcastToUint64.callAsync(new BigNumber(n)); + const actual = await testContract.downcastToUint64(new BigNumber(n)).callAsync(); expect(actual).to.bignumber.eq(n); } function toDowncastError(n: Numberish): SafeMathRevertErrors.Uint256DowncastError { diff --git a/contracts/staking/test/unit_tests/mixin_cumulative_rewards_test.ts b/contracts/staking/test/unit_tests/mixin_cumulative_rewards_test.ts index 97dcb1753c..462bd10d4d 100644 --- a/contracts/staking/test/unit_tests/mixin_cumulative_rewards_test.ts +++ b/contracts/staking/test/unit_tests/mixin_cumulative_rewards_test.ts @@ -40,89 +40,79 @@ blockchainTests.resets('MixinCumulativeRewards unit tests', env => { // Create a test pool const operatorShare = new BigNumber(1); const addOperatorAsMaker = true; - const txReceipt = await testContract.createStakingPool.awaitTransactionSuccessAsync( - operatorShare, - addOperatorAsMaker, - ); + const txReceipt = await testContract + .createStakingPool(operatorShare, addOperatorAsMaker) + .awaitTransactionSuccessAsync(); const createStakingPoolLog = txReceipt.logs[0]; testPoolId = (createStakingPoolLog as any).args.poolId; }); describe('_isCumulativeRewardSet', () => { it('Should return true iff denominator is non-zero', async () => { - const isSet = await testContract.isCumulativeRewardSet.callAsync({ - numerator: ZERO, - denominator: new BigNumber(1), - }); + const isSet = await testContract + .isCumulativeRewardSet({ + numerator: ZERO, + denominator: new BigNumber(1), + }) + .callAsync(); expect(isSet).to.be.true(); }); it('Should return false iff denominator is zero', async () => { - const isSet = await testContract.isCumulativeRewardSet.callAsync({ - numerator: new BigNumber(1), - denominator: ZERO, - }); + const isSet = await testContract + .isCumulativeRewardSet({ + numerator: new BigNumber(1), + denominator: ZERO, + }) + .callAsync(); expect(isSet).to.be.false(); }); }); describe('_addCumulativeReward', () => { it('Should set value to `reward/stake` if this is the first cumulative reward', async () => { - await testContract.addCumulativeReward.awaitTransactionSuccessAsync( - testPoolId, - testRewards[0].numerator, - testRewards[0].denominator, - ); - const mostRecentCumulativeReward = await testContract.getMostRecentCumulativeReward.callAsync(testPoolId); + await testContract + .addCumulativeReward(testPoolId, testRewards[0].numerator, testRewards[0].denominator) + .awaitTransactionSuccessAsync(); + const mostRecentCumulativeReward = await testContract.getMostRecentCumulativeReward(testPoolId).callAsync(); expect(mostRecentCumulativeReward).to.deep.equal(testRewards[0]); }); it('Should do nothing if a cumulative reward has already been recorded in the current epoch (`lastStoredEpoch == currentEpoch_`)', async () => { - await testContract.addCumulativeReward.awaitTransactionSuccessAsync( - testPoolId, - testRewards[0].numerator, - testRewards[0].denominator, - ); + await testContract + .addCumulativeReward(testPoolId, testRewards[0].numerator, testRewards[0].denominator) + .awaitTransactionSuccessAsync(); // this call should not overwrite existing value (testRewards[0]) - await testContract.addCumulativeReward.awaitTransactionSuccessAsync( - testPoolId, - testRewards[1].numerator, - testRewards[1].denominator, - ); - const mostRecentCumulativeReward = await testContract.getMostRecentCumulativeReward.callAsync(testPoolId); + await testContract + .addCumulativeReward(testPoolId, testRewards[1].numerator, testRewards[1].denominator) + .awaitTransactionSuccessAsync(); + const mostRecentCumulativeReward = await testContract.getMostRecentCumulativeReward(testPoolId).callAsync(); expect(mostRecentCumulativeReward).to.deep.equal(testRewards[0]); }); it('Should set value to normalized sum of `reward/stake` plus most recent cumulative reward, given one exists', async () => { - await testContract.addCumulativeReward.awaitTransactionSuccessAsync( - testPoolId, - testRewards[0].numerator, - testRewards[0].denominator, - ); - await testContract.incrementEpoch.awaitTransactionSuccessAsync(); - await testContract.addCumulativeReward.awaitTransactionSuccessAsync( - testPoolId, - testRewards[1].numerator, - testRewards[1].denominator, - ); - const mostRecentCumulativeReward = await testContract.getMostRecentCumulativeReward.callAsync(testPoolId); + await testContract + .addCumulativeReward(testPoolId, testRewards[0].numerator, testRewards[0].denominator) + .awaitTransactionSuccessAsync(); + await testContract.incrementEpoch().awaitTransactionSuccessAsync(); + await testContract + .addCumulativeReward(testPoolId, testRewards[1].numerator, testRewards[1].denominator) + .awaitTransactionSuccessAsync(); + const mostRecentCumulativeReward = await testContract.getMostRecentCumulativeReward(testPoolId).callAsync(); expect(mostRecentCumulativeReward).to.deep.equal(sumOfTestRewardsNormalized); }); }); describe('_updateCumulativeReward', () => { it('Should set current cumulative reward to most recent cumulative reward', async () => { - await testContract.addCumulativeReward.awaitTransactionSuccessAsync( - testPoolId, - testRewards[0].numerator, - testRewards[0].denominator, - ); - await testContract.incrementEpoch.awaitTransactionSuccessAsync(); - await testContract.updateCumulativeReward.awaitTransactionSuccessAsync(testPoolId); + await testContract + .addCumulativeReward(testPoolId, testRewards[0].numerator, testRewards[0].denominator) + .awaitTransactionSuccessAsync(); + await testContract.incrementEpoch().awaitTransactionSuccessAsync(); + await testContract.updateCumulativeReward(testPoolId).awaitTransactionSuccessAsync(); const epoch = new BigNumber(2); - const mostRecentCumulativeReward = await testContract.getCumulativeRewardAtEpochRaw.callAsync( - testPoolId, - epoch, - ); + const mostRecentCumulativeReward = await testContract + .getCumulativeRewardAtEpochRaw(testPoolId, epoch) + .callAsync(); expect(mostRecentCumulativeReward).to.deep.equal(testRewards[0]); }); }); @@ -136,22 +126,15 @@ blockchainTests.resets('MixinCumulativeRewards unit tests', env => { epochOfIntervalEnd: BigNumber, ): Promise => { // Simulate earning reward - await testContract.storeCumulativeReward.awaitTransactionSuccessAsync( - testPoolId, - testRewards[0], - epochOfFirstReward, - ); - await testContract.storeCumulativeReward.awaitTransactionSuccessAsync( - testPoolId, - sumOfTestRewardsNormalized, - epochOfSecondReward, - ); - const reward = await testContract.computeMemberRewardOverInterval.callAsync( - testPoolId, - amountToStake, - epochOfIntervalStart, - epochOfIntervalEnd, - ); + await testContract + .storeCumulativeReward(testPoolId, testRewards[0], epochOfFirstReward) + .awaitTransactionSuccessAsync(); + await testContract + .storeCumulativeReward(testPoolId, sumOfTestRewardsNormalized, epochOfSecondReward) + .awaitTransactionSuccessAsync(); + const reward = await testContract + .computeMemberRewardOverInterval(testPoolId, amountToStake, epochOfIntervalStart, epochOfIntervalEnd) + .callAsync(); // Compute expected reward const lhs = sumOfTestRewardsNormalized.numerator.dividedBy(sumOfTestRewardsNormalized.denominator); const rhs = testRewards[0].numerator.dividedBy(testRewards[0].denominator); @@ -212,12 +195,9 @@ blockchainTests.resets('MixinCumulativeRewards unit tests', env => { const stake = toBaseUnitAmount(1); const beginEpoch = new BigNumber(1); const endEpoch = new BigNumber(2); - const reward = await testContract.computeMemberRewardOverInterval.callAsync( - testPoolId, - stake, - beginEpoch, - endEpoch, - ); + const reward = await testContract + .computeMemberRewardOverInterval(testPoolId, stake, beginEpoch, endEpoch) + .callAsync(); expect(reward).to.bignumber.equal(ZERO); }); @@ -225,12 +205,9 @@ blockchainTests.resets('MixinCumulativeRewards unit tests', env => { const stake = toBaseUnitAmount(0); const beginEpoch = new BigNumber(1); const endEpoch = new BigNumber(2); - const reward = await testContract.computeMemberRewardOverInterval.callAsync( - testPoolId, - stake, - beginEpoch, - endEpoch, - ); + const reward = await testContract + .computeMemberRewardOverInterval(testPoolId, stake, beginEpoch, endEpoch) + .callAsync(); expect(reward).to.bignumber.equal(ZERO); }); @@ -238,12 +215,9 @@ blockchainTests.resets('MixinCumulativeRewards unit tests', env => { const stake = toBaseUnitAmount(1); const beginEpoch = new BigNumber(1); const endEpoch = new BigNumber(1); - const reward = await testContract.computeMemberRewardOverInterval.callAsync( - testPoolId, - stake, - beginEpoch, - endEpoch, - ); + const reward = await testContract + .computeMemberRewardOverInterval(testPoolId, stake, beginEpoch, endEpoch) + .callAsync(); expect(reward).to.bignumber.equal(ZERO); }); @@ -251,7 +225,9 @@ blockchainTests.resets('MixinCumulativeRewards unit tests', env => { const stake = toBaseUnitAmount(1); const beginEpoch = new BigNumber(2); const endEpoch = new BigNumber(1); - const tx = testContract.computeMemberRewardOverInterval.callAsync(testPoolId, stake, beginEpoch, endEpoch); + const tx = testContract + .computeMemberRewardOverInterval(testPoolId, stake, beginEpoch, endEpoch) + .callAsync(); return expect(tx).to.revertWith('CR_INTERVAL_INVALID'); }); }); diff --git a/contracts/staking/test/unit_tests/mixin_scheduler_test.ts b/contracts/staking/test/unit_tests/mixin_scheduler_test.ts index b8e49225b8..444109f3d2 100644 --- a/contracts/staking/test/unit_tests/mixin_scheduler_test.ts +++ b/contracts/staking/test/unit_tests/mixin_scheduler_test.ts @@ -29,10 +29,12 @@ blockchainTests.resets('MixinScheduler unit tests', env => { describe('getCurrentEpochEarliestEndTimeInSeconds', () => { it('Should return the sum of `epoch start time + epoch duration`', async () => { - const testDeployedTimestamp = await testContract.testDeployedTimestamp.callAsync(); - const epochDurationInSeconds = await testContract.epochDurationInSeconds.callAsync(); + const testDeployedTimestamp = await testContract.testDeployedTimestamp().callAsync(); + const epochDurationInSeconds = await testContract.epochDurationInSeconds().callAsync(); const expectedCurrentEpochEarliestEndTimeInSeconds = testDeployedTimestamp.plus(epochDurationInSeconds); - const currentEpochEarliestEndTimeInSeconds = await testContract.getCurrentEpochEarliestEndTimeInSeconds.callAsync(); + const currentEpochEarliestEndTimeInSeconds = await testContract + .getCurrentEpochEarliestEndTimeInSeconds() + .callAsync(); expect(currentEpochEarliestEndTimeInSeconds).to.bignumber.equal( expectedCurrentEpochEarliestEndTimeInSeconds, ); @@ -42,23 +44,23 @@ blockchainTests.resets('MixinScheduler unit tests', env => { describe('_initMixinScheduler', () => { it('Should succeed if scheduler is not yet initialized (`currentEpochStartTimeInSeconds == 0`)', async () => { const initCurrentEpochStartTimeInSeconds = constants.ZERO_AMOUNT; - const txReceipt = await testContract.initMixinSchedulerTest.awaitTransactionSuccessAsync( - initCurrentEpochStartTimeInSeconds, - ); + const txReceipt = await testContract + .initMixinSchedulerTest(initCurrentEpochStartTimeInSeconds) + .awaitTransactionSuccessAsync(); // Assert `currentEpochStartTimeInSeconds` was properly initialized const blockTimestamp = await env.web3Wrapper.getBlockTimestampAsync(txReceipt.blockNumber); - const currentEpochStartTimeInSeconds = await testContract.currentEpochStartTimeInSeconds.callAsync(); + const currentEpochStartTimeInSeconds = await testContract.currentEpochStartTimeInSeconds().callAsync(); expect(currentEpochStartTimeInSeconds).to.bignumber.equal(blockTimestamp); // Assert `currentEpoch` was properly initialized - const currentEpoch = await testContract.currentEpoch.callAsync(); + const currentEpoch = await testContract.currentEpoch().callAsync(); expect(currentEpoch).to.bignumber.equal(1); }); it('Should revert if scheduler is already initialized (`currentEpochStartTimeInSeconds != 0`)', async () => { const initCurrentEpochStartTimeInSeconds = new BigNumber(10); - const tx = testContract.initMixinSchedulerTest.awaitTransactionSuccessAsync( - initCurrentEpochStartTimeInSeconds, - ); + const tx = testContract + .initMixinSchedulerTest(initCurrentEpochStartTimeInSeconds) + .awaitTransactionSuccessAsync(); return expect(tx).to.revertWith( new StakingRevertErrors.InitializationError( StakingRevertErrors.InitializationErrorCodes.MixinSchedulerAlreadyInitialized, @@ -70,9 +72,9 @@ blockchainTests.resets('MixinScheduler unit tests', env => { describe('_goToNextEpoch', () => { it('Should succeed if epoch end time is strictly less than to block timestamp', async () => { const epochEndTimeDelta = new BigNumber(-10); - const txReceipt = await testContract.goToNextEpochTest.awaitTransactionSuccessAsync(epochEndTimeDelta); - const currentEpoch = await testContract.currentEpoch.callAsync(); - const currentEpochStartTimeInSeconds = await testContract.currentEpochStartTimeInSeconds.callAsync(); + const txReceipt = await testContract.goToNextEpochTest(epochEndTimeDelta).awaitTransactionSuccessAsync(); + const currentEpoch = await testContract.currentEpoch().callAsync(); + const currentEpochStartTimeInSeconds = await testContract.currentEpochStartTimeInSeconds().callAsync(); verifyEventsFromLogs( txReceipt.logs, [ @@ -87,20 +89,20 @@ blockchainTests.resets('MixinScheduler unit tests', env => { it('Should succeed if epoch end time is equal to block timestamp', async () => { const epochEndTimeDelta = constants.ZERO_AMOUNT; - const txReceipt = await testContract.goToNextEpochTest.awaitTransactionSuccessAsync(epochEndTimeDelta); + const txReceipt = await testContract.goToNextEpochTest(epochEndTimeDelta).awaitTransactionSuccessAsync(); // tslint:disable-next-line no-unnecessary-type-assertion const testLog: TestMixinSchedulerGoToNextEpochTestInfoEventArgs = (txReceipt.logs[0] as LogWithDecodedArgs< TestMixinSchedulerGoToNextEpochTestInfoEventArgs >).args; - const currentEpoch = await testContract.currentEpoch.callAsync(); - const currentEpochStartTimeInSeconds = await testContract.currentEpochStartTimeInSeconds.callAsync(); + const currentEpoch = await testContract.currentEpoch().callAsync(); + const currentEpochStartTimeInSeconds = await testContract.currentEpochStartTimeInSeconds().callAsync(); expect(currentEpoch).to.bignumber.equal(testLog.oldEpoch.plus(1)); expect(currentEpochStartTimeInSeconds).to.bignumber.equal(testLog.blockTimestamp); }); it('Should revert if epoch end time is strictly greater than block timestamp', async () => { const epochEndTimeDelta = new BigNumber(10); - const tx = testContract.goToNextEpochTest.awaitTransactionSuccessAsync(epochEndTimeDelta); + const tx = testContract.goToNextEpochTest(epochEndTimeDelta).awaitTransactionSuccessAsync(); return expect(tx).to.revertWith(new StakingRevertErrors.BlockTimestampTooLowError()); }); }); diff --git a/contracts/staking/test/unit_tests/mixin_stake_storage_test.ts b/contracts/staking/test/unit_tests/mixin_stake_storage_test.ts index 066e4077a4..ed4b57f6c9 100644 --- a/contracts/staking/test/unit_tests/mixin_stake_storage_test.ts +++ b/contracts/staking/test/unit_tests/mixin_stake_storage_test.ts @@ -24,7 +24,7 @@ blockchainTests.resets('MixinStakeStorage unit tests', env => { env.txDefaults, artifacts, ); - await testContract.setCurrentEpoch.awaitTransactionSuccessAsync(CURRENT_EPOCH); + await testContract.setCurrentEpoch(CURRENT_EPOCH).awaitTransactionSuccessAsync(); defaultUninitializedBalance = { currentEpoch: constants.INITIAL_EPOCH, currentEpochBalance: new BigNumber(0), @@ -48,7 +48,7 @@ blockchainTests.resets('MixinStakeStorage unit tests', env => { storedBalance.currentEpoch, storedBalance.currentEpochBalance, storedBalance.nextEpochBalance, - ] = await testContract.testBalances.callAsync(new BigNumber(index)); + ] = await testContract.testBalances(new BigNumber(index)).callAsync(); return storedBalance as StoredBalance; } @@ -58,9 +58,9 @@ blockchainTests.resets('MixinStakeStorage unit tests', env => { toBalance: StoredBalance, amount: BigNumber, ): Promise { - await testContract.setStoredBalance.awaitTransactionSuccessAsync(fromBalance, INDEX_ZERO); - await testContract.setStoredBalance.awaitTransactionSuccessAsync(toBalance, INDEX_ONE); - await testContract.moveStake.awaitTransactionSuccessAsync(INDEX_ZERO, INDEX_ONE, amount); + await testContract.setStoredBalance(fromBalance, INDEX_ZERO).awaitTransactionSuccessAsync(); + await testContract.setStoredBalance(toBalance, INDEX_ONE).awaitTransactionSuccessAsync(); + await testContract.moveStake(INDEX_ZERO, INDEX_ONE, amount).awaitTransactionSuccessAsync(); const actualBalances = await Promise.all([ getTestBalancesAsync(INDEX_ZERO), @@ -100,20 +100,18 @@ blockchainTests.resets('MixinStakeStorage unit tests', env => { ); }); it('Noop if pointers are equal', async () => { - await testContract.setStoredBalance.awaitTransactionSuccessAsync(defaultSyncedBalance, INDEX_ZERO); + await testContract.setStoredBalance(defaultSyncedBalance, INDEX_ZERO).awaitTransactionSuccessAsync(); // If the pointers weren't equal, this would revert with InsufficientBalanceError - await testContract.moveStake.awaitTransactionSuccessAsync( - INDEX_ZERO, - INDEX_ZERO, - defaultSyncedBalance.nextEpochBalance.plus(1), - ); + await testContract + .moveStake(INDEX_ZERO, INDEX_ZERO, defaultSyncedBalance.nextEpochBalance.plus(1)) + .awaitTransactionSuccessAsync(); const actualBalance = await getTestBalancesAsync(INDEX_ZERO); expect(actualBalance).to.deep.equal(defaultSyncedBalance); }); it("Reverts if attempting to move more than next epoch's balance", async () => { - await testContract.setStoredBalance.awaitTransactionSuccessAsync(defaultSyncedBalance, INDEX_ZERO); + await testContract.setStoredBalance(defaultSyncedBalance, INDEX_ZERO).awaitTransactionSuccessAsync(); const amount = defaultSyncedBalance.nextEpochBalance.plus(1); - const tx = testContract.moveStake.awaitTransactionSuccessAsync(INDEX_ZERO, INDEX_ONE, amount); + const tx = testContract.moveStake(INDEX_ZERO, INDEX_ONE, amount).awaitTransactionSuccessAsync(); await expect(tx).to.revertWith( new StakingRevertErrors.InsufficientBalanceError(amount, defaultSyncedBalance.nextEpochBalance), ); @@ -122,32 +120,32 @@ blockchainTests.resets('MixinStakeStorage unit tests', env => { describe('Load balance', () => { it('Balance does not change state if balance was previously synced in the current epoch', async () => { - await testContract.setStoredBalance.awaitTransactionSuccessAsync(defaultSyncedBalance, INDEX_ZERO); - const actualBalance = await testContract.loadCurrentBalance.callAsync(INDEX_ZERO); + await testContract.setStoredBalance(defaultSyncedBalance, INDEX_ZERO).awaitTransactionSuccessAsync(); + const actualBalance = await testContract.loadCurrentBalance(INDEX_ZERO).callAsync(); expect(actualBalance).to.deep.equal(defaultSyncedBalance); }); it('Balance updates current epoch fields if the balance has not yet been synced in the current epoch', async () => { - await testContract.setStoredBalance.awaitTransactionSuccessAsync(defaultUnsyncedBalance, INDEX_ZERO); - const actualBalance = await testContract.loadCurrentBalance.callAsync(INDEX_ZERO); + await testContract.setStoredBalance(defaultUnsyncedBalance, INDEX_ZERO).awaitTransactionSuccessAsync(); + const actualBalance = await testContract.loadCurrentBalance(INDEX_ZERO).callAsync(); expect(actualBalance).to.deep.equal(defaultSyncedBalance); }); it('Balance loads unsynced balance from storage without changing fields', async () => { - await testContract.setStoredBalance.awaitTransactionSuccessAsync(defaultUnsyncedBalance, INDEX_ZERO); - const actualBalance = await testContract.loadStaleBalance.callAsync(INDEX_ZERO); + await testContract.setStoredBalance(defaultUnsyncedBalance, INDEX_ZERO).awaitTransactionSuccessAsync(); + const actualBalance = await testContract.loadStaleBalance(INDEX_ZERO).callAsync(); expect(actualBalance).to.deep.equal(defaultUnsyncedBalance); }); it('Balance loads synced balance from storage without changing fields', async () => { - await testContract.setStoredBalance.awaitTransactionSuccessAsync(defaultSyncedBalance, INDEX_ZERO); - const actualBalance = await testContract.loadStaleBalance.callAsync(INDEX_ZERO); + await testContract.setStoredBalance(defaultSyncedBalance, INDEX_ZERO).awaitTransactionSuccessAsync(); + const actualBalance = await testContract.loadStaleBalance(INDEX_ZERO).callAsync(); expect(actualBalance).to.deep.equal(defaultSyncedBalance); }); }); describe('Increase/decrease balance', () => { it('_increaseCurrentAndNextBalance', async () => { - await testContract.setStoredBalance.awaitTransactionSuccessAsync(defaultUnsyncedBalance, INDEX_ZERO); + await testContract.setStoredBalance(defaultUnsyncedBalance, INDEX_ZERO).awaitTransactionSuccessAsync(); const amount = defaultUnsyncedBalance.currentEpochBalance.dividedToIntegerBy(2); - await testContract.increaseCurrentAndNextBalance.awaitTransactionSuccessAsync(INDEX_ZERO, amount); + await testContract.increaseCurrentAndNextBalance(INDEX_ZERO, amount).awaitTransactionSuccessAsync(); const actualBalance = await getTestBalancesAsync(INDEX_ZERO); expect(actualBalance).to.deep.equal({ ...defaultSyncedBalance, @@ -156,16 +154,16 @@ blockchainTests.resets('MixinStakeStorage unit tests', env => { }); }); it('_increaseCurrentAndNextBalance (previously uninitialized)', async () => { - await testContract.setStoredBalance.awaitTransactionSuccessAsync(defaultUninitializedBalance, INDEX_ZERO); + await testContract.setStoredBalance(defaultUninitializedBalance, INDEX_ZERO).awaitTransactionSuccessAsync(); const amount = defaultSyncedBalance.currentEpochBalance; - await testContract.increaseCurrentAndNextBalance.awaitTransactionSuccessAsync(INDEX_ZERO, amount); + await testContract.increaseCurrentAndNextBalance(INDEX_ZERO, amount).awaitTransactionSuccessAsync(); const actualBalance = await getTestBalancesAsync(INDEX_ZERO); expect(actualBalance).to.deep.equal(defaultSyncedBalance); }); it('_decreaseCurrentAndNextBalance', async () => { - await testContract.setStoredBalance.awaitTransactionSuccessAsync(defaultUnsyncedBalance, INDEX_ZERO); + await testContract.setStoredBalance(defaultUnsyncedBalance, INDEX_ZERO).awaitTransactionSuccessAsync(); const amount = defaultUnsyncedBalance.currentEpochBalance.dividedToIntegerBy(2); - await testContract.decreaseCurrentAndNextBalance.awaitTransactionSuccessAsync(INDEX_ZERO, amount); + await testContract.decreaseCurrentAndNextBalance(INDEX_ZERO, amount).awaitTransactionSuccessAsync(); const actualBalance = await getTestBalancesAsync(INDEX_ZERO); expect(actualBalance).to.deep.equal({ ...defaultSyncedBalance, @@ -174,9 +172,9 @@ blockchainTests.resets('MixinStakeStorage unit tests', env => { }); }); it('_increaseNextBalance', async () => { - await testContract.setStoredBalance.awaitTransactionSuccessAsync(defaultUnsyncedBalance, INDEX_ZERO); + await testContract.setStoredBalance(defaultUnsyncedBalance, INDEX_ZERO).awaitTransactionSuccessAsync(); const amount = defaultUnsyncedBalance.currentEpochBalance.dividedToIntegerBy(2); - await testContract.increaseNextBalance.awaitTransactionSuccessAsync(INDEX_ZERO, amount); + await testContract.increaseNextBalance(INDEX_ZERO, amount).awaitTransactionSuccessAsync(); const actualBalance = await getTestBalancesAsync(INDEX_ZERO); expect(actualBalance).to.deep.equal({ ...defaultSyncedBalance, @@ -184,9 +182,9 @@ blockchainTests.resets('MixinStakeStorage unit tests', env => { }); }); it('_increaseCurrentAndNextBalance (previously uninitialized)', async () => { - await testContract.setStoredBalance.awaitTransactionSuccessAsync(defaultUninitializedBalance, INDEX_ZERO); + await testContract.setStoredBalance(defaultUninitializedBalance, INDEX_ZERO).awaitTransactionSuccessAsync(); const amount = defaultSyncedBalance.currentEpochBalance; - await testContract.increaseNextBalance.awaitTransactionSuccessAsync(INDEX_ZERO, amount); + await testContract.increaseNextBalance(INDEX_ZERO, amount).awaitTransactionSuccessAsync(); const actualBalance = await getTestBalancesAsync(INDEX_ZERO); expect(actualBalance).to.deep.equal({ ...defaultSyncedBalance, @@ -194,9 +192,9 @@ blockchainTests.resets('MixinStakeStorage unit tests', env => { }); }); it('_decreaseNextBalance', async () => { - await testContract.setStoredBalance.awaitTransactionSuccessAsync(defaultUnsyncedBalance, INDEX_ZERO); + await testContract.setStoredBalance(defaultUnsyncedBalance, INDEX_ZERO).awaitTransactionSuccessAsync(); const amount = defaultUnsyncedBalance.currentEpochBalance.dividedToIntegerBy(2); - await testContract.decreaseNextBalance.awaitTransactionSuccessAsync(INDEX_ZERO, amount); + await testContract.decreaseNextBalance(INDEX_ZERO, amount).awaitTransactionSuccessAsync(); const actualBalance = await getTestBalancesAsync(INDEX_ZERO); expect(actualBalance).to.deep.equal({ ...defaultSyncedBalance, diff --git a/contracts/staking/test/unit_tests/mixin_staking_pool_rewards.ts b/contracts/staking/test/unit_tests/mixin_staking_pool_rewards.ts index 88e344f3be..2dc4580a35 100644 --- a/contracts/staking/test/unit_tests/mixin_staking_pool_rewards.ts +++ b/contracts/staking/test/unit_tests/mixin_staking_pool_rewards.ts @@ -8,7 +8,7 @@ import { hexRandom, Numberish, randomAddress, - TransactionHelper, + transactionHelper, verifyEventsFromLogs, } from '@0x/contracts-test-utils'; import { BigNumber } from '@0x/utils'; @@ -20,7 +20,6 @@ import { artifacts, TestMixinStakingPoolRewardsContract, TestMixinStakingPoolRew blockchainTests.resets('MixinStakingPoolRewards unit tests', env => { let testContract: TestMixinStakingPoolRewardsContract; - let txHelper: TransactionHelper; const POOL_ID = hexRandom(); const OPERATOR = randomAddress(); @@ -34,12 +33,13 @@ blockchainTests.resets('MixinStakingPoolRewards unit tests', env => { env.txDefaults, artifacts, ); - await testContract.setPool.awaitTransactionSuccessAsync(POOL_ID, { - operator: OPERATOR, - operatorShare: OPERATOR_SHARE, - }); + await testContract + .setPool(POOL_ID, { + operator: OPERATOR, + operatorShare: OPERATOR_SHARE, + }) + .awaitTransactionSuccessAsync(); [caller] = await env.getAccountAddressesAsync(); - txHelper = new TransactionHelper(env.web3Wrapper, artifacts); }); async function setUnfinalizedPoolRewardsAsync( @@ -47,11 +47,9 @@ blockchainTests.resets('MixinStakingPoolRewards unit tests', env => { reward: Numberish, membersStake: Numberish, ): Promise { - await testContract.setUnfinalizedPoolRewards.awaitTransactionSuccessAsync( - poolId, - new BigNumber(reward), - new BigNumber(membersStake), - ); + await testContract + .setUnfinalizedPoolRewards(poolId, new BigNumber(reward), new BigNumber(membersStake)) + .awaitTransactionSuccessAsync(); } // Set the delegated stake of a delegator in a pool. @@ -67,11 +65,13 @@ blockchainTests.resets('MixinStakingPoolRewards unit tests', env => { nextEpochBalance: getRandomInteger(1, 1e18), ...stake, }; - await testContract.setDelegatedStakeToPoolByOwner.awaitTransactionSuccessAsync(delegator, poolId, { - currentEpoch: _stake.currentEpoch, - currentEpochBalance: _stake.currentEpochBalance, - nextEpochBalance: _stake.nextEpochBalance, - }); + await testContract + .setDelegatedStakeToPoolByOwner(delegator, poolId, { + currentEpoch: _stake.currentEpoch, + currentEpochBalance: _stake.currentEpochBalance, + nextEpochBalance: _stake.nextEpochBalance, + }) + .awaitTransactionSuccessAsync(); return _stake; } @@ -82,25 +82,29 @@ blockchainTests.resets('MixinStakingPoolRewards unit tests', env => { delegator: string, finalizedReward?: Numberish, ): Promise { - const stake = await testContract.delegatedStakeToPoolByOwner.callAsync(delegator, poolId); + const stake = await testContract.delegatedStakeToPoolByOwner(delegator, poolId).callAsync(); // Split the rewards up across the two calls to `_computeMemberRewardOverInterval()` const reward = finalizedReward === undefined ? getRandomInteger(1, 1e18) : new BigNumber(finalizedReward); const oldRewards = getRandomPortion(reward); - await testContract.setMemberRewardsOverInterval.awaitTransactionSuccessAsync( - poolId, - stake.currentEpochBalance, - stake.currentEpoch, - stake.currentEpoch.plus(1), - oldRewards, - ); + await testContract + .setMemberRewardsOverInterval( + poolId, + stake.currentEpochBalance, + stake.currentEpoch, + stake.currentEpoch.plus(1), + oldRewards, + ) + .awaitTransactionSuccessAsync(); const newRewards = reward.minus(oldRewards); - await testContract.setMemberRewardsOverInterval.awaitTransactionSuccessAsync( - poolId, - stake.nextEpochBalance, - stake.currentEpoch.plus(1), - await testContract.currentEpoch.callAsync(), - newRewards, - ); + await testContract + .setMemberRewardsOverInterval( + poolId, + stake.nextEpochBalance, + stake.currentEpoch.plus(1), + await testContract.currentEpoch().callAsync(), + newRewards, + ) + .awaitTransactionSuccessAsync(); return reward; } @@ -118,7 +122,7 @@ blockchainTests.resets('MixinStakingPoolRewards unit tests', env => { describe('withdrawDelegatorRewards()', () => { it('calls `_withdrawAndSyncDelegatorRewards()` with the sender as the member', async () => { - const { logs } = await testContract.withdrawDelegatorRewards.awaitTransactionSuccessAsync(POOL_ID); + const { logs } = await testContract.withdrawDelegatorRewards(POOL_ID).awaitTransactionSuccessAsync(); verifyEventsFromLogs( logs, [{ poolId: POOL_ID, delegator: caller }], @@ -135,14 +139,14 @@ blockchainTests.resets('MixinStakingPoolRewards unit tests', env => { before(async () => { stake = await setStakeAsync(POOL_ID, DELEGATOR); - await testContract.setPoolRewards.awaitTransactionSuccessAsync(POOL_ID, POOL_REWARD); - await testContract.setWethReservedForPoolRewards.awaitTransactionSuccessAsync( - WETH_RESERVED_FOR_POOL_REWARDS, - ); + await testContract.setPoolRewards(POOL_ID, POOL_REWARD).awaitTransactionSuccessAsync(); + await testContract + .setWethReservedForPoolRewards(WETH_RESERVED_FOR_POOL_REWARDS) + .awaitTransactionSuccessAsync(); }); async function withdrawAndSyncDelegatorRewardsAsync(): Promise { - return testContract.withdrawAndSyncDelegatorRewards.awaitTransactionSuccessAsync(POOL_ID, DELEGATOR); + return testContract.withdrawAndSyncDelegatorRewards(POOL_ID, DELEGATOR).awaitTransactionSuccessAsync(); } it('reverts if the pool is not finalized', async () => { @@ -168,20 +172,20 @@ blockchainTests.resets('MixinStakingPoolRewards unit tests', env => { const finalizedReward = getRandomPortion(POOL_REWARD); await setComputeDelegatorRewardStateAsync(POOL_ID, DELEGATOR, finalizedReward); await withdrawAndSyncDelegatorRewardsAsync(); - const poolReward = await testContract.rewardsByPoolId.callAsync(POOL_ID); + const poolReward = await testContract.rewardsByPoolId(POOL_ID).callAsync(); expect(poolReward).to.bignumber.eq(POOL_REWARD.minus(finalizedReward)); }); it('reduces `wethReservedForPoolRewards` for the pool', async () => { const finalizedReward = getRandomPortion(POOL_REWARD); await setComputeDelegatorRewardStateAsync(POOL_ID, DELEGATOR, finalizedReward); await withdrawAndSyncDelegatorRewardsAsync(); - const wethReserved = await testContract.wethReservedForPoolRewards.callAsync(); + const wethReserved = await testContract.wethReservedForPoolRewards().callAsync(); expect(wethReserved).to.bignumber.eq(WETH_RESERVED_FOR_POOL_REWARDS.minus(finalizedReward)); }); it('syncs `_delegatedStakeToPoolByOwner`', async () => { await setComputeDelegatorRewardStateAsync(POOL_ID, DELEGATOR, getRandomPortion(POOL_REWARD)); await withdrawAndSyncDelegatorRewardsAsync(); - const stakeAfter = await testContract.delegatedStakeToPoolByOwner.callAsync(DELEGATOR, POOL_ID); + const stakeAfter = await testContract.delegatedStakeToPoolByOwner(DELEGATOR, POOL_ID).callAsync(); // `_loadCurrentBalance` is overridden to just increment `currentEpoch`. expect(stakeAfter).to.deep.eq({ currentEpoch: stake.currentEpoch.plus(1), @@ -197,7 +201,7 @@ blockchainTests.resets('MixinStakingPoolRewards unit tests', env => { it('no rewards if the delegated stake epoch == current epoch', async () => { // Set some finalized rewards that should be ignored. await setComputeDelegatorRewardStateAsync(POOL_ID, DELEGATOR, getRandomInteger(1, POOL_REWARD)); - await testContract.setCurrentEpoch.awaitTransactionSuccessAsync(stake.currentEpoch); + await testContract.setCurrentEpoch(stake.currentEpoch).awaitTransactionSuccessAsync(); const { logs } = await withdrawAndSyncDelegatorRewardsAsync(); // There will be no Transfer events if computed rewards are zero. verifyEventsFromLogs(logs, [], Events.Transfer); @@ -206,7 +210,7 @@ blockchainTests.resets('MixinStakingPoolRewards unit tests', env => { describe('computeRewardBalanceOfOperator()', () => { async function computeRewardBalanceOfOperatorAsync(): Promise { - return testContract.computeRewardBalanceOfOperator.callAsync(POOL_ID); + return testContract.computeRewardBalanceOfOperator(POOL_ID).callAsync(); } it('returns only unfinalized rewards', async () => { @@ -238,19 +242,23 @@ blockchainTests.resets('MixinStakingPoolRewards unit tests', env => { expect(reward).to.bignumber.eq(unfinalizedReward); }); it('returns no reward if operator share is zero', async () => { - await testContract.setPool.awaitTransactionSuccessAsync(POOL_ID, { - operator: OPERATOR, - operatorShare: constants.ZERO_AMOUNT, - }); + await testContract + .setPool(POOL_ID, { + operator: OPERATOR, + operatorShare: constants.ZERO_AMOUNT, + }) + .awaitTransactionSuccessAsync(); await setUnfinalizedPoolRewardsAsync(POOL_ID, getRandomInteger(1, 1e18), getRandomInteger(1, 1e18)); const reward = await computeRewardBalanceOfOperatorAsync(); expect(reward).to.bignumber.eq(0); }); it('returns all unfinalized reward if operator share is 100%', async () => { - await testContract.setPool.awaitTransactionSuccessAsync(POOL_ID, { - operator: OPERATOR, - operatorShare: constants.PPM_100_PERCENT, - }); + await testContract + .setPool(POOL_ID, { + operator: OPERATOR, + operatorShare: constants.PPM_100_PERCENT, + }) + .awaitTransactionSuccessAsync(); const unfinalizedReward = getRandomInteger(1, 1e18); await setUnfinalizedPoolRewardsAsync(POOL_ID, unfinalizedReward, getRandomInteger(1, 1e18)); const reward = await computeRewardBalanceOfOperatorAsync(); @@ -264,12 +272,12 @@ blockchainTests.resets('MixinStakingPoolRewards unit tests', env => { let stake: StoredBalance; before(async () => { - currentEpoch = await testContract.currentEpoch.callAsync(); + currentEpoch = await testContract.currentEpoch().callAsync(); stake = await setStakeAsync(POOL_ID, DELEGATOR); }); async function computeRewardBalanceOfDelegatorAsync(): Promise { - return testContract.computeRewardBalanceOfDelegator.callAsync(POOL_ID, DELEGATOR); + return testContract.computeRewardBalanceOfDelegator(POOL_ID, DELEGATOR).callAsync(); } function getDelegatorPortionOfUnfinalizedReward( @@ -315,7 +323,7 @@ blockchainTests.resets('MixinStakingPoolRewards unit tests', env => { currentEpoch: new BigNumber(epoch - 2), nextEpochBalance: constants.ZERO_AMOUNT, }); - await testContract.setCurrentEpoch.awaitTransactionSuccessAsync(new BigNumber(epoch)); + await testContract.setCurrentEpoch(new BigNumber(epoch)).awaitTransactionSuccessAsync(); await setUnfinalizedPoolRewardsAsync(POOL_ID, getRandomInteger(1, 1e18), getRandomInteger(1, 1e18)); const reward = await computeRewardBalanceOfDelegatorAsync(); expect(reward).to.bignumber.eq(0); @@ -347,17 +355,17 @@ blockchainTests.resets('MixinStakingPoolRewards unit tests', env => { const WETH_RESERVED_FOR_POOL_REWARDS = POOL_REWARD.plus(getRandomInteger(1, 100e18)); before(async () => { - await testContract.setPoolRewards.awaitTransactionSuccessAsync(POOL_ID, POOL_REWARD); - await testContract.setWethReservedForPoolRewards.awaitTransactionSuccessAsync( - WETH_RESERVED_FOR_POOL_REWARDS, - ); + await testContract.setPoolRewards(POOL_ID, POOL_REWARD).awaitTransactionSuccessAsync(); + await testContract + .setWethReservedForPoolRewards(WETH_RESERVED_FOR_POOL_REWARDS) + .awaitTransactionSuccessAsync(); }); async function syncPoolRewardsAsync( reward: Numberish, membersStake: Numberish, ): Promise<[[BigNumber, BigNumber], LogEntry[]]> { - const [result, receipt] = await txHelper.getResultAndReceiptAsync( + const [result, receipt] = await transactionHelper.getResultAndReceiptAsync( testContract.syncPoolRewards, POOL_ID, new BigNumber(reward), @@ -382,7 +390,7 @@ blockchainTests.resets('MixinStakingPoolRewards unit tests', env => { const membersStake = getRandomInteger(1, 1e18); await syncPoolRewardsAsync(totalReward, membersStake); const expectedMembersReward = toMembersPortion(OPERATOR_SHARE, totalReward); - const poolReward = await testContract.rewardsByPoolId.callAsync(POOL_ID); + const poolReward = await testContract.rewardsByPoolId(POOL_ID).callAsync(); expect(poolReward).to.bignumber.eq(POOL_REWARD.plus(expectedMembersReward)); }); it("increases `wethReservedForPoolRewards` with members' portion of rewards", async () => { @@ -390,7 +398,7 @@ blockchainTests.resets('MixinStakingPoolRewards unit tests', env => { const membersStake = getRandomInteger(1, 1e18); await syncPoolRewardsAsync(totalReward, membersStake); const expectedMembersReward = toMembersPortion(OPERATOR_SHARE, totalReward); - const wethReserved = await testContract.wethReservedForPoolRewards.callAsync(); + const wethReserved = await testContract.wethReservedForPoolRewards().callAsync(); expect(wethReserved).to.bignumber.eq(WETH_RESERVED_FOR_POOL_REWARDS.plus(expectedMembersReward)); }); it("returns operator and members' portion of the reward", async () => { @@ -415,10 +423,12 @@ blockchainTests.resets('MixinStakingPoolRewards unit tests', env => { }); it("gives all rewards to members if operator's share is zero", async () => { const totalReward = getRandomInteger(1, 1e18); - await testContract.setPool.awaitTransactionSuccessAsync(POOL_ID, { - operator: OPERATOR, - operatorShare: constants.ZERO_AMOUNT, - }); + await testContract + .setPool(POOL_ID, { + operator: OPERATOR, + operatorShare: constants.ZERO_AMOUNT, + }) + .awaitTransactionSuccessAsync(); const [[operatorReward, membersReward], logs] = await syncPoolRewardsAsync( totalReward, getRandomInteger(1, 1e18), @@ -435,11 +445,9 @@ blockchainTests.resets('MixinStakingPoolRewards unit tests', env => { const operatorShare = getRandomPortion(constants.PPM_100_PERCENT); const totalReward = getRandomInteger(1, 1e18); const membersStake = constants.ZERO_AMOUNT; - const [operatorReward, membersReward] = await testContract.computePoolRewardsSplit.callAsync( - operatorShare, - totalReward, - membersStake, - ); + const [operatorReward, membersReward] = await testContract + .computePoolRewardsSplit(operatorShare, totalReward, membersStake) + .callAsync(); expect(operatorReward).to.bignumber.eq(totalReward); expect(membersReward).to.bignumber.eq(0); }); @@ -447,11 +455,9 @@ blockchainTests.resets('MixinStakingPoolRewards unit tests', env => { const operatorShare = constants.ZERO_AMOUNT; const totalReward = getRandomInteger(1, 1e18); const membersStake = constants.ZERO_AMOUNT; - const [operatorReward, membersReward] = await testContract.computePoolRewardsSplit.callAsync( - operatorShare, - totalReward, - membersStake, - ); + const [operatorReward, membersReward] = await testContract + .computePoolRewardsSplit(operatorShare, totalReward, membersStake) + .callAsync(); expect(operatorReward).to.bignumber.eq(totalReward); expect(membersReward).to.bignumber.eq(0); }); @@ -459,11 +465,9 @@ blockchainTests.resets('MixinStakingPoolRewards unit tests', env => { const operatorShare = constants.PPM_100_PERCENT; const totalReward = getRandomInteger(1, 1e18); const membersStake = getRandomInteger(1, 1e18); - const [operatorReward, membersReward] = await testContract.computePoolRewardsSplit.callAsync( - operatorShare, - totalReward, - membersStake, - ); + const [operatorReward, membersReward] = await testContract + .computePoolRewardsSplit(operatorShare, totalReward, membersStake) + .callAsync(); expect(operatorReward).to.bignumber.eq(totalReward); expect(membersReward).to.bignumber.eq(0); }); @@ -471,11 +475,9 @@ blockchainTests.resets('MixinStakingPoolRewards unit tests', env => { const operatorShare = constants.ZERO_AMOUNT; const totalReward = getRandomInteger(1, 1e18); const membersStake = getRandomInteger(1, 1e18); - const [operatorReward, membersReward] = await testContract.computePoolRewardsSplit.callAsync( - operatorShare, - totalReward, - membersStake, - ); + const [operatorReward, membersReward] = await testContract + .computePoolRewardsSplit(operatorShare, totalReward, membersStake) + .callAsync(); expect(operatorReward).to.bignumber.eq(0); expect(membersReward).to.bignumber.eq(totalReward); }); @@ -483,11 +485,9 @@ blockchainTests.resets('MixinStakingPoolRewards unit tests', env => { const operatorShare = getRandomPortion(constants.PPM_100_PERCENT); const totalReward = getRandomInteger(1, 1e18); const membersStake = getRandomInteger(1, 1e18); - const [operatorReward, membersReward] = await testContract.computePoolRewardsSplit.callAsync( - operatorShare, - totalReward, - membersStake, - ); + const [operatorReward, membersReward] = await testContract + .computePoolRewardsSplit(operatorShare, totalReward, membersStake) + .callAsync(); expect(operatorReward).to.bignumber.eq(toOperatorPortion(operatorShare, totalReward)); expect(membersReward).to.bignumber.eq(toMembersPortion(operatorShare, totalReward)); }); diff --git a/contracts/staking/test/unit_tests/params_test.ts b/contracts/staking/test/unit_tests/params_test.ts index e49a46a141..59dfad4571 100644 --- a/contracts/staking/test/unit_tests/params_test.ts +++ b/contracts/staking/test/unit_tests/params_test.ts @@ -21,7 +21,7 @@ blockchainTests('Configurable Parameters unit tests', env => { env.txDefaults, artifacts, ); - await testContract.addAuthorizedAddress.awaitTransactionSuccessAsync(authorizedAddress); + await testContract.addAuthorizedAddress(authorizedAddress).awaitTransactionSuccessAsync(); }); blockchainTests.resets('setParams()', () => { @@ -33,14 +33,15 @@ blockchainTests('Configurable Parameters unit tests', env => { ...stakingConstants.DEFAULT_PARAMS, ...params, }; - const receipt = await testContract.setParams.awaitTransactionSuccessAsync( - new BigNumber(_params.epochDurationInSeconds), - new BigNumber(_params.rewardDelegatedStakeWeight), - new BigNumber(_params.minimumPoolStake), - new BigNumber(_params.cobbDouglasAlphaNumerator), - new BigNumber(_params.cobbDouglasAlphaDenominator), - { from }, - ); + const receipt = await testContract + .setParams( + new BigNumber(_params.epochDurationInSeconds), + new BigNumber(_params.rewardDelegatedStakeWeight), + new BigNumber(_params.minimumPoolStake), + new BigNumber(_params.cobbDouglasAlphaNumerator), + new BigNumber(_params.cobbDouglasAlphaDenominator), + ) + .awaitTransactionSuccessAsync({ from }); // Assert event. const events = filterLogsToArguments(receipt.logs, 'ParamsSet'); expect(events.length).to.eq(1); @@ -51,7 +52,7 @@ blockchainTests('Configurable Parameters unit tests', env => { expect(event.cobbDouglasAlphaNumerator).to.bignumber.eq(_params.cobbDouglasAlphaNumerator); expect(event.cobbDouglasAlphaDenominator).to.bignumber.eq(_params.cobbDouglasAlphaDenominator); // Assert `getParams()`. - const actual = await testContract.getParams.callAsync(); + const actual = await testContract.getParams().callAsync(); expect(actual[0]).to.bignumber.eq(_params.epochDurationInSeconds); expect(actual[1]).to.bignumber.eq(_params.rewardDelegatedStakeWeight); expect(actual[2]).to.bignumber.eq(_params.minimumPoolStake); @@ -67,7 +68,7 @@ blockchainTests('Configurable Parameters unit tests', env => { }); it('throws if `assertValidStorageParams()` throws`', async () => { - await testContract.setShouldFailAssertValidStorageParams.awaitTransactionSuccessAsync(true); + await testContract.setShouldFailAssertValidStorageParams(true).awaitTransactionSuccessAsync(); const tx = setParamsAndAssertAsync({}); return expect(tx).to.revertWith('ASSERT_VALID_STORAGE_PARAMS_FAILED'); }); diff --git a/contracts/staking/test/unit_tests/protocol_fees_test.ts b/contracts/staking/test/unit_tests/protocol_fees_test.ts index 1c027fad3a..a80b9f110e 100644 --- a/contracts/staking/test/unit_tests/protocol_fees_test.ts +++ b/contracts/staking/test/unit_tests/protocol_fees_test.ts @@ -45,7 +45,7 @@ blockchainTests('Protocol Fees unit tests', env => { exchangeAddress, ); - minimumStake = (await testContract.getParams.callAsync())[2]; + minimumStake = (await testContract.getParams().callAsync())[2]; }); interface CreateTestPoolOpts { @@ -63,12 +63,14 @@ blockchainTests('Protocol Fees unit tests', env => { makers: _.times(2, () => randomAddress()), ...opts, }; - await testContract.createTestPool.awaitTransactionSuccessAsync( - _opts.poolId, - new BigNumber(_opts.operatorStake), - new BigNumber(_opts.membersStake), - _opts.makers, - ); + await testContract + .createTestPool( + _opts.poolId, + new BigNumber(_opts.operatorStake), + new BigNumber(_opts.membersStake), + _opts.makers, + ) + .awaitTransactionSuccessAsync(); return _opts; } @@ -80,23 +82,17 @@ blockchainTests('Protocol Fees unit tests', env => { describe('forbidden actions', () => { it('should revert if called by a non-exchange', async () => { - const tx = testContract.payProtocolFee.awaitTransactionSuccessAsync( - makerAddress, - payerAddress, - DEFAULT_PROTOCOL_FEE_PAID, - { from: notExchangeAddress }, - ); + const tx = testContract + .payProtocolFee(makerAddress, payerAddress, DEFAULT_PROTOCOL_FEE_PAID) + .awaitTransactionSuccessAsync({ from: notExchangeAddress }); const expectedError = new StakingRevertErrors.OnlyCallableByExchangeError(notExchangeAddress); return expect(tx).to.revertWith(expectedError); }); it('should revert if `protocolFee` is zero with non-zero value sent', async () => { - const tx = testContract.payProtocolFee.awaitTransactionSuccessAsync( - makerAddress, - payerAddress, - ZERO_AMOUNT, - { from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID }, - ); + const tx = testContract + .payProtocolFee(makerAddress, payerAddress, ZERO_AMOUNT) + .awaitTransactionSuccessAsync({ from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID }); const expectedError = new StakingRevertErrors.InvalidProtocolFeePaymentError( ZERO_AMOUNT, DEFAULT_PROTOCOL_FEE_PAID, @@ -105,12 +101,9 @@ blockchainTests('Protocol Fees unit tests', env => { }); it('should revert if `protocolFee` is < than the provided message value', async () => { - const tx = testContract.payProtocolFee.awaitTransactionSuccessAsync( - makerAddress, - payerAddress, - DEFAULT_PROTOCOL_FEE_PAID, - { from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID.minus(1) }, - ); + const tx = testContract + .payProtocolFee(makerAddress, payerAddress, DEFAULT_PROTOCOL_FEE_PAID) + .awaitTransactionSuccessAsync({ from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID.minus(1) }); const expectedError = new StakingRevertErrors.InvalidProtocolFeePaymentError( DEFAULT_PROTOCOL_FEE_PAID, DEFAULT_PROTOCOL_FEE_PAID.minus(1), @@ -119,12 +112,9 @@ blockchainTests('Protocol Fees unit tests', env => { }); it('should revert if `protocolFee` is > than the provided message value', async () => { - const tx = testContract.payProtocolFee.awaitTransactionSuccessAsync( - makerAddress, - payerAddress, - DEFAULT_PROTOCOL_FEE_PAID, - { from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID.plus(1) }, - ); + const tx = testContract + .payProtocolFee(makerAddress, payerAddress, DEFAULT_PROTOCOL_FEE_PAID) + .awaitTransactionSuccessAsync({ from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID.plus(1) }); const expectedError = new StakingRevertErrors.InvalidProtocolFeePaymentError( DEFAULT_PROTOCOL_FEE_PAID, DEFAULT_PROTOCOL_FEE_PAID.plus(1), @@ -134,7 +124,7 @@ blockchainTests('Protocol Fees unit tests', env => { }); async function getProtocolFeesAsync(poolId: string): Promise { - return (await testContract.getStakingPoolStatsThisEpoch.callAsync(poolId)).feesCollected; + return (await testContract.getStakingPoolStatsThisEpoch(poolId).callAsync()).feesCollected; } describe('ETH fees', () => { @@ -148,23 +138,17 @@ blockchainTests('Protocol Fees unit tests', env => { it('should not transfer WETH if value is sent', async () => { await createTestPoolAsync({ operatorStake: minimumStake }); - const receipt = await testContract.payProtocolFee.awaitTransactionSuccessAsync( - makerAddress, - payerAddress, - DEFAULT_PROTOCOL_FEE_PAID, - { from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID }, - ); + const receipt = await testContract + .payProtocolFee(makerAddress, payerAddress, DEFAULT_PROTOCOL_FEE_PAID) + .awaitTransactionSuccessAsync({ from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID }); assertNoWETHTransferLogs(receipt.logs); }); it('should credit pool if the maker is in a pool', async () => { const { poolId } = await createTestPoolAsync({ operatorStake: minimumStake, makers: [makerAddress] }); - const receipt = await testContract.payProtocolFee.awaitTransactionSuccessAsync( - makerAddress, - payerAddress, - DEFAULT_PROTOCOL_FEE_PAID, - { from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID }, - ); + const receipt = await testContract + .payProtocolFee(makerAddress, payerAddress, DEFAULT_PROTOCOL_FEE_PAID) + .awaitTransactionSuccessAsync({ from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID }); assertNoWETHTransferLogs(receipt.logs); const poolFees = await getProtocolFeesAsync(poolId); @@ -173,12 +157,9 @@ blockchainTests('Protocol Fees unit tests', env => { it('should not credit the pool if maker is not in a pool', async () => { const { poolId } = await createTestPoolAsync({ operatorStake: minimumStake }); - const receipt = await testContract.payProtocolFee.awaitTransactionSuccessAsync( - makerAddress, - payerAddress, - DEFAULT_PROTOCOL_FEE_PAID, - { from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID }, - ); + const receipt = await testContract + .payProtocolFee(makerAddress, payerAddress, DEFAULT_PROTOCOL_FEE_PAID) + .awaitTransactionSuccessAsync({ from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID }); assertNoWETHTransferLogs(receipt.logs); const poolFees = await getProtocolFeesAsync(poolId); expect(poolFees).to.bignumber.eq(ZERO_AMOUNT); @@ -187,12 +168,9 @@ blockchainTests('Protocol Fees unit tests', env => { it('fees paid to the same maker should go to the same pool', async () => { const { poolId } = await createTestPoolAsync({ operatorStake: minimumStake, makers: [makerAddress] }); const payAsync = async () => { - const receipt = await testContract.payProtocolFee.awaitTransactionSuccessAsync( - makerAddress, - payerAddress, - DEFAULT_PROTOCOL_FEE_PAID, - { from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID }, - ); + const receipt = await testContract + .payProtocolFee(makerAddress, payerAddress, DEFAULT_PROTOCOL_FEE_PAID) + .awaitTransactionSuccessAsync({ from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID }); assertNoWETHTransferLogs(receipt.logs); }; await payAsync(); @@ -219,23 +197,17 @@ blockchainTests('Protocol Fees unit tests', env => { it('should transfer WETH if no value is sent and the maker is not in a pool', async () => { await createTestPoolAsync({ operatorStake: minimumStake }); - const receipt = await testContract.payProtocolFee.awaitTransactionSuccessAsync( - makerAddress, - payerAddress, - DEFAULT_PROTOCOL_FEE_PAID, - { from: exchangeAddress, value: ZERO_AMOUNT }, - ); + const receipt = await testContract + .payProtocolFee(makerAddress, payerAddress, DEFAULT_PROTOCOL_FEE_PAID) + .awaitTransactionSuccessAsync({ from: exchangeAddress, value: ZERO_AMOUNT }); assertWETHTransferLogs(receipt.logs, payerAddress, DEFAULT_PROTOCOL_FEE_PAID); }); it('should update `protocolFeesThisEpochByPool` if the maker is in a pool', async () => { const { poolId } = await createTestPoolAsync({ operatorStake: minimumStake, makers: [makerAddress] }); - const receipt = await testContract.payProtocolFee.awaitTransactionSuccessAsync( - makerAddress, - payerAddress, - DEFAULT_PROTOCOL_FEE_PAID, - { from: exchangeAddress, value: ZERO_AMOUNT }, - ); + const receipt = await testContract + .payProtocolFee(makerAddress, payerAddress, DEFAULT_PROTOCOL_FEE_PAID) + .awaitTransactionSuccessAsync({ from: exchangeAddress, value: ZERO_AMOUNT }); assertWETHTransferLogs(receipt.logs, payerAddress, DEFAULT_PROTOCOL_FEE_PAID); const poolFees = await getProtocolFeesAsync(poolId); expect(poolFees).to.bignumber.eq(DEFAULT_PROTOCOL_FEE_PAID); @@ -243,12 +215,9 @@ blockchainTests('Protocol Fees unit tests', env => { it('should not update `protocolFeesThisEpochByPool` if maker is not in a pool', async () => { const { poolId } = await createTestPoolAsync({ operatorStake: minimumStake }); - const receipt = await testContract.payProtocolFee.awaitTransactionSuccessAsync( - makerAddress, - payerAddress, - DEFAULT_PROTOCOL_FEE_PAID, - { from: exchangeAddress, value: ZERO_AMOUNT }, - ); + const receipt = await testContract + .payProtocolFee(makerAddress, payerAddress, DEFAULT_PROTOCOL_FEE_PAID) + .awaitTransactionSuccessAsync({ from: exchangeAddress, value: ZERO_AMOUNT }); assertWETHTransferLogs(receipt.logs, payerAddress, DEFAULT_PROTOCOL_FEE_PAID); const poolFees = await getProtocolFeesAsync(poolId); expect(poolFees).to.bignumber.eq(ZERO_AMOUNT); @@ -257,12 +226,9 @@ blockchainTests('Protocol Fees unit tests', env => { it('fees paid to the same maker should go to the same pool', async () => { const { poolId } = await createTestPoolAsync({ operatorStake: minimumStake, makers: [makerAddress] }); const payAsync = async () => { - const receipt = await testContract.payProtocolFee.awaitTransactionSuccessAsync( - makerAddress, - payerAddress, - DEFAULT_PROTOCOL_FEE_PAID, - { from: exchangeAddress, value: ZERO_AMOUNT }, - ); + const receipt = await testContract + .payProtocolFee(makerAddress, payerAddress, DEFAULT_PROTOCOL_FEE_PAID) + .awaitTransactionSuccessAsync({ from: exchangeAddress, value: ZERO_AMOUNT }); assertWETHTransferLogs(receipt.logs, payerAddress, DEFAULT_PROTOCOL_FEE_PAID); }; await payAsync(); @@ -275,15 +241,12 @@ blockchainTests('Protocol Fees unit tests', env => { it('fees paid to the same maker in WETH then ETH should go to the same pool', async () => { const { poolId } = await createTestPoolAsync({ operatorStake: minimumStake, makers: [makerAddress] }); const payAsync = async (inWETH: boolean) => { - await testContract.payProtocolFee.awaitTransactionSuccessAsync( - makerAddress, - payerAddress, - DEFAULT_PROTOCOL_FEE_PAID, - { + await testContract + .payProtocolFee(makerAddress, payerAddress, DEFAULT_PROTOCOL_FEE_PAID) + .awaitTransactionSuccessAsync({ from: exchangeAddress, value: inWETH ? ZERO_AMOUNT : DEFAULT_PROTOCOL_FEE_PAID, - }, - ); + }); }; await payAsync(true); await payAsync(false); @@ -300,12 +263,9 @@ blockchainTests('Protocol Fees unit tests', env => { membersStake: 0, makers: [makerAddress], }); - await testContract.payProtocolFee.awaitTransactionSuccessAsync( - makerAddress, - constants.NULL_ADDRESS, - DEFAULT_PROTOCOL_FEE_PAID, - { from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID }, - ); + await testContract + .payProtocolFee(makerAddress, constants.NULL_ADDRESS, DEFAULT_PROTOCOL_FEE_PAID) + .awaitTransactionSuccessAsync({ from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID }); const feesCredited = await getProtocolFeesAsync(poolId); expect(feesCredited).to.bignumber.eq(DEFAULT_PROTOCOL_FEE_PAID); }); @@ -316,12 +276,9 @@ blockchainTests('Protocol Fees unit tests', env => { membersStake: 0, makers: [makerAddress], }); - await testContract.payProtocolFee.awaitTransactionSuccessAsync( - makerAddress, - constants.NULL_ADDRESS, - DEFAULT_PROTOCOL_FEE_PAID, - { from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID }, - ); + await testContract + .payProtocolFee(makerAddress, constants.NULL_ADDRESS, DEFAULT_PROTOCOL_FEE_PAID) + .awaitTransactionSuccessAsync({ from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID }); const feesCredited = await getProtocolFeesAsync(poolId); expect(feesCredited).to.bignumber.eq(DEFAULT_PROTOCOL_FEE_PAID); }); @@ -332,12 +289,9 @@ blockchainTests('Protocol Fees unit tests', env => { membersStake: 0, makers: [makerAddress], }); - await testContract.payProtocolFee.awaitTransactionSuccessAsync( - makerAddress, - constants.NULL_ADDRESS, - DEFAULT_PROTOCOL_FEE_PAID, - { from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID }, - ); + await testContract + .payProtocolFee(makerAddress, constants.NULL_ADDRESS, DEFAULT_PROTOCOL_FEE_PAID) + .awaitTransactionSuccessAsync({ from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID }); const feesCredited = await getProtocolFeesAsync(poolId); expect(feesCredited).to.bignumber.eq(0); }); @@ -347,7 +301,7 @@ blockchainTests('Protocol Fees unit tests', env => { let membersStakeWeight: number; before(async () => { - membersStakeWeight = (await testContract.getParams.callAsync())[1]; + membersStakeWeight = (await testContract.getParams().callAsync())[1]; }); interface FinalizationState { @@ -357,7 +311,7 @@ blockchainTests('Protocol Fees unit tests', env => { } async function getFinalizationStateAsync(): Promise { - const aggregatedStats = await testContract.getAggregatedStatsForCurrentEpoch.callAsync(); + const aggregatedStats = await testContract.getAggregatedStatsForCurrentEpoch().callAsync(); return { numPoolsToFinalize: aggregatedStats.numPoolsToFinalize, totalFeesCollected: aggregatedStats.totalFeesCollected, @@ -372,12 +326,9 @@ blockchainTests('Protocol Fees unit tests', env => { async function payToMakerAsync(poolMaker: string, fee?: Numberish): Promise { const _fee = fee === undefined ? getRandomInteger(1, '1e18') : fee; - const receipt = await testContract.payProtocolFee.awaitTransactionSuccessAsync( - poolMaker, - payerAddress, - new BigNumber(_fee), - { from: exchangeAddress, value: _fee }, - ); + const receipt = await testContract + .payProtocolFee(poolMaker, payerAddress, new BigNumber(_fee)) + .awaitTransactionSuccessAsync({ from: exchangeAddress, value: _fee }); const events = filterLogsToArguments( receipt.logs, IStakingEventsEvents.StakingPoolEarnedRewardsInEpoch, @@ -404,7 +355,7 @@ blockchainTests('Protocol Fees unit tests', env => { it('pool is not registered to start', async () => { const { poolId } = await createTestPoolAsync(); - const pool = await testContract.getStakingPoolStatsThisEpoch.callAsync(poolId); + const pool = await testContract.getStakingPoolStatsThisEpoch(poolId).callAsync(); expect(pool.feesCollected).to.bignumber.eq(0); expect(pool.membersStake).to.bignumber.eq(0); expect(pool.weightedStake).to.bignumber.eq(0); @@ -419,7 +370,7 @@ blockchainTests('Protocol Fees unit tests', env => { const { fee, poolEarnedRewardsEvents } = await payToMakerAsync(poolMaker); expect(poolEarnedRewardsEvents.length).to.eq(1); expect(poolEarnedRewardsEvents[0].poolId).to.eq(poolId); - const actualPoolStats = await testContract.getStakingPoolStatsThisEpoch.callAsync(poolId); + const actualPoolStats = await testContract.getStakingPoolStatsThisEpoch(poolId).callAsync(); const expectedWeightedStake = toWeightedStake(pool.operatorStake, pool.membersStake); expect(actualPoolStats.feesCollected).to.bignumber.eq(fee); expect(actualPoolStats.membersStake).to.bignumber.eq(pool.membersStake); @@ -439,7 +390,7 @@ blockchainTests('Protocol Fees unit tests', env => { const { fee: fee1 } = await payToMakerAsync(poolMaker); const { fee: fee2, poolEarnedRewardsEvents } = await payToMakerAsync(poolMaker); expect(poolEarnedRewardsEvents).to.deep.eq([]); - const actualPoolStats = await testContract.getStakingPoolStatsThisEpoch.callAsync(poolId); + const actualPoolStats = await testContract.getStakingPoolStatsThisEpoch(poolId).callAsync(); const expectedWeightedStake = toWeightedStake(pool.operatorStake, pool.membersStake); const fees = BigNumber.sum(fee1, fee2); expect(actualPoolStats.feesCollected).to.bignumber.eq(fees); @@ -463,7 +414,7 @@ blockchainTests('Protocol Fees unit tests', env => { const { fee, poolEarnedRewardsEvents } = await payToMakerAsync(poolMaker); expect(poolEarnedRewardsEvents.length).to.eq(1); expect(poolEarnedRewardsEvents[0].poolId).to.eq(poolId); - const actualPoolStats = await testContract.getStakingPoolStatsThisEpoch.callAsync(poolId); + const actualPoolStats = await testContract.getStakingPoolStatsThisEpoch(poolId).callAsync(); const expectedWeightedStake = toWeightedStake(pool.operatorStake, pool.membersStake); expect(actualPoolStats.feesCollected).to.bignumber.eq(fee); expect(actualPoolStats.membersStake).to.bignumber.eq(pool.membersStake); @@ -484,8 +435,8 @@ blockchainTests('Protocol Fees unit tests', env => { makers: [poolMaker], } = pool; await payToMakerAsync(poolMaker); - await testContract.advanceEpoch.awaitTransactionSuccessAsync(); - const actualPoolStats = await testContract.getStakingPoolStatsThisEpoch.callAsync(poolId); + await testContract.advanceEpoch().awaitTransactionSuccessAsync(); + const actualPoolStats = await testContract.getStakingPoolStatsThisEpoch(poolId).callAsync(); expect(actualPoolStats.feesCollected).to.bignumber.eq(0); expect(actualPoolStats.membersStake).to.bignumber.eq(0); expect(actualPoolStats.weightedStake).to.bignumber.eq(0); diff --git a/contracts/staking/test/unit_tests/stake_balances_test.ts b/contracts/staking/test/unit_tests/stake_balances_test.ts index 019a4487b1..8c5d6cd930 100644 --- a/contracts/staking/test/unit_tests/stake_balances_test.ts +++ b/contracts/staking/test/unit_tests/stake_balances_test.ts @@ -59,11 +59,10 @@ blockchainTests.resets('MixinStakeBalances unit tests', env => { ); before(async () => { - await testContract.setGlobalStakeByStatus.awaitTransactionSuccessAsync( - StakeStatus.Delegated, - delegatedBalance, - ); - await testContract.setBalanceOfZrxVault.awaitTransactionSuccessAsync(zrxVaultBalance); + await testContract + .setGlobalStakeByStatus(StakeStatus.Delegated, delegatedBalance) + .awaitTransactionSuccessAsync(); + await testContract.setBalanceOfZrxVault(zrxVaultBalance).awaitTransactionSuccessAsync(); }); it('undelegated stake is the difference between zrx vault balance and global delegated stake', async () => { @@ -72,12 +71,12 @@ blockchainTests.resets('MixinStakeBalances unit tests', env => { currentEpochBalance: zrxVaultBalance.minus(delegatedBalance.currentEpochBalance), nextEpochBalance: zrxVaultBalance.minus(delegatedBalance.nextEpochBalance), }; - const actualBalance = await testContract.getGlobalStakeByStatus.callAsync(StakeStatus.Undelegated); + const actualBalance = await testContract.getGlobalStakeByStatus(StakeStatus.Undelegated).callAsync(); expect(actualBalance).to.deep.eq(expectedBalance); }); it('delegated stake is the global delegated stake', async () => { - const actualBalance = await testContract.getGlobalStakeByStatus.callAsync(StakeStatus.Delegated); + const actualBalance = await testContract.getGlobalStakeByStatus(StakeStatus.Delegated).callAsync(); expect(actualBalance).to.deep.eq(toCurrentBalance(delegatedBalance)); }); @@ -86,8 +85,8 @@ blockchainTests.resets('MixinStakeBalances unit tests', env => { delegatedBalance.currentEpochBalance, delegatedBalance.nextEpochBalance, ).minus(1); - await testContract.setBalanceOfZrxVault.awaitTransactionSuccessAsync(_zrxVaultBalance); - const tx = testContract.getGlobalStakeByStatus.callAsync(StakeStatus.Undelegated); + await testContract.setBalanceOfZrxVault(_zrxVaultBalance).awaitTransactionSuccessAsync(); + const tx = testContract.getGlobalStakeByStatus(StakeStatus.Undelegated).callAsync(); const expectedError = new SafeMathRevertErrors.Uint256BinOpError( SafeMathRevertErrors.BinOpErrorCodes.SubtractionUnderflow, _zrxVaultBalance, @@ -99,7 +98,7 @@ blockchainTests.resets('MixinStakeBalances unit tests', env => { }); it('throws if unknown stake status is passed in', async () => { - const tx = testContract.getGlobalStakeByStatus.callAsync(2); + const tx = testContract.getGlobalStakeByStatus(2).callAsync(); return expect(tx).to.be.rejected(); }); }); @@ -111,40 +110,36 @@ blockchainTests.resets('MixinStakeBalances unit tests', env => { const undelegatedStake = randomStoredBalance(); before(async () => { - await testContract.setOwnerStakeByStatus.awaitTransactionSuccessAsync( - staker, - StakeStatus.Delegated, - delegatedStake, - ); - await testContract.setOwnerStakeByStatus.awaitTransactionSuccessAsync( - staker, - StakeStatus.Undelegated, - undelegatedStake, - ); + await testContract + .setOwnerStakeByStatus(staker, StakeStatus.Delegated, delegatedStake) + .awaitTransactionSuccessAsync(); + await testContract + .setOwnerStakeByStatus(staker, StakeStatus.Undelegated, undelegatedStake) + .awaitTransactionSuccessAsync(); }); it('throws if unknown stake status is passed in', async () => { - const tx = testContract.getOwnerStakeByStatus.callAsync(staker, 2); + const tx = testContract.getOwnerStakeByStatus(staker, 2).callAsync(); return expect(tx).to.be.rejected(); }); it('returns empty delegated stake for an unstaked owner', async () => { - const balance = await testContract.getOwnerStakeByStatus.callAsync(notStaker, StakeStatus.Delegated); + const balance = await testContract.getOwnerStakeByStatus(notStaker, StakeStatus.Delegated).callAsync(); expect(balance).to.deep.eq(EMPTY_BALANCE); }); it('returns empty undelegated stake for an unstaked owner', async () => { - const balance = await testContract.getOwnerStakeByStatus.callAsync(notStaker, StakeStatus.Undelegated); + const balance = await testContract.getOwnerStakeByStatus(notStaker, StakeStatus.Undelegated).callAsync(); expect(balance).to.deep.eq(EMPTY_BALANCE); }); it('returns undelegated stake for a staked owner', async () => { - const balance = await testContract.getOwnerStakeByStatus.callAsync(staker, StakeStatus.Undelegated); + const balance = await testContract.getOwnerStakeByStatus(staker, StakeStatus.Undelegated).callAsync(); expect(balance).to.deep.eq(toCurrentBalance(undelegatedStake)); }); it('returns delegated stake for a staked owner', async () => { - const balance = await testContract.getOwnerStakeByStatus.callAsync(staker, StakeStatus.Delegated); + const balance = await testContract.getOwnerStakeByStatus(staker, StakeStatus.Delegated).callAsync(); expect(balance).to.deep.eq(toCurrentBalance(delegatedStake)); }); }); @@ -155,16 +150,16 @@ blockchainTests.resets('MixinStakeBalances unit tests', env => { const stakerAmount = randomAmount(); before(async () => { - await testContract.setZrxBalanceOf.awaitTransactionSuccessAsync(staker, stakerAmount); + await testContract.setZrxBalanceOf(staker, stakerAmount).awaitTransactionSuccessAsync(); }); it('returns empty for unstaked owner', async () => { - const amount = await testContract.getTotalStake.callAsync(notStaker); + const amount = await testContract.getTotalStake(notStaker).callAsync(); expect(amount).to.bignumber.eq(0); }); it('returns stake for staked owner', async () => { - const amount = await testContract.getTotalStake.callAsync(staker); + const amount = await testContract.getTotalStake(staker).callAsync(); expect(amount).to.bignumber.eq(stakerAmount); }); }); @@ -177,25 +172,23 @@ blockchainTests.resets('MixinStakeBalances unit tests', env => { const delegatedBalance = randomStoredBalance(); before(async () => { - await testContract.setDelegatedStakeToPoolByOwner.awaitTransactionSuccessAsync( - staker, - poolId, - delegatedBalance, - ); + await testContract + .setDelegatedStakeToPoolByOwner(staker, poolId, delegatedBalance) + .awaitTransactionSuccessAsync(); }); it('returns empty for unstaked owner', async () => { - const balance = await testContract.getStakeDelegatedToPoolByOwner.callAsync(notStaker, poolId); + const balance = await testContract.getStakeDelegatedToPoolByOwner(notStaker, poolId).callAsync(); expect(balance).to.deep.eq(EMPTY_BALANCE); }); it('returns empty for empty pool', async () => { - const balance = await testContract.getStakeDelegatedToPoolByOwner.callAsync(staker, notPoolId); + const balance = await testContract.getStakeDelegatedToPoolByOwner(staker, notPoolId).callAsync(); expect(balance).to.deep.eq(EMPTY_BALANCE); }); it('returns stake for staked owner in their pool', async () => { - const balance = await testContract.getStakeDelegatedToPoolByOwner.callAsync(staker, poolId); + const balance = await testContract.getStakeDelegatedToPoolByOwner(staker, poolId).callAsync(); expect(balance).to.deep.eq(toCurrentBalance(delegatedBalance)); }); }); @@ -206,16 +199,16 @@ blockchainTests.resets('MixinStakeBalances unit tests', env => { const delegatedBalance = randomStoredBalance(); before(async () => { - await testContract.setDelegatedStakeByPoolId.awaitTransactionSuccessAsync(poolId, delegatedBalance); + await testContract.setDelegatedStakeByPoolId(poolId, delegatedBalance).awaitTransactionSuccessAsync(); }); it('returns empty for empty pool', async () => { - const balance = await testContract.getTotalStakeDelegatedToPool.callAsync(notPoolId); + const balance = await testContract.getTotalStakeDelegatedToPool(notPoolId).callAsync(); expect(balance).to.deep.eq(EMPTY_BALANCE); }); it('returns stake for staked pool', async () => { - const balance = await testContract.getTotalStakeDelegatedToPool.callAsync(poolId); + const balance = await testContract.getTotalStakeDelegatedToPool(poolId).callAsync(); expect(balance).to.deep.eq(toCurrentBalance(delegatedBalance)); }); }); diff --git a/contracts/staking/test/unit_tests/stake_test.ts b/contracts/staking/test/unit_tests/stake_test.ts index 76e5dd5d47..080d0c71ef 100644 --- a/contracts/staking/test/unit_tests/stake_test.ts +++ b/contracts/staking/test/unit_tests/stake_test.ts @@ -46,17 +46,16 @@ blockchainTests.resets('MixinStake unit tests', env => { env.txDefaults, artifacts, ); - currentEpoch = await testContract.currentEpoch.callAsync(); - stakerUndelegatedStakeSlot = await testContract.getOwnerStakeByStatusSlot.callAsync( - staker, - StakeStatus.Undelegated, - ); + currentEpoch = await testContract.currentEpoch().callAsync(); + stakerUndelegatedStakeSlot = await testContract + .getOwnerStakeByStatusSlot(staker, StakeStatus.Undelegated) + .callAsync(); }); describe('stake()', () => { it('deposits funds into the ZRX vault', async () => { const amount = getRandomInteger(0, 100e18); - const { logs } = await testContract.stake.awaitTransactionSuccessAsync(amount); + const { logs } = await testContract.stake(amount).awaitTransactionSuccessAsync(); const events = filterLogsToArguments(logs, StakeEvents.ZrxVaultDepositFrom); expect(events).to.be.length(1); expect(events[0].staker).to.eq(staker); @@ -65,7 +64,7 @@ blockchainTests.resets('MixinStake unit tests', env => { it('increases current and next undelegated stake balance', async () => { const amount = getRandomInteger(0, 100e18); - const { logs } = await testContract.stake.awaitTransactionSuccessAsync(amount); + const { logs } = await testContract.stake(amount).awaitTransactionSuccessAsync(); const events = filterLogsToArguments( logs, StakeEvents.IncreaseCurrentAndNextBalance, @@ -77,7 +76,7 @@ blockchainTests.resets('MixinStake unit tests', env => { it('raises a `Stake` event', async () => { const amount = getRandomInteger(0, 100e18); - const { logs } = await testContract.stake.awaitTransactionSuccessAsync(amount); + const { logs } = await testContract.stake(amount).awaitTransactionSuccessAsync(); const events = filterLogsToArguments(logs, StakeEvents.Stake); expect(events).to.be.length(1); expect(events[0].staker).to.eq(staker); @@ -90,17 +89,19 @@ blockchainTests.resets('MixinStake unit tests', env => { currentEpochBalance: Numberish, nextEpochBalance: Numberish, ): Promise { - await testContract.setOwnerStakeByStatus.awaitTransactionSuccessAsync(staker, StakeStatus.Undelegated, { - currentEpoch, - currentEpochBalance: new BigNumber(currentEpochBalance), - nextEpochBalance: new BigNumber(nextEpochBalance), - }); + await testContract + .setOwnerStakeByStatus(staker, StakeStatus.Undelegated, { + currentEpoch, + currentEpochBalance: new BigNumber(currentEpochBalance), + nextEpochBalance: new BigNumber(nextEpochBalance), + }) + .awaitTransactionSuccessAsync(); } it('throws if not enough undelegated stake in the current epoch', async () => { const amount = getRandomInteger(0, 100e18); await setUndelegatedStakeAsync(amount.minus(1), amount); - const tx = testContract.unstake.awaitTransactionSuccessAsync(amount); + const tx = testContract.unstake(amount).awaitTransactionSuccessAsync(); const expectedError = new StakingRevertErrors.InsufficientBalanceError(amount, amount.minus(1)); return expect(tx).to.revertWith(expectedError); }); @@ -108,7 +109,7 @@ blockchainTests.resets('MixinStake unit tests', env => { it('throws if not enough undelegated stake in the next epoch', async () => { const amount = getRandomInteger(0, 100e18); await setUndelegatedStakeAsync(amount, amount.minus(1)); - const tx = testContract.unstake.awaitTransactionSuccessAsync(amount); + const tx = testContract.unstake(amount).awaitTransactionSuccessAsync(); const expectedError = new StakingRevertErrors.InsufficientBalanceError(amount, amount.minus(1)); return expect(tx).to.revertWith(expectedError); }); @@ -116,7 +117,7 @@ blockchainTests.resets('MixinStake unit tests', env => { it('throws if not enough undelegated stake in both epochs', async () => { const amount = getRandomInteger(0, 100e18); await setUndelegatedStakeAsync(amount.minus(1), amount.minus(1)); - const tx = testContract.unstake.awaitTransactionSuccessAsync(amount); + const tx = testContract.unstake(amount).awaitTransactionSuccessAsync(); const expectedError = new StakingRevertErrors.InsufficientBalanceError(amount, amount.minus(1)); return expect(tx).to.revertWith(expectedError); }); @@ -124,7 +125,7 @@ blockchainTests.resets('MixinStake unit tests', env => { it('decreases current and next undelegated stake balance', async () => { const amount = getRandomInteger(0, 100e18); await setUndelegatedStakeAsync(amount, amount); - const { logs } = await testContract.unstake.awaitTransactionSuccessAsync(amount); + const { logs } = await testContract.unstake(amount).awaitTransactionSuccessAsync(); const events = filterLogsToArguments( logs, StakeEvents.DecreaseCurrentAndNextBalance, @@ -137,7 +138,7 @@ blockchainTests.resets('MixinStake unit tests', env => { it('withdraws funds from the ZRX vault', async () => { const amount = getRandomInteger(0, 100e18); await setUndelegatedStakeAsync(amount, amount); - const { logs } = await testContract.unstake.awaitTransactionSuccessAsync(amount); + const { logs } = await testContract.unstake(amount).awaitTransactionSuccessAsync(); const events = filterLogsToArguments(logs, StakeEvents.ZrxVaultWithdrawFrom); expect(events).to.be.length(1); expect(events[0].staker).to.eq(staker); @@ -147,7 +148,7 @@ blockchainTests.resets('MixinStake unit tests', env => { it('emits an `Unstake` event', async () => { const amount = getRandomInteger(0, 100e18); await setUndelegatedStakeAsync(amount, amount); - const { logs } = await testContract.unstake.awaitTransactionSuccessAsync(amount); + const { logs } = await testContract.unstake(amount).awaitTransactionSuccessAsync(); const events = filterLogsToArguments(logs, StakeEvents.Unstake); expect(events).to.be.length(1); expect(events[0].staker).to.eq(staker); @@ -167,52 +168,59 @@ blockchainTests.resets('MixinStake unit tests', env => { before(async () => { delegatedStakeToPoolByOwnerSlots = await Promise.all( VALID_POOL_IDS.map(async poolId => - testContract.getDelegatedStakeToPoolByOwnerSlot.callAsync(poolId, staker), + testContract.getDelegatedStakeToPoolByOwnerSlot(poolId, staker).callAsync(), ), ); delegatedStakeByPoolIdSlots = await Promise.all( - VALID_POOL_IDS.map(async poolId => testContract.getDelegatedStakeByPoolIdSlot.callAsync(poolId)), - ); - globalDelegatedStakeSlot = await testContract.getGlobalStakeByStatusSlot.callAsync(StakeStatus.Delegated); - stakerDelegatedStakeSlot = await testContract.getOwnerStakeByStatusSlot.callAsync( - staker, - StakeStatus.Delegated, + VALID_POOL_IDS.map(async poolId => testContract.getDelegatedStakeByPoolIdSlot(poolId).callAsync()), ); + globalDelegatedStakeSlot = await testContract.getGlobalStakeByStatusSlot(StakeStatus.Delegated).callAsync(); + stakerDelegatedStakeSlot = await testContract + .getOwnerStakeByStatusSlot(staker, StakeStatus.Delegated) + .callAsync(); }); it('throws if the "from" pool is invalid', async () => { - const tx = testContract.moveStake.awaitTransactionSuccessAsync( - { status: StakeStatus.Delegated, poolId: INVALID_POOL_ID }, - { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[0] }, - getRandomInteger(0, 100e18), - ); + const tx = testContract + .moveStake( + { status: StakeStatus.Delegated, poolId: INVALID_POOL_ID }, + { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[0] }, + getRandomInteger(0, 100e18), + ) + .awaitTransactionSuccessAsync(); return expect(tx).to.revertWith(INVALID_POOL_ERROR); }); it('throws if the "to" pool is invalid', async () => { - const tx = testContract.moveStake.awaitTransactionSuccessAsync( - { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[0] }, - { status: StakeStatus.Delegated, poolId: INVALID_POOL_ID }, - getRandomInteger(0, 100e18), - ); + const tx = testContract + .moveStake( + { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[0] }, + { status: StakeStatus.Delegated, poolId: INVALID_POOL_ID }, + getRandomInteger(0, 100e18), + ) + .awaitTransactionSuccessAsync(); return expect(tx).to.revertWith(INVALID_POOL_ERROR); }); it('throws if the "from" and "to" pools are invalid', async () => { - const tx = testContract.moveStake.awaitTransactionSuccessAsync( - { status: StakeStatus.Delegated, poolId: INVALID_POOL_ID }, - { status: StakeStatus.Delegated, poolId: INVALID_POOL_ID }, - getRandomInteger(0, 100e18), - ); + const tx = testContract + .moveStake( + { status: StakeStatus.Delegated, poolId: INVALID_POOL_ID }, + { status: StakeStatus.Delegated, poolId: INVALID_POOL_ID }, + getRandomInteger(0, 100e18), + ) + .awaitTransactionSuccessAsync(); return expect(tx).to.revertWith(INVALID_POOL_ERROR); }); it('withdraws delegator rewards when "from" stake is delegated', async () => { - const { logs } = await testContract.moveStake.awaitTransactionSuccessAsync( - { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[0] }, - { status: StakeStatus.Undelegated, poolId: VALID_POOL_IDS[1] }, - getRandomInteger(0, 100e18), - ); + const { logs } = await testContract + .moveStake( + { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[0] }, + { status: StakeStatus.Undelegated, poolId: VALID_POOL_IDS[1] }, + getRandomInteger(0, 100e18), + ) + .awaitTransactionSuccessAsync(); const events = filterLogsToArguments( logs, StakeEvents.WithdrawAndSyncDelegatorRewards, @@ -223,11 +231,13 @@ blockchainTests.resets('MixinStake unit tests', env => { }); it('withdraws delegator rewards when "to" stake is delegated', async () => { - const { logs } = await testContract.moveStake.awaitTransactionSuccessAsync( - { status: StakeStatus.Undelegated, poolId: VALID_POOL_IDS[0] }, - { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[1] }, - getRandomInteger(0, 100e18), - ); + const { logs } = await testContract + .moveStake( + { status: StakeStatus.Undelegated, poolId: VALID_POOL_IDS[0] }, + { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[1] }, + getRandomInteger(0, 100e18), + ) + .awaitTransactionSuccessAsync(); const events = filterLogsToArguments( logs, StakeEvents.WithdrawAndSyncDelegatorRewards, @@ -238,11 +248,13 @@ blockchainTests.resets('MixinStake unit tests', env => { }); it('withdraws delegator rewards when both stakes are both delegated', async () => { - const { logs } = await testContract.moveStake.awaitTransactionSuccessAsync( - { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[0] }, - { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[1] }, - getRandomInteger(0, 100e18), - ); + const { logs } = await testContract + .moveStake( + { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[0] }, + { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[1] }, + getRandomInteger(0, 100e18), + ) + .awaitTransactionSuccessAsync(); const events = filterLogsToArguments( logs, StakeEvents.WithdrawAndSyncDelegatorRewards, @@ -255,11 +267,13 @@ blockchainTests.resets('MixinStake unit tests', env => { }); it('does not withdraw delegator rewards when both stakes are both undelegated', async () => { - const { logs } = await testContract.moveStake.awaitTransactionSuccessAsync( - { status: StakeStatus.Undelegated, poolId: VALID_POOL_IDS[0] }, - { status: StakeStatus.Undelegated, poolId: VALID_POOL_IDS[1] }, - getRandomInteger(0, 100e18), - ); + const { logs } = await testContract + .moveStake( + { status: StakeStatus.Undelegated, poolId: VALID_POOL_IDS[0] }, + { status: StakeStatus.Undelegated, poolId: VALID_POOL_IDS[1] }, + getRandomInteger(0, 100e18), + ) + .awaitTransactionSuccessAsync(); const events = filterLogsToArguments( logs, StakeEvents.WithdrawAndSyncDelegatorRewards, @@ -269,11 +283,13 @@ blockchainTests.resets('MixinStake unit tests', env => { it('decreases pool and global delegated stake counters when "from" stake is delegated', async () => { const amount = getRandomInteger(0, 100e18); - const { logs } = await testContract.moveStake.awaitTransactionSuccessAsync( - { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[0] }, - { status: StakeStatus.Undelegated, poolId: VALID_POOL_IDS[1] }, - amount, - ); + const { logs } = await testContract + .moveStake( + { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[0] }, + { status: StakeStatus.Undelegated, poolId: VALID_POOL_IDS[1] }, + amount, + ) + .awaitTransactionSuccessAsync(); const decreaseNextBalanceEvents = filterLogsToArguments( logs, StakeEvents.DecreaseNextBalance, @@ -292,11 +308,13 @@ blockchainTests.resets('MixinStake unit tests', env => { it('increases pool and global delegated stake counters when "to" stake is delegated', async () => { const amount = getRandomInteger(0, 100e18); - const { logs } = await testContract.moveStake.awaitTransactionSuccessAsync( - { status: StakeStatus.Undelegated, poolId: VALID_POOL_IDS[0] }, - { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[1] }, - amount, - ); + const { logs } = await testContract + .moveStake( + { status: StakeStatus.Undelegated, poolId: VALID_POOL_IDS[0] }, + { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[1] }, + amount, + ) + .awaitTransactionSuccessAsync(); const increaseNextBalanceEvents = filterLogsToArguments( logs, StakeEvents.IncreaseNextBalance, @@ -315,11 +333,13 @@ blockchainTests.resets('MixinStake unit tests', env => { it('decreases then increases pool and global delegated stake counters when both stakes are delegated', async () => { const amount = getRandomInteger(0, 100e18); - const { logs } = await testContract.moveStake.awaitTransactionSuccessAsync( - { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[0] }, - { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[1] }, - amount, - ); + const { logs } = await testContract + .moveStake( + { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[0] }, + { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[1] }, + amount, + ) + .awaitTransactionSuccessAsync(); const decreaseNextBalanceEvents = filterLogs( logs, StakeEvents.DecreaseNextBalance, @@ -356,11 +376,13 @@ blockchainTests.resets('MixinStake unit tests', env => { it('does not change pool and global delegated stake counters when both stakes are undelegated', async () => { const amount = getRandomInteger(0, 100e18); - const { logs } = await testContract.moveStake.awaitTransactionSuccessAsync( - { status: StakeStatus.Undelegated, poolId: VALID_POOL_IDS[0] }, - { status: StakeStatus.Undelegated, poolId: VALID_POOL_IDS[1] }, - amount, - ); + const { logs } = await testContract + .moveStake( + { status: StakeStatus.Undelegated, poolId: VALID_POOL_IDS[0] }, + { status: StakeStatus.Undelegated, poolId: VALID_POOL_IDS[1] }, + amount, + ) + .awaitTransactionSuccessAsync(); const decreaseNextBalanceEvents = filterLogsToArguments( logs, StakeEvents.DecreaseNextBalance, @@ -375,33 +397,39 @@ blockchainTests.resets('MixinStake unit tests', env => { it('does nothing when moving the owner stake from undelegated to undelegated', async () => { const amount = getRandomInteger(0, 100e18); - const { logs } = await testContract.moveStake.awaitTransactionSuccessAsync( - { status: StakeStatus.Undelegated, poolId: VALID_POOL_IDS[0] }, - { status: StakeStatus.Undelegated, poolId: VALID_POOL_IDS[1] }, - amount, - ); + const { logs } = await testContract + .moveStake( + { status: StakeStatus.Undelegated, poolId: VALID_POOL_IDS[0] }, + { status: StakeStatus.Undelegated, poolId: VALID_POOL_IDS[1] }, + amount, + ) + .awaitTransactionSuccessAsync(); const events = filterLogsToArguments(logs, StakeEvents.MoveStakeStorage); expect(events).to.be.length(0); }); it('does nothing when moving zero stake', async () => { const amount = new BigNumber(0); - const { logs } = await testContract.moveStake.awaitTransactionSuccessAsync( - { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[0] }, - { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[1] }, - amount, - ); + const { logs } = await testContract + .moveStake( + { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[0] }, + { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[1] }, + amount, + ) + .awaitTransactionSuccessAsync(); const events = filterLogsToArguments(logs, StakeEvents.MoveStakeStorage); expect(events).to.be.length(0); }); it('moves the owner stake between the same pointer when both are delegated', async () => { const amount = getRandomInteger(0, 100e18); - const { logs } = await testContract.moveStake.awaitTransactionSuccessAsync( - { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[0] }, - { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[1] }, - amount, - ); + const { logs } = await testContract + .moveStake( + { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[0] }, + { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[1] }, + amount, + ) + .awaitTransactionSuccessAsync(); const events = filterLogsToArguments(logs, StakeEvents.MoveStakeStorage); expect(events).to.be.length(1); expect(events[0].fromBalanceSlot).to.eq(stakerDelegatedStakeSlot); @@ -411,11 +439,13 @@ blockchainTests.resets('MixinStake unit tests', env => { it('moves the owner stake between different pointers when "from" is undelegated and "to" is delegated', async () => { const amount = getRandomInteger(0, 100e18); - const { logs } = await testContract.moveStake.awaitTransactionSuccessAsync( - { status: StakeStatus.Undelegated, poolId: VALID_POOL_IDS[0] }, - { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[1] }, - amount, - ); + const { logs } = await testContract + .moveStake( + { status: StakeStatus.Undelegated, poolId: VALID_POOL_IDS[0] }, + { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[1] }, + amount, + ) + .awaitTransactionSuccessAsync(); const events = filterLogsToArguments(logs, StakeEvents.MoveStakeStorage); expect(events).to.be.length(1); expect(events[0].fromBalanceSlot).to.eq(stakerUndelegatedStakeSlot); @@ -425,11 +455,13 @@ blockchainTests.resets('MixinStake unit tests', env => { it('moves the owner stake between different pointers when "from" is delegated and "to" is undelegated', async () => { const amount = getRandomInteger(0, 100e18); - const { logs } = await testContract.moveStake.awaitTransactionSuccessAsync( - { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[0] }, - { status: StakeStatus.Undelegated, poolId: VALID_POOL_IDS[1] }, - amount, - ); + const { logs } = await testContract + .moveStake( + { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[0] }, + { status: StakeStatus.Undelegated, poolId: VALID_POOL_IDS[1] }, + amount, + ) + .awaitTransactionSuccessAsync(); const events = filterLogsToArguments(logs, StakeEvents.MoveStakeStorage); expect(events).to.be.length(1); expect(events[0].fromBalanceSlot).to.eq(stakerDelegatedStakeSlot); @@ -439,11 +471,13 @@ blockchainTests.resets('MixinStake unit tests', env => { it('emits a `MoveStake` event', async () => { const amount = getRandomInteger(0, 100e18); - const { logs } = await testContract.moveStake.awaitTransactionSuccessAsync( - { status: StakeStatus.Undelegated, poolId: VALID_POOL_IDS[0] }, - { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[1] }, - amount, - ); + const { logs } = await testContract + .moveStake( + { status: StakeStatus.Undelegated, poolId: VALID_POOL_IDS[0] }, + { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[1] }, + amount, + ) + .awaitTransactionSuccessAsync(); const events = filterLogsToArguments(logs, StakeEvents.MoveStake); expect(events).to.be.length(1); expect(events[0].staker).to.eq(staker); diff --git a/contracts/staking/test/unit_tests/staking_pool_test.ts b/contracts/staking/test/unit_tests/staking_pool_test.ts index fef82105fb..88f31a4d9c 100644 --- a/contracts/staking/test/unit_tests/staking_pool_test.ts +++ b/contracts/staking/test/unit_tests/staking_pool_test.ts @@ -56,34 +56,36 @@ blockchainTests.resets('MixinStakingPool unit tests', env => { operatorShare: randomOperatorShare(), ...opts, }; - await testContract.setPoolById.awaitTransactionSuccessAsync(_opts.poolId, { - operator: _opts.operator, - operatorShare: _opts.operatorShare, - }); + await testContract + .setPoolById(_opts.poolId, { + operator: _opts.operator, + operatorShare: _opts.operatorShare, + }) + .awaitTransactionSuccessAsync(); return _opts; } async function addMakerToPoolAsync(poolId: string, _maker: string): Promise { - await testContract.setPoolIdByMaker.awaitTransactionSuccessAsync(poolId, _maker); + await testContract.setPoolIdByMaker(poolId, _maker).awaitTransactionSuccessAsync(); } describe('onlyStakingPoolOperator modifier', () => { it('fails if not called by the pool operator', async () => { const { poolId } = await createPoolAsync(); - const tx = testContract.testOnlyStakingPoolOperatorModifier.callAsync(poolId, { from: notOperatorOrMaker }); + const tx = testContract.testOnlyStakingPoolOperatorModifier(poolId).callAsync({ from: notOperatorOrMaker }); const expectedError = new StakingRevertErrors.OnlyCallableByPoolOperatorError(notOperatorOrMaker, poolId); return expect(tx).to.revertWith(expectedError); }); it('fails if called by a pool maker', async () => { const { poolId } = await createPoolAsync(); await addMakerToPoolAsync(poolId, maker); - const tx = testContract.testOnlyStakingPoolOperatorModifier.callAsync(poolId, { from: maker }); + const tx = testContract.testOnlyStakingPoolOperatorModifier(poolId).callAsync({ from: maker }); const expectedError = new StakingRevertErrors.OnlyCallableByPoolOperatorError(maker, poolId); return expect(tx).to.revertWith(expectedError); }); it('succeeds if called by the pool operator', async () => { const { poolId } = await createPoolAsync(); - await testContract.testOnlyStakingPoolOperatorModifier.callAsync(poolId, { from: operator }); + await testContract.testOnlyStakingPoolOperatorModifier(poolId).callAsync({ from: operator }); }); }); @@ -91,12 +93,12 @@ blockchainTests.resets('MixinStakingPool unit tests', env => { let nextPoolId: string; before(async () => { - nextPoolId = toNextPoolId(await testContract.lastPoolId.callAsync()); + nextPoolId = toNextPoolId(await testContract.lastPoolId().callAsync()); }); it('fails if the next pool ID overflows', async () => { - await testContract.setLastPoolId.awaitTransactionSuccessAsync(toHex(constants.MAX_UINT256)); - const tx = testContract.createStakingPool.awaitTransactionSuccessAsync(randomOperatorShare(), false); + await testContract.setLastPoolId(toHex(constants.MAX_UINT256)).awaitTransactionSuccessAsync(); + const tx = testContract.createStakingPool(randomOperatorShare(), false).awaitTransactionSuccessAsync(); const expectedError = new SafeMathRevertErrors.Uint256BinOpError( SafeMathRevertErrors.BinOpErrorCodes.AdditionOverflow, constants.MAX_UINT256, @@ -106,7 +108,7 @@ blockchainTests.resets('MixinStakingPool unit tests', env => { }); it('fails if the operator share is invalid', async () => { const operatorShare = constants.PPM_100_PERCENT + 1; - const tx = testContract.createStakingPool.awaitTransactionSuccessAsync(operatorShare, false); + const tx = testContract.createStakingPool(operatorShare, false).awaitTransactionSuccessAsync(); const expectedError = new StakingRevertErrors.OperatorShareError( StakingRevertErrors.OperatorShareErrorCodes.OperatorShareTooLarge, nextPoolId, @@ -115,14 +117,12 @@ blockchainTests.resets('MixinStakingPool unit tests', env => { return expect(tx).to.revertWith(expectedError); }); it('operator can create and own multiple pools', async () => { - const { logs: logs1 } = await testContract.createStakingPool.awaitTransactionSuccessAsync( - randomOperatorShare(), - false, - ); - const { logs: logs2 } = await testContract.createStakingPool.awaitTransactionSuccessAsync( - randomOperatorShare(), - false, - ); + const { logs: logs1 } = await testContract + .createStakingPool(randomOperatorShare(), false) + .awaitTransactionSuccessAsync(); + const { logs: logs2 } = await testContract + .createStakingPool(randomOperatorShare(), false) + .awaitTransactionSuccessAsync(); const createEvents = filterLogsToArguments( [...logs1, ...logs2], TestMixinStakingPoolEvents.StakingPoolCreated, @@ -130,27 +130,27 @@ blockchainTests.resets('MixinStakingPool unit tests', env => { expect(createEvents).to.be.length(2); const poolIds = createEvents.map(e => e.poolId); expect(poolIds[0]).to.not.eq(poolIds[1]); - const pools = await Promise.all(poolIds.map(async poolId => testContract.getStakingPool.callAsync(poolId))); + const pools = await Promise.all( + poolIds.map(async poolId => testContract.getStakingPool(poolId).callAsync()), + ); expect(pools[0].operator).to.eq(pools[1].operator); }); it('operator can only be maker of one pool', async () => { - await testContract.createStakingPool.awaitTransactionSuccessAsync(randomOperatorShare(), true); - const { logs } = await testContract.createStakingPool.awaitTransactionSuccessAsync( - randomOperatorShare(), - true, - ); + await testContract.createStakingPool(randomOperatorShare(), true).awaitTransactionSuccessAsync(); + const { logs } = await testContract + .createStakingPool(randomOperatorShare(), true) + .awaitTransactionSuccessAsync(); const createEvents = filterLogsToArguments( logs, TestMixinStakingPoolEvents.StakingPoolCreated, ); - const makerPool = await testContract.poolIdByMaker.callAsync(operator); + const makerPool = await testContract.poolIdByMaker(operator).callAsync(); expect(makerPool).to.eq(createEvents[0].poolId); }); it('computes correct next pool ID', async () => { - const { logs } = await testContract.createStakingPool.awaitTransactionSuccessAsync( - randomOperatorShare(), - false, - ); + const { logs } = await testContract + .createStakingPool(randomOperatorShare(), false) + .awaitTransactionSuccessAsync(); const createEvents = filterLogsToArguments( logs, TestMixinStakingPoolEvents.StakingPoolCreated, @@ -159,32 +159,32 @@ blockchainTests.resets('MixinStakingPool unit tests', env => { expect(poolId).to.eq(nextPoolId); }); it('increments last pool ID counter', async () => { - await testContract.createStakingPool.awaitTransactionSuccessAsync(randomOperatorShare(), false); - const lastPoolIdAfter = await testContract.lastPoolId.callAsync(); + await testContract.createStakingPool(randomOperatorShare(), false).awaitTransactionSuccessAsync(); + const lastPoolIdAfter = await testContract.lastPoolId().callAsync(); expect(lastPoolIdAfter).to.eq(nextPoolId); }); it('records pool details', async () => { const operatorShare = randomOperatorShare(); - await testContract.createStakingPool.awaitTransactionSuccessAsync(operatorShare, false, { from: operator }); - const pool = await testContract.getStakingPool.callAsync(nextPoolId); + await testContract.createStakingPool(operatorShare, false).awaitTransactionSuccessAsync({ from: operator }); + const pool = await testContract.getStakingPool(nextPoolId).callAsync(); expect(pool.operator).to.eq(operator); expect(pool.operatorShare).to.bignumber.eq(operatorShare); }); it('returns the next pool ID', async () => { - const poolId = await testContract.createStakingPool.callAsync(randomOperatorShare(), false, { + const poolId = await testContract.createStakingPool(randomOperatorShare(), false).callAsync({ from: operator, }); expect(poolId).to.eq(nextPoolId); }); it('can add operator as a maker', async () => { const operatorShare = randomOperatorShare(); - await testContract.createStakingPool.awaitTransactionSuccessAsync(operatorShare, true, { from: operator }); - const makerPoolId = await testContract.poolIdByMaker.callAsync(operator); + await testContract.createStakingPool(operatorShare, true).awaitTransactionSuccessAsync({ from: operator }); + const makerPoolId = await testContract.poolIdByMaker(operator).callAsync(); expect(makerPoolId).to.eq(nextPoolId); }); it('emits a `StakingPoolCreated` event', async () => { const operatorShare = randomOperatorShare(); - const { logs } = await testContract.createStakingPool.awaitTransactionSuccessAsync(operatorShare, false, { + const { logs } = await testContract.createStakingPool(operatorShare, false).awaitTransactionSuccessAsync({ from: operator, }); verifyEventsFromLogs( @@ -201,7 +201,7 @@ blockchainTests.resets('MixinStakingPool unit tests', env => { }); it('emits a `MakerStakingPoolSet` event when also joining as a maker', async () => { const operatorShare = randomOperatorShare(); - const { logs } = await testContract.createStakingPool.awaitTransactionSuccessAsync(operatorShare, true, { + const { logs } = await testContract.createStakingPool(operatorShare, true).awaitTransactionSuccessAsync({ from: operator, }); verifyEventsFromLogs( @@ -220,32 +220,26 @@ blockchainTests.resets('MixinStakingPool unit tests', env => { describe('decreaseStakingPoolOperatorShare()', () => { it('fails if not called by operator', async () => { const { poolId, operatorShare } = await createPoolAsync(); - const tx = testContract.decreaseStakingPoolOperatorShare.awaitTransactionSuccessAsync( - poolId, - operatorShare - 1, - { from: notOperatorOrMaker }, - ); + const tx = testContract + .decreaseStakingPoolOperatorShare(poolId, operatorShare - 1) + .awaitTransactionSuccessAsync({ from: notOperatorOrMaker }); const expectedError = new StakingRevertErrors.OnlyCallableByPoolOperatorError(notOperatorOrMaker, poolId); return expect(tx).to.revertWith(expectedError); }); it('fails if called by maker', async () => { const { poolId, operatorShare } = await createPoolAsync(); await addMakerToPoolAsync(poolId, maker); - const tx = testContract.decreaseStakingPoolOperatorShare.awaitTransactionSuccessAsync( - poolId, - operatorShare - 1, - { from: maker }, - ); + const tx = testContract + .decreaseStakingPoolOperatorShare(poolId, operatorShare - 1) + .awaitTransactionSuccessAsync({ from: maker }); const expectedError = new StakingRevertErrors.OnlyCallableByPoolOperatorError(maker, poolId); return expect(tx).to.revertWith(expectedError); }); it('fails if operator share is equal to current', async () => { const { poolId, operatorShare } = await createPoolAsync(); - const tx = testContract.decreaseStakingPoolOperatorShare.awaitTransactionSuccessAsync( - poolId, - operatorShare, - { from: operator }, - ); + const tx = testContract + .decreaseStakingPoolOperatorShare(poolId, operatorShare) + .awaitTransactionSuccessAsync({ from: operator }); const expectedError = new StakingRevertErrors.OperatorShareError( StakingRevertErrors.OperatorShareErrorCodes.CanOnlyDecreaseOperatorShare, poolId, @@ -255,11 +249,9 @@ blockchainTests.resets('MixinStakingPool unit tests', env => { }); it('fails if operator share is greater than current', async () => { const { poolId, operatorShare } = await createPoolAsync(); - const tx = testContract.decreaseStakingPoolOperatorShare.awaitTransactionSuccessAsync( - poolId, - operatorShare + 1, - { from: operator }, - ); + const tx = testContract + .decreaseStakingPoolOperatorShare(poolId, operatorShare + 1) + .awaitTransactionSuccessAsync({ from: operator }); const expectedError = new StakingRevertErrors.OperatorShareError( StakingRevertErrors.OperatorShareErrorCodes.CanOnlyDecreaseOperatorShare, poolId, @@ -269,11 +261,9 @@ blockchainTests.resets('MixinStakingPool unit tests', env => { }); it('fails if operator share is greater than PPM_100_PERCENT', async () => { const { poolId } = await createPoolAsync(); - const tx = testContract.decreaseStakingPoolOperatorShare.awaitTransactionSuccessAsync( - poolId, - constants.PPM_100_PERCENT + 1, - { from: operator }, - ); + const tx = testContract + .decreaseStakingPoolOperatorShare(poolId, constants.PPM_100_PERCENT + 1) + .awaitTransactionSuccessAsync({ from: operator }); const expectedError = new StakingRevertErrors.OperatorShareError( StakingRevertErrors.OperatorShareErrorCodes.OperatorShareTooLarge, poolId, @@ -283,31 +273,25 @@ blockchainTests.resets('MixinStakingPool unit tests', env => { }); it('records new operator share', async () => { const { poolId, operatorShare } = await createPoolAsync(); - await testContract.decreaseStakingPoolOperatorShare.awaitTransactionSuccessAsync( - poolId, - operatorShare - 1, - { from: operator }, - ); - const pool = await testContract.getStakingPool.callAsync(poolId); + await testContract + .decreaseStakingPoolOperatorShare(poolId, operatorShare - 1) + .awaitTransactionSuccessAsync({ from: operator }); + const pool = await testContract.getStakingPool(poolId).callAsync(); expect(pool.operatorShare).to.bignumber.eq(operatorShare - 1); }); it('does not modify operator', async () => { const { poolId, operatorShare } = await createPoolAsync(); - await testContract.decreaseStakingPoolOperatorShare.awaitTransactionSuccessAsync( - poolId, - operatorShare - 1, - { from: operator }, - ); - const pool = await testContract.getStakingPool.callAsync(poolId); + await testContract + .decreaseStakingPoolOperatorShare(poolId, operatorShare - 1) + .awaitTransactionSuccessAsync({ from: operator }); + const pool = await testContract.getStakingPool(poolId).callAsync(); expect(pool.operator).to.eq(operator); }); it('emits an `OperatorShareDecreased` event', async () => { const { poolId, operatorShare } = await createPoolAsync(); - const { logs } = await testContract.decreaseStakingPoolOperatorShare.awaitTransactionSuccessAsync( - poolId, - operatorShare - 1, - { from: operator }, - ); + const { logs } = await testContract + .decreaseStakingPoolOperatorShare(poolId, operatorShare - 1) + .awaitTransactionSuccessAsync({ from: operator }); verifyEventsFromLogs( logs, [ @@ -325,36 +309,36 @@ blockchainTests.resets('MixinStakingPool unit tests', env => { describe('joinStakingPoolAsMaker()', () => { it('records sender as maker for the pool', async () => { const { poolId } = await createPoolAsync(); - await testContract.joinStakingPoolAsMaker.awaitTransactionSuccessAsync(poolId, { from: maker }); - const makerPoolId = await testContract.poolIdByMaker.callAsync(maker); + await testContract.joinStakingPoolAsMaker(poolId).awaitTransactionSuccessAsync({ from: maker }); + const makerPoolId = await testContract.poolIdByMaker(maker).callAsync(); expect(makerPoolId).to.eq(poolId); }); it('operator can join as maker for the pool', async () => { const { poolId } = await createPoolAsync(); - await testContract.joinStakingPoolAsMaker.awaitTransactionSuccessAsync(poolId, { from: operator }); - const makerPoolId = await testContract.poolIdByMaker.callAsync(operator); + await testContract.joinStakingPoolAsMaker(poolId).awaitTransactionSuccessAsync({ from: operator }); + const makerPoolId = await testContract.poolIdByMaker(operator).callAsync(); expect(makerPoolId).to.eq(poolId); }); it('can join the same pool as a maker twice', async () => { const { poolId } = await createPoolAsync(); - await testContract.joinStakingPoolAsMaker.awaitTransactionSuccessAsync(poolId, { from: maker }); - await testContract.joinStakingPoolAsMaker.awaitTransactionSuccessAsync(poolId, { from: maker }); - const makerPoolId = await testContract.poolIdByMaker.callAsync(maker); + await testContract.joinStakingPoolAsMaker(poolId).awaitTransactionSuccessAsync({ from: maker }); + await testContract.joinStakingPoolAsMaker(poolId).awaitTransactionSuccessAsync({ from: maker }); + const makerPoolId = await testContract.poolIdByMaker(maker).callAsync(); expect(makerPoolId).to.eq(poolId); }); it('can only be a maker in one pool at a time', async () => { const { poolId: poolId1 } = await createPoolAsync(); const { poolId: poolId2 } = await createPoolAsync(); - await testContract.joinStakingPoolAsMaker.awaitTransactionSuccessAsync(poolId1, { from: maker }); - let makerPoolId = await testContract.poolIdByMaker.callAsync(maker); + await testContract.joinStakingPoolAsMaker(poolId1).awaitTransactionSuccessAsync({ from: maker }); + let makerPoolId = await testContract.poolIdByMaker(maker).callAsync(); expect(makerPoolId).to.eq(poolId1); - await testContract.joinStakingPoolAsMaker.awaitTransactionSuccessAsync(poolId2, { from: maker }); - makerPoolId = await testContract.poolIdByMaker.callAsync(maker); + await testContract.joinStakingPoolAsMaker(poolId2).awaitTransactionSuccessAsync({ from: maker }); + makerPoolId = await testContract.poolIdByMaker(maker).callAsync(); expect(makerPoolId).to.eq(poolId2); }); it('emits a `MakerStakingPoolSet` event', async () => { const { poolId } = await createPoolAsync(); - const { logs } = await testContract.joinStakingPoolAsMaker.awaitTransactionSuccessAsync(poolId, { + const { logs } = await testContract.joinStakingPoolAsMaker(poolId).awaitTransactionSuccessAsync({ from: maker, }); verifyEventsFromLogs( diff --git a/contracts/staking/test/unit_tests/staking_proxy_test.ts b/contracts/staking/test/unit_tests/staking_proxy_test.ts index 825ed7f2bb..d5333286de 100644 --- a/contracts/staking/test/unit_tests/staking_proxy_test.ts +++ b/contracts/staking/test/unit_tests/staking_proxy_test.ts @@ -59,23 +59,23 @@ blockchainTests.resets('StakingProxy unit tests', env => { ); // Add authorized address to Staking Proxy - await testProxyContract.addAuthorizedAddress.sendTransactionAsync(authorizedAddress, { from: owner }); + await testProxyContract.addAuthorizedAddress(authorizedAddress).sendTransactionAsync({ from: owner }); }); describe('Fallback function', () => { it('should pass back the return value of the destination contract', async () => { - const returnValue = await testContractViaProxy.echo.callAsync(testString); + const returnValue = await testContractViaProxy.echo(testString).callAsync(); expect(returnValue).to.equal(testString); }); it('should revert with correct value when destination reverts', async () => { - return expect(testContractViaProxy.die.callAsync()).to.revertWith(testRevertString); + return expect(testContractViaProxy.die().callAsync()).to.revertWith(testRevertString); }); it('should revert if no staking contract is attached', async () => { - await testProxyContract.detachStakingContract.awaitTransactionSuccessAsync({ from: authorizedAddress }); + await testProxyContract.detachStakingContract().awaitTransactionSuccessAsync({ from: authorizedAddress }); const expectedError = new StakingRevertErrors.ProxyDestinationCannotBeNilError(); - const tx = testContractViaProxy.echo.callAsync(testString); + const tx = testContractViaProxy.echo(testString).callAsync(); return expect(tx).to.revertWith(expectedError); }); }); @@ -83,11 +83,10 @@ blockchainTests.resets('StakingProxy unit tests', env => { describe('attachStakingContract', () => { it('should successfully attaching a new staking contract', async () => { // Cache existing staking contract and attach a new one - const initStakingContractAddress = await testProxyContract.stakingContract.callAsync(); - const txReceipt = await testProxyContract.attachStakingContract.awaitTransactionSuccessAsync( - testContract2.address, - { from: authorizedAddress }, - ); + const initStakingContractAddress = await testProxyContract.stakingContract().callAsync(); + const txReceipt = await testProxyContract + .attachStakingContract(testContract2.address) + .awaitTransactionSuccessAsync({ from: authorizedAddress }); // Validate `ContractAttachedToProxy` event verifyEventsFromLogs( @@ -112,14 +111,14 @@ blockchainTests.resets('StakingProxy unit tests', env => { ); // Validate new staking contract address - const finalStakingContractAddress = await testProxyContract.stakingContract.callAsync(); + const finalStakingContractAddress = await testProxyContract.stakingContract().callAsync(); expect(finalStakingContractAddress).to.be.equal(testContract2.address); expect(finalStakingContractAddress).to.not.equal(initStakingContractAddress); }); it('should revert if call to `init` on new staking contract fails', async () => { - await testProxyContract.setInitFailFlag.awaitTransactionSuccessAsync(); - const tx = testProxyContract.attachStakingContract.awaitTransactionSuccessAsync(testContract2.address, { + await testProxyContract.setInitFailFlag().awaitTransactionSuccessAsync(); + const tx = testProxyContract.attachStakingContract(testContract2.address).awaitTransactionSuccessAsync({ from: authorizedAddress, }); const expectedError = 'INIT_FAIL_FLAG_SET'; @@ -127,7 +126,7 @@ blockchainTests.resets('StakingProxy unit tests', env => { }); it('should revert if called by unauthorized address', async () => { - const tx = testProxyContract.attachStakingContract.awaitTransactionSuccessAsync(testContract2.address, { + const tx = testProxyContract.attachStakingContract(testContract2.address).awaitTransactionSuccessAsync({ from: notAuthorizedAddresses[0], }); const expectedError = new AuthorizableRevertErrors.SenderNotAuthorizedError(notAuthorizedAddresses[0]); @@ -138,8 +137,8 @@ blockchainTests.resets('StakingProxy unit tests', env => { describe('detachStakingContract', () => { it('should detach staking contract', async () => { // Cache existing staking contract and attach a new one - const initStakingContractAddress = await testProxyContract.stakingContract.callAsync(); - const txReceipt = await testProxyContract.detachStakingContract.awaitTransactionSuccessAsync({ + const initStakingContractAddress = await testProxyContract.stakingContract().callAsync(); + const txReceipt = await testProxyContract.detachStakingContract().awaitTransactionSuccessAsync({ from: authorizedAddress, }); @@ -147,13 +146,13 @@ blockchainTests.resets('StakingProxy unit tests', env => { verifyEventsFromLogs(txReceipt.logs, [{}], StakingProxyEvents.StakingContractDetachedFromProxy); // Validate staking contract address was unset - const finalStakingContractAddress = await testProxyContract.stakingContract.callAsync(); + const finalStakingContractAddress = await testProxyContract.stakingContract().callAsync(); expect(finalStakingContractAddress).to.be.equal(stakingConstants.NIL_ADDRESS); expect(finalStakingContractAddress).to.not.equal(initStakingContractAddress); }); it('should revert if called by unauthorized address', async () => { - const tx = testProxyContract.detachStakingContract.awaitTransactionSuccessAsync({ + const tx = testProxyContract.detachStakingContract().awaitTransactionSuccessAsync({ from: notAuthorizedAddresses[0], }); const expectedError = new AuthorizableRevertErrors.SenderNotAuthorizedError(notAuthorizedAddresses[0]); @@ -163,27 +162,27 @@ blockchainTests.resets('StakingProxy unit tests', env => { describe('batchExecute', () => { it('should execute no-op if no calls to make', async () => { - await testProxyContract.batchExecute.awaitTransactionSuccessAsync([]); + await testProxyContract.batchExecute([]).awaitTransactionSuccessAsync(); }); it('should call one function and return the output', async () => { - const calls = [testContract.echo.getABIEncodedTransactionData(testString)]; - const rawResults = await testProxyContract.batchExecute.callAsync(calls); + const calls = [testContract.echo(testString).getABIEncodedTransactionData()]; + const rawResults = await testProxyContract.batchExecute(calls).callAsync(); expect(rawResults.length).to.equal(1); - const returnValues = [testContract.echo.getABIDecodedReturnData(rawResults[0])]; + const returnValues = [testContract.getABIDecodedReturnData('echo', rawResults[0])]; expect(returnValues[0]).to.equal(testString); }); it('should call multiple functions and return their outputs', async () => { const calls = [ - testContract.echo.getABIEncodedTransactionData(testString), - testContract.doMath.getABIEncodedTransactionData(new BigNumber(2), new BigNumber(1)), + testContract.echo(testString).getABIEncodedTransactionData(), + testContract.doMath(new BigNumber(2), new BigNumber(1)).getABIEncodedTransactionData(), ]; - const rawResults = await testProxyContract.batchExecute.callAsync(calls); + const rawResults = await testProxyContract.batchExecute(calls).callAsync(); expect(rawResults.length).to.equal(2); const returnValues = [ - testContract.echo.getABIDecodedReturnData(rawResults[0]), - testContract.doMath.getABIDecodedReturnData(rawResults[1]), + testContract.getABIDecodedReturnData('echo', rawResults[0]), + testContract.getABIDecodedReturnData('doMath', rawResults[1]), ]; expect(returnValues[0]).to.equal(testString); expect(returnValues[1][0]).to.bignumber.equal(new BigNumber(3)); @@ -192,20 +191,20 @@ blockchainTests.resets('StakingProxy unit tests', env => { it('should revert if a call reverts', async () => { const calls = [ - testContract.echo.getABIEncodedTransactionData(testString), - testContract.die.getABIEncodedTransactionData(), - testContract.doMath.getABIEncodedTransactionData(new BigNumber(2), new BigNumber(1)), + testContract.echo(testString).getABIEncodedTransactionData(), + testContract.die().getABIEncodedTransactionData(), + testContract.doMath(new BigNumber(2), new BigNumber(1)).getABIEncodedTransactionData(), ]; - const tx = testProxyContract.batchExecute.callAsync(calls); + const tx = testProxyContract.batchExecute(calls).callAsync(); const expectedError = testRevertString; return expect(tx).to.revertWith(expectedError); }); it('should revert if no staking contract is attached', async () => { - await testProxyContract.detachStakingContract.awaitTransactionSuccessAsync({ from: authorizedAddress }); - const calls = [testContract.echo.getABIEncodedTransactionData(testString)]; + await testProxyContract.detachStakingContract().awaitTransactionSuccessAsync({ from: authorizedAddress }); + const calls = [testContract.echo(testString).getABIEncodedTransactionData()]; - const tx = testProxyContract.batchExecute.callAsync(calls); + const tx = testProxyContract.batchExecute(calls).callAsync(); const expectedError = new StakingRevertErrors.ProxyDestinationCannotBeNilError(); return expect(tx).to.revertWith(expectedError); }); @@ -220,16 +219,16 @@ blockchainTests.resets('StakingProxy unit tests', env => { minimumPoolStake: new BigNumber(100), }; it('should not revert if all storage params are valid', async () => { - await testProxyContract.setTestStorageParams.awaitTransactionSuccessAsync(validStorageParams); - await testProxyContract.assertValidStorageParams.callAsync(); + await testProxyContract.setTestStorageParams(validStorageParams).awaitTransactionSuccessAsync(); + await testProxyContract.assertValidStorageParams().callAsync(); }); it('should revert if `epochDurationInSeconds` is less than 5 days', async () => { const invalidStorageParams = { ...validStorageParams, epochDurationInSeconds: new BigNumber(0), }; - await testProxyContract.setTestStorageParams.awaitTransactionSuccessAsync(invalidStorageParams); - const tx = testProxyContract.assertValidStorageParams.callAsync(); + await testProxyContract.setTestStorageParams(invalidStorageParams).awaitTransactionSuccessAsync(); + const tx = testProxyContract.assertValidStorageParams().callAsync(); const expectedError = new StakingRevertErrors.InvalidParamValueError( StakingRevertErrors.InvalidParamValueErrorCodes.InvalidEpochDuration, ); @@ -240,8 +239,8 @@ blockchainTests.resets('StakingProxy unit tests', env => { ...validStorageParams, epochDurationInSeconds: new BigNumber(stakingConstants.ONE_DAY_IN_SECONDS * 31), }; - await testProxyContract.setTestStorageParams.awaitTransactionSuccessAsync(invalidStorageParams); - const tx = testProxyContract.assertValidStorageParams.callAsync(); + await testProxyContract.setTestStorageParams(invalidStorageParams).awaitTransactionSuccessAsync(); + const tx = testProxyContract.assertValidStorageParams().callAsync(); const expectedError = new StakingRevertErrors.InvalidParamValueError( StakingRevertErrors.InvalidParamValueErrorCodes.InvalidEpochDuration, ); @@ -253,8 +252,8 @@ blockchainTests.resets('StakingProxy unit tests', env => { cobbDouglasAlphaNumerator: new BigNumber(2), cobbDouglasAlphaDenominator: new BigNumber(1), }; - await testProxyContract.setTestStorageParams.awaitTransactionSuccessAsync(invalidStorageParams); - const tx = testProxyContract.assertValidStorageParams.callAsync(); + await testProxyContract.setTestStorageParams(invalidStorageParams).awaitTransactionSuccessAsync(); + const tx = testProxyContract.assertValidStorageParams().callAsync(); const expectedError = new StakingRevertErrors.InvalidParamValueError( StakingRevertErrors.InvalidParamValueErrorCodes.InvalidCobbDouglasAlpha, ); @@ -265,8 +264,8 @@ blockchainTests.resets('StakingProxy unit tests', env => { ...validStorageParams, cobbDouglasAlphaDenominator: new BigNumber(0), }; - await testProxyContract.setTestStorageParams.awaitTransactionSuccessAsync(invalidStorageParams); - const tx = testProxyContract.assertValidStorageParams.callAsync(); + await testProxyContract.setTestStorageParams(invalidStorageParams).awaitTransactionSuccessAsync(); + const tx = testProxyContract.assertValidStorageParams().callAsync(); const expectedError = new StakingRevertErrors.InvalidParamValueError( StakingRevertErrors.InvalidParamValueErrorCodes.InvalidCobbDouglasAlpha, ); @@ -277,8 +276,8 @@ blockchainTests.resets('StakingProxy unit tests', env => { ...validStorageParams, rewardDelegatedStakeWeight: new BigNumber(constants.PPM_DENOMINATOR + 1), }; - await testProxyContract.setTestStorageParams.awaitTransactionSuccessAsync(invalidStorageParams); - const tx = testProxyContract.assertValidStorageParams.callAsync(); + await testProxyContract.setTestStorageParams(invalidStorageParams).awaitTransactionSuccessAsync(); + const tx = testProxyContract.assertValidStorageParams().callAsync(); const expectedError = new StakingRevertErrors.InvalidParamValueError( StakingRevertErrors.InvalidParamValueErrorCodes.InvalidRewardDelegatedStakeWeight, ); @@ -289,8 +288,8 @@ blockchainTests.resets('StakingProxy unit tests', env => { ...validStorageParams, minimumPoolStake: new BigNumber(1), }; - await testProxyContract.setTestStorageParams.awaitTransactionSuccessAsync(invalidStorageParams); - const tx = testProxyContract.assertValidStorageParams.callAsync(); + await testProxyContract.setTestStorageParams(invalidStorageParams).awaitTransactionSuccessAsync(); + const tx = testProxyContract.assertValidStorageParams().callAsync(); const expectedError = new StakingRevertErrors.InvalidParamValueError( StakingRevertErrors.InvalidParamValueErrorCodes.InvalidMinimumPoolStake, ); diff --git a/contracts/staking/test/unit_tests/zrx_vault_test.ts b/contracts/staking/test/unit_tests/zrx_vault_test.ts index 6c2209ce44..3b4a54aba6 100644 --- a/contracts/staking/test/unit_tests/zrx_vault_test.ts +++ b/contracts/staking/test/unit_tests/zrx_vault_test.ts @@ -48,7 +48,7 @@ blockchainTests.resets('ZrxVault unit tests', env => { zrxProxyAddress = erc20ProxyContract.address; // deploy zrx token const [zrxTokenContract] = await erc20Wrapper.deployDummyTokensAsync(1, constants.DUMMY_TOKEN_DECIMALS); - zrxAssetData = await devUtils.encodeERC20AssetData.callAsync(zrxTokenContract.address); + zrxAssetData = await devUtils.encodeERC20AssetData(zrxTokenContract.address).callAsync(); await erc20Wrapper.setBalancesAndAllowancesAsync(); @@ -61,10 +61,10 @@ blockchainTests.resets('ZrxVault unit tests', env => { zrxTokenContract.address, ); - await zrxVault.addAuthorizedAddress.awaitTransactionSuccessAsync(owner); + await zrxVault.addAuthorizedAddress(owner).awaitTransactionSuccessAsync(); // configure erc20 proxy to accept calls from zrx vault - await erc20ProxyContract.addAuthorizedAddress.awaitTransactionSuccessAsync(zrxVault.address); + await erc20ProxyContract.addAuthorizedAddress(zrxVault.address).awaitTransactionSuccessAsync(); }); enum ZrxTransfer { @@ -88,7 +88,7 @@ blockchainTests.resets('ZrxVault unit tests', env => { expect(eventArgs[0].staker).to.equal(staker); expect(eventArgs[0].amount).to.bignumber.equal(amount); - const newVaultBalance = await zrxVault.balanceOf.callAsync(staker); + const newVaultBalance = await zrxVault.balanceOf(staker).callAsync(); const newTokenBalance = await erc20Wrapper.getBalanceAsync(staker, zrxAssetData); const [expectedVaultBalance, expectedTokenBalance] = transferType === ZrxTransfer.Deposit @@ -110,13 +110,13 @@ blockchainTests.resets('ZrxVault unit tests', env => { ); expect(eventArgs.length).to.equal(1); expect(eventArgs[0].stakingProxyAddress).to.equal(newProxy); - const actualAddress = await zrxVault.stakingProxyAddress.callAsync(); + const actualAddress = await zrxVault.stakingProxyAddress().callAsync(); expect(actualAddress).to.equal(newProxy); } it('Owner can set the ZRX proxy', async () => { const newProxy = nonOwnerAddresses[0]; - const receipt = await zrxVault.setZrxProxy.awaitTransactionSuccessAsync(newProxy, { + const receipt = await zrxVault.setZrxProxy(newProxy).awaitTransactionSuccessAsync({ from: owner, }); const eventArgs = filterLogsToArguments(receipt.logs, 'ZrxProxySet'); @@ -125,8 +125,8 @@ blockchainTests.resets('ZrxVault unit tests', env => { }); it('Authorized address can set the ZRX proxy', async () => { const [authorized, newProxy] = nonOwnerAddresses; - await zrxVault.addAuthorizedAddress.awaitTransactionSuccessAsync(authorized, { from: owner }); - const receipt = await zrxVault.setZrxProxy.awaitTransactionSuccessAsync(newProxy, { + await zrxVault.addAuthorizedAddress(authorized).awaitTransactionSuccessAsync({ from: owner }); + const receipt = await zrxVault.setZrxProxy(newProxy).awaitTransactionSuccessAsync({ from: authorized, }); const eventArgs = filterLogsToArguments(receipt.logs, 'ZrxProxySet'); @@ -135,7 +135,7 @@ blockchainTests.resets('ZrxVault unit tests', env => { }); it('Non-authorized address cannot set the ZRX proxy', async () => { const [notAuthorized, newProxy] = nonOwnerAddresses; - const tx = zrxVault.setZrxProxy.awaitTransactionSuccessAsync(newProxy, { + const tx = zrxVault.setZrxProxy(newProxy).awaitTransactionSuccessAsync({ from: notAuthorized, }); const expectedError = new AuthorizableRevertErrors.SenderNotAuthorizedError(notAuthorized); @@ -143,27 +143,27 @@ blockchainTests.resets('ZrxVault unit tests', env => { }); it('Owner can set the staking proxy', async () => { const newProxy = nonOwnerAddresses[0]; - const receipt = await zrxVault.setStakingProxy.awaitTransactionSuccessAsync(newProxy, { + const receipt = await zrxVault.setStakingProxy(newProxy).awaitTransactionSuccessAsync({ from: owner, }); await verifyStakingProxySetAsync(receipt, newProxy); }); it('Authorized address can set the staking proxy', async () => { const [authorized, newProxy] = nonOwnerAddresses; - await zrxVault.addAuthorizedAddress.awaitTransactionSuccessAsync(authorized, { from: owner }); - const receipt = await zrxVault.setStakingProxy.awaitTransactionSuccessAsync(newProxy, { + await zrxVault.addAuthorizedAddress(authorized).awaitTransactionSuccessAsync({ from: owner }); + const receipt = await zrxVault.setStakingProxy(newProxy).awaitTransactionSuccessAsync({ from: authorized, }); await verifyStakingProxySetAsync(receipt, newProxy); }); it('Non-authorized address cannot set the staking proxy', async () => { const [notAuthorized, newProxy] = nonOwnerAddresses; - const tx = zrxVault.setStakingProxy.awaitTransactionSuccessAsync(newProxy, { + const tx = zrxVault.setStakingProxy(newProxy).awaitTransactionSuccessAsync({ from: notAuthorized, }); const expectedError = new AuthorizableRevertErrors.SenderNotAuthorizedError(notAuthorized); expect(tx).to.revertWith(expectedError); - const actualAddress = await zrxVault.stakingProxyAddress.callAsync(); + const actualAddress = await zrxVault.stakingProxyAddress().callAsync(); expect(actualAddress).to.equal(stakingConstants.NIL_ADDRESS); }); }); @@ -175,26 +175,24 @@ blockchainTests.resets('ZrxVault unit tests', env => { before(async () => { [staker, stakingProxy] = nonOwnerAddresses; - await zrxVault.setStakingProxy.awaitTransactionSuccessAsync(stakingProxy, { from: owner }); - await zrxVault.depositFrom.awaitTransactionSuccessAsync(staker, new BigNumber(10), { + await zrxVault.setStakingProxy(stakingProxy).awaitTransactionSuccessAsync({ from: owner }); + await zrxVault.depositFrom(staker, new BigNumber(10)).awaitTransactionSuccessAsync({ from: stakingProxy, }); }); beforeEach(async () => { - initialVaultBalance = await zrxVault.balanceOf.callAsync(staker); + initialVaultBalance = await zrxVault.balanceOf(staker).callAsync(); initialTokenBalance = await erc20Wrapper.getBalanceAsync(staker, zrxAssetData); }); describe('Deposit', () => { it('Staking proxy can deposit zero amount on behalf of staker', async () => { - const receipt = await zrxVault.depositFrom.awaitTransactionSuccessAsync( - staker, - constants.ZERO_AMOUNT, - { + const receipt = await zrxVault + .depositFrom(staker, constants.ZERO_AMOUNT) + .awaitTransactionSuccessAsync({ from: stakingProxy, - }, - ); + }); await verifyTransferPostconditionsAsync( ZrxTransfer.Deposit, staker, @@ -205,7 +203,7 @@ blockchainTests.resets('ZrxVault unit tests', env => { ); }); it('Staking proxy can deposit nonzero amount on behalf of staker', async () => { - const receipt = await zrxVault.depositFrom.awaitTransactionSuccessAsync(staker, new BigNumber(1), { + const receipt = await zrxVault.depositFrom(staker, new BigNumber(1)).awaitTransactionSuccessAsync({ from: stakingProxy, }); await verifyTransferPostconditionsAsync( @@ -218,13 +216,11 @@ blockchainTests.resets('ZrxVault unit tests', env => { ); }); it('Staking proxy can deposit entire ZRX balance on behalf of staker', async () => { - const receipt = await zrxVault.depositFrom.awaitTransactionSuccessAsync( - staker, - initialTokenBalance, - { + const receipt = await zrxVault + .depositFrom(staker, initialTokenBalance) + .awaitTransactionSuccessAsync({ from: stakingProxy, - }, - ); + }); await verifyTransferPostconditionsAsync( ZrxTransfer.Deposit, staker, @@ -235,7 +231,7 @@ blockchainTests.resets('ZrxVault unit tests', env => { ); }); it("Reverts if attempting to deposit more than staker's ZRX balance", async () => { - const tx = zrxVault.depositFrom.sendTransactionAsync(staker, initialTokenBalance.plus(1), { + const tx = zrxVault.depositFrom(staker, initialTokenBalance.plus(1)).sendTransactionAsync({ from: stakingProxy, }); expectTransactionFailedAsync(tx, RevertReason.TransferFailed); @@ -243,13 +239,11 @@ blockchainTests.resets('ZrxVault unit tests', env => { }); describe('Withdrawal', () => { it('Staking proxy can withdraw zero amount on behalf of staker', async () => { - const receipt = await zrxVault.withdrawFrom.awaitTransactionSuccessAsync( - staker, - constants.ZERO_AMOUNT, - { + const receipt = await zrxVault + .withdrawFrom(staker, constants.ZERO_AMOUNT) + .awaitTransactionSuccessAsync({ from: stakingProxy, - }, - ); + }); await verifyTransferPostconditionsAsync( ZrxTransfer.Withdrawal, staker, @@ -260,7 +254,7 @@ blockchainTests.resets('ZrxVault unit tests', env => { ); }); it('Staking proxy can withdraw nonzero amount on behalf of staker', async () => { - const receipt = await zrxVault.withdrawFrom.awaitTransactionSuccessAsync(staker, new BigNumber(1), { + const receipt = await zrxVault.withdrawFrom(staker, new BigNumber(1)).awaitTransactionSuccessAsync({ from: stakingProxy, }); await verifyTransferPostconditionsAsync( @@ -273,13 +267,11 @@ blockchainTests.resets('ZrxVault unit tests', env => { ); }); it('Staking proxy can withdraw entire vault balance on behalf of staker', async () => { - const receipt = await zrxVault.withdrawFrom.awaitTransactionSuccessAsync( - staker, - initialVaultBalance, - { + const receipt = await zrxVault + .withdrawFrom(staker, initialVaultBalance) + .awaitTransactionSuccessAsync({ from: stakingProxy, - }, - ); + }); await verifyTransferPostconditionsAsync( ZrxTransfer.Withdrawal, staker, @@ -290,7 +282,7 @@ blockchainTests.resets('ZrxVault unit tests', env => { ); }); it("Reverts if attempting to withdraw more than staker's vault balance", async () => { - const tx = zrxVault.withdrawFrom.awaitTransactionSuccessAsync(staker, initialVaultBalance.plus(1), { + const tx = zrxVault.withdrawFrom(staker, initialVaultBalance.plus(1)).awaitTransactionSuccessAsync({ from: stakingProxy, }); const expectedError = new SafeMathRevertErrors.Uint256BinOpError( @@ -316,38 +308,38 @@ blockchainTests.resets('ZrxVault unit tests', env => { ); expect(eventArgs.length).to.equal(1); expect(eventArgs[0].sender).to.equal(sender); - expect(await zrxVault.isInCatastrophicFailure.callAsync()).to.be.true(); + expect(await zrxVault.isInCatastrophicFailure().callAsync()).to.be.true(); } it('Owner can turn on Catastrophic Failure Mode', async () => { - const receipt = await zrxVault.enterCatastrophicFailure.awaitTransactionSuccessAsync({ from: owner }); + const receipt = await zrxVault.enterCatastrophicFailure().awaitTransactionSuccessAsync({ from: owner }); await verifyCatastrophicFailureModeAsync(owner, receipt); }); it('Authorized address can turn on Catastrophic Failure Mode', async () => { const authorized = nonOwnerAddresses[0]; - await zrxVault.addAuthorizedAddress.awaitTransactionSuccessAsync(authorized, { from: owner }); - const receipt = await zrxVault.enterCatastrophicFailure.awaitTransactionSuccessAsync({ + await zrxVault.addAuthorizedAddress(authorized).awaitTransactionSuccessAsync({ from: owner }); + const receipt = await zrxVault.enterCatastrophicFailure().awaitTransactionSuccessAsync({ from: authorized, }); await verifyCatastrophicFailureModeAsync(authorized, receipt); }); it('Non-authorized address cannot turn on Catastrophic Failure Mode', async () => { const notAuthorized = nonOwnerAddresses[0]; - const tx = zrxVault.enterCatastrophicFailure.awaitTransactionSuccessAsync({ + const tx = zrxVault.enterCatastrophicFailure().awaitTransactionSuccessAsync({ from: notAuthorized, }); const expectedError = new AuthorizableRevertErrors.SenderNotAuthorizedError(notAuthorized); expect(tx).to.revertWith(expectedError); - expect(await zrxVault.isInCatastrophicFailure.callAsync()).to.be.false(); + expect(await zrxVault.isInCatastrophicFailure().callAsync()).to.be.false(); }); it('Catastrophic Failure Mode can only be turned on once', async () => { const authorized = nonOwnerAddresses[0]; - await zrxVault.addAuthorizedAddress.awaitTransactionSuccessAsync(authorized, { from: owner }); - await zrxVault.enterCatastrophicFailure.awaitTransactionSuccessAsync({ + await zrxVault.addAuthorizedAddress(authorized).awaitTransactionSuccessAsync({ from: owner }); + await zrxVault.enterCatastrophicFailure().awaitTransactionSuccessAsync({ from: authorized, }); const expectedError = new StakingRevertErrors.OnlyCallableIfNotInCatastrophicFailureError(); - return expect(zrxVault.enterCatastrophicFailure.awaitTransactionSuccessAsync()).to.revertWith( + return expect(zrxVault.enterCatastrophicFailure().awaitTransactionSuccessAsync()).to.revertWith( expectedError, ); }); @@ -361,41 +353,41 @@ blockchainTests.resets('ZrxVault unit tests', env => { before(async () => { [staker, stakingProxy, ...nonOwnerAddresses] = nonOwnerAddresses; - await zrxVault.setStakingProxy.awaitTransactionSuccessAsync(stakingProxy, { from: owner }); - await zrxVault.depositFrom.awaitTransactionSuccessAsync(staker, new BigNumber(10), { + await zrxVault.setStakingProxy(stakingProxy).awaitTransactionSuccessAsync({ from: owner }); + await zrxVault.depositFrom(staker, new BigNumber(10)).awaitTransactionSuccessAsync({ from: stakingProxy, }); - await zrxVault.enterCatastrophicFailure.awaitTransactionSuccessAsync({ from: owner }); + await zrxVault.enterCatastrophicFailure().awaitTransactionSuccessAsync({ from: owner }); }); beforeEach(async () => { - initialVaultBalance = await zrxVault.balanceOf.callAsync(staker); + initialVaultBalance = await zrxVault.balanceOf(staker).callAsync(); initialTokenBalance = await erc20Wrapper.getBalanceAsync(staker, zrxAssetData); }); it('Owner cannot set the ZRX proxy', async () => { const newProxy = nonOwnerAddresses[0]; - const tx = zrxVault.setZrxProxy.awaitTransactionSuccessAsync(newProxy, { + const tx = zrxVault.setZrxProxy(newProxy).awaitTransactionSuccessAsync({ from: owner, }); const expectedError = new StakingRevertErrors.OnlyCallableIfNotInCatastrophicFailureError(); expect(tx).to.revertWith(expectedError); - const actualAddress = await zrxVault.zrxAssetProxy.callAsync(); + const actualAddress = await zrxVault.zrxAssetProxy().callAsync(); expect(actualAddress).to.equal(zrxProxyAddress); }); it('Authorized address cannot set the ZRX proxy', async () => { const [authorized, newProxy] = nonOwnerAddresses; - await zrxVault.addAuthorizedAddress.awaitTransactionSuccessAsync(authorized, { from: owner }); - const tx = zrxVault.setZrxProxy.awaitTransactionSuccessAsync(newProxy, { + await zrxVault.addAuthorizedAddress(authorized).awaitTransactionSuccessAsync({ from: owner }); + const tx = zrxVault.setZrxProxy(newProxy).awaitTransactionSuccessAsync({ from: authorized, }); const expectedError = new StakingRevertErrors.OnlyCallableIfNotInCatastrophicFailureError(); expect(tx).to.revertWith(expectedError); - const actualAddress = await zrxVault.zrxAssetProxy.callAsync(); + const actualAddress = await zrxVault.zrxAssetProxy().callAsync(); expect(actualAddress).to.equal(zrxProxyAddress); }); it('Staking proxy cannot deposit ZRX', async () => { - const tx = zrxVault.depositFrom.awaitTransactionSuccessAsync(staker, new BigNumber(1), { + const tx = zrxVault.depositFrom(staker, new BigNumber(1)).awaitTransactionSuccessAsync({ from: stakingProxy, }); const expectedError = new StakingRevertErrors.OnlyCallableIfNotInCatastrophicFailureError(); @@ -404,14 +396,14 @@ blockchainTests.resets('ZrxVault unit tests', env => { describe('Withdrawal', () => { it('Staking proxy cannot call `withdrawFrom`', async () => { - const tx = zrxVault.withdrawFrom.awaitTransactionSuccessAsync(staker, new BigNumber(1), { + const tx = zrxVault.withdrawFrom(staker, new BigNumber(1)).awaitTransactionSuccessAsync({ from: stakingProxy, }); const expectedError = new StakingRevertErrors.OnlyCallableIfNotInCatastrophicFailureError(); expect(tx).to.revertWith(expectedError); }); it('Staker can withdraw all their ZRX', async () => { - const receipt = await zrxVault.withdrawAllFrom.awaitTransactionSuccessAsync(staker, { + const receipt = await zrxVault.withdrawAllFrom(staker).awaitTransactionSuccessAsync({ from: staker, }); await verifyTransferPostconditionsAsync( @@ -424,7 +416,7 @@ blockchainTests.resets('ZrxVault unit tests', env => { ); }); it('Owner can withdraw ZRX on behalf of a staker', async () => { - const receipt = await zrxVault.withdrawAllFrom.awaitTransactionSuccessAsync(staker, { + const receipt = await zrxVault.withdrawAllFrom(staker).awaitTransactionSuccessAsync({ from: owner, }); await verifyTransferPostconditionsAsync( @@ -437,7 +429,7 @@ blockchainTests.resets('ZrxVault unit tests', env => { ); }); it('Non-owner address can withdraw ZRX on behalf of a staker', async () => { - const receipt = await zrxVault.withdrawAllFrom.awaitTransactionSuccessAsync(staker, { + const receipt = await zrxVault.withdrawAllFrom(staker).awaitTransactionSuccessAsync({ from: nonOwnerAddresses[0], }); await verifyTransferPostconditionsAsync( diff --git a/contracts/staking/test/utils/api_wrapper.ts b/contracts/staking/test/utils/api_wrapper.ts index 11fba1b467..922422446e 100644 --- a/contracts/staking/test/utils/api_wrapper.ts +++ b/contracts/staking/test/utils/api_wrapper.ts @@ -36,7 +36,7 @@ export class StakingApiWrapper { fastForwardToNextEpochAsync: async (): Promise => { // increase timestamp of next block by how many seconds we need to // get to the next epoch. - const epochEndTime = await this.stakingContract.getCurrentEpochEarliestEndTimeInSeconds.callAsync(); + const epochEndTime = await this.stakingContract.getCurrentEpochEarliestEndTimeInSeconds().callAsync(); const lastBlockTime = await this._web3Wrapper.getBlockTimestampAsync('latest'); const dt = Math.max(0, epochEndTime.minus(lastBlockTime).toNumber()); await this._web3Wrapper.increaseTimeAsync(dt); @@ -49,7 +49,7 @@ export class StakingApiWrapper { const endOfEpochInfo = await this.utils.endEpochAsync(); const allLogs = [] as DecodedLogs; for (const poolId of endOfEpochInfo.activePoolIds) { - const receipt = await this.stakingContract.finalizePool.awaitTransactionSuccessAsync(poolId); + const receipt = await this.stakingContract.finalizePool(poolId).awaitTransactionSuccessAsync(); allLogs.splice(allLogs.length, 0, ...(receipt.logs as DecodedLogs)); } return allLogs; @@ -57,7 +57,7 @@ export class StakingApiWrapper { endEpochAsync: async (): Promise => { const activePoolIds = await this.utils.findActivePoolIdsAsync(); - const receipt = await this.stakingContract.endEpoch.awaitTransactionSuccessAsync(); + const receipt = await this.stakingContract.endEpoch().awaitTransactionSuccessAsync(); const [epochEndedEvent] = filterLogsToArguments( receipt.logs, TestStakingEvents.EpochEnded, @@ -72,7 +72,7 @@ export class StakingApiWrapper { }, findActivePoolIdsAsync: async (epoch?: number): Promise => { - const _epoch = epoch !== undefined ? epoch : await this.stakingContract.currentEpoch.callAsync(); + const _epoch = epoch !== undefined ? epoch : await this.stakingContract.currentEpoch().callAsync(); const events = filterLogsToArguments( await this.stakingContract.getLogsAsync( TestStakingEvents.StakingPoolEarnedRewardsInEpoch, @@ -90,18 +90,16 @@ export class StakingApiWrapper { operatorShare: number, addOperatorAsMaker: boolean, ): Promise => { - const txReceipt = await this.stakingContract.createStakingPool.awaitTransactionSuccessAsync( - operatorShare, - addOperatorAsMaker, - { from: operatorAddress }, - ); + const txReceipt = await this.stakingContract + .createStakingPool(operatorShare, addOperatorAsMaker) + .awaitTransactionSuccessAsync({ from: operatorAddress }); const createStakingPoolLog = txReceipt.logs[0]; const poolId = (createStakingPoolLog as any).args.poolId; return poolId; }, getZrxTokenBalanceOfZrxVaultAsync: async (): Promise => { - return this.zrxTokenContract.balanceOf.callAsync(this.zrxVaultContract.address); + return this.zrxTokenContract.balanceOf(this.zrxVaultContract.address).callAsync(); }, setParamsAsync: async (params: Partial): Promise => { @@ -109,20 +107,22 @@ export class StakingApiWrapper { ...stakingConstants.DEFAULT_PARAMS, ...params, }; - return this.stakingContract.setParams.awaitTransactionSuccessAsync( - new BigNumber(_params.epochDurationInSeconds), - new BigNumber(_params.rewardDelegatedStakeWeight), - new BigNumber(_params.minimumPoolStake), - new BigNumber(_params.cobbDouglasAlphaNumerator), - new BigNumber(_params.cobbDouglasAlphaDenominator), - ); + return this.stakingContract + .setParams( + new BigNumber(_params.epochDurationInSeconds), + new BigNumber(_params.rewardDelegatedStakeWeight), + new BigNumber(_params.minimumPoolStake), + new BigNumber(_params.cobbDouglasAlphaNumerator), + new BigNumber(_params.cobbDouglasAlphaDenominator), + ) + .awaitTransactionSuccessAsync(); }, getAvailableRewardsBalanceAsync: async (): Promise => { const [ethBalance, wethBalance, reservedRewards] = await Promise.all([ this._web3Wrapper.getBalanceInWeiAsync(this.stakingProxyContract.address), - this.wethContract.balanceOf.callAsync(this.stakingProxyContract.address), - this.stakingContract.wethReservedForPoolRewards.callAsync(), + this.wethContract.balanceOf(this.stakingProxyContract.address).callAsync(), + this.stakingContract.wethReservedForPoolRewards().callAsync(), ]); return BigNumber.sum(ethBalance, wethBalance).minus(reservedRewards); }, @@ -138,7 +138,7 @@ export class StakingApiWrapper { 'wethProxyAddress', 'zrxVaultAddress', ], - await this.stakingContract.getParams.callAsync(), + await this.stakingContract.getParams().callAsync(), ) as any) as StakingParams; }, @@ -150,15 +150,17 @@ export class StakingApiWrapper { totalStake: BigNumber, ): Promise => { const { cobbDouglasAlphaNumerator, cobbDouglasAlphaDenominator } = await this.utils.getParamsAsync(); - return this.cobbDouglasContract.cobbDouglas.callAsync( - totalRewards, - ownerFees, - totalFees, - ownerStake, - totalStake, - new BigNumber(cobbDouglasAlphaNumerator), - new BigNumber(cobbDouglasAlphaDenominator), - ); + return this.cobbDouglasContract + .cobbDouglas( + totalRewards, + ownerFees, + totalFees, + ownerStake, + totalStake, + new BigNumber(cobbDouglasAlphaNumerator), + new BigNumber(cobbDouglasAlphaDenominator), + ) + .callAsync(); }, }; @@ -232,7 +234,7 @@ export async function deployAndConfigureContractsAsync( zrxTokenContract.address, ); - await zrxVaultContract.addAuthorizedAddress.awaitTransactionSuccessAsync(ownerAddress); + await zrxVaultContract.addAuthorizedAddress(ownerAddress).awaitTransactionSuccessAsync(); // deploy staking contract const stakingContract = await TestStakingContract.deployFrom0xArtifactAsync( @@ -253,7 +255,7 @@ export async function deployAndConfigureContractsAsync( stakingContract.address, ); - await stakingProxyContract.addAuthorizedAddress.awaitTransactionSuccessAsync(ownerAddress); + await stakingProxyContract.addAuthorizedAddress(ownerAddress).awaitTransactionSuccessAsync(); // deploy cobb douglas contract const cobbDouglasContract = await TestCobbDouglasContract.deployFrom0xArtifactAsync( @@ -264,9 +266,9 @@ export async function deployAndConfigureContractsAsync( ); // configure erc20 proxy to accept calls from zrx vault - await erc20ProxyContract.addAuthorizedAddress.awaitTransactionSuccessAsync(zrxVaultContract.address); + await erc20ProxyContract.addAuthorizedAddress(zrxVaultContract.address).awaitTransactionSuccessAsync(); // set staking proxy contract in zrx vault - await zrxVaultContract.setStakingProxy.awaitTransactionSuccessAsync(stakingProxyContract.address); + await zrxVaultContract.setStakingProxy(stakingProxyContract.address).awaitTransactionSuccessAsync(); return new StakingApiWrapper( env, ownerAddress, diff --git a/contracts/staking/test/utils/cumulative_reward_tracking_simulation.ts b/contracts/staking/test/utils/cumulative_reward_tracking_simulation.ts index e16f12c323..fedba50527 100644 --- a/contracts/staking/test/utils/cumulative_reward_tracking_simulation.ts +++ b/contracts/staking/test/utils/cumulative_reward_tracking_simulation.ts @@ -73,9 +73,9 @@ export class CumulativeRewardTrackingSimulation { public async deployAndConfigureTestContractsAsync(env: BlockchainTestsEnvironment): Promise { // set exchange address - await this._stakingApiWrapper.stakingContract.addExchangeAddress.awaitTransactionSuccessAsync( - this._exchangeAddress, - ); + await this._stakingApiWrapper.stakingContract + .addExchangeAddress(this._exchangeAddress) + .awaitTransactionSuccessAsync(); this._testCumulativeRewardTrackingContract = await TestCumulativeRewardTrackingContract.deployFrom0xArtifactAsync( artifacts.TestCumulativeRewardTracking, env.provider, @@ -99,9 +99,9 @@ export class CumulativeRewardTrackingSimulation { expectedTestLogs: TestLog[], ): Promise { await this._executeActionsAsync(initActions); - await this._stakingApiWrapper.stakingProxyContract.attachStakingContract.awaitTransactionSuccessAsync( - this.getTestCumulativeRewardTrackingContract().address, - ); + await this._stakingApiWrapper.stakingProxyContract + .attachStakingContract(this.getTestCumulativeRewardTrackingContract().address) + .awaitTransactionSuccessAsync(); const testLogs = await this._executeActionsAsync(testActions); CumulativeRewardTrackingSimulation._assertTestLogs(expectedTestLogs, testLogs); } @@ -117,41 +117,38 @@ export class CumulativeRewardTrackingSimulation { break; case TestAction.Delegate: - await this._stakingApiWrapper.stakingContract.stake.sendTransactionAsync(this._amountToStake, { + await this._stakingApiWrapper.stakingContract.stake(this._amountToStake).sendTransactionAsync({ from: this._staker, }); - receipt = await this._stakingApiWrapper.stakingContract.moveStake.awaitTransactionSuccessAsync( - new StakeInfo(StakeStatus.Undelegated), - new StakeInfo(StakeStatus.Delegated, this._poolId), - this._amountToStake, - { from: this._staker }, - ); + receipt = await this._stakingApiWrapper.stakingContract + .moveStake( + new StakeInfo(StakeStatus.Undelegated), + new StakeInfo(StakeStatus.Delegated, this._poolId), + this._amountToStake, + ) + .awaitTransactionSuccessAsync({ from: this._staker }); break; case TestAction.Undelegate: - receipt = await this._stakingApiWrapper.stakingContract.moveStake.awaitTransactionSuccessAsync( - new StakeInfo(StakeStatus.Delegated, this._poolId), - new StakeInfo(StakeStatus.Undelegated), - this._amountToStake, - { from: this._staker }, - ); + receipt = await this._stakingApiWrapper.stakingContract + .moveStake( + new StakeInfo(StakeStatus.Delegated, this._poolId), + new StakeInfo(StakeStatus.Undelegated), + this._amountToStake, + ) + .awaitTransactionSuccessAsync({ from: this._staker }); break; case TestAction.PayProtocolFee: - receipt = await this._stakingApiWrapper.stakingContract.payProtocolFee.awaitTransactionSuccessAsync( - this._poolOperator, - this._takerAddress, - this._protocolFee, - { from: this._exchangeAddress, value: this._protocolFee }, - ); + receipt = await this._stakingApiWrapper.stakingContract + .payProtocolFee(this._poolOperator, this._takerAddress, this._protocolFee) + .awaitTransactionSuccessAsync({ from: this._exchangeAddress, value: this._protocolFee }); break; case TestAction.CreatePool: - receipt = await this._stakingApiWrapper.stakingContract.createStakingPool.awaitTransactionSuccessAsync( - 0, - true, - { from: this._poolOperator }, - ); + receipt = await this._stakingApiWrapper.stakingContract + .createStakingPool(0, true) + .awaitTransactionSuccessAsync({ from: this._poolOperator }); const createStakingPoolLog = receipt.logs[0]; // tslint:disable-next-line no-unnecessary-type-assertion this._poolId = (createStakingPoolLog as DecodedLogEntry).args.poolId; diff --git a/contracts/test-utils/package.json b/contracts/test-utils/package.json index c629416b19..d1410397eb 100644 --- a/contracts/test-utils/package.json +++ b/contracts/test-utils/package.json @@ -40,6 +40,7 @@ "typescript": "3.0.1" }, "dependencies": { + "@0x/base-contract": "^5.5.0-beta.0", "@0x/dev-utils": "^2.4.0-beta.0", "@0x/order-utils": "^8.5.0-beta.0", "@0x/sol-compiler": "^3.2.0-beta.0", diff --git a/contracts/test-utils/src/index.ts b/contracts/test-utils/src/index.ts index 063859363d..ec7c8afc30 100644 --- a/contracts/test-utils/src/index.ts +++ b/contracts/test-utils/src/index.ts @@ -26,7 +26,7 @@ export { randomAddress } from './address_utils'; export { OrderFactory } from './order_factory'; export { bytes32Values, testCombinatoriallyWithReferenceFunc, uint256Values } from './combinatorial_utils'; export { TransactionFactory } from './transaction_factory'; -export { MutatorContractFunction, TransactionHelper } from './transaction_helper'; +export { MutatorContractFunction, transactionHelper } from './transaction_helper'; export { testWithReferenceFuncAsync } from './test_with_reference'; export { hexConcat, diff --git a/contracts/test-utils/src/transaction_helper.ts b/contracts/test-utils/src/transaction_helper.ts index e861e389f7..b76e625588 100644 --- a/contracts/test-utils/src/transaction_helper.ts +++ b/contracts/test-utils/src/transaction_helper.ts @@ -1,56 +1,21 @@ -import { Web3Wrapper } from '@0x/web3-wrapper'; -import { ContractArtifact, TransactionReceipt } from 'ethereum-types'; - -import { LogDecoder } from './log_decoder'; - -type AsyncFunction = (...args: TArgs) => Promise; - -interface ContractArtifacts { - [contractName: string]: ContractArtifact; -} - -export interface MutatorContractFunction< - TCallAsyncArgs extends any[], - TAwaitTransactionSuccessAsyncArgs extends any[], - TCallAsyncResult -> { - callAsync: AsyncFunction; - sendTransactionAsync: AsyncFunction; -} +import { ContractTxFunctionObj } from '@0x/base-contract'; +import { TransactionReceiptWithDecodedLogs } from 'ethereum-types'; +export type MutatorContractFunction = (...args: any[]) => ContractTxFunctionObj; /** * Helper class for performing non-constant contract functions calls. */ -export class TransactionHelper { - public readonly logDecoder: LogDecoder; - - constructor(web3Wrapper: Web3Wrapper, artifacts: ContractArtifacts) { - this.logDecoder = new LogDecoder(web3Wrapper, artifacts); - } - - /** - * Call a non-constant contract function `contractFunction`, passing `args`. - * This will first perform an 'eth_call' (read-only) call in order to - * retrieve the return value, then a 'sendTransaction' to actually modify - * the state. Returns a tuple of the return value amd receipt, with decoded - * logs. - */ - public async getResultAndReceiptAsync< - TCallAsyncArgs extends any[], - TAwaitTransactionSuccessAsyncArgs extends any[], - TCallAsyncResult - >( - contractFunction: MutatorContractFunction, - // tslint:disable-next-line: trailing-comma - ...args: TAwaitTransactionSuccessAsyncArgs - ): Promise<[TCallAsyncResult, TransactionReceipt]> { +export const transactionHelper = { + async getResultAndReceiptAsync( + contractFunction: MutatorContractFunction, + ...args: any[] // tslint:disable-line:trailing-comma + ): Promise<[O, TransactionReceiptWithDecodedLogs]> { // HACK(dorothy-zbornak): We take advantage of the general rule that // the parameters for `callAsync()` are a subset of the // parameters for `sendTransactionAsync()`. - const result = await contractFunction.callAsync(...((args as any) as TCallAsyncArgs)); - const receipt = await this.logDecoder.getTxWithDecodedLogsAsync( - await contractFunction.sendTransactionAsync(...args), - ); + const contractFunctionObj = contractFunction(...args); + const result = await contractFunctionObj.callAsync(); + const receipt = await contractFunctionObj.awaitTransactionSuccessAsync(); return [result, receipt]; - } -} + }, +}; diff --git a/contracts/tests/test/dev-utils/lib_asset_data.ts b/contracts/tests/test/dev-utils/lib_asset_data.ts index 67c1277162..ea54360bc4 100644 --- a/contracts/tests/test/dev-utils/lib_asset_data.ts +++ b/contracts/tests/test/dev-utils/lib_asset_data.ts @@ -135,11 +135,11 @@ describe('LibAssetData', () => { artifacts, ); - await exchange.registerAssetProxy.awaitTransactionSuccessAsync(erc20Proxy.address); - await exchange.registerAssetProxy.awaitTransactionSuccessAsync(erc721Proxy.address); - await exchange.registerAssetProxy.awaitTransactionSuccessAsync(erc1155Proxy.address); - await exchange.registerAssetProxy.awaitTransactionSuccessAsync(multiAssetProxy.address); - await exchange.registerAssetProxy.awaitTransactionSuccessAsync(staticCallProxy.address); + await exchange.registerAssetProxy(erc20Proxy.address).awaitTransactionSuccessAsync(); + await exchange.registerAssetProxy(erc721Proxy.address).awaitTransactionSuccessAsync(); + await exchange.registerAssetProxy(erc1155Proxy.address).awaitTransactionSuccessAsync(); + await exchange.registerAssetProxy(multiAssetProxy.address).awaitTransactionSuccessAsync(); + await exchange.registerAssetProxy(staticCallProxy.address).awaitTransactionSuccessAsync(); libAssetData = await LibAssetDataContract.deployFrom0xArtifactAsync( artifacts.LibAssetData, @@ -181,7 +181,7 @@ describe('LibAssetData', () => { const transactionMinedPromises = []; for (let i = 0; i < numberOfERC721Tokens; i++) { transactionMinedPromises.push( - erc721Token.mint.awaitTransactionSuccessAsync(tokenOwnerAddress, firstERC721TokenId.plus(i - 1)), + erc721Token.mint(tokenOwnerAddress, firstERC721TokenId.plus(i - 1)).awaitTransactionSuccessAsync(), ); } await Promise.all(transactionMinedPromises); @@ -195,16 +195,14 @@ describe('LibAssetData', () => { const logDecoder = new LogDecoder(web3Wrapper, erc1155Artifacts); const transactionReceipt = await logDecoder.getTxWithDecodedLogsAsync( - await erc1155Token.create.sendTransactionAsync('uri:Dummy', /*isNonFungible:*/ false), + await erc1155Token.create('uri:Dummy', /*isNonFungible:*/ false).sendTransactionAsync(), ); // tslint:disable-next-line no-unnecessary-type-assertion erc1155TokenId = (transactionReceipt.logs[0] as LogWithDecodedArgs).args.id; - await erc1155Token.mintFungible.awaitTransactionSuccessAsync( - erc1155TokenId, - [tokenOwnerAddress], - [new BigNumber(1)], - ); + await erc1155Token + .mintFungible(erc1155TokenId, [tokenOwnerAddress], [new BigNumber(1)]) + .awaitTransactionSuccessAsync(); }); after(async () => { @@ -232,17 +230,17 @@ describe('LibAssetData', () => { ]; for (const [assetData, proxyId] of assetDataScenarios) { - expect(await libAssetData.decodeAssetProxyId.callAsync(assetData)).to.equal(proxyId); + expect(await libAssetData.decodeAssetProxyId(assetData).callAsync()).to.equal(proxyId); } }); it('should encode ERC20 asset data', async () => { - expect(await libAssetData.encodeERC20AssetData.callAsync(KNOWN_ERC20_ENCODING.address)).to.equal( + expect(await libAssetData.encodeERC20AssetData(KNOWN_ERC20_ENCODING.address).callAsync()).to.equal( KNOWN_ERC20_ENCODING.assetData, ); }); it('should decode ERC20 asset data', async () => { - expect(await libAssetData.decodeERC20AssetData.callAsync(KNOWN_ERC20_ENCODING.assetData)).to.deep.equal([ + expect(await libAssetData.decodeERC20AssetData(KNOWN_ERC20_ENCODING.assetData).callAsync()).to.deep.equal([ AssetProxyId.ERC20, KNOWN_ERC20_ENCODING.address, ]); @@ -250,56 +248,57 @@ describe('LibAssetData', () => { it('should encode ERC721 asset data', async () => { expect( - await libAssetData.encodeERC721AssetData.callAsync( - KNOWN_ERC721_ENCODING.address, - KNOWN_ERC721_ENCODING.tokenId, - ), + await libAssetData + .encodeERC721AssetData(KNOWN_ERC721_ENCODING.address, KNOWN_ERC721_ENCODING.tokenId) + .callAsync(), ).to.equal(KNOWN_ERC721_ENCODING.assetData); }); it('should decode ERC721 asset data', async () => { - expect(await libAssetData.decodeERC721AssetData.callAsync(KNOWN_ERC721_ENCODING.assetData)).to.deep.equal([ - AssetProxyId.ERC721, - KNOWN_ERC721_ENCODING.address, - KNOWN_ERC721_ENCODING.tokenId, - ]); + expect(await libAssetData.decodeERC721AssetData(KNOWN_ERC721_ENCODING.assetData).callAsync()).to.deep.equal( + [AssetProxyId.ERC721, KNOWN_ERC721_ENCODING.address, KNOWN_ERC721_ENCODING.tokenId], + ); }); it('should encode ERC1155 asset data', async () => { expect( - await libAssetData.encodeERC1155AssetData.callAsync( - KNOWN_ERC1155_ENCODING.tokenAddress, - KNOWN_ERC1155_ENCODING.tokenIds, - KNOWN_ERC1155_ENCODING.tokenValues, - KNOWN_ERC1155_ENCODING.callbackData, - ), + await libAssetData + .encodeERC1155AssetData( + KNOWN_ERC1155_ENCODING.tokenAddress, + KNOWN_ERC1155_ENCODING.tokenIds, + KNOWN_ERC1155_ENCODING.tokenValues, + KNOWN_ERC1155_ENCODING.callbackData, + ) + .callAsync(), ).to.equal(KNOWN_ERC1155_ENCODING.assetData); }); it('should decode ERC1155 asset data', async () => { - expect(await libAssetData.decodeERC1155AssetData.callAsync(KNOWN_ERC1155_ENCODING.assetData)).to.deep.equal( - [ - AssetProxyId.ERC1155, - KNOWN_ERC1155_ENCODING.tokenAddress, - KNOWN_ERC1155_ENCODING.tokenIds, - KNOWN_ERC1155_ENCODING.tokenValues, - KNOWN_ERC1155_ENCODING.callbackData, - ], - ); + expect( + await libAssetData.decodeERC1155AssetData(KNOWN_ERC1155_ENCODING.assetData).callAsync(), + ).to.deep.equal([ + AssetProxyId.ERC1155, + KNOWN_ERC1155_ENCODING.tokenAddress, + KNOWN_ERC1155_ENCODING.tokenIds, + KNOWN_ERC1155_ENCODING.tokenValues, + KNOWN_ERC1155_ENCODING.callbackData, + ]); }); it('should encode multiasset data', async () => { expect( - await libAssetData.encodeMultiAssetData.callAsync( - KNOWN_MULTI_ASSET_ENCODING.amounts, - KNOWN_MULTI_ASSET_ENCODING.nestedAssetData, - ), + await libAssetData + .encodeMultiAssetData( + KNOWN_MULTI_ASSET_ENCODING.amounts, + KNOWN_MULTI_ASSET_ENCODING.nestedAssetData, + ) + .callAsync(), ).to.equal(KNOWN_MULTI_ASSET_ENCODING.assetData); }); it('should decode multiasset data', async () => { expect( - await libAssetData.decodeMultiAssetData.callAsync(KNOWN_MULTI_ASSET_ENCODING.assetData), + await libAssetData.decodeMultiAssetData(KNOWN_MULTI_ASSET_ENCODING.assetData).callAsync(), ).to.deep.equal([ AssetProxyId.MultiAsset, KNOWN_MULTI_ASSET_ENCODING.amounts, @@ -309,17 +308,19 @@ describe('LibAssetData', () => { it('should encode StaticCall data', async () => { expect( - await libAssetData.encodeStaticCallAssetData.callAsync( - KNOWN_STATIC_CALL_ENCODING.staticCallTargetAddress, - KNOWN_STATIC_CALL_ENCODING.staticCallData, - KNOWN_STATIC_CALL_ENCODING.expectedReturnDataHash, - ), + await libAssetData + .encodeStaticCallAssetData( + KNOWN_STATIC_CALL_ENCODING.staticCallTargetAddress, + KNOWN_STATIC_CALL_ENCODING.staticCallData, + KNOWN_STATIC_CALL_ENCODING.expectedReturnDataHash, + ) + .callAsync(), ).to.equal(KNOWN_STATIC_CALL_ENCODING.assetData); }); it('should decode StaticCall data', async () => { expect( - await libAssetData.decodeStaticCallAssetData.callAsync(KNOWN_STATIC_CALL_ENCODING.assetData), + await libAssetData.decodeStaticCallAssetData(KNOWN_STATIC_CALL_ENCODING.assetData).callAsync(), ).to.deep.equal([ AssetProxyId.StaticCall, KNOWN_STATIC_CALL_ENCODING.staticCallTargetAddress, @@ -339,14 +340,14 @@ describe('LibAssetData', () => { ]; for (const data of assetData) { - await libAssetData.revertIfInvalidAssetData.callAsync(data); + await libAssetData.revertIfInvalidAssetData(data).callAsync(); } return; }); it('should revert for invalid assetProxyId', async () => { const badAssetData = '0x' + crypto.randomBytes(4).toString('hex') + constants.NULL_ADDRESS; - await expect(libAssetData.revertIfInvalidAssetData.callAsync(badAssetData)).to.eventually.be.rejectedWith( + await expect(libAssetData.revertIfInvalidAssetData(badAssetData).callAsync()).to.eventually.be.rejectedWith( StringRevertError, ); }); @@ -357,7 +358,7 @@ describe('LibAssetData', () => { for (const data of assetData) { const badData = data.substring(0, data.length - 2); // drop one byte but retain assetProxyId - await expect(libAssetData.revertIfInvalidAssetData.callAsync(badData)).to.eventually.be.rejectedWith( + await expect(libAssetData.revertIfInvalidAssetData(badData).callAsync()).to.eventually.be.rejectedWith( InvalidByteOperationError, ); } @@ -366,98 +367,98 @@ describe('LibAssetData', () => { describe('getBalance', () => { it('should query ERC20 balance by asset data', async () => { - const assetData = await libAssetData.encodeERC20AssetData.callAsync(erc20Token.address); - expect(await libAssetData.getBalance.callAsync(tokenOwnerAddress, assetData)).to.bignumber.equal( + const assetData = await libAssetData.encodeERC20AssetData(erc20Token.address).callAsync(); + expect(await libAssetData.getBalance(tokenOwnerAddress, assetData).callAsync()).to.bignumber.equal( erc20TokenTotalSupply, ); }); it('should return 0 if ERC20 token does not exist', async () => { - const assetData = await libAssetData.encodeERC20AssetData.callAsync(constants.NULL_ADDRESS); - const balance = await libAssetData.getBalance.callAsync(tokenOwnerAddress, assetData); + const assetData = await libAssetData.encodeERC20AssetData(constants.NULL_ADDRESS).callAsync(); + const balance = await libAssetData.getBalance(tokenOwnerAddress, assetData).callAsync(); expect(balance).to.bignumber.equal(constants.ZERO_AMOUNT); }); it('should query ERC721 balance by asset data', async () => { - const assetData = await libAssetData.encodeERC721AssetData.callAsync( - erc721Token.address, - firstERC721TokenId, - ); - expect(await libAssetData.getBalance.callAsync(tokenOwnerAddress, assetData)).to.bignumber.equal(1); + const assetData = await libAssetData + .encodeERC721AssetData(erc721Token.address, firstERC721TokenId) + .callAsync(); + expect(await libAssetData.getBalance(tokenOwnerAddress, assetData).callAsync()).to.bignumber.equal(1); }); it('should return 0 if ERC721 token does not exist', async () => { - const assetData = await libAssetData.encodeERC721AssetData.callAsync( - constants.NULL_ADDRESS, - firstERC721TokenId, - ); - const balance = await libAssetData.getBalance.callAsync(tokenOwnerAddress, assetData); + const assetData = await libAssetData + .encodeERC721AssetData(constants.NULL_ADDRESS, firstERC721TokenId) + .callAsync(); + const balance = await libAssetData.getBalance(tokenOwnerAddress, assetData).callAsync(); expect(balance).to.bignumber.equal(constants.ZERO_AMOUNT); }); it('should query ERC1155 balances by asset data', async () => { - const assetData = await libAssetData.encodeERC1155AssetData.callAsync( - erc1155Token.address, - [erc1155TokenId], - [new BigNumber(1)], - constants.NULL_BYTES, - ); - expect(await libAssetData.getBalance.callAsync(tokenOwnerAddress, assetData)).to.bignumber.equal(1); + const assetData = await libAssetData + .encodeERC1155AssetData( + erc1155Token.address, + [erc1155TokenId], + [new BigNumber(1)], + constants.NULL_BYTES, + ) + .callAsync(); + expect(await libAssetData.getBalance(tokenOwnerAddress, assetData).callAsync()).to.bignumber.equal(1); }); it('should return 0 if ERC1155 token does not exist', async () => { - const assetData = await libAssetData.encodeERC1155AssetData.callAsync( - constants.NULL_ADDRESS, - [erc1155TokenId], - [new BigNumber(1)], - constants.NULL_BYTES, - ); - const balance = await libAssetData.getBalance.callAsync(tokenOwnerAddress, assetData); + const assetData = await libAssetData + .encodeERC1155AssetData( + constants.NULL_ADDRESS, + [erc1155TokenId], + [new BigNumber(1)], + constants.NULL_BYTES, + ) + .callAsync(); + const balance = await libAssetData.getBalance(tokenOwnerAddress, assetData).callAsync(); expect(balance).to.bignumber.equal(constants.ZERO_AMOUNT); }); it('should query multi-asset batch balance by asset data', async () => { - const assetData = await libAssetData.encodeMultiAssetData.callAsync( - [new BigNumber(1), new BigNumber(1)], - [ - await libAssetData.encodeERC20AssetData.callAsync(erc20Token.address), - await libAssetData.encodeERC721AssetData.callAsync(erc721Token.address, firstERC721TokenId), - ], - ); - expect(await libAssetData.getBalance.callAsync(tokenOwnerAddress, assetData)).to.bignumber.equal( + const assetData = await libAssetData + .encodeMultiAssetData( + [new BigNumber(1), new BigNumber(1)], + [ + await libAssetData.encodeERC20AssetData(erc20Token.address).callAsync(), + await libAssetData.encodeERC721AssetData(erc721Token.address, firstERC721TokenId).callAsync(), + ], + ) + .callAsync(); + expect(await libAssetData.getBalance(tokenOwnerAddress, assetData).callAsync()).to.bignumber.equal( Math.min(erc20TokenTotalSupply.toNumber(), numberOfERC721Tokens), ); }); it('should return a balance of 0 if the assetData does not correspond to an AssetProxy contract', async () => { const fakeAssetData = '0x01020304'; - const balance = await libAssetData.getBalance.callAsync(tokenOwnerAddress, fakeAssetData); + const balance = await libAssetData.getBalance(tokenOwnerAddress, fakeAssetData).callAsync(); expect(balance).to.bignumber.equal(constants.ZERO_AMOUNT); }); it('should return a balance of MAX_UINT256 if the the StaticCallProxy assetData contains data for a successful staticcall', async () => { - const staticCallData = staticCallTarget.isOddNumber.getABIEncodedTransactionData(new BigNumber(1)); + const staticCallData = staticCallTarget.isOddNumber(new BigNumber(1)).getABIEncodedTransactionData(); const trueAsBuffer = ethUtil.toBuffer('0x0000000000000000000000000000000000000000000000000000000000000001'); const expectedResultHash = ethUtil.bufferToHex(ethUtil.sha3(trueAsBuffer)); - const assetData = await libAssetData.encodeStaticCallAssetData.callAsync( - staticCallTarget.address, - staticCallData, - expectedResultHash, - ); - const balance = await libAssetData.getBalance.callAsync(tokenOwnerAddress, assetData); + const assetData = await libAssetData + .encodeStaticCallAssetData(staticCallTarget.address, staticCallData, expectedResultHash) + .callAsync(); + const balance = await libAssetData.getBalance(tokenOwnerAddress, assetData).callAsync(); expect(balance).to.bignumber.equal(constants.UNLIMITED_ALLOWANCE_IN_BASE_UNITS); }); it('should return a balance of 0 if the the StaticCallProxy assetData contains data for an unsuccessful staticcall', async () => { - const staticCallData = staticCallTarget.isOddNumber.getABIEncodedTransactionData(new BigNumber(0)); + const staticCallData = staticCallTarget.isOddNumber(new BigNumber(0)).getABIEncodedTransactionData(); const trueAsBuffer = ethUtil.toBuffer('0x0000000000000000000000000000000000000000000000000000000000000001'); const expectedResultHash = ethUtil.bufferToHex(ethUtil.sha3(trueAsBuffer)); - const assetData = await libAssetData.encodeStaticCallAssetData.callAsync( - staticCallTarget.address, - staticCallData, - expectedResultHash, - ); - const balance = await libAssetData.getBalance.callAsync(tokenOwnerAddress, assetData); + const assetData = await libAssetData + .encodeStaticCallAssetData(staticCallTarget.address, staticCallData, expectedResultHash) + .callAsync(); + const balance = await libAssetData.getBalance(tokenOwnerAddress, assetData).callAsync(); expect(balance).to.bignumber.equal(constants.ZERO_AMOUNT); }); }); @@ -465,104 +466,103 @@ describe('LibAssetData', () => { describe('getAssetProxyAllowance', () => { it('should query ERC20 allowances by asset data', async () => { const allowance = new BigNumber(1); - await erc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, allowance, { + await erc20Token.approve(erc20Proxy.address, allowance).awaitTransactionSuccessAsync({ from: tokenOwnerAddress, }); - const assetData = await libAssetData.encodeERC20AssetData.callAsync(erc20Token.address); + const assetData = await libAssetData.encodeERC20AssetData(erc20Token.address).callAsync(); expect( - await libAssetData.getAssetProxyAllowance.callAsync(tokenOwnerAddress, assetData), + await libAssetData.getAssetProxyAllowance(tokenOwnerAddress, assetData).callAsync(), ).to.bignumber.equal(allowance); }); it('should query ERC721 approval by asset data', async () => { - await erc721Token.approve.awaitTransactionSuccessAsync(erc721Proxy.address, firstERC721TokenId, { + await erc721Token.approve(erc721Proxy.address, firstERC721TokenId).awaitTransactionSuccessAsync({ from: tokenOwnerAddress, }); - const assetData = await libAssetData.encodeERC721AssetData.callAsync( - erc721Token.address, - firstERC721TokenId, - ); + const assetData = await libAssetData + .encodeERC721AssetData(erc721Token.address, firstERC721TokenId) + .callAsync(); expect( - await libAssetData.getAssetProxyAllowance.callAsync(tokenOwnerAddress, assetData), + await libAssetData.getAssetProxyAllowance(tokenOwnerAddress, assetData).callAsync(), ).to.bignumber.equal(1); }); it('should query ERC721 approvalForAll by assetData', async () => { - await erc721Token.setApprovalForAll.awaitTransactionSuccessAsync(erc721Proxy.address, true, { + await erc721Token.setApprovalForAll(erc721Proxy.address, true).awaitTransactionSuccessAsync({ from: tokenOwnerAddress, }); - const assetData = await libAssetData.encodeERC721AssetData.callAsync( - erc721Token.address, - firstERC721TokenId, - ); + const assetData = await libAssetData + .encodeERC721AssetData(erc721Token.address, firstERC721TokenId) + .callAsync(); expect( - await libAssetData.getAssetProxyAllowance.callAsync(tokenOwnerAddress, assetData), + await libAssetData.getAssetProxyAllowance(tokenOwnerAddress, assetData).callAsync(), ).to.bignumber.equal(constants.UNLIMITED_ALLOWANCE_IN_BASE_UNITS); }); it('should query ERC1155 allowances by asset data', async () => { - await erc1155Token.setApprovalForAll.awaitTransactionSuccessAsync(erc1155Proxy.address, true, { + await erc1155Token.setApprovalForAll(erc1155Proxy.address, true).awaitTransactionSuccessAsync({ from: tokenOwnerAddress, }); - const assetData = await libAssetData.encodeERC1155AssetData.callAsync( - erc1155Token.address, - [erc1155TokenId], - [new BigNumber(1)], - constants.NULL_BYTES, - ); + const assetData = await libAssetData + .encodeERC1155AssetData( + erc1155Token.address, + [erc1155TokenId], + [new BigNumber(1)], + constants.NULL_BYTES, + ) + .callAsync(); expect( - await libAssetData.getAssetProxyAllowance.callAsync(tokenOwnerAddress, assetData), + await libAssetData.getAssetProxyAllowance(tokenOwnerAddress, assetData).callAsync(), ).to.bignumber.equal(constants.UNLIMITED_ALLOWANCE_IN_BASE_UNITS); }); it('should query multi-asset allowances by asset data', async () => { const allowance = new BigNumber(1); - await erc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, allowance, { + await erc20Token.approve(erc20Proxy.address, allowance).awaitTransactionSuccessAsync({ from: tokenOwnerAddress, }); - await erc721Token.approve.awaitTransactionSuccessAsync(erc721Proxy.address, firstERC721TokenId, { + await erc721Token.approve(erc721Proxy.address, firstERC721TokenId).awaitTransactionSuccessAsync({ from: tokenOwnerAddress, }); - const assetData = await libAssetData.encodeMultiAssetData.callAsync( - [new BigNumber(1), new BigNumber(1)], - [ - await libAssetData.encodeERC20AssetData.callAsync(erc20Token.address), - await libAssetData.encodeERC721AssetData.callAsync(erc721Token.address, firstERC721TokenId), - ], - ); + const assetData = await libAssetData + .encodeMultiAssetData( + [new BigNumber(1), new BigNumber(1)], + [ + await libAssetData.encodeERC20AssetData(erc20Token.address).callAsync(), + await libAssetData.encodeERC721AssetData(erc721Token.address, firstERC721TokenId).callAsync(), + ], + ) + .callAsync(); expect( - await libAssetData.getAssetProxyAllowance.callAsync(tokenOwnerAddress, assetData), + await libAssetData.getAssetProxyAllowance(tokenOwnerAddress, assetData).callAsync(), ).to.bignumber.equal(1); return; }); it('should return an allowance of 0 if the assetData does not correspond to an AssetProxy contract', async () => { const fakeAssetData = '0x01020304'; - const allowance = await libAssetData.getAssetProxyAllowance.callAsync(tokenOwnerAddress, fakeAssetData); + const allowance = await libAssetData.getAssetProxyAllowance(tokenOwnerAddress, fakeAssetData).callAsync(); expect(allowance).to.bignumber.equal(constants.ZERO_AMOUNT); }); it('should return an allowance of MAX_UINT256 for any staticCallAssetData', async () => { const staticCallData = AssetProxyId.StaticCall; - const assetData = await libAssetData.encodeStaticCallAssetData.callAsync( - staticCallTarget.address, - staticCallData, - constants.KECCAK256_NULL, - ); - const allowance = await libAssetData.getAssetProxyAllowance.callAsync(tokenOwnerAddress, assetData); + const assetData = await libAssetData + .encodeStaticCallAssetData(staticCallTarget.address, staticCallData, constants.KECCAK256_NULL) + .callAsync(); + const allowance = await libAssetData.getAssetProxyAllowance(tokenOwnerAddress, assetData).callAsync(); expect(allowance).to.bignumber.equal(constants.UNLIMITED_ALLOWANCE_IN_BASE_UNITS); }); }); describe('getBatchBalances', () => { it('should query balances for a batch of asset data strings', async () => { - const erc20AssetData = await libAssetData.encodeERC20AssetData.callAsync(erc20Token.address); - const erc721AssetData = await libAssetData.encodeERC721AssetData.callAsync( - erc721Token.address, - firstERC721TokenId, - ); + const erc20AssetData = await libAssetData.encodeERC20AssetData(erc20Token.address).callAsync(); + const erc721AssetData = await libAssetData + .encodeERC721AssetData(erc721Token.address, firstERC721TokenId) + .callAsync(); expect( - await libAssetData.getBatchBalances.callAsync(tokenOwnerAddress, [erc20AssetData, erc721AssetData]), + await libAssetData.getBatchBalances(tokenOwnerAddress, [erc20AssetData, erc721AssetData]).callAsync(), ).to.deep.equal([new BigNumber(erc20TokenTotalSupply), new BigNumber(1)]); }); }); @@ -570,24 +570,24 @@ describe('LibAssetData', () => { describe('getBalanceAndAllowance', () => { it('should query balance and allowance together, from asset data', async () => { const allowance = new BigNumber(1); - await erc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, allowance, { + await erc20Token.approve(erc20Proxy.address, allowance).awaitTransactionSuccessAsync({ from: tokenOwnerAddress, }); - const assetData = await libAssetData.encodeERC20AssetData.callAsync(erc20Token.address); + const assetData = await libAssetData.encodeERC20AssetData(erc20Token.address).callAsync(); expect( - await libAssetData.getBalanceAndAssetProxyAllowance.callAsync(tokenOwnerAddress, assetData), + await libAssetData.getBalanceAndAssetProxyAllowance(tokenOwnerAddress, assetData).callAsync(), ).to.deep.equal([new BigNumber(erc20TokenTotalSupply), allowance]); }); }); describe('getBatchBalancesAndAllowances', () => { it('should query balances and allowances together, from an asset data array', async () => { const allowance = new BigNumber(1); - await erc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, allowance, { + await erc20Token.approve(erc20Proxy.address, allowance).awaitTransactionSuccessAsync({ from: tokenOwnerAddress, }); - const assetData = await libAssetData.encodeERC20AssetData.callAsync(erc20Token.address); + const assetData = await libAssetData.encodeERC20AssetData(erc20Token.address).callAsync(); expect( - await libAssetData.getBatchBalancesAndAssetProxyAllowances.callAsync(tokenOwnerAddress, [assetData]), + await libAssetData.getBatchBalancesAndAssetProxyAllowances(tokenOwnerAddress, [assetData]).callAsync(), ).to.deep.equal([[new BigNumber(erc20TokenTotalSupply)], [allowance]]); }); }); @@ -595,22 +595,20 @@ describe('LibAssetData', () => { describe('getBatchAssetProxyAllowances', () => { it('should query allowances for a batch of asset data strings', async () => { const allowance = new BigNumber(1); - await erc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, allowance, { + await erc20Token.approve(erc20Proxy.address, allowance).awaitTransactionSuccessAsync({ from: tokenOwnerAddress, }); - await erc721Token.approve.awaitTransactionSuccessAsync(erc721Proxy.address, firstERC721TokenId, { + await erc721Token.approve(erc721Proxy.address, firstERC721TokenId).awaitTransactionSuccessAsync({ from: tokenOwnerAddress, }); - const erc20AssetData = await libAssetData.encodeERC20AssetData.callAsync(erc20Token.address); - const erc721AssetData = await libAssetData.encodeERC721AssetData.callAsync( - erc721Token.address, - firstERC721TokenId, - ); + const erc20AssetData = await libAssetData.encodeERC20AssetData(erc20Token.address).callAsync(); + const erc721AssetData = await libAssetData + .encodeERC721AssetData(erc721Token.address, firstERC721TokenId) + .callAsync(); expect( - await libAssetData.getBatchAssetProxyAllowances.callAsync(tokenOwnerAddress, [ - erc20AssetData, - erc721AssetData, - ]), + await libAssetData + .getBatchAssetProxyAllowances(tokenOwnerAddress, [erc20AssetData, erc721AssetData]) + .callAsync(), ).to.deep.equal([new BigNumber(1), new BigNumber(1)]); }); }); diff --git a/contracts/tests/test/dev-utils/lib_transaction_decoder.ts b/contracts/tests/test/dev-utils/lib_transaction_decoder.ts index 9fe5ee13d6..f0cbeb08fb 100644 --- a/contracts/tests/test/dev-utils/lib_transaction_decoder.ts +++ b/contracts/tests/test/dev-utils/lib_transaction_decoder.ts @@ -47,8 +47,8 @@ describe('LibTransactionDecoder', () => { }); it('should decode an Exchange.batchCancelOrders() transaction', async () => { - const input = exchangeInterface.batchCancelOrders.getABIEncodedTransactionData([order, order]); - expect(await libTxDecoder.decodeZeroExTransactionData.callAsync(input)).to.deep.equal([ + const input = exchangeInterface.batchCancelOrders([order, order]).getABIEncodedTransactionData(); + expect(await libTxDecoder.decodeZeroExTransactionData(input).callAsync()).to.deep.equal([ 'batchCancelOrders', [order, order], [], @@ -57,13 +57,11 @@ describe('LibTransactionDecoder', () => { }); for (const func of ['batchFillOrders', 'batchFillOrdersNoThrow', 'batchFillOrKillOrders']) { - const input = (exchangeInterface as any)[func].getABIEncodedTransactionData( - [order, order], - [takerAssetFillAmount, takerAssetFillAmount], - [signature, signature], - ); + const input = (exchangeInterface as any) + [func]([order, order], [takerAssetFillAmount, takerAssetFillAmount], [signature, signature]) + .getABIEncodedTransactionData(); it(`should decode an Exchange.${func}() transaction`, async () => { - expect(await libTxDecoder.decodeZeroExTransactionData.callAsync(input)).to.deep.equal([ + expect(await libTxDecoder.decodeZeroExTransactionData(input).callAsync()).to.deep.equal([ func, [order, order], [takerAssetFillAmount, takerAssetFillAmount], @@ -73,8 +71,8 @@ describe('LibTransactionDecoder', () => { } it('should decode an Exchange.cancelOrder() transaction', async () => { - const input = exchangeInterface.cancelOrder.getABIEncodedTransactionData(order); - expect(await libTxDecoder.decodeZeroExTransactionData.callAsync(input)).to.deep.equal([ + const input = exchangeInterface.cancelOrder(order).getABIEncodedTransactionData(); + expect(await libTxDecoder.decodeZeroExTransactionData(input).callAsync()).to.deep.equal([ 'cancelOrder', [order], [], @@ -83,13 +81,11 @@ describe('LibTransactionDecoder', () => { }); for (const func of ['fillOrder', 'fillOrKillOrder']) { - const input = (exchangeInterface as any)[func].getABIEncodedTransactionData( - order, - takerAssetFillAmount, - signature, - ); + const input = (exchangeInterface as any) + [func](order, takerAssetFillAmount, signature) + .getABIEncodedTransactionData(); it(`should decode an Exchange.${func}() transaction`, async () => { - expect(await libTxDecoder.decodeZeroExTransactionData.callAsync(input)).to.deep.equal([ + expect(await libTxDecoder.decodeZeroExTransactionData(input).callAsync()).to.deep.equal([ func, [order], [takerAssetFillAmount], @@ -104,13 +100,11 @@ describe('LibTransactionDecoder', () => { 'marketBuyOrdersFillOrKill', 'marketSellOrdersFillOrKill', ]) { - const input = (exchangeInterface as any)[func].getABIEncodedTransactionData( - [order, order], - takerAssetFillAmount, - [signature, signature], - ); + const input = (exchangeInterface as any) + [func]([order, order], takerAssetFillAmount, [signature, signature]) + .getABIEncodedTransactionData(); it(`should decode an Exchange.${func}() transaction`, async () => { - expect(await libTxDecoder.decodeZeroExTransactionData.callAsync(input)).to.deep.equal([ + expect(await libTxDecoder.decodeZeroExTransactionData(input).callAsync()).to.deep.equal([ func, [order, order], [takerAssetFillAmount], @@ -133,13 +127,10 @@ describe('LibTransactionDecoder', () => { makerFeeAssetData: order.takerFeeAssetData, takerFeeAssetData: order.makerFeeAssetData, }; - const input = exchangeInterface.matchOrders.getABIEncodedTransactionData( - order, - complementaryOrder, - signature, - signature, - ); - expect(await libTxDecoder.decodeZeroExTransactionData.callAsync(input)).to.deep.equal([ + const input = exchangeInterface + .matchOrders(order, complementaryOrder, signature, signature) + .getABIEncodedTransactionData(); + expect(await libTxDecoder.decodeZeroExTransactionData(input).callAsync()).to.deep.equal([ 'matchOrders', [order, complementaryOrder], [order.takerAssetAmount, complementaryOrder.takerAssetAmount], diff --git a/contracts/tests/test/dev-utils/order_validation_utils.ts b/contracts/tests/test/dev-utils/order_validation_utils.ts index 05f5ea8da5..aca3010448 100644 --- a/contracts/tests/test/dev-utils/order_validation_utils.ts +++ b/contracts/tests/test/dev-utils/order_validation_utils.ts @@ -97,8 +97,8 @@ describe('OrderValidationUtils/OrderTransferSimulatorUtils', () => { await exchangeWrapper.registerAssetProxyAsync(erc20Proxy.address, owner); await exchangeWrapper.registerAssetProxyAsync(erc721Proxy.address, owner); await exchangeWrapper.registerAssetProxyAsync(multiAssetProxy.address, owner); - await erc20Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(exchange.address, { from: owner }); - await erc721Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(exchange.address, { from: owner }); + await erc20Proxy.addAuthorizedAddress(exchange.address).awaitTransactionSuccessAsync({ from: owner }); + await erc721Proxy.addAuthorizedAddress(exchange.address).awaitTransactionSuccessAsync({ from: owner }); devUtils = await DevUtilsContract.deployFrom0xArtifactAsync( artifacts.DevUtils, @@ -108,10 +108,10 @@ describe('OrderValidationUtils/OrderTransferSimulatorUtils', () => { exchange.address, ); - feeAssetData = await devUtils.encodeERC20AssetData.callAsync(feeErc20Token.address); - erc20AssetData = await devUtils.encodeERC20AssetData.callAsync(erc20Token.address); - erc20AssetData2 = await devUtils.encodeERC20AssetData.callAsync(erc20Token2.address); - erc721AssetData = await devUtils.encodeERC721AssetData.callAsync(erc721Token.address, tokenId); + feeAssetData = await devUtils.encodeERC20AssetData(feeErc20Token.address).callAsync(); + erc20AssetData = await devUtils.encodeERC20AssetData(erc20Token.address).callAsync(); + erc20AssetData2 = await devUtils.encodeERC20AssetData(erc20Token2.address).callAsync(); + erc721AssetData = await devUtils.encodeERC721AssetData(erc721Token.address, tokenId).callAsync(); const defaultOrderParams = { ...constants.STATIC_ORDER_PARAMS, makerAddress, @@ -138,48 +138,44 @@ describe('OrderValidationUtils/OrderTransferSimulatorUtils', () => { it('should return the balance when balance < allowance', async () => { const balance = new BigNumber(123); const allowance = new BigNumber(456); - await erc20Token.setBalance.awaitTransactionSuccessAsync(makerAddress, balance); - await erc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, allowance, { + await erc20Token.setBalance(makerAddress, balance).awaitTransactionSuccessAsync(); + await erc20Token.approve(erc20Proxy.address, allowance).awaitTransactionSuccessAsync({ from: makerAddress, }); - const transferableAmount = await devUtils.getTransferableAssetAmount.callAsync( - makerAddress, - erc20AssetData, - ); + const transferableAmount = await devUtils + .getTransferableAssetAmount(makerAddress, erc20AssetData) + .callAsync(); expect(transferableAmount).to.bignumber.equal(balance); }); it('should return the allowance when allowance < balance', async () => { const balance = new BigNumber(456); const allowance = new BigNumber(123); - await erc20Token.setBalance.awaitTransactionSuccessAsync(makerAddress, balance); - await erc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, allowance, { + await erc20Token.setBalance(makerAddress, balance).awaitTransactionSuccessAsync(); + await erc20Token.approve(erc20Proxy.address, allowance).awaitTransactionSuccessAsync({ from: makerAddress, }); - const transferableAmount = await devUtils.getTransferableAssetAmount.callAsync( - makerAddress, - erc20AssetData, - ); + const transferableAmount = await devUtils + .getTransferableAssetAmount(makerAddress, erc20AssetData) + .callAsync(); expect(transferableAmount).to.bignumber.equal(allowance); }); it('should return the correct transferable amount for multiAssetData', async () => { - const multiAssetData = await devUtils.encodeMultiAssetData.callAsync( - [new BigNumber(1), new BigNumber(1)], - [erc20AssetData, erc20AssetData2], - ); + const multiAssetData = await devUtils + .encodeMultiAssetData([new BigNumber(1), new BigNumber(1)], [erc20AssetData, erc20AssetData2]) + .callAsync(); const transferableAmount1 = new BigNumber(10); const transferableAmount2 = new BigNumber(5); - await erc20Token.setBalance.awaitTransactionSuccessAsync(makerAddress, transferableAmount1); - await erc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, transferableAmount1, { + await erc20Token.setBalance(makerAddress, transferableAmount1).awaitTransactionSuccessAsync(); + await erc20Token.approve(erc20Proxy.address, transferableAmount1).awaitTransactionSuccessAsync({ from: makerAddress, }); - await erc20Token2.setBalance.awaitTransactionSuccessAsync(makerAddress, transferableAmount2); - await erc20Token2.approve.awaitTransactionSuccessAsync(erc20Proxy.address, transferableAmount2, { + await erc20Token2.setBalance(makerAddress, transferableAmount2).awaitTransactionSuccessAsync(); + await erc20Token2.approve(erc20Proxy.address, transferableAmount2).awaitTransactionSuccessAsync({ from: makerAddress, }); - const transferableAmount = await devUtils.getTransferableAssetAmount.callAsync( - makerAddress, - multiAssetData, - ); + const transferableAmount = await devUtils + .getTransferableAssetAmount(makerAddress, multiAssetData) + .callAsync(); expect(transferableAmount).to.bignumber.equal(transferableAmount2); }); }); @@ -188,160 +184,143 @@ describe('OrderValidationUtils/OrderTransferSimulatorUtils', () => { signedOrder = await orderFactory.newSignedOrderAsync(); }); it('should return the correct orderInfo when the order is valid', async () => { - const [orderInfo] = await devUtils.getOrderRelevantState.callAsync(signedOrder, signedOrder.signature); + const [orderInfo] = await devUtils.getOrderRelevantState(signedOrder, signedOrder.signature).callAsync(); expect(orderInfo.orderHash).to.equal(orderHashUtils.getOrderHashHex(signedOrder)); expect(orderInfo.orderStatus).to.equal(OrderStatus.Fillable); expect(orderInfo.orderTakerAssetFilledAmount).to.bignumber.equal(constants.ZERO_AMOUNT); }); it('should return isValidSignature=true when the signature is valid', async () => { - const [, , isValidSignature] = await devUtils.getOrderRelevantState.callAsync( - signedOrder, - signedOrder.signature, - ); + const [, , isValidSignature] = await devUtils + .getOrderRelevantState(signedOrder, signedOrder.signature) + .callAsync(); expect(isValidSignature).to.equal(true); }); it('should return isValidSignature=false when the signature is invalid', async () => { const invalidSignature = '0x01'; - const [, , isValidSignature] = await devUtils.getOrderRelevantState.callAsync( - signedOrder, - invalidSignature, - ); + const [, , isValidSignature] = await devUtils + .getOrderRelevantState(signedOrder, invalidSignature) + .callAsync(); expect(isValidSignature).to.equal(false); }); it('should return a fillableTakerAssetAmount of 0 when balances or allowances are insufficient', async () => { - const [, fillableTakerAssetAmount] = await devUtils.getOrderRelevantState.callAsync( - signedOrder, - signedOrder.signature, - ); + const [, fillableTakerAssetAmount] = await devUtils + .getOrderRelevantState(signedOrder, signedOrder.signature) + .callAsync(); expect(fillableTakerAssetAmount).to.bignumber.equal(constants.ZERO_AMOUNT); }); it('should return a fillableTakerAssetAmount of 0 when fee balances/allowances are insufficient', async () => { - await erc20Token.setBalance.awaitTransactionSuccessAsync(makerAddress, signedOrder.makerAssetAmount); - await erc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.makerAssetAmount, { + await erc20Token.setBalance(makerAddress, signedOrder.makerAssetAmount).awaitTransactionSuccessAsync(); + await erc20Token.approve(erc20Proxy.address, signedOrder.makerAssetAmount).awaitTransactionSuccessAsync({ from: makerAddress, }); - const [, fillableTakerAssetAmount] = await devUtils.getOrderRelevantState.callAsync( - signedOrder, - signedOrder.signature, - ); + const [, fillableTakerAssetAmount] = await devUtils + .getOrderRelevantState(signedOrder, signedOrder.signature) + .callAsync(); expect(fillableTakerAssetAmount).to.bignumber.equal(constants.ZERO_AMOUNT); }); it('should return a fillableTakerAssetAmount of 0 when balances/allowances of one asset within a multiAssetData are insufficient', async () => { - const multiAssetData = await devUtils.encodeMultiAssetData.callAsync( - [new BigNumber(1), new BigNumber(1)], - [erc20AssetData, erc20AssetData2], - ); + const multiAssetData = await devUtils + .encodeMultiAssetData([new BigNumber(1), new BigNumber(1)], [erc20AssetData, erc20AssetData2]) + .callAsync(); signedOrder = await orderFactory.newSignedOrderAsync({ makerAssetData: multiAssetData }); - await erc20Token.setBalance.awaitTransactionSuccessAsync(makerAddress, signedOrder.makerAssetAmount); - await erc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.makerAssetAmount, { + await erc20Token.setBalance(makerAddress, signedOrder.makerAssetAmount).awaitTransactionSuccessAsync(); + await erc20Token.approve(erc20Proxy.address, signedOrder.makerAssetAmount).awaitTransactionSuccessAsync({ from: makerAddress, }); - const [, fillableTakerAssetAmount] = await devUtils.getOrderRelevantState.callAsync( - signedOrder, - signedOrder.signature, - ); + const [, fillableTakerAssetAmount] = await devUtils + .getOrderRelevantState(signedOrder, signedOrder.signature) + .callAsync(); expect(fillableTakerAssetAmount).to.bignumber.equal(constants.ZERO_AMOUNT); }); it('should return the correct fillableTakerAssetAmount when fee balances/allowances are partially sufficient', async () => { - await erc20Token.setBalance.awaitTransactionSuccessAsync(makerAddress, signedOrder.makerAssetAmount); - await erc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.makerAssetAmount, { + await erc20Token.setBalance(makerAddress, signedOrder.makerAssetAmount).awaitTransactionSuccessAsync(); + await erc20Token.approve(erc20Proxy.address, signedOrder.makerAssetAmount).awaitTransactionSuccessAsync({ from: makerAddress, }); const divisor = 4; - await feeErc20Token.setBalance.awaitTransactionSuccessAsync( - makerAddress, - signedOrder.makerFee.dividedToIntegerBy(divisor), - ); - await feeErc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.makerFee, { + await feeErc20Token + .setBalance(makerAddress, signedOrder.makerFee.dividedToIntegerBy(divisor)) + .awaitTransactionSuccessAsync(); + await feeErc20Token.approve(erc20Proxy.address, signedOrder.makerFee).awaitTransactionSuccessAsync({ from: makerAddress, }); - const [, fillableTakerAssetAmount] = await devUtils.getOrderRelevantState.callAsync( - signedOrder, - signedOrder.signature, - ); + const [, fillableTakerAssetAmount] = await devUtils + .getOrderRelevantState(signedOrder, signedOrder.signature) + .callAsync(); expect(fillableTakerAssetAmount).to.bignumber.equal( signedOrder.takerAssetAmount.dividedToIntegerBy(divisor), ); }); it('should return the correct fillableTakerAssetAmount when non-fee balances/allowances are partially sufficient', async () => { const divisor = 4; - await erc20Token.setBalance.awaitTransactionSuccessAsync( - makerAddress, - signedOrder.makerAssetAmount.dividedToIntegerBy(divisor), - ); - await erc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.makerAssetAmount, { + await erc20Token + .setBalance(makerAddress, signedOrder.makerAssetAmount.dividedToIntegerBy(divisor)) + .awaitTransactionSuccessAsync(); + await erc20Token.approve(erc20Proxy.address, signedOrder.makerAssetAmount).awaitTransactionSuccessAsync({ from: makerAddress, }); - await feeErc20Token.setBalance.awaitTransactionSuccessAsync(makerAddress, signedOrder.makerFee); - await feeErc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.makerFee, { + await feeErc20Token.setBalance(makerAddress, signedOrder.makerFee).awaitTransactionSuccessAsync(); + await feeErc20Token.approve(erc20Proxy.address, signedOrder.makerFee).awaitTransactionSuccessAsync({ from: makerAddress, }); - const [, fillableTakerAssetAmount] = await devUtils.getOrderRelevantState.callAsync( - signedOrder, - signedOrder.signature, - ); + const [, fillableTakerAssetAmount] = await devUtils + .getOrderRelevantState(signedOrder, signedOrder.signature) + .callAsync(); expect(fillableTakerAssetAmount).to.bignumber.equal( signedOrder.takerAssetAmount.dividedToIntegerBy(divisor), ); }); it('should return the correct fillableTakerAssetAmount when balances/allowances of one asset within a multiAssetData are partially sufficient', async () => { - const multiAssetData = await devUtils.encodeMultiAssetData.callAsync( - [new BigNumber(1), new BigNumber(1)], - [erc20AssetData, erc20AssetData2], - ); + const multiAssetData = await devUtils + .encodeMultiAssetData([new BigNumber(1), new BigNumber(1)], [erc20AssetData, erc20AssetData2]) + .callAsync(); signedOrder = await orderFactory.newSignedOrderAsync({ makerAssetData: multiAssetData }); - await erc20Token.setBalance.awaitTransactionSuccessAsync(makerAddress, signedOrder.makerAssetAmount); - await erc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.makerAssetAmount, { + await erc20Token.setBalance(makerAddress, signedOrder.makerAssetAmount).awaitTransactionSuccessAsync(); + await erc20Token.approve(erc20Proxy.address, signedOrder.makerAssetAmount).awaitTransactionSuccessAsync({ from: makerAddress, }); - await feeErc20Token.setBalance.awaitTransactionSuccessAsync(makerAddress, signedOrder.makerFee); - await feeErc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.makerFee, { + await feeErc20Token.setBalance(makerAddress, signedOrder.makerFee).awaitTransactionSuccessAsync(); + await feeErc20Token.approve(erc20Proxy.address, signedOrder.makerFee).awaitTransactionSuccessAsync({ from: makerAddress, }); const divisor = 4; - await erc20Token2.setBalance.awaitTransactionSuccessAsync( - makerAddress, - signedOrder.makerAssetAmount.dividedToIntegerBy(divisor), - ); - await erc20Token2.approve.awaitTransactionSuccessAsync( - erc20Proxy.address, - signedOrder.makerAssetAmount.dividedToIntegerBy(divisor), - { + await erc20Token2 + .setBalance(makerAddress, signedOrder.makerAssetAmount.dividedToIntegerBy(divisor)) + .awaitTransactionSuccessAsync(); + await erc20Token2 + .approve(erc20Proxy.address, signedOrder.makerAssetAmount.dividedToIntegerBy(divisor)) + .awaitTransactionSuccessAsync({ from: makerAddress, - }, - ); - const [, fillableTakerAssetAmount] = await devUtils.getOrderRelevantState.callAsync( - signedOrder, - signedOrder.signature, - ); + }); + const [, fillableTakerAssetAmount] = await devUtils + .getOrderRelevantState(signedOrder, signedOrder.signature) + .callAsync(); expect(fillableTakerAssetAmount).to.bignumber.equal( signedOrder.takerAssetAmount.dividedToIntegerBy(divisor), ); }); it('should return a fillableTakerAssetAmount of 0 when non-fee balances/allowances are insufficient', async () => { - await feeErc20Token.setBalance.awaitTransactionSuccessAsync(makerAddress, signedOrder.makerFee); - await feeErc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.makerFee, { + await feeErc20Token.setBalance(makerAddress, signedOrder.makerFee).awaitTransactionSuccessAsync(); + await feeErc20Token.approve(erc20Proxy.address, signedOrder.makerFee).awaitTransactionSuccessAsync({ from: makerAddress, }); - const [, fillableTakerAssetAmount] = await devUtils.getOrderRelevantState.callAsync( - signedOrder, - signedOrder.signature, - ); + const [, fillableTakerAssetAmount] = await devUtils + .getOrderRelevantState(signedOrder, signedOrder.signature) + .callAsync(); expect(fillableTakerAssetAmount).to.bignumber.equal(constants.ZERO_AMOUNT); }); it('should return a fillableTakerAssetAmount equal to the takerAssetAmount when the order is unfilled and balances/allowances are sufficient', async () => { - await erc20Token.setBalance.awaitTransactionSuccessAsync(makerAddress, signedOrder.makerAssetAmount); - await erc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.makerAssetAmount, { + await erc20Token.setBalance(makerAddress, signedOrder.makerAssetAmount).awaitTransactionSuccessAsync(); + await erc20Token.approve(erc20Proxy.address, signedOrder.makerAssetAmount).awaitTransactionSuccessAsync({ from: makerAddress, }); - await feeErc20Token.setBalance.awaitTransactionSuccessAsync(makerAddress, signedOrder.makerFee); - await feeErc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.makerFee, { + await feeErc20Token.setBalance(makerAddress, signedOrder.makerFee).awaitTransactionSuccessAsync(); + await feeErc20Token.approve(erc20Proxy.address, signedOrder.makerFee).awaitTransactionSuccessAsync({ from: makerAddress, }); - const [, fillableTakerAssetAmount] = await devUtils.getOrderRelevantState.callAsync( - signedOrder, - signedOrder.signature, - ); + const [, fillableTakerAssetAmount] = await devUtils + .getOrderRelevantState(signedOrder, signedOrder.signature) + .callAsync(); expect(fillableTakerAssetAmount).to.bignumber.equal(signedOrder.takerAssetAmount); }); it('should return the correct fillableTakerAssetAmount when balances/allowances are partially sufficient and makerAsset=makerFeeAsset', async () => { @@ -352,60 +331,54 @@ describe('OrderValidationUtils/OrderTransferSimulatorUtils', () => { makerFee: new BigNumber(40), }); const transferableMakerAssetAmount = new BigNumber(10); - await feeErc20Token.setBalance.awaitTransactionSuccessAsync(makerAddress, transferableMakerAssetAmount); - await feeErc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, transferableMakerAssetAmount, { + await feeErc20Token.setBalance(makerAddress, transferableMakerAssetAmount).awaitTransactionSuccessAsync(); + await feeErc20Token.approve(erc20Proxy.address, transferableMakerAssetAmount).awaitTransactionSuccessAsync({ from: makerAddress, }); const expectedFillableTakerAssetAmount = transferableMakerAssetAmount .times(signedOrder.takerAssetAmount) .dividedToIntegerBy(signedOrder.makerAssetAmount.plus(signedOrder.makerFee)); - const [, fillableTakerAssetAmount] = await devUtils.getOrderRelevantState.callAsync( - signedOrder, - signedOrder.signature, - ); + const [, fillableTakerAssetAmount] = await devUtils + .getOrderRelevantState(signedOrder, signedOrder.signature) + .callAsync(); expect(fillableTakerAssetAmount).to.bignumber.equal(expectedFillableTakerAssetAmount); }); it('should return the correct fillabeTakerassetAmount when makerAsset balances/allowances are sufficient and there are no maker fees', async () => { signedOrder = await orderFactory.newSignedOrderAsync({ makerFee: constants.ZERO_AMOUNT }); - await erc20Token.setBalance.awaitTransactionSuccessAsync(makerAddress, signedOrder.makerAssetAmount); - await erc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.makerAssetAmount, { + await erc20Token.setBalance(makerAddress, signedOrder.makerAssetAmount).awaitTransactionSuccessAsync(); + await erc20Token.approve(erc20Proxy.address, signedOrder.makerAssetAmount).awaitTransactionSuccessAsync({ from: makerAddress, }); - const [, fillableTakerAssetAmount] = await devUtils.getOrderRelevantState.callAsync( - signedOrder, - signedOrder.signature, - ); + const [, fillableTakerAssetAmount] = await devUtils + .getOrderRelevantState(signedOrder, signedOrder.signature) + .callAsync(); expect(fillableTakerAssetAmount).to.bignumber.equal(signedOrder.takerAssetAmount); }); it('should return a fillableTakerAssetAmount when the remaining takerAssetAmount is less than the transferable amount', async () => { - await erc20Token.setBalance.awaitTransactionSuccessAsync(makerAddress, signedOrder.makerAssetAmount); - await erc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.makerAssetAmount, { + await erc20Token.setBalance(makerAddress, signedOrder.makerAssetAmount).awaitTransactionSuccessAsync(); + await erc20Token.approve(erc20Proxy.address, signedOrder.makerAssetAmount).awaitTransactionSuccessAsync({ from: makerAddress, }); - await feeErc20Token.setBalance.awaitTransactionSuccessAsync(makerAddress, signedOrder.makerFee); - await feeErc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.makerFee, { + await feeErc20Token.setBalance(makerAddress, signedOrder.makerFee).awaitTransactionSuccessAsync(); + await feeErc20Token.approve(erc20Proxy.address, signedOrder.makerFee).awaitTransactionSuccessAsync({ from: makerAddress, }); - await erc20Token2.setBalance.awaitTransactionSuccessAsync(takerAddress, signedOrder.takerAssetAmount); - await erc20Token2.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.takerAssetAmount, { + await erc20Token2.setBalance(takerAddress, signedOrder.takerAssetAmount).awaitTransactionSuccessAsync(); + await erc20Token2.approve(erc20Proxy.address, signedOrder.takerAssetAmount).awaitTransactionSuccessAsync({ from: takerAddress, }); - await feeErc20Token.setBalance.awaitTransactionSuccessAsync(takerAddress, signedOrder.takerFee); + await feeErc20Token.setBalance(takerAddress, signedOrder.takerFee).awaitTransactionSuccessAsync(); - await feeErc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.takerFee, { + await feeErc20Token.approve(erc20Proxy.address, signedOrder.takerFee).awaitTransactionSuccessAsync({ from: takerAddress, }); const takerAssetFillAmount = signedOrder.takerAssetAmount.dividedToIntegerBy(4); - await exchange.fillOrder.awaitTransactionSuccessAsync( - signedOrder, - takerAssetFillAmount, - signedOrder.signature, - { from: takerAddress }, - ); - const [, fillableTakerAssetAmount] = await devUtils.getOrderRelevantState.callAsync( - signedOrder, - signedOrder.signature, - ); + await exchange + .fillOrder(signedOrder, takerAssetFillAmount, signedOrder.signature) + .awaitTransactionSuccessAsync({ from: takerAddress }); + const [, fillableTakerAssetAmount] = await devUtils + .getOrderRelevantState(signedOrder, signedOrder.signature) + .callAsync(); expect(fillableTakerAssetAmount).to.bignumber.equal( signedOrder.takerAssetAmount.minus(takerAssetFillAmount), ); @@ -417,15 +390,13 @@ describe('OrderValidationUtils/OrderTransferSimulatorUtils', () => { makerFeeAssetData: '0x', takerFeeAssetData: '0x', }); - await erc20Token.setBalance.awaitTransactionSuccessAsync(makerAddress, signedOrder.makerAssetAmount); - await erc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.makerAssetAmount, { + await erc20Token.setBalance(makerAddress, signedOrder.makerAssetAmount).awaitTransactionSuccessAsync(); + await erc20Token.approve(erc20Proxy.address, signedOrder.makerAssetAmount).awaitTransactionSuccessAsync({ from: makerAddress, }); - const [ - orderInfo, - fillableTakerAssetAmount, - isValidSignature, - ] = await devUtils.getOrderRelevantState.callAsync(signedOrder, signedOrder.signature); + const [orderInfo, fillableTakerAssetAmount, isValidSignature] = await devUtils + .getOrderRelevantState(signedOrder, signedOrder.signature) + .callAsync(); expect(orderInfo.orderHash).to.equal(orderHashUtils.getOrderHashHex(signedOrder)); expect(orderInfo.orderStatus).to.equal(OrderStatus.Fillable); expect(orderInfo.orderTakerAssetFilledAmount).to.bignumber.equal(constants.ZERO_AMOUNT); @@ -436,25 +407,20 @@ describe('OrderValidationUtils/OrderTransferSimulatorUtils', () => { describe('getOrderRelevantStates', async () => { it('should return the correct information for multiple orders', async () => { signedOrder = await orderFactory.newSignedOrderAsync(); - await erc20Token.setBalance.awaitTransactionSuccessAsync(makerAddress, signedOrder.makerAssetAmount); - await erc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.makerAssetAmount, { + await erc20Token.setBalance(makerAddress, signedOrder.makerAssetAmount).awaitTransactionSuccessAsync(); + await erc20Token.approve(erc20Proxy.address, signedOrder.makerAssetAmount).awaitTransactionSuccessAsync({ from: makerAddress, }); - await feeErc20Token.setBalance.awaitTransactionSuccessAsync(makerAddress, signedOrder.makerFee); - await feeErc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.makerFee, { + await feeErc20Token.setBalance(makerAddress, signedOrder.makerFee).awaitTransactionSuccessAsync(); + await feeErc20Token.approve(erc20Proxy.address, signedOrder.makerFee).awaitTransactionSuccessAsync({ from: makerAddress, }); const signedOrder2 = await orderFactory.newSignedOrderAsync({ makerAssetData: erc721AssetData }); const invalidSignature = '0x01'; - await exchange.cancelOrder.awaitTransactionSuccessAsync(signedOrder2, { from: makerAddress }); - const [ - ordersInfo, - fillableTakerAssetAmounts, - isValidSignature, - ] = await devUtils.getOrderRelevantStates.callAsync( - [signedOrder, signedOrder2], - [signedOrder.signature, invalidSignature], - ); + await exchange.cancelOrder(signedOrder2).awaitTransactionSuccessAsync({ from: makerAddress }); + const [ordersInfo, fillableTakerAssetAmounts, isValidSignature] = await devUtils + .getOrderRelevantStates([signedOrder, signedOrder2], [signedOrder.signature, invalidSignature]) + .callAsync(); expect(ordersInfo[0].orderHash).to.equal(orderHashUtils.getOrderHashHex(signedOrder)); expect(ordersInfo[1].orderHash).to.equal(orderHashUtils.getOrderHashHex(signedOrder2)); expect(ordersInfo[0].orderStatus).to.equal(OrderStatus.Fillable); @@ -472,177 +438,162 @@ describe('OrderValidationUtils/OrderTransferSimulatorUtils', () => { signedOrder = await orderFactory.newSignedOrderAsync(); }); it('should return TakerAssetDataFailed if the takerAsset transfer fails', async () => { - const orderTransferResults = await devUtils.getSimulatedOrderTransferResults.callAsync( - signedOrder, - takerAddress, - signedOrder.takerAssetAmount, - ); + const orderTransferResults = await devUtils + .getSimulatedOrderTransferResults(signedOrder, takerAddress, signedOrder.takerAssetAmount) + .callAsync(); expect(orderTransferResults).to.equal(OrderTransferResults.TakerAssetDataFailed); }); it('should return MakerAssetDataFailed if the makerAsset transfer fails', async () => { - await erc20Token2.setBalance.awaitTransactionSuccessAsync(takerAddress, signedOrder.takerAssetAmount, { + await erc20Token2.setBalance(takerAddress, signedOrder.takerAssetAmount).awaitTransactionSuccessAsync({ from: owner, }); - await erc20Token2.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.takerAssetAmount, { + await erc20Token2.approve(erc20Proxy.address, signedOrder.takerAssetAmount).awaitTransactionSuccessAsync({ from: takerAddress, }); - const orderTransferResults = await devUtils.getSimulatedOrderTransferResults.callAsync( - signedOrder, - takerAddress, - signedOrder.takerAssetAmount, - ); + const orderTransferResults = await devUtils + .getSimulatedOrderTransferResults(signedOrder, takerAddress, signedOrder.takerAssetAmount) + .callAsync(); expect(orderTransferResults).to.equal(OrderTransferResults.MakerAssetDataFailed); }); it('should return TakerFeeAssetDataFailed if the takerFeeAsset transfer fails', async () => { - await erc20Token2.setBalance.awaitTransactionSuccessAsync(takerAddress, signedOrder.takerAssetAmount, { + await erc20Token2.setBalance(takerAddress, signedOrder.takerAssetAmount).awaitTransactionSuccessAsync({ from: owner, }); - await erc20Token2.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.takerAssetAmount, { + await erc20Token2.approve(erc20Proxy.address, signedOrder.takerAssetAmount).awaitTransactionSuccessAsync({ from: takerAddress, }); - await erc20Token.setBalance.awaitTransactionSuccessAsync(makerAddress, signedOrder.makerAssetAmount, { + await erc20Token.setBalance(makerAddress, signedOrder.makerAssetAmount).awaitTransactionSuccessAsync({ from: owner, }); - await erc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.makerAssetAmount, { + await erc20Token.approve(erc20Proxy.address, signedOrder.makerAssetAmount).awaitTransactionSuccessAsync({ from: makerAddress, }); - const orderTransferResults = await devUtils.getSimulatedOrderTransferResults.callAsync( - signedOrder, - takerAddress, - signedOrder.takerAssetAmount, - ); + const orderTransferResults = await devUtils + .getSimulatedOrderTransferResults(signedOrder, takerAddress, signedOrder.takerAssetAmount) + .callAsync(); expect(orderTransferResults).to.equal(OrderTransferResults.TakerFeeAssetDataFailed); }); it('should return MakerFeeAssetDataFailed if the makerFeeAsset transfer fails', async () => { - await erc20Token2.setBalance.awaitTransactionSuccessAsync(takerAddress, signedOrder.takerAssetAmount, { + await erc20Token2.setBalance(takerAddress, signedOrder.takerAssetAmount).awaitTransactionSuccessAsync({ from: owner, }); - await erc20Token2.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.takerAssetAmount, { + await erc20Token2.approve(erc20Proxy.address, signedOrder.takerAssetAmount).awaitTransactionSuccessAsync({ from: takerAddress, }); - await erc20Token.setBalance.awaitTransactionSuccessAsync(makerAddress, signedOrder.makerAssetAmount, { + await erc20Token.setBalance(makerAddress, signedOrder.makerAssetAmount).awaitTransactionSuccessAsync({ from: owner, }); - await erc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.makerAssetAmount, { + await erc20Token.approve(erc20Proxy.address, signedOrder.makerAssetAmount).awaitTransactionSuccessAsync({ from: makerAddress, }); - await feeErc20Token.setBalance.awaitTransactionSuccessAsync(takerAddress, signedOrder.takerFee, { + await feeErc20Token.setBalance(takerAddress, signedOrder.takerFee).awaitTransactionSuccessAsync({ from: owner, }); - await feeErc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.takerFee, { + await feeErc20Token.approve(erc20Proxy.address, signedOrder.takerFee).awaitTransactionSuccessAsync({ from: takerAddress, }); - const orderTransferResults = await devUtils.getSimulatedOrderTransferResults.callAsync( - signedOrder, - takerAddress, - signedOrder.takerAssetAmount, - ); + const orderTransferResults = await devUtils + .getSimulatedOrderTransferResults(signedOrder, takerAddress, signedOrder.takerAssetAmount) + .callAsync(); expect(orderTransferResults).to.equal(OrderTransferResults.MakerFeeAssetDataFailed); }); it('should return TransfersSuccessful if all transfers succeed', async () => { - await erc20Token2.setBalance.awaitTransactionSuccessAsync(takerAddress, signedOrder.takerAssetAmount, { + await erc20Token2.setBalance(takerAddress, signedOrder.takerAssetAmount).awaitTransactionSuccessAsync({ from: owner, }); - await erc20Token2.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.takerAssetAmount, { + await erc20Token2.approve(erc20Proxy.address, signedOrder.takerAssetAmount).awaitTransactionSuccessAsync({ from: takerAddress, }); - await erc20Token.setBalance.awaitTransactionSuccessAsync(makerAddress, signedOrder.makerAssetAmount, { + await erc20Token.setBalance(makerAddress, signedOrder.makerAssetAmount).awaitTransactionSuccessAsync({ from: owner, }); - await erc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.makerAssetAmount, { + await erc20Token.approve(erc20Proxy.address, signedOrder.makerAssetAmount).awaitTransactionSuccessAsync({ from: makerAddress, }); - await feeErc20Token.setBalance.awaitTransactionSuccessAsync(takerAddress, signedOrder.takerFee, { + await feeErc20Token.setBalance(takerAddress, signedOrder.takerFee).awaitTransactionSuccessAsync({ from: owner, }); - await feeErc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.takerFee, { + await feeErc20Token.approve(erc20Proxy.address, signedOrder.takerFee).awaitTransactionSuccessAsync({ from: takerAddress, }); - await feeErc20Token.setBalance.awaitTransactionSuccessAsync(makerAddress, signedOrder.makerFee, { + await feeErc20Token.setBalance(makerAddress, signedOrder.makerFee).awaitTransactionSuccessAsync({ from: owner, }); - await feeErc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.makerFee, { + await feeErc20Token.approve(erc20Proxy.address, signedOrder.makerFee).awaitTransactionSuccessAsync({ from: makerAddress, }); - const orderTransferResults = await devUtils.getSimulatedOrderTransferResults.callAsync( - signedOrder, - takerAddress, - signedOrder.takerAssetAmount, - ); + const orderTransferResults = await devUtils + .getSimulatedOrderTransferResults(signedOrder, takerAddress, signedOrder.takerAssetAmount) + .callAsync(); expect(orderTransferResults).to.equal(OrderTransferResults.TransfersSuccessful); }); it('should return TransfersSuccessful for a partial fill when taker has ample assets for the fill but not for the whole order', async () => { - await erc20Token2.setBalance.awaitTransactionSuccessAsync( - takerAddress, - signedOrder.takerAssetAmount.dividedBy(2), - { + await erc20Token2 + .setBalance(takerAddress, signedOrder.takerAssetAmount.dividedBy(2)) + .awaitTransactionSuccessAsync({ from: owner, - }, - ); - await erc20Token2.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.takerAssetAmount, { + }); + await erc20Token2.approve(erc20Proxy.address, signedOrder.takerAssetAmount).awaitTransactionSuccessAsync({ from: takerAddress, }); - await erc20Token.setBalance.awaitTransactionSuccessAsync(makerAddress, signedOrder.makerAssetAmount, { + await erc20Token.setBalance(makerAddress, signedOrder.makerAssetAmount).awaitTransactionSuccessAsync({ from: owner, }); - await erc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.makerAssetAmount, { + await erc20Token.approve(erc20Proxy.address, signedOrder.makerAssetAmount).awaitTransactionSuccessAsync({ from: makerAddress, }); - await feeErc20Token.setBalance.awaitTransactionSuccessAsync(takerAddress, signedOrder.takerFee, { + await feeErc20Token.setBalance(takerAddress, signedOrder.takerFee).awaitTransactionSuccessAsync({ from: owner, }); - await feeErc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.takerFee, { + await feeErc20Token.approve(erc20Proxy.address, signedOrder.takerFee).awaitTransactionSuccessAsync({ from: takerAddress, }); - await feeErc20Token.setBalance.awaitTransactionSuccessAsync(makerAddress, signedOrder.makerFee, { + await feeErc20Token.setBalance(makerAddress, signedOrder.makerFee).awaitTransactionSuccessAsync({ from: owner, }); - await feeErc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.makerFee, { + await feeErc20Token.approve(erc20Proxy.address, signedOrder.makerFee).awaitTransactionSuccessAsync({ from: makerAddress, }); - const orderTransferResults = await devUtils.getSimulatedOrderTransferResults.callAsync( - signedOrder, - takerAddress, - signedOrder.takerAssetAmount.dividedBy(2), - ); + const orderTransferResults = await devUtils + .getSimulatedOrderTransferResults(signedOrder, takerAddress, signedOrder.takerAssetAmount.dividedBy(2)) + .callAsync(); expect(orderTransferResults).to.equal(OrderTransferResults.TransfersSuccessful); }); }); describe('getSimulatedOrdersTransferResults', async () => { it('should simulate the transfers of each order independently from one another', async () => { // Set balances and allowances to exactly enough to fill a single order - await erc20Token2.setBalance.awaitTransactionSuccessAsync(takerAddress, signedOrder.takerAssetAmount, { + await erc20Token2.setBalance(takerAddress, signedOrder.takerAssetAmount).awaitTransactionSuccessAsync({ from: owner, }); - await erc20Token2.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.takerAssetAmount, { + await erc20Token2.approve(erc20Proxy.address, signedOrder.takerAssetAmount).awaitTransactionSuccessAsync({ from: takerAddress, }); - await erc20Token.setBalance.awaitTransactionSuccessAsync(makerAddress, signedOrder.makerAssetAmount, { + await erc20Token.setBalance(makerAddress, signedOrder.makerAssetAmount).awaitTransactionSuccessAsync({ from: owner, }); - await erc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.makerAssetAmount, { + await erc20Token.approve(erc20Proxy.address, signedOrder.makerAssetAmount).awaitTransactionSuccessAsync({ from: makerAddress, }); - await feeErc20Token.setBalance.awaitTransactionSuccessAsync(takerAddress, signedOrder.takerFee, { + await feeErc20Token.setBalance(takerAddress, signedOrder.takerFee).awaitTransactionSuccessAsync({ from: owner, }); - await feeErc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.takerFee, { + await feeErc20Token.approve(erc20Proxy.address, signedOrder.takerFee).awaitTransactionSuccessAsync({ from: takerAddress, }); - await feeErc20Token.setBalance.awaitTransactionSuccessAsync(makerAddress, signedOrder.makerFee, { + await feeErc20Token.setBalance(makerAddress, signedOrder.makerFee).awaitTransactionSuccessAsync({ from: owner, }); - await feeErc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.makerFee, { + await feeErc20Token.approve(erc20Proxy.address, signedOrder.makerFee).awaitTransactionSuccessAsync({ from: makerAddress, }); - const [ - orderTransferResults1, - orderTransferResults2, - ] = await devUtils.getSimulatedOrdersTransferResults.callAsync( - [signedOrder, signedOrder], - [takerAddress, takerAddress], - [signedOrder.takerAssetAmount, signedOrder.takerAssetAmount], - ); + const [orderTransferResults1, orderTransferResults2] = await devUtils + .getSimulatedOrdersTransferResults( + [signedOrder, signedOrder], + [takerAddress, takerAddress], + [signedOrder.takerAssetAmount, signedOrder.takerAssetAmount], + ) + .callAsync(); expect(orderTransferResults1).to.equal(OrderTransferResults.TransfersSuccessful); expect(orderTransferResults2).to.equal(OrderTransferResults.TransfersSuccessful); }); diff --git a/contracts/utils/test/authorizable.ts b/contracts/utils/test/authorizable.ts index b2a1a46876..8d11c67f4f 100644 --- a/contracts/utils/test/authorizable.ts +++ b/contracts/utils/test/authorizable.ts @@ -46,68 +46,68 @@ describe('Authorizable', () => { describe('addAuthorizedAddress', () => { it('should revert if not called by owner', async () => { const expectedError = new OwnableRevertErrors.OnlyOwnerError(notOwner, owner); - const tx = authorizable.addAuthorizedAddress.sendTransactionAsync(notOwner, { from: notOwner }); + const tx = authorizable.addAuthorizedAddress(notOwner).sendTransactionAsync({ from: notOwner }); return expect(tx).to.revertWith(expectedError); }); it('should allow owner to add an authorized address', async () => { - await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner }); - const isAuthorized = await authorizable.authorized.callAsync(address); + await authorizable.addAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner }); + const isAuthorized = await authorizable.authorized(address).callAsync(); expect(isAuthorized).to.be.true(); }); it('should revert if owner attempts to authorize the zero address', async () => { const expectedError = new AuthorizableRevertErrors.ZeroCantBeAuthorizedError(); - const tx = authorizable.addAuthorizedAddress.sendTransactionAsync(constants.NULL_ADDRESS, { from: owner }); + const tx = authorizable.addAuthorizedAddress(constants.NULL_ADDRESS).sendTransactionAsync({ from: owner }); return expect(tx).to.revertWith(expectedError); }); it('should revert if owner attempts to authorize a duplicate address', async () => { - await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner }); + await authorizable.addAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner }); const expectedError = new AuthorizableRevertErrors.TargetAlreadyAuthorizedError(address); - const tx = authorizable.addAuthorizedAddress.sendTransactionAsync(address, { from: owner }); + const tx = authorizable.addAuthorizedAddress(address).sendTransactionAsync({ from: owner }); return expect(tx).to.revertWith(expectedError); }); }); describe('removeAuthorizedAddress', () => { it('should revert if not called by owner', async () => { - await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner }); + await authorizable.addAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner }); const expectedError = new OwnableRevertErrors.OnlyOwnerError(notOwner, owner); - const tx = authorizable.removeAuthorizedAddress.sendTransactionAsync(address, { from: notOwner }); + const tx = authorizable.removeAuthorizedAddress(address).sendTransactionAsync({ from: notOwner }); return expect(tx).to.revertWith(expectedError); }); it('should allow owner to remove an authorized address', async () => { - await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner }); - await authorizable.removeAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner }); - const isAuthorized = await authorizable.authorized.callAsync(address); + await authorizable.addAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner }); + await authorizable.removeAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner }); + const isAuthorized = await authorizable.authorized(address).callAsync(); expect(isAuthorized).to.be.false(); }); it('should revert if owner attempts to remove an address that is not authorized', async () => { const expectedError = new AuthorizableRevertErrors.TargetNotAuthorizedError(address); - const tx = authorizable.removeAuthorizedAddress.sendTransactionAsync(address, { from: owner }); + const tx = authorizable.removeAuthorizedAddress(address).sendTransactionAsync({ from: owner }); return expect(tx).to.revertWith(expectedError); }); }); describe('removeAuthorizedAddressAtIndex', () => { it('should revert if not called by owner', async () => { - await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner }); + await authorizable.addAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner }); const index = new BigNumber(0); const expectedError = new OwnableRevertErrors.OnlyOwnerError(notOwner, owner); - const tx = authorizable.removeAuthorizedAddressAtIndex.sendTransactionAsync(address, index, { + const tx = authorizable.removeAuthorizedAddressAtIndex(address, index).sendTransactionAsync({ from: notOwner, }); return expect(tx).to.revertWith(expectedError); }); it('should revert if index is >= authorities.length', async () => { - await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner }); + await authorizable.addAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner }); const index = new BigNumber(1); const expectedError = new AuthorizableRevertErrors.IndexOutOfBoundsError(index, index); - const tx = authorizable.removeAuthorizedAddressAtIndex.sendTransactionAsync(address, index, { + const tx = authorizable.removeAuthorizedAddressAtIndex(address, index).sendTransactionAsync({ from: owner, }); return expect(tx).to.revertWith(expectedError); @@ -116,7 +116,7 @@ describe('Authorizable', () => { it('should revert if owner attempts to remove an address that is not authorized', async () => { const index = new BigNumber(0); const expectedError = new AuthorizableRevertErrors.TargetNotAuthorizedError(address); - const tx = authorizable.removeAuthorizedAddressAtIndex.sendTransactionAsync(address, index, { + const tx = authorizable.removeAuthorizedAddressAtIndex(address, index).sendTransactionAsync({ from: owner, }); return expect(tx).to.revertWith(expectedError); @@ -125,37 +125,37 @@ describe('Authorizable', () => { it('should revert if address at index does not match target', async () => { const address1 = address; const address2 = notOwner; - await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address1, { from: owner }); - await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address2, { from: owner }); + await authorizable.addAuthorizedAddress(address1).awaitTransactionSuccessAsync({ from: owner }); + await authorizable.addAuthorizedAddress(address2).awaitTransactionSuccessAsync({ from: owner }); const address1Index = new BigNumber(0); const expectedError = new AuthorizableRevertErrors.AuthorizedAddressMismatchError(address1, address2); - const tx = authorizable.removeAuthorizedAddressAtIndex.sendTransactionAsync(address2, address1Index, { + const tx = authorizable.removeAuthorizedAddressAtIndex(address2, address1Index).sendTransactionAsync({ from: owner, }); return expect(tx).to.revertWith(expectedError); }); it('should allow owner to remove an authorized address', async () => { - await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner }); + await authorizable.addAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner }); const index = new BigNumber(0); - await authorizable.removeAuthorizedAddressAtIndex.awaitTransactionSuccessAsync(address, index, { + await authorizable.removeAuthorizedAddressAtIndex(address, index).awaitTransactionSuccessAsync({ from: owner, }); - const isAuthorized = await authorizable.authorized.callAsync(address); + const isAuthorized = await authorizable.authorized(address).callAsync(); expect(isAuthorized).to.be.false(); }); }); describe('getAuthorizedAddresses', () => { it('should return all authorized addresses', async () => { - const initial = await authorizable.getAuthorizedAddresses.callAsync(); + const initial = await authorizable.getAuthorizedAddresses().callAsync(); expect(initial).to.have.length(0); - await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner }); - const afterAdd = await authorizable.getAuthorizedAddresses.callAsync(); + await authorizable.addAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner }); + const afterAdd = await authorizable.getAuthorizedAddresses().callAsync(); expect(afterAdd).to.have.length(1); expect(afterAdd).to.include(address); - await authorizable.removeAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner }); - const afterRemove = await authorizable.getAuthorizedAddresses.callAsync(); + await authorizable.removeAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner }); + const afterRemove = await authorizable.getAuthorizedAddresses().callAsync(); expect(afterRemove).to.have.length(0); }); }); diff --git a/contracts/utils/test/lib_address.ts b/contracts/utils/test/lib_address.ts index a538e610c0..41a270befc 100644 --- a/contracts/utils/test/lib_address.ts +++ b/contracts/utils/test/lib_address.ts @@ -30,12 +30,12 @@ describe('LibAddress', () => { describe('isContract', () => { it('should return false for a non-contract address', async () => { - const isContract = await lib.externalIsContract.callAsync(nonContract); + const isContract = await lib.externalIsContract(nonContract).callAsync(); expect(isContract).to.be.false(); }); it('should return true for a non-contract address', async () => { - const isContract = await lib.externalIsContract.callAsync(lib.address); + const isContract = await lib.externalIsContract(lib.address).callAsync(); expect(isContract).to.be.true(); }); }); diff --git a/contracts/utils/test/lib_address_array.ts b/contracts/utils/test/lib_address_array.ts index 5f74cc3659..25923aa4aa 100644 --- a/contracts/utils/test/lib_address_array.ts +++ b/contracts/utils/test/lib_address_array.ts @@ -30,7 +30,7 @@ describe('LibAddressArray', () => { describe('append', () => { it('should append to empty array', async () => { const addr = randomAddress(); - const result = await lib.publicAppend.callAsync([], addr); + const result = await lib.publicAppend([], addr).callAsync(); const expected = [addr]; expect(result).to.deep.equal(expected); }); @@ -39,7 +39,7 @@ describe('LibAddressArray', () => { const arr = _.times(3, () => randomAddress()); const addr = randomAddress(); const expected = [...arr, addr]; - const result = await lib.publicAppend.callAsync(arr, addr); + const result = await lib.publicAppend(arr, addr).callAsync(); expect(result).to.deep.equal(expected); }); @@ -52,7 +52,7 @@ describe('LibAddressArray', () => { addressArrayEndPtr.plus(freeMemOffset), addressArrayEndPtr, ); - return expect(lib.testAppendRealloc.callAsync(arr, freeMemOffset, addr)).to.revertWith(expectedError); + return expect(lib.testAppendRealloc(arr, freeMemOffset, addr).callAsync()).to.revertWith(expectedError); }); it('should keep the same memory address if free memory pointer does not move', async () => { @@ -60,11 +60,9 @@ describe('LibAddressArray', () => { const addr = randomAddress(); const freeMemOffset = new BigNumber(0); const expected = [...arr, addr]; - const [result, oldArrayMemStart, newArrayMemStart] = await lib.testAppendRealloc.callAsync( - arr, - freeMemOffset, - addr, - ); + const [result, oldArrayMemStart, newArrayMemStart] = await lib + .testAppendRealloc(arr, freeMemOffset, addr) + .callAsync(); expect(result).to.deep.equal(expected); expect(newArrayMemStart).bignumber.to.be.equal(oldArrayMemStart); }); @@ -74,11 +72,9 @@ describe('LibAddressArray', () => { const addr = randomAddress(); const freeMemOffset = new BigNumber(1); const expectedArray = [...arr, addr]; - const [result, oldArrayMemStart, newArrayMemStart] = await lib.testAppendRealloc.callAsync( - arr, - freeMemOffset, - addr, - ); + const [result, oldArrayMemStart, newArrayMemStart] = await lib + .testAppendRealloc(arr, freeMemOffset, addr) + .callAsync(); // The new location should be the end of the old array + freeMemOffset. const expectedNewArrayMemStart = oldArrayMemStart.plus((arr.length + 1) * 32).plus(freeMemOffset); expect(result).to.deep.equal(expectedArray); @@ -89,27 +85,27 @@ describe('LibAddressArray', () => { describe('contains', () => { it('should return false on an empty array', async () => { const addr = randomAddress(); - const isFound = await lib.publicContains.callAsync([], addr); + const isFound = await lib.publicContains([], addr).callAsync(); expect(isFound).to.equal(false); }); it('should return false on a missing item', async () => { const arr = _.times(3, () => randomAddress()); const addr = randomAddress(); - const isFound = await lib.publicContains.callAsync(arr, addr); + const isFound = await lib.publicContains(arr, addr).callAsync(); expect(isFound).to.equal(false); }); it('should return true on an included item', async () => { const arr = _.times(4, () => randomAddress()); const addr = _.sample(arr) as string; - const isFound = await lib.publicContains.callAsync(arr, addr); + const isFound = await lib.publicContains(arr, addr).callAsync(); expect(isFound).to.equal(true); }); it('should return true on the only item in the array', async () => { const arr = _.times(1, () => randomAddress()); - const isFound = await lib.publicContains.callAsync(arr, arr[0]); + const isFound = await lib.publicContains(arr, arr[0]).callAsync(); expect(isFound).to.equal(true); }); }); @@ -117,14 +113,14 @@ describe('LibAddressArray', () => { describe('indexOf', () => { it('should fail on an empty array', async () => { const addr = randomAddress(); - const [isSuccess] = await lib.publicIndexOf.callAsync([], addr); + const [isSuccess] = await lib.publicIndexOf([], addr).callAsync(); expect(isSuccess).to.equal(false); }); it('should fail on a missing item', async () => { const arr = _.times(3, () => randomAddress()); const addr = randomAddress(); - const [isSuccess] = await lib.publicIndexOf.callAsync(arr, addr); + const [isSuccess] = await lib.publicIndexOf(arr, addr).callAsync(); expect(isSuccess).to.equal(false); }); @@ -132,14 +128,14 @@ describe('LibAddressArray', () => { const arr = _.times(4, () => randomAddress()); const expectedIndexOf = _.random(0, arr.length - 1); const addr = arr[expectedIndexOf]; - const [isSuccess, index] = await lib.publicIndexOf.callAsync(arr, addr); + const [isSuccess, index] = await lib.publicIndexOf(arr, addr).callAsync(); expect(isSuccess).to.equal(true); expect(index).bignumber.to.equal(expectedIndexOf); }); it('should succeed on the only item in the array', async () => { const arr = _.times(1, () => randomAddress()); - const [isSuccess, index] = await lib.publicIndexOf.callAsync(arr, arr[0]); + const [isSuccess, index] = await lib.publicIndexOf(arr, arr[0]).callAsync(); expect(isSuccess).to.equal(true); expect(index).bignumber.to.equal(0); }); diff --git a/contracts/utils/test/lib_bytes.ts b/contracts/utils/test/lib_bytes.ts index 541ea43dff..90cec2d1ec 100644 --- a/contracts/utils/test/lib_bytes.ts +++ b/contracts/utils/test/lib_bytes.ts @@ -59,17 +59,17 @@ blockchainTests('LibBytes', env => { constants.ZERO_AMOUNT, constants.ZERO_AMOUNT, ); - return expect(libBytes.publicPopLastByte.callAsync(constants.NULL_BYTES)).to.revertWith(expectedError); + return expect(libBytes.publicPopLastByte(constants.NULL_BYTES).callAsync()).to.revertWith(expectedError); }); it('should pop the last byte from the input and return it when array holds more than 1 byte', async () => { - const [newBytes, poppedByte] = await libBytes.publicPopLastByte.callAsync(byteArrayLongerThan32Bytes); + const [newBytes, poppedByte] = await libBytes.publicPopLastByte(byteArrayLongerThan32Bytes).callAsync(); const expectedNewBytes = byteArrayLongerThan32Bytes.slice(0, -2); const expectedPoppedByte = `0x${byteArrayLongerThan32Bytes.slice(-2)}`; expect(newBytes).to.equal(expectedNewBytes); expect(poppedByte).to.equal(expectedPoppedByte); }); it('should pop the last byte from the input and return it when array is exactly 1 byte', async () => { - const [newBytes, poppedByte] = await libBytes.publicPopLastByte.callAsync(testByte); + const [newBytes, poppedByte] = await libBytes.publicPopLastByte(testByte).callAsync(); const expectedNewBytes = '0x'; expect(newBytes).to.equal(expectedNewBytes); return expect(poppedByte).to.be.equal(testByte); @@ -78,51 +78,45 @@ blockchainTests('LibBytes', env => { describe('equals', () => { it('should return true if byte arrays are equal (both arrays < 32 bytes)', async () => { - const isEqual = await libBytes.publicEquals.callAsync( - byteArrayShorterThan32Bytes, - byteArrayShorterThan32Bytes, - ); + const isEqual = await libBytes + .publicEquals(byteArrayShorterThan32Bytes, byteArrayShorterThan32Bytes) + .callAsync(); return expect(isEqual).to.be.true(); }); it('should return true if byte arrays are equal (both arrays > 32 bytes)', async () => { - const isEqual = await libBytes.publicEquals.callAsync( - byteArrayLongerThan32Bytes, - byteArrayLongerThan32Bytes, - ); + const isEqual = await libBytes + .publicEquals(byteArrayLongerThan32Bytes, byteArrayLongerThan32Bytes) + .callAsync(); return expect(isEqual).to.be.true(); }); it('should return false if byte arrays are not equal (first array < 32 bytes, second array > 32 bytes)', async () => { - const isEqual = await libBytes.publicEquals.callAsync( - byteArrayShorterThan32Bytes, - byteArrayLongerThan32Bytes, - ); + const isEqual = await libBytes + .publicEquals(byteArrayShorterThan32Bytes, byteArrayLongerThan32Bytes) + .callAsync(); return expect(isEqual).to.be.false(); }); it('should return false if byte arrays are not equal (first array > 32 bytes, second array < 32 bytes)', async () => { - const isEqual = await libBytes.publicEquals.callAsync( - byteArrayLongerThan32Bytes, - byteArrayShorterThan32Bytes, - ); + const isEqual = await libBytes + .publicEquals(byteArrayLongerThan32Bytes, byteArrayShorterThan32Bytes) + .callAsync(); return expect(isEqual).to.be.false(); }); it('should return false if byte arrays are not equal (same length, but a byte in first word differs)', async () => { - const isEqual = await libBytes.publicEquals.callAsync( - byteArrayLongerThan32BytesFirstBytesSwapped, - byteArrayLongerThan32Bytes, - ); + const isEqual = await libBytes + .publicEquals(byteArrayLongerThan32BytesFirstBytesSwapped, byteArrayLongerThan32Bytes) + .callAsync(); return expect(isEqual).to.be.false(); }); it('should return false if byte arrays are not equal (same length, but a byte in last word differs)', async () => { - const isEqual = await libBytes.publicEquals.callAsync( - byteArrayLongerThan32BytesLastBytesSwapped, - byteArrayLongerThan32Bytes, - ); + const isEqual = await libBytes + .publicEquals(byteArrayLongerThan32BytesLastBytesSwapped, byteArrayLongerThan32Bytes) + .callAsync(); return expect(isEqual).to.be.false(); }); describe('should ignore trailing data', () => { it('should return true when both < 32 bytes', async () => { - const isEqual = await libBytes.publicEqualsPop1.callAsync('0x0102', '0x0103'); + const isEqual = await libBytes.publicEqualsPop1('0x0102', '0x0103').callAsync(); return expect(isEqual).to.be.true(); }); }); @@ -132,7 +126,7 @@ blockchainTests('LibBytes', env => { it('should successfully read address when the address takes up the whole array', async () => { const byteArray = ethUtil.addHexPrefix(testAddress); const testAddressOffset = new BigNumber(0); - const address = await libBytes.publicReadAddress.callAsync(byteArray, testAddressOffset); + const address = await libBytes.publicReadAddress(byteArray, testAddressOffset).callAsync(); return expect(address).to.be.equal(testAddress); }); it('should successfully read address when it is offset in the array', async () => { @@ -141,7 +135,7 @@ blockchainTests('LibBytes', env => { const combinedByteArrayBuffer = Buffer.concat([prefixByteArrayBuffer, addressByteArrayBuffer]); const combinedByteArray = ethUtil.bufferToHex(combinedByteArrayBuffer); const testAddressOffset = new BigNumber(prefixByteArrayBuffer.byteLength); - const address = await libBytes.publicReadAddress.callAsync(combinedByteArray, testAddressOffset); + const address = await libBytes.publicReadAddress(combinedByteArray, testAddressOffset).callAsync(); return expect(address).to.be.equal(testAddress); }); it('should fail if the byte array is too short to hold an address', async () => { @@ -152,7 +146,7 @@ blockchainTests('LibBytes', env => { new BigNumber(3), new BigNumber(20), ); - return expect(libBytes.publicReadAddress.callAsync(shortByteArray, offset)).to.revertWith(expectedError); + return expect(libBytes.publicReadAddress(shortByteArray, offset).callAsync()).to.revertWith(expectedError); }); it('should fail if the length between the offset and end of the byte array is too short to hold an address', async () => { const byteArray = testAddress; @@ -162,7 +156,7 @@ blockchainTests('LibBytes', env => { new BigNumber(20), new BigNumber(40), ); - return expect(libBytes.publicReadAddress.callAsync(byteArray, badOffset)).to.revertWith(expectedError); + return expect(libBytes.publicReadAddress(byteArray, badOffset).callAsync()).to.revertWith(expectedError); }); }); @@ -170,11 +164,9 @@ blockchainTests('LibBytes', env => { it('should successfully write address when the address takes up the whole array', async () => { const byteArray = testAddress; const testAddressOffset = new BigNumber(0); - const newByteArray = await libBytes.publicWriteAddress.callAsync( - byteArray, - testAddressOffset, - testAddressB, - ); + const newByteArray = await libBytes + .publicWriteAddress(byteArray, testAddressOffset, testAddressB) + .callAsync(); return expect(newByteArray).to.be.equal(testAddressB); }); it('should successfully write address when it is offset in the array', async () => { @@ -183,11 +175,9 @@ blockchainTests('LibBytes', env => { const combinedByteArrayBuffer = Buffer.concat([prefixByteArrayBuffer, addressByteArrayBuffer]); const combinedByteArray = ethUtil.bufferToHex(combinedByteArrayBuffer); const testAddressOffset = new BigNumber(prefixByteArrayBuffer.byteLength); - const newByteArray = await libBytes.publicWriteAddress.callAsync( - combinedByteArray, - testAddressOffset, - testAddressB, - ); + const newByteArray = await libBytes + .publicWriteAddress(combinedByteArray, testAddressOffset, testAddressB) + .callAsync(); const newByteArrayBuffer = ethUtil.toBuffer(newByteArray); const addressFromOffsetBuffer = newByteArrayBuffer.slice(prefixByteArrayBuffer.byteLength); const addressFromOffset = ethUtil.addHexPrefix(ethUtil.bufferToHex(addressFromOffsetBuffer)); @@ -202,7 +192,7 @@ blockchainTests('LibBytes', env => { new BigNumber(20), ); return expect( - libBytes.publicWriteAddress.callAsync(byteArrayShorterThan20Bytes, offset, testAddress), + libBytes.publicWriteAddress(byteArrayShorterThan20Bytes, offset, testAddress).callAsync(), ).to.revertWith(expectedError); }); it('should fail if the length between the offset and end of the byte array is too short to hold an address', async () => { @@ -213,7 +203,7 @@ blockchainTests('LibBytes', env => { badOffset, badOffset.plus(new BigNumber(20)), ); - return expect(libBytes.publicWriteAddress.callAsync(byteArray, badOffset, testAddress)).to.revertWith( + return expect(libBytes.publicWriteAddress(byteArray, badOffset, testAddress).callAsync()).to.revertWith( expectedError, ); }); @@ -222,7 +212,7 @@ blockchainTests('LibBytes', env => { describe('readBytes32', () => { it('should successfully read bytes32 when the bytes32 takes up the whole array', async () => { const testBytes32Offset = new BigNumber(0); - const bytes32 = await libBytes.publicReadBytes32.callAsync(testBytes32, testBytes32Offset); + const bytes32 = await libBytes.publicReadBytes32(testBytes32, testBytes32Offset).callAsync(); return expect(bytes32).to.be.equal(testBytes32); }); it('should successfully read bytes32 when it is offset in the array', async () => { @@ -231,7 +221,7 @@ blockchainTests('LibBytes', env => { const combinedByteArrayBuffer = Buffer.concat([prefixByteArrayBuffer, bytes32ByteArrayBuffer]); const combinedByteArray = ethUtil.bufferToHex(combinedByteArrayBuffer); const testBytes32Offset = new BigNumber(prefixByteArrayBuffer.byteLength); - const bytes32 = await libBytes.publicReadBytes32.callAsync(combinedByteArray, testBytes32Offset); + const bytes32 = await libBytes.publicReadBytes32(combinedByteArray, testBytes32Offset).callAsync(); return expect(bytes32).to.be.equal(testBytes32); }); it('should fail if the byte array is too short to hold a bytes32', async () => { @@ -242,7 +232,7 @@ blockchainTests('LibBytes', env => { byteLen, new BigNumber(32), ); - return expect(libBytes.publicReadBytes32.callAsync(byteArrayShorterThan32Bytes, offset)).to.revertWith( + return expect(libBytes.publicReadBytes32(byteArrayShorterThan32Bytes, offset).callAsync()).to.revertWith( expectedError, ); }); @@ -253,7 +243,7 @@ blockchainTests('LibBytes', env => { badOffset, badOffset.plus(new BigNumber(32)), ); - return expect(libBytes.publicReadBytes32.callAsync(testBytes32, badOffset)).to.revertWith(expectedError); + return expect(libBytes.publicReadBytes32(testBytes32, badOffset).callAsync()).to.revertWith(expectedError); }); }); @@ -261,11 +251,9 @@ blockchainTests('LibBytes', env => { it('should successfully write bytes32 when the address takes up the whole array', async () => { const byteArray = testBytes32; const testBytes32Offset = new BigNumber(0); - const newByteArray = await libBytes.publicWriteBytes32.callAsync( - byteArray, - testBytes32Offset, - testBytes32B, - ); + const newByteArray = await libBytes + .publicWriteBytes32(byteArray, testBytes32Offset, testBytes32B) + .callAsync(); return expect(newByteArray).to.be.equal(testBytes32B); }); it('should successfully write bytes32 when it is offset in the array', async () => { @@ -274,11 +262,9 @@ blockchainTests('LibBytes', env => { const combinedByteArrayBuffer = Buffer.concat([prefixByteArrayBuffer, bytes32ByteArrayBuffer]); const combinedByteArray = ethUtil.bufferToHex(combinedByteArrayBuffer); const testBytes32Offset = new BigNumber(prefixByteArrayBuffer.byteLength); - const newByteArray = await libBytes.publicWriteBytes32.callAsync( - combinedByteArray, - testBytes32Offset, - testBytes32B, - ); + const newByteArray = await libBytes + .publicWriteBytes32(combinedByteArray, testBytes32Offset, testBytes32B) + .callAsync(); const newByteArrayBuffer = ethUtil.toBuffer(newByteArray); const bytes32FromOffsetBuffer = newByteArrayBuffer.slice(prefixByteArrayBuffer.byteLength); const bytes32FromOffset = ethUtil.addHexPrefix(ethUtil.bufferToHex(bytes32FromOffsetBuffer)); @@ -293,7 +279,7 @@ blockchainTests('LibBytes', env => { new BigNumber(32), ); return expect( - libBytes.publicWriteBytes32.callAsync(byteArrayShorterThan32Bytes, offset, testBytes32), + libBytes.publicWriteBytes32(byteArrayShorterThan32Bytes, offset, testBytes32).callAsync(), ).to.revertWith(expectedError); }); it('should fail if the length between the offset and end of the byte array is too short to hold a bytes32', async () => { @@ -304,7 +290,7 @@ blockchainTests('LibBytes', env => { badOffset, badOffset.plus(new BigNumber(32)), ); - return expect(libBytes.publicWriteBytes32.callAsync(byteArray, badOffset, testBytes32)).to.revertWith( + return expect(libBytes.publicWriteBytes32(byteArray, badOffset, testBytes32).callAsync()).to.revertWith( expectedError, ); }); @@ -316,7 +302,7 @@ blockchainTests('LibBytes', env => { const testUint256AsBuffer = ethUtil.toBuffer(formattedTestUint256); const byteArray = ethUtil.bufferToHex(testUint256AsBuffer); const testUint256Offset = new BigNumber(0); - const uint256 = await libBytes.publicReadUint256.callAsync(byteArray, testUint256Offset); + const uint256 = await libBytes.publicReadUint256(byteArray, testUint256Offset).callAsync(); return expect(uint256).to.bignumber.equal(testUint256); }); it('should successfully read uint256 when it is offset in the array', async () => { @@ -326,7 +312,7 @@ blockchainTests('LibBytes', env => { const combinedByteArrayBuffer = Buffer.concat([prefixByteArrayBuffer, testUint256AsBuffer]); const combinedByteArray = ethUtil.bufferToHex(combinedByteArrayBuffer); const testUint256Offset = new BigNumber(prefixByteArrayBuffer.byteLength); - const uint256 = await libBytes.publicReadUint256.callAsync(combinedByteArray, testUint256Offset); + const uint256 = await libBytes.publicReadUint256(combinedByteArray, testUint256Offset).callAsync(); return expect(uint256).to.bignumber.equal(testUint256); }); it('should fail if the byte array is too short to hold a uint256', async () => { @@ -337,7 +323,7 @@ blockchainTests('LibBytes', env => { byteLen, new BigNumber(32), ); - return expect(libBytes.publicReadUint256.callAsync(byteArrayShorterThan32Bytes, offset)).to.revertWith( + return expect(libBytes.publicReadUint256(byteArrayShorterThan32Bytes, offset).callAsync()).to.revertWith( expectedError, ); }); @@ -351,7 +337,7 @@ blockchainTests('LibBytes', env => { badOffset, badOffset.plus(new BigNumber(32)), ); - return expect(libBytes.publicReadUint256.callAsync(byteArray, badOffset)).to.revertWith(expectedError); + return expect(libBytes.publicReadUint256(byteArray, badOffset).callAsync()).to.revertWith(expectedError); }); }); @@ -359,11 +345,9 @@ blockchainTests('LibBytes', env => { it('should successfully write uint256 when the address takes up the whole array', async () => { const byteArray = testBytes32; const testUint256Offset = new BigNumber(0); - const newByteArray = await libBytes.publicWriteUint256.callAsync( - byteArray, - testUint256Offset, - testUint256B, - ); + const newByteArray = await libBytes + .publicWriteUint256(byteArray, testUint256Offset, testUint256B) + .callAsync(); const newByteArrayAsUint256 = new BigNumber(newByteArray, 16); return expect(newByteArrayAsUint256).to.be.bignumber.equal(testUint256B); }); @@ -373,11 +357,9 @@ blockchainTests('LibBytes', env => { const combinedByteArrayBuffer = Buffer.concat([prefixByteArrayBuffer, bytes32ByteArrayBuffer]); const combinedByteArray = ethUtil.bufferToHex(combinedByteArrayBuffer); const testUint256Offset = new BigNumber(prefixByteArrayBuffer.byteLength); - const newByteArray = await libBytes.publicWriteUint256.callAsync( - combinedByteArray, - testUint256Offset, - testUint256B, - ); + const newByteArray = await libBytes + .publicWriteUint256(combinedByteArray, testUint256Offset, testUint256B) + .callAsync(); const newByteArrayBuffer = ethUtil.toBuffer(newByteArray); const uint256FromOffsetBuffer = newByteArrayBuffer.slice(prefixByteArrayBuffer.byteLength); const uint256FromOffset = new BigNumber( @@ -395,7 +377,7 @@ blockchainTests('LibBytes', env => { new BigNumber(32), ); return expect( - libBytes.publicWriteUint256.callAsync(byteArrayShorterThan32Bytes, offset, testUint256), + libBytes.publicWriteUint256(byteArrayShorterThan32Bytes, offset, testUint256).callAsync(), ).to.revertWith(expectedError); }); it('should fail if the length between the offset and end of the byte array is too short to hold a uint256', async () => { @@ -406,7 +388,7 @@ blockchainTests('LibBytes', env => { badOffset, badOffset.plus(new BigNumber(32)), ); - return expect(libBytes.publicWriteUint256.callAsync(byteArray, badOffset, testUint256)).to.revertWith( + return expect(libBytes.publicWriteUint256(byteArray, badOffset, testUint256).callAsync()).to.revertWith( expectedError, ); }); @@ -423,18 +405,20 @@ blockchainTests('LibBytes', env => { new BigNumber(byteLen), // length of byteArrayLessThan4Bytes new BigNumber(4), ); - return expect(libBytes.publicReadBytes4.callAsync(byteArrayLessThan4Bytes, offset)).to.revertWith( + return expect(libBytes.publicReadBytes4(byteArrayLessThan4Bytes, offset).callAsync()).to.revertWith( expectedError, ); }); it('should return the first 4 bytes of a byte array of arbitrary length', async () => { - const first4Bytes = await libBytes.publicReadBytes4.callAsync(byteArrayLongerThan32Bytes, new BigNumber(0)); + const first4Bytes = await libBytes + .publicReadBytes4(byteArrayLongerThan32Bytes, new BigNumber(0)) + .callAsync(); const expectedFirst4Bytes = byteArrayLongerThan32Bytes.slice(0, 10); expect(first4Bytes).to.equal(expectedFirst4Bytes); }); it('should successfully read bytes4 when the bytes4 takes up the whole array', async () => { const testBytes4Offset = new BigNumber(0); - const bytes4 = await libBytes.publicReadBytes4.callAsync(testBytes4, testBytes4Offset); + const bytes4 = await libBytes.publicReadBytes4(testBytes4, testBytes4Offset).callAsync(); return expect(bytes4).to.be.equal(testBytes4); }); it('should successfully read bytes4 when it is offset in the array', async () => { @@ -443,7 +427,7 @@ blockchainTests('LibBytes', env => { const combinedByteArrayBuffer = Buffer.concat([prefixByteArrayBuffer, bytes4ByteArrayBuffer]); const combinedByteArray = ethUtil.bufferToHex(combinedByteArrayBuffer); const testBytes4Offset = new BigNumber(prefixByteArrayBuffer.byteLength); - const bytes4 = await libBytes.publicReadBytes4.callAsync(combinedByteArray, testBytes4Offset); + const bytes4 = await libBytes.publicReadBytes4(combinedByteArray, testBytes4Offset).callAsync(); return expect(bytes4).to.be.equal(testBytes4); }); it('should fail if the length between the offset and end of the byte array is too short to hold a bytes4', async () => { @@ -454,7 +438,7 @@ blockchainTests('LibBytes', env => { byteLen, badOffset.plus(new BigNumber(4)), ); - return expect(libBytes.publicReadBytes4.callAsync(testBytes4, badOffset)).to.revertWith(expectedError); + return expect(libBytes.publicReadBytes4(testBytes4, badOffset).callAsync()).to.revertWith(expectedError); }); }); @@ -476,12 +460,9 @@ blockchainTests('LibBytes', env => { tests.forEach(([dest, source, length, job]) => it(job, async () => { const expected = refMemcpy(memory, dest, source, length); - const resultStr = await libBytes.testMemcpy.callAsync( - memHex, - new BigNumber(dest), - new BigNumber(source), - new BigNumber(length), - ); + const resultStr = await libBytes + .testMemcpy(memHex, new BigNumber(dest), new BigNumber(source), new BigNumber(length)) + .callAsync(); const result = fromHex(resultStr); expect(result).to.deep.equal(expected); }), @@ -633,14 +614,14 @@ blockchainTests('LibBytes', env => { from, to, ); - return expect(libBytes.publicSlice.callAsync(byteArrayLongerThan32Bytes, from, to)).to.revertWith( + return expect(libBytes.publicSlice(byteArrayLongerThan32Bytes, from, to).callAsync()).to.revertWith( expectedError, ); }); it('should return a byte array of length 0 if from == to', async () => { const from = new BigNumber(0); const to = from; - const [result, original] = await libBytes.publicSlice.callAsync(byteArrayLongerThan32Bytes, from, to); + const [result, original] = await libBytes.publicSlice(byteArrayLongerThan32Bytes, from, to).callAsync(); expect(original).to.eq(byteArrayLongerThan32Bytes); expect(result).to.eq(constants.NULL_BYTES); }); @@ -648,7 +629,7 @@ blockchainTests('LibBytes', env => { const byteLen = fromHex(byteArrayLongerThan32Bytes).length; const from = new BigNumber(byteLen); const to = from; - const [result, original] = await libBytes.publicSlice.callAsync(byteArrayLongerThan32Bytes, from, to); + const [result, original] = await libBytes.publicSlice(byteArrayLongerThan32Bytes, from, to).callAsync(); expect(original).to.eq(byteArrayLongerThan32Bytes); expect(result).to.eq(constants.NULL_BYTES); }); @@ -661,14 +642,14 @@ blockchainTests('LibBytes', env => { to, new BigNumber(byteLen), ); - return expect(libBytes.publicSlice.callAsync(byteArrayLongerThan32Bytes, from, to)).to.revertWith( + return expect(libBytes.publicSlice(byteArrayLongerThan32Bytes, from, to).callAsync()).to.revertWith( expectedError, ); }); it('should slice a section of the input', async () => { const from = new BigNumber(1); const to = new BigNumber(2); - const [result, original] = await libBytes.publicSlice.callAsync(byteArrayLongerThan32Bytes, from, to); + const [result, original] = await libBytes.publicSlice(byteArrayLongerThan32Bytes, from, to).callAsync(); const expectedResult = `0x${byteArrayLongerThan32Bytes.slice(4, 6)}`; expect(original).to.eq(byteArrayLongerThan32Bytes); expect(result).to.eq(expectedResult); @@ -677,7 +658,7 @@ blockchainTests('LibBytes', env => { const byteLen = fromHex(byteArrayLongerThan32Bytes).length; const from = new BigNumber(0); const to = new BigNumber(byteLen); - const [result, original] = await libBytes.publicSlice.callAsync(byteArrayLongerThan32Bytes, from, to); + const [result, original] = await libBytes.publicSlice(byteArrayLongerThan32Bytes, from, to).callAsync(); expect(original).to.eq(byteArrayLongerThan32Bytes); expect(result).to.eq(byteArrayLongerThan32Bytes); }); @@ -692,21 +673,21 @@ blockchainTests('LibBytes', env => { from, to, ); - return expect(libBytes.publicSlice.callAsync(byteArrayLongerThan32Bytes, from, to)).to.revertWith( + return expect(libBytes.publicSlice(byteArrayLongerThan32Bytes, from, to).callAsync()).to.revertWith( expectedError, ); }); it('should return a byte array of length 0 if from == to', async () => { const from = new BigNumber(0); const to = from; - const [result] = await libBytes.publicSliceDestructive.callAsync(byteArrayLongerThan32Bytes, from, to); + const [result] = await libBytes.publicSliceDestructive(byteArrayLongerThan32Bytes, from, to).callAsync(); expect(result).to.eq(constants.NULL_BYTES); }); it('should return a byte array of length 0 if from == to == b.length', async () => { const byteLen = fromHex(byteArrayLongerThan32Bytes).length; const from = new BigNumber(byteLen); const to = from; - const [result] = await libBytes.publicSliceDestructive.callAsync(byteArrayLongerThan32Bytes, from, to); + const [result] = await libBytes.publicSliceDestructive(byteArrayLongerThan32Bytes, from, to).callAsync(); expect(result).to.eq(constants.NULL_BYTES); }); it('should revert if to > input.length', async () => { @@ -719,13 +700,13 @@ blockchainTests('LibBytes', env => { new BigNumber(byteLen), ); return expect( - libBytes.publicSliceDestructive.callAsync(byteArrayLongerThan32Bytes, from, to), + libBytes.publicSliceDestructive(byteArrayLongerThan32Bytes, from, to).callAsync(), ).to.revertWith(expectedError); }); it('should slice a section of the input', async () => { const from = new BigNumber(1); const to = new BigNumber(2); - const [result] = await libBytes.publicSliceDestructive.callAsync(byteArrayLongerThan32Bytes, from, to); + const [result] = await libBytes.publicSliceDestructive(byteArrayLongerThan32Bytes, from, to).callAsync(); const expectedResult = `0x${byteArrayLongerThan32Bytes.slice(4, 6)}`; expect(result).to.eq(expectedResult); }); @@ -733,37 +714,31 @@ blockchainTests('LibBytes', env => { const byteLen = fromHex(byteArrayLongerThan32Bytes).length; const from = new BigNumber(0); const to = new BigNumber(byteLen); - const [result] = await libBytes.publicSliceDestructive.callAsync(byteArrayLongerThan32Bytes, from, to); + const [result] = await libBytes.publicSliceDestructive(byteArrayLongerThan32Bytes, from, to).callAsync(); expect(result).to.eq(byteArrayLongerThan32Bytes); }); }); describe('writeLength', () => { it('should return a null byte array if length is set to 0', async () => { - const result = await libBytes.publicWriteLength.callAsync( - byteArrayLongerThan32Bytes, - constants.ZERO_AMOUNT, - constants.NULL_BYTES, - ); + const result = await libBytes + .publicWriteLength(byteArrayLongerThan32Bytes, constants.ZERO_AMOUNT, constants.NULL_BYTES) + .callAsync(); expect(result).to.eq(constants.NULL_BYTES); }); it('should return the same byte array if length is unchanged', async () => { const byteLen = fromHex(byteArrayLongerThan32Bytes).length; - const result = await libBytes.publicWriteLength.callAsync( - byteArrayLongerThan32Bytes, - new BigNumber(byteLen), - constants.NULL_BYTES, - ); + const result = await libBytes + .publicWriteLength(byteArrayLongerThan32Bytes, new BigNumber(byteLen), constants.NULL_BYTES) + .callAsync(); expect(result).to.eq(byteArrayLongerThan32Bytes); }); it('should shave off lower order bytes if new length is less than original', async () => { const byteLen = fromHex(byteArrayLongerThan32Bytes).length; const newLen = new BigNumber(byteLen).dividedToIntegerBy(2); - const result = await libBytes.publicWriteLength.callAsync( - byteArrayLongerThan32Bytes, - newLen, - constants.NULL_BYTES, - ); + const result = await libBytes + .publicWriteLength(byteArrayLongerThan32Bytes, newLen, constants.NULL_BYTES) + .callAsync(); expect(result).to.eq( byteArrayLongerThan32Bytes.slice( 0, @@ -777,35 +752,31 @@ blockchainTests('LibBytes', env => { it("should right pad with 0's if new length is greater than original and no extra bytes are appended", async () => { const byteLen = fromHex(byteArrayLongerThan32Bytes).length; const newLen = new BigNumber(byteLen).multipliedBy(2); - const result = await libBytes.publicWriteLength.callAsync( - byteArrayLongerThan32Bytes, - newLen, - constants.NULL_BYTES, - ); + const result = await libBytes + .publicWriteLength(byteArrayLongerThan32Bytes, newLen, constants.NULL_BYTES) + .callAsync(); expect(result).to.eq(`${byteArrayLongerThan32Bytes}${'0'.repeat(byteArrayLongerThan32Bytes.length - 2)}`); }); it('should right pad with extra bytes if specified', async () => { const byteLen = fromHex(byteArrayLongerThan32Bytes).length; const newLen = new BigNumber(byteLen).multipliedBy(2); - const result = await libBytes.publicWriteLength.callAsync( - byteArrayLongerThan32Bytes, - newLen, - byteArrayLongerThan32Bytes, - ); + const result = await libBytes + .publicWriteLength(byteArrayLongerThan32Bytes, newLen, byteArrayLongerThan32Bytes) + .callAsync(); expect(result).to.eq(`${byteArrayLongerThan32Bytes}${byteArrayLongerThan32Bytes.slice(2)}`); }); it('should result in the same byte array if length is reduced and reset', async () => { const byteLen = fromHex(byteArrayLongerThan32Bytes).length; const tempByteLen = new BigNumber(byteLen).dividedToIntegerBy(2); return expect( - libBytes.assertBytesUnchangedAfterLengthReset.callAsync(byteArrayLongerThan32Bytes, tempByteLen), + libBytes.assertBytesUnchangedAfterLengthReset(byteArrayLongerThan32Bytes, tempByteLen).callAsync(), ).to.be.fulfilled(''); }); it('should result in the same byte array if length is increased and reset', async () => { const byteLen = fromHex(byteArrayLongerThan32Bytes).length; const tempByteLen = new BigNumber(byteLen).multipliedBy(2); return expect( - libBytes.assertBytesUnchangedAfterLengthReset.callAsync(byteArrayLongerThan32Bytes, tempByteLen), + libBytes.assertBytesUnchangedAfterLengthReset(byteArrayLongerThan32Bytes, tempByteLen).callAsync(), ).to.be.fulfilled(''); }); }); diff --git a/contracts/utils/test/lib_eip712.ts b/contracts/utils/test/lib_eip712.ts index 34c46eedbb..41fcd134e5 100644 --- a/contracts/utils/test/lib_eip712.ts +++ b/contracts/utils/test/lib_eip712.ts @@ -44,12 +44,9 @@ describe('LibEIP712', () => { chainId, verifyingContract, }); - const actualHash = await lib.externalHashEIP712DomainSeperator.callAsync( - name, - version, - new BigNumber(chainId), - verifyingContract, - ); + const actualHash = await lib + .externalHashEIP712DomainSeperator(name, version, new BigNumber(chainId), verifyingContract) + .callAsync(); expect(actualHash).to.be.eq(hexConcat(expectedHash)); } @@ -83,7 +80,7 @@ describe('LibEIP712', () => { const expectedHash = '0x'.concat(ethUtil.sha3(input).toString('hex')); // Get the actual hash by calling the smart contract - const actualHash = await lib.externalHashEIP712Message.callAsync(domainHash, hashStruct); + const actualHash = await lib.externalHashEIP712Message(domainHash, hashStruct).callAsync(); // Verify that the actual hash matches the expected hash expect(actualHash).to.be.eq(expectedHash); diff --git a/contracts/utils/test/lib_rich_errors.ts b/contracts/utils/test/lib_rich_errors.ts index 3e796ca119..3342c08d8a 100644 --- a/contracts/utils/test/lib_rich_errors.ts +++ b/contracts/utils/test/lib_rich_errors.ts @@ -20,7 +20,7 @@ blockchainTests('LibRichErrors', env => { it('should correctly revert the extra bytes', async () => { const extraBytes = hexRandom(100); try { - await lib.externalRRevert.callAsync(extraBytes); + await lib.externalRRevert(extraBytes).callAsync(); } catch (err) { const revertError = coerceThrownErrorAsRevertError(err); return expect(revertError.encode()).to.eq(extraBytes); @@ -32,7 +32,7 @@ blockchainTests('LibRichErrors', env => { it('should correctly revert a StringRevertError', async () => { const error = new StringRevertError('foo'); - return expect(lib.externalRRevert.callAsync(error.encode())).to.revertWith(error); + return expect(lib.externalRRevert(error.encode()).callAsync()).to.revertWith(error); }); }); }); diff --git a/contracts/utils/test/lib_safe_math.ts b/contracts/utils/test/lib_safe_math.ts index 39e1ae5d1a..ab68ea67e8 100644 --- a/contracts/utils/test/lib_safe_math.ts +++ b/contracts/utils/test/lib_safe_math.ts @@ -28,17 +28,17 @@ blockchainTests('SafeMath', env => { const a = ONE_ETHER; const b = ONE_ETHER.times(2); const expected = ReferenceFunctions.safeMul(a, b); - const actual = await safeMath.externalSafeMul.callAsync(a, b); + const actual = await safeMath.externalSafeMul(a, b).callAsync(); expect(actual).bignumber.to.be.eq(expected); }); it('should return zero if first argument is zero', async () => { - const result = await safeMath.externalSafeMul.callAsync(constants.ZERO_AMOUNT, toBigNumber(1)); + const result = await safeMath.externalSafeMul(constants.ZERO_AMOUNT, toBigNumber(1)).callAsync(); expect(result).bignumber.to.be.eq(constants.ZERO_AMOUNT); }); it('should return zero if second argument is zero', async () => { - const result = await safeMath.externalSafeMul.callAsync(toBigNumber(1), constants.ZERO_AMOUNT); + const result = await safeMath.externalSafeMul(toBigNumber(1), constants.ZERO_AMOUNT).callAsync(); expect(result).bignumber.to.be.eq(constants.ZERO_AMOUNT); }); @@ -50,11 +50,11 @@ blockchainTests('SafeMath', env => { a, b, ); - return expect(safeMath.externalSafeMul.callAsync(a, b)).to.revertWith(expectedError); + return expect(safeMath.externalSafeMul(a, b).callAsync()).to.revertWith(expectedError); }); it("should calculate correct value for values that don't overflow", async () => { - const result = await safeMath.externalSafeMul.callAsync(toBigNumber(15), toBigNumber(13)); + const result = await safeMath.externalSafeMul(toBigNumber(15), toBigNumber(13)).callAsync(); expect(result).bignumber.to.be.eq(toBigNumber(195)); }); }); @@ -64,27 +64,27 @@ blockchainTests('SafeMath', env => { const a = ONE_ETHER; const b = ONE_ETHER.times(2); const expected = ReferenceFunctions.safeDiv(a, b); - const actual = await safeMath.externalSafeDiv.callAsync(a, b); + const actual = await safeMath.externalSafeDiv(a, b).callAsync(); expect(actual).bignumber.to.be.eq(expected); }); it('should return the correct value if both values are the same', async () => { - const result = await safeMath.externalSafeDiv.callAsync(toBigNumber(1), toBigNumber(1)); + const result = await safeMath.externalSafeDiv(toBigNumber(1), toBigNumber(1)).callAsync(); expect(result).bignumber.to.be.eq(toBigNumber(1)); }); it('should return the correct value if the values are different', async () => { - const result = await safeMath.externalSafeDiv.callAsync(toBigNumber(3), toBigNumber(2)); + const result = await safeMath.externalSafeDiv(toBigNumber(3), toBigNumber(2)).callAsync(); expect(result).bignumber.to.be.eq(toBigNumber(1)); }); it('should return zero if the numerator is smaller than the denominator', async () => { - const result = await safeMath.externalSafeDiv.callAsync(toBigNumber(2), toBigNumber(3)); + const result = await safeMath.externalSafeDiv(toBigNumber(2), toBigNumber(3)).callAsync(); expect(result).bignumber.to.be.eq(constants.ZERO_AMOUNT); }); it('should return zero if first argument is zero', async () => { - const result = await safeMath.externalSafeDiv.callAsync(constants.ZERO_AMOUNT, toBigNumber(1)); + const result = await safeMath.externalSafeDiv(constants.ZERO_AMOUNT, toBigNumber(1)).callAsync(); expect(result).bignumber.to.be.eq(constants.ZERO_AMOUNT); }); @@ -96,7 +96,7 @@ blockchainTests('SafeMath', env => { a, b, ); - return expect(safeMath.externalSafeDiv.callAsync(a, b)).to.revertWith(expectedError); + return expect(safeMath.externalSafeDiv(a, b).callAsync()).to.revertWith(expectedError); }); }); @@ -105,7 +105,7 @@ blockchainTests('SafeMath', env => { const a = ONE_ETHER; const b = ONE_ETHER.dividedToIntegerBy(2); const expected = ReferenceFunctions.safeSub(a, b); - const actual = await safeMath.externalSafeSub.callAsync(a, b); + const actual = await safeMath.externalSafeSub(a, b).callAsync(); expect(actual).bignumber.to.be.eq(expected); }); @@ -117,16 +117,16 @@ blockchainTests('SafeMath', env => { a, b, ); - return expect(safeMath.externalSafeSub.callAsync(a, b)).to.revertWith(expectedError); + return expect(safeMath.externalSafeSub(a, b).callAsync()).to.revertWith(expectedError); }); it('should calculate correct value for values that are equal', async () => { - const result = await safeMath.externalSafeMul.callAsync(constants.ZERO_AMOUNT, constants.ZERO_AMOUNT); + const result = await safeMath.externalSafeMul(constants.ZERO_AMOUNT, constants.ZERO_AMOUNT).callAsync(); expect(result).bignumber.to.be.eq(constants.ZERO_AMOUNT); }); it('should calculate correct value for values that are not equal', async () => { - const result = await safeMath.externalSafeSub.callAsync(toBigNumber(15), toBigNumber(13)); + const result = await safeMath.externalSafeSub(toBigNumber(15), toBigNumber(13)).callAsync(); expect(result).bignumber.to.be.eq(toBigNumber(2)); }); }); @@ -136,7 +136,7 @@ blockchainTests('SafeMath', env => { const a = ONE_ETHER; const b = ONE_ETHER.dividedToIntegerBy(2); const expected = ReferenceFunctions.safeAdd(a, b); - const actual = await safeMath.externalSafeAdd.callAsync(a, b); + const actual = await safeMath.externalSafeAdd(a, b).callAsync(); expect(actual).bignumber.to.be.eq(expected); }); @@ -148,55 +148,55 @@ blockchainTests('SafeMath', env => { a, b, ); - return expect(safeMath.externalSafeAdd.callAsync(a, b)).to.revertWith(expectedError); + return expect(safeMath.externalSafeAdd(a, b).callAsync()).to.revertWith(expectedError); }); it('should calculate correct value if addition does not overflow', async () => { - const result = await safeMath.externalSafeAdd.callAsync(toBigNumber(15), toBigNumber(13)); + const result = await safeMath.externalSafeAdd(toBigNumber(15), toBigNumber(13)).callAsync(); expect(result).bignumber.to.be.eq(toBigNumber(28)); }); it('should calculate correct value if first argument is zero', async () => { - const result = await safeMath.externalSafeAdd.callAsync(constants.ZERO_AMOUNT, toBigNumber(13)); + const result = await safeMath.externalSafeAdd(constants.ZERO_AMOUNT, toBigNumber(13)).callAsync(); expect(result).bignumber.to.be.eq(toBigNumber(13)); }); it('should calculate correct value if second argument is zero', async () => { - const result = await safeMath.externalSafeAdd.callAsync(toBigNumber(13), constants.ZERO_AMOUNT); + const result = await safeMath.externalSafeAdd(toBigNumber(13), constants.ZERO_AMOUNT).callAsync(); expect(result).bignumber.to.be.eq(toBigNumber(13)); }); }); describe('maxUint256', () => { it('should return first argument if it is greater than the second', async () => { - const result = await safeMath.externalMaxUint256.callAsync(toBigNumber(13), constants.ZERO_AMOUNT); + const result = await safeMath.externalMaxUint256(toBigNumber(13), constants.ZERO_AMOUNT).callAsync(); expect(result).bignumber.to.be.eq(toBigNumber(13)); }); it('should return first argument if it is equal the second', async () => { - const result = await safeMath.externalMaxUint256.callAsync(constants.ZERO_AMOUNT, constants.ZERO_AMOUNT); + const result = await safeMath.externalMaxUint256(constants.ZERO_AMOUNT, constants.ZERO_AMOUNT).callAsync(); expect(result).bignumber.to.be.eq(constants.ZERO_AMOUNT); }); it('should return second argument if it is greater than the first', async () => { - const result = await safeMath.externalMaxUint256.callAsync(constants.ZERO_AMOUNT, toBigNumber(13)); + const result = await safeMath.externalMaxUint256(constants.ZERO_AMOUNT, toBigNumber(13)).callAsync(); expect(result).bignumber.to.be.eq(toBigNumber(13)); }); }); describe('minUint256', () => { it('should return first argument if it is less than the second', async () => { - const result = await safeMath.externalMaxUint256.callAsync(constants.ZERO_AMOUNT, toBigNumber(13)); + const result = await safeMath.externalMaxUint256(constants.ZERO_AMOUNT, toBigNumber(13)).callAsync(); expect(result).bignumber.to.be.eq(toBigNumber(13)); }); it('should return first argument if it is equal the second', async () => { - const result = await safeMath.externalMaxUint256.callAsync(constants.ZERO_AMOUNT, constants.ZERO_AMOUNT); + const result = await safeMath.externalMaxUint256(constants.ZERO_AMOUNT, constants.ZERO_AMOUNT).callAsync(); expect(result).bignumber.to.be.eq(constants.ZERO_AMOUNT); }); it('should return second argument if it is less than the first', async () => { - const result = await safeMath.externalMaxUint256.callAsync(toBigNumber(13), constants.ZERO_AMOUNT); + const result = await safeMath.externalMaxUint256(toBigNumber(13), constants.ZERO_AMOUNT).callAsync(); expect(result).bignumber.to.be.eq(toBigNumber(13)); }); }); diff --git a/contracts/utils/test/log_decoding.ts b/contracts/utils/test/log_decoding.ts index 13d9d14971..507a0c5459 100644 --- a/contracts/utils/test/log_decoding.ts +++ b/contracts/utils/test/log_decoding.ts @@ -48,19 +48,25 @@ describe('TestLogDecoding', () => { describe('Decoding Log Arguments', () => { it('should decode locally emitted event args when no dependencies are passed into wrapper', async () => { - const txReceipt = await testLogDecodingDeployedWithoutDependencies.emitEvent.awaitTransactionSuccessAsync(); + const txReceipt = await testLogDecodingDeployedWithoutDependencies + .emitEvent() + .awaitTransactionSuccessAsync(); expect(txReceipt.logs.length).to.be.equal(1); // tslint:disable no-unnecessary-type-assertion expect((txReceipt.logs[0] as LogWithDecodedArgs).args).to.be.deep.equal(expectedEvent); }); it('should not decode event args when no dependencies are passed into wrapper', async () => { - const txReceipt = await testLogDecodingDeployedWithoutDependencies.emitEventDownstream.awaitTransactionSuccessAsync(); + const txReceipt = await testLogDecodingDeployedWithoutDependencies + .emitEventDownstream() + .awaitTransactionSuccessAsync(); expect(txReceipt.logs.length).to.be.equal(1); // tslint:disable no-unnecessary-type-assertion expect((txReceipt.logs[0] as LogWithDecodedArgs).args).to.be.undefined(); }); it('should decode args for local but not downstream event when no dependencies are passed into wrapper', async () => { - const txReceipt = await testLogDecodingDeployedWithoutDependencies.emitEventsLocalAndDownstream.awaitTransactionSuccessAsync(); + const txReceipt = await testLogDecodingDeployedWithoutDependencies + .emitEventsLocalAndDownstream() + .awaitTransactionSuccessAsync(); expect(txReceipt.logs.length).to.be.equal(2); // tslint:disable no-unnecessary-type-assertion expect((txReceipt.logs[0] as LogWithDecodedArgs).args).to.be.deep.equal(expectedEvent); @@ -68,13 +74,15 @@ describe('TestLogDecoding', () => { expect((txReceipt.logs[1] as LogWithDecodedArgs).args).to.be.undefined(); }); it('should decode locally emitted event args when dependencies are passed into wrapper', async () => { - const txReceipt = await testLogDecodingWithDependencies.emitEvent.awaitTransactionSuccessAsync(); + const txReceipt = await testLogDecodingWithDependencies.emitEvent().awaitTransactionSuccessAsync(); expect(txReceipt.logs.length).to.be.equal(1); // tslint:disable no-unnecessary-type-assertion expect((txReceipt.logs[0] as LogWithDecodedArgs).args).to.be.deep.equal(expectedEvent); }); it('should decode downstream event args when dependencies are passed into wrapper', async () => { - const txReceipt = await testLogDecodingWithDependencies.emitEventDownstream.awaitTransactionSuccessAsync(); + const txReceipt = await testLogDecodingWithDependencies + .emitEventDownstream() + .awaitTransactionSuccessAsync(); expect(txReceipt.logs.length).to.be.equal(1); // tslint:disable no-unnecessary-type-assertion expect((txReceipt.logs[0] as LogWithDecodedArgs).args).to.be.deep.equal( @@ -82,7 +90,9 @@ describe('TestLogDecoding', () => { ); }); it('should decode args for both local and downstream events when dependencies are passed into wrapper', async () => { - const txReceipt = await testLogDecodingWithDependencies.emitEventsLocalAndDownstream.awaitTransactionSuccessAsync(); + const txReceipt = await testLogDecodingWithDependencies + .emitEventsLocalAndDownstream() + .awaitTransactionSuccessAsync(); expect(txReceipt.logs.length).to.be.equal(2); // tslint:disable no-unnecessary-type-assertion expect((txReceipt.logs[0] as LogWithDecodedArgs).args).to.be.deep.equal(expectedEvent); diff --git a/contracts/utils/test/ownable.ts b/contracts/utils/test/ownable.ts index d4859f730f..e21a7ae82b 100644 --- a/contracts/utils/test/ownable.ts +++ b/contracts/utils/test/ownable.ts @@ -23,11 +23,11 @@ blockchainTests.resets('Ownable', env => { describe('onlyOwner', () => { it('should revert if sender is not the owner', async () => { const expectedError = new OwnableRevertErrors.OnlyOwnerError(nonOwner, owner); - return expect(ownable.externalOnlyOwner.callAsync({ from: nonOwner })).to.revertWith(expectedError); + return expect(ownable.externalOnlyOwner().callAsync({ from: nonOwner })).to.revertWith(expectedError); }); it('should succeed if sender is the owner', async () => { - const isSuccessful = await ownable.externalOnlyOwner.callAsync({ from: owner }); + const isSuccessful = await ownable.externalOnlyOwner().callAsync({ from: owner }); expect(isSuccessful).to.be.true(); }); }); @@ -35,12 +35,12 @@ blockchainTests.resets('Ownable', env => { describe('transferOwnership', () => { it('should revert if the specified new owner is the zero address', async () => { const expectedError = new OwnableRevertErrors.TransferOwnerToZeroError(); - const tx = ownable.transferOwnership.sendTransactionAsync(constants.NULL_ADDRESS, { from: owner }); + const tx = ownable.transferOwnership(constants.NULL_ADDRESS).sendTransactionAsync({ from: owner }); return expect(tx).to.revertWith(expectedError); }); it('should transfer ownership if the specified new owner is not the zero address', async () => { - const receipt = await ownable.transferOwnership.awaitTransactionSuccessAsync(nonOwner, { from: owner }); + const receipt = await ownable.transferOwnership(nonOwner).awaitTransactionSuccessAsync({ from: owner }); // Ensure that the correct logs were emitted. expect(receipt.logs.length).to.be.eq(1); @@ -51,7 +51,7 @@ blockchainTests.resets('Ownable', env => { expect(event).to.be.deep.eq({ previousOwner: owner, newOwner: nonOwner }); // Ensure that the owner was actually updated - const updatedOwner = await ownable.owner.callAsync(); + const updatedOwner = await ownable.owner().callAsync(); expect(updatedOwner).to.be.eq(nonOwner); }); }); diff --git a/contracts/utils/test/reentrancy_guard.ts b/contracts/utils/test/reentrancy_guard.ts index 9018e6f4c0..c816bf550d 100644 --- a/contracts/utils/test/reentrancy_guard.ts +++ b/contracts/utils/test/reentrancy_guard.ts @@ -31,11 +31,11 @@ describe('ReentrancyGuard', () => { describe('nonReentrant', () => { it('should revert if reentrancy occurs', async () => { const expectedError = new ReentrancyGuardRevertErrors.IllegalReentrancyError(); - return expect(guard.guarded.sendTransactionAsync(true)).to.revertWith(expectedError); + return expect(guard.guarded(true).sendTransactionAsync()).to.revertWith(expectedError); }); it('should succeed if reentrancy does not occur', async () => { - const isSuccessful = await guard.guarded.callAsync(false); + const isSuccessful = await guard.guarded(false).callAsync(); expect(isSuccessful).to.be.true(); }); }); diff --git a/contracts/utils/test/refundable.ts b/contracts/utils/test/refundable.ts index 8411716231..d474f139d2 100644 --- a/contracts/utils/test/refundable.ts +++ b/contracts/utils/test/refundable.ts @@ -35,14 +35,14 @@ blockchainTests('Refundable', env => { blockchainTests.resets('refundNonzeroBalance', () => { it('should not send a refund when no value is sent', async () => { // Send 100 wei to the refundable contract that should be refunded. - await receiver.testRefundNonZeroBalance.awaitTransactionSuccessAsync(refundable.address, { + await receiver.testRefundNonZeroBalance(refundable.address).awaitTransactionSuccessAsync({ value: constants.ZERO_AMOUNT, }); }); it('should send a full refund when nonzero value is sent', async () => { // Send 100 wei to the refundable contract that should be refunded. - await receiver.testRefundNonZeroBalance.awaitTransactionSuccessAsync(refundable.address, { + await receiver.testRefundNonZeroBalance(refundable.address).awaitTransactionSuccessAsync({ value: ONE_HUNDRED, }); }); @@ -53,7 +53,7 @@ blockchainTests('Refundable', env => { blockchainTests.resets('refundFinalBalance', () => { it('should fully refund the sender when `shouldNotRefund` is false', async () => { // Send 100 wei to the refundable contract that should be refunded to the receiver contract. - await receiver.testRefundFinalBalance.awaitTransactionSuccessAsync(refundable.address, false, { + await receiver.testRefundFinalBalance(refundable.address, false).awaitTransactionSuccessAsync({ value: ONE_HUNDRED, }); }); @@ -61,19 +61,19 @@ blockchainTests('Refundable', env => { // This test may not be necessary, but it is included here as a sanity check. it('should fully refund the sender when `shouldNotRefund` is false for two calls in a row', async () => { // Send 100 wei to the refundable contract that should be refunded to the receiver contract. - await receiver.testRefundFinalBalance.awaitTransactionSuccessAsync(refundable.address, false, { + await receiver.testRefundFinalBalance(refundable.address, false).awaitTransactionSuccessAsync({ value: ONE_HUNDRED, }); // Send 1000 wei to the refundable contract that should be refunded to the receiver contract. - await receiver.testRefundFinalBalance.awaitTransactionSuccessAsync(refundable.address, false, { + await receiver.testRefundFinalBalance(refundable.address, false).awaitTransactionSuccessAsync({ value: new BigNumber(1000), }); }); it('should not refund the sender if `shouldNotRefund` is true', async () => { /// Send 100 wei to the refundable contract that should not be refunded. - await receiver.testRefundFinalBalance.awaitTransactionSuccessAsync(refundable.address, true, { + await receiver.testRefundFinalBalance(refundable.address, true).awaitTransactionSuccessAsync({ value: new BigNumber(1000), }); }); @@ -84,7 +84,7 @@ blockchainTests('Refundable', env => { blockchainTests.resets('disableRefundUntilEnd', () => { it('should fully refund the sender when `shouldNotRefund` is false', async () => { // Send 100 wei to the refundable contract that should be refunded to the receiver contract. - await receiver.testDisableRefundUntilEnd.awaitTransactionSuccessAsync(refundable.address, false, { + await receiver.testDisableRefundUntilEnd(refundable.address, false).awaitTransactionSuccessAsync({ value: ONE_HUNDRED, }); }); @@ -92,47 +92,47 @@ blockchainTests('Refundable', env => { // This test may not be necessary, but it is included here as a sanity check. it('should fully refund the sender when `shouldNotRefund` is false for two calls in a row', async () => { // Send 100 wei to the refundable contract that should be refunded to the receiver contract. - await receiver.testDisableRefundUntilEnd.awaitTransactionSuccessAsync(refundable.address, false, { + await receiver.testDisableRefundUntilEnd(refundable.address, false).awaitTransactionSuccessAsync({ value: ONE_HUNDRED, }); // Send 1000 wei to the refundable contract that should be refunded to the receiver contract. - await receiver.testDisableRefundUntilEnd.awaitTransactionSuccessAsync(refundable.address, false, { + await receiver.testDisableRefundUntilEnd(refundable.address, false).awaitTransactionSuccessAsync({ value: ONE_THOUSAND, }); }); it('should not refund the sender if `shouldNotRefund` is true', async () => { /// Send 100 wei to the refundable contract that should not be refunded. - await receiver.testDisableRefundUntilEnd.awaitTransactionSuccessAsync(refundable.address, false, { + await receiver.testDisableRefundUntilEnd(refundable.address, false).awaitTransactionSuccessAsync({ value: ONE_HUNDRED, }); }); it('should disable the `disableRefundUntilEnd` modifier and refund when `shouldNotRefund` is false', async () => { /// Send 100 wei to the refundable contract that should be refunded. - await receiver.testNestedDisableRefundUntilEnd.awaitTransactionSuccessAsync(refundable.address, false, { + await receiver.testNestedDisableRefundUntilEnd(refundable.address, false).awaitTransactionSuccessAsync({ value: ONE_HUNDRED, }); }); it('should disable the `refundFinalBalance` modifier and send no refund when `shouldNotRefund` is true', async () => { /// Send 100 wei to the refundable contract that should not be refunded. - await receiver.testNestedDisableRefundUntilEnd.awaitTransactionSuccessAsync(refundable.address, true, { + await receiver.testNestedDisableRefundUntilEnd(refundable.address, true).awaitTransactionSuccessAsync({ value: ONE_HUNDRED, }); }); it('should disable the `refundFinalBalance` modifier and refund when `shouldNotRefund` is false', async () => { /// Send 100 wei to the refundable contract that should be refunded. - await receiver.testMixedRefunds.awaitTransactionSuccessAsync(refundable.address, false, { + await receiver.testMixedRefunds(refundable.address, false).awaitTransactionSuccessAsync({ value: ONE_HUNDRED, }); }); it('should disable the `refundFinalBalance` modifier and send no refund when `shouldNotRefund` is true', async () => { /// Send 100 wei to the refundable contract that should not be refunded. - await receiver.testMixedRefunds.awaitTransactionSuccessAsync(refundable.address, true, { + await receiver.testMixedRefunds(refundable.address, true).awaitTransactionSuccessAsync({ value: ONE_HUNDRED, }); }); diff --git a/packages/asset-buyer/src/asset_buyer.ts b/packages/asset-buyer/src/asset_buyer.ts index 55f972bcd4..953a254228 100644 --- a/packages/asset-buyer/src/asset_buyer.ts +++ b/packages/asset-buyer/src/asset_buyer.ts @@ -177,7 +177,7 @@ export class AssetBuyer { ): Promise { assert.isETHAddressHex('tokenAddress', tokenAddress); assert.isBigNumber('assetBuyAmount', assetBuyAmount); - const assetData = await this._contractWrappers.devUtils.encodeERC20AssetData.callAsync(tokenAddress); + const assetData = await this._contractWrappers.devUtils.encodeERC20AssetData(tokenAddress).callAsync(); const buyQuote = this.getBuyQuoteAsync(assetData, assetBuyAmount, options); return buyQuote; } @@ -267,19 +267,20 @@ export class AssetBuyer { // if no ethAmount is provided, default to the worst ethAmount from buyQuote const value = ethAmount || worstCaseQuoteInfo.totalEthAmount; - const txHash = await this._contractWrappers.forwarder.marketBuyOrdersWithEth.sendTransactionAsync( - orders, - assetBuyAmount, - orders.map(o => o.signature), - formattedFeePercentage, - feeRecipient, - { + const txHash = await this._contractWrappers.forwarder + .marketBuyOrdersWithEth( + orders, + assetBuyAmount, + orders.map(o => o.signature), + formattedFeePercentage, + feeRecipient, + ) + .sendTransactionAsync({ value, from: finalTakerAddress.toLowerCase(), gas: gasLimit, gasPrice, - }, - ); + }); return txHash; } catch (err) { @@ -360,17 +361,17 @@ export class AssetBuyer { * Will throw if WETH does not exist for the current chain. */ private async _getEtherTokenAssetDataOrThrowAsync(): Promise { - return this._contractWrappers.devUtils.encodeERC20AssetData.callAsync( - this._contractWrappers.contractAddresses.etherToken, - ); + return this._contractWrappers.devUtils + .encodeERC20AssetData(this._contractWrappers.contractAddresses.etherToken) + .callAsync(); } /** * Get the assetData that represents the ZRX token. * Will throw if ZRX does not exist for the current chain. */ private async _getZrxTokenAssetDataOrThrowAsync(): Promise { - return this._contractWrappers.devUtils.encodeERC20AssetData.callAsync( - this._contractWrappers.contractAddresses.zrxToken, - ); + return this._contractWrappers.devUtils + .encodeERC20AssetData(this._contractWrappers.contractAddresses.zrxToken) + .callAsync(); } } diff --git a/packages/asset-buyer/src/utils/order_provider_response_processor.ts b/packages/asset-buyer/src/utils/order_provider_response_processor.ts index defd5452c9..c19bab17dc 100644 --- a/packages/asset-buyer/src/utils/order_provider_response_processor.ts +++ b/packages/asset-buyer/src/utils/order_provider_response_processor.ts @@ -44,10 +44,9 @@ export const orderProviderResponseProcessor = { if (orderValidator !== undefined) { const takerAddresses = _.map(filteredOrders, () => constants.NULL_ADDRESS); try { - const [ordersInfo, tradersInfo] = await orderValidator.getOrdersAndTradersInfo.callAsync( - filteredOrders, - takerAddresses, - ); + const [ordersInfo, tradersInfo] = await orderValidator + .getOrdersAndTradersInfo(filteredOrders, takerAddresses) + .callAsync(); const ordersAndTradersInfo = ordersInfo.map((orderInfo, index) => { return { orderInfo, diff --git a/packages/asset-swapper/src/quote_consumers/exchange_swap_quote_consumer.ts b/packages/asset-swapper/src/quote_consumers/exchange_swap_quote_consumer.ts index 7e79b930c7..996a652c10 100644 --- a/packages/asset-swapper/src/quote_consumers/exchange_swap_quote_consumer.ts +++ b/packages/asset-swapper/src/quote_consumers/exchange_swap_quote_consumer.ts @@ -144,28 +144,22 @@ export class ExchangeSwapQuoteConsumer implements SwapQuoteConsumerBase o.signature), - { + txHash = await this._contractWrappers.exchange + .marketBuyOrdersNoThrow(orders, makerAssetFillAmount, orders.map(o => o.signature)) + .sendTransactionAsync({ from: finalTakerAddress, gas: gasLimit, gasPrice, - }, - ); + }); } else { const { takerAssetFillAmount } = quote; - txHash = await this._contractWrappers.exchange.marketSellOrdersNoThrow.sendTransactionAsync( - orders, - takerAssetFillAmount, - orders.map(o => o.signature), - { + txHash = await this._contractWrappers.exchange + .marketSellOrdersNoThrow(orders, takerAssetFillAmount, orders.map(o => o.signature)) + .sendTransactionAsync({ from: finalTakerAddress, gas: gasLimit, gasPrice, - }, - ); + }); } return txHash; } catch (err) { diff --git a/packages/asset-swapper/src/quote_consumers/forwarder_swap_quote_consumer.ts b/packages/asset-swapper/src/quote_consumers/forwarder_swap_quote_consumer.ts index a709fa53db..82420df4a9 100644 --- a/packages/asset-swapper/src/quote_consumers/forwarder_swap_quote_consumer.ts +++ b/packages/asset-swapper/src/quote_consumers/forwarder_swap_quote_consumer.ts @@ -196,32 +196,29 @@ export class ForwarderSwapQuoteConsumer implements SwapQuoteConsumerBase o.signature), - formattedFeePercentage, - feeRecipient, - { + txHash = await this._contractWrappers.forwarder + .marketBuyOrdersWithEth( + orders, + makerAssetFillAmount, + orders.map(o => o.signature), + formattedFeePercentage, + feeRecipient, + ) + .sendTransactionAsync({ value, from: finalTakerAddress.toLowerCase(), gas: gasLimit, gasPrice, - }, - ); + }); } else { - txHash = await this._contractWrappers.forwarder.marketSellOrdersWithEth.sendTransactionAsync( - orders, - orders.map(o => o.signature), - formattedFeePercentage, - feeRecipient, - { + txHash = await this._contractWrappers.forwarder + .marketSellOrdersWithEth(orders, orders.map(o => o.signature), formattedFeePercentage, feeRecipient) + .sendTransactionAsync({ value, from: finalTakerAddress.toLowerCase(), gas: gasLimit, gasPrice, - }, - ); + }); } return txHash; } catch (err) { @@ -236,8 +233,8 @@ export class ForwarderSwapQuoteConsumer implements SwapQuoteConsumerBase { - return this._contractWrappers.devUtils.encodeERC20AssetData.callAsync( - this._contractWrappers.contractAddresses.etherToken, - ); + return this._contractWrappers.devUtils + .encodeERC20AssetData(this._contractWrappers.contractAddresses.etherToken) + .callAsync(); } } diff --git a/packages/asset-swapper/src/swap_quoter.ts b/packages/asset-swapper/src/swap_quoter.ts index a5f43d8350..65e24e3d9f 100644 --- a/packages/asset-swapper/src/swap_quoter.ts +++ b/packages/asset-swapper/src/swap_quoter.ts @@ -216,8 +216,12 @@ export class SwapQuoter { assert.isETHAddressHex('makerTokenAddress', makerTokenAddress); assert.isETHAddressHex('takerTokenAddress', takerTokenAddress); assert.isBigNumber('makerAssetBuyAmount', makerAssetBuyAmount); - const makerAssetData = await this._contractWrappers.devUtils.encodeERC20AssetData.callAsync(makerTokenAddress); - const takerAssetData = await this._contractWrappers.devUtils.encodeERC20AssetData.callAsync(takerTokenAddress); + const makerAssetData = await this._contractWrappers.devUtils + .encodeERC20AssetData(makerTokenAddress) + .callAsync(); + const takerAssetData = await this._contractWrappers.devUtils + .encodeERC20AssetData(takerTokenAddress) + .callAsync(); const swapQuote = this.getMarketBuySwapQuoteForAssetDataAsync( makerAssetData, takerAssetData, @@ -246,8 +250,12 @@ export class SwapQuoter { assert.isETHAddressHex('makerTokenAddress', makerTokenAddress); assert.isETHAddressHex('takerTokenAddress', takerTokenAddress); assert.isBigNumber('takerAssetSellAmount', takerAssetSellAmount); - const makerAssetData = await this._contractWrappers.devUtils.encodeERC20AssetData.callAsync(makerTokenAddress); - const takerAssetData = await this._contractWrappers.devUtils.encodeERC20AssetData.callAsync(takerTokenAddress); + const makerAssetData = await this._contractWrappers.devUtils + .encodeERC20AssetData(makerTokenAddress) + .callAsync(); + const takerAssetData = await this._contractWrappers.devUtils + .encodeERC20AssetData(takerTokenAddress) + .callAsync(); const swapQuote = this.getMarketSellSwapQuoteForAssetDataAsync( makerAssetData, takerAssetData, @@ -374,10 +382,9 @@ export class SwapQuoter { takerAddress: string, ): Promise<[boolean, boolean]> { const orderValidator = this._contractWrappers.orderValidator; - const balanceAndAllowance = await orderValidator.getBalanceAndAllowance.callAsync( - takerAddress, - swapQuote.takerAssetData, - ); + const balanceAndAllowance = await orderValidator + .getBalanceAndAllowance(takerAddress, swapQuote.takerAssetData) + .callAsync(); const allowance = balanceAndAllowance[1]; return [ allowance.isGreaterThanOrEqualTo(swapQuote.bestCaseQuoteInfo.totalTakerTokenAmount), @@ -397,9 +404,9 @@ export class SwapQuoter { * Will throw if ZRX does not exist for the current chain. */ private async _getZrxTokenAssetDataOrThrowAsync(): Promise { - return this._contractWrappers.devUtils.encodeERC20AssetData.callAsync( - this._contractWrappers.contractAddresses.zrxToken, - ); + return this._contractWrappers.devUtils + .encodeERC20AssetData(this._contractWrappers.contractAddresses.zrxToken) + .callAsync(); } /** diff --git a/packages/asset-swapper/src/utils/order_provider_response_processor.ts b/packages/asset-swapper/src/utils/order_provider_response_processor.ts index 82531d0ff4..92442fa52c 100644 --- a/packages/asset-swapper/src/utils/order_provider_response_processor.ts +++ b/packages/asset-swapper/src/utils/order_provider_response_processor.ts @@ -45,10 +45,9 @@ export const orderProviderResponseProcessor = { if (orderValidator !== undefined) { const takerAddresses = _.map(filteredOrders, () => constants.NULL_ADDRESS); try { - const [ordersInfo, tradersInfo] = await orderValidator.getOrdersAndTradersInfo.callAsync( - filteredOrders, - takerAddresses, - ); + const [ordersInfo, tradersInfo] = await orderValidator + .getOrdersAndTradersInfo(filteredOrders, takerAddresses) + .callAsync(); const ordersAndTradersInfo: any[] = ordersInfo.map((orderInfo, index) => { const singleOrderAndTraderInfo = { orderInfo, diff --git a/packages/asset-swapper/src/utils/swap_quote_consumer_utils.ts b/packages/asset-swapper/src/utils/swap_quote_consumer_utils.ts index 3a1fd1c9d8..87be11f339 100644 --- a/packages/asset-swapper/src/utils/swap_quote_consumer_utils.ts +++ b/packages/asset-swapper/src/utils/swap_quote_consumer_utils.ts @@ -52,7 +52,7 @@ export const swapQuoteConsumerUtils = { ): Promise<[BigNumber, BigNumber]> { const web3Wrapper = new Web3Wrapper(provider); const ethBalance = await web3Wrapper.getBalanceInWeiAsync(takerAddress); - const wethBalance = await contractWrappers.weth9.balanceOf.callAsync(takerAddress); + const wethBalance = await contractWrappers.weth9.balanceOf(takerAddress).callAsync(); return [ethBalance, wethBalance]; }, isValidForwarderSwapQuote(swapQuote: SwapQuote, wethAssetData: string): boolean { @@ -84,9 +84,9 @@ export const swapQuoteConsumerUtils = { provider: Provider, opts: Partial, ): Promise { - const wethAssetData = await contractWrappers.devUtils.encodeERC20AssetData.callAsync( - contractWrappers.contractAddresses.etherToken, - ); + const wethAssetData = await contractWrappers.devUtils + .encodeERC20AssetData(contractWrappers.contractAddresses.etherToken) + .callAsync(); if (swapQuoteConsumerUtils.isValidForwarderSwapQuote(quote, wethAssetData)) { if (opts.takerAddress !== undefined) { assert.isETHAddressHex('takerAddress', opts.takerAddress); diff --git a/packages/asset-swapper/test/exchange_swap_quote_consumer_test.ts b/packages/asset-swapper/test/exchange_swap_quote_consumer_test.ts index f48f28c856..880435e249 100644 --- a/packages/asset-swapper/test/exchange_swap_quote_consumer_test.ts +++ b/packages/asset-swapper/test/exchange_swap_quote_consumer_test.ts @@ -66,9 +66,9 @@ describe('ExchangeSwapQuoteConsumer', () => { [coinbaseAddress, takerAddress, makerAddress, feeRecipient] = userAddresses; [makerTokenAddress, takerTokenAddress] = tokenUtils.getDummyERC20TokenAddresses(); [makerAssetData, takerAssetData, wethAssetData] = [ - await contractWrappers.devUtils.encodeERC20AssetData.callAsync(makerTokenAddress), - await contractWrappers.devUtils.encodeERC20AssetData.callAsync(takerTokenAddress), - await contractWrappers.devUtils.encodeERC20AssetData.callAsync(contractAddresses.etherToken), + await contractWrappers.devUtils.encodeERC20AssetData(makerTokenAddress).callAsync(), + await contractWrappers.devUtils.encodeERC20AssetData(takerTokenAddress).callAsync(), + await contractWrappers.devUtils.encodeERC20AssetData(contractAddresses.etherToken).callAsync(), ]; erc20TokenContract = new ERC20TokenContract(makerTokenAddress, provider); @@ -79,12 +79,12 @@ describe('ExchangeSwapQuoteConsumer', () => { takerAddress, makerAssetData, takerAssetData, - makerFeeAssetData: await contractWrappers.devUtils.encodeERC20AssetData.callAsync( - contractAddresses.zrxToken, - ), - takerFeeAssetData: await contractWrappers.devUtils.encodeERC20AssetData.callAsync( - contractAddresses.zrxToken, - ), + makerFeeAssetData: await contractWrappers.devUtils + .encodeERC20AssetData(contractAddresses.zrxToken) + .callAsync(), + takerFeeAssetData: await contractWrappers.devUtils + .encodeERC20AssetData(contractAddresses.zrxToken) + .callAsync(), exchangeAddress: contractAddresses.exchange, chainId, }; @@ -132,24 +132,24 @@ describe('ExchangeSwapQuoteConsumer', () => { * Does not test the validity of the state change performed by the forwarder smart contract */ it('should perform a marketSell execution when provided a MarketSell type swapQuote', async () => { - let makerBalance = await erc20TokenContract.balanceOf.callAsync(makerAddress); - let takerBalance = await erc20TokenContract.balanceOf.callAsync(takerAddress); + let makerBalance = await erc20TokenContract.balanceOf(makerAddress).callAsync(); + let takerBalance = await erc20TokenContract.balanceOf(takerAddress).callAsync(); expect(makerBalance).to.bignumber.equal(new BigNumber(10).multipliedBy(ONE_ETH_IN_WEI)); expect(takerBalance).to.bignumber.equal(constants.ZERO_AMOUNT); await swapQuoteConsumer.executeSwapQuoteOrThrowAsync(marketSellSwapQuote, { takerAddress }); - makerBalance = await erc20TokenContract.balanceOf.callAsync(makerAddress); - takerBalance = await erc20TokenContract.balanceOf.callAsync(takerAddress); + makerBalance = await erc20TokenContract.balanceOf(makerAddress).callAsync(); + takerBalance = await erc20TokenContract.balanceOf(takerAddress).callAsync(); expect(takerBalance).to.bignumber.equal(new BigNumber(10).multipliedBy(ONE_ETH_IN_WEI)); expect(makerBalance).to.bignumber.equal(constants.ZERO_AMOUNT); }); it('should perform a marketBuy execution when provided a MarketBuy type swapQuote', async () => { - let makerBalance = await erc20TokenContract.balanceOf.callAsync(makerAddress); - let takerBalance = await erc20TokenContract.balanceOf.callAsync(takerAddress); + let makerBalance = await erc20TokenContract.balanceOf(makerAddress).callAsync(); + let takerBalance = await erc20TokenContract.balanceOf(takerAddress).callAsync(); expect(makerBalance).to.bignumber.equal(new BigNumber(10).multipliedBy(ONE_ETH_IN_WEI)); expect(takerBalance).to.bignumber.equal(constants.ZERO_AMOUNT); await swapQuoteConsumer.executeSwapQuoteOrThrowAsync(marketBuySwapQuote, { takerAddress }); - makerBalance = await erc20TokenContract.balanceOf.callAsync(makerAddress); - takerBalance = await erc20TokenContract.balanceOf.callAsync(takerAddress); + makerBalance = await erc20TokenContract.balanceOf(makerAddress).callAsync(); + takerBalance = await erc20TokenContract.balanceOf(takerAddress).callAsync(); expect(takerBalance).to.bignumber.equal(new BigNumber(10).multipliedBy(ONE_ETH_IN_WEI)); expect(makerBalance).to.bignumber.equal(constants.ZERO_AMOUNT); }); @@ -192,8 +192,8 @@ describe('ExchangeSwapQuoteConsumer', () => { describe('getCalldataOrThrow', () => { describe('valid swap quote', async () => { it('provide correct and optimized calldata options with default options for a marketSell SwapQuote (no affiliate fees)', async () => { - let makerBalance = await erc20TokenContract.balanceOf.callAsync(makerAddress); - let takerBalance = await erc20TokenContract.balanceOf.callAsync(takerAddress); + let makerBalance = await erc20TokenContract.balanceOf(makerAddress).callAsync(); + let takerBalance = await erc20TokenContract.balanceOf(takerAddress).callAsync(); expect(makerBalance).to.bignumber.equal(new BigNumber(10).multipliedBy(ONE_ETH_IN_WEI)); expect(takerBalance).to.bignumber.equal(constants.ZERO_AMOUNT); const { calldataHexString, toAddress } = await swapQuoteConsumer.getCalldataOrThrowAsync( @@ -207,14 +207,14 @@ describe('ExchangeSwapQuoteConsumer', () => { data: calldataHexString, gas: 4000000, }); - makerBalance = await erc20TokenContract.balanceOf.callAsync(makerAddress); - takerBalance = await erc20TokenContract.balanceOf.callAsync(takerAddress); + makerBalance = await erc20TokenContract.balanceOf(makerAddress).callAsync(); + takerBalance = await erc20TokenContract.balanceOf(takerAddress).callAsync(); expect(takerBalance).to.bignumber.equal(new BigNumber(10).multipliedBy(ONE_ETH_IN_WEI)); expect(makerBalance).to.bignumber.equal(constants.ZERO_AMOUNT); }); it('provide correct and optimized calldata options with default options for a marketBuy SwapQuote (no affiliate fees)', async () => { - let makerBalance = await erc20TokenContract.balanceOf.callAsync(makerAddress); - let takerBalance = await erc20TokenContract.balanceOf.callAsync(takerAddress); + let makerBalance = await erc20TokenContract.balanceOf(makerAddress).callAsync(); + let takerBalance = await erc20TokenContract.balanceOf(takerAddress).callAsync(); expect(makerBalance).to.bignumber.equal(new BigNumber(10).multipliedBy(ONE_ETH_IN_WEI)); expect(takerBalance).to.bignumber.equal(constants.ZERO_AMOUNT); const { calldataHexString, toAddress } = await swapQuoteConsumer.getCalldataOrThrowAsync( @@ -228,8 +228,8 @@ describe('ExchangeSwapQuoteConsumer', () => { data: calldataHexString, gas: 4000000, }); - makerBalance = await erc20TokenContract.balanceOf.callAsync(makerAddress); - takerBalance = await erc20TokenContract.balanceOf.callAsync(takerAddress); + makerBalance = await erc20TokenContract.balanceOf(makerAddress).callAsync(); + takerBalance = await erc20TokenContract.balanceOf(takerAddress).callAsync(); expect(takerBalance).to.bignumber.equal(new BigNumber(10).multipliedBy(ONE_ETH_IN_WEI)); expect(makerBalance).to.bignumber.equal(constants.ZERO_AMOUNT); }); diff --git a/packages/asset-swapper/test/forwarder_swap_quote_consumer_test.ts b/packages/asset-swapper/test/forwarder_swap_quote_consumer_test.ts index 4b6621487e..6de57242e7 100644 --- a/packages/asset-swapper/test/forwarder_swap_quote_consumer_test.ts +++ b/packages/asset-swapper/test/forwarder_swap_quote_consumer_test.ts @@ -66,9 +66,9 @@ describe('ForwarderSwapQuoteConsumer', () => { [makerTokenAddress, takerTokenAddress] = tokenUtils.getDummyERC20TokenAddresses(); erc20Token = new ERC20TokenContract(makerTokenAddress, provider); [makerAssetData, takerAssetData, wethAssetData] = [ - await contractWrappers.devUtils.encodeERC20AssetData.callAsync(makerTokenAddress), - await contractWrappers.devUtils.encodeERC20AssetData.callAsync(takerTokenAddress), - await contractWrappers.devUtils.encodeERC20AssetData.callAsync(contractAddresses.etherToken), + await contractWrappers.devUtils.encodeERC20AssetData(makerTokenAddress).callAsync(), + await contractWrappers.devUtils.encodeERC20AssetData(takerTokenAddress).callAsync(), + await contractWrappers.devUtils.encodeERC20AssetData(contractAddresses.etherToken).callAsync(), ]; }); after(async () => { @@ -84,11 +84,11 @@ describe('ForwarderSwapQuoteConsumer', () => { new BigNumber(0), ); - await erc20Token.transfer.sendTransactionAsync(makerAddress, totalFillableAmount, { + await erc20Token.transfer(makerAddress, totalFillableAmount).sendTransactionAsync({ from: coinbaseAddress, }); - await erc20Token.approve.sendTransactionAsync(erc20ProxyAddress, UNLIMITED_ALLOWANCE, { + await erc20Token.approve(erc20ProxyAddress, UNLIMITED_ALLOWANCE).sendTransactionAsync({ from: makerAddress, }); orders = await getSignedOrdersWithNoFeesAsync( @@ -154,32 +154,32 @@ describe('ForwarderSwapQuoteConsumer', () => { * Does not test the validity of the state change performed by the forwarder smart contract */ it('should perform a marketSell execution when provided a MarketSell type swapQuote', async () => { - let makerBalance = await erc20Token.balanceOf.callAsync(makerAddress); - let takerBalance = await erc20Token.balanceOf.callAsync(takerAddress); + let makerBalance = await erc20Token.balanceOf(makerAddress).callAsync(); + let takerBalance = await erc20Token.balanceOf(takerAddress).callAsync(); expect(makerBalance).to.bignumber.equal(new BigNumber(10).multipliedBy(ONE_ETH_IN_WEI)); expect(takerBalance).to.bignumber.equal(constants.ZERO_AMOUNT); await swapQuoteConsumer.executeSwapQuoteOrThrowAsync(marketSellSwapQuote, { takerAddress }); - makerBalance = await erc20Token.balanceOf.callAsync(makerAddress); - takerBalance = await erc20Token.balanceOf.callAsync(takerAddress); + makerBalance = await erc20Token.balanceOf(makerAddress).callAsync(); + takerBalance = await erc20Token.balanceOf(takerAddress).callAsync(); expect(makerBalance).to.bignumber.equal(new BigNumber(0.5).multipliedBy(ONE_ETH_IN_WEI)); expect(takerBalance).to.bignumber.equal(new BigNumber(9.5).multipliedBy(ONE_ETH_IN_WEI)); }); it('should perform a marketBuy execution when provided a MarketBuy type swapQuote', async () => { - let makerBalance = await erc20Token.balanceOf.callAsync(makerAddress); - let takerBalance = await erc20Token.balanceOf.callAsync(takerAddress); + let makerBalance = await erc20Token.balanceOf(makerAddress).callAsync(); + let takerBalance = await erc20Token.balanceOf(takerAddress).callAsync(); expect(makerBalance).to.bignumber.equal(new BigNumber(10).multipliedBy(ONE_ETH_IN_WEI)); expect(takerBalance).to.bignumber.equal(constants.ZERO_AMOUNT); await swapQuoteConsumer.executeSwapQuoteOrThrowAsync(marketBuySwapQuote, { takerAddress }); - makerBalance = await erc20Token.balanceOf.callAsync(makerAddress); - takerBalance = await erc20Token.balanceOf.callAsync(takerAddress); + makerBalance = await erc20Token.balanceOf(makerAddress).callAsync(); + takerBalance = await erc20Token.balanceOf(takerAddress).callAsync(); expect(takerBalance).to.bignumber.equal(new BigNumber(10).multipliedBy(ONE_ETH_IN_WEI)); expect(makerBalance).to.bignumber.equal(constants.ZERO_AMOUNT); }); it('should perform a marketBuy execution with affiliate fees', async () => { - let makerBalance = await erc20Token.balanceOf.callAsync(makerAddress); - let takerBalance = await erc20Token.balanceOf.callAsync(takerAddress); + let makerBalance = await erc20Token.balanceOf(makerAddress).callAsync(); + let takerBalance = await erc20Token.balanceOf(takerAddress).callAsync(); const feeRecipientEthBalanceBefore = await web3Wrapper.getBalanceInWeiAsync(feeRecipient); expect(makerBalance).to.bignumber.equal(new BigNumber(10).multipliedBy(ONE_ETH_IN_WEI)); expect(takerBalance).to.bignumber.equal(constants.ZERO_AMOUNT); @@ -188,8 +188,8 @@ describe('ForwarderSwapQuoteConsumer', () => { feePercentage: 0.05, feeRecipient, }); - makerBalance = await erc20Token.balanceOf.callAsync(makerAddress); - takerBalance = await erc20Token.balanceOf.callAsync(takerAddress); + makerBalance = await erc20Token.balanceOf(makerAddress).callAsync(); + takerBalance = await erc20Token.balanceOf(takerAddress).callAsync(); const feeRecipientEthBalanceAfter = await web3Wrapper.getBalanceInWeiAsync(feeRecipient); expect(makerBalance).to.bignumber.equal(constants.ZERO_AMOUNT); expect(takerBalance).to.bignumber.equal(new BigNumber(10).multipliedBy(ONE_ETH_IN_WEI)); @@ -200,15 +200,15 @@ describe('ForwarderSwapQuoteConsumer', () => { // TODO(david) Finish marketSell affiliate fee excution testing // it('should perform a marketSell execution with affiliate fees', async () => { - // let makerBalance = await erc20Token.balanceOf.callAsync(makerAddress); - // let takerBalance = await erc20Token.balanceOf.callAsync(takerAddress); + // let makerBalance = await erc20Token.balanceOf(makerAddress).callAsync(); + // let takerBalance = await erc20Token.balanceOf(takerAddress).callAsync(); // const feeRecipientEthBalanceBefore = await web3Wrapper.getBalanceInWeiAsync(feeRecipient); // expect(makerBalance).to.bignumber.equal((new BigNumber(10)).multipliedBy(ONE_ETH_IN_WEI)); // expect(takerBalance).to.bignumber.equal(constants.ZERO_AMOUNT); // console.log(makerBalance, takerBalance, feeRecipientEthBalanceBefore); // await swapQuoteConsumer.executeSwapQuoteOrThrowAsync(marketSellSwapQuote, { takerAddress, feePercentage: 0.05, feeRecipient }); - // makerBalance = await erc20Token.balanceOf.callAsync(makerAddress); - // takerBalance = await erc20Token.balanceOf.callAsync(takerAddress); + // makerBalance = await erc20Token.balanceOf(makerAddress).callAsync(); + // takerBalance = await erc20Token.balanceOf(takerAddress).callAsync(); // const feeRecipientEthBalanceAfter = await web3Wrapper.getBalanceInWeiAsync(feeRecipient); // console.log(makerBalance, takerBalance, feeRecipientEthBalanceAfter); // expect(makerBalance).to.bignumber.equal((new BigNumber(0.5)).multipliedBy(ONE_ETH_IN_WEI)); @@ -364,8 +364,8 @@ describe('ForwarderSwapQuoteConsumer', () => { describe('valid swap quote', async () => { it('provide correct and optimized calldata options with default options for a marketSell SwapQuote (no affiliate fees)', async () => { - let makerBalance = await erc20Token.balanceOf.callAsync(makerAddress); - let takerBalance = await erc20Token.balanceOf.callAsync(takerAddress); + let makerBalance = await erc20Token.balanceOf(makerAddress).callAsync(); + let takerBalance = await erc20Token.balanceOf(takerAddress).callAsync(); expect(makerBalance).to.bignumber.equal(new BigNumber(10).multipliedBy(ONE_ETH_IN_WEI)); expect(takerBalance).to.bignumber.equal(constants.ZERO_AMOUNT); const { calldataHexString, toAddress } = await swapQuoteConsumer.getCalldataOrThrowAsync( @@ -380,14 +380,14 @@ describe('ForwarderSwapQuoteConsumer', () => { value: marketSellSwapQuote.worstCaseQuoteInfo.totalTakerTokenAmount, gas: 4000000, }); - makerBalance = await erc20Token.balanceOf.callAsync(makerAddress); - takerBalance = await erc20Token.balanceOf.callAsync(takerAddress); + makerBalance = await erc20Token.balanceOf(makerAddress).callAsync(); + takerBalance = await erc20Token.balanceOf(takerAddress).callAsync(); expect(makerBalance).to.bignumber.equal(new BigNumber(0.5).multipliedBy(ONE_ETH_IN_WEI)); expect(takerBalance).to.bignumber.equal(new BigNumber(9.5).multipliedBy(ONE_ETH_IN_WEI)); }); it('provide correct and optimized calldata options with default options for a marketBuy SwapQuote (no affiliate fees)', async () => { - let makerBalance = await erc20Token.balanceOf.callAsync(makerAddress); - let takerBalance = await erc20Token.balanceOf.callAsync(takerAddress); + let makerBalance = await erc20Token.balanceOf(makerAddress).callAsync(); + let takerBalance = await erc20Token.balanceOf(takerAddress).callAsync(); expect(makerBalance).to.bignumber.equal(new BigNumber(10).multipliedBy(ONE_ETH_IN_WEI)); expect(takerBalance).to.bignumber.equal(constants.ZERO_AMOUNT); const { calldataHexString, toAddress } = await swapQuoteConsumer.getCalldataOrThrowAsync( @@ -402,8 +402,8 @@ describe('ForwarderSwapQuoteConsumer', () => { value: marketBuySwapQuote.worstCaseQuoteInfo.totalTakerTokenAmount, gas: 4000000, }); - makerBalance = await erc20Token.balanceOf.callAsync(makerAddress); - takerBalance = await erc20Token.balanceOf.callAsync(takerAddress); + makerBalance = await erc20Token.balanceOf(makerAddress).callAsync(); + takerBalance = await erc20Token.balanceOf(takerAddress).callAsync(); expect(takerBalance).to.bignumber.equal(new BigNumber(10).multipliedBy(ONE_ETH_IN_WEI)); expect(makerBalance).to.bignumber.equal(constants.ZERO_AMOUNT); }); diff --git a/packages/asset-swapper/test/swap_quote_consumer_test.ts b/packages/asset-swapper/test/swap_quote_consumer_test.ts index 11cc89af3c..d7682ebbd8 100644 --- a/packages/asset-swapper/test/swap_quote_consumer_test.ts +++ b/packages/asset-swapper/test/swap_quote_consumer_test.ts @@ -60,9 +60,9 @@ describe('SwapQuoteConsumer', () => { [makerTokenAddress, takerTokenAddress] = tokenUtils.getDummyERC20TokenAddresses(); erc20Token = new ERC20TokenContract(makerTokenAddress, provider); [makerAssetData, takerAssetData, wethAssetData] = [ - await contractWrappers.devUtils.encodeERC20AssetData.callAsync(makerTokenAddress), - await contractWrappers.devUtils.encodeERC20AssetData.callAsync(takerTokenAddress), - await contractWrappers.devUtils.encodeERC20AssetData.callAsync(contractAddresses.etherToken), + await contractWrappers.devUtils.encodeERC20AssetData(makerTokenAddress).callAsync(), + await contractWrappers.devUtils.encodeERC20AssetData(takerTokenAddress).callAsync(), + await contractWrappers.devUtils.encodeERC20AssetData(contractAddresses.etherToken).callAsync(), ]; }); after(async () => { @@ -78,11 +78,11 @@ describe('SwapQuoteConsumer', () => { new BigNumber(0), ); - await erc20Token.transfer.sendTransactionAsync(makerAddress, totalFillableAmount, { + await erc20Token.transfer(makerAddress, totalFillableAmount).sendTransactionAsync({ from: coinbaseAddress, }); - await erc20Token.approve.sendTransactionAsync(erc20ProxyAddress, UNLIMITED_ALLOWANCE, { + await erc20Token.approve(erc20ProxyAddress, UNLIMITED_ALLOWANCE).sendTransactionAsync({ from: makerAddress, }); orders = await getSignedOrdersWithNoFeesAsync( @@ -116,24 +116,24 @@ describe('SwapQuoteConsumer', () => { // * Does not test the validity of the state change performed by the forwarder smart contract // */ // it('should perform an asset swap with Forwarder contract when provided corresponding useExtensionContract option', async () => { - // let makerBalance = await erc20TokenContract.balanceOf.callAsync(makerAddress); - // let takerBalance = await erc20TokenContract.balanceOf.callAsync(takerAddress); + // let makerBalance = await erc20TokenContract.balanceOf(makerAddress).callAsync(); + // let takerBalance = await erc20TokenContract.balanceOf(takerAddress).callAsync(); // expect(makerBalance).to.bignumber.equal(new BigNumber(10).multipliedBy(ONE_ETH_IN_WEI)); // expect(takerBalance).to.bignumber.equal(constants.ZERO_AMOUNT); // await swapQuoteConsumer.executeSwapQuoteOrThrowAsync(marketSellSwapQuote, { takerAddress, useExtensionContract: ConsumerType.Forwarder }); - // makerBalance = await erc20TokenContract.balanceOf.callAsync(makerAddress); - // takerBalance = await erc20TokenContract.balanceOf.callAsync(takerAddress); + // makerBalance = await erc20TokenContract.balanceOf(makerAddress).callAsync(); + // takerBalance = await erc20TokenContract.balanceOf(takerAddress).callAsync(); // expect(takerBalance).to.bignumber.equal(new BigNumber(10).multipliedBy(ONE_ETH_IN_WEI)); // expect(makerBalance).to.bignumber.equal(constants.ZERO_AMOUNT); // }); // it('should perform an asset swap with Exchange contract when provided corresponding useExtensionContract option', async () => { - // let makerBalance = await erc20TokenContract.balanceOf.callAsync(makerAddress); - // let takerBalance = await erc20TokenContract.balanceOf.callAsync(takerAddress); + // let makerBalance = await erc20TokenContract.balanceOf(makerAddress).callAsync(); + // let takerBalance = await erc20TokenContract.balanceOf(takerAddress).callAsync(); // expect(makerBalance).to.bignumber.equal(new BigNumber(10).multipliedBy(ONE_ETH_IN_WEI)); // expect(takerBalance).to.bignumber.equal(constants.ZERO_AMOUNT); // await swapQuoteConsumer.executeSwapQuoteOrThrowAsync(marketBuySwapQuote, { takerAddress }); - // makerBalance = await erc20TokenContract.balanceOf.callAsync(makerAddress); - // takerBalance = await erc20TokenContract.balanceOf.callAsync(takerAddress); + // makerBalance = await erc20TokenContract.balanceOf(makerAddress).callAsync(); + // takerBalance = await erc20TokenContract.balanceOf(takerAddress).callAsync(); // expect(takerBalance).to.bignumber.equal(new BigNumber(10).multipliedBy(ONE_ETH_IN_WEI)); // expect(makerBalance).to.bignumber.equal(constants.ZERO_AMOUNT); // }); diff --git a/packages/asset-swapper/test/swap_quote_consumer_utils_test.ts b/packages/asset-swapper/test/swap_quote_consumer_utils_test.ts index b5e782c96a..9252e014fc 100644 --- a/packages/asset-swapper/test/swap_quote_consumer_utils_test.ts +++ b/packages/asset-swapper/test/swap_quote_consumer_utils_test.ts @@ -52,9 +52,9 @@ describe('swapQuoteConsumerUtils', () => { [takerAddress, makerAddress] = userAddresses; [makerTokenAddress, takerTokenAddress] = tokenUtils.getDummyERC20TokenAddresses(); [makerAssetData, takerAssetData, wethAssetData] = [ - await contractWrappers.devUtils.encodeERC20AssetData.callAsync(makerTokenAddress), - await contractWrappers.devUtils.encodeERC20AssetData.callAsync(takerTokenAddress), - await contractWrappers.devUtils.encodeERC20AssetData.callAsync(contractAddresses.etherToken), + await contractWrappers.devUtils.encodeERC20AssetData(makerTokenAddress).callAsync(), + await contractWrappers.devUtils.encodeERC20AssetData(takerTokenAddress).callAsync(), + await contractWrappers.devUtils.encodeERC20AssetData(contractAddresses.etherToken).callAsync(), ]; swapQuoteConsumer = new SwapQuoteConsumer(provider, { @@ -145,7 +145,7 @@ describe('swapQuoteConsumerUtils', () => { }); it('should return exchange consumer if takerAsset is wEth and taker has enough weth', async () => { const etherInWei = new BigNumber(20).multipliedBy(ONE_ETH_IN_WEI); - await contractWrappers.weth9.deposit.sendTransactionAsync({ value: etherInWei, from: takerAddress }); + await contractWrappers.weth9.deposit({ value: etherInWei, from: takerAddress }).sendTransactionAsync(); const extensionContractType = await swapQuoteConsumer.getOptimalExtensionContractTypeAsync( forwarderSwapQuote, { takerAddress }, @@ -154,7 +154,7 @@ describe('swapQuoteConsumerUtils', () => { }); it('should return forwarder consumer if takerAsset is wEth and takerAddress has no available balance in either weth or eth (defaulting behavior)', async () => { const etherInWei = new BigNumber(50).multipliedBy(ONE_ETH_IN_WEI); - await contractWrappers.weth9.deposit.sendTransactionAsync({ value: etherInWei, from: takerAddress }); + await contractWrappers.weth9.deposit({ value: etherInWei, from: takerAddress }).sendTransactionAsync(); const extensionContractType = await swapQuoteConsumer.getOptimalExtensionContractTypeAsync( largeForwarderSwapQuote, { takerAddress }, diff --git a/packages/contract-wrappers/src/coordinator_wrapper.ts b/packages/contract-wrappers/src/coordinator_wrapper.ts index 40250ba9cb..d95cf0f65e 100644 --- a/packages/contract-wrappers/src/coordinator_wrapper.ts +++ b/packages/contract-wrappers/src/coordinator_wrapper.ts @@ -543,13 +543,15 @@ export class CoordinatorWrapper { assert.isHexString('approvalSignature', approvalSignature); } - await this._contractInstance.assertValidCoordinatorApprovals.callAsync( - transaction, - txOrigin, - transactionSignature, - approvalExpirationTimeSeconds, - approvalSignatures, - ); + await this._contractInstance + .assertValidCoordinatorApprovals( + transaction, + txOrigin, + transactionSignature, + approvalExpirationTimeSeconds, + approvalSignatures, + ) + .callAsync(); } /** @@ -561,7 +563,7 @@ export class CoordinatorWrapper { public async getSignerAddressAsync(hash: string, signature: string): Promise { assert.isHexString('hash', hash); assert.isHexString('signature', signature); - const signerAddress = await this._contractInstance.getSignerAddress.callAsync(hash, signature); + const signerAddress = await this._contractInstance.getSignerAddress(hash, signature).callAsync(); return signerAddress; } @@ -665,7 +667,7 @@ export class CoordinatorWrapper { feeRecipient: string, registryInstance: CoordinatorRegistryContract, ): Promise { - const coordinatorOperatorEndpoint = await registryInstance.getCoordinatorEndpoint.callAsync(feeRecipient); + const coordinatorOperatorEndpoint = await registryInstance.getCoordinatorEndpoint(feeRecipient).callAsync(); if (coordinatorOperatorEndpoint === '' || coordinatorOperatorEndpoint === undefined) { throw new Error( `No Coordinator server endpoint found in Coordinator Registry for feeRecipientAddress: ${feeRecipient}. Registry contract address: ${ @@ -744,33 +746,35 @@ export class CoordinatorWrapper { orderTransactionOpts: OrderTransactionOpts, ): Promise { if (orderTransactionOpts.shouldValidate) { - await this._contractInstance.executeTransaction.callAsync( - transaction, - txOrigin, - transactionSignature, - approvalExpirationTimeSeconds, - approvalSignatures, - { + await this._contractInstance + .executeTransaction( + transaction, + txOrigin, + transactionSignature, + approvalExpirationTimeSeconds, + approvalSignatures, + ) + .callAsync({ from: txOrigin, gas: orderTransactionOpts.gasLimit, gasPrice: orderTransactionOpts.gasPrice, nonce: orderTransactionOpts.nonce, - }, - ); + }); } - const txHash = await this._contractInstance.executeTransaction.sendTransactionAsync( - transaction, - txOrigin, - transactionSignature, - approvalExpirationTimeSeconds, - approvalSignatures, - { + const txHash = await this._contractInstance + .executeTransaction( + transaction, + txOrigin, + transactionSignature, + approvalExpirationTimeSeconds, + approvalSignatures, + ) + .sendTransactionAsync({ from: txOrigin, gas: orderTransactionOpts.gasLimit, gasPrice: orderTransactionOpts.gasPrice, nonce: orderTransactionOpts.nonce, - }, - ); + }); return txHash; } diff --git a/packages/contract-wrappers/src/index.ts b/packages/contract-wrappers/src/index.ts index e3576f9f49..743d3b46e2 100644 --- a/packages/contract-wrappers/src/index.ts +++ b/packages/contract-wrappers/src/index.ts @@ -154,8 +154,6 @@ export { SignedZeroExTransaction, SimpleEvmOutput, SimpleEvmBytecodeOutput, - AwaitTransactionSuccessOpts, - SendTransactionOpts, EIP712DomainWithDefaultSchema, EventCallback, DecodedLogEvent, @@ -163,3 +161,4 @@ export { } from '@0x/types'; export { AbiDecoder, DecodedCalldata } from '@0x/utils'; +export { AwaitTransactionSuccessOpts, SendTransactionOpts } from '@0x/base-contract'; diff --git a/packages/contract-wrappers/src/utils/getAbiEncodedTransactionData.ts b/packages/contract-wrappers/src/utils/getAbiEncodedTransactionData.ts index 79ebd8833b..cb6e5f460e 100644 --- a/packages/contract-wrappers/src/utils/getAbiEncodedTransactionData.ts +++ b/packages/contract-wrappers/src/utils/getAbiEncodedTransactionData.ts @@ -16,7 +16,7 @@ export function getAbiEncodedTransactionData( getABIEncodedTransactionData: (...args: any[]) => string; }; if (method.getABIEncodedTransactionData) { - const abiEncodedData = method.getABIEncodedTransactionData(...params); + const abiEncodedData = method(...params).getABIEncodedTransactionData(); return abiEncodedData; } else { return ''; diff --git a/packages/contract-wrappers/test/calldata_decoder_test.ts b/packages/contract-wrappers/test/calldata_decoder_test.ts index e205e63725..b8d1e7808d 100644 --- a/packages/contract-wrappers/test/calldata_decoder_test.ts +++ b/packages/contract-wrappers/test/calldata_decoder_test.ts @@ -56,48 +56,48 @@ describe('ABI Decoding Calldata', () => { // Values are arbitrary, with the exception of maker addresses (generated above). orderLeft = { makerAddress: makerAddressLeft, - makerAssetData: await contractWrappers.devUtils.encodeERC20AssetData.callAsync( - defaultERC20MakerAssetAddress, - ), + makerAssetData: await contractWrappers.devUtils + .encodeERC20AssetData(defaultERC20MakerAssetAddress) + .callAsync(), makerAssetAmount: new BigNumber(10), takerAddress: '0x0000000000000000000000000000000000000000', - takerAssetData: await contractWrappers.devUtils.encodeERC20AssetData.callAsync( - defaultERC20MakerAssetAddress, - ), + takerAssetData: await contractWrappers.devUtils + .encodeERC20AssetData(defaultERC20MakerAssetAddress) + .callAsync(), takerAssetAmount: new BigNumber(1), feeRecipientAddress, makerFee: new BigNumber(0), takerFee: new BigNumber(0), - makerFeeAssetData: await contractWrappers.devUtils.encodeERC20AssetData.callAsync( - defaultERC20MakerAssetAddress, - ), - takerFeeAssetData: await contractWrappers.devUtils.encodeERC20AssetData.callAsync( - defaultERC20MakerAssetAddress, - ), + makerFeeAssetData: await contractWrappers.devUtils + .encodeERC20AssetData(defaultERC20MakerAssetAddress) + .callAsync(), + takerFeeAssetData: await contractWrappers.devUtils + .encodeERC20AssetData(defaultERC20MakerAssetAddress) + .callAsync(), senderAddress: '0x0000000000000000000000000000000000000000', expirationTimeSeconds: new BigNumber(1549498915), salt: new BigNumber(217), }; orderRight = { makerAddress: makerAddressRight, - makerAssetData: await contractWrappers.devUtils.encodeERC20AssetData.callAsync( - defaultERC20MakerAssetAddress, - ), + makerAssetData: await contractWrappers.devUtils + .encodeERC20AssetData(defaultERC20MakerAssetAddress) + .callAsync(), makerAssetAmount: new BigNumber(1), takerAddress: '0x0000000000000000000000000000000000000000', - takerAssetData: await contractWrappers.devUtils.encodeERC20AssetData.callAsync( - defaultERC20MakerAssetAddress, - ), + takerAssetData: await contractWrappers.devUtils + .encodeERC20AssetData(defaultERC20MakerAssetAddress) + .callAsync(), takerAssetAmount: new BigNumber(8), feeRecipientAddress, makerFee: new BigNumber(0), takerFee: new BigNumber(0), - makerFeeAssetData: await contractWrappers.devUtils.encodeERC20AssetData.callAsync( - defaultERC20MakerAssetAddress, - ), - takerFeeAssetData: await contractWrappers.devUtils.encodeERC20AssetData.callAsync( - defaultERC20MakerAssetAddress, - ), + makerFeeAssetData: await contractWrappers.devUtils + .encodeERC20AssetData(defaultERC20MakerAssetAddress) + .callAsync(), + takerFeeAssetData: await contractWrappers.devUtils + .encodeERC20AssetData(defaultERC20MakerAssetAddress) + .callAsync(), senderAddress: '0x0000000000000000000000000000000000000000', expirationTimeSeconds: new BigNumber(1549498915), salt: new BigNumber(50010), diff --git a/packages/contract-wrappers/test/coordinator_wrapper_test.ts b/packages/contract-wrappers/test/coordinator_wrapper_test.ts index 6589f2ce3c..ff459a4b5a 100644 --- a/packages/contract-wrappers/test/coordinator_wrapper_test.ts +++ b/packages/contract-wrappers/test/coordinator_wrapper_test.ts @@ -85,9 +85,9 @@ describe.skip('CoordinatorWrapper', () => { [makerTokenAddress, takerTokenAddress] = tokenUtils.getDummyERC20TokenAddresses(); feeTokenAddress = contractAddresses.zrxToken; [makerAssetData, takerAssetData, feeAssetData] = [ - await contractWrappers.devUtils.encodeERC20AssetData.callAsync(makerTokenAddress), - await contractWrappers.devUtils.encodeERC20AssetData.callAsync(takerTokenAddress), - await contractWrappers.devUtils.encodeERC20AssetData.callAsync(feeTokenAddress), + await contractWrappers.devUtils.encodeERC20AssetData(makerTokenAddress).callAsync(), + await contractWrappers.devUtils.encodeERC20AssetData(takerTokenAddress).callAsync(), + await contractWrappers.devUtils.encodeERC20AssetData(feeTokenAddress).callAsync(), ]; // Configure order defaults @@ -190,32 +190,29 @@ describe.skip('CoordinatorWrapper', () => { // register coordinator server await web3Wrapper.awaitTransactionSuccessAsync( - await coordinatorRegistryInstance.setCoordinatorEndpoint.sendTransactionAsync( - `${coordinatorEndpoint}${coordinatorPort}`, - { + await coordinatorRegistryInstance + .setCoordinatorEndpoint(`${coordinatorEndpoint}${coordinatorPort}`) + .sendTransactionAsync({ from: feeRecipientAddressOne, - }, - ), + }), constants.AWAIT_TRANSACTION_MINED_MS, ); await web3Wrapper.awaitTransactionSuccessAsync( - await coordinatorRegistryInstance.setCoordinatorEndpoint.sendTransactionAsync( - `${coordinatorEndpoint}${coordinatorPort}`, - { + await coordinatorRegistryInstance + .setCoordinatorEndpoint(`${coordinatorEndpoint}${coordinatorPort}`) + .sendTransactionAsync({ from: feeRecipientAddressTwo, - }, - ), + }), constants.AWAIT_TRANSACTION_MINED_MS, ); // register another coordinator server await web3Wrapper.awaitTransactionSuccessAsync( - await coordinatorRegistryInstance.setCoordinatorEndpoint.sendTransactionAsync( - `${coordinatorEndpoint}${anotherCoordinatorPort}`, - { + await coordinatorRegistryInstance + .setCoordinatorEndpoint(`${coordinatorEndpoint}${anotherCoordinatorPort}`) + .sendTransactionAsync({ from: feeRecipientAddressThree, - }, - ), + }), constants.AWAIT_TRANSACTION_MINED_MS, ); }); @@ -238,12 +235,12 @@ describe.skip('CoordinatorWrapper', () => { }); describe('test setup', () => { it('should have coordinator registry which returns an endpoint', async () => { - const setCoordinatorEndpoint = await coordinatorRegistryInstance.getCoordinatorEndpoint.callAsync( - feeRecipientAddressOne, - ); - const anotherSetCoordinatorEndpoint = await coordinatorRegistryInstance.getCoordinatorEndpoint.callAsync( - feeRecipientAddressThree, - ); + const setCoordinatorEndpoint = await coordinatorRegistryInstance + .getCoordinatorEndpoint(feeRecipientAddressOne) + .callAsync(); + const anotherSetCoordinatorEndpoint = await coordinatorRegistryInstance + .getCoordinatorEndpoint(feeRecipientAddressThree) + .callAsync(); expect(setCoordinatorEndpoint).to.be.equal(`${coordinatorEndpoint}${coordinatorPort}`); expect(anotherSetCoordinatorEndpoint).to.be.equal(`${coordinatorEndpoint}${anotherCoordinatorPort}`); }); @@ -386,10 +383,9 @@ describe.skip('CoordinatorWrapper', () => { txHash = await contractWrappers.coordinator.hardCancelOrdersUpToAsync(targetOrderEpoch, makerAddress); await web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS); - const orderEpoch = await contractWrappers.exchange.orderEpoch.callAsync( - makerAddress, - contractWrappers.coordinator.address, - ); + const orderEpoch = await contractWrappers.exchange + .orderEpoch(makerAddress, contractWrappers.coordinator.address) + .callAsync(); expect(orderEpoch).to.be.bignumber.equal(targetOrderEpoch.plus(1)); }); }); @@ -406,7 +402,7 @@ describe.skip('CoordinatorWrapper', () => { }); it('should throw error when coordinator endpoint is malformed', async () => { await web3Wrapper.awaitTransactionSuccessAsync( - await coordinatorRegistryInstance.setCoordinatorEndpoint.sendTransactionAsync('localhost', { + await coordinatorRegistryInstance.setCoordinatorEndpoint('localhost').sendTransactionAsync({ from: feeRecipientAddressFour, }), constants.AWAIT_TRANSACTION_MINED_MS, diff --git a/packages/contract-wrappers/test/utils/token_utils.ts b/packages/contract-wrappers/test/utils/token_utils.ts index 903fa5b09d..cf98bddb6a 100644 --- a/packages/contract-wrappers/test/utils/token_utils.ts +++ b/packages/contract-wrappers/test/utils/token_utils.ts @@ -28,7 +28,7 @@ export const tokenUtils = { async mintDummyERC721Async(address: string, tokenOwner: string): Promise { const erc721 = new DummyERC721TokenContract(address, provider, txDefaults); const tokenId = generatePseudoRandomSalt(); - const txHash = await erc721.mint.sendTransactionAsync(tokenOwner, tokenId); + const txHash = await erc721.mint(tokenOwner, tokenId).sendTransactionAsync(); web3Wrapper.awaitTransactionSuccessAsync(txHash); return tokenId; }, diff --git a/packages/migrations/src/migration.ts b/packages/migrations/src/migration.ts index 87982e0086..7bd22f948f 100644 --- a/packages/migrations/src/migration.ts +++ b/packages/migrations/src/migration.ts @@ -143,26 +143,26 @@ export async function runMigrationsAsync( artifacts, ); - await erc20Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(exchange.address, txDefaults); - await erc721Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(exchange.address, txDefaults); - await erc1155Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(exchange.address, txDefaults); - await multiAssetProxy.addAuthorizedAddress.awaitTransactionSuccessAsync(exchange.address, txDefaults); + await erc20Proxy.addAuthorizedAddress(exchange.address).awaitTransactionSuccessAsync(txDefaults); + await erc721Proxy.addAuthorizedAddress(exchange.address).awaitTransactionSuccessAsync(txDefaults); + await erc1155Proxy.addAuthorizedAddress(exchange.address).awaitTransactionSuccessAsync(txDefaults); + await multiAssetProxy.addAuthorizedAddress(exchange.address).awaitTransactionSuccessAsync(txDefaults); // MultiAssetProxy - await erc20Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(multiAssetProxy.address, txDefaults); - await erc721Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(multiAssetProxy.address, txDefaults); - await erc1155Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(multiAssetProxy.address, txDefaults); - await multiAssetProxy.registerAssetProxy.awaitTransactionSuccessAsync(erc20Proxy.address, txDefaults); - await multiAssetProxy.registerAssetProxy.awaitTransactionSuccessAsync(erc721Proxy.address, txDefaults); - await multiAssetProxy.registerAssetProxy.awaitTransactionSuccessAsync(erc1155Proxy.address, txDefaults); - await multiAssetProxy.registerAssetProxy.awaitTransactionSuccessAsync(staticCallProxy.address, txDefaults); + await erc20Proxy.addAuthorizedAddress(multiAssetProxy.address).awaitTransactionSuccessAsync(txDefaults); + await erc721Proxy.addAuthorizedAddress(multiAssetProxy.address).awaitTransactionSuccessAsync(txDefaults); + await erc1155Proxy.addAuthorizedAddress(multiAssetProxy.address).awaitTransactionSuccessAsync(txDefaults); + await multiAssetProxy.registerAssetProxy(erc20Proxy.address).awaitTransactionSuccessAsync(txDefaults); + await multiAssetProxy.registerAssetProxy(erc721Proxy.address).awaitTransactionSuccessAsync(txDefaults); + await multiAssetProxy.registerAssetProxy(erc1155Proxy.address).awaitTransactionSuccessAsync(txDefaults); + await multiAssetProxy.registerAssetProxy(staticCallProxy.address).awaitTransactionSuccessAsync(txDefaults); // Register the Asset Proxies to the Exchange - await exchange.registerAssetProxy.awaitTransactionSuccessAsync(erc20Proxy.address, txDefaults); - await exchange.registerAssetProxy.awaitTransactionSuccessAsync(erc721Proxy.address, txDefaults); - await exchange.registerAssetProxy.awaitTransactionSuccessAsync(erc1155Proxy.address, txDefaults); - await exchange.registerAssetProxy.awaitTransactionSuccessAsync(multiAssetProxy.address, txDefaults); - await exchange.registerAssetProxy.awaitTransactionSuccessAsync(staticCallProxy.address, txDefaults); + await exchange.registerAssetProxy(erc20Proxy.address).awaitTransactionSuccessAsync(txDefaults); + await exchange.registerAssetProxy(erc721Proxy.address).awaitTransactionSuccessAsync(txDefaults); + await exchange.registerAssetProxy(erc1155Proxy.address).awaitTransactionSuccessAsync(txDefaults); + await exchange.registerAssetProxy(multiAssetProxy.address).awaitTransactionSuccessAsync(txDefaults); + await exchange.registerAssetProxy(staticCallProxy.address).awaitTransactionSuccessAsync(txDefaults); // Forwarder const forwarder = await wrappers.ForwarderContract.deployFrom0xArtifactAsync( @@ -217,16 +217,16 @@ export async function runMigrationsAsync( // // Transfer Ownership to the Asset Proxy Owner // await web3Wrapper.awaitTransactionSuccessAsync( - // await erc20Proxy.transferOwnership.sendTransactionAsync(assetProxyOwner.address, txDefaults), + // await erc20Proxy.transferOwnership(assetProxyOwner.address).sendTransactionAsync(txDefaults), // ); // await web3Wrapper.awaitTransactionSuccessAsync( - // await erc721Proxy.transferOwnership.sendTransactionAsync(assetProxyOwner.address, txDefaults), + // await erc721Proxy.transferOwnership(assetProxyOwner.address).sendTransactionAsync(txDefaults), // ); // await web3Wrapper.awaitTransactionSuccessAsync( - // await erc1155Proxy.transferOwnership.sendTransactionAsync(assetProxyOwner.address, txDefaults), + // await erc1155Proxy.transferOwnership(assetProxyOwner.address).sendTransactionAsync(txDefaults), // ); // await web3Wrapper.awaitTransactionSuccessAsync( - // await multiAssetProxy.transferOwnership.sendTransactionAsync(assetProxyOwner.address, txDefaults), + // await multiAssetProxy.transferOwnership(assetProxyOwner.address).sendTransactionAsync(txDefaults), // ); // Fake the above transactions so our nonce increases and we result with the same addresses @@ -237,9 +237,9 @@ export async function runMigrationsAsync( } // Fund the Forwarder with ZRX - const zrxDecimals = await zrxToken.decimals.callAsync(); + const zrxDecimals = await zrxToken.decimals().callAsync(); const zrxForwarderAmount = Web3Wrapper.toBaseUnitAmount(new BigNumber(5000), zrxDecimals); - await zrxToken.transfer.awaitTransactionSuccessAsync(forwarder.address, zrxForwarderAmount, txDefaults); + await zrxToken.transfer(forwarder.address, zrxForwarderAmount).awaitTransactionSuccessAsync(txDefaults); // CoordinatorRegistry const coordinatorRegistry = await wrappers.CoordinatorRegistryContract.deployFrom0xArtifactAsync( diff --git a/packages/migrations/src/test_contract_configs.ts b/packages/migrations/src/test_contract_configs.ts index 9c56e584b7..fcaa16e6c6 100644 --- a/packages/migrations/src/test_contract_configs.ts +++ b/packages/migrations/src/test_contract_configs.ts @@ -45,30 +45,30 @@ async function testContractConfigsAsync(provider: SupportedProvider): Promise { - const exchangeOwner = await exchangeV2.owner.callAsync(); + const exchangeOwner = await exchangeV2.owner().callAsync(); warnIfMismatch(exchangeOwner, governor.address, 'Unexpected ExchangeV2 owner'); - const registeredERC20Proxy = await exchangeV2.getAssetProxy.callAsync(AssetProxyId.ERC20); + const registeredERC20Proxy = await exchangeV2.getAssetProxy(AssetProxyId.ERC20).callAsync(); warnIfMismatch(registeredERC20Proxy, erc20Proxy.address, 'Unexpected ERC20Proxy registered in ExchangeV2'); - const registeredERC721Proxy = await exchangeV2.getAssetProxy.callAsync(AssetProxyId.ERC721); + const registeredERC721Proxy = await exchangeV2.getAssetProxy(AssetProxyId.ERC721).callAsync(); warnIfMismatch(registeredERC721Proxy, erc721Proxy.address, 'Unexpected ERC721Proxy registered in ExchangeV2'); - const registeredERC1155Proxy = await exchangeV2.getAssetProxy.callAsync(AssetProxyId.ERC1155); + const registeredERC1155Proxy = await exchangeV2.getAssetProxy(AssetProxyId.ERC1155).callAsync(); warnIfMismatch( registeredERC1155Proxy, erc1155Proxy.address, 'Unexpected ERC1155Proxy registered in ExchangeV2', ); - const registeredMultiAssetProxy = await exchangeV2.getAssetProxy.callAsync(AssetProxyId.MultiAsset); + const registeredMultiAssetProxy = await exchangeV2.getAssetProxy(AssetProxyId.MultiAsset).callAsync(); warnIfMismatch( registeredMultiAssetProxy, multiAssetProxy.address, 'Unexpected MultiAssetProxy registered in ExchangeV2', ); - const registeredStaticCallProxy = await exchangeV2.getAssetProxy.callAsync(AssetProxyId.StaticCall); + const registeredStaticCallProxy = await exchangeV2.getAssetProxy(AssetProxyId.StaticCall).callAsync(); warnIfMismatch( registeredStaticCallProxy, addresses.staticCallProxy, @@ -77,158 +77,164 @@ async function testContractConfigsAsync(provider: SupportedProvider): Promise { - const exchangeOwner = await exchange.owner.callAsync(); + const exchangeOwner = await exchange.owner().callAsync(); warnIfMismatch(exchangeOwner, governor.address, 'Unexpected Exchange owner'); - const registeredERC20Proxy = await exchange.getAssetProxy.callAsync(AssetProxyId.ERC20); + const registeredERC20Proxy = await exchange.getAssetProxy(AssetProxyId.ERC20).callAsync(); warnIfMismatch(registeredERC20Proxy, erc20Proxy.address, 'Unexpected ERC20Proxy registered in Exchange'); - const registeredERC721Proxy = await exchange.getAssetProxy.callAsync(AssetProxyId.ERC721); + const registeredERC721Proxy = await exchange.getAssetProxy(AssetProxyId.ERC721).callAsync(); warnIfMismatch(registeredERC721Proxy, erc721Proxy.address, 'Unexpected ERC721Proxy registered in Exchange'); - const registeredERC1155Proxy = await exchange.getAssetProxy.callAsync(AssetProxyId.ERC1155); + const registeredERC1155Proxy = await exchange.getAssetProxy(AssetProxyId.ERC1155).callAsync(); warnIfMismatch(registeredERC1155Proxy, erc1155Proxy.address, 'Unexpected ERC1155Proxy registered in Exchange'); - const registeredMultiAssetProxy = await exchange.getAssetProxy.callAsync(AssetProxyId.MultiAsset); + const registeredMultiAssetProxy = await exchange.getAssetProxy(AssetProxyId.MultiAsset).callAsync(); warnIfMismatch( registeredMultiAssetProxy, multiAssetProxy.address, 'Unexpected MultiAssetProxy registered in Exchange', ); - const registeredStaticCallProxy = await exchange.getAssetProxy.callAsync(AssetProxyId.StaticCall); + const registeredStaticCallProxy = await exchange.getAssetProxy(AssetProxyId.StaticCall).callAsync(); warnIfMismatch( registeredStaticCallProxy, addresses.staticCallProxy, 'Unexpected StaticCallProxy registered in Exchange', ); - const protocolFeeCollector = await exchange.protocolFeeCollector.callAsync(); + const protocolFeeCollector = await exchange.protocolFeeCollector().callAsync(); warnIfMismatch(protocolFeeCollector, addresses.stakingProxy, 'Unexpected StakingProxy attached to Exchange'); - const protocolFeeMultiplier = await exchange.protocolFeeMultiplier.callAsync(); + const protocolFeeMultiplier = await exchange.protocolFeeMultiplier().callAsync(); warnIfMismatch(protocolFeeMultiplier.toString(), '150000', 'Unexpected protocolFeeMultiplier in Exchange'); } async function verifyAssetProxyConfigsAsync(): Promise { // Verify ERC20Proxy configs - const erc20ProxyOwner = await erc20Proxy.owner.callAsync(); + const erc20ProxyOwner = await erc20Proxy.owner().callAsync(); warnIfMismatch(erc20ProxyOwner, governor.address, 'Unexpected ERC20Proxy owner'); - const erc20AuthorizedAddresses = await erc20Proxy.getAuthorizedAddresses.callAsync(); + const erc20AuthorizedAddresses = await erc20Proxy.getAuthorizedAddresses().callAsync(); warnIfMismatch(erc20AuthorizedAddresses.length, 4, 'Unexpected number of authorized addresses in ERC20Proxy'); - const isExchangeV2AuthorizedInERC20Proxy = await erc20Proxy.authorized.callAsync(exchangeV2.address); + const isExchangeV2AuthorizedInERC20Proxy = await erc20Proxy.authorized(exchangeV2.address).callAsync(); warnIfMismatch(isExchangeV2AuthorizedInERC20Proxy, true, 'ExchangeV2 not authorized in ERC20Proxy'); - const isExchangeAuthorizedInERC20Proxy = await erc20Proxy.authorized.callAsync(exchange.address); + const isExchangeAuthorizedInERC20Proxy = await erc20Proxy.authorized(exchange.address).callAsync(); warnIfMismatch(isExchangeAuthorizedInERC20Proxy, true, 'Exchange not authorized in ERC20Proxy'); - const isMAPAuthorizedInER20Proxy = await erc20Proxy.authorized.callAsync(multiAssetProxy.address); + const isMAPAuthorizedInER20Proxy = await erc20Proxy.authorized(multiAssetProxy.address).callAsync(); warnIfMismatch(isMAPAuthorizedInER20Proxy, true, 'MultiAssetProxy not authorized in ERC20Proxy'); - const isZrxVaultAuthorizedInER20Proxy = await erc20Proxy.authorized.callAsync(zrxVault.address); + const isZrxVaultAuthorizedInER20Proxy = await erc20Proxy.authorized(zrxVault.address).callAsync(); warnIfMismatch(isZrxVaultAuthorizedInER20Proxy, true, 'ZrxVault not authorized in ERC20Proxy'); // Verify ERC721Proxy configs - const erc721ProxyOwner = await erc721Proxy.owner.callAsync(); + const erc721ProxyOwner = await erc721Proxy.owner().callAsync(); warnIfMismatch(erc721ProxyOwner, governor.address, 'Unexpected ERC721Proxy owner'); - const erc721AuthorizedAddresses = await erc721Proxy.getAuthorizedAddresses.callAsync(); + const erc721AuthorizedAddresses = await erc721Proxy.getAuthorizedAddresses().callAsync(); warnIfMismatch(erc721AuthorizedAddresses.length, 3, 'Unexpected number of authorized addresses in ERC721Proxy'); - const isExchangeV2AuthorizedInERC721Proxy = await erc721Proxy.authorized.callAsync(exchangeV2.address); + const isExchangeV2AuthorizedInERC721Proxy = await erc721Proxy.authorized(exchangeV2.address).callAsync(); warnIfMismatch(isExchangeV2AuthorizedInERC721Proxy, true, 'ExchangeV2 not authorized in ERC721Proxy'); - const isExchangeAuthorizedInERC721Proxy = await erc721Proxy.authorized.callAsync(exchange.address); + const isExchangeAuthorizedInERC721Proxy = await erc721Proxy.authorized(exchange.address).callAsync(); warnIfMismatch(isExchangeAuthorizedInERC721Proxy, true, 'Exchange not authorized in ERC721Proxy'); - const isMAPAuthorizedInER721Proxy = await erc721Proxy.authorized.callAsync(multiAssetProxy.address); + const isMAPAuthorizedInER721Proxy = await erc721Proxy.authorized(multiAssetProxy.address).callAsync(); warnIfMismatch(isMAPAuthorizedInER721Proxy, true, 'MultiAssetProxy not authorized in ERC721Proxy'); // Verify ERC1155Proxy configs - const erc1155ProxyOwner = await erc1155Proxy.owner.callAsync(); + const erc1155ProxyOwner = await erc1155Proxy.owner().callAsync(); warnIfMismatch(erc1155ProxyOwner, governor.address, 'Unexpected ERC1155Proxy owner'); - const erc1155AuthorizedAddresses = await erc1155Proxy.getAuthorizedAddresses.callAsync(); + const erc1155AuthorizedAddresses = await erc1155Proxy.getAuthorizedAddresses().callAsync(); warnIfMismatch( erc1155AuthorizedAddresses.length, 3, 'Unexpected number of authorized addresses in ERC1155Proxy', ); - const isExchangeV2AuthorizedInERC1155Proxy = await erc1155Proxy.authorized.callAsync(exchangeV2.address); + const isExchangeV2AuthorizedInERC1155Proxy = await erc1155Proxy.authorized(exchangeV2.address).callAsync(); warnIfMismatch(isExchangeV2AuthorizedInERC1155Proxy, true, 'ExchangeV2 not authorized in ERC1155Proxy'); - const isExchangeAuthorizedInERC1155Proxy = await erc1155Proxy.authorized.callAsync(exchange.address); + const isExchangeAuthorizedInERC1155Proxy = await erc1155Proxy.authorized(exchange.address).callAsync(); warnIfMismatch(isExchangeAuthorizedInERC1155Proxy, true, 'Exchange not authorized in ERC1155Proxy'); - const isMAPAuthorizedInERC1155Proxy = await erc1155Proxy.authorized.callAsync(multiAssetProxy.address); + const isMAPAuthorizedInERC1155Proxy = await erc1155Proxy.authorized(multiAssetProxy.address).callAsync(); warnIfMismatch(isMAPAuthorizedInERC1155Proxy, true, 'MultiAssetProxy not authorized in ERC1155Proxy'); // Verify ERC20BridgeProxy configs - const erc20BridgeProxyOwner = await erc20BridgeProxy.owner.callAsync(); + const erc20BridgeProxyOwner = await erc20BridgeProxy.owner().callAsync(); warnIfMismatch(erc20BridgeProxyOwner, governor.address, 'Unexpected ERC20BridgeProxy owner'); - const erc20BridgeAuthorizedAddresses = await erc20BridgeProxy.getAuthorizedAddresses.callAsync(); + const erc20BridgeAuthorizedAddresses = await erc20BridgeProxy.getAuthorizedAddresses().callAsync(); warnIfMismatch( erc20BridgeAuthorizedAddresses.length, 2, 'Unexpected number of authorized addresses in ERC20BridgeProxy', ); - const isExchangeAuthorizedInERC20BridgeProxy = await erc20BridgeProxy.authorized.callAsync(exchange.address); + const isExchangeAuthorizedInERC20BridgeProxy = await erc20BridgeProxy.authorized(exchange.address).callAsync(); warnIfMismatch(isExchangeAuthorizedInERC20BridgeProxy, true, 'Exchange not authorized in ERC20BridgeProxy'); - const isMAPAuthorizedInERC20BridgeProxy = await erc20BridgeProxy.authorized.callAsync(multiAssetProxy.address); + const isMAPAuthorizedInERC20BridgeProxy = await erc20BridgeProxy + .authorized(multiAssetProxy.address) + .callAsync(); warnIfMismatch(isMAPAuthorizedInERC20BridgeProxy, true, 'MultiAssetProxy not authorized in ERC20BridgeProxy'); // Verify MultiAssetProxy configs - const multiAssetProxyOwner = await multiAssetProxy.owner.callAsync(); + const multiAssetProxyOwner = await multiAssetProxy.owner().callAsync(); warnIfMismatch(multiAssetProxyOwner, governor.address, 'Unexpected MultiAssetProxy owner'); - const multiAssetProxyAuthorizedAddresses = await multiAssetProxy.getAuthorizedAddresses.callAsync(); + const multiAssetProxyAuthorizedAddresses = await multiAssetProxy.getAuthorizedAddresses().callAsync(); warnIfMismatch( multiAssetProxyAuthorizedAddresses.length, 2, 'Unexpected number of authorized addresses in MultiAssetProxy', ); - const isExchangeV2AuthorizedInMultiAssetProxy = await multiAssetProxy.authorized.callAsync(exchangeV2.address); + const isExchangeV2AuthorizedInMultiAssetProxy = await multiAssetProxy + .authorized(exchangeV2.address) + .callAsync(); warnIfMismatch(isExchangeV2AuthorizedInMultiAssetProxy, true, 'ExchangeV2 not authorized in MultiAssetProxy'); - const isExchangeAuthorizedInMultiAssetProxy = await multiAssetProxy.authorized.callAsync(exchange.address); + const isExchangeAuthorizedInMultiAssetProxy = await multiAssetProxy.authorized(exchange.address).callAsync(); warnIfMismatch(isExchangeAuthorizedInMultiAssetProxy, true, 'Exchange not authorized in MultiAssetProxy'); - const registeredERC20ProxyInMAP = await multiAssetProxy.getAssetProxy.callAsync(AssetProxyId.ERC20); + const registeredERC20ProxyInMAP = await multiAssetProxy.getAssetProxy(AssetProxyId.ERC20).callAsync(); warnIfMismatch( registeredERC20ProxyInMAP, erc20Proxy.address, 'Unexpected ERC20Proxy registered in MultiAssetProxy', ); - const registeredERC721ProxyInMAP = await multiAssetProxy.getAssetProxy.callAsync(AssetProxyId.ERC721); + const registeredERC721ProxyInMAP = await multiAssetProxy.getAssetProxy(AssetProxyId.ERC721).callAsync(); warnIfMismatch( registeredERC721ProxyInMAP, erc721Proxy.address, 'Unexpected ERC721Proxy registered in MultiAssetProxy', ); - const registeredERC1155ProxyInMAP = await multiAssetProxy.getAssetProxy.callAsync(AssetProxyId.ERC1155); + const registeredERC1155ProxyInMAP = await multiAssetProxy.getAssetProxy(AssetProxyId.ERC1155).callAsync(); warnIfMismatch( registeredERC1155ProxyInMAP, erc1155Proxy.address, 'Unexpected ERC1155Proxy registered in MultiAssetProxy', ); - const registeredStaticCallProxyInMAP = await multiAssetProxy.getAssetProxy.callAsync(AssetProxyId.StaticCall); + const registeredStaticCallProxyInMAP = await multiAssetProxy.getAssetProxy(AssetProxyId.StaticCall).callAsync(); warnIfMismatch( registeredStaticCallProxyInMAP, addresses.staticCallProxy, 'Unexpected StaticCallProxy registered in MultiAssetProxy', ); - const registeredERC20BridgeProxyInMAP = await multiAssetProxy.getAssetProxy.callAsync(AssetProxyId.ERC20Bridge); + const registeredERC20BridgeProxyInMAP = await multiAssetProxy + .getAssetProxy(AssetProxyId.ERC20Bridge) + .callAsync(); warnIfMismatch( registeredERC20BridgeProxyInMAP, addresses.erc20BridgeProxy, @@ -237,33 +243,33 @@ async function testContractConfigsAsync(provider: SupportedProvider): Promise { - const stakingLogicAddress = await stakingProxy.stakingContract.callAsync(); + const stakingLogicAddress = await stakingProxy.stakingContract().callAsync(); warnIfMismatch(stakingLogicAddress, addresses.staking, 'Unexpected Staking contract attached to StakingProxy'); - const zrxVaultAddress = await stakingContract.getZrxVault.callAsync(); + const zrxVaultAddress = await stakingContract.getZrxVault().callAsync(); warnIfMismatch(zrxVaultAddress, addresses.zrxVault, 'Unexpected ZrxVault set in Staking contract'); - const wethAddress = await stakingContract.getWethContract.callAsync(); + const wethAddress = await stakingContract.getWethContract().callAsync(); warnIfMismatch(wethAddress, addresses.etherToken, 'Unexpected WETH contract set in Staking contract'); - const stakingProxyOwner = await stakingProxy.owner.callAsync(); + const stakingProxyOwner = await stakingProxy.owner().callAsync(); warnIfMismatch(stakingProxyOwner, addresses.zeroExGovernor, 'Unexpected StakingProxy owner'); - const zrxVaultOwner = await zrxVault.owner.callAsync(); + const zrxVaultOwner = await zrxVault.owner().callAsync(); warnIfMismatch(zrxVaultOwner, addresses.zeroExGovernor, 'Unexpected ZrxVault owner'); - const stakingProxyAuthorizedAddresses = await stakingProxy.getAuthorizedAddresses.callAsync(); + const stakingProxyAuthorizedAddresses = await stakingProxy.getAuthorizedAddresses().callAsync(); warnIfMismatch( stakingProxyAuthorizedAddresses.length, 1, 'Unexpected number of authorized addresses in StakingProxy', ); - const isGovernorAuthorizedInStakingProxy = await stakingProxy.authorized.callAsync(addresses.zeroExGovernor); + const isGovernorAuthorizedInStakingProxy = await stakingProxy.authorized(addresses.zeroExGovernor).callAsync(); warnIfMismatch(isGovernorAuthorizedInStakingProxy, true, 'ZeroExGovernor not authorized in StakingProxy'); - const zrxVaultAuthorizedAddresses = await zrxVault.getAuthorizedAddresses.callAsync(); + const zrxVaultAuthorizedAddresses = await zrxVault.getAuthorizedAddresses().callAsync(); warnIfMismatch(zrxVaultAuthorizedAddresses.length, 1, 'Unexpected number of authorized addresses in ZrxVault'); - const isGovernorAuthorizedInZrxVault = await zrxVault.authorized.callAsync(addresses.zeroExGovernor); + const isGovernorAuthorizedInZrxVault = await zrxVault.authorized(addresses.zeroExGovernor).callAsync(); warnIfMismatch(isGovernorAuthorizedInZrxVault, true, 'ZeroExGovernor not authorized in ZrxVault'); } diff --git a/packages/migrations/src/testnet_migrations.ts b/packages/migrations/src/testnet_migrations.ts index e5bf90c959..341fe02e35 100644 --- a/packages/migrations/src/testnet_migrations.ts +++ b/packages/migrations/src/testnet_migrations.ts @@ -27,15 +27,13 @@ async function submitAndExecuteTransactionAsync( destination: string, data: string, ): Promise { - const txReceipt = await governor.submitTransaction.awaitTransactionSuccessAsync( - destination, - constants.ZERO_AMOUNT, - data, - ); + const txReceipt = await governor + .submitTransaction(destination, constants.ZERO_AMOUNT, data) + .awaitTransactionSuccessAsync(); // tslint:disable-next-line:no-unnecessary-type-assertion const txId = (txReceipt.logs[0] as LogWithDecodedArgs).args.transactionId; logUtils.log(`${txId} submitted`); - await governor.executeTransaction.awaitTransactionSuccessAsync(txId); + await governor.executeTransaction(txId).awaitTransactionSuccessAsync(); logUtils.log(`${txId} executed`); } @@ -100,7 +98,7 @@ export async function runMigrationsAsync(supportedProvider: SupportedProvider, t chainId, ); - const wethAssetData = await devUtils.encodeERC20AssetData.callAsync(deployedAddresses.etherToken); + const wethAssetData = await devUtils.encodeERC20AssetData(deployedAddresses.etherToken).callAsync(); await ForwarderContract.deployFrom0xArtifactAsync( forwarderArtifacts.Forwarder, provider, @@ -117,150 +115,150 @@ export async function runMigrationsAsync(supportedProvider: SupportedProvider, t // AssetProxy timelocks { destination: deployedAddresses.erc20Proxy, - functionSelector: authorizableInterface.removeAuthorizedAddress.getSelector(), + functionSelector: authorizableInterface.getSelector('removeAuthorizedAddress'), secondsTimeLocked: constants.ZERO_AMOUNT, }, { destination: deployedAddresses.erc20Proxy, - functionSelector: authorizableInterface.removeAuthorizedAddressAtIndex.getSelector(), + functionSelector: authorizableInterface.getSelector('removeAuthorizedAddressAtIndex'), secondsTimeLocked: constants.ZERO_AMOUNT, }, { destination: deployedAddresses.erc721Proxy, - functionSelector: authorizableInterface.removeAuthorizedAddress.getSelector(), + functionSelector: authorizableInterface.getSelector('removeAuthorizedAddress'), secondsTimeLocked: constants.ZERO_AMOUNT, }, { destination: deployedAddresses.erc721Proxy, - functionSelector: authorizableInterface.removeAuthorizedAddressAtIndex.getSelector(), + functionSelector: authorizableInterface.getSelector('removeAuthorizedAddressAtIndex'), secondsTimeLocked: constants.ZERO_AMOUNT, }, { destination: deployedAddresses.erc1155Proxy, - functionSelector: authorizableInterface.removeAuthorizedAddress.getSelector(), + functionSelector: authorizableInterface.getSelector('removeAuthorizedAddress'), secondsTimeLocked: constants.ZERO_AMOUNT, }, { destination: deployedAddresses.erc1155Proxy, - functionSelector: authorizableInterface.removeAuthorizedAddressAtIndex.getSelector(), + functionSelector: authorizableInterface.getSelector('removeAuthorizedAddressAtIndex'), secondsTimeLocked: constants.ZERO_AMOUNT, }, { destination: deployedAddresses.multiAssetProxy, - functionSelector: authorizableInterface.removeAuthorizedAddress.getSelector(), + functionSelector: authorizableInterface.getSelector('removeAuthorizedAddress'), secondsTimeLocked: constants.ZERO_AMOUNT, }, { destination: deployedAddresses.multiAssetProxy, - functionSelector: authorizableInterface.removeAuthorizedAddressAtIndex.getSelector(), + functionSelector: authorizableInterface.getSelector('removeAuthorizedAddressAtIndex'), secondsTimeLocked: constants.ZERO_AMOUNT, }, { destination: erc20BridgeProxy.address, - functionSelector: authorizableInterface.removeAuthorizedAddress.getSelector(), + functionSelector: authorizableInterface.getSelector('removeAuthorizedAddress'), secondsTimeLocked: constants.ZERO_AMOUNT, }, { destination: erc20BridgeProxy.address, - functionSelector: authorizableInterface.removeAuthorizedAddressAtIndex.getSelector(), + functionSelector: authorizableInterface.getSelector('removeAuthorizedAddressAtIndex'), secondsTimeLocked: constants.ZERO_AMOUNT, }, // ZrxVault timelocks { destination: deployedAddresses.zrxVault, - functionSelector: zrxVault.enterCatastrophicFailure.getSelector(), + functionSelector: zrxVault.getSelector('enterCatastrophicFailure'), secondsTimeLocked: constants.ZERO_AMOUNT, }, { destination: deployedAddresses.zrxVault, - functionSelector: zrxVault.setStakingProxy.getSelector(), + functionSelector: zrxVault.getSelector('setStakingProxy'), secondsTimeLocked: constants.ZERO_AMOUNT, // 20 days on mainnet }, { destination: deployedAddresses.zrxVault, - functionSelector: zrxVault.setZrxProxy.getSelector(), + functionSelector: zrxVault.getSelector('setZrxProxy'), secondsTimeLocked: constants.ZERO_AMOUNT, // 20 days on mainnet }, { destination: deployedAddresses.zrxVault, - functionSelector: ownableInterface.transferOwnership.getSelector(), + functionSelector: ownableInterface.getSelector('transferOwnership'), secondsTimeLocked: constants.ZERO_AMOUNT, // 20 days on mainnet }, { destination: deployedAddresses.zrxVault, - functionSelector: authorizableInterface.addAuthorizedAddress.getSelector(), + functionSelector: authorizableInterface.getSelector('addAuthorizedAddress'), secondsTimeLocked: constants.ZERO_AMOUNT, // 20 days on mainnet }, { destination: deployedAddresses.zrxVault, - functionSelector: authorizableInterface.removeAuthorizedAddress.getSelector(), + functionSelector: authorizableInterface.getSelector('removeAuthorizedAddress'), secondsTimeLocked: constants.ZERO_AMOUNT, // 20 days on mainnet }, { destination: deployedAddresses.zrxVault, - functionSelector: authorizableInterface.removeAuthorizedAddressAtIndex.getSelector(), + functionSelector: authorizableInterface.getSelector('removeAuthorizedAddressAtIndex'), secondsTimeLocked: constants.ZERO_AMOUNT, // 20 days on mainnet }, // StakingProxy timelocks { destination: deployedAddresses.stakingProxy, - functionSelector: stakingProxy.attachStakingContract.getSelector(), + functionSelector: stakingProxy.getSelector('attachStakingContract'), secondsTimeLocked: constants.ZERO_AMOUNT, // 20 days on mainnet }, { destination: deployedAddresses.stakingProxy, - functionSelector: stakingProxy.detachStakingContract.getSelector(), + functionSelector: stakingProxy.getSelector('detachStakingContract'), secondsTimeLocked: constants.ZERO_AMOUNT, // 20 days on mainnet }, { destination: deployedAddresses.stakingProxy, - functionSelector: stakingLogic.setParams.getSelector(), + functionSelector: stakingLogic.getSelector('setParams'), secondsTimeLocked: constants.ZERO_AMOUNT, // 10 days on mainnet }, { destination: deployedAddresses.stakingProxy, - functionSelector: stakingLogic.addExchangeAddress.getSelector(), + functionSelector: stakingLogic.getSelector('addExchangeAddress'), secondsTimeLocked: constants.ZERO_AMOUNT, // 20 days on mainnet }, { destination: deployedAddresses.stakingProxy, - functionSelector: stakingLogic.removeExchangeAddress.getSelector(), + functionSelector: stakingLogic.getSelector('removeExchangeAddress'), secondsTimeLocked: constants.ZERO_AMOUNT, // 20 days on mainnet }, { destination: deployedAddresses.stakingProxy, - functionSelector: ownableInterface.transferOwnership.getSelector(), + functionSelector: ownableInterface.getSelector('transferOwnership'), secondsTimeLocked: constants.ZERO_AMOUNT, // 20 days on mainnet }, { destination: deployedAddresses.stakingProxy, - functionSelector: authorizableInterface.addAuthorizedAddress.getSelector(), + functionSelector: authorizableInterface.getSelector('addAuthorizedAddress'), secondsTimeLocked: constants.ZERO_AMOUNT, // 20 days on mainnet }, { destination: deployedAddresses.stakingProxy, - functionSelector: authorizableInterface.removeAuthorizedAddress.getSelector(), + functionSelector: authorizableInterface.getSelector('removeAuthorizedAddress'), secondsTimeLocked: constants.ZERO_AMOUNT, // 20 days on mainnet }, { destination: deployedAddresses.stakingProxy, - functionSelector: authorizableInterface.removeAuthorizedAddressAtIndex.getSelector(), + functionSelector: authorizableInterface.getSelector('removeAuthorizedAddressAtIndex'), secondsTimeLocked: constants.ZERO_AMOUNT, // 20 days on mainnet }, // Exchange timelocks { destination: exchange.address, - functionSelector: exchange.setProtocolFeeMultiplier.getSelector(), + functionSelector: exchange.getSelector('setProtocolFeeMultiplier'), secondsTimeLocked: constants.ZERO_AMOUNT, // 10 days on mainnet }, { destination: exchange.address, - functionSelector: exchange.setProtocolFeeCollectorAddress.getSelector(), + functionSelector: exchange.getSelector('setProtocolFeeCollectorAddress'), secondsTimeLocked: constants.ZERO_AMOUNT, // 20 days on mainnet }, { destination: exchange.address, - functionSelector: exchange.detachProtocolFeeCollector.getSelector(), + functionSelector: exchange.getSelector('detachProtocolFeeCollector'), secondsTimeLocked: constants.ZERO_AMOUNT, }, ]; @@ -279,19 +277,19 @@ export async function runMigrationsAsync(supportedProvider: SupportedProvider, t ); logUtils.log('Configuring Exchange...'); - await exchange.transferOwnership.awaitTransactionSuccessAsync(governor.address); + await exchange.transferOwnership(governor.address).awaitTransactionSuccessAsync(); logUtils.log('Exchange configured!'); logUtils.log('Configuring ERC20BridgeProxy...'); - await erc20BridgeProxy.transferOwnership.awaitTransactionSuccessAsync(governor.address); + await erc20BridgeProxy.transferOwnership(governor.address).awaitTransactionSuccessAsync(); logUtils.log('ERC20BridgeProxy configured!'); logUtils.log('Configuring ZrxVault...'); - await zrxVault.transferOwnership.awaitTransactionSuccessAsync(governor.address); + await zrxVault.transferOwnership(governor.address).awaitTransactionSuccessAsync(); logUtils.log('ZrxVault configured!'); logUtils.log('Configuring StakingProxy...'); - await stakingProxy.transferOwnership.awaitTransactionSuccessAsync(governor.address); + await stakingProxy.transferOwnership(governor.address).awaitTransactionSuccessAsync(); logUtils.log('StakingProxy configured!'); logUtils.log('Transfering ownership of 2.0 contracts...'); @@ -299,27 +297,27 @@ export async function runMigrationsAsync(supportedProvider: SupportedProvider, t await submitAndExecuteTransactionAsync( oldAssetProxyOwner, deployedAddresses.exchangeV2, // Exchange 2.1 address - ownableInterface.transferOwnership.getABIEncodedTransactionData(governor.address), + ownableInterface.transferOwnership(governor.address).getABIEncodedTransactionData(), ); await submitAndExecuteTransactionAsync( oldAssetProxyOwner, deployedAddresses.erc20Proxy, - ownableInterface.transferOwnership.getABIEncodedTransactionData(governor.address), + ownableInterface.transferOwnership(governor.address).getABIEncodedTransactionData(), ); await submitAndExecuteTransactionAsync( oldAssetProxyOwner, deployedAddresses.erc721Proxy, - ownableInterface.transferOwnership.getABIEncodedTransactionData(governor.address), + ownableInterface.transferOwnership(governor.address).getABIEncodedTransactionData(), ); await submitAndExecuteTransactionAsync( oldAssetProxyOwner, deployedAddresses.erc1155Proxy, - ownableInterface.transferOwnership.getABIEncodedTransactionData(governor.address), + ownableInterface.transferOwnership(governor.address).getABIEncodedTransactionData(), ); await submitAndExecuteTransactionAsync( oldAssetProxyOwner, deployedAddresses.multiAssetProxy, - ownableInterface.transferOwnership.getABIEncodedTransactionData(governor.address), + ownableInterface.transferOwnership(governor.address).getABIEncodedTransactionData(), ); logUtils.log('Ownership transferred!'); @@ -327,89 +325,89 @@ export async function runMigrationsAsync(supportedProvider: SupportedProvider, t // Exchange staking configs { destination: exchange.address, - data: exchange.setProtocolFeeCollectorAddress.getABIEncodedTransactionData(stakingProxy.address), + data: exchange.setProtocolFeeCollectorAddress(stakingProxy.address).getABIEncodedTransactionData(), }, { destination: exchange.address, - data: exchange.setProtocolFeeMultiplier.getABIEncodedTransactionData(new BigNumber(150000)), + data: exchange.setProtocolFeeMultiplier(new BigNumber(150000)).getABIEncodedTransactionData(), }, // Exchange AssetProxy registrations { destination: exchange.address, - data: exchange.registerAssetProxy.getABIEncodedTransactionData(deployedAddresses.erc20Proxy), + data: exchange.registerAssetProxy(deployedAddresses.erc20Proxy).getABIEncodedTransactionData(), }, { destination: exchange.address, - data: exchange.registerAssetProxy.getABIEncodedTransactionData(deployedAddresses.erc721Proxy), + data: exchange.registerAssetProxy(deployedAddresses.erc721Proxy).getABIEncodedTransactionData(), }, { destination: exchange.address, - data: exchange.registerAssetProxy.getABIEncodedTransactionData(deployedAddresses.erc1155Proxy), + data: exchange.registerAssetProxy(deployedAddresses.erc1155Proxy).getABIEncodedTransactionData(), }, { destination: exchange.address, - data: exchange.registerAssetProxy.getABIEncodedTransactionData(deployedAddresses.multiAssetProxy), + data: exchange.registerAssetProxy(deployedAddresses.multiAssetProxy).getABIEncodedTransactionData(), }, { destination: exchange.address, - data: exchange.registerAssetProxy.getABIEncodedTransactionData(deployedAddresses.staticCallProxy), + data: exchange.registerAssetProxy(deployedAddresses.staticCallProxy).getABIEncodedTransactionData(), }, { destination: exchange.address, - data: exchange.registerAssetProxy.getABIEncodedTransactionData(erc20BridgeProxy.address), + data: exchange.registerAssetProxy(erc20BridgeProxy.address).getABIEncodedTransactionData(), }, // ZrxVault configs { destination: zrxVault.address, - data: authorizableInterface.addAuthorizedAddress.getABIEncodedTransactionData(governor.address), + data: authorizableInterface.addAuthorizedAddress(governor.address).getABIEncodedTransactionData(), }, { destination: zrxVault.address, - data: zrxVault.setStakingProxy.getABIEncodedTransactionData(stakingProxy.address), + data: zrxVault.setStakingProxy(stakingProxy.address).getABIEncodedTransactionData(), }, // StakingProxy configs { destination: stakingProxy.address, - data: authorizableInterface.addAuthorizedAddress.getABIEncodedTransactionData(governor.address), + data: authorizableInterface.addAuthorizedAddress(governor.address).getABIEncodedTransactionData(), }, { destination: stakingProxy.address, - data: stakingLogic.addExchangeAddress.getABIEncodedTransactionData(exchange.address), + data: stakingLogic.addExchangeAddress(exchange.address).getABIEncodedTransactionData(), }, // AssetProxy configs { destination: deployedAddresses.erc20Proxy, - data: authorizableInterface.addAuthorizedAddress.getABIEncodedTransactionData(exchange.address), + data: authorizableInterface.addAuthorizedAddress(exchange.address).getABIEncodedTransactionData(), }, { destination: deployedAddresses.erc20Proxy, - data: authorizableInterface.addAuthorizedAddress.getABIEncodedTransactionData(zrxVault.address), + data: authorizableInterface.addAuthorizedAddress(zrxVault.address).getABIEncodedTransactionData(), }, { destination: deployedAddresses.erc721Proxy, - data: authorizableInterface.addAuthorizedAddress.getABIEncodedTransactionData(exchange.address), + data: authorizableInterface.addAuthorizedAddress(exchange.address).getABIEncodedTransactionData(), }, { destination: deployedAddresses.erc1155Proxy, - data: authorizableInterface.addAuthorizedAddress.getABIEncodedTransactionData(exchange.address), + data: authorizableInterface.addAuthorizedAddress(exchange.address).getABIEncodedTransactionData(), }, { destination: deployedAddresses.multiAssetProxy, - data: authorizableInterface.addAuthorizedAddress.getABIEncodedTransactionData(exchange.address), + data: authorizableInterface.addAuthorizedAddress(exchange.address).getABIEncodedTransactionData(), }, { destination: deployedAddresses.multiAssetProxy, - data: exchange.registerAssetProxy.getABIEncodedTransactionData(erc20BridgeProxy.address), + data: exchange.registerAssetProxy(erc20BridgeProxy.address).getABIEncodedTransactionData(), }, { destination: erc20BridgeProxy.address, - data: authorizableInterface.addAuthorizedAddress.getABIEncodedTransactionData(exchange.address), + data: authorizableInterface.addAuthorizedAddress(exchange.address).getABIEncodedTransactionData(), }, { destination: erc20BridgeProxy.address, - data: authorizableInterface.addAuthorizedAddress.getABIEncodedTransactionData( - deployedAddresses.multiAssetProxy, - ), + data: authorizableInterface + .addAuthorizedAddress(deployedAddresses.multiAssetProxy) + .getABIEncodedTransactionData(), }, ]; diff --git a/packages/order-utils/src/asset_balance_and_proxy_allowance_fetcher.ts b/packages/order-utils/src/asset_balance_and_proxy_allowance_fetcher.ts index 1cef5d3c73..0745747bb6 100644 --- a/packages/order-utils/src/asset_balance_and_proxy_allowance_fetcher.ts +++ b/packages/order-utils/src/asset_balance_and_proxy_allowance_fetcher.ts @@ -10,11 +10,11 @@ export class AssetBalanceAndProxyAllowanceFetcher implements AbstractBalanceAndP this._devUtilsContract = devUtilsContract; } public async getBalanceAsync(assetData: string, userAddress: string): Promise { - const balance = await this._devUtilsContract.getBalance.callAsync(userAddress, assetData); + const balance = await this._devUtilsContract.getBalance(userAddress, assetData).callAsync(); return balance; } public async getProxyAllowanceAsync(assetData: string, userAddress: string): Promise { - const proxyAllowance = await this._devUtilsContract.getAssetProxyAllowance.callAsync(userAddress, assetData); + const proxyAllowance = await this._devUtilsContract.getAssetProxyAllowance(userAddress, assetData).callAsync(); return proxyAllowance; } } diff --git a/packages/order-utils/src/signature_utils.ts b/packages/order-utils/src/signature_utils.ts index 25e92e3457..364f564c39 100644 --- a/packages/order-utils/src/signature_utils.ts +++ b/packages/order-utils/src/signature_utils.ts @@ -125,7 +125,7 @@ export const signatureUtils = { exchangeContract = new ExchangeContract(addresses.exchange, provider); } - const isValid = await exchangeContract.preSigned.callAsync(data, signerAddress); + const isValid = await exchangeContract.preSigned(data, signerAddress).callAsync(); return isValid; }, /** @@ -150,7 +150,7 @@ export const signatureUtils = { const signatureWithoutType = signature.slice(0, -2); const walletContract = new IWalletContract(signerAddress, provider); try { - const magicValue = await walletContract.isValidSignature.callAsync(data, signatureWithoutType); + const magicValue = await walletContract.isValidSignature(data, signatureWithoutType).callAsync(); return magicValue === constants.IS_VALID_WALLET_SIGNATURE_MAGIC_VALUE; } catch (e) { return false; @@ -189,10 +189,9 @@ export const signatureUtils = { } const validatorSignature = signatureUtils.parseValidatorSignature(signature); - const isValidatorApproved = await exchangeContract.allowedValidators.callAsync( - signerAddress, - validatorSignature.validatorAddress, - ); + const isValidatorApproved = await exchangeContract + .allowedValidators(signerAddress, validatorSignature.validatorAddress) + .callAsync(); if (!isValidatorApproved) { throw new Error( `Validator ${validatorSignature.validatorAddress} was not pre-approved by ${signerAddress}.`, @@ -201,11 +200,9 @@ export const signatureUtils = { const validatorContract = new IValidatorContract(validatorSignature.validatorAddress, provider); try { - const magicValue = await validatorContract.isValidSignature.callAsync( - data, - signerAddress, - validatorSignature.signature, - ); + const magicValue = await validatorContract + .isValidSignature(data, signerAddress, validatorSignature.signature) + .callAsync(); return magicValue === constants.IS_VALID_VALIDATOR_SIGNATURE_MAGIC_VALUE; } catch (e) { return false; diff --git a/packages/order-utils/test/exchange_transfer_simulator_test.ts b/packages/order-utils/test/exchange_transfer_simulator_test.ts index 1d64401482..1c06828375 100644 --- a/packages/order-utils/test/exchange_transfer_simulator_test.ts +++ b/packages/order-utils/test/exchange_transfer_simulator_test.ts @@ -72,7 +72,7 @@ describe('ExchangeTransferSimulator', async () => { totalSupply, ); - exampleAssetData = await devUtils.encodeERC20AssetData.callAsync(dummyERC20Token.address); + exampleAssetData = await devUtils.encodeERC20AssetData(dummyERC20Token.address).callAsync(); }); beforeEach(async () => { await blockchainLifecycle.startAsync(); @@ -110,7 +110,7 @@ describe('ExchangeTransferSimulator', async () => { ).to.be.rejectedWith(ExchangeContractErrs.InsufficientTakerAllowance); }); it("throws if the user doesn't have enough balance", async () => { - txHash = await dummyERC20Token.approve.sendTransactionAsync(erc20ProxyAddress, transferAmount, { + txHash = await dummyERC20Token.approve(erc20ProxyAddress, transferAmount).sendTransactionAsync({ from: sender, }); await web3Wrapper.awaitTransactionSuccessAsync(txHash); @@ -126,12 +126,12 @@ describe('ExchangeTransferSimulator', async () => { ).to.be.rejectedWith(ExchangeContractErrs.InsufficientMakerBalance); }); it('updates balances and proxyAllowance after transfer', async () => { - txHash = await dummyERC20Token.transfer.sendTransactionAsync(sender, transferAmount, { + txHash = await dummyERC20Token.transfer(sender, transferAmount).sendTransactionAsync({ from: coinbase, }); await web3Wrapper.awaitTransactionSuccessAsync(txHash); - txHash = await dummyERC20Token.approve.sendTransactionAsync(erc20ProxyAddress, transferAmount, { + txHash = await dummyERC20Token.approve(erc20ProxyAddress, transferAmount).sendTransactionAsync({ from: sender, }); await web3Wrapper.awaitTransactionSuccessAsync(txHash); @@ -153,17 +153,15 @@ describe('ExchangeTransferSimulator', async () => { expect(senderProxyAllowance).to.be.bignumber.equal(0); }); it("doesn't update proxyAllowance after transfer if unlimited", async () => { - txHash = await dummyERC20Token.transfer.sendTransactionAsync(sender, transferAmount, { + txHash = await dummyERC20Token.transfer(sender, transferAmount).sendTransactionAsync({ from: coinbase, }); await web3Wrapper.awaitTransactionSuccessAsync(txHash); - txHash = await dummyERC20Token.approve.sendTransactionAsync( - erc20ProxyAddress, - constants.UNLIMITED_ALLOWANCE_IN_BASE_UNITS, - { + txHash = await dummyERC20Token + .approve(erc20ProxyAddress, constants.UNLIMITED_ALLOWANCE_IN_BASE_UNITS) + .sendTransactionAsync({ from: sender, - }, - ); + }); await web3Wrapper.awaitTransactionSuccessAsync(txHash); await exchangeTransferSimulator.transferFromAsync( exampleAssetData, diff --git a/packages/order-utils/test/utils/simple_erc20_balance_and_proxy_allowance_fetcher.ts b/packages/order-utils/test/utils/simple_erc20_balance_and_proxy_allowance_fetcher.ts index d3ea8b4567..59f25e9d74 100644 --- a/packages/order-utils/test/utils/simple_erc20_balance_and_proxy_allowance_fetcher.ts +++ b/packages/order-utils/test/utils/simple_erc20_balance_and_proxy_allowance_fetcher.ts @@ -13,13 +13,15 @@ export class SimpleERC20BalanceAndProxyAllowanceFetcher implements AbstractBalan public async getBalanceAsync(_assetData: string, userAddress: string): Promise { // HACK: We cheat and don't pass in the assetData since it's always the same token used // in our tests. - const balance = await this._erc20TokenContract.balanceOf.callAsync(userAddress); + const balance = await this._erc20TokenContract.balanceOf(userAddress).callAsync(); return balance; } public async getProxyAllowanceAsync(_assetData: string, userAddress: string): Promise { // HACK: We cheat and don't pass in the assetData since it's always the same token used // in our tests. - const proxyAllowance = await this._erc20TokenContract.allowance.callAsync(userAddress, this._erc20ProxyAddress); + const proxyAllowance = await this._erc20TokenContract + .allowance(userAddress, this._erc20ProxyAddress) + .callAsync(); return proxyAllowance; } } diff --git a/packages/testnet-faucets/src/ts/dispense_asset_tasks.ts b/packages/testnet-faucets/src/ts/dispense_asset_tasks.ts index afe1ceb0cc..d10819c4d5 100644 --- a/packages/testnet-faucets/src/ts/dispense_asset_tasks.ts +++ b/packages/testnet-faucets/src/ts/dispense_asset_tasks.ts @@ -48,7 +48,7 @@ export const dispenseAssetTasks = { } const baseUnitAmount = Web3Wrapper.toBaseUnitAmount(amountToDispense, tokenIfExists.decimals); const erc20Token = new ERC20TokenContract(tokenIfExists.address, provider); - const userBalanceBaseUnits = await erc20Token.balanceOf.callAsync(recipientAddress); + const userBalanceBaseUnits = await erc20Token.balanceOf(recipientAddress).callAsync(); const maxAmountBaseUnits = Web3Wrapper.toBaseUnitAmount( new BigNumber(DISPENSE_MAX_AMOUNT_TOKEN), tokenIfExists.decimals, @@ -59,7 +59,7 @@ export const dispenseAssetTasks = { ); return; } - const txHash = await erc20Token.transfer.sendTransactionAsync(recipientAddress, baseUnitAmount, { + const txHash = await erc20Token.transfer(recipientAddress, baseUnitAmount).sendTransactionAsync({ from: configs.DISPENSER_ADDRESS, }); logUtils.log(`Sent ${amountToDispense} ${tokenSymbol} to ${recipientAddress} tx: ${txHash}`); From 1ee22b3fcf8c185e36703e3409bf9d0bd1e5a034 Mon Sep 17 00:00:00 2001 From: xianny Date: Tue, 12 Nov 2019 19:29:49 -0600 Subject: [PATCH 03/20] wip: get all packages to build --- contracts/asset-proxy/test/authorizable.ts | 54 +- contracts/asset-proxy/test/erc1155_proxy.ts | 224 +- .../asset-proxy/test/erc20bridge_proxy.ts | 31 +- contracts/asset-proxy/test/eth2dai_bridge.ts | 30 +- contracts/asset-proxy/test/proxies.ts | 922 +++--- .../asset-proxy/test/static_call_proxy.ts | 147 +- contracts/asset-proxy/test/uniswap_bridge.ts | 81 +- .../test/utils/erc1155_proxy_wrapper.ts | 40 +- .../asset-proxy/test/utils/erc20_wrapper.ts | 40 +- .../asset-proxy/test/utils/erc721_wrapper.ts | 24 +- .../coordinator/test/coordinator_registry.ts | 39 +- contracts/coordinator/test/libs.ts | 2 +- contracts/coordinator/test/mixins.ts | 280 +- contracts/erc1155/test/erc1155_token.ts | 70 +- .../erc1155/test/utils/erc1155_wrapper.ts | 40 +- contracts/erc20/test/lib_erc20_token.ts | 279 +- .../erc20/test/unlimited_allowance_token.ts | 56 +- contracts/erc20/test/weth9.ts | 24 +- contracts/erc20/test/zrx_token.ts | 64 +- contracts/erc721/test/erc721_token.ts | 52 +- .../test/lib_eip712_exchange_domain.ts | 4 +- .../exchange-libs/test/lib_fill_results.ts | 203 +- contracts/exchange-libs/test/lib_math.ts | 67 +- contracts/exchange-libs/test/lib_order.ts | 8 +- .../test/lib_zero_ex_transaction.ts | 18 +- contracts/exchange/src/wrapper_interfaces.ts | 62 +- .../assertion_wrappers/fill_order_wrapper.ts | 26 +- .../blockchain_balance_store.ts | 11 +- .../balance_stores/local_balance_store.ts | 18 +- contracts/exchange/test/core.ts | 418 ++- contracts/exchange/test/dispatcher.ts | 207 +- contracts/exchange/test/internal.ts | 109 +- contracts/exchange/test/match_orders.ts | 174 +- contracts/exchange/test/protocol_fees.ts | 263 +- .../exchange/test/protocol_fees_manager.ts | 34 +- contracts/exchange/test/reentrancy_tests.ts | 8 +- .../exchange/test/signature_validator.ts | 218 +- contracts/exchange/test/transactions.ts | 102 +- .../exchange/test/transactions_unit_tests.ts | 239 +- .../exchange/test/utils/asset_wrapper.ts | 74 +- .../test/utils/exchange_data_encoder.ts | 52 +- .../exchange/test/utils/exchange_wrapper.ts | 290 +- .../utils/fill_order_combinatorial_utils.ts | 20 +- .../test/utils/isolated_exchange_wrapper.ts | 50 +- .../exchange/test/utils/match_order_tester.ts | 14 +- .../test/utils/order_factory_from_scenario.ts | 204 +- contracts/exchange/test/wrapper_unit_tests.ts | 2656 ++++++++--------- .../test/balance_threshold_filter.ts | 21 +- contracts/extensions/test/dutch_auction.ts | 31 +- contracts/extensions/test/order_matcher.ts | 212 +- .../test/utils/balance_threshold_wrapper.ts | 138 +- .../test/utils/dutch_auction_test_wrapper.ts | 14 +- contracts/integrations/test/actors/base.ts | 29 +- contracts/integrations/test/actors/keeper.ts | 8 +- contracts/integrations/test/actors/maker.ts | 4 +- .../integrations/test/actors/pool_operator.ts | 16 +- contracts/integrations/test/actors/staker.ts | 15 +- contracts/integrations/test/actors/taker.ts | 11 +- .../test/coordinator/coordinator_test.ts | 179 +- .../test/forwarder/forwarder_test.ts | 102 +- .../test/forwarder/forwarder_test_factory.ts | 42 +- .../deployment_manager_test.ts | 56 +- .../function_assertion_test.ts | 2 +- .../deployment_test.ts | 61 +- .../exchange_wrapper_test.ts | 128 +- .../fillorder_test.ts | 20 +- .../test/utils/deployment_manager.ts | 32 +- .../test/utils/function_assertions.ts | 30 +- .../multisig/test/multi_sig_with_time_lock.ts | 34 +- .../multisig/test/utils/multi_sig_wrapper.ts | 8 +- .../test/utils/zero_ex_governor_wrapper.ts | 24 +- contracts/multisig/test/zero_ex_governor.ts | 292 +- .../staking/test/actors/finalizer_actor.ts | 24 +- contracts/staking/test/actors/maker_actor.ts | 9 +- .../test/actors/pool_operator_actor.ts | 14 +- contracts/staking/test/actors/staker_actor.ts | 80 +- contracts/staking/test/epoch_test.ts | 4 +- contracts/staking/test/migration_test.ts | 153 +- contracts/staking/test/pools_test.ts | 4 +- contracts/staking/test/rewards_test.ts | 60 +- contracts/staking/test/stake_test.ts | 2 +- .../test/unit_tests/delegator_reward_test.ts | 48 +- .../staking/test/unit_tests/exchange_test.ts | 28 +- .../staking/test/unit_tests/finalizer_test.ts | 119 +- .../test/unit_tests/lib_cobb_douglas_test.ts | 23 +- .../test/unit_tests/lib_fixed_math_test.ts | 216 +- .../test/unit_tests/lib_safe_downcast_test.ts | 4 +- .../mixin_cumulative_rewards_test.ts | 150 +- .../test/unit_tests/mixin_scheduler_test.ts | 38 +- .../unit_tests/mixin_stake_storage_test.ts | 64 +- .../unit_tests/mixin_staking_pool_rewards.ts | 180 +- .../staking/test/unit_tests/params_test.ts | 23 +- .../test/unit_tests/protocol_fees_test.ts | 189 +- .../test/unit_tests/stake_balances_test.ts | 71 +- .../staking/test/unit_tests/stake_test.ts | 256 +- .../test/unit_tests/staking_pool_test.ts | 172 +- .../test/unit_tests/staking_proxy_test.ts | 95 +- .../staking/test/unit_tests/zrx_vault_test.ts | 128 +- contracts/staking/test/utils/api_wrapper.ts | 68 +- .../cumulative_reward_tracking_simulation.ts | 57 +- contracts/test-utils/package.json | 1 + contracts/test-utils/src/index.ts | 2 +- .../test-utils/src/transaction_helper.ts | 61 +- .../tests/test/dev-utils/lib_asset_data.ts | 332 +-- .../test/dev-utils/lib_transaction_decoder.ts | 49 +- .../test/dev-utils/order_validation_utils.ts | 443 ++- contracts/utils/test/authorizable.ts | 56 +- contracts/utils/test/lib_address.ts | 4 +- contracts/utils/test/lib_address_array.ts | 38 +- contracts/utils/test/lib_bytes.ts | 223 +- contracts/utils/test/lib_eip712.ts | 11 +- contracts/utils/test/lib_rich_errors.ts | 4 +- contracts/utils/test/lib_safe_math.ts | 52 +- contracts/utils/test/log_decoding.ts | 22 +- contracts/utils/test/ownable.ts | 10 +- contracts/utils/test/reentrancy_guard.ts | 4 +- contracts/utils/test/refundable.ts | 28 +- packages/asset-buyer/src/asset_buyer.ts | 33 +- .../order_provider_response_processor.ts | 7 +- .../exchange_swap_quote_consumer.ts | 22 +- .../forwarder_swap_quote_consumer.ts | 37 +- packages/asset-swapper/src/swap_quoter.ts | 29 +- .../order_provider_response_processor.ts | 7 +- .../src/utils/swap_quote_consumer_utils.ts | 8 +- .../test/exchange_swap_quote_consumer_test.ts | 50 +- .../forwarder_swap_quote_consumer_test.ts | 58 +- .../test/swap_quote_consumer_test.ts | 26 +- .../test/swap_quote_consumer_utils_test.ts | 10 +- .../src/coordinator_wrapper.ts | 136 +- packages/contract-wrappers/src/index.ts | 3 +- .../src/utils/getAbiEncodedTransactionData.ts | 24 - .../test/calldata_decoder_test.ts | 60 +- .../test/coordinator_wrapper_test.ts | 54 +- .../test/utils/token_utils.ts | 2 +- packages/migrations/src/migration.ts | 44 +- .../migrations/src/test_contract_configs.ts | 110 +- packages/migrations/src/testnet_migrations.ts | 132 +- ...set_balance_and_proxy_allowance_fetcher.ts | 4 +- packages/order-utils/src/signature_utils.ts | 19 +- .../test/exchange_transfer_simulator_test.ts | 20 +- ...c20_balance_and_proxy_allowance_fetcher.ts | 6 +- .../src/ts/dispense_asset_tasks.ts | 4 +- 142 files changed, 6590 insertions(+), 7491 deletions(-) delete mode 100644 packages/contract-wrappers/src/utils/getAbiEncodedTransactionData.ts diff --git a/contracts/asset-proxy/test/authorizable.ts b/contracts/asset-proxy/test/authorizable.ts index 4a7794734c..31401d281b 100644 --- a/contracts/asset-proxy/test/authorizable.ts +++ b/contracts/asset-proxy/test/authorizable.ts @@ -47,21 +47,21 @@ describe('Authorizable', () => { describe('addAuthorizedAddress', () => { it('should revert if not called by owner', async () => { await expectTransactionFailedAsync( - authorizable.addAuthorizedAddress.sendTransactionAsync(notOwner, { from: notOwner }), + authorizable.addAuthorizedAddress(notOwner).sendTransactionAsync({ from: notOwner }), RevertReason.OnlyContractOwner, ); }); it('should allow owner to add an authorized address', async () => { - await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner }); - const isAuthorized = await authorizable.authorized.callAsync(address); + await authorizable.addAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner }); + const isAuthorized = await authorizable.authorized(address).callAsync(); expect(isAuthorized).to.be.true(); }); it('should revert if owner attempts to authorize a duplicate address', async () => { - await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner }); + await authorizable.addAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner }); return expectTransactionFailedAsync( - authorizable.addAuthorizedAddress.sendTransactionAsync(address, { from: owner }), + authorizable.addAuthorizedAddress(address).sendTransactionAsync({ from: owner }), RevertReason.TargetAlreadyAuthorized, ); }); @@ -69,23 +69,23 @@ describe('Authorizable', () => { describe('removeAuthorizedAddress', () => { it('should revert if not called by owner', async () => { - await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner }); + await authorizable.addAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner }); await expectTransactionFailedAsync( - authorizable.removeAuthorizedAddress.sendTransactionAsync(address, { from: notOwner }), + authorizable.removeAuthorizedAddress(address).sendTransactionAsync({ from: notOwner }), RevertReason.OnlyContractOwner, ); }); it('should allow owner to remove an authorized address', async () => { - await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner }); - await authorizable.removeAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner }); - const isAuthorized = await authorizable.authorized.callAsync(address); + await authorizable.addAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner }); + await authorizable.removeAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner }); + const isAuthorized = await authorizable.authorized(address).callAsync(); expect(isAuthorized).to.be.false(); }); it('should revert if owner attempts to remove an address that is not authorized', async () => { return expectTransactionFailedAsync( - authorizable.removeAuthorizedAddress.sendTransactionAsync(address, { + authorizable.removeAuthorizedAddress(address).sendTransactionAsync({ from: owner, }), RevertReason.TargetNotAuthorized, @@ -95,10 +95,10 @@ describe('Authorizable', () => { describe('removeAuthorizedAddressAtIndex', () => { it('should revert if not called by owner', async () => { - await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner }); + await authorizable.addAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner }); const index = new BigNumber(0); await expectTransactionFailedAsync( - authorizable.removeAuthorizedAddressAtIndex.sendTransactionAsync(address, index, { + authorizable.removeAuthorizedAddressAtIndex(address, index).sendTransactionAsync({ from: notOwner, }), RevertReason.OnlyContractOwner, @@ -106,10 +106,10 @@ describe('Authorizable', () => { }); it('should revert if index is >= authorities.length', async () => { - await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner }); + await authorizable.addAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner }); const index = new BigNumber(1); return expectTransactionFailedAsync( - authorizable.removeAuthorizedAddressAtIndex.sendTransactionAsync(address, index, { + authorizable.removeAuthorizedAddressAtIndex(address, index).sendTransactionAsync({ from: owner, }), RevertReason.IndexOutOfBounds, @@ -119,7 +119,7 @@ describe('Authorizable', () => { it('should revert if owner attempts to remove an address that is not authorized', async () => { const index = new BigNumber(0); return expectTransactionFailedAsync( - authorizable.removeAuthorizedAddressAtIndex.sendTransactionAsync(address, index, { + authorizable.removeAuthorizedAddressAtIndex(address, index).sendTransactionAsync({ from: owner, }), RevertReason.TargetNotAuthorized, @@ -129,11 +129,11 @@ describe('Authorizable', () => { it('should revert if address at index does not match target', async () => { const address1 = address; const address2 = notOwner; - await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address1, { from: owner }); - await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address2, { from: owner }); + await authorizable.addAuthorizedAddress(address1).awaitTransactionSuccessAsync({ from: owner }); + await authorizable.addAuthorizedAddress(address2).awaitTransactionSuccessAsync({ from: owner }); const address1Index = new BigNumber(0); return expectTransactionFailedAsync( - authorizable.removeAuthorizedAddressAtIndex.sendTransactionAsync(address2, address1Index, { + authorizable.removeAuthorizedAddressAtIndex(address2, address1Index).sendTransactionAsync({ from: owner, }), RevertReason.AuthorizedAddressMismatch, @@ -141,26 +141,26 @@ describe('Authorizable', () => { }); it('should allow owner to remove an authorized address', async () => { - await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner }); + await authorizable.addAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner }); const index = new BigNumber(0); - await authorizable.removeAuthorizedAddressAtIndex.awaitTransactionSuccessAsync(address, index, { + await authorizable.removeAuthorizedAddressAtIndex(address, index).awaitTransactionSuccessAsync({ from: owner, }); - const isAuthorized = await authorizable.authorized.callAsync(address); + const isAuthorized = await authorizable.authorized(address).callAsync(); expect(isAuthorized).to.be.false(); }); }); describe('getAuthorizedAddresses', () => { it('should return all authorized addresses', async () => { - const initial = await authorizable.getAuthorizedAddresses.callAsync(); + const initial = await authorizable.getAuthorizedAddresses().callAsync(); expect(initial).to.have.length(0); - await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner }); - const afterAdd = await authorizable.getAuthorizedAddresses.callAsync(); + await authorizable.addAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner }); + const afterAdd = await authorizable.getAuthorizedAddresses().callAsync(); expect(afterAdd).to.have.length(1); expect(afterAdd).to.include(address); - await authorizable.removeAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner }); - const afterRemove = await authorizable.getAuthorizedAddresses.callAsync(); + await authorizable.removeAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner }); + const afterRemove = await authorizable.getAuthorizedAddresses().callAsync(); expect(afterRemove).to.have.length(0); }); }); diff --git a/contracts/asset-proxy/test/erc1155_proxy.ts b/contracts/asset-proxy/test/erc1155_proxy.ts index 82c410a184..015b2bd44f 100644 --- a/contracts/asset-proxy/test/erc1155_proxy.ts +++ b/contracts/asset-proxy/test/erc1155_proxy.ts @@ -74,8 +74,8 @@ describe('ERC1155Proxy', () => { const usedAddresses = ([owner, notAuthorized, authorized, spender, receiver] = _.slice(accounts, 0, 5)); erc1155ProxyWrapper = new ERC1155ProxyWrapper(provider, usedAddresses, owner); erc1155Proxy = await erc1155ProxyWrapper.deployProxyAsync(); - await erc1155Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(authorized, { from: owner }); - await erc1155Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(erc1155Proxy.address, { from: owner }); + await erc1155Proxy.addAuthorizedAddress(authorized).awaitTransactionSuccessAsync({ from: owner }); + await erc1155Proxy.addAuthorizedAddress(erc1155Proxy.address).awaitTransactionSuccessAsync({ from: owner }); // deploy & configure ERC1155 tokens and receiver [erc1155Wrapper] = await erc1155ProxyWrapper.deployDummyContractsAsync(); erc1155Contract = erc1155Wrapper.getContract(); @@ -119,7 +119,7 @@ describe('ERC1155Proxy', () => { ); }); it('should have an id of 0xa7cb5fb7', async () => { - const proxyId = await erc1155Proxy.getProxyId.callAsync(); + const proxyId = await erc1155Proxy.getProxyId().callAsync(); const expectedProxyId = AssetProxyId.ERC1155; expect(proxyId).to.equal(expectedProxyId); }); @@ -634,12 +634,14 @@ describe('ERC1155Proxy', () => { return value.times(valueMultiplier); }); const erc1155ContractAddress = erc1155Wrapper.getContract().address; - const assetData = await devUtils.encodeERC1155AssetData.callAsync( - erc1155ContractAddress, - tokensToTransfer, - valuesToTransfer, - receiverCallbackData, - ); + const assetData = await devUtils + .encodeERC1155AssetData( + erc1155ContractAddress, + tokensToTransfer, + valuesToTransfer, + receiverCallbackData, + ) + .callAsync(); const extraData = '0102030405060708091001020304050607080910010203040506070809100102'; const assetDataWithExtraData = `${assetData}${extraData}`; // check balances before transfer @@ -694,14 +696,16 @@ describe('ERC1155Proxy', () => { // create token await erc1155Wrapper .getContract() - .createWithType.awaitTransactionSuccessAsync(tokenToCreate, tokenUri, { + .createWithType(tokenToCreate, tokenUri) + .awaitTransactionSuccessAsync({ from: owner, }); // mint balance for spender await erc1155Wrapper .getContract() - .mintFungible.awaitTransactionSuccessAsync(tokenToCreate, [spender], [spenderInitialBalance], { + .mintFungible(tokenToCreate, [spender], [spenderInitialBalance]) + .awaitTransactionSuccessAsync({ from: owner, }); } @@ -739,7 +743,7 @@ describe('ERC1155Proxy', () => { // hand encode optimized assetData because our tooling (based on LibAssetData.sol/encodeERC1155AssetData) does not use optimized encoding const assetDataContract = new IAssetDataContract(constants.NULL_ADDRESS, provider); - const selector = assetDataContract.ERC1155Assets.getSelector(); + const selector = assetDataContract.getSelector('ERC1155Assets'); const assetDataWithoutContractAddress = '0000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000040102030400000000000000000000000000000000000000000000000000000000'; const assetData = `${selector}000000000000000000000000${erc1155ContractAddress.substr( @@ -794,14 +798,16 @@ describe('ERC1155Proxy', () => { // create token await erc1155Wrapper .getContract() - .createWithType.awaitTransactionSuccessAsync(tokenToCreate, tokenUri, { + .createWithType(tokenToCreate, tokenUri) + .awaitTransactionSuccessAsync({ from: owner, }); // mint balance for spender await erc1155Wrapper .getContract() - .mintFungible.awaitTransactionSuccessAsync(tokenToCreate, [spender], [spenderInitialBalance], { + .mintFungible(tokenToCreate, [spender], [spenderInitialBalance]) + .awaitTransactionSuccessAsync({ from: owner, }); } @@ -847,12 +853,14 @@ describe('ERC1155Proxy', () => { const valuesToTransfer = [new BigNumber(2), new BigNumber(2)]; const valueMultiplier = new BigNumber(2); // create callback data that is the encoded version of `valuesToTransfer` - const generatedAssetData = await devUtils.encodeERC1155AssetData.callAsync( - erc1155ContractAddress, - tokensToTransfer, - valuesToTransfer, - receiverCallbackData, - ); + const generatedAssetData = await devUtils + .encodeERC1155AssetData( + erc1155ContractAddress, + tokensToTransfer, + valuesToTransfer, + receiverCallbackData, + ) + .callAsync(); // remove the function selector and contract address from check, as these change on each test const offsetToTokenIds = 74; const assetDataSelectorAndContractAddress = generatedAssetData.substr(0, offsetToTokenIds); @@ -919,14 +927,16 @@ describe('ERC1155Proxy', () => { // create token await erc1155Wrapper .getContract() - .createWithType.awaitTransactionSuccessAsync(tokenToCreate, tokenUri, { + .createWithType(tokenToCreate, tokenUri) + .awaitTransactionSuccessAsync({ from: owner, }); // mint balance for spender await erc1155Wrapper .getContract() - .mintFungible.awaitTransactionSuccessAsync(tokenToCreate, [spender], [spenderInitialBalance], { + .mintFungible(tokenToCreate, [spender], [spenderInitialBalance]) + .awaitTransactionSuccessAsync({ from: owner, }); } @@ -969,12 +979,14 @@ describe('ERC1155Proxy', () => { const valuesToTransfer = [new BigNumber(1), new BigNumber(2)]; const valueMultiplier = new BigNumber(2); // create callback data that is the encoded version of `valuesToTransfer` - const generatedAssetData = await devUtils.encodeERC1155AssetData.callAsync( - erc1155ContractAddress, - tokensToTransfer, - valuesToTransfer, - receiverCallbackData, - ); + const generatedAssetData = await devUtils + .encodeERC1155AssetData( + erc1155ContractAddress, + tokensToTransfer, + valuesToTransfer, + receiverCallbackData, + ) + .callAsync(); // remove the function selector and contract address from check, as these change on each test const offsetToTokenIds = 74; const assetDataSelectorAndContractAddress = generatedAssetData.substr(0, offsetToTokenIds); @@ -1032,12 +1044,14 @@ describe('ERC1155Proxy', () => { const valuesToTransfer = [fungibleValueToTransferLarge]; const valueMultiplier = valueMultiplierSmall; const erc1155ContractAddress = erc1155Wrapper.getContract().address; - const assetData = await devUtils.encodeERC1155AssetData.callAsync( - erc1155ContractAddress, - tokensToTransfer, - valuesToTransfer, - receiverCallbackData, - ); + const assetData = await devUtils + .encodeERC1155AssetData( + erc1155ContractAddress, + tokensToTransfer, + valuesToTransfer, + receiverCallbackData, + ) + .callAsync(); // The asset data we just generated will look like this: // a7cb5fb7 // 0x 0000000000000000000000000b1ba0af832d7c05fd64161e0db78e85978e8082 @@ -1079,12 +1093,14 @@ describe('ERC1155Proxy', () => { const valuesToTransfer = [fungibleValueToTransferLarge]; const valueMultiplier = valueMultiplierSmall; const erc1155ContractAddress = erc1155Wrapper.getContract().address; - const assetData = await devUtils.encodeERC1155AssetData.callAsync( - erc1155ContractAddress, - tokensToTransfer, - valuesToTransfer, - receiverCallbackData, - ); + const assetData = await devUtils + .encodeERC1155AssetData( + erc1155ContractAddress, + tokensToTransfer, + valuesToTransfer, + receiverCallbackData, + ) + .callAsync(); // The asset data we just generated will look like this: // a7cb5fb7 // 0x 0000000000000000000000000b1ba0af832d7c05fd64161e0db78e85978e8082 @@ -1130,12 +1146,14 @@ describe('ERC1155Proxy', () => { const valuesToTransfer = [fungibleValueToTransferLarge]; const valueMultiplier = valueMultiplierSmall; const erc1155ContractAddress = erc1155Wrapper.getContract().address; - const assetData = await devUtils.encodeERC1155AssetData.callAsync( - erc1155ContractAddress, - tokensToTransfer, - valuesToTransfer, - receiverCallbackData, - ); + const assetData = await devUtils + .encodeERC1155AssetData( + erc1155ContractAddress, + tokensToTransfer, + valuesToTransfer, + receiverCallbackData, + ) + .callAsync(); // The asset data we just generated will look like this: // a7cb5fb7 // 0x 0000000000000000000000000b1ba0af832d7c05fd64161e0db78e85978e8082 @@ -1181,12 +1199,14 @@ describe('ERC1155Proxy', () => { const valuesToTransfer = [fungibleValueToTransferLarge]; const valueMultiplier = valueMultiplierSmall; const erc1155ContractAddress = erc1155Wrapper.getContract().address; - const assetData = await devUtils.encodeERC1155AssetData.callAsync( - erc1155ContractAddress, - tokensToTransfer, - valuesToTransfer, - receiverCallbackData, - ); + const assetData = await devUtils + .encodeERC1155AssetData( + erc1155ContractAddress, + tokensToTransfer, + valuesToTransfer, + receiverCallbackData, + ) + .callAsync(); // The asset data we just generated will look like this: // a7cb5fb7 // 0x 0000000000000000000000000b1ba0af832d7c05fd64161e0db78e85978e8082 @@ -1232,12 +1252,14 @@ describe('ERC1155Proxy', () => { const valuesToTransfer = [fungibleValueToTransferLarge]; const valueMultiplier = valueMultiplierSmall; const erc1155ContractAddress = erc1155Wrapper.getContract().address; - const assetData = await devUtils.encodeERC1155AssetData.callAsync( - erc1155ContractAddress, - tokensToTransfer, - valuesToTransfer, - receiverCallbackData, - ); + const assetData = await devUtils + .encodeERC1155AssetData( + erc1155ContractAddress, + tokensToTransfer, + valuesToTransfer, + receiverCallbackData, + ) + .callAsync(); // The asset data we just generated will look like this: // a7cb5fb7 // 0x 0000000000000000000000000b1ba0af832d7c05fd64161e0db78e85978e8082 @@ -1284,12 +1306,14 @@ describe('ERC1155Proxy', () => { const valuesToTransfer = [fungibleValueToTransferLarge]; const valueMultiplier = valueMultiplierSmall; const erc1155ContractAddress = erc1155Wrapper.getContract().address; - const assetData = await devUtils.encodeERC1155AssetData.callAsync( - erc1155ContractAddress, - tokensToTransfer, - valuesToTransfer, - receiverCallbackData, - ); + const assetData = await devUtils + .encodeERC1155AssetData( + erc1155ContractAddress, + tokensToTransfer, + valuesToTransfer, + receiverCallbackData, + ) + .callAsync(); // The asset data we just generated will look like this: // a7cb5fb7 // 0x 0000000000000000000000000b1ba0af832d7c05fd64161e0db78e85978e8082 @@ -1331,12 +1355,14 @@ describe('ERC1155Proxy', () => { const valuesToTransfer = [fungibleValueToTransferLarge]; const valueMultiplier = valueMultiplierSmall; const erc1155ContractAddress = erc1155Wrapper.getContract().address; - const assetData = await devUtils.encodeERC1155AssetData.callAsync( - erc1155ContractAddress, - tokensToTransfer, - valuesToTransfer, - receiverCallbackData, - ); + const assetData = await devUtils + .encodeERC1155AssetData( + erc1155ContractAddress, + tokensToTransfer, + valuesToTransfer, + receiverCallbackData, + ) + .callAsync(); // The asset data we just generated will look like this: // a7cb5fb7 // 0x 0000000000000000000000000b1ba0af832d7c05fd64161e0db78e85978e8082 @@ -1382,12 +1408,14 @@ describe('ERC1155Proxy', () => { const valuesToTransfer = [fungibleValueToTransferLarge]; const valueMultiplier = valueMultiplierSmall; const erc1155ContractAddress = erc1155Wrapper.getContract().address; - const assetData = await devUtils.encodeERC1155AssetData.callAsync( - erc1155ContractAddress, - tokensToTransfer, - valuesToTransfer, - receiverCallbackData, - ); + const assetData = await devUtils + .encodeERC1155AssetData( + erc1155ContractAddress, + tokensToTransfer, + valuesToTransfer, + receiverCallbackData, + ) + .callAsync(); // The asset data we just generated will look like this: // a7cb5fb7 // 0x 0000000000000000000000000b1ba0af832d7c05fd64161e0db78e85978e8082 @@ -1429,12 +1457,14 @@ describe('ERC1155Proxy', () => { const valuesToTransfer = [fungibleValueToTransferLarge]; const valueMultiplier = valueMultiplierSmall; const erc1155ContractAddress = erc1155Wrapper.getContract().address; - const assetData = await devUtils.encodeERC1155AssetData.callAsync( - erc1155ContractAddress, - tokensToTransfer, - valuesToTransfer, - receiverCallbackData, - ); + const assetData = await devUtils + .encodeERC1155AssetData( + erc1155ContractAddress, + tokensToTransfer, + valuesToTransfer, + receiverCallbackData, + ) + .callAsync(); // The asset data we just generated will look like this: // a7cb5fb7 // 0x 0000000000000000000000000b1ba0af832d7c05fd64161e0db78e85978e8082 @@ -1480,12 +1510,14 @@ describe('ERC1155Proxy', () => { const valuesToTransfer = [fungibleValueToTransferLarge]; const valueMultiplier = valueMultiplierSmall; const erc1155ContractAddress = erc1155Wrapper.getContract().address; - const assetData = await devUtils.encodeERC1155AssetData.callAsync( - erc1155ContractAddress, - tokensToTransfer, - valuesToTransfer, - receiverCallbackData, - ); + const assetData = await devUtils + .encodeERC1155AssetData( + erc1155ContractAddress, + tokensToTransfer, + valuesToTransfer, + receiverCallbackData, + ) + .callAsync(); const txData = await erc1155ProxyWrapper.getTransferFromAbiEncodedTxDataAsync( spender, receiverContract, @@ -1511,12 +1543,14 @@ describe('ERC1155Proxy', () => { const valuesToTransfer = [fungibleValueToTransferLarge]; const valueMultiplier = valueMultiplierSmall; const erc1155ContractAddress = erc1155Wrapper.getContract().address; - const assetData = await devUtils.encodeERC1155AssetData.callAsync( - erc1155ContractAddress, - tokensToTransfer, - valuesToTransfer, - receiverCallbackData, - ); + const assetData = await devUtils + .encodeERC1155AssetData( + erc1155ContractAddress, + tokensToTransfer, + valuesToTransfer, + receiverCallbackData, + ) + .callAsync(); const txData = await erc1155ProxyWrapper.getTransferFromAbiEncodedTxDataAsync( spender, receiverContract, @@ -1640,7 +1674,7 @@ describe('ERC1155Proxy', () => { it('should propagate revert reason from erc1155 contract failure', async () => { // disable transfers const shouldRejectTransfer = true; - await erc1155Receiver.setRejectTransferFlag.awaitTransactionSuccessAsync(shouldRejectTransfer, { + await erc1155Receiver.setRejectTransferFlag(shouldRejectTransfer).awaitTransactionSuccessAsync({ from: owner, }); // setup test parameters diff --git a/contracts/asset-proxy/test/erc20bridge_proxy.ts b/contracts/asset-proxy/test/erc20bridge_proxy.ts index 358b0038b2..ef25b78a50 100644 --- a/contracts/asset-proxy/test/erc20bridge_proxy.ts +++ b/contracts/asset-proxy/test/erc20bridge_proxy.ts @@ -44,8 +44,8 @@ blockchainTests.resets('ERC20BridgeProxy unit tests', env => { env.txDefaults, artifacts, ); - testTokenAddress = await bridgeContract.testToken.callAsync(); - await assetProxy.addAuthorizedAddress.awaitTransactionSuccessAsync(owner); + testTokenAddress = await bridgeContract.testToken().callAsync(); + await assetProxy.addAuthorizedAddress(owner).awaitTransactionSuccessAsync(); }); interface AssetDataOpts { @@ -102,7 +102,7 @@ blockchainTests.resets('ERC20BridgeProxy unit tests', env => { } async function setTestTokenBalanceAsync(_owner: string, balance: Numberish): Promise { - await bridgeContract.setTestTokenBalance.awaitTransactionSuccessAsync(_owner, new BigNumber(balance)); + await bridgeContract.setTestTokenBalance(_owner, new BigNumber(balance)).awaitTransactionSuccessAsync(); } describe('transferFrom()', () => { @@ -132,13 +132,9 @@ blockchainTests.resets('ERC20BridgeProxy unit tests', env => { async function transferFromAsync(opts?: Partial, caller?: string): Promise { const _opts = createTransferFromOpts(opts); - const { logs } = await assetProxy.transferFrom.awaitTransactionSuccessAsync( - encodeAssetData(_opts.assetData), - _opts.from, - _opts.to, - new BigNumber(_opts.amount), - { from: caller }, - ); + const { logs } = await assetProxy + .transferFrom(encodeAssetData(_opts.assetData), _opts.from, _opts.to, new BigNumber(_opts.amount)) + .awaitTransactionSuccessAsync({ from: caller }); return (logs as any) as DecodedLogs; } @@ -180,12 +176,9 @@ blockchainTests.resets('ERC20BridgeProxy unit tests', env => { it('fails if asset data is truncated', async () => { const opts = createTransferFromOpts(); const truncatedAssetData = hexSlice(encodeAssetData(opts.assetData), 0, -1); - const tx = assetProxy.transferFrom.awaitTransactionSuccessAsync( - truncatedAssetData, - opts.from, - opts.to, - new BigNumber(opts.amount), - ); + const tx = assetProxy + .transferFrom(truncatedAssetData, opts.from, opts.to, new BigNumber(opts.amount)) + .awaitTransactionSuccessAsync(); return expect(tx).to.be.rejected(); }); @@ -281,18 +274,18 @@ blockchainTests.resets('ERC20BridgeProxy unit tests', env => { it('retrieves the balance of the encoded token', async () => { const _owner = randomAddress(); const balance = getRandomInteger(1, 100e18); - await bridgeContract.setTestTokenBalance.awaitTransactionSuccessAsync(_owner, balance); + await bridgeContract.setTestTokenBalance(_owner, balance).awaitTransactionSuccessAsync(); const assetData = createAssetData({ tokenAddress: testTokenAddress, }); - const actualBalance = await assetProxy.balanceOf.callAsync(encodeAssetData(assetData), _owner); + const actualBalance = await assetProxy.balanceOf(encodeAssetData(assetData), _owner).callAsync(); expect(actualBalance).to.bignumber.eq(balance); }); }); describe('getProxyId()', () => { it('returns the correct proxy ID', async () => { - const proxyId = await assetProxy.getProxyId.callAsync(); + const proxyId = await assetProxy.getProxyId().callAsync(); expect(proxyId).to.eq(PROXY_ID); }); }); diff --git a/contracts/asset-proxy/test/eth2dai_bridge.ts b/contracts/asset-proxy/test/eth2dai_bridge.ts index 2cf0173239..4af06f95a8 100644 --- a/contracts/asset-proxy/test/eth2dai_bridge.ts +++ b/contracts/asset-proxy/test/eth2dai_bridge.ts @@ -8,7 +8,7 @@ import { hexRandom, Numberish, randomAddress, - TransactionHelper, + transactionHelper, } from '@0x/contracts-test-utils'; import { AssetProxyId } from '@0x/types'; import { BigNumber, RawRevertError } from '@0x/utils'; @@ -25,7 +25,6 @@ import { } from '../src'; blockchainTests.resets('Eth2DaiBridge unit tests', env => { - const txHelper = new TransactionHelper(env.web3Wrapper, artifacts); let testContract: TestEth2DaiBridgeContract; before(async () => { @@ -40,7 +39,7 @@ blockchainTests.resets('Eth2DaiBridge unit tests', env => { describe('isValidSignature()', () => { it('returns success bytes', async () => { const LEGACY_WALLET_MAGIC_VALUE = '0xb0671381'; - const result = await testContract.isValidSignature.callAsync(hexRandom(), hexRandom(_.random(0, 32))); + const result = await testContract.isValidSignature(hexRandom(), hexRandom(_.random(0, 32))).callAsync(); expect(result).to.eq(LEGACY_WALLET_MAGIC_VALUE); }); }); @@ -80,31 +79,32 @@ blockchainTests.resets('Eth2DaiBridge unit tests', env => { async function withdrawToAsync(opts?: Partial): Promise { const _opts = createWithdrawToOpts(opts); // Set the fill behavior. - await testContract.setFillBehavior.awaitTransactionSuccessAsync( - _opts.revertReason, - new BigNumber(_opts.fillAmount), - ); + await testContract + .setFillBehavior(_opts.revertReason, new BigNumber(_opts.fillAmount)) + .awaitTransactionSuccessAsync(); // Create tokens and balances. if (_opts.fromTokenAddress === undefined) { - [_opts.fromTokenAddress] = await txHelper.getResultAndReceiptAsync( + [_opts.fromTokenAddress] = await transactionHelper.getResultAndReceiptAsync( testContract.createToken, new BigNumber(_opts.fromTokenBalance), ); } if (_opts.toTokenAddress === undefined) { - [_opts.toTokenAddress] = await txHelper.getResultAndReceiptAsync( + [_opts.toTokenAddress] = await transactionHelper.getResultAndReceiptAsync( testContract.createToken, constants.ZERO_AMOUNT, ); } // Set the transfer behavior of `toTokenAddress`. - await testContract.setTransferBehavior.awaitTransactionSuccessAsync( - _opts.toTokenAddress, - _opts.toTokentransferRevertReason, - _opts.toTokenTransferReturnData, - ); + await testContract + .setTransferBehavior( + _opts.toTokenAddress, + _opts.toTokentransferRevertReason, + _opts.toTokenTransferReturnData, + ) + .awaitTransactionSuccessAsync(); // Call bridgeTransferFrom(). - const [result, { logs }] = await txHelper.getResultAndReceiptAsync( + const [result, { logs }] = await transactionHelper.getResultAndReceiptAsync( testContract.bridgeTransferFrom, // "to" token address _opts.toTokenAddress, diff --git a/contracts/asset-proxy/test/proxies.ts b/contracts/asset-proxy/test/proxies.ts index 232b085086..9de496ec3e 100644 --- a/contracts/asset-proxy/test/proxies.ts +++ b/contracts/asset-proxy/test/proxies.ts @@ -107,24 +107,24 @@ describe('Asset Transfer Proxies', () => { ); // Configure ERC20Proxy - await erc20Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(authorized, { from: owner }); - await erc20Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(multiAssetProxy.address, { from: owner }); + await erc20Proxy.addAuthorizedAddress(authorized).awaitTransactionSuccessAsync({ from: owner }); + await erc20Proxy.addAuthorizedAddress(multiAssetProxy.address).awaitTransactionSuccessAsync({ from: owner }); // Configure ERC721Proxy - await erc721Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(authorized, { from: owner }); - await erc721Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(multiAssetProxy.address, { from: owner }); + await erc721Proxy.addAuthorizedAddress(authorized).awaitTransactionSuccessAsync({ from: owner }); + await erc721Proxy.addAuthorizedAddress(multiAssetProxy.address).awaitTransactionSuccessAsync({ from: owner }); // Configure ERC115Proxy erc1155ProxyWrapper = new ERC1155ProxyWrapper(provider, usedAddresses, owner); erc1155Proxy = await erc1155ProxyWrapper.deployProxyAsync(); - await erc1155Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(authorized, { from: owner }); - await erc1155Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(multiAssetProxy.address, { from: owner }); + await erc1155Proxy.addAuthorizedAddress(authorized).awaitTransactionSuccessAsync({ from: owner }); + await erc1155Proxy.addAuthorizedAddress(multiAssetProxy.address).awaitTransactionSuccessAsync({ from: owner }); // Configure MultiAssetProxy - await multiAssetProxy.addAuthorizedAddress.awaitTransactionSuccessAsync(authorized, { from: owner }); - await multiAssetProxy.registerAssetProxy.awaitTransactionSuccessAsync(erc20Proxy.address, { from: owner }); - await multiAssetProxy.registerAssetProxy.awaitTransactionSuccessAsync(erc721Proxy.address, { from: owner }); - await multiAssetProxy.registerAssetProxy.awaitTransactionSuccessAsync(erc1155Proxy.address, { from: owner }); + await multiAssetProxy.addAuthorizedAddress(authorized).awaitTransactionSuccessAsync({ from: owner }); + await multiAssetProxy.registerAssetProxy(erc20Proxy.address).awaitTransactionSuccessAsync({ from: owner }); + await multiAssetProxy.registerAssetProxy(erc721Proxy.address).awaitTransactionSuccessAsync({ from: owner }); + await multiAssetProxy.registerAssetProxy(erc1155Proxy.address).awaitTransactionSuccessAsync({ from: owner }); // Deploy and configure ERC20 tokens const numDummyErc20ToDeploy = 2; @@ -154,26 +154,20 @@ describe('Asset Transfer Proxies', () => { ); await erc20Wrapper.setBalancesAndAllowancesAsync(); - await noReturnErc20Token.setBalance.awaitTransactionSuccessAsync(fromAddress, constants.INITIAL_ERC20_BALANCE, { + await noReturnErc20Token.setBalance(fromAddress, constants.INITIAL_ERC20_BALANCE).awaitTransactionSuccessAsync({ from: owner, }); - await noReturnErc20Token.approve.awaitTransactionSuccessAsync( - erc20Proxy.address, - constants.INITIAL_ERC20_ALLOWANCE, - { from: fromAddress }, - ); - await multipleReturnErc20Token.setBalance.awaitTransactionSuccessAsync( - fromAddress, - constants.INITIAL_ERC20_BALANCE, - { + await noReturnErc20Token + .approve(erc20Proxy.address, constants.INITIAL_ERC20_ALLOWANCE) + .awaitTransactionSuccessAsync({ from: fromAddress }); + await multipleReturnErc20Token + .setBalance(fromAddress, constants.INITIAL_ERC20_BALANCE) + .awaitTransactionSuccessAsync({ from: owner, - }, - ); - await multipleReturnErc20Token.approve.awaitTransactionSuccessAsync( - erc20Proxy.address, - constants.INITIAL_ERC20_ALLOWANCE, - { from: fromAddress }, - ); + }); + await multipleReturnErc20Token + .approve(erc20Proxy.address, constants.INITIAL_ERC20_ALLOWANCE) + .awaitTransactionSuccessAsync({ from: fromAddress }); // Deploy and configure ERC721 tokens and receiver [erc721TokenA, erc721TokenB] = await erc721Wrapper.deployDummyTokensAsync(); @@ -225,23 +219,20 @@ describe('Asset Transfer Proxies', () => { ); }); it('should have an id of 0xf47261b0', async () => { - const proxyId = await erc20Proxy.getProxyId.callAsync(); + const proxyId = await erc20Proxy.getProxyId().callAsync(); const expectedProxyId = '0xf47261b0'; expect(proxyId).to.equal(expectedProxyId); }); describe('transferFrom', () => { it('should successfully transfer tokens', async () => { // Construct ERC20 asset data - const encodedAssetData = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); + const encodedAssetData = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); // Perform a transfer from fromAddress to toAddress const erc20Balances = await erc20Wrapper.getBalancesAsync(); const amount = new BigNumber(10); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - encodedAssetData, - fromAddress, - toAddress, - amount, - ); + const data = assetProxyInterface + .transferFrom(encodedAssetData, fromAddress, toAddress, amount) + .getABIEncodedTransactionData(); await web3Wrapper.awaitTransactionSuccessAsync( await web3Wrapper.sendTransactionAsync({ to: erc20Proxy.address, @@ -262,17 +253,14 @@ describe('Asset Transfer Proxies', () => { it('should successfully transfer tokens that do not return a value', async () => { // Construct ERC20 asset data - const encodedAssetData = await devUtils.encodeERC20AssetData.callAsync(noReturnErc20Token.address); + const encodedAssetData = await devUtils.encodeERC20AssetData(noReturnErc20Token.address).callAsync(); // Perform a transfer from fromAddress to toAddress - const initialFromBalance = await noReturnErc20Token.balanceOf.callAsync(fromAddress); - const initialToBalance = await noReturnErc20Token.balanceOf.callAsync(toAddress); + const initialFromBalance = await noReturnErc20Token.balanceOf(fromAddress).callAsync(); + const initialToBalance = await noReturnErc20Token.balanceOf(toAddress).callAsync(); const amount = new BigNumber(10); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - encodedAssetData, - fromAddress, - toAddress, - amount, - ); + const data = assetProxyInterface + .transferFrom(encodedAssetData, fromAddress, toAddress, amount) + .getABIEncodedTransactionData(); await web3Wrapper.awaitTransactionSuccessAsync( await web3Wrapper.sendTransactionAsync({ to: erc20Proxy.address, @@ -282,8 +270,8 @@ describe('Asset Transfer Proxies', () => { constants.AWAIT_TRANSACTION_MINED_MS, ); // Verify transfer was successful - const newFromBalance = await noReturnErc20Token.balanceOf.callAsync(fromAddress); - const newToBalance = await noReturnErc20Token.balanceOf.callAsync(toAddress); + const newFromBalance = await noReturnErc20Token.balanceOf(fromAddress).callAsync(); + const newToBalance = await noReturnErc20Token.balanceOf(toAddress).callAsync(); expect(newFromBalance).to.be.bignumber.equal(initialFromBalance.minus(amount)); expect(newToBalance).to.be.bignumber.equal(initialToBalance.plus(amount)); }); @@ -291,18 +279,15 @@ describe('Asset Transfer Proxies', () => { it('should successfully transfer tokens and ignore extra assetData', async () => { // Construct ERC20 asset data const extraData = '0102030405060708'; - const encodedAssetData = `${await devUtils.encodeERC20AssetData.callAsync( - erc20TokenA.address, - )}${extraData}`; + const encodedAssetData = `${await devUtils + .encodeERC20AssetData(erc20TokenA.address) + .callAsync()}${extraData}`; // Perform a transfer from fromAddress to toAddress const erc20Balances = await erc20Wrapper.getBalancesAsync(); const amount = new BigNumber(10); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - encodedAssetData, - fromAddress, - toAddress, - amount, - ); + const data = assetProxyInterface + .transferFrom(encodedAssetData, fromAddress, toAddress, amount) + .getABIEncodedTransactionData(); await web3Wrapper.awaitTransactionSuccessAsync( await web3Wrapper.sendTransactionAsync({ to: erc20Proxy.address, @@ -323,16 +308,13 @@ describe('Asset Transfer Proxies', () => { it('should do nothing if transferring 0 amount of a token', async () => { // Construct ERC20 asset data - const encodedAssetData = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); + const encodedAssetData = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); // Perform a transfer from fromAddress to toAddress const erc20Balances = await erc20Wrapper.getBalancesAsync(); const amount = new BigNumber(0); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - encodedAssetData, - fromAddress, - toAddress, - amount, - ); + const data = assetProxyInterface + .transferFrom(encodedAssetData, fromAddress, toAddress, amount) + .getABIEncodedTransactionData(); await web3Wrapper.awaitTransactionSuccessAsync( await web3Wrapper.sendTransactionAsync({ to: erc20Proxy.address, @@ -353,17 +335,14 @@ describe('Asset Transfer Proxies', () => { it('should revert if allowances are too low', async () => { // Construct ERC20 asset data - const encodedAssetData = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); + const encodedAssetData = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); // Create allowance less than transfer amount. Set allowance on proxy. const allowance = new BigNumber(0); const amount = new BigNumber(10); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - encodedAssetData, - fromAddress, - toAddress, - amount, - ); - await erc20TokenA.approve.awaitTransactionSuccessAsync(erc20Proxy.address, allowance, { + const data = assetProxyInterface + .transferFrom(encodedAssetData, fromAddress, toAddress, amount) + .getABIEncodedTransactionData(); + await erc20TokenA.approve(erc20Proxy.address, allowance).awaitTransactionSuccessAsync({ from: fromAddress, }); const erc20Balances = await erc20Wrapper.getBalancesAsync(); @@ -382,21 +361,18 @@ describe('Asset Transfer Proxies', () => { it('should revert if allowances are too low and token does not return a value', async () => { // Construct ERC20 asset data - const encodedAssetData = await devUtils.encodeERC20AssetData.callAsync(noReturnErc20Token.address); + const encodedAssetData = await devUtils.encodeERC20AssetData(noReturnErc20Token.address).callAsync(); // Create allowance less than transfer amount. Set allowance on proxy. const allowance = new BigNumber(0); const amount = new BigNumber(10); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - encodedAssetData, - fromAddress, - toAddress, - amount, - ); - await noReturnErc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, allowance, { + const data = assetProxyInterface + .transferFrom(encodedAssetData, fromAddress, toAddress, amount) + .getABIEncodedTransactionData(); + await noReturnErc20Token.approve(erc20Proxy.address, allowance).awaitTransactionSuccessAsync({ from: fromAddress, }); - const initialFromBalance = await noReturnErc20Token.balanceOf.callAsync(fromAddress); - const initialToBalance = await noReturnErc20Token.balanceOf.callAsync(toAddress); + const initialFromBalance = await noReturnErc20Token.balanceOf(fromAddress).callAsync(); + const initialToBalance = await noReturnErc20Token.balanceOf(toAddress).callAsync(); // Perform a transfer; expect this to fail. await expectTransactionFailedAsync( web3Wrapper.sendTransactionAsync({ @@ -406,23 +382,20 @@ describe('Asset Transfer Proxies', () => { }), RevertReason.TransferFailed, ); - const newFromBalance = await noReturnErc20Token.balanceOf.callAsync(fromAddress); - const newToBalance = await noReturnErc20Token.balanceOf.callAsync(toAddress); + const newFromBalance = await noReturnErc20Token.balanceOf(fromAddress).callAsync(); + const newToBalance = await noReturnErc20Token.balanceOf(toAddress).callAsync(); expect(newFromBalance).to.be.bignumber.equal(initialFromBalance); expect(newToBalance).to.be.bignumber.equal(initialToBalance); }); it('should revert if caller is not authorized', async () => { // Construct ERC20 asset data - const encodedAssetData = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); + const encodedAssetData = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); // Perform a transfer from fromAddress to toAddress const amount = new BigNumber(10); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - encodedAssetData, - fromAddress, - toAddress, - amount, - ); + const data = assetProxyInterface + .transferFrom(encodedAssetData, fromAddress, toAddress, amount) + .getABIEncodedTransactionData(); const erc20Balances = await erc20Wrapper.getBalancesAsync(); await expectTransactionFailedAsync( web3Wrapper.sendTransactionAsync({ @@ -438,18 +411,15 @@ describe('Asset Transfer Proxies', () => { it('should revert if token returns more than 32 bytes', async () => { // Construct ERC20 asset data - const encodedAssetData = await devUtils.encodeERC20AssetData.callAsync( - multipleReturnErc20Token.address, - ); + const encodedAssetData = await devUtils + .encodeERC20AssetData(multipleReturnErc20Token.address) + .callAsync(); const amount = new BigNumber(10); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - encodedAssetData, - fromAddress, - toAddress, - amount, - ); - const initialFromBalance = await multipleReturnErc20Token.balanceOf.callAsync(fromAddress); - const initialToBalance = await multipleReturnErc20Token.balanceOf.callAsync(toAddress); + const data = assetProxyInterface + .transferFrom(encodedAssetData, fromAddress, toAddress, amount) + .getABIEncodedTransactionData(); + const initialFromBalance = await multipleReturnErc20Token.balanceOf(fromAddress).callAsync(); + const initialToBalance = await multipleReturnErc20Token.balanceOf(toAddress).callAsync(); // Perform a transfer; expect this to fail. await expectTransactionFailedAsync( web3Wrapper.sendTransactionAsync({ @@ -459,8 +429,8 @@ describe('Asset Transfer Proxies', () => { }), RevertReason.TransferFailed, ); - const newFromBalance = await multipleReturnErc20Token.balanceOf.callAsync(fromAddress); - const newToBalance = await multipleReturnErc20Token.balanceOf.callAsync(toAddress); + const newFromBalance = await multipleReturnErc20Token.balanceOf(fromAddress).callAsync(); + const newToBalance = await multipleReturnErc20Token.balanceOf(toAddress).callAsync(); expect(newFromBalance).to.be.bignumber.equal(initialFromBalance); expect(newToBalance).to.be.bignumber.equal(initialToBalance); }); @@ -480,28 +450,24 @@ describe('Asset Transfer Proxies', () => { ); }); it('should have an id of 0x02571792', async () => { - const proxyId = await erc721Proxy.getProxyId.callAsync(); + const proxyId = await erc721Proxy.getProxyId().callAsync(); const expectedProxyId = '0x02571792'; expect(proxyId).to.equal(expectedProxyId); }); describe('transferFrom', () => { it('should successfully transfer tokens', async () => { // Construct ERC721 asset data - const encodedAssetData = await devUtils.encodeERC721AssetData.callAsync( - erc721TokenA.address, - erc721AFromTokenId, - ); + const encodedAssetData = await devUtils + .encodeERC721AssetData(erc721TokenA.address, erc721AFromTokenId) + .callAsync(); // Verify pre-condition - const ownerFromAsset = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId); + const ownerFromAsset = await erc721TokenA.ownerOf(erc721AFromTokenId).callAsync(); expect(ownerFromAsset).to.be.equal(fromAddress); // Perform a transfer from fromAddress to toAddress const amount = new BigNumber(1); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - encodedAssetData, - fromAddress, - toAddress, - amount, - ); + const data = assetProxyInterface + .transferFrom(encodedAssetData, fromAddress, toAddress, amount) + .getABIEncodedTransactionData(); await web3Wrapper.awaitTransactionSuccessAsync( await web3Wrapper.sendTransactionAsync({ to: erc721Proxy.address, @@ -511,28 +477,24 @@ describe('Asset Transfer Proxies', () => { constants.AWAIT_TRANSACTION_MINED_MS, ); // Verify transfer was successful - const newOwnerFromAsset = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId); + const newOwnerFromAsset = await erc721TokenA.ownerOf(erc721AFromTokenId).callAsync(); expect(newOwnerFromAsset).to.be.bignumber.equal(toAddress); }); it('should successfully transfer tokens and ignore extra assetData', async () => { // Construct ERC721 asset data const extraData = '0102030405060708'; - const encodedAssetData = `${await devUtils.encodeERC721AssetData.callAsync( - erc721TokenA.address, - erc721AFromTokenId, - )}${extraData}`; + const encodedAssetData = `${await devUtils + .encodeERC721AssetData(erc721TokenA.address, erc721AFromTokenId) + .callAsync()}${extraData}`; // Verify pre-condition - const ownerFromAsset = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId); + const ownerFromAsset = await erc721TokenA.ownerOf(erc721AFromTokenId).callAsync(); expect(ownerFromAsset).to.be.equal(fromAddress); // Perform a transfer from fromAddress to toAddress const amount = new BigNumber(1); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - encodedAssetData, - fromAddress, - toAddress, - amount, - ); + const data = assetProxyInterface + .transferFrom(encodedAssetData, fromAddress, toAddress, amount) + .getABIEncodedTransactionData(); await web3Wrapper.awaitTransactionSuccessAsync( await web3Wrapper.sendTransactionAsync({ to: erc721Proxy.address, @@ -542,27 +504,23 @@ describe('Asset Transfer Proxies', () => { constants.AWAIT_TRANSACTION_MINED_MS, ); // Verify transfer was successful - const newOwnerFromAsset = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId); + const newOwnerFromAsset = await erc721TokenA.ownerOf(erc721AFromTokenId).callAsync(); expect(newOwnerFromAsset).to.be.bignumber.equal(toAddress); }); it('should not call onERC721Received when transferring to a smart contract', async () => { // Construct ERC721 asset data - const encodedAssetData = await devUtils.encodeERC721AssetData.callAsync( - erc721TokenA.address, - erc721AFromTokenId, - ); + const encodedAssetData = await devUtils + .encodeERC721AssetData(erc721TokenA.address, erc721AFromTokenId) + .callAsync(); // Verify pre-condition - const ownerFromAsset = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId); + const ownerFromAsset = await erc721TokenA.ownerOf(erc721AFromTokenId).callAsync(); expect(ownerFromAsset).to.be.equal(fromAddress); // Perform a transfer from fromAddress to toAddress const amount = new BigNumber(1); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - encodedAssetData, - fromAddress, - erc721Receiver.address, - amount, - ); + const data = assetProxyInterface + .transferFrom(encodedAssetData, fromAddress, erc721Receiver.address, amount) + .getABIEncodedTransactionData(); const logDecoder = new LogDecoder(web3Wrapper, { ...artifacts, ...erc721Artifacts }); const tx = await logDecoder.getTxWithDecodedLogsAsync( await web3Wrapper.sendTransactionAsync({ @@ -575,27 +533,23 @@ describe('Asset Transfer Proxies', () => { // Verify that no log was emitted by erc721 receiver expect(tx.logs.length).to.be.equal(1); // Verify transfer was successful - const newOwnerFromAsset = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId); + const newOwnerFromAsset = await erc721TokenA.ownerOf(erc721AFromTokenId).callAsync(); expect(newOwnerFromAsset).to.be.bignumber.equal(erc721Receiver.address); }); it('should revert if transferring 0 amount of a token', async () => { // Construct ERC721 asset data - const encodedAssetData = await devUtils.encodeERC721AssetData.callAsync( - erc721TokenA.address, - erc721AFromTokenId, - ); + const encodedAssetData = await devUtils + .encodeERC721AssetData(erc721TokenA.address, erc721AFromTokenId) + .callAsync(); // Verify pre-condition - const ownerFromAsset = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId); + const ownerFromAsset = await erc721TokenA.ownerOf(erc721AFromTokenId).callAsync(); expect(ownerFromAsset).to.be.equal(fromAddress); // Perform a transfer from fromAddress to toAddress const amount = new BigNumber(0); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - encodedAssetData, - fromAddress, - toAddress, - amount, - ); + const data = assetProxyInterface + .transferFrom(encodedAssetData, fromAddress, toAddress, amount) + .getABIEncodedTransactionData(); await expectTransactionFailedAsync( web3Wrapper.sendTransactionAsync({ to: erc721Proxy.address, @@ -604,27 +558,23 @@ describe('Asset Transfer Proxies', () => { }), RevertReason.InvalidAmount, ); - const newOwner = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId); + const newOwner = await erc721TokenA.ownerOf(erc721AFromTokenId).callAsync(); expect(newOwner).to.be.equal(ownerFromAsset); }); it('should revert if transferring > 1 amount of a token', async () => { // Construct ERC721 asset data - const encodedAssetData = await devUtils.encodeERC721AssetData.callAsync( - erc721TokenA.address, - erc721AFromTokenId, - ); + const encodedAssetData = await devUtils + .encodeERC721AssetData(erc721TokenA.address, erc721AFromTokenId) + .callAsync(); // Verify pre-condition - const ownerFromAsset = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId); + const ownerFromAsset = await erc721TokenA.ownerOf(erc721AFromTokenId).callAsync(); expect(ownerFromAsset).to.be.equal(fromAddress); // Perform a transfer from fromAddress to toAddress const amount = new BigNumber(500); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - encodedAssetData, - fromAddress, - toAddress, - amount, - ); + const data = assetProxyInterface + .transferFrom(encodedAssetData, fromAddress, toAddress, amount) + .getABIEncodedTransactionData(); await expectTransactionFailedAsync( web3Wrapper.sendTransactionAsync({ to: erc721Proxy.address, @@ -633,35 +583,31 @@ describe('Asset Transfer Proxies', () => { }), RevertReason.InvalidAmount, ); - const newOwner = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId); + const newOwner = await erc721TokenA.ownerOf(erc721AFromTokenId).callAsync(); expect(newOwner).to.be.equal(ownerFromAsset); }); it('should revert if allowances are too low', async () => { // Construct ERC721 asset data - const encodedAssetData = await devUtils.encodeERC721AssetData.callAsync( - erc721TokenA.address, - erc721AFromTokenId, - ); + const encodedAssetData = await devUtils + .encodeERC721AssetData(erc721TokenA.address, erc721AFromTokenId) + .callAsync(); // Verify pre-condition - const ownerFromAsset = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId); + const ownerFromAsset = await erc721TokenA.ownerOf(erc721AFromTokenId).callAsync(); expect(ownerFromAsset).to.be.equal(fromAddress); // Remove blanket transfer approval for fromAddress. - await erc721TokenA.setApprovalForAll.awaitTransactionSuccessAsync(erc721Proxy.address, false, { + await erc721TokenA.setApprovalForAll(erc721Proxy.address, false).awaitTransactionSuccessAsync({ from: fromAddress, }); // Remove token transfer approval for fromAddress. - await erc721TokenA.approve.awaitTransactionSuccessAsync(constants.NULL_ADDRESS, erc721AFromTokenId, { + await erc721TokenA.approve(constants.NULL_ADDRESS, erc721AFromTokenId).awaitTransactionSuccessAsync({ from: fromAddress, }); // Perform a transfer; expect this to fail. const amount = new BigNumber(1); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - encodedAssetData, - fromAddress, - toAddress, - amount, - ); + const data = assetProxyInterface + .transferFrom(encodedAssetData, fromAddress, toAddress, amount) + .getABIEncodedTransactionData(); await expectTransactionFailedAsync( web3Wrapper.sendTransactionAsync({ to: erc721Proxy.address, @@ -670,27 +616,23 @@ describe('Asset Transfer Proxies', () => { }), RevertReason.TransferFailed, ); - const newOwner = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId); + const newOwner = await erc721TokenA.ownerOf(erc721AFromTokenId).callAsync(); expect(newOwner).to.be.equal(ownerFromAsset); }); it('should revert if caller is not authorized', async () => { // Construct ERC721 asset data - const encodedAssetData = await devUtils.encodeERC721AssetData.callAsync( - erc721TokenA.address, - erc721AFromTokenId, - ); + const encodedAssetData = await devUtils + .encodeERC721AssetData(erc721TokenA.address, erc721AFromTokenId) + .callAsync(); // Verify pre-condition - const ownerFromAsset = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId); + const ownerFromAsset = await erc721TokenA.ownerOf(erc721AFromTokenId).callAsync(); expect(ownerFromAsset).to.be.equal(fromAddress); // Perform a transfer from fromAddress to toAddress const amount = new BigNumber(1); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - encodedAssetData, - fromAddress, - toAddress, - amount, - ); + const data = assetProxyInterface + .transferFrom(encodedAssetData, fromAddress, toAddress, amount) + .getABIEncodedTransactionData(); await expectTransactionFailedAsync( web3Wrapper.sendTransactionAsync({ to: erc721Proxy.address, @@ -699,7 +641,7 @@ describe('Asset Transfer Proxies', () => { }), RevertReason.SenderNotAuthorized, ); - const newOwner = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId); + const newOwner = await erc721TokenA.ownerOf(erc721AFromTokenId).callAsync(); expect(newOwner).to.be.equal(ownerFromAsset); }); }); @@ -717,7 +659,7 @@ describe('Asset Transfer Proxies', () => { ); }); it('should have an id of 0x94cfcdd7', async () => { - const proxyId = await multiAssetProxy.getProxyId.callAsync(); + const proxyId = await multiAssetProxy.getProxyId().callAsync(); // first 4 bytes of `keccak256('MultiAsset(uint256[],bytes[])')` const expectedProxyId = '0x94cfcdd7'; expect(proxyId).to.equal(expectedProxyId); @@ -726,16 +668,13 @@ describe('Asset Transfer Proxies', () => { it('should transfer a single ERC20 token', async () => { const inputAmount = new BigNumber(1); const erc20Amount = new BigNumber(10); - const erc20AssetData = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); + const erc20AssetData = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); const amounts = [erc20Amount]; const nestedAssetData = [erc20AssetData]; - const assetData = await devUtils.encodeMultiAssetData.callAsync(amounts, nestedAssetData); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - assetData, - fromAddress, - toAddress, - inputAmount, - ); + const assetData = await devUtils.encodeMultiAssetData(amounts, nestedAssetData).callAsync(); + const data = assetProxyInterface + .transferFrom(assetData, fromAddress, toAddress, inputAmount) + .getABIEncodedTransactionData(); const erc20Balances = await erc20Wrapper.getBalancesAsync(); await web3Wrapper.awaitTransactionSuccessAsync( await web3Wrapper.sendTransactionAsync({ @@ -757,16 +696,15 @@ describe('Asset Transfer Proxies', () => { it('should dispatch an ERC20 transfer when input amount is 0', async () => { const inputAmount = constants.ZERO_AMOUNT; const erc20Amount = new BigNumber(10); - const erc20AssetData = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); + const erc20AssetData = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); const amounts = [erc20Amount]; const nestedAssetData = [erc20AssetData]; - const assetData = assetDataInterface.MultiAsset.getABIEncodedTransactionData(amounts, nestedAssetData); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - assetData, - fromAddress, - toAddress, - inputAmount, - ); + const assetData = assetDataInterface + .MultiAsset(amounts, nestedAssetData) + .getABIEncodedTransactionData(); + const data = assetProxyInterface + .transferFrom(assetData, fromAddress, toAddress, inputAmount) + .getABIEncodedTransactionData(); const erc20Balances = await erc20Wrapper.getBalancesAsync(); const logDecoder = new LogDecoder(web3Wrapper, { ...artifacts, ...erc20Artifacts }); const tx = await logDecoder.getTxWithDecodedLogsAsync( @@ -788,17 +726,14 @@ describe('Asset Transfer Proxies', () => { const inputAmount = new BigNumber(1); const erc20Amount1 = new BigNumber(10); const erc20Amount2 = new BigNumber(20); - const erc20AssetData1 = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); - const erc20AssetData2 = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); + const erc20AssetData1 = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); + const erc20AssetData2 = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); const amounts = [erc20Amount1, erc20Amount2]; const nestedAssetData = [erc20AssetData1, erc20AssetData2]; - const assetData = await devUtils.encodeMultiAssetData.callAsync(amounts, nestedAssetData); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - assetData, - fromAddress, - toAddress, - inputAmount, - ); + const assetData = await devUtils.encodeMultiAssetData(amounts, nestedAssetData).callAsync(); + const data = assetProxyInterface + .transferFrom(assetData, fromAddress, toAddress, inputAmount) + .getABIEncodedTransactionData(); const erc20Balances = await erc20Wrapper.getBalancesAsync(); await web3Wrapper.awaitTransactionSuccessAsync( await web3Wrapper.sendTransactionAsync({ @@ -821,17 +756,14 @@ describe('Asset Transfer Proxies', () => { const inputAmount = new BigNumber(1); const erc20Amount1 = new BigNumber(10); const erc20Amount2 = new BigNumber(20); - const erc20AssetData1 = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); - const erc20AssetData2 = await devUtils.encodeERC20AssetData.callAsync(erc20TokenB.address); + const erc20AssetData1 = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); + const erc20AssetData2 = await devUtils.encodeERC20AssetData(erc20TokenB.address).callAsync(); const amounts = [erc20Amount1, erc20Amount2]; const nestedAssetData = [erc20AssetData1, erc20AssetData2]; - const assetData = await devUtils.encodeMultiAssetData.callAsync(amounts, nestedAssetData); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - assetData, - fromAddress, - toAddress, - inputAmount, - ); + const assetData = await devUtils.encodeMultiAssetData(amounts, nestedAssetData).callAsync(); + const data = assetProxyInterface + .transferFrom(assetData, fromAddress, toAddress, inputAmount) + .getABIEncodedTransactionData(); const erc20Balances = await erc20Wrapper.getBalancesAsync(); await web3Wrapper.awaitTransactionSuccessAsync( await web3Wrapper.sendTransactionAsync({ @@ -860,20 +792,16 @@ describe('Asset Transfer Proxies', () => { it('should transfer a single ERC721 token', async () => { const inputAmount = new BigNumber(1); const erc721Amount = new BigNumber(1); - const erc721AssetData = await devUtils.encodeERC721AssetData.callAsync( - erc721TokenA.address, - erc721AFromTokenId, - ); + const erc721AssetData = await devUtils + .encodeERC721AssetData(erc721TokenA.address, erc721AFromTokenId) + .callAsync(); const amounts = [erc721Amount]; const nestedAssetData = [erc721AssetData]; - const assetData = await devUtils.encodeMultiAssetData.callAsync(amounts, nestedAssetData); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - assetData, - fromAddress, - toAddress, - inputAmount, - ); - const ownerFromAsset = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId); + const assetData = await devUtils.encodeMultiAssetData(amounts, nestedAssetData).callAsync(); + const data = assetProxyInterface + .transferFrom(assetData, fromAddress, toAddress, inputAmount) + .getABIEncodedTransactionData(); + const ownerFromAsset = await erc721TokenA.ownerOf(erc721AFromTokenId).callAsync(); expect(ownerFromAsset).to.be.equal(fromAddress); await web3Wrapper.awaitTransactionSuccessAsync( await web3Wrapper.sendTransactionAsync({ @@ -883,34 +811,29 @@ describe('Asset Transfer Proxies', () => { }), constants.AWAIT_TRANSACTION_MINED_MS, ); - const newOwnerFromAsset = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId); + const newOwnerFromAsset = await erc721TokenA.ownerOf(erc721AFromTokenId).callAsync(); expect(newOwnerFromAsset).to.be.equal(toAddress); }); it('should successfully transfer multiple of the same ERC721 token', async () => { const erc721Balances = await erc721Wrapper.getBalancesAsync(); const erc721AFromTokenId2 = erc721Balances[fromAddress][erc721TokenA.address][1]; - const erc721AssetData1 = await devUtils.encodeERC721AssetData.callAsync( - erc721TokenA.address, - erc721AFromTokenId, - ); - const erc721AssetData2 = await devUtils.encodeERC721AssetData.callAsync( - erc721TokenA.address, - erc721AFromTokenId2, - ); + const erc721AssetData1 = await devUtils + .encodeERC721AssetData(erc721TokenA.address, erc721AFromTokenId) + .callAsync(); + const erc721AssetData2 = await devUtils + .encodeERC721AssetData(erc721TokenA.address, erc721AFromTokenId2) + .callAsync(); const inputAmount = new BigNumber(1); const erc721Amount = new BigNumber(1); const amounts = [erc721Amount, erc721Amount]; const nestedAssetData = [erc721AssetData1, erc721AssetData2]; - const assetData = await devUtils.encodeMultiAssetData.callAsync(amounts, nestedAssetData); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - assetData, - fromAddress, - toAddress, - inputAmount, - ); - const ownerFromAsset1 = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId); + const assetData = await devUtils.encodeMultiAssetData(amounts, nestedAssetData).callAsync(); + const data = assetProxyInterface + .transferFrom(assetData, fromAddress, toAddress, inputAmount) + .getABIEncodedTransactionData(); + const ownerFromAsset1 = await erc721TokenA.ownerOf(erc721AFromTokenId).callAsync(); expect(ownerFromAsset1).to.be.equal(fromAddress); - const ownerFromAsset2 = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId2); + const ownerFromAsset2 = await erc721TokenA.ownerOf(erc721AFromTokenId2).callAsync(); expect(ownerFromAsset2).to.be.equal(fromAddress); await web3Wrapper.awaitTransactionSuccessAsync( await web3Wrapper.sendTransactionAsync({ @@ -921,34 +844,29 @@ describe('Asset Transfer Proxies', () => { }), constants.AWAIT_TRANSACTION_MINED_MS, ); - const newOwnerFromAsset1 = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId); - const newOwnerFromAsset2 = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId2); + const newOwnerFromAsset1 = await erc721TokenA.ownerOf(erc721AFromTokenId).callAsync(); + const newOwnerFromAsset2 = await erc721TokenA.ownerOf(erc721AFromTokenId2).callAsync(); expect(newOwnerFromAsset1).to.be.equal(toAddress); expect(newOwnerFromAsset2).to.be.equal(toAddress); }); it('should successfully transfer multiple different ERC721 tokens', async () => { - const erc721AssetData1 = await devUtils.encodeERC721AssetData.callAsync( - erc721TokenA.address, - erc721AFromTokenId, - ); - const erc721AssetData2 = await devUtils.encodeERC721AssetData.callAsync( - erc721TokenB.address, - erc721BFromTokenId, - ); + const erc721AssetData1 = await devUtils + .encodeERC721AssetData(erc721TokenA.address, erc721AFromTokenId) + .callAsync(); + const erc721AssetData2 = await devUtils + .encodeERC721AssetData(erc721TokenB.address, erc721BFromTokenId) + .callAsync(); const inputAmount = new BigNumber(1); const erc721Amount = new BigNumber(1); const amounts = [erc721Amount, erc721Amount]; const nestedAssetData = [erc721AssetData1, erc721AssetData2]; - const assetData = await devUtils.encodeMultiAssetData.callAsync(amounts, nestedAssetData); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - assetData, - fromAddress, - toAddress, - inputAmount, - ); - const ownerFromAsset1 = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId); + const assetData = await devUtils.encodeMultiAssetData(amounts, nestedAssetData).callAsync(); + const data = assetProxyInterface + .transferFrom(assetData, fromAddress, toAddress, inputAmount) + .getABIEncodedTransactionData(); + const ownerFromAsset1 = await erc721TokenA.ownerOf(erc721AFromTokenId).callAsync(); expect(ownerFromAsset1).to.be.equal(fromAddress); - const ownerFromAsset2 = await erc721TokenB.ownerOf.callAsync(erc721BFromTokenId); + const ownerFromAsset2 = await erc721TokenB.ownerOf(erc721BFromTokenId).callAsync(); expect(ownerFromAsset2).to.be.equal(fromAddress); await web3Wrapper.awaitTransactionSuccessAsync( await web3Wrapper.sendTransactionAsync({ @@ -959,8 +877,8 @@ describe('Asset Transfer Proxies', () => { }), constants.AWAIT_TRANSACTION_MINED_MS, ); - const newOwnerFromAsset1 = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId); - const newOwnerFromAsset2 = await erc721TokenB.ownerOf.callAsync(erc721BFromTokenId); + const newOwnerFromAsset1 = await erc721TokenA.ownerOf(erc721AFromTokenId).callAsync(); + const newOwnerFromAsset2 = await erc721TokenB.ownerOf(erc721BFromTokenId).callAsync(); expect(newOwnerFromAsset1).to.be.equal(toAddress); expect(newOwnerFromAsset2).to.be.equal(toAddress); }); @@ -980,23 +898,22 @@ describe('Asset Transfer Proxies', () => { ]; await erc1155Wrapper.assertBalancesAsync(tokenHolders, tokensToTransfer, expectedInitialBalances); // encode erc1155 asset data - const erc1155AssetData = await devUtils.encodeERC1155AssetData.callAsync( - erc1155Contract.address, - tokensToTransfer, - valuesToTransfer, - receiverCallbackData, - ); + const erc1155AssetData = await devUtils + .encodeERC1155AssetData( + erc1155Contract.address, + tokensToTransfer, + valuesToTransfer, + receiverCallbackData, + ) + .callAsync(); // encode multi-asset data const multiAssetAmount = new BigNumber(5); const amounts = [valueMultiplier]; const nestedAssetData = [erc1155AssetData]; - const assetData = await devUtils.encodeMultiAssetData.callAsync(amounts, nestedAssetData); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - assetData, - fromAddress, - toAddress, - multiAssetAmount, - ); + const assetData = await devUtils.encodeMultiAssetData(amounts, nestedAssetData).callAsync(); + const data = assetProxyInterface + .transferFrom(assetData, fromAddress, toAddress, multiAssetAmount) + .getABIEncodedTransactionData(); // execute transfer await web3Wrapper.awaitTransactionSuccessAsync( await web3Wrapper.sendTransactionAsync({ @@ -1036,23 +953,22 @@ describe('Asset Transfer Proxies', () => { ]; await erc1155Wrapper.assertBalancesAsync(tokenHolders, tokensToTransfer, expectedInitialBalances); // encode erc1155 asset data - const erc1155AssetData = await devUtils.encodeERC1155AssetData.callAsync( - erc1155Contract.address, - tokensToTransfer, - valuesToTransfer, - receiverCallbackData, - ); + const erc1155AssetData = await devUtils + .encodeERC1155AssetData( + erc1155Contract.address, + tokensToTransfer, + valuesToTransfer, + receiverCallbackData, + ) + .callAsync(); // encode multi-asset data const multiAssetAmount = new BigNumber(5); const amounts = [valueMultiplier]; const nestedAssetData = [erc1155AssetData]; - const assetData = await devUtils.encodeMultiAssetData.callAsync(amounts, nestedAssetData); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - assetData, - fromAddress, - toAddress, - multiAssetAmount, - ); + const assetData = await devUtils.encodeMultiAssetData(amounts, nestedAssetData).callAsync(); + const data = assetProxyInterface + .transferFrom(assetData, fromAddress, toAddress, multiAssetAmount) + .getABIEncodedTransactionData(); // execute transfer await web3Wrapper.awaitTransactionSuccessAsync( await web3Wrapper.sendTransactionAsync({ @@ -1100,23 +1016,22 @@ describe('Asset Transfer Proxies', () => { ]; await erc1155Wrapper.assertBalancesAsync(tokenHolders, tokensToTransfer, expectedInitialBalances); // encode erc1155 asset data - const erc1155AssetData = await devUtils.encodeERC1155AssetData.callAsync( - erc1155Contract.address, - tokensToTransfer, - valuesToTransfer, - receiverCallbackData, - ); + const erc1155AssetData = await devUtils + .encodeERC1155AssetData( + erc1155Contract.address, + tokensToTransfer, + valuesToTransfer, + receiverCallbackData, + ) + .callAsync(); // encode multi-asset data const multiAssetAmount = new BigNumber(1); const amounts = [valueMultiplier]; const nestedAssetData = [erc1155AssetData]; - const assetData = await devUtils.encodeMultiAssetData.callAsync(amounts, nestedAssetData); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - assetData, - fromAddress, - toAddress, - multiAssetAmount, - ); + const assetData = await devUtils.encodeMultiAssetData(amounts, nestedAssetData).callAsync(); + const data = assetProxyInterface + .transferFrom(assetData, fromAddress, toAddress, multiAssetAmount) + .getABIEncodedTransactionData(); // execute transfer await web3Wrapper.awaitTransactionSuccessAsync( await web3Wrapper.sendTransactionAsync({ @@ -1157,29 +1072,30 @@ describe('Asset Transfer Proxies', () => { await erc1155Wrapper.assertBalancesAsync(tokenHolders, tokensToTransfer, expectedInitialBalances); await erc1155Wrapper2.assertBalancesAsync(tokenHolders, tokensToTransfer, expectedInitialBalances); // encode erc1155 asset data - const erc1155AssetData1 = await devUtils.encodeERC1155AssetData.callAsync( - erc1155Contract.address, - tokensToTransfer, - valuesToTransfer, - receiverCallbackData, - ); - const erc1155AssetData2 = await devUtils.encodeERC1155AssetData.callAsync( - erc1155Contract2.address, - tokensToTransfer, - valuesToTransfer, - receiverCallbackData, - ); + const erc1155AssetData1 = await devUtils + .encodeERC1155AssetData( + erc1155Contract.address, + tokensToTransfer, + valuesToTransfer, + receiverCallbackData, + ) + .callAsync(); + const erc1155AssetData2 = await devUtils + .encodeERC1155AssetData( + erc1155Contract2.address, + tokensToTransfer, + valuesToTransfer, + receiverCallbackData, + ) + .callAsync(); // encode multi-asset data const multiAssetAmount = new BigNumber(5); const amounts = [valueMultiplier, valueMultiplier]; const nestedAssetData = [erc1155AssetData1, erc1155AssetData2]; - const assetData = await devUtils.encodeMultiAssetData.callAsync(amounts, nestedAssetData); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - assetData, - fromAddress, - toAddress, - multiAssetAmount, - ); + const assetData = await devUtils.encodeMultiAssetData(amounts, nestedAssetData).callAsync(); + const data = assetProxyInterface + .transferFrom(assetData, fromAddress, toAddress, multiAssetAmount) + .getABIEncodedTransactionData(); // execute transfer await web3Wrapper.awaitTransactionSuccessAsync( await web3Wrapper.sendTransactionAsync({ @@ -1204,35 +1120,33 @@ describe('Asset Transfer Proxies', () => { // setup test parameters const inputAmount = new BigNumber(1); const erc20Amount = new BigNumber(10); - const erc20AssetData = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); + const erc20AssetData = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); const erc721Amount = new BigNumber(1); - const erc721AssetData = await devUtils.encodeERC721AssetData.callAsync( - erc721TokenA.address, - erc721AFromTokenId, - ); + const erc721AssetData = await devUtils + .encodeERC721AssetData(erc721TokenA.address, erc721AFromTokenId) + .callAsync(); const erc1155TokenHolders = [fromAddress, toAddress]; const erc1155TokensToTransfer = erc1155FungibleTokens.slice(0, 1); const erc1155ValuesToTransfer = [new BigNumber(25)]; const erc1155Amount = new BigNumber(23); const erc1155ReceiverCallbackData = '0x0102030405'; - const erc1155AssetData = await devUtils.encodeERC1155AssetData.callAsync( - erc1155Contract.address, - erc1155TokensToTransfer, - erc1155ValuesToTransfer, - erc1155ReceiverCallbackData, - ); + const erc1155AssetData = await devUtils + .encodeERC1155AssetData( + erc1155Contract.address, + erc1155TokensToTransfer, + erc1155ValuesToTransfer, + erc1155ReceiverCallbackData, + ) + .callAsync(); const amounts = [erc20Amount, erc721Amount, erc1155Amount]; const nestedAssetData = [erc20AssetData, erc721AssetData, erc1155AssetData]; - const assetData = await devUtils.encodeMultiAssetData.callAsync(amounts, nestedAssetData); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - assetData, - fromAddress, - toAddress, - inputAmount, - ); + const assetData = await devUtils.encodeMultiAssetData(amounts, nestedAssetData).callAsync(); + const data = assetProxyInterface + .transferFrom(assetData, fromAddress, toAddress, inputAmount) + .getABIEncodedTransactionData(); // check balances before transfer const erc20Balances = await erc20Wrapper.getBalancesAsync(); - const ownerFromAsset = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId); + const ownerFromAsset = await erc721TokenA.ownerOf(erc721AFromTokenId).callAsync(); expect(ownerFromAsset).to.be.equal(fromAddress); const erc1155ExpectedInitialBalances = [ constants.INITIAL_ERC1155_FUNGIBLE_BALANCE, @@ -1262,7 +1176,7 @@ describe('Asset Transfer Proxies', () => { expect(newBalances[toAddress][erc20TokenA.address]).to.be.bignumber.equal( erc20Balances[toAddress][erc20TokenA.address].plus(totalAmount), ); - const newOwnerFromAsset = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId); + const newOwnerFromAsset = await erc721TokenA.ownerOf(erc721AFromTokenId).callAsync(); expect(newOwnerFromAsset).to.be.equal(toAddress); const erc1155TotalValueTransferred = erc1155ValuesToTransfer[0].times(erc1155Amount).times(inputAmount); const expectedFinalBalances = [ @@ -1278,23 +1192,19 @@ describe('Asset Transfer Proxies', () => { it('should successfully transfer a combination of ERC20 and ERC721 tokens', async () => { const inputAmount = new BigNumber(1); const erc20Amount = new BigNumber(10); - const erc20AssetData = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); + const erc20AssetData = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); const erc721Amount = new BigNumber(1); - const erc721AssetData = await devUtils.encodeERC721AssetData.callAsync( - erc721TokenA.address, - erc721AFromTokenId, - ); + const erc721AssetData = await devUtils + .encodeERC721AssetData(erc721TokenA.address, erc721AFromTokenId) + .callAsync(); const amounts = [erc20Amount, erc721Amount]; const nestedAssetData = [erc20AssetData, erc721AssetData]; - const assetData = await devUtils.encodeMultiAssetData.callAsync(amounts, nestedAssetData); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - assetData, - fromAddress, - toAddress, - inputAmount, - ); + const assetData = await devUtils.encodeMultiAssetData(amounts, nestedAssetData).callAsync(); + const data = assetProxyInterface + .transferFrom(assetData, fromAddress, toAddress, inputAmount) + .getABIEncodedTransactionData(); const erc20Balances = await erc20Wrapper.getBalancesAsync(); - const ownerFromAsset = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId); + const ownerFromAsset = await erc721TokenA.ownerOf(erc721AFromTokenId).callAsync(); expect(ownerFromAsset).to.be.equal(fromAddress); await web3Wrapper.awaitTransactionSuccessAsync( await web3Wrapper.sendTransactionAsync({ @@ -1312,33 +1222,28 @@ describe('Asset Transfer Proxies', () => { expect(newBalances[toAddress][erc20TokenA.address]).to.be.bignumber.equal( erc20Balances[toAddress][erc20TokenA.address].plus(totalAmount), ); - const newOwnerFromAsset = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId); + const newOwnerFromAsset = await erc721TokenA.ownerOf(erc721AFromTokenId).callAsync(); expect(newOwnerFromAsset).to.be.equal(toAddress); }); it('should successfully transfer tokens and ignore extra assetData', async () => { const inputAmount = new BigNumber(1); const erc20Amount = new BigNumber(10); - const erc20AssetData = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); + const erc20AssetData = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); const erc721Amount = new BigNumber(1); - const erc721AssetData = await devUtils.encodeERC721AssetData.callAsync( - erc721TokenA.address, - erc721AFromTokenId, - ); + const erc721AssetData = await devUtils + .encodeERC721AssetData(erc721TokenA.address, erc721AFromTokenId) + .callAsync(); const amounts = [erc20Amount, erc721Amount]; const nestedAssetData = [erc20AssetData, erc721AssetData]; const extraData = '0102030405060708090001020304050607080900010203040506070809000102'; - const assetData = `${await devUtils.encodeMultiAssetData.callAsync( - amounts, - nestedAssetData, - )}${extraData}`; - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - assetData, - fromAddress, - toAddress, - inputAmount, - ); + const assetData = `${await devUtils + .encodeMultiAssetData(amounts, nestedAssetData) + .callAsync()}${extraData}`; + const data = assetProxyInterface + .transferFrom(assetData, fromAddress, toAddress, inputAmount) + .getABIEncodedTransactionData(); const erc20Balances = await erc20Wrapper.getBalancesAsync(); - const ownerFromAsset = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId); + const ownerFromAsset = await erc721TokenA.ownerOf(erc721AFromTokenId).callAsync(); expect(ownerFromAsset).to.be.equal(fromAddress); await web3Wrapper.awaitTransactionSuccessAsync( await web3Wrapper.sendTransactionAsync({ @@ -1356,24 +1261,21 @@ describe('Asset Transfer Proxies', () => { expect(newBalances[toAddress][erc20TokenA.address]).to.be.bignumber.equal( erc20Balances[toAddress][erc20TokenA.address].plus(totalAmount), ); - const newOwnerFromAsset = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId); + const newOwnerFromAsset = await erc721TokenA.ownerOf(erc721AFromTokenId).callAsync(); expect(newOwnerFromAsset).to.be.equal(toAddress); }); it('should successfully transfer correct amounts when the `amount` > 1', async () => { const inputAmount = new BigNumber(100); const erc20Amount1 = new BigNumber(10); const erc20Amount2 = new BigNumber(20); - const erc20AssetData1 = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); - const erc20AssetData2 = await devUtils.encodeERC20AssetData.callAsync(erc20TokenB.address); + const erc20AssetData1 = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); + const erc20AssetData2 = await devUtils.encodeERC20AssetData(erc20TokenB.address).callAsync(); const amounts = [erc20Amount1, erc20Amount2]; const nestedAssetData = [erc20AssetData1, erc20AssetData2]; - const assetData = await devUtils.encodeMultiAssetData.callAsync(amounts, nestedAssetData); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - assetData, - fromAddress, - toAddress, - inputAmount, - ); + const assetData = await devUtils.encodeMultiAssetData(amounts, nestedAssetData).callAsync(); + const data = assetProxyInterface + .transferFrom(assetData, fromAddress, toAddress, inputAmount) + .getABIEncodedTransactionData(); const erc20Balances = await erc20Wrapper.getBalancesAsync(); await web3Wrapper.awaitTransactionSuccessAsync( await web3Wrapper.sendTransactionAsync({ @@ -1403,28 +1305,24 @@ describe('Asset Transfer Proxies', () => { const inputAmount = new BigNumber(1); const erc20Amount1 = new BigNumber(10); const erc20Amount2 = new BigNumber(20); - const erc20AssetData1 = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); - const erc20AssetData2 = await devUtils.encodeERC20AssetData.callAsync(erc20TokenB.address); + const erc20AssetData1 = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); + const erc20AssetData2 = await devUtils.encodeERC20AssetData(erc20TokenB.address).callAsync(); const erc721Amount = new BigNumber(1); const erc721Balances = await erc721Wrapper.getBalancesAsync(); const erc721AFromTokenId2 = erc721Balances[fromAddress][erc721TokenA.address][1]; const erc721BFromTokenId2 = erc721Balances[fromAddress][erc721TokenB.address][1]; - const erc721AssetData1 = await devUtils.encodeERC721AssetData.callAsync( - erc721TokenA.address, - erc721AFromTokenId, - ); - const erc721AssetData2 = await devUtils.encodeERC721AssetData.callAsync( - erc721TokenA.address, - erc721AFromTokenId2, - ); - const erc721AssetData3 = await devUtils.encodeERC721AssetData.callAsync( - erc721TokenB.address, - erc721BFromTokenId, - ); - const erc721AssetData4 = await devUtils.encodeERC721AssetData.callAsync( - erc721TokenB.address, - erc721BFromTokenId2, - ); + const erc721AssetData1 = await devUtils + .encodeERC721AssetData(erc721TokenA.address, erc721AFromTokenId) + .callAsync(); + const erc721AssetData2 = await devUtils + .encodeERC721AssetData(erc721TokenA.address, erc721AFromTokenId2) + .callAsync(); + const erc721AssetData3 = await devUtils + .encodeERC721AssetData(erc721TokenB.address, erc721BFromTokenId) + .callAsync(); + const erc721AssetData4 = await devUtils + .encodeERC721AssetData(erc721TokenB.address, erc721BFromTokenId2) + .callAsync(); const amounts = [erc721Amount, erc20Amount1, erc721Amount, erc20Amount2, erc721Amount, erc721Amount]; const nestedAssetData = [ erc721AssetData1, @@ -1434,20 +1332,17 @@ describe('Asset Transfer Proxies', () => { erc721AssetData3, erc721AssetData4, ]; - const assetData = await devUtils.encodeMultiAssetData.callAsync(amounts, nestedAssetData); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - assetData, - fromAddress, - toAddress, - inputAmount, - ); - const ownerFromAsset1 = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId); + const assetData = await devUtils.encodeMultiAssetData(amounts, nestedAssetData).callAsync(); + const data = assetProxyInterface + .transferFrom(assetData, fromAddress, toAddress, inputAmount) + .getABIEncodedTransactionData(); + const ownerFromAsset1 = await erc721TokenA.ownerOf(erc721AFromTokenId).callAsync(); expect(ownerFromAsset1).to.be.equal(fromAddress); - const ownerFromAsset2 = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId2); + const ownerFromAsset2 = await erc721TokenA.ownerOf(erc721AFromTokenId2).callAsync(); expect(ownerFromAsset2).to.be.equal(fromAddress); - const ownerFromAsset3 = await erc721TokenB.ownerOf.callAsync(erc721BFromTokenId); + const ownerFromAsset3 = await erc721TokenB.ownerOf(erc721BFromTokenId).callAsync(); expect(ownerFromAsset3).to.be.equal(fromAddress); - const ownerFromAsset4 = await erc721TokenB.ownerOf.callAsync(erc721BFromTokenId2); + const ownerFromAsset4 = await erc721TokenB.ownerOf(erc721BFromTokenId2).callAsync(); expect(ownerFromAsset4).to.be.equal(fromAddress); const erc20Balances = await erc20Wrapper.getBalancesAsync(); await web3Wrapper.awaitTransactionSuccessAsync( @@ -1459,10 +1354,10 @@ describe('Asset Transfer Proxies', () => { }), constants.AWAIT_TRANSACTION_MINED_MS, ); - const newOwnerFromAsset1 = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId); - const newOwnerFromAsset2 = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId2); - const newOwnerFromAsset3 = await erc721TokenB.ownerOf.callAsync(erc721BFromTokenId); - const newOwnerFromAsset4 = await erc721TokenB.ownerOf.callAsync(erc721BFromTokenId2); + const newOwnerFromAsset1 = await erc721TokenA.ownerOf(erc721AFromTokenId).callAsync(); + const newOwnerFromAsset2 = await erc721TokenA.ownerOf(erc721AFromTokenId2).callAsync(); + const newOwnerFromAsset3 = await erc721TokenB.ownerOf(erc721BFromTokenId).callAsync(); + const newOwnerFromAsset4 = await erc721TokenB.ownerOf(erc721BFromTokenId2).callAsync(); expect(newOwnerFromAsset1).to.be.equal(toAddress); expect(newOwnerFromAsset2).to.be.equal(toAddress); expect(newOwnerFromAsset3).to.be.equal(toAddress); @@ -1486,22 +1381,18 @@ describe('Asset Transfer Proxies', () => { it('should revert if a single transfer fails', async () => { const inputAmount = new BigNumber(1); const erc20Amount = new BigNumber(10); - const erc20AssetData = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); + const erc20AssetData = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); // 2 is an invalid erc721 amount const erc721Amount = new BigNumber(2); - const erc721AssetData = await devUtils.encodeERC721AssetData.callAsync( - erc721TokenA.address, - erc721AFromTokenId, - ); + const erc721AssetData = await devUtils + .encodeERC721AssetData(erc721TokenA.address, erc721AFromTokenId) + .callAsync(); const amounts = [erc20Amount, erc721Amount]; const nestedAssetData = [erc20AssetData, erc721AssetData]; - const assetData = await devUtils.encodeMultiAssetData.callAsync(amounts, nestedAssetData); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - assetData, - fromAddress, - toAddress, - inputAmount, - ); + const assetData = await devUtils.encodeMultiAssetData(amounts, nestedAssetData).callAsync(); + const data = assetProxyInterface + .transferFrom(assetData, fromAddress, toAddress, inputAmount) + .getABIEncodedTransactionData(); await expectTransactionFailedAsync( web3Wrapper.sendTransactionAsync({ to: multiAssetProxy.address, @@ -1514,23 +1405,19 @@ describe('Asset Transfer Proxies', () => { it('should revert if an AssetProxy is not registered', async () => { const inputAmount = new BigNumber(1); const erc20Amount = new BigNumber(10); - const erc20AssetData = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); + const erc20AssetData = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); const erc721Amount = new BigNumber(1); - const erc721AssetData = await devUtils.encodeERC721AssetData.callAsync( - erc721TokenA.address, - erc721AFromTokenId, - ); + const erc721AssetData = await devUtils + .encodeERC721AssetData(erc721TokenA.address, erc721AFromTokenId) + .callAsync(); const invalidProxyId = '0x12345678'; const invalidErc721AssetData = `${invalidProxyId}${erc721AssetData.slice(10)}`; const amounts = [erc20Amount, erc721Amount]; const nestedAssetData = [erc20AssetData, invalidErc721AssetData]; - const assetData = await devUtils.encodeMultiAssetData.callAsync(amounts, nestedAssetData); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - assetData, - fromAddress, - toAddress, - inputAmount, - ); + const assetData = await devUtils.encodeMultiAssetData(amounts, nestedAssetData).callAsync(); + const data = assetProxyInterface + .transferFrom(assetData, fromAddress, toAddress, inputAmount) + .getABIEncodedTransactionData(); await expectTransactionFailedAsync( web3Wrapper.sendTransactionAsync({ to: multiAssetProxy.address, @@ -1543,20 +1430,16 @@ describe('Asset Transfer Proxies', () => { it('should revert if the length of `amounts` does not match the length of `nestedAssetData`', async () => { const inputAmount = new BigNumber(1); const erc20Amount = new BigNumber(10); - const erc20AssetData = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); - const erc721AssetData = await devUtils.encodeERC721AssetData.callAsync( - erc721TokenA.address, - erc721AFromTokenId, - ); + const erc20AssetData = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); + const erc721AssetData = await devUtils + .encodeERC721AssetData(erc721TokenA.address, erc721AFromTokenId) + .callAsync(); const amounts = [erc20Amount]; const nestedAssetData = [erc20AssetData, erc721AssetData]; - const assetData = await devUtils.encodeMultiAssetData.callAsync(amounts, nestedAssetData); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - assetData, - fromAddress, - toAddress, - inputAmount, - ); + const assetData = await devUtils.encodeMultiAssetData(amounts, nestedAssetData).callAsync(); + const data = assetProxyInterface + .transferFrom(assetData, fromAddress, toAddress, inputAmount) + .getABIEncodedTransactionData(); await expectTransactionFailedAsync( web3Wrapper.sendTransactionAsync({ to: multiAssetProxy.address, @@ -1569,16 +1452,13 @@ describe('Asset Transfer Proxies', () => { it('should revert if amounts multiplication results in an overflow', async () => { const inputAmount = new BigNumber(2).pow(128); const erc20Amount = new BigNumber(2).pow(128); - const erc20AssetData = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); + const erc20AssetData = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); const amounts = [erc20Amount]; const nestedAssetData = [erc20AssetData]; - const assetData = await devUtils.encodeMultiAssetData.callAsync(amounts, nestedAssetData); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - assetData, - fromAddress, - toAddress, - inputAmount, - ); + const assetData = await devUtils.encodeMultiAssetData(amounts, nestedAssetData).callAsync(); + const data = assetProxyInterface + .transferFrom(assetData, fromAddress, toAddress, inputAmount) + .getABIEncodedTransactionData(); await expectTransactionFailedAsync( web3Wrapper.sendTransactionAsync({ to: multiAssetProxy.address, @@ -1591,18 +1471,15 @@ describe('Asset Transfer Proxies', () => { it('should revert if an element of `nestedAssetData` is < 4 bytes long', async () => { const inputAmount = new BigNumber(1); const erc20Amount = new BigNumber(10); - const erc20AssetData = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); + const erc20AssetData = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); const erc721Amount = new BigNumber(1); const erc721AssetData = '0x123456'; const amounts = [erc20Amount, erc721Amount]; const nestedAssetData = [erc20AssetData, erc721AssetData]; - const assetData = await devUtils.encodeMultiAssetData.callAsync(amounts, nestedAssetData); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - assetData, - fromAddress, - toAddress, - inputAmount, - ); + const assetData = await devUtils.encodeMultiAssetData(amounts, nestedAssetData).callAsync(); + const data = assetProxyInterface + .transferFrom(assetData, fromAddress, toAddress, inputAmount) + .getABIEncodedTransactionData(); await expectTransactionFailedAsync( web3Wrapper.sendTransactionAsync({ to: multiAssetProxy.address, @@ -1615,21 +1492,17 @@ describe('Asset Transfer Proxies', () => { it('should revert if caller is not authorized', async () => { const inputAmount = new BigNumber(1); const erc20Amount = new BigNumber(10); - const erc20AssetData = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); + const erc20AssetData = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); const erc721Amount = new BigNumber(1); - const erc721AssetData = await devUtils.encodeERC721AssetData.callAsync( - erc721TokenA.address, - erc721AFromTokenId, - ); + const erc721AssetData = await devUtils + .encodeERC721AssetData(erc721TokenA.address, erc721AFromTokenId) + .callAsync(); const amounts = [erc20Amount, erc721Amount]; const nestedAssetData = [erc20AssetData, erc721AssetData]; - const assetData = await devUtils.encodeMultiAssetData.callAsync(amounts, nestedAssetData); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - assetData, - fromAddress, - toAddress, - inputAmount, - ); + const assetData = await devUtils.encodeMultiAssetData(amounts, nestedAssetData).callAsync(); + const data = assetProxyInterface + .transferFrom(assetData, fromAddress, toAddress, inputAmount) + .getABIEncodedTransactionData(); await expectTransactionFailedAsync( web3Wrapper.sendTransactionAsync({ to: multiAssetProxy.address, @@ -1642,21 +1515,17 @@ describe('Asset Transfer Proxies', () => { it('should revert if asset data overflows beyond the bounds of calldata', async () => { const inputAmount = new BigNumber(1); const erc20Amount = new BigNumber(10); - const erc20AssetData = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); + const erc20AssetData = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); const erc721Amount = new BigNumber(1); - const erc721AssetData = await devUtils.encodeERC721AssetData.callAsync( - erc721TokenA.address, - erc721AFromTokenId, - ); + const erc721AssetData = await devUtils + .encodeERC721AssetData(erc721TokenA.address, erc721AFromTokenId) + .callAsync(); const amounts = [erc20Amount, erc721Amount]; const nestedAssetData = [erc20AssetData, erc721AssetData]; - const assetData = await devUtils.encodeMultiAssetData.callAsync(amounts, nestedAssetData); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - assetData, - fromAddress, - toAddress, - inputAmount, - ); + const assetData = await devUtils.encodeMultiAssetData(amounts, nestedAssetData).callAsync(); + const data = assetProxyInterface + .transferFrom(assetData, fromAddress, toAddress, inputAmount) + .getABIEncodedTransactionData(); // append asset data to end of tx data with a length of 0x300 bytes, which will extend past actual calldata. const offsetToAssetData = '0000000000000000000000000000000000000000000000000000000000000080'; const invalidOffsetToAssetData = '00000000000000000000000000000000000000000000000000000000000002a0'; @@ -1675,21 +1544,17 @@ describe('Asset Transfer Proxies', () => { it('should revert if asset data resolves to a location beyond the bounds of calldata', async () => { const inputAmount = new BigNumber(1); const erc20Amount = new BigNumber(10); - const erc20AssetData = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); + const erc20AssetData = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); const erc721Amount = new BigNumber(1); - const erc721AssetData = await devUtils.encodeERC721AssetData.callAsync( - erc721TokenA.address, - erc721AFromTokenId, - ); + const erc721AssetData = await devUtils + .encodeERC721AssetData(erc721TokenA.address, erc721AFromTokenId) + .callAsync(); const amounts = [erc20Amount, erc721Amount]; const nestedAssetData = [erc20AssetData, erc721AssetData]; - const assetData = await devUtils.encodeMultiAssetData.callAsync(amounts, nestedAssetData); - const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - assetData, - fromAddress, - toAddress, - inputAmount, - ); + const assetData = await devUtils.encodeMultiAssetData(amounts, nestedAssetData).callAsync(); + const data = assetProxyInterface + .transferFrom(assetData, fromAddress, toAddress, inputAmount) + .getABIEncodedTransactionData(); const offsetToAssetData = '0000000000000000000000000000000000000000000000000000000000000080'; const invalidOffsetToAssetData = '0000000000000000000000000000000000000000000000000000000000000400'; const badData = data.replace(offsetToAssetData, invalidOffsetToAssetData); @@ -1709,23 +1574,19 @@ describe('Asset Transfer Proxies', () => { // setup test parameters const inputAmount = new BigNumber(1); const erc20Amount = new BigNumber(10); - const erc20AssetData = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); + const erc20AssetData = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); const erc721Amount = new BigNumber(1); - const erc721AssetData = await devUtils.encodeERC721AssetData.callAsync( - erc721TokenA.address, - erc721AFromTokenId, - ); + const erc721AssetData = await devUtils + .encodeERC721AssetData(erc721TokenA.address, erc721AFromTokenId) + .callAsync(); const amounts = [erc20Amount, erc721Amount]; const nestedAssetData = [erc20AssetData, erc721AssetData]; - const assetData = await devUtils.encodeMultiAssetData.callAsync(amounts, nestedAssetData); + const assetData = await devUtils.encodeMultiAssetData(amounts, nestedAssetData).callAsync(); const extraData = '01'; const assetDataWithExtraData = `${assetData}${extraData}`; - const badData = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - assetDataWithExtraData, - fromAddress, - toAddress, - inputAmount, - ); + const badData = assetProxyInterface + .transferFrom(assetDataWithExtraData, fromAddress, toAddress, inputAmount) + .getABIEncodedTransactionData(); // execute transfer await expectTransactionFailedAsync( web3Wrapper.sendTransactionAsync({ @@ -1746,12 +1607,9 @@ describe('Asset Transfer Proxies', () => { // so that we know the error is not triggered by another check in the code. const zeros32Bytes = '0'.repeat(64); const assetData36Bytes = `${AssetProxyId.MultiAsset}${zeros32Bytes}`; - const badData = assetProxyInterface.transferFrom.getABIEncodedTransactionData( - assetData36Bytes, - fromAddress, - toAddress, - inputAmount, - ); + const badData = assetProxyInterface + .transferFrom(assetData36Bytes, fromAddress, toAddress, inputAmount) + .getABIEncodedTransactionData(); // execute transfer await expectTransactionFailedAsync( web3Wrapper.sendTransactionAsync({ diff --git a/contracts/asset-proxy/test/static_call_proxy.ts b/contracts/asset-proxy/test/static_call_proxy.ts index 743cc476a3..f366b61c02 100644 --- a/contracts/asset-proxy/test/static_call_proxy.ts +++ b/contracts/asset-proxy/test/static_call_proxy.ts @@ -79,26 +79,21 @@ describe('StaticCallProxy', () => { ); }); it('should have an id of 0xc339d10a', async () => { - const proxyId = await staticCallProxy.getProxyId.callAsync(); + const proxyId = await staticCallProxy.getProxyId().callAsync(); const expectedProxyId = AssetProxyId.StaticCall; expect(proxyId).to.equal(expectedProxyId); }); }); describe('transferFrom', () => { it('should revert if assetData lies outside the bounds of calldata', async () => { - const staticCallData = staticCallTarget.noInputFunction.getABIEncodedTransactionData(); + const staticCallData = staticCallTarget.noInputFunction().getABIEncodedTransactionData(); const expectedResultHash = constants.KECCAK256_NULL; - const assetData = await devUtils.encodeStaticCallAssetData.callAsync( - staticCallTarget.address, - staticCallData, - expectedResultHash, - ); - const txData = staticCallProxy.transferFrom.getABIEncodedTransactionData( - assetData, - fromAddress, - toAddress, - amount, - ); + const assetData = await devUtils + .encodeStaticCallAssetData(staticCallTarget.address, staticCallData, expectedResultHash) + .callAsync(); + const txData = staticCallProxy + .transferFrom(assetData, fromAddress, toAddress, amount) + .getABIEncodedTransactionData(); const offsetToAssetData = '0000000000000000000000000000000000000000000000000000000000000080'; const txDataEndBuffer = ethUtil.toBuffer((txData.length - 2) / 2 - 4); const paddedTxDataEndBuffer = ethUtil.setLengthLeft(txDataEndBuffer, 32); @@ -116,25 +111,21 @@ describe('StaticCallProxy', () => { it('should revert if the length of assetData is less than 100 bytes', async () => { const staticCallData = constants.NULL_BYTES; const expectedResultHash = constants.KECCAK256_NULL; - const assetData = (await devUtils.encodeStaticCallAssetData.callAsync( - staticCallTarget.address, - staticCallData, - expectedResultHash, - )).slice(0, -128); + const assetData = (await devUtils + .encodeStaticCallAssetData(staticCallTarget.address, staticCallData, expectedResultHash) + .callAsync()).slice(0, -128); const assetDataByteLen = (assetData.length - 2) / 2; expect((assetDataByteLen - 4) % 32).to.equal(0); await expectTransactionFailedWithoutReasonAsync( - staticCallProxy.transferFrom.sendTransactionAsync(assetData, fromAddress, toAddress, amount), + staticCallProxy.transferFrom(assetData, fromAddress, toAddress, amount).sendTransactionAsync(), ); }); it('should revert if the offset to `staticCallData` points to outside of assetData', async () => { - const staticCallData = staticCallTarget.noInputFunction.getABIEncodedTransactionData(); + const staticCallData = staticCallTarget.noInputFunction().getABIEncodedTransactionData(); const expectedResultHash = constants.KECCAK256_NULL; - const assetData = await devUtils.encodeStaticCallAssetData.callAsync( - staticCallTarget.address, - staticCallData, - expectedResultHash, - ); + const assetData = await devUtils + .encodeStaticCallAssetData(staticCallTarget.address, staticCallData, expectedResultHash) + .callAsync(); const offsetToStaticCallData = '0000000000000000000000000000000000000000000000000000000000000060'; const assetDataEndBuffer = ethUtil.toBuffer((assetData.length - 2) / 2 - 4); const paddedAssetDataEndBuffer = ethUtil.setLengthLeft(assetDataEndBuffer, 32); @@ -145,94 +136,88 @@ describe('StaticCallProxy', () => { invalidOffsetToStaticCallData, )}${newStaticCallData}`; await expectTransactionFailedWithoutReasonAsync( - staticCallProxy.transferFrom.sendTransactionAsync(badAssetData, fromAddress, toAddress, amount), + staticCallProxy.transferFrom(badAssetData, fromAddress, toAddress, amount).sendTransactionAsync(), ); }); it('should revert if the callTarget attempts to write to state', async () => { - const staticCallData = staticCallTarget.updateState.getABIEncodedTransactionData(); + const staticCallData = staticCallTarget.updateState().getABIEncodedTransactionData(); const expectedResultHash = constants.KECCAK256_NULL; - const assetData = await devUtils.encodeStaticCallAssetData.callAsync( - staticCallTarget.address, - staticCallData, - expectedResultHash, - ); + const assetData = await devUtils + .encodeStaticCallAssetData(staticCallTarget.address, staticCallData, expectedResultHash) + .callAsync(); await expectTransactionFailedWithoutReasonAsync( - staticCallProxy.transferFrom.sendTransactionAsync(assetData, fromAddress, toAddress, amount), + staticCallProxy.transferFrom(assetData, fromAddress, toAddress, amount).sendTransactionAsync(), ); }); it('should revert with data provided by the callTarget if the staticcall reverts', async () => { - const staticCallData = staticCallTarget.assertEvenNumber.getABIEncodedTransactionData(new BigNumber(1)); + const staticCallData = staticCallTarget.assertEvenNumber(new BigNumber(1)).getABIEncodedTransactionData(); const expectedResultHash = constants.KECCAK256_NULL; - const assetData = await devUtils.encodeStaticCallAssetData.callAsync( - staticCallTarget.address, - staticCallData, - expectedResultHash, - ); + const assetData = await devUtils + .encodeStaticCallAssetData(staticCallTarget.address, staticCallData, expectedResultHash) + .callAsync(); await expectTransactionFailedAsync( - staticCallProxy.transferFrom.sendTransactionAsync(assetData, fromAddress, toAddress, amount), + staticCallProxy.transferFrom(assetData, fromAddress, toAddress, amount).sendTransactionAsync(), RevertReason.TargetNotEven, ); }); it('should revert if the hash of the output is different than expected expected', async () => { - const staticCallData = staticCallTarget.isOddNumber.getABIEncodedTransactionData(new BigNumber(0)); + const staticCallData = staticCallTarget.isOddNumber(new BigNumber(0)).getABIEncodedTransactionData(); const trueAsBuffer = ethUtil.toBuffer('0x0000000000000000000000000000000000000000000000000000000000000001'); const expectedResultHash = ethUtil.bufferToHex(ethUtil.sha3(trueAsBuffer)); - const assetData = await devUtils.encodeStaticCallAssetData.callAsync( - staticCallTarget.address, - staticCallData, - expectedResultHash, - ); + const assetData = await devUtils + .encodeStaticCallAssetData(staticCallTarget.address, staticCallData, expectedResultHash) + .callAsync(); await expectTransactionFailedAsync( - staticCallProxy.transferFrom.sendTransactionAsync(assetData, fromAddress, toAddress, amount), + staticCallProxy.transferFrom(assetData, fromAddress, toAddress, amount).sendTransactionAsync(), RevertReason.UnexpectedStaticCallResult, ); }); it('should be successful if a function call with no inputs and no outputs is successful', async () => { - const staticCallData = staticCallTarget.noInputFunction.getABIEncodedTransactionData(); + const staticCallData = staticCallTarget.noInputFunction().getABIEncodedTransactionData(); const expectedResultHash = constants.KECCAK256_NULL; - const assetData = await devUtils.encodeStaticCallAssetData.callAsync( - staticCallTarget.address, - staticCallData, - expectedResultHash, - ); - await staticCallProxy.transferFrom.awaitTransactionSuccessAsync(assetData, fromAddress, toAddress, amount); + const assetData = await devUtils + .encodeStaticCallAssetData(staticCallTarget.address, staticCallData, expectedResultHash) + .callAsync(); + await staticCallProxy + .transferFrom(assetData, fromAddress, toAddress, amount) + .awaitTransactionSuccessAsync(); }); it('should be successful if the staticCallTarget is not a contract and no return value is expected', async () => { const staticCallData = '0x0102030405060708'; const expectedResultHash = constants.KECCAK256_NULL; - const assetData = await devUtils.encodeStaticCallAssetData.callAsync( - toAddress, - staticCallData, - expectedResultHash, - ); - await staticCallProxy.transferFrom.awaitTransactionSuccessAsync(assetData, fromAddress, toAddress, amount); + const assetData = await devUtils + .encodeStaticCallAssetData(toAddress, staticCallData, expectedResultHash) + .callAsync(); + await staticCallProxy + .transferFrom(assetData, fromAddress, toAddress, amount) + .awaitTransactionSuccessAsync(); }); it('should be successful if a function call with one static input returns the correct value', async () => { - const staticCallData = staticCallTarget.isOddNumber.getABIEncodedTransactionData(new BigNumber(1)); + const staticCallData = staticCallTarget.isOddNumber(new BigNumber(1)).getABIEncodedTransactionData(); const trueAsBuffer = ethUtil.toBuffer('0x0000000000000000000000000000000000000000000000000000000000000001'); const expectedResultHash = ethUtil.bufferToHex(ethUtil.sha3(trueAsBuffer)); - const assetData = await devUtils.encodeStaticCallAssetData.callAsync( - staticCallTarget.address, - staticCallData, - expectedResultHash, - ); - await staticCallProxy.transferFrom.awaitTransactionSuccessAsync(assetData, fromAddress, toAddress, amount); + const assetData = await devUtils + .encodeStaticCallAssetData(staticCallTarget.address, staticCallData, expectedResultHash) + .callAsync(); + await staticCallProxy + .transferFrom(assetData, fromAddress, toAddress, amount) + .awaitTransactionSuccessAsync(); }); it('should be successful if a function with one dynamic input is successful', async () => { const dynamicInput = '0x0102030405060708'; - const staticCallData = staticCallTarget.dynamicInputFunction.getABIEncodedTransactionData(dynamicInput); + const staticCallData = staticCallTarget.dynamicInputFunction(dynamicInput).getABIEncodedTransactionData(); const expectedResultHash = constants.KECCAK256_NULL; - const assetData = await devUtils.encodeStaticCallAssetData.callAsync( - staticCallTarget.address, - staticCallData, - expectedResultHash, - ); - await staticCallProxy.transferFrom.awaitTransactionSuccessAsync(assetData, fromAddress, toAddress, amount); + const assetData = await devUtils + .encodeStaticCallAssetData(staticCallTarget.address, staticCallData, expectedResultHash) + .callAsync(); + await staticCallProxy + .transferFrom(assetData, fromAddress, toAddress, amount) + .awaitTransactionSuccessAsync(); }); it('should be successful if a function call returns a complex type', async () => { const a = new BigNumber(1); const b = new BigNumber(2); - const staticCallData = staticCallTarget.returnComplexType.getABIEncodedTransactionData(a, b); + const staticCallData = staticCallTarget.returnComplexType(a, b).getABIEncodedTransactionData(); const abiEncoder = new AbiEncoder.DynamicBytes({ name: '', type: 'bytes', @@ -245,12 +230,12 @@ describe('StaticCallProxy', () => { const expectedResultHash = ethUtil.bufferToHex( ethUtil.sha3(ethUtil.toBuffer(encodedExpectedResultWithOffset)), ); - const assetData = await devUtils.encodeStaticCallAssetData.callAsync( - staticCallTarget.address, - staticCallData, - expectedResultHash, - ); - await staticCallProxy.transferFrom.awaitTransactionSuccessAsync(assetData, fromAddress, toAddress, amount); + const assetData = await devUtils + .encodeStaticCallAssetData(staticCallTarget.address, staticCallData, expectedResultHash) + .callAsync(); + await staticCallProxy + .transferFrom(assetData, fromAddress, toAddress, amount) + .awaitTransactionSuccessAsync(); }); }); }); diff --git a/contracts/asset-proxy/test/uniswap_bridge.ts b/contracts/asset-proxy/test/uniswap_bridge.ts index 2f7f6a0290..ae07d17abe 100644 --- a/contracts/asset-proxy/test/uniswap_bridge.ts +++ b/contracts/asset-proxy/test/uniswap_bridge.ts @@ -9,7 +9,7 @@ import { hexRandom, Numberish, randomAddress, - TransactionHelper, + transactionHelper, } from '@0x/contracts-test-utils'; import { AssetProxyId } from '@0x/types'; import { BigNumber } from '@0x/utils'; @@ -30,7 +30,6 @@ import { } from '../src'; blockchainTests.resets('UniswapBridge unit tests', env => { - const txHelper = new TransactionHelper(env.web3Wrapper, artifacts); let testContract: TestUniswapBridgeContract; let wethTokenAddress: string; @@ -41,13 +40,13 @@ blockchainTests.resets('UniswapBridge unit tests', env => { env.txDefaults, artifacts, ); - wethTokenAddress = await testContract.wethToken.callAsync(); + wethTokenAddress = await testContract.wethToken().callAsync(); }); describe('isValidSignature()', () => { it('returns success bytes', async () => { const LEGACY_WALLET_MAGIC_VALUE = '0xb0671381'; - const result = await testContract.isValidSignature.callAsync(hexRandom(), hexRandom(_.random(0, 32))); + const result = await testContract.isValidSignature(hexRandom(), hexRandom(_.random(0, 32))).callAsync(); expect(result).to.eq(LEGACY_WALLET_MAGIC_VALUE); }); }); @@ -90,33 +89,31 @@ blockchainTests.resets('UniswapBridge unit tests', env => { async function withdrawToAsync(opts?: Partial): Promise { const _opts = createWithdrawToOpts(opts); // Create the "from" token and exchange. - [[_opts.fromTokenAddress]] = await txHelper.getResultAndReceiptAsync( + [[_opts.fromTokenAddress]] = await transactionHelper.getResultAndReceiptAsync( testContract.createTokenAndExchange, _opts.fromTokenAddress, _opts.exchangeRevertReason, { value: new BigNumber(_opts.exchangeFillAmount) }, ); // Create the "to" token and exchange. - [[_opts.toTokenAddress]] = await txHelper.getResultAndReceiptAsync( + [[_opts.toTokenAddress]] = await transactionHelper.getResultAndReceiptAsync( testContract.createTokenAndExchange, _opts.toTokenAddress, _opts.exchangeRevertReason, { value: new BigNumber(_opts.exchangeFillAmount) }, ); - await testContract.setTokenRevertReason.awaitTransactionSuccessAsync( - _opts.toTokenAddress, - _opts.toTokenRevertReason, - ); - await testContract.setTokenRevertReason.awaitTransactionSuccessAsync( - _opts.fromTokenAddress, - _opts.fromTokenRevertReason, - ); + await testContract + .setTokenRevertReason(_opts.toTokenAddress, _opts.toTokenRevertReason) + .awaitTransactionSuccessAsync(); + await testContract + .setTokenRevertReason(_opts.fromTokenAddress, _opts.fromTokenRevertReason) + .awaitTransactionSuccessAsync(); // Set the token balance for the token we're converting from. - await testContract.setTokenBalance.awaitTransactionSuccessAsync(_opts.fromTokenAddress, { + await testContract.setTokenBalance(_opts.fromTokenAddress).awaitTransactionSuccessAsync({ value: new BigNumber(_opts.fromTokenBalance), }); // Call bridgeTransferFrom(). - const [result, receipt] = await txHelper.getResultAndReceiptAsync( + const [result, receipt] = await transactionHelper.getResultAndReceiptAsync( testContract.bridgeTransferFrom, // The "to" token address. _opts.toTokenAddress, @@ -138,7 +135,7 @@ blockchainTests.resets('UniswapBridge unit tests', env => { } async function getExchangeForTokenAsync(tokenAddress: string): Promise { - return testContract.getExchange.callAsync(tokenAddress); + return testContract.getExchange(tokenAddress).callAsync(); } it('returns magic bytes on success', async () => { @@ -147,7 +144,7 @@ blockchainTests.resets('UniswapBridge unit tests', env => { }); it('just transfers tokens to `to` if the same tokens are in play', async () => { - const [[tokenAddress]] = await txHelper.getResultAndReceiptAsync( + const [[tokenAddress]] = await transactionHelper.getResultAndReceiptAsync( testContract.createTokenAndExchange, constants.NULL_ADDRESS, '', @@ -203,13 +200,15 @@ blockchainTests.resets('UniswapBridge unit tests', env => { }); it('fails if "from" token does not exist', async () => { - const tx = testContract.bridgeTransferFrom.awaitTransactionSuccessAsync( - randomAddress(), - randomAddress(), - randomAddress(), - getRandomInteger(1, 1e18), - hexLeftPad(randomAddress()), - ); + const tx = testContract + .bridgeTransferFrom( + randomAddress(), + randomAddress(), + randomAddress(), + getRandomInteger(1, 1e18), + hexLeftPad(randomAddress()), + ) + .awaitTransactionSuccessAsync(); return expect(tx).to.revertWith('NO_UNISWAP_EXCHANGE_FOR_TOKEN'); }); @@ -275,13 +274,15 @@ blockchainTests.resets('UniswapBridge unit tests', env => { }); it('fails if "from" token does not exist', async () => { - const tx = testContract.bridgeTransferFrom.awaitTransactionSuccessAsync( - randomAddress(), - randomAddress(), - randomAddress(), - getRandomInteger(1, 1e18), - hexLeftPad(wethTokenAddress), - ); + const tx = testContract + .bridgeTransferFrom( + randomAddress(), + randomAddress(), + randomAddress(), + getRandomInteger(1, 1e18), + hexLeftPad(wethTokenAddress), + ) + .awaitTransactionSuccessAsync(); return expect(tx).to.revertWith('NO_UNISWAP_EXCHANGE_FOR_TOKEN'); }); @@ -333,13 +334,15 @@ blockchainTests.resets('UniswapBridge unit tests', env => { }); it('fails if "to" token does not exist', async () => { - const tx = testContract.bridgeTransferFrom.awaitTransactionSuccessAsync( - wethTokenAddress, - randomAddress(), - randomAddress(), - getRandomInteger(1, 1e18), - hexLeftPad(randomAddress()), - ); + const tx = testContract + .bridgeTransferFrom( + wethTokenAddress, + randomAddress(), + randomAddress(), + getRandomInteger(1, 1e18), + hexLeftPad(randomAddress()), + ) + .awaitTransactionSuccessAsync(); return expect(tx).to.revertWith('NO_UNISWAP_EXCHANGE_FOR_TOKEN'); }); diff --git a/contracts/asset-proxy/test/utils/erc1155_proxy_wrapper.ts b/contracts/asset-proxy/test/utils/erc1155_proxy_wrapper.ts index 5bc707af41..6dbe18bb46 100644 --- a/contracts/asset-proxy/test/utils/erc1155_proxy_wrapper.ts +++ b/contracts/asset-proxy/test/utils/erc1155_proxy_wrapper.ts @@ -74,7 +74,7 @@ export class ERC1155ProxyWrapper { txDefaults, artifacts, ); - this._proxyIdIfExists = await this._proxyContract.getProxyId.callAsync(); + this._proxyIdIfExists = await this._proxyContract.getProxyId().callAsync(); return this._proxyContract; } /** @@ -111,19 +111,13 @@ export class ERC1155ProxyWrapper { this._validateProxyContractExistsOrThrow(); const assetData = assetData_ === undefined - ? await this._devUtils.encodeERC1155AssetData.callAsync( - contractAddress, - tokensToTransfer, - valuesToTransfer, - receiverCallbackData, - ) + ? await this._devUtils + .encodeERC1155AssetData(contractAddress, tokensToTransfer, valuesToTransfer, receiverCallbackData) + .callAsync() : assetData_; - const data = this._assetProxyInterface.transferFrom.getABIEncodedTransactionData( - assetData, - from, - to, - valueMultiplier, - ); + const data = this._assetProxyInterface + .transferFrom(assetData, from, to, valueMultiplier) + .getABIEncodedTransactionData(); return data; } /** @@ -171,19 +165,13 @@ export class ERC1155ProxyWrapper { this._validateProxyContractExistsOrThrow(); const assetData = assetData_ === undefined - ? await this._devUtils.encodeERC1155AssetData.callAsync( - contractAddress, - tokensToTransfer, - valuesToTransfer, - receiverCallbackData, - ) + ? await this._devUtils + .encodeERC1155AssetData(contractAddress, tokensToTransfer, valuesToTransfer, receiverCallbackData) + .callAsync() : assetData_; - const data = this._assetProxyInterface.transferFrom.getABIEncodedTransactionData( - assetData, - from, - to, - valueMultiplier, - ); + const data = this._assetProxyInterface + .transferFrom(assetData, from, to, valueMultiplier) + .getABIEncodedTransactionData(); const txHash = await this._web3Wrapper.sendTransactionAsync({ to: (this._proxyContract as ERC1155ProxyContract).address, data, @@ -364,7 +352,7 @@ export class ERC1155ProxyWrapper { this._validateProxyContractExistsOrThrow(); const tokenContract = this._getContractFromAddress(contractAddress); const operator = (this._proxyContract as ERC1155ProxyContract).address; - const didApproveAll = await tokenContract.isApprovedForAll.callAsync(userAddress, operator); + const didApproveAll = await tokenContract.isApprovedForAll(userAddress, operator).callAsync(); return didApproveAll; } public getFungibleTokenIds(): BigNumber[] { diff --git a/contracts/asset-proxy/test/utils/erc20_wrapper.ts b/contracts/asset-proxy/test/utils/erc20_wrapper.ts index 52e8d43142..57a9a2afe3 100644 --- a/contracts/asset-proxy/test/utils/erc20_wrapper.ts +++ b/contracts/asset-proxy/test/utils/erc20_wrapper.ts @@ -56,7 +56,7 @@ export class ERC20Wrapper { txDefaults, artifacts, ); - this._proxyIdIfExists = await this._proxyContract.getProxyId.callAsync(); + this._proxyIdIfExists = await this._proxyContract.getProxyId().callAsync(); return this._proxyContract; } public getProxyId(): string { @@ -68,43 +68,39 @@ export class ERC20Wrapper { this._validateProxyContractExistsOrThrow(); for (const dummyTokenContract of this._dummyTokenContracts) { for (const tokenOwnerAddress of this._tokenOwnerAddresses) { - await dummyTokenContract.setBalance.awaitTransactionSuccessAsync( - tokenOwnerAddress, - constants.INITIAL_ERC20_BALANCE, - { from: this._contractOwnerAddress }, - ); - await dummyTokenContract.approve.awaitTransactionSuccessAsync( - (this._proxyContract as ERC20ProxyContract).address, - constants.INITIAL_ERC20_ALLOWANCE, - { from: tokenOwnerAddress }, - ); + await dummyTokenContract + .setBalance(tokenOwnerAddress, constants.INITIAL_ERC20_BALANCE) + .awaitTransactionSuccessAsync({ from: this._contractOwnerAddress }); + await dummyTokenContract + .approve((this._proxyContract as ERC20ProxyContract).address, constants.INITIAL_ERC20_ALLOWANCE) + .awaitTransactionSuccessAsync({ from: tokenOwnerAddress }); } } } public async getBalanceAsync(userAddress: string, assetData: string): Promise { const tokenContract = await this._getTokenContractFromAssetDataAsync(assetData); - const balance = new BigNumber(await tokenContract.balanceOf.callAsync(userAddress)); + const balance = new BigNumber(await tokenContract.balanceOf(userAddress).callAsync()); return balance; } public async setBalanceAsync(userAddress: string, assetData: string, amount: BigNumber): Promise { const tokenContract = await this._getTokenContractFromAssetDataAsync(assetData); - await tokenContract.setBalance.awaitTransactionSuccessAsync( - userAddress, - amount, - { from: this._contractOwnerAddress }, - { pollingIntervalMs: constants.AWAIT_TRANSACTION_MINED_MS }, - ); + await tokenContract + .setBalance(userAddress, amount) + .awaitTransactionSuccessAsync( + { from: this._contractOwnerAddress }, + { pollingIntervalMs: constants.AWAIT_TRANSACTION_MINED_MS }, + ); } public async getProxyAllowanceAsync(userAddress: string, assetData: string): Promise { const tokenContract = await this._getTokenContractFromAssetDataAsync(assetData); const proxyAddress = (this._proxyContract as ERC20ProxyContract).address; - const allowance = new BigNumber(await tokenContract.allowance.callAsync(userAddress, proxyAddress)); + const allowance = new BigNumber(await tokenContract.allowance(userAddress, proxyAddress).callAsync()); return allowance; } public async setAllowanceAsync(userAddress: string, assetData: string, amount: BigNumber): Promise { const tokenContract = await this._getTokenContractFromAssetDataAsync(assetData); const proxyAddress = (this._proxyContract as ERC20ProxyContract).address; - await tokenContract.approve.awaitTransactionSuccessAsync(proxyAddress, amount, { from: userAddress }); + await tokenContract.approve(proxyAddress, amount).awaitTransactionSuccessAsync({ from: userAddress }); } public async getBalancesAsync(): Promise { this._validateDummyTokenContractsExistOrThrow(); @@ -113,7 +109,7 @@ export class ERC20Wrapper { const balanceInfo: Array<{ tokenOwnerAddress: string; tokenAddress: string }> = []; for (const dummyTokenContract of this._dummyTokenContracts) { for (const tokenOwnerAddress of this._tokenOwnerAddresses) { - balances.push(await dummyTokenContract.balanceOf.callAsync(tokenOwnerAddress)); + balances.push(await dummyTokenContract.balanceOf(tokenOwnerAddress).callAsync()); balanceInfo.push({ tokenOwnerAddress, tokenAddress: dummyTokenContract.address, @@ -147,7 +143,7 @@ export class ERC20Wrapper { return tokenAddresses; } private async _getTokenContractFromAssetDataAsync(assetData: string): Promise { - const [proxyId, tokenAddress] = await this._devUtils.decodeERC20AssetData.callAsync(assetData); // tslint:disable-line:no-unused-variable + const [proxyId, tokenAddress] = await this._devUtils.decodeERC20AssetData(assetData).callAsync(); // tslint:disable-line:no-unused-variable const tokenContractIfExists = _.find(this._dummyTokenContracts, c => c.address === tokenAddress); if (tokenContractIfExists === undefined) { throw new Error(`Token: ${tokenAddress} was not deployed through ERC20Wrapper`); diff --git a/contracts/asset-proxy/test/utils/erc721_wrapper.ts b/contracts/asset-proxy/test/utils/erc721_wrapper.ts index e2ae988930..ec50c15847 100644 --- a/contracts/asset-proxy/test/utils/erc721_wrapper.ts +++ b/contracts/asset-proxy/test/utils/erc721_wrapper.ts @@ -44,7 +44,7 @@ export class ERC721Wrapper { txDefaults, artifacts, ); - this._proxyIdIfExists = await this._proxyContract.getProxyId.callAsync(); + this._proxyIdIfExists = await this._proxyContract.getProxyId().callAsync(); return this._proxyContract; } public getProxyId(): string { @@ -78,7 +78,7 @@ export class ERC721Wrapper { } public async doesTokenExistAsync(tokenAddress: string, tokenId: BigNumber): Promise { const tokenContract = this._getTokenContractFromAssetData(tokenAddress); - const owner = await tokenContract.ownerOf.callAsync(tokenId); + const owner = await tokenContract.ownerOf(tokenId).callAsync(); const doesExist = owner !== constants.NULL_ADDRESS; return doesExist; } @@ -93,14 +93,14 @@ export class ERC721Wrapper { ): Promise { const tokenContract = this._getTokenContractFromAssetData(tokenAddress); const proxyAddress = (this._proxyContract as ERC721ProxyContract).address; - await tokenContract.setApprovalForAll.awaitTransactionSuccessAsync(proxyAddress, isApproved, { + await tokenContract.setApprovalForAll(proxyAddress, isApproved).awaitTransactionSuccessAsync({ from: ownerAddress, }); } public async approveAsync(to: string, tokenAddress: string, tokenId: BigNumber): Promise { const tokenContract = this._getTokenContractFromAssetData(tokenAddress); const tokenOwner = await this.ownerOfAsync(tokenAddress, tokenId); - await tokenContract.approve.awaitTransactionSuccessAsync(to, tokenId, { from: tokenOwner }); + await tokenContract.approve(to, tokenId).awaitTransactionSuccessAsync({ from: tokenOwner }); } public async transferFromAsync( tokenAddress: string, @@ -109,28 +109,28 @@ export class ERC721Wrapper { userAddress: string, ): Promise { const tokenContract = this._getTokenContractFromAssetData(tokenAddress); - await tokenContract.transferFrom.awaitTransactionSuccessAsync(currentOwner, userAddress, tokenId, { + await tokenContract.transferFrom(currentOwner, userAddress, tokenId).awaitTransactionSuccessAsync({ from: currentOwner, }); } public async mintAsync(tokenAddress: string, tokenId: BigNumber, userAddress: string): Promise { const tokenContract = this._getTokenContractFromAssetData(tokenAddress); - await tokenContract.mint.awaitTransactionSuccessAsync(userAddress, tokenId, { + await tokenContract.mint(userAddress, tokenId).awaitTransactionSuccessAsync({ from: this._contractOwnerAddress, }); } public async burnAsync(tokenAddress: string, tokenId: BigNumber, owner: string): Promise { const tokenContract = this._getTokenContractFromAssetData(tokenAddress); - await tokenContract.burn.awaitTransactionSuccessAsync(owner, tokenId, { from: this._contractOwnerAddress }); + await tokenContract.burn(owner, tokenId).awaitTransactionSuccessAsync({ from: this._contractOwnerAddress }); } public async ownerOfAsync(tokenAddress: string, tokenId: BigNumber): Promise { const tokenContract = this._getTokenContractFromAssetData(tokenAddress); - const owner = await tokenContract.ownerOf.callAsync(tokenId); + const owner = await tokenContract.ownerOf(tokenId).callAsync(); return owner; } public async isOwnerAsync(userAddress: string, tokenAddress: string, tokenId: BigNumber): Promise { const tokenContract = this._getTokenContractFromAssetData(tokenAddress); - const tokenOwner = await tokenContract.ownerOf.callAsync(tokenId); + const tokenOwner = await tokenContract.ownerOf(tokenId).callAsync(); const isOwner = tokenOwner === userAddress; return isOwner; } @@ -138,13 +138,13 @@ export class ERC721Wrapper { this._validateProxyContractExistsOrThrow(); const tokenContract = this._getTokenContractFromAssetData(tokenAddress); const operator = (this._proxyContract as ERC721ProxyContract).address; - const didApproveAll = await tokenContract.isApprovedForAll.callAsync(userAddress, operator); + const didApproveAll = await tokenContract.isApprovedForAll(userAddress, operator).callAsync(); return didApproveAll; } public async isProxyApprovedAsync(tokenAddress: string, tokenId: BigNumber): Promise { this._validateProxyContractExistsOrThrow(); const tokenContract = this._getTokenContractFromAssetData(tokenAddress); - const approvedAddress = await tokenContract.getApproved.callAsync(tokenId); + const approvedAddress = await tokenContract.getApproved(tokenId).callAsync(); const proxyAddress = (this._proxyContract as ERC721ProxyContract).address; const isProxyAnApprovedOperator = approvedAddress === proxyAddress; return isProxyAnApprovedOperator; @@ -161,7 +161,7 @@ export class ERC721Wrapper { dummyTokenContract.address ]; for (const tokenId of initialTokenOwnerIds) { - tokenOwnerAddresses.push(await dummyTokenContract.ownerOf.callAsync(tokenId)); + tokenOwnerAddresses.push(await dummyTokenContract.ownerOf(tokenId).callAsync()); tokenInfo.push({ tokenId, tokenAddress: dummyTokenContract.address, diff --git a/contracts/coordinator/test/coordinator_registry.ts b/contracts/coordinator/test/coordinator_registry.ts index 743132fa7e..8a2c8906f0 100644 --- a/contracts/coordinator/test/coordinator_registry.ts +++ b/contracts/coordinator/test/coordinator_registry.ts @@ -23,43 +23,42 @@ blockchainTests.resets('Coordinator Registry tests', env => { }); describe('core', () => { it('Should successfully set a Coordinator endpoint', async () => { - await coordinatorRegistry.setCoordinatorEndpoint.awaitTransactionSuccessAsync(coordinatorEndpoint, { + await coordinatorRegistry.setCoordinatorEndpoint(coordinatorEndpoint).awaitTransactionSuccessAsync({ from: coordinatorOperator, }); - const recordedCoordinatorEndpoint = await coordinatorRegistry.getCoordinatorEndpoint.callAsync( - coordinatorOperator, - ); + const recordedCoordinatorEndpoint = await coordinatorRegistry + .getCoordinatorEndpoint(coordinatorOperator) + .callAsync(); expect(recordedCoordinatorEndpoint).to.be.equal(coordinatorEndpoint); }); it('Should successfully unset a Coordinator endpoint', async () => { // set Coordinator endpoint - await coordinatorRegistry.setCoordinatorEndpoint.awaitTransactionSuccessAsync(coordinatorEndpoint, { + await coordinatorRegistry.setCoordinatorEndpoint(coordinatorEndpoint).awaitTransactionSuccessAsync({ from: coordinatorOperator, }); - let recordedCoordinatorEndpoint = await coordinatorRegistry.getCoordinatorEndpoint.callAsync( - coordinatorOperator, - ); + let recordedCoordinatorEndpoint = await coordinatorRegistry + .getCoordinatorEndpoint(coordinatorOperator) + .callAsync(); expect(recordedCoordinatorEndpoint).to.be.equal(coordinatorEndpoint); // unset Coordinator endpoint - await coordinatorRegistry.setCoordinatorEndpoint.awaitTransactionSuccessAsync(nilCoordinatorEndpoint, { + await coordinatorRegistry.setCoordinatorEndpoint(nilCoordinatorEndpoint).awaitTransactionSuccessAsync({ from: coordinatorOperator, }); - recordedCoordinatorEndpoint = await coordinatorRegistry.getCoordinatorEndpoint.callAsync( - coordinatorOperator, - ); + recordedCoordinatorEndpoint = await coordinatorRegistry + .getCoordinatorEndpoint(coordinatorOperator) + .callAsync(); expect(recordedCoordinatorEndpoint).to.be.equal(nilCoordinatorEndpoint); }); it('Should emit an event when setting Coordinator endpoint', async () => { // set Coordinator endpoint - const txReceipt = await coordinatorRegistry.setCoordinatorEndpoint.awaitTransactionSuccessAsync( - coordinatorEndpoint, - { + const txReceipt = await coordinatorRegistry + .setCoordinatorEndpoint(coordinatorEndpoint) + .awaitTransactionSuccessAsync({ from: coordinatorOperator, - }, - ); - const recordedCoordinatorEndpoint = await coordinatorRegistry.getCoordinatorEndpoint.callAsync( - coordinatorOperator, - ); + }); + const recordedCoordinatorEndpoint = await coordinatorRegistry + .getCoordinatorEndpoint(coordinatorOperator) + .callAsync(); expect(recordedCoordinatorEndpoint).to.be.equal(coordinatorEndpoint); // validate event const expectedEvent: CoordinatorRegistryCoordinatorEndpointSetEventArgs = { diff --git a/contracts/coordinator/test/libs.ts b/contracts/coordinator/test/libs.ts index ef6eb0b2a7..1ae2630d13 100644 --- a/contracts/coordinator/test/libs.ts +++ b/contracts/coordinator/test/libs.ts @@ -42,7 +42,7 @@ blockchainTests.resets('Libs tests', env => { transactionSignature: signedTx.signature, }; const expectedApprovalHash = hashUtils.getApprovalHashHex(signedTx, coordinatorContract.address, txOrigin); - const approvalHash = await coordinatorContract.getCoordinatorApprovalHash.callAsync(approval); + const approvalHash = await coordinatorContract.getCoordinatorApprovalHash(approval).callAsync(); expect(expectedApprovalHash).to.eq(approvalHash); }); }); diff --git a/contracts/coordinator/test/mixins.ts b/contracts/coordinator/test/mixins.ts index 4ee471b797..de86012ea2 100644 --- a/contracts/coordinator/test/mixins.ts +++ b/contracts/coordinator/test/mixins.ts @@ -70,14 +70,14 @@ blockchainTests.resets('Mixins tests', env => { const data = constants.NULL_BYTES; const transaction = await transactionFactory.newSignedTransactionAsync({ data }, SignatureType.EthSign); const transactionHash = transactionHashUtils.getTransactionHashHex(transaction); - const signerAddress = await mixins.getSignerAddress.callAsync(transactionHash, transaction.signature); + const signerAddress = await mixins.getSignerAddress(transactionHash, transaction.signature).callAsync(); expect(transaction.signerAddress).to.eq(signerAddress); }); it('should return the correct address using the EIP712 signature type', async () => { const data = constants.NULL_BYTES; const transaction = await transactionFactory.newSignedTransactionAsync({ data }, SignatureType.EIP712); const transactionHash = transactionHashUtils.getTransactionHashHex(transaction); - const signerAddress = await mixins.getSignerAddress.callAsync(transactionHash, transaction.signature); + const signerAddress = await mixins.getSignerAddress(transactionHash, transaction.signature).callAsync(); expect(transaction.signerAddress).to.eq(signerAddress); }); it('should revert with with the Illegal signature type', async () => { @@ -88,7 +88,7 @@ blockchainTests.resets('Mixins tests', env => { SignatureType.Illegal, ); const transactionHash = transactionHashUtils.getTransactionHashHex(transaction); - expect(mixins.getSignerAddress.callAsync(transactionHash, transaction.signature)).to.revertWith( + expect(mixins.getSignerAddress(transactionHash, transaction.signature).callAsync()).to.revertWith( new CoordinatorRevertErrors.SignatureError( CoordinatorRevertErrors.SignatureErrorCodes.Illegal, transactionHash, @@ -101,7 +101,7 @@ blockchainTests.resets('Mixins tests', env => { const transaction = await transactionFactory.newSignedTransactionAsync({ data }); transaction.signature = hexConcat(SignatureType.Invalid); const transactionHash = transactionHashUtils.getTransactionHashHex(transaction); - expect(mixins.getSignerAddress.callAsync(transactionHash, transaction.signature)).to.revertWith( + expect(mixins.getSignerAddress(transactionHash, transaction.signature).callAsync()).to.revertWith( new CoordinatorRevertErrors.SignatureError( CoordinatorRevertErrors.SignatureErrorCodes.Invalid, transactionHash, @@ -117,7 +117,7 @@ blockchainTests.resets('Mixins tests', env => { SignatureType.NSignatureTypes, ); const transactionHash = transactionHashUtils.getTransactionHashHex(transaction); - expect(mixins.getSignerAddress.callAsync(transactionHash, transaction.signature)).to.revertWith( + expect(mixins.getSignerAddress(transactionHash, transaction.signature).callAsync()).to.revertWith( new CoordinatorRevertErrors.SignatureError( CoordinatorRevertErrors.SignatureErrorCodes.Unsupported, transactionHash, @@ -133,7 +133,7 @@ blockchainTests.resets('Mixins tests', env => { SignatureType.Wallet, ); const transactionHash = transactionHashUtils.getTransactionHashHex(transaction); - expect(mixins.getSignerAddress.callAsync(transactionHash, transaction.signature)).to.revertWith( + expect(mixins.getSignerAddress(transactionHash, transaction.signature).callAsync()).to.revertWith( new CoordinatorRevertErrors.SignatureError( CoordinatorRevertErrors.SignatureErrorCodes.Unsupported, transactionHash, @@ -148,7 +148,7 @@ blockchainTests.resets('Mixins tests', env => { it(`should correctly decode the orders for ${fnName} data`, async () => { const orders = [defaultOrder]; const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); - const decodedOrders = await mixins.decodeOrdersFromFillData.callAsync(data); + const decodedOrders = await mixins.decodeOrdersFromFillData(data).callAsync(); const decodedSignedOrders = decodedOrders.map(order => ({ ...order, signature: constants.NULL_BYTES, @@ -162,7 +162,7 @@ blockchainTests.resets('Mixins tests', env => { it(`should correctly decode the orders for ${fnName} data`, async () => { const orders = [defaultOrder, defaultOrder]; const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); - const decodedOrders = await mixins.decodeOrdersFromFillData.callAsync(data); + const decodedOrders = await mixins.decodeOrdersFromFillData(data).callAsync(); const decodedSignedOrders = decodedOrders.map(order => ({ ...order, signature: constants.NULL_BYTES, @@ -176,7 +176,7 @@ blockchainTests.resets('Mixins tests', env => { it(`should correctly decode the orders for ${fnName} data`, async () => { const orders = [defaultOrder, defaultOrder]; const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); - const decodedOrders = await mixins.decodeOrdersFromFillData.callAsync(data); + const decodedOrders = await mixins.decodeOrdersFromFillData(data).callAsync(); const decodedSignedOrders = decodedOrders.map(order => ({ ...order, signature: constants.NULL_BYTES, @@ -190,7 +190,7 @@ blockchainTests.resets('Mixins tests', env => { it(`should correctly decode the orders for ${fnName} data`, async () => { const orders = [defaultOrder, defaultOrder]; const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); - const decodedOrders = await mixins.decodeOrdersFromFillData.callAsync(data); + const decodedOrders = await mixins.decodeOrdersFromFillData(data).callAsync(); const decodedSignedOrders = decodedOrders.map(order => ({ ...order, signature: constants.NULL_BYTES, @@ -204,14 +204,14 @@ blockchainTests.resets('Mixins tests', env => { it(`should correctly decode the orders for ${fnName} data`, async () => { const orders = [defaultOrder, defaultOrder]; const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); - const decodedOrders = await mixins.decodeOrdersFromFillData.callAsync(data); + const decodedOrders = await mixins.decodeOrdersFromFillData(data).callAsync(); const emptyArray: any[] = []; expect(emptyArray).to.deep.eq(decodedOrders); }); } it('should decode an empty array for invalid data', async () => { const data = '0x0123456789'; - const decodedOrders = await mixins.decodeOrdersFromFillData.callAsync(data); + const decodedOrders = await mixins.decodeOrdersFromFillData(data).callAsync(); const emptyArray: any[] = []; expect(emptyArray).to.deep.eq(decodedOrders); }); @@ -222,7 +222,7 @@ blockchainTests.resets('Mixins tests', env => { new BigNumber(3), // the length of data new BigNumber(4), ); - return expect(mixins.decodeOrdersFromFillData.callAsync(data)).to.revertWith(expectedError); + return expect(mixins.decodeOrdersFromFillData(data).callAsync()).to.revertWith(expectedError); }); }); @@ -233,13 +233,11 @@ blockchainTests.resets('Mixins tests', env => { const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); const transaction = await transactionFactory.newSignedTransactionAsync({ data }); const approval = approvalFactory1.newSignedApproval(transaction, transactionSignerAddress); - await mixins.assertValidCoordinatorApprovals.callAsync( - transaction, - transactionSignerAddress, - transaction.signature, - [approval.signature], - { from: transactionSignerAddress }, - ); + await mixins + .assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, [ + approval.signature, + ]) + .callAsync({ from: transactionSignerAddress }); }); it(`Should be successful: function=${fnName}, caller=tx_signer, senderAddress=[null], approval_sig=[approver1]`, async () => { const order = { @@ -250,54 +248,42 @@ blockchainTests.resets('Mixins tests', env => { const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); const transaction = await transactionFactory.newSignedTransactionAsync({ data }); const approval = approvalFactory1.newSignedApproval(transaction, transactionSignerAddress); - await mixins.assertValidCoordinatorApprovals.callAsync( - transaction, - transactionSignerAddress, - transaction.signature, - [approval.signature], - { from: transactionSignerAddress }, - ); + await mixins + .assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, [ + approval.signature, + ]) + .callAsync({ from: transactionSignerAddress }); }); it(`Should be successful: function=${fnName}, caller=approver1, senderAddress=[verifier], approval_sig=[]`, async () => { const orders = [defaultOrder]; const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); const transaction = await transactionFactory.newSignedTransactionAsync({ data }); - await mixins.assertValidCoordinatorApprovals.callAsync( - transaction, - approvalSignerAddress1, - transaction.signature, - [], - { + await mixins + .assertValidCoordinatorApprovals(transaction, approvalSignerAddress1, transaction.signature, []) + .callAsync({ from: approvalSignerAddress1, - }, - ); + }); }); it(`Should be successful: function=${fnName}, caller=approver1, senderAddress=[verifier], approval_sig=[approver1]`, async () => { const orders = [defaultOrder]; const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); const transaction = await transactionFactory.newSignedTransactionAsync({ data }); const approval = approvalFactory1.newSignedApproval(transaction, transactionSignerAddress); - await mixins.assertValidCoordinatorApprovals.callAsync( - transaction, - approvalSignerAddress1, - transaction.signature, - [approval.signature], - { from: approvalSignerAddress1 }, - ); + await mixins + .assertValidCoordinatorApprovals(transaction, approvalSignerAddress1, transaction.signature, [ + approval.signature, + ]) + .callAsync({ from: approvalSignerAddress1 }); }); it(`Should be successful: function=${fnName}, caller=approver1, senderAddress=[verifier], approval_sig=[]`, async () => { const orders = [defaultOrder]; const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); const transaction = await transactionFactory.newSignedTransactionAsync({ data }); - await mixins.assertValidCoordinatorApprovals.callAsync( - transaction, - approvalSignerAddress1, - transaction.signature, - [], - { + await mixins + .assertValidCoordinatorApprovals(transaction, approvalSignerAddress1, transaction.signature, []) + .callAsync({ from: approvalSignerAddress1, - }, - ); + }); }); it(`Should revert: function=${fnName}, caller=tx_signer, senderAddress=[verifier], approval_sig=[invalid]`, async () => { const orders = [defaultOrder]; @@ -309,13 +295,11 @@ blockchainTests.resets('Mixins tests', env => { '0xFFFFFFFF', hexSlice(approval.signature, 6), ); - const tx = mixins.assertValidCoordinatorApprovals.callAsync( - transaction, - transactionSignerAddress, - transaction.signature, - [signature], - { from: transactionSignerAddress }, - ); + const tx = mixins + .assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, [ + signature, + ]) + .callAsync({ from: transactionSignerAddress }); const transactionHash = transactionHashUtils.getTransactionHashHex(transaction); expect(tx).to.revertWith( @@ -328,13 +312,11 @@ blockchainTests.resets('Mixins tests', env => { const transaction = await transactionFactory.newSignedTransactionAsync({ data }); const approval = approvalFactory1.newSignedApproval(transaction, transactionSignerAddress); - const tx = mixins.assertValidCoordinatorApprovals.callAsync( - transaction, - transactionSignerAddress, - transaction.signature, - [approval.signature], - { from: approvalSignerAddress2 }, - ); + const tx = mixins + .assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, [ + approval.signature, + ]) + .callAsync({ from: approvalSignerAddress2 }); expect(tx).to.revertWith(new CoordinatorRevertErrors.InvalidOriginError(transactionSignerAddress)); }); } @@ -350,13 +332,11 @@ blockchainTests.resets('Mixins tests', env => { const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); const transaction = await transactionFactory.newSignedTransactionAsync({ data }); const approval = approvalFactory1.newSignedApproval(transaction, transactionSignerAddress); - await mixins.assertValidCoordinatorApprovals.callAsync( - transaction, - transactionSignerAddress, - transaction.signature, - [approval.signature], - { from: transactionSignerAddress }, - ); + await mixins + .assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, [ + approval.signature, + ]) + .callAsync({ from: transactionSignerAddress }); }); it(`Should be successful: function=${fnName} caller=tx_signer, senderAddress=[null,null], feeRecipient=[approver1,approver1], approval_sig=[approver1]`, async () => { const orders = [defaultOrder, defaultOrder].map(order => ({ @@ -366,13 +346,11 @@ blockchainTests.resets('Mixins tests', env => { const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); const transaction = await transactionFactory.newSignedTransactionAsync({ data }); const approval = approvalFactory1.newSignedApproval(transaction, transactionSignerAddress); - await mixins.assertValidCoordinatorApprovals.callAsync( - transaction, - transactionSignerAddress, - transaction.signature, - [approval.signature], - { from: transactionSignerAddress }, - ); + await mixins + .assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, [ + approval.signature, + ]) + .callAsync({ from: transactionSignerAddress }); }); it(`Should be successful: function=${fnName} caller=tx_signer, senderAddress=[null,null], feeRecipient=[approver1,approver1], approval_sig=[]`, async () => { const orders = [defaultOrder, defaultOrder].map(order => ({ @@ -381,26 +359,20 @@ blockchainTests.resets('Mixins tests', env => { })); const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); const transaction = await transactionFactory.newSignedTransactionAsync({ data }); - await mixins.assertValidCoordinatorApprovals.callAsync( - transaction, - transactionSignerAddress, - transaction.signature, - [], - { from: transactionSignerAddress }, - ); + await mixins + .assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, []) + .callAsync({ from: transactionSignerAddress }); }); it(`Should be successful: function=${fnName} caller=tx_signer, senderAddress=[verifier,null], feeRecipient=[approver1,approver1], approval_sig=[approver1]`, async () => { const orders = [defaultOrder, { ...defaultOrder, senderAddress: constants.NULL_ADDRESS }]; const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); const transaction = await transactionFactory.newSignedTransactionAsync({ data }); const approval = approvalFactory1.newSignedApproval(transaction, transactionSignerAddress); - await mixins.assertValidCoordinatorApprovals.callAsync( - transaction, - transactionSignerAddress, - transaction.signature, - [approval.signature], - { from: transactionSignerAddress }, - ); + await mixins + .assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, [ + approval.signature, + ]) + .callAsync({ from: transactionSignerAddress }); }); it(`Should be successful: function=${fnName} caller=tx_signer, senderAddress=[verifier,verifier], feeRecipient=[approver1,approver2], approval_sig=[approver1,approver2]`, async () => { const orders = [defaultOrder, { ...defaultOrder, feeRecipientAddress: approvalSignerAddress2 }]; @@ -408,25 +380,20 @@ blockchainTests.resets('Mixins tests', env => { const transaction = await transactionFactory.newSignedTransactionAsync({ data }); const approval1 = approvalFactory1.newSignedApproval(transaction, transactionSignerAddress); const approval2 = approvalFactory2.newSignedApproval(transaction, transactionSignerAddress); - await mixins.assertValidCoordinatorApprovals.callAsync( - transaction, - transactionSignerAddress, - transaction.signature, - [approval1.signature, approval2.signature], - { from: transactionSignerAddress }, - ); + await mixins + .assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, [ + approval1.signature, + approval2.signature, + ]) + .callAsync({ from: transactionSignerAddress }); }); it(`Should be successful: function=${fnName} caller=approver1, senderAddress=[verifier,verifier], feeRecipient=[approver1,approver1], approval_sig=[]`, async () => { const orders = [defaultOrder, defaultOrder]; const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); const transaction = await transactionFactory.newSignedTransactionAsync({ data }); - await mixins.assertValidCoordinatorApprovals.callAsync( - transaction, - approvalSignerAddress1, - transaction.signature, - [], - { from: approvalSignerAddress1 }, - ); + await mixins + .assertValidCoordinatorApprovals(transaction, approvalSignerAddress1, transaction.signature, []) + .callAsync({ from: approvalSignerAddress1 }); }); it(`Should revert: function=${fnName} caller=approver1, senderAddress=[verifier,verifier], feeRecipient=[approver1,approver2], approval_sig=[approver2]`, async () => { const orders = [defaultOrder, { ...defaultOrder, feeRecipientAddress: approvalSignerAddress2 }]; @@ -434,26 +401,20 @@ blockchainTests.resets('Mixins tests', env => { const transaction = await transactionFactory.newSignedTransactionAsync({ data }); const approval2 = approvalFactory2.newSignedApproval(transaction, transactionSignerAddress); - const tx = mixins.assertValidCoordinatorApprovals.callAsync( - transaction, - transactionSignerAddress, - transaction.signature, - [approval2.signature], - { from: approvalSignerAddress1 }, - ); + const tx = mixins + .assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, [ + approval2.signature, + ]) + .callAsync({ from: approvalSignerAddress1 }); expect(tx).to.revertWith(new CoordinatorRevertErrors.InvalidOriginError(transactionSignerAddress)); }); it(`Should revert: function=${fnName} caller=tx_signer, senderAddress=[verifier,verifier], feeRecipient=[approver1, approver1], approval_sig=[]`, async () => { const orders = [defaultOrder, defaultOrder]; const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); const transaction = await transactionFactory.newSignedTransactionAsync({ data }); - const tx = mixins.assertValidCoordinatorApprovals.callAsync( - transaction, - transactionSignerAddress, - transaction.signature, - [], - { from: transactionSignerAddress }, - ); + const tx = mixins + .assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, []) + .callAsync({ from: transactionSignerAddress }); const transactionHash = transactionHashUtils.getTransactionHashHex(transaction); expect(tx).to.revertWith( @@ -470,13 +431,11 @@ blockchainTests.resets('Mixins tests', env => { '0xFFFFFFFF', hexSlice(approval.signature, 6), ); - const tx = mixins.assertValidCoordinatorApprovals.callAsync( - transaction, - transactionSignerAddress, - transaction.signature, - [signature], - { from: transactionSignerAddress }, - ); + const tx = mixins + .assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, [ + signature, + ]) + .callAsync({ from: transactionSignerAddress }); const transactionHash = transactionHashUtils.getTransactionHashHex(transaction); expect(tx).to.revertWith( @@ -494,13 +453,12 @@ blockchainTests.resets('Mixins tests', env => { '0xFFFFFFFF', hexSlice(approval2.signature, 6), ); - const tx = mixins.assertValidCoordinatorApprovals.callAsync( - transaction, - transactionSignerAddress, - transaction.signature, - [approval1.signature, approvalSignature2], - { from: transactionSignerAddress }, - ); + const tx = mixins + .assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, [ + approval1.signature, + approvalSignature2, + ]) + .callAsync({ from: transactionSignerAddress }); const transactionHash = transactionHashUtils.getTransactionHashHex(transaction); expect(tx).to.revertWith( @@ -517,13 +475,11 @@ blockchainTests.resets('Mixins tests', env => { '0xFFFFFFFF', hexSlice(approval2.signature, 6), ); - const tx = mixins.assertValidCoordinatorApprovals.callAsync( - transaction, - approvalSignerAddress1, - transaction.signature, - [approvalSignature2], - { from: approvalSignerAddress1 }, - ); + const tx = mixins + .assertValidCoordinatorApprovals(transaction, approvalSignerAddress1, transaction.signature, [ + approvalSignature2, + ]) + .callAsync({ from: approvalSignerAddress1 }); const transactionHash = transactionHashUtils.getTransactionHashHex(transaction); expect(tx).to.revertWith( @@ -536,13 +492,11 @@ blockchainTests.resets('Mixins tests', env => { const transaction = await transactionFactory.newSignedTransactionAsync({ data }); const approval1 = approvalFactory1.newSignedApproval(transaction, transactionSignerAddress); - const tx = mixins.assertValidCoordinatorApprovals.callAsync( - transaction, - transactionSignerAddress, - transaction.signature, - [approval1.signature], - { from: approvalSignerAddress2 }, - ); + const tx = mixins + .assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, [ + approval1.signature, + ]) + .callAsync({ from: approvalSignerAddress2 }); expect(tx).to.revertWith(new CoordinatorRevertErrors.InvalidOriginError(transactionSignerAddress)); }); } @@ -552,36 +506,24 @@ blockchainTests.resets('Mixins tests', env => { const orders = [defaultOrder]; const data = exchangeDataEncoder.encodeOrdersToExchangeData(ExchangeFunctionName.CancelOrder, orders); const transaction = await transactionFactory.newSignedTransactionAsync({ data }); - await mixins.assertValidCoordinatorApprovals.callAsync( - transaction, - transactionSignerAddress, - transaction.signature, - [], - { from: transactionSignerAddress }, - ); + await mixins + .assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, []) + .callAsync({ from: transactionSignerAddress }); }); it('should allow the tx signer to call `batchCancelOrders` without approval', async () => { const orders = [defaultOrder, defaultOrder]; const data = exchangeDataEncoder.encodeOrdersToExchangeData(ExchangeFunctionName.BatchCancelOrders, orders); const transaction = await transactionFactory.newSignedTransactionAsync({ data }); - await mixins.assertValidCoordinatorApprovals.callAsync( - transaction, - transactionSignerAddress, - transaction.signature, - [], - { from: transactionSignerAddress }, - ); + await mixins + .assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, []) + .callAsync({ from: transactionSignerAddress }); }); it('should allow the tx signer to call `cancelOrdersUpTo` without approval', async () => { const data = exchangeDataEncoder.encodeOrdersToExchangeData(ExchangeFunctionName.CancelOrdersUpTo); const transaction = await transactionFactory.newSignedTransactionAsync({ data }); - await mixins.assertValidCoordinatorApprovals.callAsync( - transaction, - transactionSignerAddress, - transaction.signature, - [], - { from: transactionSignerAddress }, - ); + await mixins + .assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, []) + .callAsync({ from: transactionSignerAddress }); }); }); }); diff --git a/contracts/erc1155/test/erc1155_token.ts b/contracts/erc1155/test/erc1155_token.ts index ef3b2def3e..88f2048a78 100644 --- a/contracts/erc1155/test/erc1155_token.ts +++ b/contracts/erc1155/test/erc1155_token.ts @@ -179,14 +179,9 @@ describe('ERC1155Token', () => { valueToTransfer, ); // execute transfer - const tx = erc1155Contract.safeTransferFrom.sendTransactionAsync( - spender, - receiver, - tokenToTransfer, - valueToTransfer, - receiverCallbackData, - { from: spender }, - ); + const tx = erc1155Contract + .safeTransferFrom(spender, receiver, tokenToTransfer, valueToTransfer, receiverCallbackData) + .sendTransactionAsync({ from: spender }); return expect(tx).to.revertWith(expectedError); }); it('should revert if callback reverts', async () => { @@ -196,19 +191,14 @@ describe('ERC1155Token', () => { // set receiver to reject balances const shouldRejectTransfer = true; await web3Wrapper.awaitTransactionSuccessAsync( - await erc1155Receiver.setRejectTransferFlag.sendTransactionAsync(shouldRejectTransfer), + await erc1155Receiver.setRejectTransferFlag(shouldRejectTransfer).sendTransactionAsync(), constants.AWAIT_TRANSACTION_MINED_MS, ); // execute transfer await expectTransactionFailedAsync( - erc1155Contract.safeTransferFrom.sendTransactionAsync( - spender, - receiver, - tokenToTransfer, - valueToTransfer, - receiverCallbackData, - { from: spender }, - ), + erc1155Contract + .safeTransferFrom(spender, receiver, tokenToTransfer, valueToTransfer, receiverCallbackData) + .sendTransactionAsync({ from: spender }), RevertReason.TransferRejected, ); }); @@ -355,14 +345,9 @@ describe('ERC1155Token', () => { valuesToTransfer[0], ); // execute transfer - const tx = erc1155Contract.safeBatchTransferFrom.sendTransactionAsync( - spender, - receiver, - tokensToTransfer, - valuesToTransfer, - receiverCallbackData, - { from: spender }, - ); + const tx = erc1155Contract + .safeBatchTransferFrom(spender, receiver, tokensToTransfer, valuesToTransfer, receiverCallbackData) + .sendTransactionAsync({ from: spender }); return expect(tx).to.revertWith(expectedError); }); it('should revert if callback reverts', async () => { @@ -372,19 +357,14 @@ describe('ERC1155Token', () => { // set receiver to reject balances const shouldRejectTransfer = true; await web3Wrapper.awaitTransactionSuccessAsync( - await erc1155Receiver.setRejectTransferFlag.sendTransactionAsync(shouldRejectTransfer), + await erc1155Receiver.setRejectTransferFlag(shouldRejectTransfer).sendTransactionAsync(), constants.AWAIT_TRANSACTION_MINED_MS, ); // execute transfer await expectTransactionFailedAsync( - erc1155Contract.safeBatchTransferFrom.sendTransactionAsync( - spender, - receiver, - tokensToTransfer, - valuesToTransfer, - receiverCallbackData, - { from: spender }, - ), + erc1155Contract + .safeBatchTransferFrom(spender, receiver, tokensToTransfer, valuesToTransfer, receiverCallbackData) + .sendTransactionAsync({ from: spender }), RevertReason.TransferRejected, ); }); @@ -432,14 +412,9 @@ describe('ERC1155Token', () => { await erc1155Wrapper.assertBalancesAsync(tokenHolders, [tokenToTransfer], expectedInitialBalances); // execute transfer await expectTransactionFailedAsync( - erc1155Contract.safeTransferFrom.sendTransactionAsync( - spender, - receiver, - tokenToTransfer, - valueToTransfer, - receiverCallbackData, - { from: delegatedSpender }, - ), + erc1155Contract + .safeTransferFrom(spender, receiver, tokenToTransfer, valueToTransfer, receiverCallbackData) + .sendTransactionAsync({ from: delegatedSpender }), RevertReason.InsufficientAllowance, ); }); @@ -485,14 +460,9 @@ describe('ERC1155Token', () => { await erc1155Wrapper.assertBalancesAsync(tokenHolders, tokensToTransfer, expectedInitialBalances); // execute transfer await expectTransactionFailedAsync( - erc1155Contract.safeBatchTransferFrom.sendTransactionAsync( - spender, - receiver, - tokensToTransfer, - valuesToTransfer, - receiverCallbackData, - { from: delegatedSpender }, - ), + erc1155Contract + .safeBatchTransferFrom(spender, receiver, tokensToTransfer, valuesToTransfer, receiverCallbackData) + .sendTransactionAsync({ from: delegatedSpender }), RevertReason.InsufficientAllowance, ); }); diff --git a/contracts/erc1155/test/utils/erc1155_wrapper.ts b/contracts/erc1155/test/utils/erc1155_wrapper.ts index 984935db17..f9b49131c2 100644 --- a/contracts/erc1155/test/utils/erc1155_wrapper.ts +++ b/contracts/erc1155/test/utils/erc1155_wrapper.ts @@ -25,7 +25,7 @@ export class Erc1155Wrapper { return this._erc1155Contract; } public async getBalancesAsync(owners: string[], tokens: BigNumber[]): Promise { - const balances = await this._erc1155Contract.balanceOfBatch.callAsync(owners, tokens); + const balances = await this._erc1155Contract.balanceOfBatch(owners, tokens).callAsync(); return balances; } public async safeTransferFromAsync( @@ -39,7 +39,7 @@ export class Erc1155Wrapper { const spender = delegatedSpender === undefined ? from : delegatedSpender; const callbackDataHex = callbackData === undefined ? '0x' : callbackData; const tx = await this._logDecoder.getTxWithDecodedLogsAsync( - await this._erc1155Contract.safeTransferFrom.sendTransactionAsync(from, to, token, value, callbackDataHex, { + await this._erc1155Contract.safeTransferFrom(from, to, token, value, callbackDataHex).sendTransactionAsync({ from: spender, }), ); @@ -56,14 +56,9 @@ export class Erc1155Wrapper { const spender = delegatedSpender === undefined ? from : delegatedSpender; const callbackDataHex = callbackData === undefined ? '0x' : callbackData; const tx = await this._logDecoder.getTxWithDecodedLogsAsync( - await this._erc1155Contract.safeBatchTransferFrom.sendTransactionAsync( - from, - to, - tokens, - values, - callbackDataHex, - { from: spender }, - ), + await this._erc1155Contract + .safeBatchTransferFrom(from, to, tokens, values, callbackDataHex) + .sendTransactionAsync({ from: spender }), ); return tx; } @@ -74,7 +69,7 @@ export class Erc1155Wrapper { const tokenUri = 'dummyFungibleToken'; const tokenIsNonFungible = false; const tx = await this._logDecoder.getTxWithDecodedLogsAsync( - await this._erc1155Contract.create.sendTransactionAsync(tokenUri, tokenIsNonFungible, { + await this._erc1155Contract.create(tokenUri, tokenIsNonFungible).sendTransactionAsync({ from: this._contractOwner, }), ); @@ -95,25 +90,22 @@ export class Erc1155Wrapper { tokenAmountsAsArray.push(tokenAmounts); }); } - await this._erc1155Contract.mintFungible.awaitTransactionSuccessAsync( - tokenId, - beneficiaries, - tokenAmountsAsArray, - { from: this._contractOwner }, - ); + await this._erc1155Contract + .mintFungible(tokenId, beneficiaries, tokenAmountsAsArray) + .awaitTransactionSuccessAsync({ from: this._contractOwner }); } public async mintNonFungibleTokensAsync(beneficiaries: string[]): Promise<[BigNumber, BigNumber[]]> { const tokenUri = 'dummyNonFungibleToken'; const tokenIsNonFungible = true; const tx = await this._logDecoder.getTxWithDecodedLogsAsync( - await this._erc1155Contract.create.sendTransactionAsync(tokenUri, tokenIsNonFungible, { + await this._erc1155Contract.create(tokenUri, tokenIsNonFungible).sendTransactionAsync({ from: this._contractOwner, }), ); // tslint:disable-next-line no-unnecessary-type-assertion const createFungibleTokenLog = tx.logs[0] as LogWithDecodedArgs; const token = createFungibleTokenLog.args.id; - await this._erc1155Contract.mintNonFungible.awaitTransactionSuccessAsync(token, beneficiaries, { + await this._erc1155Contract.mintNonFungible(token, beneficiaries).awaitTransactionSuccessAsync({ from: this._contractOwner, }); const encodedNftIds: BigNumber[] = []; @@ -132,14 +124,14 @@ export class Erc1155Wrapper { isApproved: boolean, ): Promise { const tx = await this._logDecoder.getTxWithDecodedLogsAsync( - await this._erc1155Contract.setApprovalForAll.sendTransactionAsync(beneficiary, isApproved, { + await this._erc1155Contract.setApprovalForAll(beneficiary, isApproved).sendTransactionAsync({ from: owner, }), ); return tx; } public async isApprovedForAllAsync(owner: string, beneficiary: string): Promise { - const isApprovedForAll = await this._erc1155Contract.isApprovedForAll.callAsync(owner, beneficiary); + const isApprovedForAll = await this._erc1155Contract.isApprovedForAll(owner, beneficiary).callAsync(); return isApprovedForAll; } public async assertBalancesAsync( @@ -161,18 +153,18 @@ export class Erc1155Wrapper { }); } public async isNonFungibleItemAsync(tokenId: BigNumber): Promise { - return this._erc1155Contract.isNonFungibleItem.callAsync(tokenId); + return this._erc1155Contract.isNonFungibleItem(tokenId).callAsync(); } public async isFungibleItemAsync(tokenId: BigNumber): Promise { return !(await this.isNonFungibleItemAsync(tokenId)); } public async getOwnerOfAsync(tokenId: BigNumber): Promise { - return this._erc1155Contract.ownerOf.callAsync(tokenId); + return this._erc1155Contract.ownerOf(tokenId).callAsync(); } /** * @dev Get the balance of an ERC1155 token for a given owner and token ID. */ public async getBalanceAsync(ownerAddress: string, tokenId: BigNumber): Promise { - return this._erc1155Contract.balanceOf.callAsync(ownerAddress, tokenId); + return this._erc1155Contract.balanceOf(ownerAddress, tokenId).callAsync(); } } diff --git a/contracts/erc20/test/lib_erc20_token.ts b/contracts/erc20/test/lib_erc20_token.ts index b843867a8c..3df3d2b363 100644 --- a/contracts/erc20/test/lib_erc20_token.ts +++ b/contracts/erc20/test/lib_erc20_token.ts @@ -37,13 +37,9 @@ blockchainTests('LibERC20Token', env => { it('calls the target with the correct arguments', async () => { const spender = randomAddress(); const allowance = getRandomInteger(0, 100e18); - const { logs } = await testContract.testApprove.awaitTransactionSuccessAsync( - false, - encodeRevert(REVERT_STRING), - ENCODED_TRUE, - spender, - allowance, - ); + const { logs } = await testContract + .testApprove(false, encodeRevert(REVERT_STRING), ENCODED_TRUE, spender, allowance) + .awaitTransactionSuccessAsync(); expect(logs).to.be.length(1); verifyEventsFromLogs(logs, [{ spender, allowance }], TestLibERC20TokenTargetEvents.ApproveCalled); }); @@ -51,37 +47,25 @@ blockchainTests('LibERC20Token', env => { it('succeeds if the target returns true', async () => { const spender = randomAddress(); const allowance = getRandomInteger(0, 100e18); - await testContract.testApprove.awaitTransactionSuccessAsync( - false, - encodeRevert(REVERT_STRING), - ENCODED_TRUE, - spender, - allowance, - ); + await testContract + .testApprove(false, encodeRevert(REVERT_STRING), ENCODED_TRUE, spender, allowance) + .awaitTransactionSuccessAsync(); }); it('succeeds if the target returns nothing', async () => { const spender = randomAddress(); const allowance = getRandomInteger(0, 100e18); - await testContract.testApprove.awaitTransactionSuccessAsync( - false, - encodeRevert(REVERT_STRING), - constants.NULL_BYTES, - spender, - allowance, - ); + await testContract + .testApprove(false, encodeRevert(REVERT_STRING), constants.NULL_BYTES, spender, allowance) + .awaitTransactionSuccessAsync(); }); it('fails if the target returns false', async () => { const spender = randomAddress(); const allowance = getRandomInteger(0, 100e18); - const tx = testContract.testApprove.awaitTransactionSuccessAsync( - false, - encodeRevert(REVERT_STRING), - ENCODED_FALSE, - spender, - allowance, - ); + const tx = testContract + .testApprove(false, encodeRevert(REVERT_STRING), ENCODED_FALSE, spender, allowance) + .awaitTransactionSuccessAsync(); const expectedError = new RawRevertError(ENCODED_FALSE); return expect(tx).to.revertWith(expectedError); }); @@ -89,13 +73,9 @@ blockchainTests('LibERC20Token', env => { it('fails if the target returns nonzero and not true', async () => { const spender = randomAddress(); const allowance = getRandomInteger(0, 100e18); - const tx = testContract.testApprove.awaitTransactionSuccessAsync( - false, - encodeRevert(REVERT_STRING), - ENCODED_TWO, - spender, - allowance, - ); + const tx = testContract + .testApprove(false, encodeRevert(REVERT_STRING), ENCODED_TWO, spender, allowance) + .awaitTransactionSuccessAsync(); const expectedError = new RawRevertError(ENCODED_TWO); return expect(tx).to.revertWith(expectedError); }); @@ -103,13 +83,9 @@ blockchainTests('LibERC20Token', env => { it('fails if the target returns less than 32 bytes', async () => { const spender = randomAddress(); const allowance = getRandomInteger(0, 100e18); - const tx = testContract.testApprove.awaitTransactionSuccessAsync( - false, - encodeRevert(REVERT_STRING), - ENCODED_SHORT_TRUE, - spender, - allowance, - ); + const tx = testContract + .testApprove(false, encodeRevert(REVERT_STRING), ENCODED_SHORT_TRUE, spender, allowance) + .awaitTransactionSuccessAsync(); const expectedError = new RawRevertError(ENCODED_SHORT_TRUE); return expect(tx).to.revertWith(expectedError); }); @@ -117,13 +93,9 @@ blockchainTests('LibERC20Token', env => { it('fails if the target returns greater than 32 bytes', async () => { const spender = randomAddress(); const allowance = getRandomInteger(0, 100e18); - const tx = testContract.testApprove.awaitTransactionSuccessAsync( - false, - encodeRevert(REVERT_STRING), - ENCODED_LONG_TRUE, - spender, - allowance, - ); + const tx = testContract + .testApprove(false, encodeRevert(REVERT_STRING), ENCODED_LONG_TRUE, spender, allowance) + .awaitTransactionSuccessAsync(); const expectedError = new RawRevertError(ENCODED_LONG_TRUE); return expect(tx).to.revertWith(expectedError); }); @@ -131,26 +103,18 @@ blockchainTests('LibERC20Token', env => { it('fails if the target reverts', async () => { const spender = randomAddress(); const allowance = getRandomInteger(0, 100e18); - const tx = testContract.testApprove.awaitTransactionSuccessAsync( - true, - encodeRevert(REVERT_STRING), - ENCODED_TRUE, - spender, - allowance, - ); + const tx = testContract + .testApprove(true, encodeRevert(REVERT_STRING), ENCODED_TRUE, spender, allowance) + .awaitTransactionSuccessAsync(); return expect(tx).to.revertWith(REVERT_STRING); }); it('fails if the target reverts with no data', async () => { const spender = randomAddress(); const allowance = getRandomInteger(0, 100e18); - const tx = testContract.testApprove.awaitTransactionSuccessAsync( - true, - constants.NULL_BYTES, - ENCODED_TRUE, - spender, - allowance, - ); + const tx = testContract + .testApprove(true, constants.NULL_BYTES, ENCODED_TRUE, spender, allowance) + .awaitTransactionSuccessAsync(); return expect(tx).to.be.rejectedWith('revert'); }); }); @@ -159,13 +123,9 @@ blockchainTests('LibERC20Token', env => { it('calls the target with the correct arguments', async () => { const to = randomAddress(); const amount = getRandomInteger(0, 100e18); - const { logs } = await testContract.testTransfer.awaitTransactionSuccessAsync( - false, - encodeRevert(REVERT_STRING), - ENCODED_TRUE, - to, - amount, - ); + const { logs } = await testContract + .testTransfer(false, encodeRevert(REVERT_STRING), ENCODED_TRUE, to, amount) + .awaitTransactionSuccessAsync(); expect(logs).to.be.length(1); verifyEventsFromLogs(logs, [{ to, amount }], TestLibERC20TokenTargetEvents.TransferCalled); }); @@ -173,37 +133,25 @@ blockchainTests('LibERC20Token', env => { it('succeeds if the target returns true', async () => { const to = randomAddress(); const amount = getRandomInteger(0, 100e18); - await testContract.testTransfer.awaitTransactionSuccessAsync( - false, - encodeRevert(REVERT_STRING), - ENCODED_TRUE, - to, - amount, - ); + await testContract + .testTransfer(false, encodeRevert(REVERT_STRING), ENCODED_TRUE, to, amount) + .awaitTransactionSuccessAsync(); }); it('succeeds if the target returns nothing', async () => { const to = randomAddress(); const amount = getRandomInteger(0, 100e18); - await testContract.testTransfer.awaitTransactionSuccessAsync( - false, - encodeRevert(REVERT_STRING), - constants.NULL_BYTES, - to, - amount, - ); + await testContract + .testTransfer(false, encodeRevert(REVERT_STRING), constants.NULL_BYTES, to, amount) + .awaitTransactionSuccessAsync(); }); it('fails if the target returns false', async () => { const to = randomAddress(); const amount = getRandomInteger(0, 100e18); - const tx = testContract.testTransfer.awaitTransactionSuccessAsync( - false, - encodeRevert(REVERT_STRING), - ENCODED_FALSE, - to, - amount, - ); + const tx = testContract + .testTransfer(false, encodeRevert(REVERT_STRING), ENCODED_FALSE, to, amount) + .awaitTransactionSuccessAsync(); const expectedError = new RawRevertError(ENCODED_FALSE); return expect(tx).to.revertWith(expectedError); }); @@ -211,13 +159,9 @@ blockchainTests('LibERC20Token', env => { it('fails if the target returns nonzero and not true', async () => { const to = randomAddress(); const amount = getRandomInteger(0, 100e18); - const tx = testContract.testTransfer.awaitTransactionSuccessAsync( - false, - encodeRevert(REVERT_STRING), - ENCODED_TWO, - to, - amount, - ); + const tx = testContract + .testTransfer(false, encodeRevert(REVERT_STRING), ENCODED_TWO, to, amount) + .awaitTransactionSuccessAsync(); const expectedError = new RawRevertError(ENCODED_TWO); return expect(tx).to.revertWith(expectedError); }); @@ -225,13 +169,9 @@ blockchainTests('LibERC20Token', env => { it('fails if the target returns less than 32 bytes', async () => { const to = randomAddress(); const amount = getRandomInteger(0, 100e18); - const tx = testContract.testTransfer.awaitTransactionSuccessAsync( - false, - encodeRevert(REVERT_STRING), - ENCODED_SHORT_TRUE, - to, - amount, - ); + const tx = testContract + .testTransfer(false, encodeRevert(REVERT_STRING), ENCODED_SHORT_TRUE, to, amount) + .awaitTransactionSuccessAsync(); const expectedError = new RawRevertError(ENCODED_SHORT_TRUE); return expect(tx).to.revertWith(expectedError); }); @@ -239,13 +179,9 @@ blockchainTests('LibERC20Token', env => { it('fails if the target returns greater than 32 bytes', async () => { const to = randomAddress(); const amount = getRandomInteger(0, 100e18); - const tx = testContract.testTransfer.awaitTransactionSuccessAsync( - false, - encodeRevert(REVERT_STRING), - ENCODED_LONG_TRUE, - to, - amount, - ); + const tx = testContract + .testTransfer(false, encodeRevert(REVERT_STRING), ENCODED_LONG_TRUE, to, amount) + .awaitTransactionSuccessAsync(); const expectedError = new RawRevertError(ENCODED_LONG_TRUE); return expect(tx).to.revertWith(expectedError); }); @@ -253,26 +189,18 @@ blockchainTests('LibERC20Token', env => { it('fails if the target reverts', async () => { const to = randomAddress(); const amount = getRandomInteger(0, 100e18); - const tx = testContract.testTransfer.awaitTransactionSuccessAsync( - true, - encodeRevert(REVERT_STRING), - ENCODED_TRUE, - to, - amount, - ); + const tx = testContract + .testTransfer(true, encodeRevert(REVERT_STRING), ENCODED_TRUE, to, amount) + .awaitTransactionSuccessAsync(); return expect(tx).to.revertWith(REVERT_STRING); }); it('fails if the target reverts with no data', async () => { const to = randomAddress(); const amount = getRandomInteger(0, 100e18); - const tx = testContract.testTransfer.awaitTransactionSuccessAsync( - true, - constants.NULL_BYTES, - ENCODED_TRUE, - to, - amount, - ); + const tx = testContract + .testTransfer(true, constants.NULL_BYTES, ENCODED_TRUE, to, amount) + .awaitTransactionSuccessAsync(); return expect(tx).to.be.rejectedWith('revert'); }); }); @@ -282,14 +210,9 @@ blockchainTests('LibERC20Token', env => { const owner = randomAddress(); const to = randomAddress(); const amount = getRandomInteger(0, 100e18); - const { logs } = await testContract.testTransferFrom.awaitTransactionSuccessAsync( - false, - encodeRevert(REVERT_STRING), - ENCODED_TRUE, - owner, - to, - amount, - ); + const { logs } = await testContract + .testTransferFrom(false, encodeRevert(REVERT_STRING), ENCODED_TRUE, owner, to, amount) + .awaitTransactionSuccessAsync(); expect(logs).to.be.length(1); verifyEventsFromLogs(logs, [{ from: owner, to, amount }], TestLibERC20TokenTargetEvents.TransferFromCalled); }); @@ -298,42 +221,27 @@ blockchainTests('LibERC20Token', env => { const owner = randomAddress(); const to = randomAddress(); const amount = getRandomInteger(0, 100e18); - await testContract.testTransferFrom.awaitTransactionSuccessAsync( - false, - encodeRevert(REVERT_STRING), - ENCODED_TRUE, - owner, - to, - amount, - ); + await testContract + .testTransferFrom(false, encodeRevert(REVERT_STRING), ENCODED_TRUE, owner, to, amount) + .awaitTransactionSuccessAsync(); }); it('succeeds if the target returns nothing', async () => { const owner = randomAddress(); const to = randomAddress(); const amount = getRandomInteger(0, 100e18); - await testContract.testTransferFrom.awaitTransactionSuccessAsync( - false, - encodeRevert(REVERT_STRING), - constants.NULL_BYTES, - owner, - to, - amount, - ); + await testContract + .testTransferFrom(false, encodeRevert(REVERT_STRING), constants.NULL_BYTES, owner, to, amount) + .awaitTransactionSuccessAsync(); }); it('fails if the target returns false', async () => { const owner = randomAddress(); const to = randomAddress(); const amount = getRandomInteger(0, 100e18); - const tx = testContract.testTransferFrom.awaitTransactionSuccessAsync( - false, - encodeRevert(REVERT_STRING), - ENCODED_FALSE, - owner, - to, - amount, - ); + const tx = testContract + .testTransferFrom(false, encodeRevert(REVERT_STRING), ENCODED_FALSE, owner, to, amount) + .awaitTransactionSuccessAsync(); const expectedError = new RawRevertError(ENCODED_FALSE); return expect(tx).to.revertWith(expectedError); }); @@ -342,14 +250,9 @@ blockchainTests('LibERC20Token', env => { const owner = randomAddress(); const to = randomAddress(); const amount = getRandomInteger(0, 100e18); - const tx = testContract.testTransferFrom.awaitTransactionSuccessAsync( - false, - encodeRevert(REVERT_STRING), - ENCODED_TWO, - owner, - to, - amount, - ); + const tx = testContract + .testTransferFrom(false, encodeRevert(REVERT_STRING), ENCODED_TWO, owner, to, amount) + .awaitTransactionSuccessAsync(); const expectedError = new RawRevertError(ENCODED_TWO); return expect(tx).to.revertWith(expectedError); }); @@ -358,14 +261,9 @@ blockchainTests('LibERC20Token', env => { const owner = randomAddress(); const to = randomAddress(); const amount = getRandomInteger(0, 100e18); - const tx = testContract.testTransferFrom.awaitTransactionSuccessAsync( - false, - encodeRevert(REVERT_STRING), - ENCODED_SHORT_TRUE, - owner, - to, - amount, - ); + const tx = testContract + .testTransferFrom(false, encodeRevert(REVERT_STRING), ENCODED_SHORT_TRUE, owner, to, amount) + .awaitTransactionSuccessAsync(); const expectedError = new RawRevertError(ENCODED_SHORT_TRUE); return expect(tx).to.revertWith(expectedError); }); @@ -374,14 +272,9 @@ blockchainTests('LibERC20Token', env => { const owner = randomAddress(); const to = randomAddress(); const amount = getRandomInteger(0, 100e18); - const tx = testContract.testTransferFrom.awaitTransactionSuccessAsync( - false, - encodeRevert(REVERT_STRING), - ENCODED_LONG_TRUE, - owner, - to, - amount, - ); + const tx = testContract + .testTransferFrom(false, encodeRevert(REVERT_STRING), ENCODED_LONG_TRUE, owner, to, amount) + .awaitTransactionSuccessAsync(); const expectedError = new RawRevertError(ENCODED_LONG_TRUE); return expect(tx).to.revertWith(expectedError); }); @@ -390,14 +283,9 @@ blockchainTests('LibERC20Token', env => { const owner = randomAddress(); const to = randomAddress(); const amount = getRandomInteger(0, 100e18); - const tx = testContract.testTransferFrom.awaitTransactionSuccessAsync( - true, - encodeRevert(REVERT_STRING), - ENCODED_TRUE, - owner, - to, - amount, - ); + const tx = testContract + .testTransferFrom(true, encodeRevert(REVERT_STRING), ENCODED_TRUE, owner, to, amount) + .awaitTransactionSuccessAsync(); return expect(tx).to.revertWith(REVERT_STRING); }); @@ -405,14 +293,9 @@ blockchainTests('LibERC20Token', env => { const owner = randomAddress(); const to = randomAddress(); const amount = getRandomInteger(0, 100e18); - const tx = testContract.testTransferFrom.awaitTransactionSuccessAsync( - true, - constants.NULL_BYTES, - ENCODED_TRUE, - owner, - to, - amount, - ); + const tx = testContract + .testTransferFrom(true, constants.NULL_BYTES, ENCODED_TRUE, owner, to, amount) + .awaitTransactionSuccessAsync(); return expect(tx).to.be.rejectedWith('revert'); }); }); diff --git a/contracts/erc20/test/unlimited_allowance_token.ts b/contracts/erc20/test/unlimited_allowance_token.ts index 9d9de2ab01..e0dbaa2433 100644 --- a/contracts/erc20/test/unlimited_allowance_token.ts +++ b/contracts/erc20/test/unlimited_allowance_token.ts @@ -44,7 +44,7 @@ describe('UnlimitedAllowanceToken', () => { constants.DUMMY_TOKEN_TOTAL_SUPPLY, ); await web3Wrapper.awaitTransactionSuccessAsync( - await token.mint.sendTransactionAsync(MAX_MINT_VALUE, { from: owner }), + await token.mint(MAX_MINT_VALUE).sendTransactionAsync({ from: owner }), constants.AWAIT_TRANSACTION_MINED_MS, ); }); @@ -56,24 +56,24 @@ describe('UnlimitedAllowanceToken', () => { }); describe('transfer', () => { it('should revert if owner has insufficient balance', async () => { - const ownerBalance = await token.balanceOf.callAsync(owner); + const ownerBalance = await token.balanceOf(owner).callAsync(); const amountToTransfer = ownerBalance.plus(1); return expectContractCallFailedAsync( - token.transfer.callAsync(spender, amountToTransfer, { from: owner }), + token.transfer(spender, amountToTransfer).callAsync({ from: owner }), RevertReason.Erc20InsufficientBalance, ); }); it('should transfer balance from sender to receiver', async () => { const receiver = spender; - const initOwnerBalance = await token.balanceOf.callAsync(owner); + const initOwnerBalance = await token.balanceOf(owner).callAsync(); const amountToTransfer = new BigNumber(1); await web3Wrapper.awaitTransactionSuccessAsync( - await token.transfer.sendTransactionAsync(receiver, amountToTransfer, { from: owner }), + await token.transfer(receiver, amountToTransfer).sendTransactionAsync({ from: owner }), constants.AWAIT_TRANSACTION_MINED_MS, ); - const finalOwnerBalance = await token.balanceOf.callAsync(owner); - const finalReceiverBalance = await token.balanceOf.callAsync(receiver); + const finalOwnerBalance = await token.balanceOf(owner).callAsync(); + const finalReceiverBalance = await token.balanceOf(receiver).callAsync(); const expectedFinalOwnerBalance = initOwnerBalance.minus(amountToTransfer); const expectedFinalReceiverBalance = amountToTransfer; @@ -82,7 +82,7 @@ describe('UnlimitedAllowanceToken', () => { }); it('should return true on a 0 value transfer', async () => { - const didReturnTrue = await token.transfer.callAsync(spender, new BigNumber(0), { + const didReturnTrue = await token.transfer(spender, new BigNumber(0)).callAsync({ from: owner, }); expect(didReturnTrue).to.be.true(); @@ -91,14 +91,14 @@ describe('UnlimitedAllowanceToken', () => { describe('transferFrom', () => { it('should revert if owner has insufficient balance', async () => { - const ownerBalance = await token.balanceOf.callAsync(owner); + const ownerBalance = await token.balanceOf(owner).callAsync(); const amountToTransfer = ownerBalance.plus(1); await web3Wrapper.awaitTransactionSuccessAsync( - await token.approve.sendTransactionAsync(spender, amountToTransfer, { from: owner }), + await token.approve(spender, amountToTransfer).sendTransactionAsync({ from: owner }), constants.AWAIT_TRANSACTION_MINED_MS, ); return expectContractCallFailedAsync( - token.transferFrom.callAsync(owner, spender, amountToTransfer, { + token.transferFrom(owner, spender, amountToTransfer).callAsync({ from: spender, }), RevertReason.Erc20InsufficientBalance, @@ -106,15 +106,15 @@ describe('UnlimitedAllowanceToken', () => { }); it('should revert if spender has insufficient allowance', async () => { - const ownerBalance = await token.balanceOf.callAsync(owner); + const ownerBalance = await token.balanceOf(owner).callAsync(); const amountToTransfer = ownerBalance; - const spenderAllowance = await token.allowance.callAsync(owner, spender); + const spenderAllowance = await token.allowance(owner, spender).callAsync(); const isSpenderAllowanceInsufficient = spenderAllowance.comparedTo(amountToTransfer) < 0; expect(isSpenderAllowanceInsufficient).to.be.true(); return expectContractCallFailedAsync( - token.transferFrom.callAsync(owner, spender, amountToTransfer, { + token.transferFrom(owner, spender, amountToTransfer).callAsync({ from: spender, }), RevertReason.Erc20InsufficientAllowance, @@ -123,72 +123,72 @@ describe('UnlimitedAllowanceToken', () => { it('should return true on a 0 value transfer', async () => { const amountToTransfer = new BigNumber(0); - const didReturnTrue = await token.transferFrom.callAsync(owner, spender, amountToTransfer, { + const didReturnTrue = await token.transferFrom(owner, spender, amountToTransfer).callAsync({ from: spender, }); expect(didReturnTrue).to.be.true(); }); it('should not modify spender allowance if spender allowance is 2^256 - 1', async () => { - const initOwnerBalance = await token.balanceOf.callAsync(owner); + const initOwnerBalance = await token.balanceOf(owner).callAsync(); const amountToTransfer = initOwnerBalance; const initSpenderAllowance = constants.UNLIMITED_ALLOWANCE_IN_BASE_UNITS; await web3Wrapper.awaitTransactionSuccessAsync( - await token.approve.sendTransactionAsync(spender, initSpenderAllowance, { from: owner }), + await token.approve(spender, initSpenderAllowance).sendTransactionAsync({ from: owner }), constants.AWAIT_TRANSACTION_MINED_MS, ); await web3Wrapper.awaitTransactionSuccessAsync( - await token.transferFrom.sendTransactionAsync(owner, spender, amountToTransfer, { + await token.transferFrom(owner, spender, amountToTransfer).sendTransactionAsync({ from: spender, gas: constants.MAX_TOKEN_TRANSFERFROM_GAS, }), constants.AWAIT_TRANSACTION_MINED_MS, ); - const newSpenderAllowance = await token.allowance.callAsync(owner, spender); + const newSpenderAllowance = await token.allowance(owner, spender).callAsync(); expect(initSpenderAllowance).to.be.bignumber.equal(newSpenderAllowance); }); it('should transfer the correct balances if spender has sufficient allowance', async () => { - const initOwnerBalance = await token.balanceOf.callAsync(owner); + const initOwnerBalance = await token.balanceOf(owner).callAsync(); const amountToTransfer = initOwnerBalance; const initSpenderAllowance = initOwnerBalance; await web3Wrapper.awaitTransactionSuccessAsync( - await token.approve.sendTransactionAsync(spender, initSpenderAllowance, { from: owner }), + await token.approve(spender, initSpenderAllowance).sendTransactionAsync({ from: owner }), constants.AWAIT_TRANSACTION_MINED_MS, ); await web3Wrapper.awaitTransactionSuccessAsync( - await token.transferFrom.sendTransactionAsync(owner, spender, amountToTransfer, { + await token.transferFrom(owner, spender, amountToTransfer).sendTransactionAsync({ from: spender, gas: constants.MAX_TOKEN_TRANSFERFROM_GAS, }), constants.AWAIT_TRANSACTION_MINED_MS, ); - const newOwnerBalance = await token.balanceOf.callAsync(owner); - const newSpenderBalance = await token.balanceOf.callAsync(spender); + const newOwnerBalance = await token.balanceOf(owner).callAsync(); + const newSpenderBalance = await token.balanceOf(spender).callAsync(); expect(newOwnerBalance).to.be.bignumber.equal(0); expect(newSpenderBalance).to.be.bignumber.equal(initOwnerBalance); }); it('should modify allowance if spender has sufficient allowance less than 2^256 - 1', async () => { - const initOwnerBalance = await token.balanceOf.callAsync(owner); + const initOwnerBalance = await token.balanceOf(owner).callAsync(); const amountToTransfer = initOwnerBalance; const initSpenderAllowance = initOwnerBalance; await web3Wrapper.awaitTransactionSuccessAsync( - await token.approve.sendTransactionAsync(spender, initSpenderAllowance, { from: owner }), + await token.approve(spender, initSpenderAllowance).sendTransactionAsync({ from: owner }), constants.AWAIT_TRANSACTION_MINED_MS, ); await web3Wrapper.awaitTransactionSuccessAsync( - await token.transferFrom.sendTransactionAsync(owner, spender, amountToTransfer, { + await token.transferFrom(owner, spender, amountToTransfer).sendTransactionAsync({ from: spender, gas: constants.MAX_TOKEN_TRANSFERFROM_GAS, }), constants.AWAIT_TRANSACTION_MINED_MS, ); - const newSpenderAllowance = await token.allowance.callAsync(owner, spender); + const newSpenderAllowance = await token.allowance(owner, spender).callAsync(); expect(newSpenderAllowance).to.be.bignumber.equal(0); }); }); diff --git a/contracts/erc20/test/weth9.ts b/contracts/erc20/test/weth9.ts index 602abd29f9..f0862bbf66 100644 --- a/contracts/erc20/test/weth9.ts +++ b/contracts/erc20/test/weth9.ts @@ -54,16 +54,16 @@ describe('EtherToken', () => { const initEthBalance = await web3Wrapper.getBalanceInWeiAsync(account); const ethToDeposit = initEthBalance.plus(1); - return expectInsufficientFundsAsync(etherToken.deposit.sendTransactionAsync({ value: ethToDeposit })); + return expectInsufficientFundsAsync(etherToken.deposit().sendTransactionAsync({ value: ethToDeposit })); }); it('should convert deposited Ether to wrapped Ether tokens', async () => { const initEthBalance = await web3Wrapper.getBalanceInWeiAsync(account); - const initEthTokenBalance = await etherToken.balanceOf.callAsync(account); + const initEthTokenBalance = await etherToken.balanceOf(account).callAsync(); const ethToDeposit = new BigNumber(Web3Wrapper.toWei(new BigNumber(1))); - const txHash = await etherToken.deposit.sendTransactionAsync({ value: ethToDeposit }); + const txHash = await etherToken.deposit().sendTransactionAsync({ value: ethToDeposit }); const receipt = await web3Wrapper.awaitTransactionSuccessAsync( txHash, constants.AWAIT_TRANSACTION_MINED_MS, @@ -71,7 +71,7 @@ describe('EtherToken', () => { const ethSpentOnGas = gasPrice.times(receipt.gasUsed); const finalEthBalance = await web3Wrapper.getBalanceInWeiAsync(account); - const finalEthTokenBalance = await etherToken.balanceOf.callAsync(account); + const finalEthTokenBalance = await etherToken.balanceOf(account).callAsync(); expect(finalEthBalance).to.be.bignumber.equal(initEthBalance.minus(ethToDeposit.plus(ethSpentOnGas))); expect(finalEthTokenBalance).to.be.bignumber.equal(initEthTokenBalance.plus(ethToDeposit)); @@ -80,25 +80,25 @@ describe('EtherToken', () => { describe('withdraw', () => { it('should revert if caller attempts to withdraw greater than caller balance', async () => { - const initEthTokenBalance = await etherToken.balanceOf.callAsync(account); + const initEthTokenBalance = await etherToken.balanceOf(account).callAsync(); const ethTokensToWithdraw = initEthTokenBalance.plus(1); return expectTransactionFailedWithoutReasonAsync( - etherToken.withdraw.sendTransactionAsync(ethTokensToWithdraw), + etherToken.withdraw(ethTokensToWithdraw).sendTransactionAsync(), ); }); it('should convert ether tokens to ether with sufficient balance', async () => { const ethToDeposit = new BigNumber(Web3Wrapper.toWei(new BigNumber(1))); await web3Wrapper.awaitTransactionSuccessAsync( - await etherToken.deposit.sendTransactionAsync({ value: ethToDeposit }), + await etherToken.deposit().sendTransactionAsync({ value: ethToDeposit }), constants.AWAIT_TRANSACTION_MINED_MS, ); - const initEthTokenBalance = await etherToken.balanceOf.callAsync(account); + const initEthTokenBalance = await etherToken.balanceOf(account).callAsync(); const initEthBalance = await web3Wrapper.getBalanceInWeiAsync(account); const ethTokensToWithdraw = initEthTokenBalance; expect(ethTokensToWithdraw).to.not.be.bignumber.equal(0); - const txHash = await etherToken.withdraw.sendTransactionAsync(ethTokensToWithdraw, { + const txHash = await etherToken.withdraw(ethTokensToWithdraw).sendTransactionAsync({ gas: constants.MAX_ETHERTOKEN_WITHDRAW_GAS, }); const receipt = await web3Wrapper.awaitTransactionSuccessAsync( @@ -108,7 +108,7 @@ describe('EtherToken', () => { const ethSpentOnGas = gasPrice.times(receipt.gasUsed); const finalEthBalance = await web3Wrapper.getBalanceInWeiAsync(account); - const finalEthTokenBalance = await etherToken.balanceOf.callAsync(account); + const finalEthTokenBalance = await etherToken.balanceOf(account).callAsync(); expect(finalEthBalance).to.be.bignumber.equal( initEthBalance.plus(ethTokensToWithdraw.minus(ethSpentOnGas)), @@ -120,7 +120,7 @@ describe('EtherToken', () => { describe('fallback', () => { it('should convert sent ether to ether tokens', async () => { const initEthBalance = await web3Wrapper.getBalanceInWeiAsync(account); - const initEthTokenBalance = await etherToken.balanceOf.callAsync(account); + const initEthTokenBalance = await etherToken.balanceOf(account).callAsync(); const ethToDeposit = Web3Wrapper.toBaseUnitAmount(new BigNumber(1), 18); @@ -138,7 +138,7 @@ describe('EtherToken', () => { const ethSpentOnGas = gasPrice.times(receipt.gasUsed); const finalEthBalance = await web3Wrapper.getBalanceInWeiAsync(account); - const finalEthTokenBalance = await etherToken.balanceOf.callAsync(account); + const finalEthTokenBalance = await etherToken.balanceOf(account).callAsync(); expect(finalEthBalance).to.be.bignumber.equal(initEthBalance.minus(ethToDeposit.plus(ethSpentOnGas))); expect(finalEthTokenBalance).to.be.bignumber.equal(initEthTokenBalance.plus(ethToDeposit)); diff --git a/contracts/erc20/test/zrx_token.ts b/contracts/erc20/test/zrx_token.ts index a148fc0d85..b0ee2d7d47 100644 --- a/contracts/erc20/test/zrx_token.ts +++ b/contracts/erc20/test/zrx_token.ts @@ -42,25 +42,25 @@ describe('ZRXToken', () => { }); describe('constants', () => { it('should have 18 decimals', async () => { - const decimals = new BigNumber(await zrxToken.decimals.callAsync()); + const decimals = new BigNumber(await zrxToken.decimals().callAsync()); const expectedDecimals = 18; expect(decimals).to.be.bignumber.equal(expectedDecimals); }); it('should have a total supply of 1 billion tokens', async () => { - const totalSupply = new BigNumber(await zrxToken.totalSupply.callAsync()); + const totalSupply = new BigNumber(await zrxToken.totalSupply().callAsync()); const expectedTotalSupply = 1000000000; expect(Web3Wrapper.toUnitAmount(totalSupply, 18)).to.be.bignumber.equal(expectedTotalSupply); }); it('should be named 0x Protocol Token', async () => { - const name = await zrxToken.name.callAsync(); + const name = await zrxToken.name().callAsync(); const expectedName = '0x Protocol Token'; expect(name).to.be.equal(expectedName); }); it('should have the symbol ZRX', async () => { - const symbol = await zrxToken.symbol.callAsync(); + const symbol = await zrxToken.symbol().callAsync(); const expectedSymbol = 'ZRX'; expect(symbol).to.be.equal(expectedSymbol); }); @@ -68,8 +68,8 @@ describe('ZRXToken', () => { describe('constructor', () => { it('should initialize owner balance to totalSupply', async () => { - const ownerBalance = await zrxToken.balanceOf.callAsync(owner); - const totalSupply = new BigNumber(await zrxToken.totalSupply.callAsync()); + const ownerBalance = await zrxToken.balanceOf(owner).callAsync(); + const totalSupply = new BigNumber(await zrxToken.totalSupply().callAsync()); expect(totalSupply).to.be.bignumber.equal(ownerBalance); }); }); @@ -77,14 +77,14 @@ describe('ZRXToken', () => { describe('transfer', () => { it('should transfer balance from sender to receiver', async () => { const receiver = spender; - const initOwnerBalance = await zrxToken.balanceOf.callAsync(owner); + const initOwnerBalance = await zrxToken.balanceOf(owner).callAsync(); const amountToTransfer = new BigNumber(1); await web3Wrapper.awaitTransactionSuccessAsync( - await zrxToken.transfer.sendTransactionAsync(receiver, amountToTransfer, { from: owner }), + await zrxToken.transfer(receiver, amountToTransfer).sendTransactionAsync({ from: owner }), constants.AWAIT_TRANSACTION_MINED_MS, ); - const finalOwnerBalance = await zrxToken.balanceOf.callAsync(owner); - const finalReceiverBalance = await zrxToken.balanceOf.callAsync(receiver); + const finalOwnerBalance = await zrxToken.balanceOf(owner).callAsync(); + const finalReceiverBalance = await zrxToken.balanceOf(receiver).callAsync(); const expectedFinalOwnerBalance = initOwnerBalance.minus(amountToTransfer); const expectedFinalReceiverBalance = amountToTransfer; @@ -93,7 +93,7 @@ describe('ZRXToken', () => { }); it('should return true on a 0 value transfer', async () => { - const didReturnTrue = await zrxToken.transfer.callAsync(spender, new BigNumber(0), { + const didReturnTrue = await zrxToken.transfer(spender, new BigNumber(0)).callAsync({ from: owner, }); expect(didReturnTrue).to.be.true(); @@ -102,30 +102,30 @@ describe('ZRXToken', () => { describe('transferFrom', () => { it('should return false if owner has insufficient balance', async () => { - const ownerBalance = await zrxToken.balanceOf.callAsync(owner); + const ownerBalance = await zrxToken.balanceOf(owner).callAsync(); const amountToTransfer = ownerBalance.plus(1); await web3Wrapper.awaitTransactionSuccessAsync( - await zrxToken.approve.sendTransactionAsync(spender, amountToTransfer, { + await zrxToken.approve(spender, amountToTransfer).sendTransactionAsync({ from: owner, gas: constants.MAX_TOKEN_APPROVE_GAS, }), constants.AWAIT_TRANSACTION_MINED_MS, ); - const didReturnTrue = await zrxToken.transferFrom.callAsync(owner, spender, amountToTransfer, { + const didReturnTrue = await zrxToken.transferFrom(owner, spender, amountToTransfer).callAsync({ from: spender, }); expect(didReturnTrue).to.be.false(); }); it('should return false if spender has insufficient allowance', async () => { - const ownerBalance = await zrxToken.balanceOf.callAsync(owner); + const ownerBalance = await zrxToken.balanceOf(owner).callAsync(); const amountToTransfer = ownerBalance; - const spenderAllowance = await zrxToken.allowance.callAsync(owner, spender); + const spenderAllowance = await zrxToken.allowance(owner, spender).callAsync(); const isSpenderAllowanceInsufficient = spenderAllowance.comparedTo(amountToTransfer) < 0; expect(isSpenderAllowanceInsufficient).to.be.true(); - const didReturnTrue = await zrxToken.transferFrom.callAsync(owner, spender, amountToTransfer, { + const didReturnTrue = await zrxToken.transferFrom(owner, spender, amountToTransfer).callAsync({ from: spender, }); expect(didReturnTrue).to.be.false(); @@ -133,75 +133,75 @@ describe('ZRXToken', () => { it('should return true on a 0 value transfer', async () => { const amountToTransfer = new BigNumber(0); - const didReturnTrue = await zrxToken.transferFrom.callAsync(owner, spender, amountToTransfer, { + const didReturnTrue = await zrxToken.transferFrom(owner, spender, amountToTransfer).callAsync({ from: spender, }); expect(didReturnTrue).to.be.true(); }); it('should not modify spender allowance if spender allowance is 2^256 - 1', async () => { - const initOwnerBalance = await zrxToken.balanceOf.callAsync(owner); + const initOwnerBalance = await zrxToken.balanceOf(owner).callAsync(); const amountToTransfer = initOwnerBalance; const initSpenderAllowance = MAX_UINT; await web3Wrapper.awaitTransactionSuccessAsync( - await zrxToken.approve.sendTransactionAsync(spender, initSpenderAllowance, { + await zrxToken.approve(spender, initSpenderAllowance).sendTransactionAsync({ from: owner, gas: constants.MAX_TOKEN_APPROVE_GAS, }), constants.AWAIT_TRANSACTION_MINED_MS, ); await web3Wrapper.awaitTransactionSuccessAsync( - await zrxToken.transferFrom.sendTransactionAsync(owner, spender, amountToTransfer, { + await zrxToken.transferFrom(owner, spender, amountToTransfer).sendTransactionAsync({ from: spender, gas: constants.MAX_TOKEN_TRANSFERFROM_GAS, }), constants.AWAIT_TRANSACTION_MINED_MS, ); - const newSpenderAllowance = await zrxToken.allowance.callAsync(owner, spender); + const newSpenderAllowance = await zrxToken.allowance(owner, spender).callAsync(); expect(initSpenderAllowance).to.be.bignumber.equal(newSpenderAllowance); }); it('should transfer the correct balances if spender has sufficient allowance', async () => { - const initOwnerBalance = await zrxToken.balanceOf.callAsync(owner); - const initSpenderBalance = await zrxToken.balanceOf.callAsync(spender); + const initOwnerBalance = await zrxToken.balanceOf(owner).callAsync(); + const initSpenderBalance = await zrxToken.balanceOf(spender).callAsync(); const amountToTransfer = initOwnerBalance; const initSpenderAllowance = initOwnerBalance; await web3Wrapper.awaitTransactionSuccessAsync( - await zrxToken.approve.sendTransactionAsync(spender, initSpenderAllowance), + await zrxToken.approve(spender, initSpenderAllowance).sendTransactionAsync(), constants.AWAIT_TRANSACTION_MINED_MS, ); await web3Wrapper.awaitTransactionSuccessAsync( - await zrxToken.transferFrom.sendTransactionAsync(owner, spender, amountToTransfer, { + await zrxToken.transferFrom(owner, spender, amountToTransfer).sendTransactionAsync({ from: spender, gas: constants.MAX_TOKEN_TRANSFERFROM_GAS, }), constants.AWAIT_TRANSACTION_MINED_MS, ); - const newOwnerBalance = await zrxToken.balanceOf.callAsync(owner); - const newSpenderBalance = await zrxToken.balanceOf.callAsync(spender); + const newOwnerBalance = await zrxToken.balanceOf(owner).callAsync(); + const newSpenderBalance = await zrxToken.balanceOf(spender).callAsync(); expect(newOwnerBalance).to.be.bignumber.equal(0); expect(newSpenderBalance).to.be.bignumber.equal(initSpenderBalance.plus(initOwnerBalance)); }); it('should modify allowance if spender has sufficient allowance less than 2^256 - 1', async () => { - const initOwnerBalance = await zrxToken.balanceOf.callAsync(owner); + const initOwnerBalance = await zrxToken.balanceOf(owner).callAsync(); const amountToTransfer = initOwnerBalance; await web3Wrapper.awaitTransactionSuccessAsync( - await zrxToken.approve.sendTransactionAsync(spender, amountToTransfer), + await zrxToken.approve(spender, amountToTransfer).sendTransactionAsync(), constants.AWAIT_TRANSACTION_MINED_MS, ); await web3Wrapper.awaitTransactionSuccessAsync( - await zrxToken.transferFrom.sendTransactionAsync(owner, spender, amountToTransfer, { + await zrxToken.transferFrom(owner, spender, amountToTransfer).sendTransactionAsync({ from: spender, gas: constants.MAX_TOKEN_TRANSFERFROM_GAS, }), constants.AWAIT_TRANSACTION_MINED_MS, ); - const newSpenderAllowance = await zrxToken.allowance.callAsync(owner, spender); + const newSpenderAllowance = await zrxToken.allowance(owner, spender).callAsync(); expect(newSpenderAllowance).to.be.bignumber.equal(0); }); }); diff --git a/contracts/erc721/test/erc721_token.ts b/contracts/erc721/test/erc721_token.ts index b3c0ba4141..560d9a0b90 100644 --- a/contracts/erc721/test/erc721_token.ts +++ b/contracts/erc721/test/erc721_token.ts @@ -60,7 +60,7 @@ describe('ERC721Token', () => { ); logDecoder = new LogDecoder(web3Wrapper, artifacts); await web3Wrapper.awaitTransactionSuccessAsync( - await token.mint.sendTransactionAsync(owner, tokenId, { from: owner }), + await token.mint(owner, tokenId).sendTransactionAsync({ from: owner }), constants.AWAIT_TRANSACTION_MINED_MS, ); }); @@ -77,7 +77,7 @@ describe('ERC721Token', () => { const to = erc721Receiver.address; const unownedTokenId = new BigNumber(2); await expectTransactionFailedAsync( - token.transferFrom.sendTransactionAsync(from, to, unownedTokenId), + token.transferFrom(from, to, unownedTokenId).sendTransactionAsync(), RevertReason.Erc721ZeroOwner, ); }); @@ -85,7 +85,7 @@ describe('ERC721Token', () => { const from = owner; const to = constants.NULL_ADDRESS; await expectTransactionFailedAsync( - token.transferFrom.sendTransactionAsync(from, to, tokenId), + token.transferFrom(from, to, tokenId).sendTransactionAsync(), RevertReason.Erc721ZeroToAddress, ); }); @@ -93,7 +93,7 @@ describe('ERC721Token', () => { const from = spender; const to = erc721Receiver.address; await expectTransactionFailedAsync( - token.transferFrom.sendTransactionAsync(from, to, tokenId), + token.transferFrom(from, to, tokenId).sendTransactionAsync(), RevertReason.Erc721OwnerMismatch, ); }); @@ -101,7 +101,7 @@ describe('ERC721Token', () => { const from = owner; const to = erc721Receiver.address; await expectTransactionFailedAsync( - token.transferFrom.sendTransactionAsync(from, to, tokenId, { from: spender }), + token.transferFrom(from, to, tokenId).sendTransactionAsync({ from: spender }), RevertReason.Erc721InvalidSpender, ); }); @@ -109,9 +109,9 @@ describe('ERC721Token', () => { const from = owner; const to = erc721Receiver.address; const txReceipt = await logDecoder.getTxWithDecodedLogsAsync( - await token.transferFrom.sendTransactionAsync(from, to, tokenId), + await token.transferFrom(from, to, tokenId).sendTransactionAsync(), ); - const newOwner = await token.ownerOf.callAsync(tokenId); + const newOwner = await token.ownerOf(tokenId).callAsync(); expect(newOwner).to.be.equal(to); const log = txReceipt.logs[0] as LogWithDecodedArgs; expect(log.args._from).to.be.equal(from); @@ -121,16 +121,16 @@ describe('ERC721Token', () => { it('should transfer the token if spender is approved for all', async () => { const isApproved = true; await web3Wrapper.awaitTransactionSuccessAsync( - await token.setApprovalForAll.sendTransactionAsync(spender, isApproved), + await token.setApprovalForAll(spender, isApproved).sendTransactionAsync(), constants.AWAIT_TRANSACTION_MINED_MS, ); const from = owner; const to = erc721Receiver.address; const txReceipt = await logDecoder.getTxWithDecodedLogsAsync( - await token.transferFrom.sendTransactionAsync(from, to, tokenId), + await token.transferFrom(from, to, tokenId).sendTransactionAsync(), ); - const newOwner = await token.ownerOf.callAsync(tokenId); + const newOwner = await token.ownerOf(tokenId).callAsync(); expect(newOwner).to.be.equal(to); const log = txReceipt.logs[0] as LogWithDecodedArgs; expect(log.args._from).to.be.equal(from); @@ -139,19 +139,19 @@ describe('ERC721Token', () => { }); it('should transfer the token if spender is individually approved', async () => { await web3Wrapper.awaitTransactionSuccessAsync( - await token.approve.sendTransactionAsync(spender, tokenId), + await token.approve(spender, tokenId).sendTransactionAsync(), constants.AWAIT_TRANSACTION_MINED_MS, ); const from = owner; const to = erc721Receiver.address; const txReceipt = await logDecoder.getTxWithDecodedLogsAsync( - await token.transferFrom.sendTransactionAsync(from, to, tokenId), + await token.transferFrom(from, to, tokenId).sendTransactionAsync(), ); - const newOwner = await token.ownerOf.callAsync(tokenId); + const newOwner = await token.ownerOf(tokenId).callAsync(); expect(newOwner).to.be.equal(to); - const approvedAddress = await token.getApproved.callAsync(tokenId); + const approvedAddress = await token.getApproved(tokenId).callAsync(); expect(approvedAddress).to.be.equal(constants.NULL_ADDRESS); const log = txReceipt.logs[0] as LogWithDecodedArgs; expect(log.args._from).to.be.equal(from); @@ -164,9 +164,9 @@ describe('ERC721Token', () => { const from = owner; const to = spender; const txReceipt = await logDecoder.getTxWithDecodedLogsAsync( - await token.safeTransferFrom1.sendTransactionAsync(from, to, tokenId), + await token.safeTransferFrom1(from, to, tokenId).sendTransactionAsync(), ); - const newOwner = await token.ownerOf.callAsync(tokenId); + const newOwner = await token.ownerOf(tokenId).callAsync(); expect(newOwner).to.be.equal(to); const log = txReceipt.logs[0] as LogWithDecodedArgs; expect(log.args._from).to.be.equal(from); @@ -185,7 +185,7 @@ describe('ERC721Token', () => { const from = owner; const to = contract.address; await expectTransactionFailedWithoutReasonAsync( - token.safeTransferFrom1.sendTransactionAsync(from, to, tokenId), + token.safeTransferFrom1(from, to, tokenId).sendTransactionAsync(), ); }); it('should revert if onERC721Received does not return the correct value', async () => { @@ -198,7 +198,7 @@ describe('ERC721Token', () => { const from = owner; const to = invalidErc721Receiver.address; await expectTransactionFailedAsync( - token.safeTransferFrom1.sendTransactionAsync(from, to, tokenId), + token.safeTransferFrom1(from, to, tokenId).sendTransactionAsync(), RevertReason.Erc721InvalidSelector, ); }); @@ -206,9 +206,9 @@ describe('ERC721Token', () => { const from = owner; const to = erc721Receiver.address; const txReceipt = await logDecoder.getTxWithDecodedLogsAsync( - await token.safeTransferFrom1.sendTransactionAsync(from, to, tokenId), + await token.safeTransferFrom1(from, to, tokenId).sendTransactionAsync(), ); - const newOwner = await token.ownerOf.callAsync(tokenId); + const newOwner = await token.ownerOf(tokenId).callAsync(); expect(newOwner).to.be.equal(to); const transferLog = txReceipt.logs[0] as LogWithDecodedArgs; const receiverLog = txReceipt.logs[1] as LogWithDecodedArgs; @@ -227,9 +227,9 @@ describe('ERC721Token', () => { const from = owner; const to = spender; const txReceipt = await logDecoder.getTxWithDecodedLogsAsync( - await token.safeTransferFrom2.sendTransactionAsync(from, to, tokenId, data), + await token.safeTransferFrom2(from, to, tokenId, data).sendTransactionAsync(), ); - const newOwner = await token.ownerOf.callAsync(tokenId); + const newOwner = await token.ownerOf(tokenId).callAsync(); expect(newOwner).to.be.equal(to); const log = txReceipt.logs[0] as LogWithDecodedArgs; expect(log.args._from).to.be.equal(from); @@ -248,7 +248,7 @@ describe('ERC721Token', () => { const from = owner; const to = contract.address; await expectTransactionFailedWithoutReasonAsync( - token.safeTransferFrom2.sendTransactionAsync(from, to, tokenId, data), + token.safeTransferFrom2(from, to, tokenId, data).sendTransactionAsync(), ); }); it('should revert if onERC721Received does not return the correct value', async () => { @@ -261,7 +261,7 @@ describe('ERC721Token', () => { const from = owner; const to = invalidErc721Receiver.address; await expectTransactionFailedAsync( - token.safeTransferFrom2.sendTransactionAsync(from, to, tokenId, data), + token.safeTransferFrom2(from, to, tokenId, data).sendTransactionAsync(), RevertReason.Erc721InvalidSelector, ); }); @@ -269,9 +269,9 @@ describe('ERC721Token', () => { const from = owner; const to = erc721Receiver.address; const txReceipt = await logDecoder.getTxWithDecodedLogsAsync( - await token.safeTransferFrom2.sendTransactionAsync(from, to, tokenId, data), + await token.safeTransferFrom2(from, to, tokenId, data).sendTransactionAsync(), ); - const newOwner = await token.ownerOf.callAsync(tokenId); + const newOwner = await token.ownerOf(tokenId).callAsync(); expect(newOwner).to.be.equal(to); const transferLog = txReceipt.logs[0] as LogWithDecodedArgs; const receiverLog = txReceipt.logs[1] as LogWithDecodedArgs; diff --git a/contracts/exchange-libs/test/lib_eip712_exchange_domain.ts b/contracts/exchange-libs/test/lib_eip712_exchange_domain.ts index e608726e47..652a2e8766 100644 --- a/contracts/exchange-libs/test/lib_eip712_exchange_domain.ts +++ b/contracts/exchange-libs/test/lib_eip712_exchange_domain.ts @@ -23,7 +23,7 @@ blockchainTests('LibEIP712ExchangeDomain', env => { version: constants.EIP712_DOMAIN_VERSION, }; const expectedDomainHash = ethUtil.bufferToHex(signTypedDataUtils.generateDomainHash(domain)); - const actualDomainHash = await libEIP712ExchangeDomainContract.EIP712_EXCHANGE_DOMAIN_HASH.callAsync(); + const actualDomainHash = await libEIP712ExchangeDomainContract.EIP712_EXCHANGE_DOMAIN_HASH().callAsync(); expect(actualDomainHash).to.be.equal(expectedDomainHash); }); it('should calculate the correct domain hash when verifyingContractAddressIfExists is set to a non-null address', async () => { @@ -44,7 +44,7 @@ blockchainTests('LibEIP712ExchangeDomain', env => { version: constants.EIP712_DOMAIN_VERSION, }; const expectedDomainHash = ethUtil.bufferToHex(signTypedDataUtils.generateDomainHash(domain)); - const actualDomainHash = await libEIP712ExchangeDomainContract.EIP712_EXCHANGE_DOMAIN_HASH.callAsync(); + const actualDomainHash = await libEIP712ExchangeDomainContract.EIP712_EXCHANGE_DOMAIN_HASH().callAsync(); expect(actualDomainHash).to.be.equal(expectedDomainHash); }); }); diff --git a/contracts/exchange-libs/test/lib_fill_results.ts b/contracts/exchange-libs/test/lib_fill_results.ts index c62ee15803..b92ade1c60 100644 --- a/contracts/exchange-libs/test/lib_fill_results.ts +++ b/contracts/exchange-libs/test/lib_fill_results.ts @@ -106,12 +106,14 @@ blockchainTests('LibFillResults', env => { otherAmount: BigNumber, ): Promise { const order = makeOrder(otherAmount, orderTakerAssetAmount, otherAmount, otherAmount); - return libsContract.calculateFillResults.callAsync( - order, - takerAssetFilledAmount, - takerAssetFilledAmount, // Using this so that the gas price is distinct from protocolFeeMultiplier - otherAmount, - ); + return libsContract + .calculateFillResults( + order, + takerAssetFilledAmount, + takerAssetFilledAmount, // Using this so that the gas price is distinct from protocolFeeMultiplier + otherAmount, + ) + .callAsync(); } testCombinatoriallyWithReferenceFunc( @@ -145,12 +147,14 @@ blockchainTests('LibFillResults', env => { DEFAULT_PROTOCOL_FEE_MULTIPLIER, DEFAULT_GAS_PRICE, ); - const actual = await libsContract.calculateFillResults.callAsync( - order, - takerAssetFilledAmount, - DEFAULT_PROTOCOL_FEE_MULTIPLIER, - DEFAULT_GAS_PRICE, - ); + const actual = await libsContract + .calculateFillResults( + order, + takerAssetFilledAmount, + DEFAULT_PROTOCOL_FEE_MULTIPLIER, + DEFAULT_GAS_PRICE, + ) + .callAsync(); expect(actual).to.deep.eq(expected); }); @@ -167,12 +171,14 @@ blockchainTests('LibFillResults', env => { order.makerAssetAmount, ); return expect( - libsContract.calculateFillResults.callAsync( - order, - takerAssetFilledAmount, - DEFAULT_PROTOCOL_FEE_MULTIPLIER, - DEFAULT_GAS_PRICE, - ), + libsContract + .calculateFillResults( + order, + takerAssetFilledAmount, + DEFAULT_PROTOCOL_FEE_MULTIPLIER, + DEFAULT_GAS_PRICE, + ) + .callAsync(), ).to.revertWith(expectedError); }); @@ -195,12 +201,14 @@ blockchainTests('LibFillResults', env => { order.makerFee, ); return expect( - libsContract.calculateFillResults.callAsync( - order, - takerAssetFilledAmount, - DEFAULT_PROTOCOL_FEE_MULTIPLIER, - DEFAULT_GAS_PRICE, - ), + libsContract + .calculateFillResults( + order, + takerAssetFilledAmount, + DEFAULT_PROTOCOL_FEE_MULTIPLIER, + DEFAULT_GAS_PRICE, + ) + .callAsync(), ).to.revertWith(expectedError); }); @@ -218,12 +226,14 @@ blockchainTests('LibFillResults', env => { order.takerFee, ); return expect( - libsContract.calculateFillResults.callAsync( - order, - takerAssetFilledAmount, - DEFAULT_PROTOCOL_FEE_MULTIPLIER, - DEFAULT_GAS_PRICE, - ), + libsContract + .calculateFillResults( + order, + takerAssetFilledAmount, + DEFAULT_PROTOCOL_FEE_MULTIPLIER, + DEFAULT_GAS_PRICE, + ) + .callAsync(), ).to.revertWith(expectedError); }); @@ -235,12 +245,14 @@ blockchainTests('LibFillResults', env => { const takerAssetFilledAmount = ONE_ETHER; const expectedError = new LibMathRevertErrors.DivisionByZeroError(); return expect( - libsContract.calculateFillResults.callAsync( - order, - takerAssetFilledAmount, - DEFAULT_PROTOCOL_FEE_MULTIPLIER, - DEFAULT_GAS_PRICE, - ), + libsContract + .calculateFillResults( + order, + takerAssetFilledAmount, + DEFAULT_PROTOCOL_FEE_MULTIPLIER, + DEFAULT_GAS_PRICE, + ) + .callAsync(), ).to.revertWith(expectedError); }); @@ -256,12 +268,14 @@ blockchainTests('LibFillResults', env => { order.makerAssetAmount, ); return expect( - libsContract.calculateFillResults.callAsync( - order, - takerAssetFilledAmount, - DEFAULT_PROTOCOL_FEE_MULTIPLIER, - DEFAULT_GAS_PRICE, - ), + libsContract + .calculateFillResults( + order, + takerAssetFilledAmount, + DEFAULT_PROTOCOL_FEE_MULTIPLIER, + DEFAULT_GAS_PRICE, + ) + .callAsync(), ).to.revertWith(expectedError); }); @@ -283,12 +297,14 @@ blockchainTests('LibFillResults', env => { order.makerFee, ); return expect( - libsContract.calculateFillResults.callAsync( - order, - takerAssetFilledAmount, - DEFAULT_PROTOCOL_FEE_MULTIPLIER, - DEFAULT_GAS_PRICE, - ), + libsContract + .calculateFillResults( + order, + takerAssetFilledAmount, + DEFAULT_PROTOCOL_FEE_MULTIPLIER, + DEFAULT_GAS_PRICE, + ) + .callAsync(), ).to.revertWith(expectedError); }); @@ -310,12 +326,14 @@ blockchainTests('LibFillResults', env => { order.takerFee, ); return expect( - libsContract.calculateFillResults.callAsync( - order, - takerAssetFilledAmount, - DEFAULT_PROTOCOL_FEE_MULTIPLIER, - DEFAULT_GAS_PRICE, - ), + libsContract + .calculateFillResults( + order, + takerAssetFilledAmount, + DEFAULT_PROTOCOL_FEE_MULTIPLIER, + DEFAULT_GAS_PRICE, + ) + .callAsync(), ).to.revertWith(expectedError); }); @@ -333,12 +351,9 @@ blockchainTests('LibFillResults', env => { MAX_UINT256, ); return expect( - libsContract.calculateFillResults.callAsync( - order, - takerAssetFilledAmount, - MAX_UINT256, - DEFAULT_GAS_PRICE, - ), + libsContract + .calculateFillResults(order, takerAssetFilledAmount, MAX_UINT256, DEFAULT_GAS_PRICE) + .callAsync(), ).to.revertWith(expectedError); }); @@ -360,12 +375,14 @@ blockchainTests('LibFillResults', env => { order.makerFee, ); return expect( - libsContract.calculateFillResults.callAsync( - order, - takerAssetFilledAmount, - DEFAULT_PROTOCOL_FEE_MULTIPLIER, - DEFAULT_GAS_PRICE, - ), + libsContract + .calculateFillResults( + order, + takerAssetFilledAmount, + DEFAULT_PROTOCOL_FEE_MULTIPLIER, + DEFAULT_GAS_PRICE, + ) + .callAsync(), ).to.revertWith(expectedError); }); }); @@ -393,7 +410,7 @@ blockchainTests('LibFillResults', env => { it('matches the output of the reference function', async () => { const [a, b] = DEFAULT_FILL_RESULTS; const expected = ReferenceFunctions.addFillResults(a, b); - const actual = await libsContract.addFillResults.callAsync(a, b); + const actual = await libsContract.addFillResults(a, b).callAsync(); expect(actual).to.deep.equal(expected); }); @@ -405,7 +422,7 @@ blockchainTests('LibFillResults', env => { a.makerAssetFilledAmount, b.makerAssetFilledAmount, ); - return expect(libsContract.addFillResults.callAsync(a, b)).to.revertWith(expectedError); + return expect(libsContract.addFillResults(a, b).callAsync()).to.revertWith(expectedError); }); it('reverts if computing `takerAssetFilledAmount` overflows', async () => { @@ -416,7 +433,7 @@ blockchainTests('LibFillResults', env => { a.takerAssetFilledAmount, b.takerAssetFilledAmount, ); - return expect(libsContract.addFillResults.callAsync(a, b)).to.revertWith(expectedError); + return expect(libsContract.addFillResults(a, b).callAsync()).to.revertWith(expectedError); }); it('reverts if computing `makerFeePaid` overflows', async () => { @@ -427,7 +444,7 @@ blockchainTests('LibFillResults', env => { a.makerFeePaid, b.makerFeePaid, ); - return expect(libsContract.addFillResults.callAsync(a, b)).to.revertWith(expectedError); + return expect(libsContract.addFillResults(a, b).callAsync()).to.revertWith(expectedError); }); it('reverts if computing `takerFeePaid` overflows', async () => { @@ -438,7 +455,7 @@ blockchainTests('LibFillResults', env => { a.takerFeePaid, b.takerFeePaid, ); - return expect(libsContract.addFillResults.callAsync(a, b)).to.revertWith(expectedError); + return expect(libsContract.addFillResults(a, b).callAsync()).to.revertWith(expectedError); }); it('reverts if computing `protocolFeePaid` overflows', async () => { @@ -449,7 +466,7 @@ blockchainTests('LibFillResults', env => { a.protocolFeePaid, b.protocolFeePaid, ); - return expect(libsContract.addFillResults.callAsync(a, b)).to.revertWith(expectedError); + return expect(libsContract.addFillResults(a, b).callAsync()).to.revertWith(expectedError); }); }); }); @@ -513,16 +530,17 @@ blockchainTests('LibFillResults', env => { gasPrice: BigNumber, from?: string, ): Promise { - const actualMatchedFillResults = await libsContract.calculateMatchedFillResults.callAsync( - leftOrder, - rightOrder, - leftOrderTakerAssetFilledAmount, - rightOrderTakerAssetFilledAmount, - protocolFeeMultiplier, - gasPrice, - false, - { from }, - ); + const actualMatchedFillResults = await libsContract + .calculateMatchedFillResults( + leftOrder, + rightOrder, + leftOrderTakerAssetFilledAmount, + rightOrderTakerAssetFilledAmount, + protocolFeeMultiplier, + gasPrice, + false, + ) + .callAsync({ from }); expect(actualMatchedFillResults).to.be.deep.eq(expectedMatchedFillResults); } @@ -1184,16 +1202,17 @@ blockchainTests('LibFillResults', env => { gasPrice: BigNumber, from?: string, ): Promise { - const actualMatchedFillResults = await libsContract.calculateMatchedFillResults.callAsync( - leftOrder, - rightOrder, - leftOrderTakerAssetFilledAmount, - rightOrderTakerAssetFilledAmount, - protocolFeeMultiplier, - gasPrice, - true, - { from }, - ); + const actualMatchedFillResults = await libsContract + .calculateMatchedFillResults( + leftOrder, + rightOrder, + leftOrderTakerAssetFilledAmount, + rightOrderTakerAssetFilledAmount, + protocolFeeMultiplier, + gasPrice, + true, + ) + .callAsync({ from }); expect(actualMatchedFillResults).to.be.deep.eq(expectedMatchedFillResults); } diff --git a/contracts/exchange-libs/test/lib_math.ts b/contracts/exchange-libs/test/lib_math.ts index 5e9b89023e..409517bae9 100644 --- a/contracts/exchange-libs/test/lib_math.ts +++ b/contracts/exchange-libs/test/lib_math.ts @@ -33,8 +33,7 @@ blockchainTests('LibMath', env => { function createContractTestFunction(name: string): (...args: any[]) => Promise { return async (...args: any[]): Promise => { - const method = (libsContract as any)[name] as { callAsync: (...args: any[]) => Promise }; - return method.callAsync(...args); + return (libsContract as any)[name](...args).callAsync; }; } @@ -54,7 +53,7 @@ blockchainTests('LibMath', env => { const denominator = ONE_ETHER.dividedToIntegerBy(2); const target = ONE_ETHER.times(0.01); const expected = ReferenceFunctions.getPartialAmountFloor(numerator, denominator, target); - const actual = await libsContract.getPartialAmountFloor.callAsync(numerator, denominator, target); + const actual = await libsContract.getPartialAmountFloor(numerator, denominator, target).callAsync(); expect(actual).to.bignumber.eq(expected); }); @@ -63,7 +62,7 @@ blockchainTests('LibMath', env => { const denominator = ONE_ETHER.times(1.8); const target = ONE_ETHER; const expected = ONE_ETHER.dividedToIntegerBy(3); - const actual = await libsContract.getPartialAmountFloor.callAsync(numerator, denominator, target); + const actual = await libsContract.getPartialAmountFloor(numerator, denominator, target).callAsync(); expect(actual).to.bignumber.eq(expected); }); @@ -77,7 +76,7 @@ blockchainTests('LibMath', env => { denominator, ); return expect( - libsContract.getPartialAmountFloor.callAsync(numerator, denominator, target), + libsContract.getPartialAmountFloor(numerator, denominator, target).callAsync(), ).to.revertWith(expectedError); }); @@ -91,7 +90,7 @@ blockchainTests('LibMath', env => { target, ); return expect( - libsContract.getPartialAmountFloor.callAsync(numerator, denominator, target), + libsContract.getPartialAmountFloor(numerator, denominator, target).callAsync(), ).to.revertWith(expectedError); }); }); @@ -113,7 +112,7 @@ blockchainTests('LibMath', env => { const denominator = ONE_ETHER.dividedToIntegerBy(2); const target = ONE_ETHER.times(0.01); const expected = ReferenceFunctions.getPartialAmountCeil(numerator, denominator, target); - const actual = await libsContract.getPartialAmountCeil.callAsync(numerator, denominator, target); + const actual = await libsContract.getPartialAmountCeil(numerator, denominator, target).callAsync(); expect(actual).to.bignumber.eq(expected); }); @@ -122,7 +121,7 @@ blockchainTests('LibMath', env => { const denominator = ONE_ETHER.times(1.8); const target = ONE_ETHER; const expected = ONE_ETHER.dividedToIntegerBy(3).plus(1); - const actual = await libsContract.getPartialAmountCeil.callAsync(numerator, denominator, target); + const actual = await libsContract.getPartialAmountCeil(numerator, denominator, target).callAsync(); expect(actual).to.bignumber.eq(expected); }); @@ -137,7 +136,7 @@ blockchainTests('LibMath', env => { new BigNumber(1), ); return expect( - libsContract.getPartialAmountCeil.callAsync(numerator, denominator, target), + libsContract.getPartialAmountCeil(numerator, denominator, target).callAsync(), ).to.revertWith(expectedError); }); @@ -151,7 +150,7 @@ blockchainTests('LibMath', env => { target, ); return expect( - libsContract.getPartialAmountCeil.callAsync(numerator, denominator, target), + libsContract.getPartialAmountCeil(numerator, denominator, target).callAsync(), ).to.revertWith(expectedError); }); }); @@ -173,7 +172,7 @@ blockchainTests('LibMath', env => { const denominator = ONE_ETHER.dividedToIntegerBy(2); const target = ONE_ETHER.times(0.01); const expected = ReferenceFunctions.safeGetPartialAmountFloor(numerator, denominator, target); - const actual = await libsContract.safeGetPartialAmountFloor.callAsync(numerator, denominator, target); + const actual = await libsContract.safeGetPartialAmountFloor(numerator, denominator, target).callAsync(); expect(actual).to.bignumber.eq(expected); }); @@ -182,7 +181,7 @@ blockchainTests('LibMath', env => { const denominator = ONE_ETHER.times(1.8); const target = ONE_ETHER; const expected = ONE_ETHER.dividedToIntegerBy(3); - const actual = await libsContract.safeGetPartialAmountFloor.callAsync(numerator, denominator, target); + const actual = await libsContract.safeGetPartialAmountFloor(numerator, denominator, target).callAsync(); expect(actual).to.bignumber.eq(expected); }); @@ -192,7 +191,7 @@ blockchainTests('LibMath', env => { const target = new BigNumber(333); const expectedError = new LibMathRevertErrors.RoundingError(numerator, denominator, target); return expect( - libsContract.safeGetPartialAmountFloor.callAsync(numerator, denominator, target), + libsContract.safeGetPartialAmountFloor(numerator, denominator, target).callAsync(), ).to.revertWith(expectedError); }); @@ -202,7 +201,7 @@ blockchainTests('LibMath', env => { const target = ONE_ETHER.times(0.01); const expectedError = new LibMathRevertErrors.DivisionByZeroError(); return expect( - libsContract.safeGetPartialAmountFloor.callAsync(numerator, denominator, target), + libsContract.safeGetPartialAmountFloor(numerator, denominator, target).callAsync(), ).to.revertWith(expectedError); }); @@ -216,7 +215,7 @@ blockchainTests('LibMath', env => { target, ); return expect( - libsContract.safeGetPartialAmountFloor.callAsync(numerator, denominator, target), + libsContract.safeGetPartialAmountFloor(numerator, denominator, target).callAsync(), ).to.revertWith(expectedError); }); }); @@ -238,7 +237,7 @@ blockchainTests('LibMath', env => { const denominator = ONE_ETHER.dividedToIntegerBy(2); const target = ONE_ETHER.times(0.01); const expected = ReferenceFunctions.safeGetPartialAmountCeil(numerator, denominator, target); - const actual = await libsContract.safeGetPartialAmountCeil.callAsync(numerator, denominator, target); + const actual = await libsContract.safeGetPartialAmountCeil(numerator, denominator, target).callAsync(); expect(actual).to.bignumber.eq(expected); }); @@ -247,7 +246,7 @@ blockchainTests('LibMath', env => { const denominator = ONE_ETHER.times(1.8); const target = ONE_ETHER; const expected = ONE_ETHER.dividedToIntegerBy(3).plus(1); - const actual = await libsContract.safeGetPartialAmountCeil.callAsync(numerator, denominator, target); + const actual = await libsContract.safeGetPartialAmountCeil(numerator, denominator, target).callAsync(); expect(actual).to.bignumber.eq(expected); }); @@ -257,7 +256,7 @@ blockchainTests('LibMath', env => { const target = new BigNumber(333); const expectedError = new LibMathRevertErrors.RoundingError(numerator, denominator, target); return expect( - libsContract.safeGetPartialAmountCeil.callAsync(numerator, denominator, target), + libsContract.safeGetPartialAmountCeil(numerator, denominator, target).callAsync(), ).to.revertWith(expectedError); }); @@ -267,7 +266,7 @@ blockchainTests('LibMath', env => { const target = ONE_ETHER.times(0.01); const expectedError = new LibMathRevertErrors.DivisionByZeroError(); return expect( - libsContract.safeGetPartialAmountCeil.callAsync(numerator, denominator, target), + libsContract.safeGetPartialAmountCeil(numerator, denominator, target).callAsync(), ).to.revertWith(expectedError); }); @@ -281,7 +280,7 @@ blockchainTests('LibMath', env => { target, ); return expect( - libsContract.safeGetPartialAmountCeil.callAsync(numerator, denominator, target), + libsContract.safeGetPartialAmountCeil(numerator, denominator, target).callAsync(), ).to.revertWith(expectedError); }); }); @@ -303,7 +302,7 @@ blockchainTests('LibMath', env => { const denominator = new BigNumber(102); const target = new BigNumber(52); // tslint:disable-next-line: boolean-naming - const actual = await libsContract.isRoundingErrorFloor.callAsync(numerator, denominator, target); + const actual = await libsContract.isRoundingErrorFloor(numerator, denominator, target).callAsync(); expect(actual).to.eq(true); }); @@ -312,7 +311,7 @@ blockchainTests('LibMath', env => { const denominator = new BigNumber(101); const target = new BigNumber(92); // tslint:disable-next-line: boolean-naming - const actual = await libsContract.isRoundingErrorFloor.callAsync(numerator, denominator, target); + const actual = await libsContract.isRoundingErrorFloor(numerator, denominator, target).callAsync(); expect(actual).to.eq(false); }); @@ -323,7 +322,7 @@ blockchainTests('LibMath', env => { // tslint:disable-next-line: boolean-naming const expected = ReferenceFunctions.isRoundingErrorFloor(numerator, denominator, target); // tslint:disable-next-line: boolean-naming - const actual = await libsContract.isRoundingErrorFloor.callAsync(numerator, denominator, target); + const actual = await libsContract.isRoundingErrorFloor(numerator, denominator, target).callAsync(); expect(actual).to.eq(expected); }); @@ -333,7 +332,7 @@ blockchainTests('LibMath', env => { const target = ONE_ETHER.times(0.01); const expectedError = new LibMathRevertErrors.DivisionByZeroError(); return expect( - libsContract.isRoundingErrorFloor.callAsync(numerator, denominator, target), + libsContract.isRoundingErrorFloor(numerator, denominator, target).callAsync(), ).to.revertWith(expectedError); }); @@ -347,7 +346,7 @@ blockchainTests('LibMath', env => { target, ); return expect( - libsContract.isRoundingErrorFloor.callAsync(numerator, denominator, target), + libsContract.isRoundingErrorFloor(numerator, denominator, target).callAsync(), ).to.revertWith(expectedError); }); }); @@ -369,7 +368,7 @@ blockchainTests('LibMath', env => { const denominator = new BigNumber(101); const target = new BigNumber(92); // tslint:disable-next-line: boolean-naming - const actual = await libsContract.isRoundingErrorCeil.callAsync(numerator, denominator, target); + const actual = await libsContract.isRoundingErrorCeil(numerator, denominator, target).callAsync(); expect(actual).to.eq(true); }); @@ -378,7 +377,7 @@ blockchainTests('LibMath', env => { const denominator = new BigNumber(102); const target = new BigNumber(52); // tslint:disable-next-line: boolean-naming - const actual = await libsContract.isRoundingErrorCeil.callAsync(numerator, denominator, target); + const actual = await libsContract.isRoundingErrorCeil(numerator, denominator, target).callAsync(); expect(actual).to.eq(false); }); @@ -389,7 +388,7 @@ blockchainTests('LibMath', env => { // tslint:disable-next-line: boolean-naming const expected = ReferenceFunctions.isRoundingErrorCeil(numerator, denominator, target); // tslint:disable-next-line: boolean-naming - const actual = await libsContract.isRoundingErrorCeil.callAsync(numerator, denominator, target); + const actual = await libsContract.isRoundingErrorCeil(numerator, denominator, target).callAsync(); expect(actual).to.eq(expected); }); @@ -398,9 +397,9 @@ blockchainTests('LibMath', env => { const denominator = ZERO_AMOUNT; const target = ONE_ETHER.times(0.01); const expectedError = new LibMathRevertErrors.DivisionByZeroError(); - return expect(libsContract.isRoundingErrorCeil.callAsync(numerator, denominator, target)).to.revertWith( - expectedError, - ); + return expect( + libsContract.isRoundingErrorCeil(numerator, denominator, target).callAsync(), + ).to.revertWith(expectedError); }); it('reverts if `numerator * target` overflows', async () => { @@ -412,9 +411,9 @@ blockchainTests('LibMath', env => { numerator, target, ); - return expect(libsContract.isRoundingErrorCeil.callAsync(numerator, denominator, target)).to.revertWith( - expectedError, - ); + return expect( + libsContract.isRoundingErrorCeil(numerator, denominator, target).callAsync(), + ).to.revertWith(expectedError); }); }); }); diff --git a/contracts/exchange-libs/test/lib_order.ts b/contracts/exchange-libs/test/lib_order.ts index ec87e6b4cd..1ad0f015db 100644 --- a/contracts/exchange-libs/test/lib_order.ts +++ b/contracts/exchange-libs/test/lib_order.ts @@ -56,7 +56,7 @@ blockchainTests('LibOrder', env => { version: constants.EIP712_DOMAIN_VERSION, }), ); - const actualHash = await libOrderContract.getTypedDataHash.callAsync(order, domainHash); + const actualHash = await libOrderContract.getTypedDataHash(order, domainHash).callAsync(); expect(actualHash).to.be.eq(expectedHash); } @@ -106,8 +106,8 @@ blockchainTests('LibOrder', env => { chainId: 1337, }), ); - const orderHashHex1 = await libOrderContract.getTypedDataHash.callAsync(EMPTY_ORDER, domainHash1); - const orderHashHex2 = await libOrderContract.getTypedDataHash.callAsync(EMPTY_ORDER, domainHash2); + const orderHashHex1 = await libOrderContract.getTypedDataHash(EMPTY_ORDER, domainHash1).callAsync(); + const orderHashHex2 = await libOrderContract.getTypedDataHash(EMPTY_ORDER, domainHash2).callAsync(); expect(orderHashHex1).to.be.not.equal(orderHashHex2); }); }); @@ -118,7 +118,7 @@ blockchainTests('LibOrder', env => { async function testGetStructHashAsync(order: Order): Promise { const typedData = eip712Utils.createOrderTypedData(order); const expectedHash = ethUtil.bufferToHex(signTypedDataUtils.generateTypedDataHashWithoutDomain(typedData)); - const actualHash = await libOrderContract.getStructHash.callAsync(order); + const actualHash = await libOrderContract.getStructHash(order).callAsync(); expect(actualHash).to.be.eq(expectedHash); } diff --git a/contracts/exchange-libs/test/lib_zero_ex_transaction.ts b/contracts/exchange-libs/test/lib_zero_ex_transaction.ts index 00d3446606..e650e17a31 100644 --- a/contracts/exchange-libs/test/lib_zero_ex_transaction.ts +++ b/contracts/exchange-libs/test/lib_zero_ex_transaction.ts @@ -48,7 +48,7 @@ blockchainTests('LibZeroExTransaction', env => { version: constants.EIP712_DOMAIN_VERSION, }), ); - const actualHash = await libZeroExTransactionContract.getTypedDataHash.callAsync(transaction, domainHash); + const actualHash = await libZeroExTransactionContract.getTypedDataHash(transaction, domainHash).callAsync(); expect(actualHash).to.be.eq(expectedHash); } @@ -92,14 +92,12 @@ blockchainTests('LibZeroExTransaction', env => { chainId: 1337, }), ); - const transactionHashHex1 = await libZeroExTransactionContract.getTypedDataHash.callAsync( - EMPTY_TRANSACTION, - domainHash1, - ); - const transactionHashHex2 = await libZeroExTransactionContract.getTypedDataHash.callAsync( - EMPTY_TRANSACTION, - domainHash2, - ); + const transactionHashHex1 = await libZeroExTransactionContract + .getTypedDataHash(EMPTY_TRANSACTION, domainHash1) + .callAsync(); + const transactionHashHex2 = await libZeroExTransactionContract + .getTypedDataHash(EMPTY_TRANSACTION, domainHash2) + .callAsync(); expect(transactionHashHex1).to.be.not.equal(transactionHashHex2); }); }); @@ -110,7 +108,7 @@ blockchainTests('LibZeroExTransaction', env => { async function testGetStructHashAsync(transaction: ZeroExTransaction): Promise { const typedData = eip712Utils.createZeroExTransactionTypedData(transaction); const expectedHash = ethUtil.bufferToHex(signTypedDataUtils.generateTypedDataHashWithoutDomain(typedData)); - const actualHash = await libZeroExTransactionContract.getStructHash.callAsync(transaction); + const actualHash = await libZeroExTransactionContract.getStructHash(transaction).callAsync(); expect(actualHash).to.be.eq(expectedHash); } diff --git a/contracts/exchange/src/wrapper_interfaces.ts b/contracts/exchange/src/wrapper_interfaces.ts index 2c8fe219b1..23942b10b5 100644 --- a/contracts/exchange/src/wrapper_interfaces.ts +++ b/contracts/exchange/src/wrapper_interfaces.ts @@ -1,53 +1,21 @@ -import { PromiseWithTransactionHash } from '@0x/base-contract'; -import { AwaitTransactionSuccessOpts } from '@0x/types'; -import { BlockParam, CallData, TransactionReceiptWithDecodedLogs, TxData } from 'ethereum-types'; +import { ContractFunctionObj, ContractTxFunctionObj, PromiseWithTransactionHash } from '@0x/base-contract'; +import { BlockParam, CallData } from 'ethereum-types'; +// tslint:disable:max-classes-per-file // Generated Wrapper Interfaces -export interface AssetProxyDispatcher { - registerAssetProxy: { - awaitTransactionSuccessAsync: ( - assetProxy: string, - txData?: Partial, - txOpts?: AwaitTransactionSuccessOpts, - ) => PromiseWithTransactionHash; - }; - getAssetProxy: { - callAsync(assetProxyId: string, callData?: Partial, defaultBlock?: BlockParam): Promise; - }; +export abstract class AssetProxyDispatcher { + public abstract registerAssetProxy(assetProxy: string): ContractTxFunctionObj; + public abstract getAssetProxy(assetProxyId: string): ContractFunctionObj; } -export interface Authorizable extends Ownable { - addAuthorizedAddress: { - awaitTransactionSuccessAsync: ( - target: string, - txData?: Partial, - txOpts?: AwaitTransactionSuccessOpts, - ) => PromiseWithTransactionHash; - }; - removeAuthorizedAddress: { - awaitTransactionSuccessAsync: ( - target: string, - txData?: Partial, - txOpts?: AwaitTransactionSuccessOpts, - ) => PromiseWithTransactionHash; - }; - authorized: { - callAsync(authority: string, callData?: Partial, defaultBlock?: BlockParam): Promise; - }; - getAuthorizedAddresses: { - callAsync(callData?: Partial, defaultBlock?: BlockParam): Promise; - }; -} +export abstract class Ownable { + public abstract transferOwnership(newOwner: string): ContractTxFunctionObj; -export interface Ownable { - transferOwnership: { - awaitTransactionSuccessAsync: ( - newOwner: string, - txData?: Partial, - txOpts?: AwaitTransactionSuccessOpts, - ) => PromiseWithTransactionHash; - }; - owner: { - callAsync(callData?: Partial, defaultBlock?: BlockParam): Promise; - }; + public abstract owner(callData?: Partial, defaultBlock?: BlockParam): ContractFunctionObj; +} +export abstract class Authorizable extends Ownable { + public abstract addAuthorizedAddress(target: string): ContractTxFunctionObj; + public abstract removeAuthorizedAddress(target: string): ContractTxFunctionObj; + public abstract authorized(authority: string): ContractFunctionObj; + public abstract getAuthorizedAddresses(): ContractFunctionObj; } diff --git a/contracts/exchange/test/assertion_wrappers/fill_order_wrapper.ts b/contracts/exchange/test/assertion_wrappers/fill_order_wrapper.ts index 0c6e552f3b..cb2878dbed 100644 --- a/contracts/exchange/test/assertion_wrappers/fill_order_wrapper.ts +++ b/contracts/exchange/test/assertion_wrappers/fill_order_wrapper.ts @@ -157,9 +157,9 @@ export class FillOrderWrapper { ): Promise { // Get init state await this._blockchainBalanceStore.updateBalancesAsync(); - const initTakerAssetFilledAmount = await this._exchange.filled.callAsync( - orderHashUtils.getOrderHashHex(signedOrder), - ); + const initTakerAssetFilledAmount = await this._exchange + .filled(orderHashUtils.getOrderHashHex(signedOrder)) + .callAsync(); // Assert init state of exchange await this._assertOrderStateAsync(signedOrder, initTakerAssetFilledAmount); // Simulate and execute fill then assert outputs @@ -190,18 +190,12 @@ export class FillOrderWrapper { opts: { takerAssetFillAmount?: BigNumber } = {}, ): Promise<[FillResults, FillEventArgs, TransactionReceiptWithDecodedLogs]> { const params = orderUtils.createFill(signedOrder, opts.takerAssetFillAmount); - const fillResults = await this._exchange.fillOrder.callAsync( - params.order, - params.takerAssetFillAmount, - params.signature, - { from }, - ); - const txReceipt = await this._exchange.fillOrder.awaitTransactionSuccessAsync( - params.order, - params.takerAssetFillAmount, - params.signature, - { from }, - ); + const fillResults = await this._exchange + .fillOrder(params.order, params.takerAssetFillAmount, params.signature) + .callAsync({ from }); + const txReceipt = await this._exchange + .fillOrder(params.order, params.takerAssetFillAmount, params.signature) + .awaitTransactionSuccessAsync({ from }); const fillEvent = FillOrderWrapper._extractFillEventsfromReceipt(txReceipt)[0]; return [fillResults, fillEvent, txReceipt]; } @@ -216,7 +210,7 @@ export class FillOrderWrapper { order: SignedOrder, expectedFilledAmount: BigNumber = new BigNumber(0), ): Promise { - const orderInfo = await this._exchange.getOrderInfo.callAsync(order); + const orderInfo = await this._exchange.getOrderInfo(order).callAsync(); // Check filled amount of order. const actualFilledAmount = orderInfo.orderTakerAssetFilledAmount; expect(actualFilledAmount, 'order filled amount').to.be.bignumber.equal(expectedFilledAmount); diff --git a/contracts/exchange/test/balance_stores/blockchain_balance_store.ts b/contracts/exchange/test/balance_stores/blockchain_balance_store.ts index 73d4fff643..4cebeea2f9 100644 --- a/contracts/exchange/test/balance_stores/blockchain_balance_store.ts +++ b/contracts/exchange/test/balance_stores/blockchain_balance_store.ts @@ -64,7 +64,7 @@ export class BlockchainBalanceStore extends BalanceStore { this._ownerAddresses.map(async account => _.zipObject( this._tokenContracts.erc20.map(token => token.address), - await Promise.all(this._tokenContracts.erc20.map(token => token.balanceOf.callAsync(account))), + await Promise.all(this._tokenContracts.erc20.map(token => token.balanceOf(account).callAsync())), ), ), ); @@ -83,7 +83,7 @@ export class BlockchainBalanceStore extends BalanceStore { this._balances.erc721 = {}; for (const [tokenAddress, tokenIds] of Object.entries(this._tokenIds.erc721)) { for (const tokenId of tokenIds) { - const tokenOwner = await erc721ContractsByAddress[tokenAddress].ownerOf.callAsync(tokenId); + const tokenOwner = await erc721ContractsByAddress[tokenAddress].ownerOf(tokenId).callAsync(); _.update(this._balances.erc721, [tokenOwner, tokenAddress], nfts => _.union([tokenId], nfts).sort()); } } @@ -108,10 +108,9 @@ export class BlockchainBalanceStore extends BalanceStore { const [_tokenIds, _tokenOwners] = _.unzip( combinatorics.cartesianProduct(tokenIds, this._ownerAddresses).toArray(), ); - const balances = await contract.balanceOfBatch.callAsync( - _tokenOwners as string[], - _tokenIds as BigNumber[], - ); + const balances = await contract + .balanceOfBatch(_tokenOwners as string[], _tokenIds as BigNumber[]) + .callAsync(); let i = 0; for (const tokenOwner of this._ownerAddresses) { diff --git a/contracts/exchange/test/balance_stores/local_balance_store.ts b/contracts/exchange/test/balance_stores/local_balance_store.ts index 458777a871..8fb612f219 100644 --- a/contracts/exchange/test/balance_stores/local_balance_store.ts +++ b/contracts/exchange/test/balance_stores/local_balance_store.ts @@ -81,11 +81,11 @@ export class LocalBalanceStore extends BalanceStore { if (fromAddress === toAddress) { return; } - const assetProxyId = await this._devUtils.decodeAssetProxyId.callAsync(assetData); + const assetProxyId = await this._devUtils.decodeAssetProxyId(assetData).callAsync(); switch (assetProxyId) { case AssetProxyId.ERC20: { // tslint:disable-next-line:no-unused-variable - const [proxyId, tokenAddress] = await this._devUtils.decodeERC20AssetData.callAsync(assetData); + const [proxyId, tokenAddress] = await this._devUtils.decodeERC20AssetData(assetData).callAsync(); _.update(this._balances.erc20, [fromAddress, tokenAddress], balance => balance.minus(amount)); _.update(this._balances.erc20, [toAddress, tokenAddress], balance => (balance || constants.ZERO_AMOUNT).plus(amount), @@ -94,9 +94,9 @@ export class LocalBalanceStore extends BalanceStore { } case AssetProxyId.ERC721: { // tslint:disable-next-line:no-unused-variable - const [proxyId, tokenAddress, tokenId] = await this._devUtils.decodeERC721AssetData.callAsync( - assetData, - ); + const [proxyId, tokenAddress, tokenId] = await this._devUtils + .decodeERC721AssetData(assetData) + .callAsync(); const fromTokens = _.get(this._balances.erc721, [fromAddress, tokenAddress], []); const toTokens = _.get(this._balances.erc721, [toAddress, tokenAddress], []); if (amount.gte(1)) { @@ -117,7 +117,7 @@ export class LocalBalanceStore extends BalanceStore { tokenAddress, tokenIds, tokenValues, - ] = await this._devUtils.decodeERC1155AssetData.callAsync(assetData); + ] = await this._devUtils.decodeERC1155AssetData(assetData).callAsync(); const fromBalances = { // tslint:disable-next-line:no-inferred-empty-object-type fungible: _.get(this._balances.erc1155, [fromAddress, tokenAddress, 'fungible'], {}), @@ -155,9 +155,9 @@ export class LocalBalanceStore extends BalanceStore { } case AssetProxyId.MultiAsset: { // tslint:disable-next-line:no-unused-variable - const [proxyId, amounts, nestedAssetData] = await this._devUtils.decodeMultiAssetData.callAsync( - assetData, - ); + const [proxyId, amounts, nestedAssetData] = await this._devUtils + .decodeMultiAssetData(assetData) + .callAsync(); for (const [i, amt] of amounts.entries()) { const nestedAmount = amount.times(amt); await this.transferAssetAsync(fromAddress, toAddress, nestedAmount, nestedAssetData[i]); diff --git a/contracts/exchange/test/core.ts b/contracts/exchange/test/core.ts index 55da2bd13b..ff281a5ecd 100644 --- a/contracts/exchange/test/core.ts +++ b/contracts/exchange/test/core.ts @@ -157,22 +157,22 @@ blockchainTests.resets('Exchange core', () => { exchange.address, ); // Configure ERC20Proxy - await erc20Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(exchange.address, { from: owner }); - await erc20Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(multiAssetProxy.address, { from: owner }); + await erc20Proxy.addAuthorizedAddress(exchange.address).awaitTransactionSuccessAsync({ from: owner }); + await erc20Proxy.addAuthorizedAddress(multiAssetProxy.address).awaitTransactionSuccessAsync({ from: owner }); // Configure ERC721Proxy - await erc721Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(exchange.address, { from: owner }); - await erc721Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(multiAssetProxy.address, { from: owner }); + await erc721Proxy.addAuthorizedAddress(exchange.address).awaitTransactionSuccessAsync({ from: owner }); + await erc721Proxy.addAuthorizedAddress(multiAssetProxy.address).awaitTransactionSuccessAsync({ from: owner }); // Configure ERC1155Proxy - await erc1155Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(exchange.address, { from: owner }); - await erc1155Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(multiAssetProxy.address, { from: owner }); + await erc1155Proxy.addAuthorizedAddress(exchange.address).awaitTransactionSuccessAsync({ from: owner }); + await erc1155Proxy.addAuthorizedAddress(multiAssetProxy.address).awaitTransactionSuccessAsync({ from: owner }); // Configure MultiAssetProxy - await multiAssetProxy.addAuthorizedAddress.awaitTransactionSuccessAsync(exchange.address, { from: owner }); - await multiAssetProxy.registerAssetProxy.awaitTransactionSuccessAsync(erc20Proxy.address, { from: owner }); - await multiAssetProxy.registerAssetProxy.awaitTransactionSuccessAsync(erc721Proxy.address, { from: owner }); - await multiAssetProxy.registerAssetProxy.awaitTransactionSuccessAsync(staticCallProxy.address, { from: owner }); + await multiAssetProxy.addAuthorizedAddress(exchange.address).awaitTransactionSuccessAsync({ from: owner }); + await multiAssetProxy.registerAssetProxy(erc20Proxy.address).awaitTransactionSuccessAsync({ from: owner }); + await multiAssetProxy.registerAssetProxy(erc721Proxy.address).awaitTransactionSuccessAsync({ from: owner }); + await multiAssetProxy.registerAssetProxy(staticCallProxy.address).awaitTransactionSuccessAsync({ from: owner }); // Configure Exchange exchangeWrapper = new ExchangeWrapper(exchange); @@ -216,10 +216,10 @@ blockchainTests.resets('Exchange core', () => { ...constants.STATIC_ORDER_PARAMS, makerAddress, feeRecipientAddress, - makerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultMakerAssetAddress), - takerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultTakerAssetAddress), - makerFeeAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultFeeAssetAddress), - takerFeeAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultFeeAssetAddress), + makerAssetData: await devUtils.encodeERC20AssetData(defaultMakerAssetAddress).callAsync(), + takerAssetData: await devUtils.encodeERC20AssetData(defaultTakerAssetAddress).callAsync(), + makerFeeAssetData: await devUtils.encodeERC20AssetData(defaultFeeAssetAddress).callAsync(), + takerFeeAssetData: await devUtils.encodeERC20AssetData(defaultFeeAssetAddress).callAsync(), exchangeAddress: exchange.address, chainId, }; @@ -257,24 +257,19 @@ blockchainTests.resets('Exchange core', () => { describe('callback signature types', () => { beforeEach(async () => { // Approve the ERC20 proxy with the test validator wallet. - await validatorWallet.approveERC20.awaitTransactionSuccessAsync( - erc20TokenA.address, - erc20Proxy.address, - constants.INITIAL_ERC20_ALLOWANCE, - ); + await validatorWallet + .approveERC20(erc20TokenA.address, erc20Proxy.address, constants.INITIAL_ERC20_ALLOWANCE) + .awaitTransactionSuccessAsync(); // Mint some ERC20 tokens to the test validator wallet. - await erc20TokenA.setBalance.awaitTransactionSuccessAsync( - validatorWallet.address, - constants.INITIAL_ERC20_BALANCE, - ); + await erc20TokenA + .setBalance(validatorWallet.address, constants.INITIAL_ERC20_BALANCE) + .awaitTransactionSuccessAsync(); // Approve the validator. - await exchange.setSignatureValidatorApproval.awaitTransactionSuccessAsync( - validatorWallet.address, - true, - { + await exchange + .setSignatureValidatorApproval(validatorWallet.address, true) + .awaitTransactionSuccessAsync({ from: makerAddress, - }, - ); + }); signedOrder = await orderFactory.newSignedOrderAsync({ makerFee: constants.ZERO_AMOUNT, takerFee: constants.ZERO_AMOUNT, @@ -286,19 +281,15 @@ blockchainTests.resets('Exchange core', () => { signedOrder.signature = signatureHex; const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder); // Allow the signature check for the first fill. - await validatorWallet.prepare.awaitTransactionSuccessAsync( - orderHashHex, - ValidatorWalletAction.Accept, - constants.NULL_BYTES, - ); + await validatorWallet + .prepare(orderHashHex, ValidatorWalletAction.Accept, constants.NULL_BYTES) + .awaitTransactionSuccessAsync(); const fillAmount = signedOrder.takerAssetAmount.div(10); await exchangeWrapper.fillOrderAsync(signedOrder, takerAddress, { takerAssetFillAmount: fillAmount }); // Reject the signature check for the second fill. - await validatorWallet.prepare.awaitTransactionSuccessAsync( - orderHashHex, - ValidatorWalletAction.Reject, - constants.NULL_BYTES, - ); + await validatorWallet + .prepare(orderHashHex, ValidatorWalletAction.Reject, constants.NULL_BYTES) + .awaitTransactionSuccessAsync(); const tx = exchangeWrapper.fillOrderAsync(signedOrder, takerAddress, { takerAssetFillAmount: fillAmount, }); @@ -317,19 +308,15 @@ blockchainTests.resets('Exchange core', () => { signedOrder.signature = signatureHex; const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder); // Allow the signature check for the first fill. - await validatorWallet.prepare.awaitTransactionSuccessAsync( - orderHashHex, - ValidatorWalletAction.Accept, - constants.NULL_BYTES, - ); + await validatorWallet + .prepare(orderHashHex, ValidatorWalletAction.Accept, constants.NULL_BYTES) + .awaitTransactionSuccessAsync(); const fillAmount = signedOrder.takerAssetAmount.div(10); await exchangeWrapper.fillOrderAsync(signedOrder, takerAddress, { takerAssetFillAmount: fillAmount }); // Reject the signature check for the second fill. - await validatorWallet.prepare.awaitTransactionSuccessAsync( - orderHashHex, - ValidatorWalletAction.Reject, - constants.NULL_BYTES, - ); + await validatorWallet + .prepare(orderHashHex, ValidatorWalletAction.Reject, constants.NULL_BYTES) + .awaitTransactionSuccessAsync(); const tx = exchangeWrapper.fillOrderAsync(signedOrder, takerAddress, { takerAssetFillAmount: fillAmount, }); @@ -348,19 +335,15 @@ blockchainTests.resets('Exchange core', () => { signedOrder.signature = signatureHex; const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder); // Allow the signature check for the first fill. - await validatorWallet.prepare.awaitTransactionSuccessAsync( - orderHashHex, - ValidatorWalletAction.Accept, - constants.NULL_BYTES, - ); + await validatorWallet + .prepare(orderHashHex, ValidatorWalletAction.Accept, constants.NULL_BYTES) + .awaitTransactionSuccessAsync(); const fillAmount = signedOrder.takerAssetAmount.div(10); await exchangeWrapper.fillOrderAsync(signedOrder, takerAddress, { takerAssetFillAmount: fillAmount }); // Reject the signature check for the second fill. - await validatorWallet.prepare.awaitTransactionSuccessAsync( - orderHashHex, - ValidatorWalletAction.Reject, - constants.NULL_BYTES, - ); + await validatorWallet + .prepare(orderHashHex, ValidatorWalletAction.Reject, constants.NULL_BYTES) + .awaitTransactionSuccessAsync(); const tx = exchangeWrapper.fillOrderAsync(signedOrder, takerAddress, { takerAssetFillAmount: fillAmount, }); @@ -425,9 +408,11 @@ blockchainTests.resets('Exchange core', () => { describe('Fill transfer ordering', () => { it('should allow the maker to exchange assets received by the taker', async () => { // Set maker/taker assetData to the same asset - const takerAssetData = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); + const takerAssetData = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); const takerAssetAmount = new BigNumber(1); - const makerAssetData = await devUtils.encodeMultiAssetData.callAsync([takerAssetAmount], [takerAssetData]); + const makerAssetData = await devUtils + .encodeMultiAssetData([takerAssetAmount], [takerAssetData]) + .callAsync(); signedOrder = await orderFactory.newSignedOrderAsync({ makerAssetData, takerAssetData, @@ -437,33 +422,33 @@ blockchainTests.resets('Exchange core', () => { takerFee: constants.ZERO_AMOUNT, }); // Set maker balance to 0 so that the asset must be received by the taker in order for the fill to succeed - await erc20TokenA.setBalance.awaitTransactionSuccessAsync(makerAddress, constants.ZERO_AMOUNT, { + await erc20TokenA.setBalance(makerAddress, constants.ZERO_AMOUNT).awaitTransactionSuccessAsync({ from: owner, }); await fillOrderWrapper.fillOrderAndAssertEffectsAsync(signedOrder, takerAddress); }); it('should allow the taker to pay fees with an asset that received by the maker', async () => { - const makerAssetData = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); + const makerAssetData = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); signedOrder = await orderFactory.newSignedOrderAsync({ takerFeeAssetData: makerAssetData, makerFee: constants.ZERO_AMOUNT, takerFee: new BigNumber(1), }); // Set taker balance to 0 so that the asset must be received by the maker in order for the fill to succeed - await erc20TokenA.setBalance.awaitTransactionSuccessAsync(takerAddress, constants.ZERO_AMOUNT, { + await erc20TokenA.setBalance(takerAddress, constants.ZERO_AMOUNT).awaitTransactionSuccessAsync({ from: owner, }); await fillOrderWrapper.fillOrderAndAssertEffectsAsync(signedOrder, takerAddress); }); it('should allow the maker to pay fees with an asset that received by the taker', async () => { - const takerAssetData = await devUtils.encodeERC20AssetData.callAsync(erc20TokenB.address); + const takerAssetData = await devUtils.encodeERC20AssetData(erc20TokenB.address).callAsync(); signedOrder = await orderFactory.newSignedOrderAsync({ makerFeeAssetData: takerAssetData, makerFee: new BigNumber(1), takerFee: constants.ZERO_AMOUNT, }); // Set maker balance to 0 so that the asset must be received by the taker in order for the fill to succeed - await erc20TokenB.setBalance.awaitTransactionSuccessAsync(makerAddress, constants.ZERO_AMOUNT, { + await erc20TokenB.setBalance(makerAddress, constants.ZERO_AMOUNT).awaitTransactionSuccessAsync({ from: owner, }); await fillOrderWrapper.fillOrderAndAssertEffectsAsync(signedOrder, takerAddress); @@ -471,19 +456,16 @@ blockchainTests.resets('Exchange core', () => { }); describe('Testing exchange of ERC20 tokens with no return values', () => { before(async () => { - await noReturnErc20Token.setBalance.awaitTransactionSuccessAsync( - makerAddress, - constants.INITIAL_ERC20_BALANCE, - ); - await noReturnErc20Token.approve.awaitTransactionSuccessAsync( - erc20Proxy.address, - constants.INITIAL_ERC20_ALLOWANCE, - { from: makerAddress }, - ); + await noReturnErc20Token + .setBalance(makerAddress, constants.INITIAL_ERC20_BALANCE) + .awaitTransactionSuccessAsync(); + await noReturnErc20Token + .approve(erc20Proxy.address, constants.INITIAL_ERC20_ALLOWANCE) + .awaitTransactionSuccessAsync({ from: makerAddress }); }); it('should transfer the correct amounts when makerAssetAmount === takerAssetAmount', async () => { signedOrder = await orderFactory.newSignedOrderAsync({ - makerAssetData: await devUtils.encodeERC20AssetData.callAsync(noReturnErc20Token.address), + makerAssetData: await devUtils.encodeERC20AssetData(noReturnErc20Token.address).callAsync(), makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(100), 18), takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(100), 18), }); @@ -491,7 +473,7 @@ blockchainTests.resets('Exchange core', () => { }); it('should transfer the correct amounts when makerAssetAmount > takerAssetAmount', async () => { signedOrder = await orderFactory.newSignedOrderAsync({ - makerAssetData: await devUtils.encodeERC20AssetData.callAsync(noReturnErc20Token.address), + makerAssetData: await devUtils.encodeERC20AssetData(noReturnErc20Token.address).callAsync(), makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(200), 18), takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(100), 18), }); @@ -499,7 +481,7 @@ blockchainTests.resets('Exchange core', () => { }); it('should transfer the correct amounts when makerAssetAmount < takerAssetAmount', async () => { signedOrder = await orderFactory.newSignedOrderAsync({ - makerAssetData: await devUtils.encodeERC20AssetData.callAsync(noReturnErc20Token.address), + makerAssetData: await devUtils.encodeERC20AssetData(noReturnErc20Token.address).callAsync(), makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(100), 18), takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(200), 18), }); @@ -676,14 +658,14 @@ blockchainTests.resets('Exchange core', () => { signedOrder = await orderFactory.newSignedOrderAsync({ makerAssetAmount: new BigNumber(1), takerAssetAmount: new BigNumber(1), - makerAssetData: await devUtils.encodeERC721AssetData.callAsync(erc721Token.address, makerAssetId), - takerAssetData: await devUtils.encodeERC721AssetData.callAsync(erc721Token.address, takerAssetId), + makerAssetData: await devUtils.encodeERC721AssetData(erc721Token.address, makerAssetId).callAsync(), + takerAssetData: await devUtils.encodeERC721AssetData(erc721Token.address, takerAssetId).callAsync(), }); const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder); // Verify pre-conditions - const initialOwnerMakerAsset = await erc721Token.ownerOf.callAsync(makerAssetId); + const initialOwnerMakerAsset = await erc721Token.ownerOf(makerAssetId).callAsync(); expect(initialOwnerMakerAsset).to.be.bignumber.not.equal(makerAddress); - const initialOwnerTakerAsset = await erc721Token.ownerOf.callAsync(takerAssetId); + const initialOwnerTakerAsset = await erc721Token.ownerOf(takerAssetId).callAsync(); expect(initialOwnerTakerAsset).to.be.bignumber.equal(takerAddress); // Call Exchange const takerAssetFillAmount = signedOrder.takerAssetAmount; @@ -703,14 +685,14 @@ blockchainTests.resets('Exchange core', () => { signedOrder = await orderFactory.newSignedOrderAsync({ makerAssetAmount: new BigNumber(1), takerAssetAmount: new BigNumber(1), - makerAssetData: await devUtils.encodeERC721AssetData.callAsync(erc721Token.address, makerAssetId), - takerAssetData: await devUtils.encodeERC721AssetData.callAsync(erc721Token.address, takerAssetId), + makerAssetData: await devUtils.encodeERC721AssetData(erc721Token.address, makerAssetId).callAsync(), + takerAssetData: await devUtils.encodeERC721AssetData(erc721Token.address, takerAssetId).callAsync(), }); const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder); // Verify pre-conditions - const initialOwnerMakerAsset = await erc721Token.ownerOf.callAsync(makerAssetId); + const initialOwnerMakerAsset = await erc721Token.ownerOf(makerAssetId).callAsync(); expect(initialOwnerMakerAsset).to.be.bignumber.equal(makerAddress); - const initialOwnerTakerAsset = await erc721Token.ownerOf.callAsync(takerAssetId); + const initialOwnerTakerAsset = await erc721Token.ownerOf(takerAssetId).callAsync(); expect(initialOwnerTakerAsset).to.be.bignumber.not.equal(takerAddress); // Call Exchange const takerAssetFillAmount = signedOrder.takerAssetAmount; @@ -730,14 +712,14 @@ blockchainTests.resets('Exchange core', () => { signedOrder = await orderFactory.newSignedOrderAsync({ makerAssetAmount: new BigNumber(2), takerAssetAmount: new BigNumber(1), - makerAssetData: await devUtils.encodeERC721AssetData.callAsync(erc721Token.address, makerAssetId), - takerAssetData: await devUtils.encodeERC721AssetData.callAsync(erc721Token.address, takerAssetId), + makerAssetData: await devUtils.encodeERC721AssetData(erc721Token.address, makerAssetId).callAsync(), + takerAssetData: await devUtils.encodeERC721AssetData(erc721Token.address, takerAssetId).callAsync(), }); const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder); // Verify pre-conditions - const initialOwnerMakerAsset = await erc721Token.ownerOf.callAsync(makerAssetId); + const initialOwnerMakerAsset = await erc721Token.ownerOf(makerAssetId).callAsync(); expect(initialOwnerMakerAsset).to.be.bignumber.equal(makerAddress); - const initialOwnerTakerAsset = await erc721Token.ownerOf.callAsync(takerAssetId); + const initialOwnerTakerAsset = await erc721Token.ownerOf(takerAssetId).callAsync(); expect(initialOwnerTakerAsset).to.be.bignumber.equal(takerAddress); // Call Exchange const takerAssetFillAmount = signedOrder.takerAssetAmount; @@ -757,14 +739,14 @@ blockchainTests.resets('Exchange core', () => { signedOrder = await orderFactory.newSignedOrderAsync({ makerAssetAmount: new BigNumber(1), takerAssetAmount: new BigNumber(500), - makerAssetData: await devUtils.encodeERC721AssetData.callAsync(erc721Token.address, makerAssetId), - takerAssetData: await devUtils.encodeERC721AssetData.callAsync(erc721Token.address, takerAssetId), + makerAssetData: await devUtils.encodeERC721AssetData(erc721Token.address, makerAssetId).callAsync(), + takerAssetData: await devUtils.encodeERC721AssetData(erc721Token.address, takerAssetId).callAsync(), }); const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder); // Verify pre-conditions - const initialOwnerMakerAsset = await erc721Token.ownerOf.callAsync(makerAssetId); + const initialOwnerMakerAsset = await erc721Token.ownerOf(makerAssetId).callAsync(); expect(initialOwnerMakerAsset).to.be.bignumber.equal(makerAddress); - const initialOwnerTakerAsset = await erc721Token.ownerOf.callAsync(takerAssetId); + const initialOwnerTakerAsset = await erc721Token.ownerOf(takerAssetId).callAsync(); expect(initialOwnerTakerAsset).to.be.bignumber.equal(takerAddress); // Call Exchange const takerAssetFillAmount = signedOrder.takerAssetAmount; @@ -783,8 +765,8 @@ blockchainTests.resets('Exchange core', () => { signedOrder = await orderFactory.newSignedOrderAsync({ makerAssetAmount: new BigNumber(1), takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(100), 18), - makerAssetData: await devUtils.encodeERC721AssetData.callAsync(erc721Token.address, makerAssetId), - takerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultTakerAssetAddress), + makerAssetData: await devUtils.encodeERC721AssetData(erc721Token.address, makerAssetId).callAsync(), + takerAssetData: await devUtils.encodeERC20AssetData(defaultTakerAssetAddress).callAsync(), }); // Call Exchange const takerAssetFillAmount = signedOrder.takerAssetAmount.div(2); @@ -802,12 +784,12 @@ blockchainTests.resets('Exchange core', () => { it('should allow multiple assets to be exchanged for a single asset', async () => { const makerAmounts = [new BigNumber(10), new BigNumber(20)]; const makerNestedAssetData = [ - await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address), - await devUtils.encodeERC20AssetData.callAsync(erc20TokenB.address), + await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(), + await devUtils.encodeERC20AssetData(erc20TokenB.address).callAsync(), ]; - const makerAssetData = await devUtils.encodeMultiAssetData.callAsync(makerAmounts, makerNestedAssetData); + const makerAssetData = await devUtils.encodeMultiAssetData(makerAmounts, makerNestedAssetData).callAsync(); const makerAssetAmount = new BigNumber(1); - const takerAssetData = await devUtils.encodeERC20AssetData.callAsync(feeToken.address); + const takerAssetData = await devUtils.encodeERC20AssetData(feeToken.address).callAsync(); const takerAssetAmount = new BigNumber(10); signedOrder = await orderFactory.newSignedOrderAsync({ makerAssetData, @@ -822,18 +804,18 @@ blockchainTests.resets('Exchange core', () => { it('should allow multiple assets to be exchanged for multiple assets', async () => { const makerAmounts = [new BigNumber(10), new BigNumber(20)]; const makerNestedAssetData = [ - await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address), - await devUtils.encodeERC20AssetData.callAsync(erc20TokenB.address), + await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(), + await devUtils.encodeERC20AssetData(erc20TokenB.address).callAsync(), ]; - const makerAssetData = await devUtils.encodeMultiAssetData.callAsync(makerAmounts, makerNestedAssetData); + const makerAssetData = await devUtils.encodeMultiAssetData(makerAmounts, makerNestedAssetData).callAsync(); const makerAssetAmount = new BigNumber(1); const takerAmounts = [new BigNumber(10), new BigNumber(1)]; const takerAssetId = erc721TakerAssetIds[0]; const takerNestedAssetData = [ - await devUtils.encodeERC20AssetData.callAsync(feeToken.address), - await devUtils.encodeERC721AssetData.callAsync(erc721Token.address, takerAssetId), + await devUtils.encodeERC20AssetData(feeToken.address).callAsync(), + await devUtils.encodeERC721AssetData(erc721Token.address, takerAssetId).callAsync(), ]; - const takerAssetData = await devUtils.encodeMultiAssetData.callAsync(takerAmounts, takerNestedAssetData); + const takerAssetData = await devUtils.encodeMultiAssetData(takerAmounts, takerNestedAssetData).callAsync(); const takerAssetAmount = new BigNumber(1); signedOrder = await orderFactory.newSignedOrderAsync({ makerAssetData, @@ -848,12 +830,12 @@ blockchainTests.resets('Exchange core', () => { it('should allow an order selling multiple assets to be partially filled', async () => { const makerAmounts = [new BigNumber(10), new BigNumber(20)]; const makerNestedAssetData = [ - await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address), - await devUtils.encodeERC20AssetData.callAsync(erc20TokenB.address), + await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(), + await devUtils.encodeERC20AssetData(erc20TokenB.address).callAsync(), ]; - const makerAssetData = await devUtils.encodeMultiAssetData.callAsync(makerAmounts, makerNestedAssetData); + const makerAssetData = await devUtils.encodeMultiAssetData(makerAmounts, makerNestedAssetData).callAsync(); const makerAssetAmount = new BigNumber(30); - const takerAssetData = await devUtils.encodeERC20AssetData.callAsync(feeToken.address); + const takerAssetData = await devUtils.encodeERC20AssetData(feeToken.address).callAsync(); const takerAssetAmount = new BigNumber(10); signedOrder = await orderFactory.newSignedOrderAsync({ makerAssetData, @@ -870,12 +852,12 @@ blockchainTests.resets('Exchange core', () => { it('should allow an order buying multiple assets to be partially filled', async () => { const takerAmounts = [new BigNumber(10), new BigNumber(20)]; const takerNestedAssetData = [ - await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address), - await devUtils.encodeERC20AssetData.callAsync(erc20TokenB.address), + await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(), + await devUtils.encodeERC20AssetData(erc20TokenB.address).callAsync(), ]; - const takerAssetData = await devUtils.encodeMultiAssetData.callAsync(takerAmounts, takerNestedAssetData); + const takerAssetData = await devUtils.encodeMultiAssetData(takerAmounts, takerNestedAssetData).callAsync(); const takerAssetAmount = new BigNumber(30); - const makerAssetData = await devUtils.encodeERC20AssetData.callAsync(feeToken.address); + const makerAssetData = await devUtils.encodeERC20AssetData(feeToken.address).callAsync(); const makerAssetAmount = new BigNumber(10); signedOrder = await orderFactory.newSignedOrderAsync({ makerAssetData, @@ -901,18 +883,22 @@ blockchainTests.resets('Exchange core', () => { const makerAssetAmount = new BigNumber(1); const takerAssetAmount = new BigNumber(1); const receiverCallbackData = '0x'; - const makerAssetData = await devUtils.encodeERC1155AssetData.callAsync( - erc1155Contract.address, - makerAssetsToTransfer, - makerValuesToTransfer, - receiverCallbackData, - ); - const takerAssetData = await devUtils.encodeERC1155AssetData.callAsync( - erc1155Contract.address, - takerAssetsToTransfer, - takerValuesToTransfer, - receiverCallbackData, - ); + const makerAssetData = await devUtils + .encodeERC1155AssetData( + erc1155Contract.address, + makerAssetsToTransfer, + makerValuesToTransfer, + receiverCallbackData, + ) + .callAsync(); + const takerAssetData = await devUtils + .encodeERC1155AssetData( + erc1155Contract.address, + takerAssetsToTransfer, + takerValuesToTransfer, + receiverCallbackData, + ) + .callAsync(); signedOrder = await orderFactory.newSignedOrderAsync({ makerAssetData, takerAssetData, @@ -936,18 +922,22 @@ blockchainTests.resets('Exchange core', () => { const makerAssetAmount = new BigNumber(1); const takerAssetAmount = new BigNumber(1); const receiverCallbackData = '0x'; - const makerAssetData = await devUtils.encodeERC1155AssetData.callAsync( - erc1155Contract.address, - makerAssetsToTransfer, - makerValuesToTransfer, - receiverCallbackData, - ); - const takerAssetData = await devUtils.encodeERC1155AssetData.callAsync( - erc1155Contract.address, - takerAssetsToTransfer, - takerValuesToTransfer, - receiverCallbackData, - ); + const makerAssetData = await devUtils + .encodeERC1155AssetData( + erc1155Contract.address, + makerAssetsToTransfer, + makerValuesToTransfer, + receiverCallbackData, + ) + .callAsync(); + const takerAssetData = await devUtils + .encodeERC1155AssetData( + erc1155Contract.address, + takerAssetsToTransfer, + takerValuesToTransfer, + receiverCallbackData, + ) + .callAsync(); signedOrder = await orderFactory.newSignedOrderAsync({ makerAssetData, takerAssetData, @@ -970,18 +960,22 @@ blockchainTests.resets('Exchange core', () => { const makerAssetAmount = new BigNumber(1); const takerAssetAmount = new BigNumber(1); const receiverCallbackData = '0x'; - const makerAssetData = await devUtils.encodeERC1155AssetData.callAsync( - erc1155Contract.address, - makerAssetsToTransfer, - makerValuesToTransfer, - receiverCallbackData, - ); - const takerAssetData = await devUtils.encodeERC1155AssetData.callAsync( - erc1155Contract.address, - takerAssetsToTransfer, - takerValuesToTransfer, - receiverCallbackData, - ); + const makerAssetData = await devUtils + .encodeERC1155AssetData( + erc1155Contract.address, + makerAssetsToTransfer, + makerValuesToTransfer, + receiverCallbackData, + ) + .callAsync(); + const takerAssetData = await devUtils + .encodeERC1155AssetData( + erc1155Contract.address, + takerAssetsToTransfer, + takerValuesToTransfer, + receiverCallbackData, + ) + .callAsync(); signedOrder = await orderFactory.newSignedOrderAsync({ makerAssetData, takerAssetData, @@ -1010,18 +1004,22 @@ blockchainTests.resets('Exchange core', () => { const makerAssetAmount = new BigNumber(1); const takerAssetAmount = new BigNumber(1); const receiverCallbackData = '0x'; - const makerAssetData = await devUtils.encodeERC1155AssetData.callAsync( - erc1155Contract.address, - makerAssetsToTransfer, - makerValuesToTransfer, - receiverCallbackData, - ); - const takerAssetData = await devUtils.encodeERC1155AssetData.callAsync( - erc1155Contract.address, - takerAssetsToTransfer, - takerValuesToTransfer, - receiverCallbackData, - ); + const makerAssetData = await devUtils + .encodeERC1155AssetData( + erc1155Contract.address, + makerAssetsToTransfer, + makerValuesToTransfer, + receiverCallbackData, + ) + .callAsync(); + const takerAssetData = await devUtils + .encodeERC1155AssetData( + erc1155Contract.address, + takerAssetsToTransfer, + takerValuesToTransfer, + receiverCallbackData, + ) + .callAsync(); signedOrder = await orderFactory.newSignedOrderAsync({ makerAssetData, takerAssetData, @@ -1055,18 +1053,22 @@ blockchainTests.resets('Exchange core', () => { const makerAssetAmount = new BigNumber(10); const takerAssetAmount = new BigNumber(20); const receiverCallbackData = '0x'; - const makerAssetData = await devUtils.encodeERC1155AssetData.callAsync( - erc1155Contract.address, - makerAssetsToTransfer, - makerValuesToTransfer, - receiverCallbackData, - ); - const takerAssetData = await devUtils.encodeERC1155AssetData.callAsync( - erc1155Contract.address, - takerAssetsToTransfer, - takerValuesToTransfer, - receiverCallbackData, - ); + const makerAssetData = await devUtils + .encodeERC1155AssetData( + erc1155Contract.address, + makerAssetsToTransfer, + makerValuesToTransfer, + receiverCallbackData, + ) + .callAsync(); + const takerAssetData = await devUtils + .encodeERC1155AssetData( + erc1155Contract.address, + takerAssetsToTransfer, + takerValuesToTransfer, + receiverCallbackData, + ) + .callAsync(); signedOrder = await orderFactory.newSignedOrderAsync({ makerAssetData, takerAssetData, @@ -1091,12 +1093,10 @@ blockchainTests.resets('Exchange core', () => { ); }); it('should revert if the staticcall is unsuccessful', async () => { - const staticCallData = staticCallTarget.assertEvenNumber.getABIEncodedTransactionData(new BigNumber(1)); - const assetData = await devUtils.encodeStaticCallAssetData.callAsync( - staticCallTarget.address, - staticCallData, - constants.KECCAK256_NULL, - ); + const staticCallData = staticCallTarget.assertEvenNumber(new BigNumber(1)).getABIEncodedTransactionData(); + const assetData = await devUtils + .encodeStaticCallAssetData(staticCallTarget.address, staticCallData, constants.KECCAK256_NULL) + .callAsync(); signedOrder = await orderFactory.newSignedOrderAsync({ makerAssetData: assetData }); const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder); const expectedError = new ExchangeRevertErrors.AssetProxyTransferError( @@ -1108,28 +1108,26 @@ blockchainTests.resets('Exchange core', () => { return expect(tx).to.revertWith(expectedError); }); it('should fill the order if the staticcall is successful', async () => { - const staticCallData = staticCallTarget.assertEvenNumber.getABIEncodedTransactionData( - constants.ZERO_AMOUNT, - ); - const assetData = await devUtils.encodeStaticCallAssetData.callAsync( - staticCallTarget.address, - staticCallData, - constants.KECCAK256_NULL, - ); + const staticCallData = staticCallTarget + .assertEvenNumber(constants.ZERO_AMOUNT) + .getABIEncodedTransactionData(); + const assetData = await devUtils + .encodeStaticCallAssetData(staticCallTarget.address, staticCallData, constants.KECCAK256_NULL) + .callAsync(); signedOrder = await orderFactory.newSignedOrderAsync({ makerAssetData: assetData }); await fillOrderWrapper.fillOrderAndAssertEffectsAsync(signedOrder, takerAddress); }); it('should revert if the staticcall is unsuccessful using the MultiAssetProxy', async () => { - const staticCallData = staticCallTarget.assertEvenNumber.getABIEncodedTransactionData(new BigNumber(1)); - const staticCallAssetData = await devUtils.encodeStaticCallAssetData.callAsync( - staticCallTarget.address, - staticCallData, - constants.KECCAK256_NULL, - ); - const assetData = await devUtils.encodeMultiAssetData.callAsync( - [new BigNumber(1), new BigNumber(1)], - [await devUtils.encodeERC20AssetData.callAsync(defaultMakerAssetAddress), staticCallAssetData], - ); + const staticCallData = staticCallTarget.assertEvenNumber(new BigNumber(1)).getABIEncodedTransactionData(); + const staticCallAssetData = await devUtils + .encodeStaticCallAssetData(staticCallTarget.address, staticCallData, constants.KECCAK256_NULL) + .callAsync(); + const assetData = await devUtils + .encodeMultiAssetData( + [new BigNumber(1), new BigNumber(1)], + [await devUtils.encodeERC20AssetData(defaultMakerAssetAddress).callAsync(), staticCallAssetData], + ) + .callAsync(); signedOrder = await orderFactory.newSignedOrderAsync({ makerAssetData: assetData }); const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder); const expectedError = new ExchangeRevertErrors.AssetProxyTransferError( @@ -1141,18 +1139,18 @@ blockchainTests.resets('Exchange core', () => { return expect(tx).to.revertWith(expectedError); }); it('should fill the order is the staticcall is successful using the MultiAssetProxy', async () => { - const staticCallData = staticCallTarget.assertEvenNumber.getABIEncodedTransactionData( - constants.ZERO_AMOUNT, - ); - const staticCallAssetData = await devUtils.encodeStaticCallAssetData.callAsync( - staticCallTarget.address, - staticCallData, - constants.KECCAK256_NULL, - ); - const assetData = await devUtils.encodeMultiAssetData.callAsync( - [new BigNumber(1), new BigNumber(1)], - [await devUtils.encodeERC20AssetData.callAsync(defaultMakerAssetAddress), staticCallAssetData], - ); + const staticCallData = staticCallTarget + .assertEvenNumber(constants.ZERO_AMOUNT) + .getABIEncodedTransactionData(); + const staticCallAssetData = await devUtils + .encodeStaticCallAssetData(staticCallTarget.address, staticCallData, constants.KECCAK256_NULL) + .callAsync(); + const assetData = await devUtils + .encodeMultiAssetData( + [new BigNumber(1), new BigNumber(1)], + [await devUtils.encodeERC20AssetData(defaultMakerAssetAddress).callAsync(), staticCallAssetData], + ) + .callAsync(); signedOrder = await orderFactory.newSignedOrderAsync({ makerAssetData: assetData }); await fillOrderWrapper.fillOrderAndAssertEffectsAsync(signedOrder, takerAddress); }); diff --git a/contracts/exchange/test/dispatcher.ts b/contracts/exchange/test/dispatcher.ts index 067f3e2fac..a7794ad8ba 100644 --- a/contracts/exchange/test/dispatcher.ts +++ b/contracts/exchange/test/dispatcher.ts @@ -82,10 +82,10 @@ describe('AssetProxyDispatcher', () => { txDefaults, dependencyArtifacts, ); - await erc20Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(assetProxyDispatcher.address, { + await erc20Proxy.addAuthorizedAddress(assetProxyDispatcher.address).awaitTransactionSuccessAsync({ from: owner, }); - await erc721Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(assetProxyDispatcher.address, { + await erc721Proxy.addAuthorizedAddress(assetProxyDispatcher.address).awaitTransactionSuccessAsync({ from: owner, }); }); @@ -97,34 +97,34 @@ describe('AssetProxyDispatcher', () => { }); describe('registerAssetProxy', () => { it('should record proxy upon registration', async () => { - await assetProxyDispatcher.registerAssetProxy.awaitTransactionSuccessAsync(erc20Proxy.address, { + await assetProxyDispatcher.registerAssetProxy(erc20Proxy.address).awaitTransactionSuccessAsync({ from: owner, }); - const proxyAddress = await assetProxyDispatcher.getAssetProxy.callAsync(AssetProxyId.ERC20); + const proxyAddress = await assetProxyDispatcher.getAssetProxy(AssetProxyId.ERC20).callAsync(); expect(proxyAddress).to.be.equal(erc20Proxy.address); }); it('should be able to record multiple proxies', async () => { // Record first proxy - await assetProxyDispatcher.registerAssetProxy.awaitTransactionSuccessAsync(erc20Proxy.address, { + await assetProxyDispatcher.registerAssetProxy(erc20Proxy.address).awaitTransactionSuccessAsync({ from: owner, }); - let proxyAddress = await assetProxyDispatcher.getAssetProxy.callAsync(AssetProxyId.ERC20); + let proxyAddress = await assetProxyDispatcher.getAssetProxy(AssetProxyId.ERC20).callAsync(); expect(proxyAddress).to.be.equal(erc20Proxy.address); // Record another proxy - await assetProxyDispatcher.registerAssetProxy.awaitTransactionSuccessAsync(erc721Proxy.address, { + await assetProxyDispatcher.registerAssetProxy(erc721Proxy.address).awaitTransactionSuccessAsync({ from: owner, }); - proxyAddress = await assetProxyDispatcher.getAssetProxy.callAsync(AssetProxyId.ERC721); + proxyAddress = await assetProxyDispatcher.getAssetProxy(AssetProxyId.ERC721).callAsync(); expect(proxyAddress).to.be.equal(erc721Proxy.address); }); it('should revert if a proxy with the same id is already registered', async () => { // Initial registration - await assetProxyDispatcher.registerAssetProxy.awaitTransactionSuccessAsync(erc20Proxy.address, { + await assetProxyDispatcher.registerAssetProxy(erc20Proxy.address).awaitTransactionSuccessAsync({ from: owner, }); - const proxyAddress = await assetProxyDispatcher.getAssetProxy.callAsync(AssetProxyId.ERC20); + const proxyAddress = await assetProxyDispatcher.getAssetProxy(AssetProxyId.ERC20).callAsync(); expect(proxyAddress).to.be.equal(erc20Proxy.address); // Deploy a new version of the ERC20 Transfer Proxy contract const newErc20TransferProxy = await ERC20ProxyContract.deployFrom0xArtifactAsync( @@ -134,7 +134,7 @@ describe('AssetProxyDispatcher', () => { dependencyArtifacts, ); const expectedError = new ExchangeRevertErrors.AssetProxyExistsError(AssetProxyId.ERC20, proxyAddress); - const tx = assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(newErc20TransferProxy.address, { + const tx = assetProxyDispatcher.registerAssetProxy(newErc20TransferProxy.address).sendTransactionAsync({ from: owner, }); return expect(tx).to.revertWith(expectedError); @@ -142,7 +142,7 @@ describe('AssetProxyDispatcher', () => { it('should revert if requesting address is not owner', async () => { const expectedError = new OwnableRevertErrors.OnlyOwnerError(notOwner, owner); - const tx = assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(erc20Proxy.address, { + const tx = assetProxyDispatcher.registerAssetProxy(erc20Proxy.address).sendTransactionAsync({ from: notOwner, }); return expect(tx).to.revertWith(expectedError); @@ -150,7 +150,7 @@ describe('AssetProxyDispatcher', () => { it('should revert if the proxy is not a contract address', async () => { const errMessage = 'VM Exception while processing transaction: revert'; - const tx = assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(notOwner, { + const tx = assetProxyDispatcher.registerAssetProxy(notOwner).sendTransactionAsync({ from: owner, }); return expect(tx).to.be.rejectedWith(errMessage); @@ -159,7 +159,7 @@ describe('AssetProxyDispatcher', () => { it('should log an event with correct arguments when an asset proxy is registered', async () => { const logDecoder = new LogDecoder(web3Wrapper, artifacts); const txReceipt = await logDecoder.getTxWithDecodedLogsAsync( - await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(erc20Proxy.address, { + await assetProxyDispatcher.registerAssetProxy(erc20Proxy.address).sendTransactionAsync({ from: owner, }), ); @@ -172,15 +172,15 @@ describe('AssetProxyDispatcher', () => { describe('getAssetProxy', () => { it('should return correct address of registered proxy', async () => { - await assetProxyDispatcher.registerAssetProxy.awaitTransactionSuccessAsync(erc20Proxy.address, { + await assetProxyDispatcher.registerAssetProxy(erc20Proxy.address).awaitTransactionSuccessAsync({ from: owner, }); - const proxyAddress = await assetProxyDispatcher.getAssetProxy.callAsync(AssetProxyId.ERC20); + const proxyAddress = await assetProxyDispatcher.getAssetProxy(AssetProxyId.ERC20).callAsync(); expect(proxyAddress).to.be.equal(erc20Proxy.address); }); it('should return NULL address if requesting non-existent proxy', async () => { - const proxyAddress = await assetProxyDispatcher.getAssetProxy.callAsync(AssetProxyId.ERC20); + const proxyAddress = await assetProxyDispatcher.getAssetProxy(AssetProxyId.ERC20).callAsync(); expect(proxyAddress).to.be.equal(constants.NULL_ADDRESS); }); }); @@ -189,23 +189,18 @@ describe('AssetProxyDispatcher', () => { const orderHash = orderUtils.generatePseudoRandomOrderHash(); it('should dispatch transfer to registered proxy', async () => { // Register ERC20 proxy - await assetProxyDispatcher.registerAssetProxy.awaitTransactionSuccessAsync(erc20Proxy.address, { + await assetProxyDispatcher.registerAssetProxy(erc20Proxy.address).awaitTransactionSuccessAsync({ from: owner, }); // Construct metadata for ERC20 proxy - const encodedAssetData = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); + const encodedAssetData = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); // Perform a transfer from makerAddress to takerAddress const erc20Balances = await erc20Wrapper.getBalancesAsync(); const amount = new BigNumber(10); - await assetProxyDispatcher.dispatchTransferFrom.awaitTransactionSuccessAsync( - orderHash, - encodedAssetData, - makerAddress, - takerAddress, - amount, - { from: owner }, - ); + await assetProxyDispatcher + .dispatchTransferFrom(orderHash, encodedAssetData, makerAddress, takerAddress, amount) + .awaitTransactionSuccessAsync({ from: owner }); // Verify transfer was successful const newBalances = await erc20Wrapper.getBalancesAsync(); expect(newBalances[makerAddress][erc20TokenA.address]).to.be.bignumber.equal( @@ -218,23 +213,18 @@ describe('AssetProxyDispatcher', () => { it('should not dispatch a transfer if amount == 0', async () => { // Register ERC20 proxy - await assetProxyDispatcher.registerAssetProxy.awaitTransactionSuccessAsync(erc20Proxy.address, { + await assetProxyDispatcher.registerAssetProxy(erc20Proxy.address).awaitTransactionSuccessAsync({ from: owner, }); // Construct metadata for ERC20 proxy - const encodedAssetData = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); + const encodedAssetData = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); // Perform a transfer from makerAddress to takerAddress const erc20Balances = await erc20Wrapper.getBalancesAsync(); const amount = constants.ZERO_AMOUNT; - const txReceipt = await assetProxyDispatcher.dispatchTransferFrom.awaitTransactionSuccessAsync( - orderHash, - encodedAssetData, - makerAddress, - takerAddress, - amount, - { from: owner }, - ); + const txReceipt = await assetProxyDispatcher + .dispatchTransferFrom(orderHash, encodedAssetData, makerAddress, takerAddress, amount) + .awaitTransactionSuccessAsync({ from: owner }); expect(txReceipt.logs.length).to.be.equal(0); const newBalances = await erc20Wrapper.getBalancesAsync(); expect(newBalances).to.deep.equal(erc20Balances); @@ -242,7 +232,7 @@ describe('AssetProxyDispatcher', () => { it('should revert if dispatching to unregistered proxy', async () => { // Construct metadata for ERC20 proxy - const encodedAssetData = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); + const encodedAssetData = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); // Perform a transfer from makerAddress to takerAddress const amount = new BigNumber(10); @@ -251,70 +241,58 @@ describe('AssetProxyDispatcher', () => { orderHash, encodedAssetData, ); - const tx = assetProxyDispatcher.dispatchTransferFrom.sendTransactionAsync( - orderHash, - encodedAssetData, - makerAddress, - takerAddress, - amount, - { from: owner }, - ); + const tx = assetProxyDispatcher + .dispatchTransferFrom(orderHash, encodedAssetData, makerAddress, takerAddress, amount) + .sendTransactionAsync({ from: owner }); return expect(tx).to.revertWith(expectedError); }); it('should revert with the correct error when assetData length < 4 bytes', async () => { - await assetProxyDispatcher.registerAssetProxy.awaitTransactionSuccessAsync(erc20Proxy.address, { + await assetProxyDispatcher.registerAssetProxy(erc20Proxy.address).awaitTransactionSuccessAsync({ from: owner, }); - const encodedAssetData = (await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address)).slice(0, 8); + const encodedAssetData = (await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync()).slice(0, 8); const amount = new BigNumber(1); const expectedError = new ExchangeRevertErrors.AssetProxyDispatchError( ExchangeRevertErrors.AssetProxyDispatchErrorCode.InvalidAssetDataLength, orderHash, encodedAssetData, ); - const tx = assetProxyDispatcher.dispatchTransferFrom.sendTransactionAsync( - orderHash, - encodedAssetData, - makerAddress, - takerAddress, - amount, - { from: owner }, - ); + const tx = assetProxyDispatcher + .dispatchTransferFrom(orderHash, encodedAssetData, makerAddress, takerAddress, amount) + .sendTransactionAsync({ from: owner }); return expect(tx).to.revertWith(expectedError); }); it('should revert if assetData is not padded to 32 bytes (excluding the id)', async () => { - await assetProxyDispatcher.registerAssetProxy.awaitTransactionSuccessAsync(erc20Proxy.address, { + await assetProxyDispatcher.registerAssetProxy(erc20Proxy.address).awaitTransactionSuccessAsync({ from: owner, }); // Shave off the last byte - const encodedAssetData = (await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address)).slice(0, 72); + const encodedAssetData = (await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync()).slice( + 0, + 72, + ); const amount = new BigNumber(1); const expectedError = new ExchangeRevertErrors.AssetProxyDispatchError( ExchangeRevertErrors.AssetProxyDispatchErrorCode.InvalidAssetDataLength, orderHash, encodedAssetData, ); - const tx = assetProxyDispatcher.dispatchTransferFrom.sendTransactionAsync( - orderHash, - encodedAssetData, - makerAddress, - takerAddress, - amount, - { from: owner }, - ); + const tx = assetProxyDispatcher + .dispatchTransferFrom(orderHash, encodedAssetData, makerAddress, takerAddress, amount) + .sendTransactionAsync({ from: owner }); return expect(tx).to.revertWith(expectedError); }); it('should revert with the reason provided by the AssetProxy when a transfer fails', async () => { - await assetProxyDispatcher.registerAssetProxy.awaitTransactionSuccessAsync(erc20Proxy.address, { + await assetProxyDispatcher.registerAssetProxy(erc20Proxy.address).awaitTransactionSuccessAsync({ from: owner, }); - await erc20TokenA.approve.awaitTransactionSuccessAsync(erc20Proxy.address, constants.ZERO_AMOUNT, { + await erc20TokenA.approve(erc20Proxy.address, constants.ZERO_AMOUNT).awaitTransactionSuccessAsync({ from: makerAddress, }); - const encodedAssetData = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); + const encodedAssetData = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); const amount = new BigNumber(1); const nestedError = new StringRevertError(RevertReason.TransferFailed).encode(); const expectedError = new ExchangeRevertErrors.AssetProxyTransferError( @@ -322,25 +300,20 @@ describe('AssetProxyDispatcher', () => { encodedAssetData, nestedError, ); - const tx = assetProxyDispatcher.dispatchTransferFrom.sendTransactionAsync( - orderHash, - encodedAssetData, - makerAddress, - takerAddress, - amount, - { from: owner }, - ); + const tx = assetProxyDispatcher + .dispatchTransferFrom(orderHash, encodedAssetData, makerAddress, takerAddress, amount) + .sendTransactionAsync({ from: owner }); return expect(tx).to.revertWith(expectedError); }); }); describe('simulateDispatchTransferFromCalls', () => { it('should revert with the information specific to the failed transfer', async () => { - await assetProxyDispatcher.registerAssetProxy.awaitTransactionSuccessAsync(erc20Proxy.address, { + await assetProxyDispatcher.registerAssetProxy(erc20Proxy.address).awaitTransactionSuccessAsync({ from: owner, }); - const assetDataA = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); - const assetDataB = await devUtils.encodeERC20AssetData.callAsync(erc20TokenB.address); - await erc20TokenB.approve.awaitTransactionSuccessAsync(erc20Proxy.address, constants.ZERO_AMOUNT, { + const assetDataA = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); + const assetDataB = await devUtils.encodeERC20AssetData(erc20TokenB.address).callAsync(); + await erc20TokenB.approve(erc20Proxy.address, constants.ZERO_AMOUNT).awaitTransactionSuccessAsync({ from: makerAddress, }); const transferIndexAsBytes32 = '0x0000000000000000000000000000000000000000000000000000000000000001'; @@ -350,59 +323,67 @@ describe('AssetProxyDispatcher', () => { assetDataB, nestedError, ); - const tx = assetProxyDispatcher.simulateDispatchTransferFromCalls.sendTransactionAsync( - [assetDataA, assetDataB], - [makerAddress, makerAddress], - [takerAddress, takerAddress], - [new BigNumber(1), new BigNumber(1)], - ); + const tx = assetProxyDispatcher + .simulateDispatchTransferFromCalls( + [assetDataA, assetDataB], + [makerAddress, makerAddress], + [takerAddress, takerAddress], + [new BigNumber(1), new BigNumber(1)], + ) + .sendTransactionAsync(); return expect(tx).to.revertWith(expectedError); }); it('should forward the revert reason from the underlying failed transfer', async () => { - const assetDataA = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); - const assetDataB = await devUtils.encodeERC20AssetData.callAsync(erc20TokenB.address); + const assetDataA = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); + const assetDataB = await devUtils.encodeERC20AssetData(erc20TokenB.address).callAsync(); const transferIndexAsBytes32 = '0x0000000000000000000000000000000000000000000000000000000000000000'; const expectedError = new ExchangeRevertErrors.AssetProxyDispatchError( ExchangeRevertErrors.AssetProxyDispatchErrorCode.UnknownAssetProxy, transferIndexAsBytes32, assetDataA, ); - const tx = assetProxyDispatcher.simulateDispatchTransferFromCalls.sendTransactionAsync( - [assetDataA, assetDataB], - [makerAddress, makerAddress], - [takerAddress, takerAddress], - [new BigNumber(1), new BigNumber(1)], - ); + const tx = assetProxyDispatcher + .simulateDispatchTransferFromCalls( + [assetDataA, assetDataB], + [makerAddress, makerAddress], + [takerAddress, takerAddress], + [new BigNumber(1), new BigNumber(1)], + ) + .sendTransactionAsync(); return expect(tx).to.revertWith(expectedError); }); it('should revert with TRANSFERS_SUCCESSFUL if no transfers fail', async () => { - await assetProxyDispatcher.registerAssetProxy.awaitTransactionSuccessAsync(erc20Proxy.address, { + await assetProxyDispatcher.registerAssetProxy(erc20Proxy.address).awaitTransactionSuccessAsync({ from: owner, }); - const assetDataA = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); - const assetDataB = await devUtils.encodeERC20AssetData.callAsync(erc20TokenB.address); - const tx = assetProxyDispatcher.simulateDispatchTransferFromCalls.sendTransactionAsync( - [assetDataA, assetDataB], - [makerAddress, makerAddress], - [takerAddress, takerAddress], - [new BigNumber(1), new BigNumber(1)], - ); + const assetDataA = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); + const assetDataB = await devUtils.encodeERC20AssetData(erc20TokenB.address).callAsync(); + const tx = assetProxyDispatcher + .simulateDispatchTransferFromCalls( + [assetDataA, assetDataB], + [makerAddress, makerAddress], + [takerAddress, takerAddress], + [new BigNumber(1), new BigNumber(1)], + ) + .sendTransactionAsync(); return expect(tx).to.revertWith(RevertReason.TransfersSuccessful); }); it('should not modify balances if all transfers are successful', async () => { - await assetProxyDispatcher.registerAssetProxy.awaitTransactionSuccessAsync(erc20Proxy.address, { + await assetProxyDispatcher.registerAssetProxy(erc20Proxy.address).awaitTransactionSuccessAsync({ from: owner, }); - const assetDataA = await devUtils.encodeERC20AssetData.callAsync(erc20TokenA.address); - const assetDataB = await devUtils.encodeERC20AssetData.callAsync(erc20TokenB.address); + const assetDataA = await devUtils.encodeERC20AssetData(erc20TokenA.address).callAsync(); + const assetDataB = await devUtils.encodeERC20AssetData(erc20TokenB.address).callAsync(); const balances = await erc20Wrapper.getBalancesAsync(); try { - await assetProxyDispatcher.simulateDispatchTransferFromCalls.awaitTransactionSuccessAsync( - [assetDataA, assetDataB], - [makerAddress, makerAddress], - [takerAddress, takerAddress], - [new BigNumber(1), new BigNumber(1)], - ); + await assetProxyDispatcher + .simulateDispatchTransferFromCalls( + [assetDataA, assetDataB], + [makerAddress, makerAddress], + [takerAddress, takerAddress], + [new BigNumber(1), new BigNumber(1)], + ) + .awaitTransactionSuccessAsync(); } catch (err) { const newBalances = await erc20Wrapper.getBalancesAsync(); expect(newBalances).to.deep.equal(balances); diff --git a/contracts/exchange/test/internal.ts b/contracts/exchange/test/internal.ts index 9713714774..8507b35937 100644 --- a/contracts/exchange/test/internal.ts +++ b/contracts/exchange/test/internal.ts @@ -1,5 +1,5 @@ import { ReferenceFunctions as LibReferenceFunctions } from '@0x/contracts-exchange-libs'; -import { blockchainTests, constants, expect, hexRandom, LogDecoder } from '@0x/contracts-test-utils'; +import { blockchainTests, constants, expect, hexRandom } from '@0x/contracts-test-utils'; import { ExchangeRevertErrors, orderHashUtils } from '@0x/order-utils'; import { Order } from '@0x/types'; import { BigNumber, SafeMathRevertErrors } from '@0x/utils'; @@ -21,7 +21,6 @@ blockchainTests('Exchange core internal functions', env => { const randomHash = () => hexRandom(constants.WORD_LENGTH); const randomAssetData = () => hexRandom(36); let testExchange: TestExchangeInternalsContract; - let logDecoder: LogDecoder; let senderAddress: string; const DEFAULT_PROTOCOL_MULTIPLIER = new BigNumber(150000); const DEFAULT_GAS_PRICE = new BigNumber(200000); @@ -37,7 +36,6 @@ blockchainTests('Exchange core internal functions', env => { {}, new BigNumber(CHAIN_ID), ); - logDecoder = new LogDecoder(env.web3Wrapper, artifacts); }); blockchainTests('assertValidMatch', () => { @@ -82,7 +80,9 @@ blockchainTests('Exchange core internal functions', env => { leftOrder.makerAssetAmount, rightOrder.makerAssetAmount, ); - return expect(testExchange.assertValidMatch.callAsync(leftOrder, rightOrder)).to.revertWith(expectedError); + return expect(testExchange.assertValidMatch(leftOrder, rightOrder).callAsync()).to.revertWith( + expectedError, + ); }); it('should revert if the taker asset multiplication should overflow', async () => { @@ -99,7 +99,9 @@ blockchainTests('Exchange core internal functions', env => { leftOrder.takerAssetAmount, rightOrder.takerAssetAmount, ); - return expect(testExchange.assertValidMatch.callAsync(leftOrder, rightOrder)).to.revertWith(expectedError); + return expect(testExchange.assertValidMatch(leftOrder, rightOrder).callAsync()).to.revertWith( + expectedError, + ); }); it('should revert if the prices of the left order is less than the price of the right order', async () => { @@ -114,7 +116,9 @@ blockchainTests('Exchange core internal functions', env => { const orderHashHexLeft = orderHashUtils.getOrderHashHex(leftOrder); const orderHashHexRight = orderHashUtils.getOrderHashHex(rightOrder); const expectedError = new ExchangeRevertErrors.NegativeSpreadError(orderHashHexLeft, orderHashHexRight); - return expect(testExchange.assertValidMatch.callAsync(leftOrder, rightOrder)).to.revertWith(expectedError); + return expect(testExchange.assertValidMatch(leftOrder, rightOrder).callAsync()).to.revertWith( + expectedError, + ); }); it('should succeed if the prices of the left and right orders are equal', async () => { @@ -126,7 +130,7 @@ blockchainTests('Exchange core internal functions', env => { makerAssetAmount: Web3Wrapper.toBaseUnitAmount(100, 18), takerAssetAmount: Web3Wrapper.toBaseUnitAmount(50, 18), }); - return expect(testExchange.assertValidMatch.callAsync(leftOrder, rightOrder)).to.be.fulfilled(''); + return expect(testExchange.assertValidMatch(leftOrder, rightOrder).callAsync()).to.be.fulfilled(''); }); it('should succeed if the price of the left order is higher than the price of the right', async () => { @@ -138,7 +142,7 @@ blockchainTests('Exchange core internal functions', env => { makerAssetAmount: Web3Wrapper.toBaseUnitAmount(100, 18), takerAssetAmount: Web3Wrapper.toBaseUnitAmount(50, 18), }); - return expect(testExchange.assertValidMatch.callAsync(leftOrder, rightOrder)).to.be.fulfilled(''); + return expect(testExchange.assertValidMatch(leftOrder, rightOrder).callAsync()).to.be.fulfilled(''); }); }); @@ -185,17 +189,12 @@ blockchainTests('Exchange core internal functions', env => { // CAll `testUpdateFilledState()`, which will set the `filled` // state for this order to `orderTakerAssetFilledAmount` before // calling `_updateFilledState()`. - const receipt = await logDecoder.getTxWithDecodedLogsAsync( - await testExchange.testUpdateFilledState.sendTransactionAsync( - order, - takerAddress, - orderHash, - orderTakerAssetFilledAmount, - fillResults, - ), - ); + const receipt = await testExchange + .testUpdateFilledState(order, takerAddress, orderHash, orderTakerAssetFilledAmount, fillResults) + .awaitTransactionSuccessAsync(); + // Grab the new `filled` state for this order. - const actualFilledState = await testExchange.filled.callAsync(orderHash); + const actualFilledState = await testExchange.filled(orderHash).callAsync(); // Assert the `filled` state for this order. expect(actualFilledState).to.bignumber.eq(expectedFilledState); // Assert the logs. @@ -247,13 +246,15 @@ blockchainTests('Exchange core internal functions', env => { takerAssetFillAmount, ); return expect( - testExchange.testUpdateFilledState.awaitTransactionSuccessAsync( - order, - randomAddress(), - randomHash(), - orderTakerAssetFilledAmount, - fillResults, - ), + testExchange + .testUpdateFilledState( + order, + randomAddress(), + randomHash(), + orderTakerAssetFilledAmount, + fillResults, + ) + .awaitTransactionSuccessAsync(), ).to.revertWith(expectedError); }); }); @@ -287,9 +288,9 @@ blockchainTests('Exchange core internal functions', env => { takerFeePaid: ONE_ETHER.times(0.025), protocolFeePaid: constants.ZERO_AMOUNT, }; - const receipt = await logDecoder.getTxWithDecodedLogsAsync( - await testExchange.settleOrder.sendTransactionAsync(orderHash, order, takerAddress, fillResults), - ); + const receipt = await testExchange + .settleOrder(orderHash, order, takerAddress, fillResults) + .awaitTransactionSuccessAsync(); const logs = receipt.logs as Array< LogWithDecodedArgs >; @@ -380,14 +381,16 @@ blockchainTests('Exchange core internal functions', env => { ); // Ensure that the call to `settleMatchOrders()` fails with the expected error. - const tx = testExchange.settleMatchOrders.sendTransactionAsync( - leftOrderHash, - rightOrderHash, - leftOrder, - rightOrder, - takerAddress, - matchedFillResults, - ); + const tx = testExchange + .settleMatchOrders( + leftOrderHash, + rightOrderHash, + leftOrder, + rightOrder, + takerAddress, + matchedFillResults, + ) + .sendTransactionAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -419,14 +422,16 @@ blockchainTests('Exchange core internal functions', env => { // The call to `settleMatchOrders()` should be successful. return expect( - testExchange.settleMatchOrders.sendTransactionAsync( - leftOrderHash, - rightOrderHash, - leftOrder, - rightOrder, - takerAddress, - matchedFillResults, - ), + testExchange + .settleMatchOrders( + leftOrderHash, + rightOrderHash, + leftOrder, + rightOrder, + takerAddress, + matchedFillResults, + ) + .sendTransactionAsync(), ).to.be.fulfilled(''); }); @@ -460,16 +465,16 @@ blockchainTests('Exchange core internal functions', env => { rightOrder.takerFeeAssetData = leftOrder.takerFeeAssetData; // Call settleMatchOrders and collect the logs - const receipt = await logDecoder.getTxWithDecodedLogsAsync( - await testExchange.settleMatchOrders.sendTransactionAsync( + const receipt = await testExchange + .settleMatchOrders( leftOrderHash, rightOrderHash, leftOrder, rightOrder, takerAddress, matchedFillResults, - ), - ); + ) + .awaitTransactionSuccessAsync(); const logs = receipt.logs as Array< LogWithDecodedArgs >; @@ -554,16 +559,16 @@ blockchainTests('Exchange core internal functions', env => { }; // Call settleMatchOrders and collect the logs - const receipt = await logDecoder.getTxWithDecodedLogsAsync( - await testExchange.settleMatchOrders.sendTransactionAsync( + const receipt = await testExchange + .settleMatchOrders( leftOrderHash, rightOrderHash, leftOrder, rightOrder, takerAddress, matchedFillResults, - ), - ); + ) + .awaitTransactionSuccessAsync(); const logs = receipt.logs as Array< LogWithDecodedArgs >; diff --git a/contracts/exchange/test/match_orders.ts b/contracts/exchange/test/match_orders.ts index e05aad4316..4065704366 100644 --- a/contracts/exchange/test/match_orders.ts +++ b/contracts/exchange/test/match_orders.ts @@ -143,28 +143,28 @@ describe('matchOrders', () => { await exchangeWrapper.registerAssetProxyAsync(erc1155Proxy.address, owner); await exchangeWrapper.registerAssetProxyAsync(multiAssetProxyContract.address, owner); // Authorize proxies. - await erc20Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(exchange.address, { from: owner }); - await erc721Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(exchange.address, { from: owner }); - await erc1155Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(exchange.address, { from: owner }); - await multiAssetProxyContract.addAuthorizedAddress.awaitTransactionSuccessAsync(exchange.address, { + await erc20Proxy.addAuthorizedAddress(exchange.address).awaitTransactionSuccessAsync({ from: owner }); + await erc721Proxy.addAuthorizedAddress(exchange.address).awaitTransactionSuccessAsync({ from: owner }); + await erc1155Proxy.addAuthorizedAddress(exchange.address).awaitTransactionSuccessAsync({ from: owner }); + await multiAssetProxyContract.addAuthorizedAddress(exchange.address).awaitTransactionSuccessAsync({ from: owner, }); - await erc20Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(multiAssetProxyContract.address, { + await erc20Proxy.addAuthorizedAddress(multiAssetProxyContract.address).awaitTransactionSuccessAsync({ from: owner, }); - await erc721Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(multiAssetProxyContract.address, { + await erc721Proxy.addAuthorizedAddress(multiAssetProxyContract.address).awaitTransactionSuccessAsync({ from: owner, }); - await erc1155Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(multiAssetProxyContract.address, { + await erc1155Proxy.addAuthorizedAddress(multiAssetProxyContract.address).awaitTransactionSuccessAsync({ from: owner, }); - await multiAssetProxyContract.registerAssetProxy.awaitTransactionSuccessAsync(erc20Proxy.address, { + await multiAssetProxyContract.registerAssetProxy(erc20Proxy.address).awaitTransactionSuccessAsync({ from: owner, }); - await multiAssetProxyContract.registerAssetProxy.awaitTransactionSuccessAsync(erc721Proxy.address, { + await multiAssetProxyContract.registerAssetProxy(erc721Proxy.address).awaitTransactionSuccessAsync({ from: owner, }); - await multiAssetProxyContract.registerAssetProxy.awaitTransactionSuccessAsync(erc1155Proxy.address, { + await multiAssetProxyContract.registerAssetProxy(erc1155Proxy.address).awaitTransactionSuccessAsync({ from: owner, }); @@ -179,10 +179,10 @@ describe('matchOrders', () => { const defaultOrderParamsLeft = { ...constants.STATIC_ORDER_PARAMS, makerAddress: makerAddressLeft, - makerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultERC20MakerAssetAddress), - takerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultERC20TakerAssetAddress), - makerFeeAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultFeeTokenAddress), - takerFeeAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultFeeTokenAddress), + makerAssetData: await devUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress).callAsync(), + takerAssetData: await devUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress).callAsync(), + makerFeeAssetData: await devUtils.encodeERC20AssetData(defaultFeeTokenAddress).callAsync(), + takerFeeAssetData: await devUtils.encodeERC20AssetData(defaultFeeTokenAddress).callAsync(), feeRecipientAddress: feeRecipientAddressLeft, exchangeAddress: exchange.address, chainId, @@ -190,10 +190,10 @@ describe('matchOrders', () => { const defaultOrderParamsRight = { ...constants.STATIC_ORDER_PARAMS, makerAddress: makerAddressRight, - makerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultERC20TakerAssetAddress), - takerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultERC20MakerAssetAddress), - makerFeeAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultFeeTokenAddress), - takerFeeAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultFeeTokenAddress), + makerAssetData: await devUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress).callAsync(), + takerAssetData: await devUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress).callAsync(), + makerFeeAssetData: await devUtils.encodeERC20AssetData(defaultFeeTokenAddress).callAsync(), + takerFeeAssetData: await devUtils.encodeERC20AssetData(defaultFeeTokenAddress).callAsync(), feeRecipientAddress: feeRecipientAddressRight, exchangeAddress: exchange.address, chainId, @@ -346,8 +346,8 @@ describe('matchOrders', () => { }); const signedOrderRight = await orderFactoryRight.newSignedOrderAsync({ makerAddress: makerAddressRight, - makerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultERC20TakerAssetAddress), - takerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultERC20MakerAssetAddress), + makerAssetData: await devUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress).callAsync(), + takerAssetData: await devUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress).callAsync(), makerAssetAmount: Web3Wrapper.toBaseUnitAmount(83, 0), takerAssetAmount: Web3Wrapper.toBaseUnitAmount(49, 0), feeRecipientAddress: feeRecipientAddressRight, @@ -400,8 +400,8 @@ describe('matchOrders', () => { }); const signedOrderRight = await orderFactoryRight.newSignedOrderAsync({ makerAddress: makerAddressRight, - makerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultERC20TakerAssetAddress), - takerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultERC20MakerAssetAddress), + makerAssetData: await devUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress).callAsync(), + takerAssetData: await devUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress).callAsync(), makerAssetAmount: Web3Wrapper.toBaseUnitAmount(89, 0), takerAssetAmount: Web3Wrapper.toBaseUnitAmount(1, 0), feeRecipientAddress: feeRecipientAddressRight, @@ -451,8 +451,8 @@ describe('matchOrders', () => { }); const signedOrderRight = await orderFactoryRight.newSignedOrderAsync({ makerAddress: makerAddressRight, - makerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultERC20TakerAssetAddress), - takerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultERC20MakerAssetAddress), + makerAssetData: await devUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress).callAsync(), + takerAssetData: await devUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress).callAsync(), makerAssetAmount: Web3Wrapper.toBaseUnitAmount(83, 0), takerAssetAmount: Web3Wrapper.toBaseUnitAmount(49, 0), feeRecipientAddress: feeRecipientAddressRight, @@ -500,8 +500,8 @@ describe('matchOrders', () => { }); const signedOrderRight = await orderFactoryRight.newSignedOrderAsync({ makerAddress: makerAddressRight, - makerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultERC20TakerAssetAddress), - takerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultERC20MakerAssetAddress), + makerAssetData: await devUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress).callAsync(), + takerAssetData: await devUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress).callAsync(), makerAssetAmount: Web3Wrapper.toBaseUnitAmount(89, 0), takerAssetAmount: Web3Wrapper.toBaseUnitAmount(1, 0), feeRecipientAddress: feeRecipientAddressRight, @@ -545,8 +545,8 @@ describe('matchOrders', () => { }); const signedOrderRight = await orderFactoryRight.newSignedOrderAsync({ makerAddress: makerAddressRight, - makerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultERC20TakerAssetAddress), - takerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultERC20MakerAssetAddress), + makerAssetData: await devUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress).callAsync(), + takerAssetData: await devUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress).callAsync(), makerAssetAmount: Web3Wrapper.toBaseUnitAmount(2126, 0), takerAssetAmount: Web3Wrapper.toBaseUnitAmount(1063, 0), feeRecipientAddress: feeRecipientAddressRight, @@ -1170,7 +1170,7 @@ describe('matchOrders', () => { const signedOrderLeft = await orderFactoryLeft.newSignedOrderAsync({ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(5, 18), takerAssetAmount: Web3Wrapper.toBaseUnitAmount(10, 18), - makerFeeAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultERC20TakerAssetAddress), + makerFeeAssetData: await devUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress).callAsync(), feeRecipientAddress: makerAddressLeft, }); const signedOrderRight = await orderFactoryRight.newSignedOrderAsync({ @@ -1267,7 +1267,7 @@ describe('matchOrders', () => { takerAssetAmount: Web3Wrapper.toBaseUnitAmount(10, 18), }); const signedOrderRight = await orderFactoryRight.newSignedOrderAsync({ - takerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultERC20TakerAssetAddress), + takerAssetData: await devUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress).callAsync(), makerAssetAmount: Web3Wrapper.toBaseUnitAmount(10, 18), takerAssetAmount: Web3Wrapper.toBaseUnitAmount(2, 18), }); @@ -1294,7 +1294,7 @@ describe('matchOrders', () => { it('should revert if the right maker asset is not equal to the left taker asset', async () => { // Create orders to match const signedOrderLeft = await orderFactoryLeft.newSignedOrderAsync({ - takerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultERC20MakerAssetAddress), + takerAssetData: await devUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress).callAsync(), makerAssetAmount: Web3Wrapper.toBaseUnitAmount(5, 18), takerAssetAmount: Web3Wrapper.toBaseUnitAmount(10, 18), }); @@ -1448,8 +1448,8 @@ describe('matchOrders', () => { }); const signedOrderRight = await orderFactoryRight.newSignedOrderAsync({ makerAddress: makerAddressRight, - makerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultERC20TakerAssetAddress), - takerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultERC20MakerAssetAddress), + makerAssetData: await devUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress).callAsync(), + takerAssetData: await devUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress).callAsync(), makerAssetAmount: Web3Wrapper.toBaseUnitAmount(87, 0), takerAssetAmount: Web3Wrapper.toBaseUnitAmount(48, 0), feeRecipientAddress: feeRecipientAddressRight, @@ -1536,8 +1536,8 @@ describe('matchOrders', () => { }); const signedOrderRight = await orderFactoryRight.newSignedOrderAsync({ makerAddress: makerAddressRight, - makerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultERC20TakerAssetAddress), - takerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultERC20MakerAssetAddress), + makerAssetData: await devUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress).callAsync(), + takerAssetData: await devUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress).callAsync(), makerAssetAmount: Web3Wrapper.toBaseUnitAmount(89, 0), takerAssetAmount: Web3Wrapper.toBaseUnitAmount(1, 0), feeRecipientAddress: feeRecipientAddressRight, @@ -1587,8 +1587,8 @@ describe('matchOrders', () => { }); const signedOrderRight = await orderFactoryRight.newSignedOrderAsync({ makerAddress: makerAddressRight, - makerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultERC20TakerAssetAddress), - takerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultERC20MakerAssetAddress), + makerAssetData: await devUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress).callAsync(), + takerAssetData: await devUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress).callAsync(), makerAssetAmount: Web3Wrapper.toBaseUnitAmount(87, 0), takerAssetAmount: Web3Wrapper.toBaseUnitAmount(48, 0), feeRecipientAddress: feeRecipientAddressRight, @@ -1633,8 +1633,8 @@ describe('matchOrders', () => { }); const signedOrderRight = await orderFactoryRight.newSignedOrderAsync({ makerAddress: makerAddressRight, - makerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultERC20TakerAssetAddress), - takerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultERC20MakerAssetAddress), + makerAssetData: await devUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress).callAsync(), + takerAssetData: await devUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress).callAsync(), makerAssetAmount: Web3Wrapper.toBaseUnitAmount(89, 0), takerAssetAmount: Web3Wrapper.toBaseUnitAmount(1, 0), feeRecipientAddress: feeRecipientAddressRight, @@ -1678,8 +1678,8 @@ describe('matchOrders', () => { }); const signedOrderRight = await orderFactoryRight.newSignedOrderAsync({ makerAddress: makerAddressRight, - makerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultERC20TakerAssetAddress), - takerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultERC20MakerAssetAddress), + makerAssetData: await devUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress).callAsync(), + takerAssetData: await devUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress).callAsync(), makerAssetAmount: Web3Wrapper.toBaseUnitAmount(89, 0), takerAssetAmount: Web3Wrapper.toBaseUnitAmount(1, 0), feeRecipientAddress: feeRecipientAddressRight, @@ -1797,8 +1797,8 @@ describe('matchOrders', () => { }); const signedOrderRight = await orderFactoryRight.newSignedOrderAsync({ makerAddress: makerAddressRight, - makerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultERC20TakerAssetAddress), - takerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultERC20MakerAssetAddress), + makerAssetData: await devUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress).callAsync(), + takerAssetData: await devUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress).callAsync(), makerAssetAmount: Web3Wrapper.toBaseUnitAmount(2126, 0), takerAssetAmount: Web3Wrapper.toBaseUnitAmount(1063, 0), feeRecipientAddress: feeRecipientAddressRight, @@ -2251,7 +2251,7 @@ describe('matchOrders', () => { const signedOrderLeft = await orderFactoryLeft.newSignedOrderAsync({ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(5, 18), takerAssetAmount: Web3Wrapper.toBaseUnitAmount(10, 18), - makerFeeAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultERC20TakerAssetAddress), + makerFeeAssetData: await devUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress).callAsync(), feeRecipientAddress: makerAddressLeft, }); const signedOrderRight = await orderFactoryRight.newSignedOrderAsync({ @@ -2348,7 +2348,7 @@ describe('matchOrders', () => { takerAssetAmount: Web3Wrapper.toBaseUnitAmount(10, 18), }); const signedOrderRight = await orderFactoryRight.newSignedOrderAsync({ - takerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultERC20TakerAssetAddress), + takerAssetData: await devUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress).callAsync(), makerAssetAmount: Web3Wrapper.toBaseUnitAmount(10, 18), takerAssetAmount: Web3Wrapper.toBaseUnitAmount(2, 18), }); @@ -2375,7 +2375,7 @@ describe('matchOrders', () => { it('should revert if the right maker asset is not equal to the left taker asset', async () => { // Create orders to match const signedOrderLeft = await orderFactoryLeft.newSignedOrderAsync({ - takerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultERC20MakerAssetAddress), + takerAssetData: await devUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress).callAsync(), makerAssetAmount: Web3Wrapper.toBaseUnitAmount(5, 18), takerAssetAmount: Web3Wrapper.toBaseUnitAmount(10, 18), }); @@ -2684,29 +2684,29 @@ describe('matchOrders', () => { let nameToMultiAssetAsset: { [name: string]: [BigNumber[], string[]] }; async function getAssetDataAsync(assetType: AssetType): Promise { - const encodeERC20AssetData = await devUtils.encodeERC20AssetData.callAsync; - const encodeERC721AssetData = await devUtils.encodeERC721AssetData.callAsync; - const encodeERC1155AssetData = await devUtils.encodeERC1155AssetData.callAsync; - const encodeMultiAssetData = await devUtils.encodeMultiAssetData.callAsync; if (nameToERC20Asset[assetType] !== undefined) { const tokenAddress = nameToERC20Asset[assetType]; - return encodeERC20AssetData(tokenAddress); + return devUtils.encodeERC20AssetData(tokenAddress).callAsync(); } if (nameToERC721Asset[assetType] !== undefined) { const [tokenAddress, tokenId] = nameToERC721Asset[assetType]; - return encodeERC721AssetData(tokenAddress, tokenId); + return devUtils.encodeERC721AssetData(tokenAddress, tokenId).callAsync(); } if (nameToERC1155FungibleAsset[assetType] !== undefined) { const [tokenAddress, tokenId] = nameToERC1155FungibleAsset[assetType]; - return encodeERC1155AssetData(tokenAddress, [tokenId], [ONE], constants.NULL_BYTES); + return devUtils + .encodeERC1155AssetData(tokenAddress, [tokenId], [ONE], constants.NULL_BYTES) + .callAsync(); } if (nameToERC1155NonFungibleAsset[assetType] !== undefined) { const [tokenAddress, tokenId] = nameToERC1155NonFungibleAsset[assetType]; - return encodeERC1155AssetData(tokenAddress, [tokenId], [ONE], constants.NULL_BYTES); + return devUtils + .encodeERC1155AssetData(tokenAddress, [tokenId], [ONE], constants.NULL_BYTES) + .callAsync(); } if (nameToMultiAssetAsset[assetType] !== undefined) { const [amounts, nestedAssetData] = nameToMultiAssetAsset[assetType]; - return encodeMultiAssetData(amounts, nestedAssetData); + return devUtils.encodeMultiAssetData(amounts, nestedAssetData).callAsync(); } throw new Error(`Unknown asset type: ${assetType}`); } @@ -2752,49 +2752,57 @@ describe('matchOrders', () => { MULTI_ASSET_A: [ [ONE, TWO], [ - await devUtils.encodeERC20AssetData.callAsync(erc20Tokens[0].address), - await devUtils.encodeERC1155AssetData.callAsync( - defaultERC1155AssetAddress, - [erc1155FungibleTokens[0]], - [ONE], - constants.NULL_BYTES, - ), + await devUtils.encodeERC20AssetData(erc20Tokens[0].address).callAsync(), + await devUtils + .encodeERC1155AssetData( + defaultERC1155AssetAddress, + [erc1155FungibleTokens[0]], + [ONE], + constants.NULL_BYTES, + ) + .callAsync(), ], ], MULTI_ASSET_B: [ [ONE, TWO], [ - await devUtils.encodeERC20AssetData.callAsync(erc20Tokens[1].address), - await devUtils.encodeERC1155AssetData.callAsync( - defaultERC1155AssetAddress, - [erc1155FungibleTokens[1]], - [ONE], - constants.NULL_BYTES, - ), + await devUtils.encodeERC20AssetData(erc20Tokens[1].address).callAsync(), + await devUtils + .encodeERC1155AssetData( + defaultERC1155AssetAddress, + [erc1155FungibleTokens[1]], + [ONE], + constants.NULL_BYTES, + ) + .callAsync(), ], ], MULTI_ASSET_C: [ [ONE, TWO], [ - await devUtils.encodeERC20AssetData.callAsync(erc20Tokens[2].address), - await devUtils.encodeERC1155AssetData.callAsync( - defaultERC1155AssetAddress, - [erc1155FungibleTokens[2]], - [ONE], - constants.NULL_BYTES, - ), + await devUtils.encodeERC20AssetData(erc20Tokens[2].address).callAsync(), + await devUtils + .encodeERC1155AssetData( + defaultERC1155AssetAddress, + [erc1155FungibleTokens[2]], + [ONE], + constants.NULL_BYTES, + ) + .callAsync(), ], ], MULTI_ASSET_D: [ [ONE, TWO], [ - await devUtils.encodeERC20AssetData.callAsync(erc20Tokens[3].address), - await devUtils.encodeERC1155AssetData.callAsync( - erc1155Token.address, - [erc1155FungibleTokens[3]], - [ONE], - constants.NULL_BYTES, - ), + await devUtils.encodeERC20AssetData(erc20Tokens[3].address).callAsync(), + await devUtils + .encodeERC1155AssetData( + erc1155Token.address, + [erc1155FungibleTokens[3]], + [ONE], + constants.NULL_BYTES, + ) + .callAsync(), ], ], }; diff --git a/contracts/exchange/test/protocol_fees.ts b/contracts/exchange/test/protocol_fees.ts index 5cba8686ff..3a46d392d7 100644 --- a/contracts/exchange/test/protocol_fees.ts +++ b/contracts/exchange/test/protocol_fees.ts @@ -31,244 +31,223 @@ blockchainTests('Protocol Fee Payments', env => { blockchainTests.resets('fillOrder Protocol Fees', () => { it('should not pay protocol fee when there is no registered protocol fee collector', async () => { - await testProtocolFeesReceiver.testFillOrderProtocolFees.awaitTransactionSuccessAsync( - testProtocolFees.address, - DEFAULT_PROTOCOL_FEE_MULTIPLIER, - false, - { + await testProtocolFeesReceiver + .testFillOrderProtocolFees(testProtocolFees.address, DEFAULT_PROTOCOL_FEE_MULTIPLIER, false) + .awaitTransactionSuccessAsync({ gasPrice: DEFAULT_GAS_PRICE, value: DEFAULT_PROTOCOL_FEE, - }, - ); + }); }); it('should not forward ETH when too little value is sent', async () => { - await testProtocolFeesReceiver.testFillOrderProtocolFees.awaitTransactionSuccessAsync( - testProtocolFees.address, - DEFAULT_PROTOCOL_FEE_MULTIPLIER, - true, - { + await testProtocolFeesReceiver + .testFillOrderProtocolFees(testProtocolFees.address, DEFAULT_PROTOCOL_FEE_MULTIPLIER, true) + .awaitTransactionSuccessAsync({ gasPrice: DEFAULT_GAS_PRICE, value: DEFAULT_PROTOCOL_FEE.minus(10), - }, - ); + }); }); it('should pay protocol fee in ETH when the correct value is sent', async () => { - await testProtocolFeesReceiver.testFillOrderProtocolFees.awaitTransactionSuccessAsync( - testProtocolFees.address, - DEFAULT_PROTOCOL_FEE_MULTIPLIER, - true, - { + await testProtocolFeesReceiver + .testFillOrderProtocolFees(testProtocolFees.address, DEFAULT_PROTOCOL_FEE_MULTIPLIER, true) + .awaitTransactionSuccessAsync({ gasPrice: DEFAULT_GAS_PRICE, value: DEFAULT_PROTOCOL_FEE, - }, - ); + }); }); it('should pay protocol fee in ETH when extra value is sent', async () => { - await testProtocolFeesReceiver.testFillOrderProtocolFees.awaitTransactionSuccessAsync( - testProtocolFees.address, - DEFAULT_PROTOCOL_FEE_MULTIPLIER, - true, - { + await testProtocolFeesReceiver + .testFillOrderProtocolFees(testProtocolFees.address, DEFAULT_PROTOCOL_FEE_MULTIPLIER, true) + .awaitTransactionSuccessAsync({ gasPrice: DEFAULT_GAS_PRICE, value: DEFAULT_PROTOCOL_FEE.plus(10), - }, - ); + }); }); }); blockchainTests.resets('matchOrders Protocol Fees', () => { it('should not pay protocol fee when there is no registered protocol fee collector', async () => { - await testProtocolFeesReceiver.testMatchOrdersProtocolFees.awaitTransactionSuccessAsync( - testProtocolFees.address, - DEFAULT_PROTOCOL_FEE_MULTIPLIER, - false, - { + await testProtocolFeesReceiver + .testMatchOrdersProtocolFees(testProtocolFees.address, DEFAULT_PROTOCOL_FEE_MULTIPLIER, false) + .awaitTransactionSuccessAsync({ gasPrice: DEFAULT_GAS_PRICE, value: DEFAULT_PROTOCOL_FEE, - }, - ); + }); }); it('should not forward ETH twice when too little value is sent', async () => { - await testProtocolFeesReceiver.testMatchOrdersProtocolFees.awaitTransactionSuccessAsync( - testProtocolFees.address, - DEFAULT_PROTOCOL_FEE_MULTIPLIER, - true, - { + await testProtocolFeesReceiver + .testMatchOrdersProtocolFees(testProtocolFees.address, DEFAULT_PROTOCOL_FEE_MULTIPLIER, true) + .awaitTransactionSuccessAsync({ gasPrice: DEFAULT_GAS_PRICE, value: DEFAULT_PROTOCOL_FEE.minus(10), - }, - ); + }); }); it('should pay protocol fee in ETH and then not forward ETH when exactly one protocol fee is sent', async () => { - await testProtocolFeesReceiver.testMatchOrdersProtocolFees.awaitTransactionSuccessAsync( - testProtocolFees.address, - DEFAULT_PROTOCOL_FEE_MULTIPLIER, - true, - { + await testProtocolFeesReceiver + .testMatchOrdersProtocolFees(testProtocolFees.address, DEFAULT_PROTOCOL_FEE_MULTIPLIER, true) + .awaitTransactionSuccessAsync({ gasPrice: DEFAULT_GAS_PRICE, value: DEFAULT_PROTOCOL_FEE, - }, - ); + }); }); it('should pay protocol fee in ETH and then not forward ETH when a bit more than one protocol fee is sent', async () => { - await testProtocolFeesReceiver.testMatchOrdersProtocolFees.awaitTransactionSuccessAsync( - testProtocolFees.address, - DEFAULT_PROTOCOL_FEE_MULTIPLIER, - true, - { + await testProtocolFeesReceiver + .testMatchOrdersProtocolFees(testProtocolFees.address, DEFAULT_PROTOCOL_FEE_MULTIPLIER, true) + .awaitTransactionSuccessAsync({ gasPrice: DEFAULT_GAS_PRICE, value: DEFAULT_PROTOCOL_FEE.plus(10), - }, - ); + }); }); it('should pay protocol fee in ETH when exactly double the protocol fee is sent', async () => { - await testProtocolFeesReceiver.testMatchOrdersProtocolFees.awaitTransactionSuccessAsync( - testProtocolFees.address, - DEFAULT_PROTOCOL_FEE_MULTIPLIER, - true, - { + await testProtocolFeesReceiver + .testMatchOrdersProtocolFees(testProtocolFees.address, DEFAULT_PROTOCOL_FEE_MULTIPLIER, true) + .awaitTransactionSuccessAsync({ gasPrice: DEFAULT_GAS_PRICE, value: DEFAULT_PROTOCOL_FEE.times(2), - }, - ); + }); }); it('should pay protocol fee in ETH when more than double the protocol fee is sent', async () => { - await testProtocolFeesReceiver.testMatchOrdersProtocolFees.awaitTransactionSuccessAsync( - testProtocolFees.address, - DEFAULT_PROTOCOL_FEE_MULTIPLIER, - true, - { + await testProtocolFeesReceiver + .testMatchOrdersProtocolFees(testProtocolFees.address, DEFAULT_PROTOCOL_FEE_MULTIPLIER, true) + .awaitTransactionSuccessAsync({ gasPrice: DEFAULT_GAS_PRICE, value: DEFAULT_PROTOCOL_FEE.times(2).plus(10), - }, - ); + }); }); }); blockchainTests.resets('batchFillOrder ProtocolFees', () => { it('should not pay protocol fees when there is not a protocolFeeCollector registered', async () => { - await testProtocolFeesReceiver.testBatchFillOrdersProtocolFees.awaitTransactionSuccessAsync( - testProtocolFees.address, - DEFAULT_PROTOCOL_FEE_MULTIPLIER, - new BigNumber(2), // If successful, create a `batchFillOrders` with 2 orders. - false, - { + await testProtocolFeesReceiver + .testBatchFillOrdersProtocolFees( + testProtocolFees.address, + DEFAULT_PROTOCOL_FEE_MULTIPLIER, + new BigNumber(2), // If successful, create a `batchFillOrders` with 2 orders. + false, + ) + .awaitTransactionSuccessAsync({ gasPrice: DEFAULT_GAS_PRICE, value: DEFAULT_PROTOCOL_FEE, - }, - ); + }); }); it('should not forward ETH when less than one protocol fee is sent and only one order is in the batch', async () => { - await testProtocolFeesReceiver.testBatchFillOrdersProtocolFees.awaitTransactionSuccessAsync( - testProtocolFees.address, - DEFAULT_PROTOCOL_FEE_MULTIPLIER, - new BigNumber(1), - true, - { + await testProtocolFeesReceiver + .testBatchFillOrdersProtocolFees( + testProtocolFees.address, + DEFAULT_PROTOCOL_FEE_MULTIPLIER, + new BigNumber(1), + true, + ) + .awaitTransactionSuccessAsync({ gasPrice: DEFAULT_GAS_PRICE, value: DEFAULT_PROTOCOL_FEE.minus(10), - }, - ); + }); }); it('should pay one protocol fee in ETH when the exact protocol fee is sent and only one order is in the batch', async () => { - await testProtocolFeesReceiver.testBatchFillOrdersProtocolFees.awaitTransactionSuccessAsync( - testProtocolFees.address, - DEFAULT_PROTOCOL_FEE_MULTIPLIER, - new BigNumber(1), - true, - { + await testProtocolFeesReceiver + .testBatchFillOrdersProtocolFees( + testProtocolFees.address, + DEFAULT_PROTOCOL_FEE_MULTIPLIER, + new BigNumber(1), + true, + ) + .awaitTransactionSuccessAsync({ gasPrice: DEFAULT_GAS_PRICE, value: DEFAULT_PROTOCOL_FEE, - }, - ); + }); }); it('should pay one protocol fee in ETH when more than the exact protocol fee is sent and only one order is in the batch', async () => { - await testProtocolFeesReceiver.testBatchFillOrdersProtocolFees.awaitTransactionSuccessAsync( - testProtocolFees.address, - DEFAULT_PROTOCOL_FEE_MULTIPLIER, - new BigNumber(1), - true, - { + await testProtocolFeesReceiver + .testBatchFillOrdersProtocolFees( + testProtocolFees.address, + DEFAULT_PROTOCOL_FEE_MULTIPLIER, + new BigNumber(1), + true, + ) + .awaitTransactionSuccessAsync({ gasPrice: DEFAULT_GAS_PRICE, value: DEFAULT_PROTOCOL_FEE.plus(10), - }, - ); + }); }); it('should not forward ETH twice when an insuffiecent amount of ETH for one protocol fee is sent', async () => { - await testProtocolFeesReceiver.testBatchFillOrdersProtocolFees.awaitTransactionSuccessAsync( - testProtocolFees.address, - DEFAULT_PROTOCOL_FEE_MULTIPLIER, - new BigNumber(2), - true, - { + await testProtocolFeesReceiver + .testBatchFillOrdersProtocolFees( + testProtocolFees.address, + DEFAULT_PROTOCOL_FEE_MULTIPLIER, + new BigNumber(2), + true, + ) + .awaitTransactionSuccessAsync({ gasPrice: DEFAULT_GAS_PRICE, value: DEFAULT_PROTOCOL_FEE.minus(10), - }, - ); + }); }); it('should pay a protocol in ETH and not forward ETH for the second when exactly one protocol fee in ETH is sent', async () => { - await testProtocolFeesReceiver.testBatchFillOrdersProtocolFees.awaitTransactionSuccessAsync( - testProtocolFees.address, - DEFAULT_PROTOCOL_FEE_MULTIPLIER, - new BigNumber(2), - true, - { + await testProtocolFeesReceiver + .testBatchFillOrdersProtocolFees( + testProtocolFees.address, + DEFAULT_PROTOCOL_FEE_MULTIPLIER, + new BigNumber(2), + true, + ) + .awaitTransactionSuccessAsync({ gasPrice: DEFAULT_GAS_PRICE, value: DEFAULT_PROTOCOL_FEE, - }, - ); + }); }); it('should pay both protocol fees in ETH when exactly two protocol fees in ETH is sent', async () => { - await testProtocolFeesReceiver.testBatchFillOrdersProtocolFees.awaitTransactionSuccessAsync( - testProtocolFees.address, - DEFAULT_PROTOCOL_FEE_MULTIPLIER, - new BigNumber(2), - true, - { + await testProtocolFeesReceiver + .testBatchFillOrdersProtocolFees( + testProtocolFees.address, + DEFAULT_PROTOCOL_FEE_MULTIPLIER, + new BigNumber(2), + true, + ) + .awaitTransactionSuccessAsync({ gasPrice: DEFAULT_GAS_PRICE, value: DEFAULT_PROTOCOL_FEE.times(2), - }, - ); + }); }); it('should pay two protocol fees in ETH and then not forward ETH for a third when exactly two protocol fees in ETH is sent', async () => { - await testProtocolFeesReceiver.testBatchFillOrdersProtocolFees.awaitTransactionSuccessAsync( - testProtocolFees.address, - DEFAULT_PROTOCOL_FEE_MULTIPLIER, - new BigNumber(3), - true, - { + await testProtocolFeesReceiver + .testBatchFillOrdersProtocolFees( + testProtocolFees.address, + DEFAULT_PROTOCOL_FEE_MULTIPLIER, + new BigNumber(3), + true, + ) + .awaitTransactionSuccessAsync({ gasPrice: DEFAULT_GAS_PRICE, value: DEFAULT_PROTOCOL_FEE.times(2), - }, - ); + }); }); it('should pay three protocol fees in ETH when more than three protocol fees in ETH is sent', async () => { - await testProtocolFeesReceiver.testBatchFillOrdersProtocolFees.awaitTransactionSuccessAsync( - testProtocolFees.address, - DEFAULT_PROTOCOL_FEE_MULTIPLIER, - new BigNumber(3), - true, - { + await testProtocolFeesReceiver + .testBatchFillOrdersProtocolFees( + testProtocolFees.address, + DEFAULT_PROTOCOL_FEE_MULTIPLIER, + new BigNumber(3), + true, + ) + .awaitTransactionSuccessAsync({ gasPrice: DEFAULT_GAS_PRICE, value: DEFAULT_PROTOCOL_FEE.times(3).plus(10), - }, - ); + }); }); }); }); diff --git a/contracts/exchange/test/protocol_fees_manager.ts b/contracts/exchange/test/protocol_fees_manager.ts index 010fe122c6..54bc8273b0 100644 --- a/contracts/exchange/test/protocol_fees_manager.ts +++ b/contracts/exchange/test/protocol_fees_manager.ts @@ -43,7 +43,7 @@ blockchainTests.resets('MixinProtocolFees', env => { const expectedError = new OwnableRevertErrors.OnlyOwnerError(nonOwner, owner); // Ensure that the transaction reverts with the expected rich error. - const tx = exchange.setProtocolFeeCollectorAddress.sendTransactionAsync(protocolFeeCollector, { + const tx = exchange.setProtocolFeeCollectorAddress(protocolFeeCollector).sendTransactionAsync({ from: nonOwner, }); return expect(tx).to.revertWith(expectedError); @@ -51,15 +51,14 @@ blockchainTests.resets('MixinProtocolFees', env => { it('should succeed and emit an ProtocolFeeMultiplier event if msg.sender == owner', async () => { // Call the `setProtocolFeeMultiplier()` function and get the receipt. - const receipt = await exchange.setProtocolFeeMultiplier.awaitTransactionSuccessAsync( - protocolFeeMultiplier, - { + const receipt = await exchange + .setProtocolFeeMultiplier(protocolFeeMultiplier) + .awaitTransactionSuccessAsync({ from: owner, - }, - ); + }); // Verify that the protocolFeeCollector address was actually updated to the correct address. - const updated = await exchange.protocolFeeMultiplier.callAsync(); + const updated = await exchange.protocolFeeMultiplier().callAsync(); expect(updated).bignumber.to.be.eq(protocolFeeMultiplier); // Ensure that the correct `ProtocolFeeCollectorAddress` event was logged. @@ -76,7 +75,7 @@ blockchainTests.resets('MixinProtocolFees', env => { const expectedError = new OwnableRevertErrors.OnlyOwnerError(nonOwner, owner); // Ensure that the transaction reverts with the expected rich error. - const tx = exchange.setProtocolFeeCollectorAddress.sendTransactionAsync(protocolFeeCollector, { + const tx = exchange.setProtocolFeeCollectorAddress(protocolFeeCollector).sendTransactionAsync({ from: nonOwner, }); return expect(tx).to.revertWith(expectedError); @@ -84,15 +83,14 @@ blockchainTests.resets('MixinProtocolFees', env => { it('should succeed and emit an ProtocolFeeCollectorAddress event if msg.sender == owner', async () => { // Call the `setProtocolFeeCollectorAddress()` function and get the receipt. - const receipt = await exchange.setProtocolFeeCollectorAddress.awaitTransactionSuccessAsync( - protocolFeeCollector, - { + const receipt = await exchange + .setProtocolFeeCollectorAddress(protocolFeeCollector) + .awaitTransactionSuccessAsync({ from: owner, - }, - ); + }); // Verify that the protocolFeeCollector address was actually updated to the correct address. - const updated = await exchange.protocolFeeCollector.callAsync(); + const updated = await exchange.protocolFeeCollector().callAsync(); expect(updated).to.be.eq(protocolFeeCollector); // Ensure that the correct `UpdatedProtocolFeeCollectorAddress` event was logged. @@ -109,23 +107,23 @@ blockchainTests.resets('MixinProtocolFees', env => { const expectedError = new OwnableRevertErrors.OnlyOwnerError(nonOwner, owner); // Ensure that the transaction reverts with the expected rich error. - const tx = exchange.detachProtocolFeeCollector.sendTransactionAsync({ + const tx = exchange.detachProtocolFeeCollector().sendTransactionAsync({ from: nonOwner, }); return expect(tx).to.revertWith(expectedError); }); it('should succeed and emit an ProtocolFeeCollectorAddress event if msg.sender == owner', async () => { - await exchange.setProtocolFeeCollectorAddress.awaitTransactionSuccessAsync(protocolFeeCollector, { + await exchange.setProtocolFeeCollectorAddress(protocolFeeCollector).awaitTransactionSuccessAsync({ from: owner, }); - const receipt = await exchange.detachProtocolFeeCollector.awaitTransactionSuccessAsync({ + const receipt = await exchange.detachProtocolFeeCollector().awaitTransactionSuccessAsync({ from: owner, }); // Verify that the protocolFeeCollector address was actually updated to the correct address. - const updated = await exchange.protocolFeeCollector.callAsync(); + const updated = await exchange.protocolFeeCollector().callAsync(); expect(updated).to.be.eq(constants.NULL_ADDRESS); // Ensure that the correct `UpdatedProtocolFeeCollectorAddress` event was logged. diff --git a/contracts/exchange/test/reentrancy_tests.ts b/contracts/exchange/test/reentrancy_tests.ts index 593c8285f2..7a56dbc9bc 100644 --- a/contracts/exchange/test/reentrancy_tests.ts +++ b/contracts/exchange/test/reentrancy_tests.ts @@ -101,8 +101,8 @@ blockchainTests.resets('Reentrancy Tests', env => { for (const fn of NON_REENTRANT_FUNCTIONS) { it(`${fn.name}()`, async () => { const inputs = createFunctionInputs(fn.inputs); - const callData = (testerContract as any)[fn.name].getABIEncodedTransactionData(...inputs); - const isReentrant = await testerContract.isReentrant.callAsync(callData); + const callData = (testerContract as any)[fn.name](...inputs).getABIEncodedTransactionData(); + const isReentrant = await testerContract.isReentrant(callData).callAsync(); expect(isReentrant).to.be.false(); }); } @@ -112,8 +112,8 @@ blockchainTests.resets('Reentrancy Tests', env => { for (const fn of REENTRANT_FUNCTIONS) { it(`${fn.name}()`, async () => { const inputs = createFunctionInputs(fn.inputs); - const callData = (testerContract as any)[fn.name].getABIEncodedTransactionData(...inputs); - const isReentrant = await testerContract.isReentrant.callAsync(callData); + const callData = (testerContract as any)[fn.name](...inputs).getABIEncodedTransactionData(); + const isReentrant = await testerContract.isReentrant(callData).callAsync(); expect(isReentrant).to.be.true(); }); } diff --git a/contracts/exchange/test/signature_validator.ts b/contracts/exchange/test/signature_validator.ts index 33aec898fb..cecdb5386b 100644 --- a/contracts/exchange/test/signature_validator.ts +++ b/contracts/exchange/test/signature_validator.ts @@ -58,16 +58,14 @@ blockchainTests.resets('MixinSignatureValidator', env => { {}, signatureValidator.address, ); - validatorWalletRevertReason = await validatorWallet.REVERT_REASON.callAsync(); + validatorWalletRevertReason = await validatorWallet.REVERT_REASON().callAsync(); // Approve the validator for both signers. await Promise.all( [signerAddress, notSignerAddress].map(async (addr: string) => { - return signatureValidator.setSignatureValidatorApproval.awaitTransactionSuccessAsync( - validatorWallet.address, - true, - { from: addr }, - ); + return signatureValidator + .setSignatureValidatorApproval(validatorWallet.address, true) + .awaitTransactionSuccessAsync({ from: addr }); }), ); @@ -299,7 +297,7 @@ blockchainTests.resets('MixinSignatureValidator', env => { it('should return true when SignatureType=Presigned and signer has presigned hash', async () => { const hashHex = getCurrentHashHex(); // Presign the hash - await signatureValidator.preSign.awaitTransactionSuccessAsync(hashHex, { from: signerAddress }); + await signatureValidator.preSign(hashHex).awaitTransactionSuccessAsync({ from: signerAddress }); // Validate presigned signature const signatureHex = hexConcat(SignatureType.PreSigned); const isValidSignature = await validateAsync(hashHex, signerAddress, signatureHex); @@ -333,13 +331,11 @@ blockchainTests.resets('MixinSignatureValidator', env => { ? constants.NULL_BYTES : hashBytes(validatorExpectedSignatureHex); if (validatorAction !== undefined) { - await validatorWallet.prepare.awaitTransactionSuccessAsync( - _hashHex, - validatorAction, - expectedSignatureHashHex, - ); + await validatorWallet + .prepare(_hashHex, validatorAction, expectedSignatureHashHex) + .awaitTransactionSuccessAsync(); } - return signatureValidator.isValidHashSignature.callAsync(_hashHex, _signerAddress, signatureHex); + return signatureValidator.isValidHashSignature(_hashHex, _signerAddress, signatureHex).callAsync(); }; it('should revert when signerAddress == 0', async () => { @@ -388,11 +384,9 @@ blockchainTests.resets('MixinSignatureValidator', env => { const trezorSignatureType = ethUtil.toBuffer(`0x${SignatureType.EthSign}`); const signature = Buffer.concat([v, r, s, trezorSignatureType]); const signatureHex = ethUtil.bufferToHex(signature); - const isValidSignature = await signatureValidator.isValidHashSignature.callAsync( - messageHash, - signer, - signatureHex, - ); + const isValidSignature = await signatureValidator + .isValidHashSignature(messageHash, signer, signatureHex) + .callAsync(); expect(isValidSignature).to.be.true(); }); @@ -406,11 +400,9 @@ blockchainTests.resets('MixinSignatureValidator', env => { const trezorSignatureType = ethUtil.toBuffer(`0x${SignatureType.EthSign}`); const signature = Buffer.concat([v, r, s, trezorSignatureType]); const signatureHex = ethUtil.bufferToHex(signature); - const isValidSignature = await signatureValidator.isValidHashSignature.callAsync( - messageHash, - signer, - signatureHex, - ); + const isValidSignature = await signatureValidator + .isValidHashSignature(messageHash, signer, signatureHex) + .callAsync(); expect(isValidSignature).to.be.true(); }); @@ -427,10 +419,10 @@ blockchainTests.resets('MixinSignatureValidator', env => { ...constants.STATIC_ORDER_PARAMS, makerAddress, feeRecipientAddress: randomAddress(), - makerAssetData: await devUtils.encodeERC20AssetData.callAsync(randomAddress()), - takerAssetData: await devUtils.encodeERC20AssetData.callAsync(randomAddress()), - makerFeeAssetData: await devUtils.encodeERC20AssetData.callAsync(randomAddress()), - takerFeeAssetData: await devUtils.encodeERC20AssetData.callAsync(randomAddress()), + makerAssetData: await devUtils.encodeERC20AssetData(randomAddress()).callAsync(), + takerAssetData: await devUtils.encodeERC20AssetData(randomAddress()).callAsync(), + makerFeeAssetData: await devUtils.encodeERC20AssetData(randomAddress()).callAsync(), + takerFeeAssetData: await devUtils.encodeERC20AssetData(randomAddress()).callAsync(), makerFee: constants.ZERO_AMOUNT, takerFee: constants.ZERO_AMOUNT, exchangeAddress: signatureValidator.address, @@ -455,13 +447,11 @@ blockchainTests.resets('MixinSignatureValidator', env => { ? constants.NULL_BYTES : hashBytes(validatorExpectedSignatureHex); if (validatorAction !== undefined) { - await validatorWallet.prepare.awaitTransactionSuccessAsync( - orderHashHex, - validatorAction, - expectedSignatureHashHex, - ); + await validatorWallet + .prepare(orderHashHex, validatorAction, expectedSignatureHashHex) + .awaitTransactionSuccessAsync(); } - return signatureValidator.isValidOrderSignature.callAsync(order, signatureHex); + return signatureValidator.isValidOrderSignature(order, signatureHex).callAsync(); }; it('should revert when signerAddress == 0', async () => { @@ -477,7 +467,7 @@ blockchainTests.resets('MixinSignatureValidator', env => { constants.NULL_ADDRESS, signatureHex, ); - const tx = signatureValidator.isValidOrderSignature.callAsync(nullMakerOrder, signatureHex); + const tx = signatureValidator.isValidOrderSignature(nullMakerOrder, signatureHex).callAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -526,7 +516,7 @@ blockchainTests.resets('MixinSignatureValidator', env => { const signatureDataHex = generateRandomSignature(); const signatureHex = hexConcat(signatureDataHex, validatorWallet.address, SignatureType.Validator); const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder); - const data = eip1271Data.OrderWithHash.getABIEncodedTransactionData(signedOrder, orderHashHex); + const data = eip1271Data.OrderWithHash(signedOrder, orderHashHex).getABIEncodedTransactionData(); const expectedError = new ExchangeRevertErrors.EIP1271SignatureError( validatorWallet.address, data, @@ -543,7 +533,7 @@ blockchainTests.resets('MixinSignatureValidator', env => { const signatureDataHex = generateRandomSignature(); const signatureHex = hexConcat(signatureDataHex, validatorWallet.address, SignatureType.Validator); const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder); - const data = eip1271Data.OrderWithHash.getABIEncodedTransactionData(signedOrder, orderHashHex); + const data = eip1271Data.OrderWithHash(signedOrder, orderHashHex).getABIEncodedTransactionData(); const expectedError = new ExchangeRevertErrors.EIP1271SignatureError( validatorWallet.address, data, @@ -560,7 +550,7 @@ blockchainTests.resets('MixinSignatureValidator', env => { const signatureDataHex = generateRandomSignature(); const signatureHex = hexConcat(signatureDataHex, validatorWallet.address, SignatureType.Validator); const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder); - const data = eip1271Data.OrderWithHash.getABIEncodedTransactionData(signedOrder, orderHashHex); + const data = eip1271Data.OrderWithHash(signedOrder, orderHashHex).getABIEncodedTransactionData(); const expectedError = new ExchangeRevertErrors.EIP1271SignatureError( validatorWallet.address, data, @@ -573,11 +563,9 @@ blockchainTests.resets('MixinSignatureValidator', env => { it('should revert when SignatureType=Validator and signature is shorter than 21 bytes', async () => { // Set approval of signature validator to false - await signatureValidator.setSignatureValidatorApproval.awaitTransactionSuccessAsync( - validatorWallet.address, - false, - { from: signedOrder.makerAddress }, - ); + await signatureValidator + .setSignatureValidatorApproval(validatorWallet.address, false) + .awaitTransactionSuccessAsync({ from: signedOrder.makerAddress }); // Doesn't have to contain a real signature since our wallet contract // just does a hash comparison. const signatureHex = hexConcat(SignatureType.Validator); @@ -594,11 +582,9 @@ blockchainTests.resets('MixinSignatureValidator', env => { it('should revert when SignatureType=Validator, signature is valid and validator is not approved', async () => { // Set approval of signature validator to false - await signatureValidator.setSignatureValidatorApproval.awaitTransactionSuccessAsync( - validatorWallet.address, - false, - { from: signedOrder.makerAddress }, - ); + await signatureValidator + .setSignatureValidatorApproval(validatorWallet.address, false) + .awaitTransactionSuccessAsync({ from: signedOrder.makerAddress }); // Doesn't have to contain a real signature since our wallet contract // just does a hash comparison. const signatureDataHex = generateRandomSignature(); @@ -663,7 +649,7 @@ blockchainTests.resets('MixinSignatureValidator', env => { const signatureDataHex = generateRandomSignature(); const signatureHex = hexConcat(signatureDataHex, SignatureType.EIP1271Wallet); const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder); - const data = eip1271Data.OrderWithHash.getABIEncodedTransactionData(signedOrder, orderHashHex); + const data = eip1271Data.OrderWithHash(signedOrder, orderHashHex).getABIEncodedTransactionData(); const expectedError = new ExchangeRevertErrors.EIP1271SignatureError( validatorWallet.address, data, @@ -680,7 +666,7 @@ blockchainTests.resets('MixinSignatureValidator', env => { // just does a hash comparison. const signatureHex = hexConcat(generateRandomSignature(), SignatureType.EIP1271Wallet); const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder); - const data = eip1271Data.OrderWithHash.getABIEncodedTransactionData(signedOrder, orderHashHex); + const data = eip1271Data.OrderWithHash(signedOrder, orderHashHex).getABIEncodedTransactionData(); const expectedError = new ExchangeRevertErrors.EIP1271SignatureError( validatorWallet.address, data, @@ -695,7 +681,7 @@ blockchainTests.resets('MixinSignatureValidator', env => { signedOrder.makerAddress = validatorWallet.address; const signatureHex = hexConcat(SignatureType.EIP1271Wallet); const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder); - const data = eip1271Data.OrderWithHash.getABIEncodedTransactionData(signedOrder, orderHashHex); + const data = eip1271Data.OrderWithHash(signedOrder, orderHashHex).getABIEncodedTransactionData(); const expectedError = new ExchangeRevertErrors.EIP1271SignatureError( validatorWallet.address, data, @@ -710,21 +696,21 @@ blockchainTests.resets('MixinSignatureValidator', env => { const signatureHex = hexConcat(SignatureType.EIP1271Wallet); signedOrder.makerAddress = notSignerAddress; const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder); - const data = eip1271Data.OrderWithHash.getABIEncodedTransactionData(signedOrder, orderHashHex); + const data = eip1271Data.OrderWithHash(signedOrder, orderHashHex).getABIEncodedTransactionData(); const expectedError = new ExchangeRevertErrors.EIP1271SignatureError( notSignerAddress, data, signatureHex, constants.NULL_BYTES, ); - const tx = signatureValidator.isValidOrderSignature.callAsync(signedOrder, signatureHex); + const tx = signatureValidator.isValidOrderSignature(signedOrder, signatureHex).callAsync(); return expect(tx).to.revertWith(expectedError); }); it('should revert when signer is an EOA and SignatureType=Validator', async () => { const signatureHex = hexConcat(notSignerAddress, SignatureType.Validator); const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder); - const data = eip1271Data.OrderWithHash.getABIEncodedTransactionData(signedOrder, orderHashHex); + const data = eip1271Data.OrderWithHash(signedOrder, orderHashHex).getABIEncodedTransactionData(); const expectedError = new ExchangeRevertErrors.EIP1271SignatureError( notSignerAddress, data, @@ -732,12 +718,10 @@ blockchainTests.resets('MixinSignatureValidator', env => { constants.NULL_BYTES, ); // Register an EOA as a validator. - await signatureValidator.setSignatureValidatorApproval.awaitTransactionSuccessAsync( - notSignerAddress, - true, - { from: signerAddress }, - ); - const tx = signatureValidator.isValidOrderSignature.callAsync(signedOrder, signatureHex); + await signatureValidator + .setSignatureValidatorApproval(notSignerAddress, true) + .awaitTransactionSuccessAsync({ from: signerAddress }); + const tx = signatureValidator.isValidOrderSignature(signedOrder, signatureHex).callAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -787,13 +771,11 @@ blockchainTests.resets('MixinSignatureValidator', env => { ? constants.NULL_BYTES : hashBytes(validatorExpectedSignatureHex); if (validatorAction !== undefined) { - await validatorWallet.prepare.awaitTransactionSuccessAsync( - transactionHashHex, - validatorAction, - expectedSignatureHashHex, - ); + await validatorWallet + .prepare(transactionHashHex, validatorAction, expectedSignatureHashHex) + .awaitTransactionSuccessAsync(); } - return signatureValidator.isValidTransactionSignature.callAsync(transaction, signatureHex); + return signatureValidator.isValidTransactionSignature(transaction, signatureHex).callAsync(); }; it('should revert when signerAddress == 0', async () => { @@ -809,7 +791,7 @@ blockchainTests.resets('MixinSignatureValidator', env => { constants.NULL_ADDRESS, signatureHex, ); - const tx = signatureValidator.isValidTransactionSignature.callAsync(nullSignerTransaction, signatureHex); + const tx = signatureValidator.isValidTransactionSignature(nullSignerTransaction, signatureHex).callAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -856,11 +838,9 @@ blockchainTests.resets('MixinSignatureValidator', env => { it('should revert when SignatureType=Validator and signature is shorter than 21 bytes', async () => { // Set approval of signature validator to false - await signatureValidator.setSignatureValidatorApproval.awaitTransactionSuccessAsync( - validatorWallet.address, - false, - { from: signedTransaction.signerAddress }, - ); + await signatureValidator + .setSignatureValidatorApproval(validatorWallet.address, false) + .awaitTransactionSuccessAsync({ from: signedTransaction.signerAddress }); // Doesn't have to contain a real signature since our wallet contract // just does a hash comparison. const signatureHex = hexConcat(SignatureType.Validator); @@ -879,10 +859,9 @@ blockchainTests.resets('MixinSignatureValidator', env => { const signatureDataHex = generateRandomSignature(); const signatureHex = hexConcat(signatureDataHex, validatorWallet.address, SignatureType.Validator); const transactionHashHex = transactionHashUtils.getTransactionHashHex(signedTransaction); - const data = eip1271Data.ZeroExTransactionWithHash.getABIEncodedTransactionData( - signedTransaction, - transactionHashHex, - ); + const data = eip1271Data + .ZeroExTransactionWithHash(signedTransaction, transactionHashHex) + .getABIEncodedTransactionData(); const expectedError = new ExchangeRevertErrors.EIP1271SignatureError( validatorWallet.address, data, @@ -904,10 +883,9 @@ blockchainTests.resets('MixinSignatureValidator', env => { const signatureDataHex = generateRandomSignature(); const signatureHex = hexConcat(signatureDataHex, validatorWallet.address, SignatureType.Validator); const transactionHashHex = transactionHashUtils.getTransactionHashHex(signedTransaction); - const data = eip1271Data.ZeroExTransactionWithHash.getABIEncodedTransactionData( - signedTransaction, - transactionHashHex, - ); + const data = eip1271Data + .ZeroExTransactionWithHash(signedTransaction, transactionHashHex) + .getABIEncodedTransactionData(); const expectedError = new ExchangeRevertErrors.EIP1271SignatureError( validatorWallet.address, data, @@ -924,10 +902,9 @@ blockchainTests.resets('MixinSignatureValidator', env => { const signatureDataHex = generateRandomSignature(); const signatureHex = hexConcat(signatureDataHex, validatorWallet.address, SignatureType.Validator); const transactionHashHex = transactionHashUtils.getTransactionHashHex(signedTransaction); - const data = eip1271Data.ZeroExTransactionWithHash.getABIEncodedTransactionData( - signedTransaction, - transactionHashHex, - ); + const data = eip1271Data + .ZeroExTransactionWithHash(signedTransaction, transactionHashHex) + .getABIEncodedTransactionData(); const expectedError = new ExchangeRevertErrors.EIP1271SignatureError( validatorWallet.address, data, @@ -940,11 +917,9 @@ blockchainTests.resets('MixinSignatureValidator', env => { it('should revert when SignatureType=Validator, signature is valid and validator is not approved', async () => { // Set approval of signature validator to false - await signatureValidator.setSignatureValidatorApproval.awaitTransactionSuccessAsync( - validatorWallet.address, - false, - { from: signedTransaction.signerAddress }, - ); + await signatureValidator + .setSignatureValidatorApproval(validatorWallet.address, false) + .awaitTransactionSuccessAsync({ from: signedTransaction.signerAddress }); // Doesn't have to contain a real signature since our wallet contract // just does a hash comparison. const signatureDataHex = generateRandomSignature(); @@ -1009,10 +984,9 @@ blockchainTests.resets('MixinSignatureValidator', env => { const signatureDataHex = generateRandomSignature(); const signatureHex = hexConcat(signatureDataHex, SignatureType.EIP1271Wallet); const transactionHashHex = transactionHashUtils.getTransactionHashHex(signedTransaction); - const data = eip1271Data.ZeroExTransactionWithHash.getABIEncodedTransactionData( - signedTransaction, - transactionHashHex, - ); + const data = eip1271Data + .ZeroExTransactionWithHash(signedTransaction, transactionHashHex) + .getABIEncodedTransactionData(); const expectedError = new ExchangeRevertErrors.EIP1271SignatureError( validatorWallet.address, data, @@ -1034,10 +1008,9 @@ blockchainTests.resets('MixinSignatureValidator', env => { // just does a hash comparison. const signatureHex = hexConcat(generateRandomSignature(), SignatureType.EIP1271Wallet); const transactionHashHex = transactionHashUtils.getTransactionHashHex(signedTransaction); - const data = eip1271Data.ZeroExTransactionWithHash.getABIEncodedTransactionData( - signedTransaction, - transactionHashHex, - ); + const data = eip1271Data + .ZeroExTransactionWithHash(signedTransaction, transactionHashHex) + .getABIEncodedTransactionData(); const expectedError = new ExchangeRevertErrors.EIP1271SignatureError( validatorWallet.address, data, @@ -1054,10 +1027,9 @@ blockchainTests.resets('MixinSignatureValidator', env => { // just does a hash comparison. const signatureHex = hexConcat(generateRandomSignature(), SignatureType.EIP1271Wallet); const transactionHashHex = transactionHashUtils.getTransactionHashHex(signedTransaction); - const data = eip1271Data.ZeroExTransactionWithHash.getABIEncodedTransactionData( - signedTransaction, - transactionHashHex, - ); + const data = eip1271Data + .ZeroExTransactionWithHash(signedTransaction, transactionHashHex) + .getABIEncodedTransactionData(); const expectedError = new ExchangeRevertErrors.EIP1271SignatureError( validatorWallet.address, data, @@ -1071,27 +1043,25 @@ blockchainTests.resets('MixinSignatureValidator', env => { it('should revert when signer is an EOA and SignatureType=EIP1271Wallet', async () => { const signatureHex = hexConcat(SignatureType.EIP1271Wallet); const transactionHashHex = transactionHashUtils.getTransactionHashHex(signedTransaction); - const data = eip1271Data.ZeroExTransactionWithHash.getABIEncodedTransactionData( - signedTransaction, - transactionHashHex, - ); + const data = eip1271Data + .ZeroExTransactionWithHash(signedTransaction, transactionHashHex) + .getABIEncodedTransactionData(); const expectedError = new ExchangeRevertErrors.EIP1271SignatureError( signedTransaction.signerAddress, data, signatureHex, constants.NULL_BYTES, ); - const tx = signatureValidator.isValidTransactionSignature.callAsync(signedTransaction, signatureHex); + const tx = signatureValidator.isValidTransactionSignature(signedTransaction, signatureHex).callAsync(); return expect(tx).to.revertWith(expectedError); }); it('should revert when signer is an EOA and SignatureType=Validator', async () => { const signatureHex = hexConcat(notSignerAddress, SignatureType.Validator); const transactionHashHex = transactionHashUtils.getTransactionHashHex(signedTransaction); - const data = eip1271Data.ZeroExTransactionWithHash.getABIEncodedTransactionData( - signedTransaction, - transactionHashHex, - ); + const data = eip1271Data + .ZeroExTransactionWithHash(signedTransaction, transactionHashHex) + .getABIEncodedTransactionData(); const expectedError = new ExchangeRevertErrors.EIP1271SignatureError( notSignerAddress, data, @@ -1099,12 +1069,10 @@ blockchainTests.resets('MixinSignatureValidator', env => { constants.NULL_BYTES, ); // Register an EOA as a validator. - await signatureValidator.setSignatureValidatorApproval.awaitTransactionSuccessAsync( - notSignerAddress, - true, - { from: signerAddress }, - ); - const tx = signatureValidator.isValidTransactionSignature.callAsync(signedTransaction, signatureHex); + await signatureValidator + .setSignatureValidatorApproval(notSignerAddress, true) + .awaitTransactionSuccessAsync({ from: signerAddress }); + const tx = signatureValidator.isValidTransactionSignature(signedTransaction, signatureHex).callAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -1134,13 +1102,11 @@ blockchainTests.resets('MixinSignatureValidator', env => { it('should emit a SignatureValidatorApprovalSet with correct args when a validator is approved', async () => { const approval = true; - const res = await signatureValidator.setSignatureValidatorApproval.awaitTransactionSuccessAsync( - validatorWallet.address, - approval, - { + const res = await signatureValidator + .setSignatureValidatorApproval(validatorWallet.address, approval) + .awaitTransactionSuccessAsync({ from: signerAddress, - }, - ); + }); expect(res.logs.length).to.equal(1); const log = signatureValidatorLogDecoder.decodeLogOrThrow(res.logs[0]) as LogWithDecodedArgs< TestSignatureValidatorSignatureValidatorApprovalEventArgs @@ -1152,13 +1118,11 @@ blockchainTests.resets('MixinSignatureValidator', env => { }); it('should emit a SignatureValidatorApprovalSet with correct args when a validator is disapproved', async () => { const approval = false; - const res = await signatureValidator.setSignatureValidatorApproval.awaitTransactionSuccessAsync( - validatorWallet.address, - approval, - { + const res = await signatureValidator + .setSignatureValidatorApproval(validatorWallet.address, approval) + .awaitTransactionSuccessAsync({ from: signerAddress, - }, - ); + }); expect(res.logs.length).to.equal(1); const log = signatureValidatorLogDecoder.decodeLogOrThrow(res.logs[0]) as LogWithDecodedArgs< TestSignatureValidatorSignatureValidatorApprovalEventArgs diff --git a/contracts/exchange/test/transactions.ts b/contracts/exchange/test/transactions.ts index 00e932dbe6..dceff61f57 100644 --- a/contracts/exchange/test/transactions.ts +++ b/contracts/exchange/test/transactions.ts @@ -101,7 +101,7 @@ blockchainTests.resets('Exchange transactions', env => { exchangeWrapper = new ExchangeWrapper(exchangeInstance); await exchangeWrapper.registerAssetProxyAsync(erc20Proxy.address, owner); - await erc20Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(exchangeInstance.address, { from: owner }); + await erc20Proxy.addAuthorizedAddress(exchangeInstance.address).awaitTransactionSuccessAsync({ from: owner }); defaultMakerTokenAddress = erc20TokenA.address; defaultTakerTokenAddress = erc20TokenB.address; @@ -112,10 +112,10 @@ blockchainTests.resets('Exchange transactions', env => { ...constants.STATIC_ORDER_PARAMS, makerAddress, feeRecipientAddress, - makerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultMakerTokenAddress), - takerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultTakerTokenAddress), - makerFeeAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultMakerFeeTokenAddress), - takerFeeAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultTakerFeeTokenAddress), + makerAssetData: await devUtils.encodeERC20AssetData(defaultMakerTokenAddress).callAsync(), + takerAssetData: await devUtils.encodeERC20AssetData(defaultTakerTokenAddress).callAsync(), + makerFeeAssetData: await devUtils.encodeERC20AssetData(defaultMakerFeeTokenAddress).callAsync(), + takerFeeAssetData: await devUtils.encodeERC20AssetData(defaultTakerFeeTokenAddress).callAsync(), exchangeAddress: exchangeInstance.address, chainId, }; @@ -179,11 +179,9 @@ blockchainTests.resets('Exchange transactions', env => { actualGasPrice, transaction.gasPrice, ); - const tx = exchangeInstance.executeTransaction.sendTransactionAsync( - transaction, - transaction.signature, - { gasPrice: actualGasPrice, from: senderAddress }, - ); + const tx = exchangeInstance + .executeTransaction(transaction, transaction.signature) + .sendTransactionAsync({ gasPrice: actualGasPrice, from: senderAddress }); return expect(tx).to.revertWith(expectedError); }); it('should revert if the actual gasPrice is less than expected', async () => { @@ -200,11 +198,9 @@ blockchainTests.resets('Exchange transactions', env => { actualGasPrice, transaction.gasPrice, ); - const tx = exchangeInstance.executeTransaction.sendTransactionAsync( - transaction, - transaction.signature, - { gasPrice: actualGasPrice, from: senderAddress }, - ); + const tx = exchangeInstance + .executeTransaction(transaction, transaction.signature) + .sendTransactionAsync({ gasPrice: actualGasPrice, from: senderAddress }); return expect(tx).to.revertWith(expectedError); }); }); @@ -288,13 +284,11 @@ blockchainTests.resets('Exchange transactions', env => { const orders = [order]; const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); const transaction = await takerTransactionFactory.newSignedTransactionAsync({ data }); - const returnData = await exchangeInstance.executeTransaction.callAsync( - transaction, - transaction.signature, - { + const returnData = await exchangeInstance + .executeTransaction(transaction, transaction.signature) + .callAsync({ from: senderAddress, - }, - ); + }); const abi = artifacts.Exchange.compilerOutput.abi; const methodAbi = abi.filter(abiItem => (abiItem as MethodAbi).name === fnName)[0] as MethodAbi; const abiEncoder = new AbiEncoder.Method(methodAbi); @@ -328,10 +322,9 @@ blockchainTests.resets('Exchange transactions', env => { const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); const transaction = await takerTransactionFactory.newSignedTransactionAsync({ data }); const transactionHashHex = transactionHashUtils.getTransactionHashHex(transaction); - const recursiveData = exchangeInstance.executeTransaction.getABIEncodedTransactionData( - transaction, - transaction.signature, - ); + const recursiveData = exchangeInstance + .executeTransaction(transaction, transaction.signature) + .getABIEncodedTransactionData(); const recursiveTransaction = await takerTransactionFactory.newSignedTransactionAsync({ data: recursiveData, }); @@ -353,10 +346,9 @@ blockchainTests.resets('Exchange transactions', env => { const orders = [await orderFactory.newSignedOrderAsync()]; const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); const transaction = await takerTransactionFactory.newSignedTransactionAsync({ data }); - const recursiveData = exchangeInstance.executeTransaction.getABIEncodedTransactionData( - transaction, - constants.NULL_BYTES, - ); + const recursiveData = exchangeInstance + .executeTransaction(transaction, constants.NULL_BYTES) + .getABIEncodedTransactionData(); const recursiveTransaction = await takerTransactionFactory.newSignedTransactionAsync({ data: recursiveData, }); @@ -539,7 +531,7 @@ blockchainTests.resets('Exchange transactions', env => { describe('cancelOrdersUpTo', () => { it('should be successful if signed by maker and called by sender', async () => { const targetEpoch = constants.ZERO_AMOUNT; - const data = exchangeInstance.cancelOrdersUpTo.getABIEncodedTransactionData(targetEpoch); + const data = exchangeInstance.cancelOrdersUpTo(targetEpoch).getABIEncodedTransactionData(); const transaction = await makerTransactionFactory.newSignedTransactionAsync({ data }); const transactionReceipt = await exchangeWrapper.executeTransactionAsync(transaction, senderAddress); const cancelLogs = transactionReceipt.logs.filter( @@ -553,7 +545,7 @@ blockchainTests.resets('Exchange transactions', env => { }); it('should be successful if called by maker without a signature', async () => { const targetEpoch = constants.ZERO_AMOUNT; - const data = exchangeInstance.cancelOrdersUpTo.getABIEncodedTransactionData(targetEpoch); + const data = exchangeInstance.cancelOrdersUpTo(targetEpoch).getABIEncodedTransactionData(); const transaction = await makerTransactionFactory.newSignedTransactionAsync({ data }); const transactionReceipt = await exchangeWrapper.executeTransactionAsync(transaction, makerAddress); const cancelLogs = transactionReceipt.logs.filter( @@ -570,34 +562,33 @@ blockchainTests.resets('Exchange transactions', env => { it('should preSign a hash for the signer', async () => { const order = await orderFactory.newSignedOrderAsync(); const orderHash = orderHashUtils.getOrderHashHex(order); - const data = exchangeInstance.preSign.getABIEncodedTransactionData(orderHash); + const data = exchangeInstance.preSign(orderHash).getABIEncodedTransactionData(); const transaction = await takerTransactionFactory.newSignedTransactionAsync({ data }); - let isPreSigned = await exchangeInstance.preSigned.callAsync(orderHash, takerAddress); + let isPreSigned = await exchangeInstance.preSigned(orderHash, takerAddress).callAsync(); expect(isPreSigned).to.be.eq(false); await exchangeWrapper.executeTransactionAsync(transaction, senderAddress); - isPreSigned = await exchangeInstance.preSigned.callAsync(orderHash, takerAddress); + isPreSigned = await exchangeInstance.preSigned(orderHash, takerAddress).callAsync(); expect(isPreSigned).to.be.eq(true); }); it('should preSign a hash for the caller if called without a signature', async () => { const order = await orderFactory.newSignedOrderAsync(); const orderHash = orderHashUtils.getOrderHashHex(order); - const data = exchangeInstance.preSign.getABIEncodedTransactionData(orderHash); + const data = exchangeInstance.preSign(orderHash).getABIEncodedTransactionData(); const transaction = await takerTransactionFactory.newSignedTransactionAsync({ data }); transaction.signature = constants.NULL_BYTES; - let isPreSigned = await exchangeInstance.preSigned.callAsync(orderHash, takerAddress); + let isPreSigned = await exchangeInstance.preSigned(orderHash, takerAddress).callAsync(); expect(isPreSigned).to.be.eq(false); await exchangeWrapper.executeTransactionAsync(transaction, takerAddress); - isPreSigned = await exchangeInstance.preSigned.callAsync(orderHash, takerAddress); + isPreSigned = await exchangeInstance.preSigned(orderHash, takerAddress).callAsync(); expect(isPreSigned).to.be.eq(true); }); }); describe('setSignatureValidatorApproval', () => { it('should approve a validator for the signer', async () => { const shouldApprove = true; - const data = exchangeInstance.setSignatureValidatorApproval.getABIEncodedTransactionData( - validatorAddress, - shouldApprove, - ); + const data = exchangeInstance + .setSignatureValidatorApproval(validatorAddress, shouldApprove) + .getABIEncodedTransactionData(); const transaction = await takerTransactionFactory.newSignedTransactionAsync({ data }); const transactionReceipt = await exchangeWrapper.executeTransactionAsync(transaction, senderAddress); const validatorApprovalLogs = transactionReceipt.logs.filter( @@ -615,10 +606,9 @@ blockchainTests.resets('Exchange transactions', env => { }); it('should approve a validator for the caller if called with no signature', async () => { const shouldApprove = true; - const data = exchangeInstance.setSignatureValidatorApproval.getABIEncodedTransactionData( - validatorAddress, - shouldApprove, - ); + const data = exchangeInstance + .setSignatureValidatorApproval(validatorAddress, shouldApprove) + .getABIEncodedTransactionData(); const transaction = await takerTransactionFactory.newSignedTransactionAsync({ data }); transaction.signature = constants.NULL_BYTES; const transactionReceipt = await exchangeWrapper.executeTransactionAsync(transaction, takerAddress); @@ -839,11 +829,12 @@ blockchainTests.resets('Exchange transactions', env => { const data2 = exchangeDataEncoder.encodeOrdersToExchangeData(ExchangeFunctionName.FillOrder, [order2]); const transaction1 = await takerTransactionFactory.newSignedTransactionAsync({ data: data1 }); const transaction2 = await taker2TransactionFactory.newSignedTransactionAsync({ data: data2 }); - const returnData = await exchangeInstance.batchExecuteTransactions.callAsync( - [transaction1, transaction2], - [transaction1.signature, transaction2.signature], - { from: senderAddress }, - ); + const returnData = await exchangeInstance + .batchExecuteTransactions( + [transaction1, transaction2], + [transaction1.signature, transaction2.signature], + ) + .callAsync({ from: senderAddress }); const abi = artifacts.Exchange.compilerOutput.abi; const methodAbi = abi.filter( abiItem => (abiItem as MethodAbi).name === ExchangeFunctionName.FillOrder, @@ -945,11 +936,12 @@ blockchainTests.resets('Exchange transactions', env => { ]); const transaction1 = await takerTransactionFactory.newSignedTransactionAsync({ data: data1 }); const transaction2 = await makerTransactionFactory.newSignedTransactionAsync({ data: data2 }); - const returnData = await exchangeInstance.batchExecuteTransactions.callAsync( - [transaction1, transaction2], - [transaction1.signature, transaction2.signature], - { from: senderAddress }, - ); + const returnData = await exchangeInstance + .batchExecuteTransactions( + [transaction1, transaction2], + [transaction1.signature, transaction2.signature], + ) + .callAsync({ from: senderAddress }); const abi = artifacts.Exchange.compilerOutput.abi; const methodAbi = abi.filter( abiItem => (abiItem as MethodAbi).name === ExchangeFunctionName.FillOrder, diff --git a/contracts/exchange/test/transactions_unit_tests.ts b/contracts/exchange/test/transactions_unit_tests.ts index 257bbf798d..1a537d7a26 100644 --- a/contracts/exchange/test/transactions_unit_tests.ts +++ b/contracts/exchange/test/transactions_unit_tests.ts @@ -1,4 +1,4 @@ -import { blockchainTests, constants, describe, expect, hexRandom, TransactionHelper } from '@0x/contracts-test-utils'; +import { blockchainTests, constants, describe, expect, hexRandom, transactionHelper } from '@0x/contracts-test-utils'; import { ExchangeRevertErrors, transactionHashUtils } from '@0x/order-utils'; import { EIP712DomainWithDefaultSchema, ZeroExTransaction } from '@0x/types'; import { BigNumber, StringRevertError } from '@0x/utils'; @@ -29,8 +29,6 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef const DEADBEEF_RETURN_DATA = '0xdeadbeef'; const INVALID_SIGNATURE = '0x0000'; - const transactionHelper = new TransactionHelper(web3Wrapper, artifacts); - before(async () => { // A list of available addresses to use during testing. accounts = await web3Wrapper.getAvailableAddressesAsync(); @@ -54,11 +52,9 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef * Generates calldata for a call to `executable()` in the `TestTransactions` contract. */ function getExecutableCallData(shouldSucceed: boolean, callData: string, returnData: string): string { - return (transactionsContract as any).executable.getABIEncodedTransactionData( - shouldSucceed, - callData, - returnData, - ); + return (transactionsContract as any) + .executable(shouldSucceed, callData, returnData) + .getABIEncodedTransactionData(); } interface GenerateZeroExTransactionParams { @@ -109,10 +105,9 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef ); // Call the `batchExecuteTransactions()` function and ensure that it reverts with the expected revert error. - const tx = transactionsContract.batchExecuteTransactions.awaitTransactionSuccessAsync( - [transaction], - [randomSignature()], - ); + const tx = transactionsContract + .batchExecuteTransactions([transaction], [randomSignature()]) + .awaitTransactionSuccessAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -132,10 +127,9 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef ); // Call the `batchExecuteTransactions()` function and ensure that it reverts with the expected revert error. - const tx = transactionsContract.batchExecuteTransactions.awaitTransactionSuccessAsync( - [transaction1, transaction2], - [randomSignature(), randomSignature()], - ); + const tx = transactionsContract + .batchExecuteTransactions([transaction1, transaction2], [randomSignature(), randomSignature()]) + .awaitTransactionSuccessAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -155,10 +149,9 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef ); // Call the `batchExecuteTransactions()` function and ensure that it reverts with the expected revert error. - const tx = transactionsContract.batchExecuteTransactions.awaitTransactionSuccessAsync( - [transaction1, transaction2], - [randomSignature(), randomSignature()], - ); + const tx = transactionsContract + .batchExecuteTransactions([transaction1, transaction2], [randomSignature(), randomSignature()]) + .awaitTransactionSuccessAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -176,13 +169,11 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef ExchangeRevertErrors.TransactionErrorCode.AlreadyExecuted, transactionHash2, ); - const tx = transactionsContract.batchExecuteTransactions.awaitTransactionSuccessAsync( - [transaction1, transaction2], - [randomSignature(), randomSignature()], - { + const tx = transactionsContract + .batchExecuteTransactions([transaction1, transaction2], [randomSignature(), randomSignature()]) + .awaitTransactionSuccessAsync({ from: accounts[0], - }, - ); + }); return expect(tx).to.revertWith(expectedError); }); @@ -203,7 +194,7 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef ); expect(result.length).to.be.eq(1); - const returnData = transactionsContract.executeTransaction.getABIDecodedReturnData(result[0]); + const returnData = transactionsContract.getABIDecodedReturnData('executeTransaction', result[0]); expect(returnData).to.equal(DEADBEEF_RETURN_DATA); // Ensure that the correct number of events were logged. @@ -241,10 +232,10 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef ); expect(result.length).to.be.eq(2); - expect(transactionsContract.executeTransaction.getABIDecodedReturnData(result[0])).to.equal( + expect(transactionsContract.getABIDecodedReturnData('executeTransaction', result[0])).to.equal( DEADBEEF_RETURN_DATA, ); - expect(transactionsContract.executeTransaction.getABIDecodedReturnData(result[1])).to.equal(returnData2); + expect(transactionsContract.getABIDecodedReturnData('executeTransaction', result[1])).to.equal(returnData2); // Verify that the correct number of events were logged. const logs = receipt.logs as Array>; @@ -269,17 +260,18 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef const innerTransaction2 = await generateZeroExTransactionAsync({ signerAddress: accounts[1] }); const innerBatchExecuteTransaction = await generateZeroExTransactionAsync({ signerAddress: accounts[2], - callData: transactionsContract.batchExecuteTransactions.getABIEncodedTransactionData( - [innerTransaction1, innerTransaction2], - [randomSignature(), randomSignature()], - ), + callData: transactionsContract + .batchExecuteTransactions( + [innerTransaction1, innerTransaction2], + [randomSignature(), randomSignature()], + ) + .getABIEncodedTransactionData(), }); const outerExecuteTransaction = await generateZeroExTransactionAsync({ signerAddress: accounts[1], - callData: transactionsContract.executeTransaction.getABIEncodedTransactionData( - innerBatchExecuteTransaction, - randomSignature(), - ), + callData: transactionsContract + .executeTransaction(innerBatchExecuteTransaction, randomSignature()) + .getABIEncodedTransactionData(), }); const innerBatchExecuteTransactionHash = transactionHashUtils.getTransactionHashHex( innerBatchExecuteTransaction, @@ -293,11 +285,9 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef outerExecuteTransactionHash, innerExpectedError.encode(), ); - const tx = transactionsContract.batchExecuteTransactions.awaitTransactionSuccessAsync( - [outerExecuteTransaction], - [randomSignature()], - { from: accounts[2] }, - ); + const tx = transactionsContract + .batchExecuteTransactions([outerExecuteTransaction], [randomSignature()]) + .awaitTransactionSuccessAsync({ from: accounts[2] }); return expect(tx).to.revertWith(outerExpectedError); }); it('should allow recursion as long as currentContextAddress is not set', async () => { @@ -306,34 +296,32 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef // From this point on, all transactions and calls will have the same sender, which does not change currentContextAddress when called const innerBatchExecuteTransaction = await generateZeroExTransactionAsync({ signerAddress: accounts[2], - callData: transactionsContract.batchExecuteTransactions.getABIEncodedTransactionData( - [innerTransaction1, innerTransaction2], - [randomSignature(), randomSignature()], - ), + callData: transactionsContract + .batchExecuteTransactions( + [innerTransaction1, innerTransaction2], + [randomSignature(), randomSignature()], + ) + .getABIEncodedTransactionData(), }); const outerExecuteTransaction = await generateZeroExTransactionAsync({ signerAddress: accounts[2], - callData: transactionsContract.executeTransaction.getABIEncodedTransactionData( - innerBatchExecuteTransaction, - randomSignature(), - ), + callData: transactionsContract + .executeTransaction(innerBatchExecuteTransaction, randomSignature()) + .getABIEncodedTransactionData(), }); return expect( - transactionsContract.batchExecuteTransactions.awaitTransactionSuccessAsync( - [outerExecuteTransaction], - [randomSignature()], - { from: accounts[2] }, - ), + transactionsContract + .batchExecuteTransactions([outerExecuteTransaction], [randomSignature()]) + .awaitTransactionSuccessAsync({ from: accounts[2] }), ).to.be.fulfilled(''); }); }); describe('executeTransaction', () => { function getExecuteTransactionCallData(transaction: ZeroExTransaction, signature: string): string { - return (transactionsContract as any).executeTransaction.getABIEncodedTransactionData( - transaction, - signature, - ); + return (transactionsContract as any) + .executeTransaction(transaction, signature) + .getABIEncodedTransactionData(); } it('should revert if the current time is past the expiration time', async () => { const transaction = await generateZeroExTransactionAsync({ @@ -344,10 +332,9 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef ExchangeRevertErrors.TransactionErrorCode.Expired, transactionHash, ); - const tx = transactionsContract.executeTransaction.awaitTransactionSuccessAsync( - transaction, - randomSignature(), - ); + const tx = transactionsContract + .executeTransaction(transaction, randomSignature()) + .awaitTransactionSuccessAsync(); return expect(tx).to.revertWith(expectedError); }); it('should revert if the transaction is submitted with a gasPrice that does not equal the required gasPrice', async () => { @@ -359,13 +346,11 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef actualGasPrice, transaction.gasPrice, ); - const tx = transactionsContract.executeTransaction.awaitTransactionSuccessAsync( - transaction, - randomSignature(), - { + const tx = transactionsContract + .executeTransaction(transaction, randomSignature()) + .awaitTransactionSuccessAsync({ gasPrice: actualGasPrice, - }, - ); + }); return expect(tx).to.revertWith(expectedError); }); it('should revert if reentrancy occurs in the middle of an executeTransaction call and msg.sender != signer for both calls', async () => { @@ -383,13 +368,11 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef accounts[0], ).encode(); const expectedError = new ExchangeRevertErrors.TransactionExecutionError(outerTransactionHash, errorData); - const tx = transactionsContract.executeTransaction.awaitTransactionSuccessAsync( - outerTransaction, - validSignature, - { + const tx = transactionsContract + .executeTransaction(outerTransaction, validSignature) + .awaitTransactionSuccessAsync({ from: accounts[1], // Different then the signing addresses - }, - ); + }); return expect(tx).to.revertWith(expectedError); }); it('should revert if reentrancy occurs in the middle of an executeTransaction call and msg.sender != signer and then msg.sender == signer', async () => { @@ -407,13 +390,11 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef accounts[0], ).encode(); const expectedError = new ExchangeRevertErrors.TransactionExecutionError(outerTransactionHash, errorData); - const tx = transactionsContract.executeTransaction.awaitTransactionSuccessAsync( - outerTransaction, - validSignature, - { + const tx = transactionsContract + .executeTransaction(outerTransaction, validSignature) + .awaitTransactionSuccessAsync({ from: accounts[1], // Different then the signing addresses - }, - ); + }); return expect(tx).to.revertWith(expectedError); }); it('should allow reentrancy in the middle of an executeTransaction call if msg.sender == signer for both calls', async () => { @@ -425,7 +406,7 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef returnData: DEADBEEF_RETURN_DATA, }); return expect( - transactionsContract.executeTransaction.awaitTransactionSuccessAsync(outerTransaction, validSignature, { + transactionsContract.executeTransaction(outerTransaction, validSignature).awaitTransactionSuccessAsync({ from: accounts[0], }), ).to.be.fulfilled(''); @@ -439,7 +420,7 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef returnData: DEADBEEF_RETURN_DATA, }); return expect( - transactionsContract.executeTransaction.awaitTransactionSuccessAsync(outerTransaction, validSignature, { + transactionsContract.executeTransaction(outerTransaction, validSignature).awaitTransactionSuccessAsync({ from: accounts[0], }), ).to.be.fulfilled(''); @@ -450,17 +431,16 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef const transactionHash = transactionHashUtils.getTransactionHashHex(transaction); // Use the transaction in execute transaction. await expect( - transactionsContract.executeTransaction.awaitTransactionSuccessAsync(transaction, validSignature), + transactionsContract.executeTransaction(transaction, validSignature).awaitTransactionSuccessAsync(), ).to.be.fulfilled(''); // Use the same transaction to make another call const expectedError = new ExchangeRevertErrors.TransactionError( ExchangeRevertErrors.TransactionErrorCode.AlreadyExecuted, transactionHash, ); - const tx = transactionsContract.executeTransaction.awaitTransactionSuccessAsync( - transaction, - validSignature, - ); + const tx = transactionsContract + .executeTransaction(transaction, validSignature) + .awaitTransactionSuccessAsync(); return expect(tx).to.revertWith(expectedError); }); it('should revert if the signer != msg.sender and the signature is not valid', async () => { @@ -472,13 +452,11 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef accounts[1], INVALID_SIGNATURE, ); - const tx = transactionsContract.executeTransaction.awaitTransactionSuccessAsync( - transaction, - INVALID_SIGNATURE, - { + const tx = transactionsContract + .executeTransaction(transaction, INVALID_SIGNATURE) + .awaitTransactionSuccessAsync({ from: accounts[0], - }, - ); + }); return expect(tx).to.revertWith(expectedError); }); it('should revert if the signer == msg.sender but the delegatecall fails', async () => { @@ -493,13 +471,11 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef transactionHash, executableError.encode(), ); - const tx = transactionsContract.executeTransaction.awaitTransactionSuccessAsync( - transaction, - randomSignature(), - { + const tx = transactionsContract + .executeTransaction(transaction, randomSignature()) + .awaitTransactionSuccessAsync({ from: accounts[1], - }, - ); + }); return expect(tx).to.revertWith(expectedError); }); it('should revert if the signer != msg.sender and the signature is valid but the delegatecall fails', async () => { @@ -515,13 +491,11 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef transactionHash, executableError.encode(), ); - const tx = transactionsContract.executeTransaction.awaitTransactionSuccessAsync( - transaction, - validSignature, - { + const tx = transactionsContract + .executeTransaction(transaction, validSignature) + .awaitTransactionSuccessAsync({ from: accounts[0], - }, - ); + }); return expect(tx).to.revertWith(expectedError); }); it('should succeed with the correct return hash and event emitted when msg.sender != signer', async () => { @@ -540,7 +514,7 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef { from: accounts[0] }, ); - expect(transactionsContract.executeTransaction.getABIDecodedReturnData(result)).to.equal( + expect(transactionsContract.getABIDecodedReturnData('executeTransaction', result)).to.equal( DEADBEEF_RETURN_DATA, ); @@ -571,7 +545,7 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef { from: accounts[0] }, ); - expect(transactionsContract.executeTransaction.getABIDecodedReturnData(result)).to.equal( + expect(transactionsContract.getABIDecodedReturnData('executeTransaction', result)).to.equal( DEADBEEF_RETURN_DATA, ); @@ -599,7 +573,7 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef transactionHash, ); expect( - transactionsContract.assertExecutableTransaction.callAsync(transaction, randomSignature()), + transactionsContract.assertExecutableTransaction(transaction, randomSignature()).callAsync(), ).to.revertWith(expectedError); }); it('should revert if the gasPrice is less than required', async () => { @@ -612,7 +586,7 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef transaction.gasPrice, ); expect( - transactionsContract.assertExecutableTransaction.callAsync(transaction, randomSignature(), { + transactionsContract.assertExecutableTransaction(transaction, randomSignature()).callAsync({ gasPrice: actualGasPrice, }), ).to.revertWith(expectedError); @@ -627,30 +601,30 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef transaction.gasPrice, ); expect( - transactionsContract.assertExecutableTransaction.callAsync(transaction, randomSignature(), { + transactionsContract.assertExecutableTransaction(transaction, randomSignature()).callAsync({ gasPrice: actualGasPrice, }), ).to.revertWith(expectedError); }); it('should revert if currentContextAddress is non-zero', async () => { - await transactionsContract.setCurrentContextAddress.awaitTransactionSuccessAsync(accounts[0]); + await transactionsContract.setCurrentContextAddress(accounts[0]).awaitTransactionSuccessAsync(); const transaction = await generateZeroExTransactionAsync(); const transactionHash = transactionHashUtils.getTransactionHashHex(transaction); const expectedError = new ExchangeRevertErrors.TransactionInvalidContextError(transactionHash, accounts[0]); expect( - transactionsContract.assertExecutableTransaction.callAsync(transaction, randomSignature()), + transactionsContract.assertExecutableTransaction(transaction, randomSignature()).callAsync(), ).to.revertWith(expectedError); }); it('should revert if the transaction has already been executed', async () => { const transaction = await generateZeroExTransactionAsync(); const transactionHash = transactionHashUtils.getTransactionHashHex(transaction); - await transactionsContract.setTransactionExecuted.awaitTransactionSuccessAsync(transactionHash); + await transactionsContract.setTransactionExecuted(transactionHash).awaitTransactionSuccessAsync(); const expectedError = new ExchangeRevertErrors.TransactionError( ExchangeRevertErrors.TransactionErrorCode.AlreadyExecuted, transactionHash, ); expect( - transactionsContract.assertExecutableTransaction.callAsync(transaction, randomSignature()), + transactionsContract.assertExecutableTransaction(transaction, randomSignature()).callAsync(), ).to.revertWith(expectedError); }); it('should revert if signer != msg.sender and the signature is invalid', async () => { @@ -663,7 +637,7 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef INVALID_SIGNATURE, ); expect( - transactionsContract.assertExecutableTransaction.callAsync(transaction, INVALID_SIGNATURE, { + transactionsContract.assertExecutableTransaction(transaction, INVALID_SIGNATURE).callAsync({ from: accounts[1], }), ).to.revertWith(expectedError); @@ -671,7 +645,7 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef it('should be successful if signer == msg.sender and the signature is invalid', async () => { const transaction = await generateZeroExTransactionAsync({ signerAddress: accounts[0] }); return expect( - transactionsContract.assertExecutableTransaction.callAsync(transaction, INVALID_SIGNATURE, { + transactionsContract.assertExecutableTransaction(transaction, INVALID_SIGNATURE).callAsync({ from: accounts[0], }), ).to.be.fulfilled(''); @@ -679,7 +653,7 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef it('should be successful if signer == msg.sender and the signature is valid', async () => { const transaction = await generateZeroExTransactionAsync({ signerAddress: accounts[0] }); return expect( - transactionsContract.assertExecutableTransaction.callAsync(transaction, randomSignature(), { + transactionsContract.assertExecutableTransaction(transaction, randomSignature()).callAsync({ from: accounts[0], }), ).to.be.fulfilled(''); @@ -687,7 +661,7 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef it('should be successful if not expired, the gasPrice is correct, the tx has not been executed, currentContextAddress has not been set, signer != msg.sender, and the signature is valid', async () => { const transaction = await generateZeroExTransactionAsync({ signerAddress: accounts[0] }); return expect( - transactionsContract.assertExecutableTransaction.callAsync(transaction, randomSignature(), { + transactionsContract.assertExecutableTransaction(transaction, randomSignature()).callAsync({ from: accounts[1], }), ).to.be.fulfilled(''); @@ -697,30 +671,27 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef describe('setCurrentContextAddressIfRequired', () => { it('should set the currentContextAddress if signer not equal to sender', async () => { const randomAddress = hexRandom(20); - await transactionsContract.setCurrentContextAddressIfRequired.awaitTransactionSuccessAsync( - randomAddress, - randomAddress, - ); - const currentContextAddress = await transactionsContract.currentContextAddress.callAsync(); + await transactionsContract + .setCurrentContextAddressIfRequired(randomAddress, randomAddress) + .awaitTransactionSuccessAsync(); + const currentContextAddress = await transactionsContract.currentContextAddress().callAsync(); expect(currentContextAddress).to.eq(randomAddress); }); it('should not set the currentContextAddress if signer equal to sender', async () => { const randomAddress = hexRandom(20); - await transactionsContract.setCurrentContextAddressIfRequired.awaitTransactionSuccessAsync( - accounts[0], - randomAddress, - { + await transactionsContract + .setCurrentContextAddressIfRequired(accounts[0], randomAddress) + .awaitTransactionSuccessAsync({ from: accounts[0], - }, - ); - const currentContextAddress = await transactionsContract.currentContextAddress.callAsync(); + }); + const currentContextAddress = await transactionsContract.currentContextAddress().callAsync(); expect(currentContextAddress).to.eq(constants.NULL_ADDRESS); }); }); describe('getCurrentContext', () => { it('should return the sender address when there is not a saved context address', async () => { - const currentContextAddress = await transactionsContract.getCurrentContextAddress.callAsync({ + const currentContextAddress = await transactionsContract.getCurrentContextAddress().callAsync({ from: accounts[0], }); expect(currentContextAddress).to.be.eq(accounts[0]); @@ -728,10 +699,10 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef it('should return the sender address when there is a saved context address', async () => { // Set the current context address to the taker address - await transactionsContract.setCurrentContextAddress.awaitTransactionSuccessAsync(accounts[1]); + await transactionsContract.setCurrentContextAddress(accounts[1]).awaitTransactionSuccessAsync(); // Ensure that the queried current context address is the same as the address that was set. - const currentContextAddress = await transactionsContract.getCurrentContextAddress.callAsync({ + const currentContextAddress = await transactionsContract.getCurrentContextAddress().callAsync({ from: accounts[0], }); expect(currentContextAddress).to.be.eq(accounts[1]); diff --git a/contracts/exchange/test/utils/asset_wrapper.ts b/contracts/exchange/test/utils/asset_wrapper.ts index fe1ffd8739..a04575213f 100644 --- a/contracts/exchange/test/utils/asset_wrapper.ts +++ b/contracts/exchange/test/utils/asset_wrapper.ts @@ -32,7 +32,7 @@ export class AssetWrapper { }); } public async getBalanceAsync(userAddress: string, assetData: string): Promise { - const proxyId = await this._devUtils.decodeAssetProxyId.callAsync(assetData); + const proxyId = await this._devUtils.decodeAssetProxyId(assetData).callAsync(); switch (proxyId) { case AssetProxyId.ERC20: { // tslint:disable-next-line:no-unnecessary-type-assertion @@ -44,9 +44,9 @@ export class AssetWrapper { // tslint:disable-next-line:no-unnecessary-type-assertion const assetWrapper = this._proxyIdToAssetWrappers[proxyId] as ERC721Wrapper; // tslint:disable-next-line:no-unused-variable - const [assetProxyId, tokenAddress, tokenId] = await this._devUtils.decodeERC721AssetData.callAsync( - assetData, - ); + const [assetProxyId, tokenAddress, tokenId] = await this._devUtils + .decodeERC721AssetData(assetData) + .callAsync(); const isOwner = await assetWrapper.isOwnerAsync(userAddress, tokenAddress, tokenId); const balance = isOwner ? ONE_NFT_UNIT : ZERO_NFT_UNIT; return balance; @@ -59,7 +59,7 @@ export class AssetWrapper { assetProxyAddress, tokenAddress, tokenIds, - ] = await this._devUtils.decodeERC1155AssetData.callAsync(assetData); + ] = await this._devUtils.decodeERC1155AssetData(assetData).callAsync(); const assetWrapper = assetProxyWrapper.getContractWrapper(tokenAddress); const balances = await Promise.all( _.map(tokenIds).map(tokenId => assetWrapper.getBalanceAsync(userAddress, tokenId)), @@ -68,9 +68,9 @@ export class AssetWrapper { } case AssetProxyId.MultiAsset: { // tslint:disable-next-line:no-unused-variable - const [assetProxyId, amounts, nestedAssetData] = await this._devUtils.decodeMultiAssetData.callAsync( - assetData, - ); + const [assetProxyId, amounts, nestedAssetData] = await this._devUtils + .decodeMultiAssetData(assetData) + .callAsync(); const nestedBalances = await Promise.all( nestedAssetData.map(async _nestedAssetData => this.getBalanceAsync(userAddress, _nestedAssetData)), ); @@ -84,7 +84,7 @@ export class AssetWrapper { } } public async setBalanceAsync(userAddress: string, assetData: string, desiredBalance: BigNumber): Promise { - const proxyId = await this._devUtils.decodeAssetProxyId.callAsync(assetData); + const proxyId = await this._devUtils.decodeAssetProxyId(assetData).callAsync(); switch (proxyId) { case AssetProxyId.ERC20: { // tslint:disable-next-line:no-unnecessary-type-assertion @@ -100,9 +100,9 @@ export class AssetWrapper { // tslint:disable-next-line:no-unnecessary-type-assertion const erc721Wrapper = this._proxyIdToAssetWrappers[proxyId] as ERC721Wrapper; // tslint:disable-next-line:no-unused-variable - const [assetProxyId, tokenAddress, tokenId] = await this._devUtils.decodeERC721AssetData.callAsync( - assetData, - ); + const [assetProxyId, tokenAddress, tokenId] = await this._devUtils + .decodeERC721AssetData(assetData) + .callAsync(); const doesTokenExist = erc721Wrapper.doesTokenExistAsync(tokenAddress, tokenId); if (!doesTokenExist && desiredBalance.gte(1)) { await erc721Wrapper.mintAsync(tokenAddress, tokenId, userAddress); @@ -134,7 +134,7 @@ export class AssetWrapper { tokenAddress, tokenIds, tokenValues, - ] = await this._devUtils.decodeERC1155AssetData.callAsync(assetData); + ] = await this._devUtils.decodeERC1155AssetData(assetData).callAsync(); const assetWrapper = assetProxyWrapper.getContractWrapper(tokenAddress); const tokenValuesSum = BigNumber.sum(...tokenValues); let tokenValueRatios = tokenValues; @@ -197,9 +197,9 @@ export class AssetWrapper { } case AssetProxyId.MultiAsset: { // tslint:disable-next-line:no-unused-variable - const [assetProxyId, amounts, nestedAssetData] = await this._devUtils.decodeMultiAssetData.callAsync( - assetData, - ); + const [assetProxyId, amounts, nestedAssetData] = await this._devUtils + .decodeMultiAssetData(assetData) + .callAsync(); const amountsSum = BigNumber.sum(...amounts); let assetAmountRatios = amounts; if (!amountsSum.eq(0)) { @@ -220,7 +220,7 @@ export class AssetWrapper { assetData: string, desiredBalance: BigNumber, ): Promise { - const proxyId = await this._devUtils.decodeAssetProxyId.callAsync(assetData); + const proxyId = await this._devUtils.decodeAssetProxyId(assetData).callAsync(); switch (proxyId) { case AssetProxyId.ERC20: case AssetProxyId.ERC721: @@ -235,7 +235,7 @@ export class AssetWrapper { } } public async getProxyAllowanceAsync(userAddress: string, assetData: string): Promise { - const proxyId = await this._devUtils.decodeAssetProxyId.callAsync(assetData); + const proxyId = await this._devUtils.decodeAssetProxyId(assetData).callAsync(); switch (proxyId) { case AssetProxyId.ERC20: { // tslint:disable-next-line:no-unnecessary-type-assertion @@ -247,9 +247,9 @@ export class AssetWrapper { // tslint:disable-next-line:no-unnecessary-type-assertion const assetWrapper = this._proxyIdToAssetWrappers[proxyId] as ERC721Wrapper; // tslint:disable-next-line:no-unused-variable - const [assetProxyId, tokenAddress, tokenId] = await this._devUtils.decodeERC721AssetData.callAsync( - assetData, - ); + const [assetProxyId, tokenAddress, tokenId] = await this._devUtils + .decodeERC721AssetData(assetData) + .callAsync(); const isProxyApprovedForAll = await assetWrapper.isProxyApprovedForAllAsync(userAddress, tokenAddress); if (isProxyApprovedForAll) { return constants.UNLIMITED_ALLOWANCE_IN_BASE_UNITS; @@ -263,9 +263,9 @@ export class AssetWrapper { // tslint:disable-next-line:no-unnecessary-type-assertion const assetProxyWrapper = this._proxyIdToAssetWrappers[proxyId] as ERC1155ProxyWrapper; // tslint:disable-next-line:no-unused-variable - const [assetProxyAddress, tokenAddress] = await this._devUtils.decodeERC1155AssetData.callAsync( - assetData, - ); + const [assetProxyAddress, tokenAddress] = await this._devUtils + .decodeERC1155AssetData(assetData) + .callAsync(); const isApprovedForAll = await assetProxyWrapper.isProxyApprovedForAllAsync(userAddress, tokenAddress); if (!isApprovedForAll) { // ERC1155 is all or nothing. @@ -275,9 +275,9 @@ export class AssetWrapper { } case AssetProxyId.MultiAsset: { // tslint:disable-next-line:no-unused-variable - const [assetProxyId, amounts, nestedAssetData] = await this._devUtils.decodeMultiAssetData.callAsync( - assetData, - ); + const [assetProxyId, amounts, nestedAssetData] = await this._devUtils + .decodeMultiAssetData(assetData) + .callAsync(); const allowances = await Promise.all( nestedAssetData.map(async _nestedAssetData => this.getProxyAllowanceAsync(userAddress, _nestedAssetData), @@ -294,7 +294,7 @@ export class AssetWrapper { assetData: string, desiredAllowance: BigNumber, ): Promise { - const proxyId = await this._devUtils.decodeAssetProxyId.callAsync(assetData); + const proxyId = await this._devUtils.decodeAssetProxyId(assetData).callAsync(); switch (proxyId) { case AssetProxyId.ERC20: { // tslint:disable-next-line:no-unnecessary-type-assertion @@ -315,9 +315,9 @@ export class AssetWrapper { // tslint:disable-next-line:no-unnecessary-type-assertion const erc721Wrapper = this._proxyIdToAssetWrappers[proxyId] as ERC721Wrapper; // tslint:disable-next-line:no-unused-variable - const [assetProxyId, tokenAddress, tokenId] = await this._devUtils.decodeERC721AssetData.callAsync( - assetData, - ); + const [assetProxyId, tokenAddress, tokenId] = await this._devUtils + .decodeERC721AssetData(assetData) + .callAsync(); const doesTokenExist = await erc721Wrapper.doesTokenExistAsync(tokenAddress, tokenId); if (!doesTokenExist) { @@ -352,9 +352,9 @@ export class AssetWrapper { // tslint:disable-next-line:no-unnecessary-type-assertion const assetProxyWrapper = this._proxyIdToAssetWrappers[proxyId] as ERC1155ProxyWrapper; // tslint:disable-next-line:no-unused-variable - const [assetProxyAddress, tokenAddress] = await this._devUtils.decodeERC1155AssetData.callAsync( - assetData, - ); + const [assetProxyAddress, tokenAddress] = await this._devUtils + .decodeERC1155AssetData(assetData) + .callAsync(); // ERC1155 allowances are all or nothing. const shouldApprovedForAll = desiredAllowance.gt(0); const currentAllowance = await this.getProxyAllowanceAsync(userAddress, assetData); @@ -369,9 +369,9 @@ export class AssetWrapper { } case AssetProxyId.MultiAsset: { // tslint:disable-next-line:no-unused-variable - const [assetProxyId, amounts, nestedAssetData] = await this._devUtils.decodeMultiAssetData.callAsync( - assetData, - ); + const [assetProxyId, amounts, nestedAssetData] = await this._devUtils + .decodeMultiAssetData(assetData) + .callAsync(); await Promise.all( nestedAssetData.map(async _nestedAssetData => this.setProxyAllowanceAsync(userAddress, _nestedAssetData, desiredAllowance), diff --git a/contracts/exchange/test/utils/exchange_data_encoder.ts b/contracts/exchange/test/utils/exchange_data_encoder.ts index 5b7e383d08..87d7e227c2 100644 --- a/contracts/exchange/test/utils/exchange_data_encoder.ts +++ b/contracts/exchange/test/utils/exchange_data_encoder.ts @@ -9,44 +9,38 @@ export const exchangeDataEncoder = { const exchangeInstance = new IExchangeContract(constants.NULL_ADDRESS, provider); let data; if (exchangeConstants.SINGLE_FILL_FN_NAMES.indexOf(fnName) !== -1) { - data = (exchangeInstance as any)[fnName].getABIEncodedTransactionData( - orders[0], - orders[0].takerAssetAmount, - orders[0].signature, - ); + data = (exchangeInstance as any) + [fnName](orders[0], orders[0].takerAssetAmount, orders[0].signature) + .getABIEncodedTransactionData(); } else if (exchangeConstants.BATCH_FILL_FN_NAMES.indexOf(fnName) !== -1) { - data = (exchangeInstance as any)[fnName].getABIEncodedTransactionData( - orders, - orders.map(order => order.takerAssetAmount), - orders.map(order => order.signature), - ); + data = (exchangeInstance as any) + [fnName](orders, orders.map(order => order.takerAssetAmount), orders.map(order => order.signature)) + .getABIEncodedTransactionData(); } else if (exchangeConstants.MARKET_FILL_FN_NAMES.indexOf(fnName) !== -1) { const fillAsset = /Buy/.test(fnName) ? 'makerAssetAmount' : 'takerAssetAmount'; - data = (exchangeInstance as any)[fnName].getABIEncodedTransactionData( - orders, - orders.map(order => order[fillAsset]).reduce((prev, curr) => prev.plus(curr)), - orders.map(order => order.signature), - ); + data = (exchangeInstance as any) + [fnName]( + orders, + orders.map(order => order[fillAsset]).reduce((prev, curr) => prev.plus(curr)), + orders.map(order => order.signature), + ) + .getABIEncodedTransactionData(); } else if (exchangeConstants.MATCH_ORDER_FN_NAMES.indexOf(fnName) !== -1) { - data = exchangeInstance.matchOrders.getABIEncodedTransactionData( - orders[0], - orders[1], - orders[0].signature, - orders[1].signature, - ); + data = exchangeInstance + .matchOrders(orders[0], orders[1], orders[0].signature, orders[1].signature) + .getABIEncodedTransactionData(); } else if (fnName === ExchangeFunctionName.CancelOrder) { - data = exchangeInstance.cancelOrder.getABIEncodedTransactionData(orders[0]); + data = exchangeInstance.cancelOrder(orders[0]).getABIEncodedTransactionData(); } else if (fnName === ExchangeFunctionName.BatchCancelOrders) { - data = exchangeInstance.batchCancelOrders.getABIEncodedTransactionData(orders); + data = exchangeInstance.batchCancelOrders(orders).getABIEncodedTransactionData(); } else if (fnName === ExchangeFunctionName.CancelOrdersUpTo) { - data = exchangeInstance.cancelOrdersUpTo.getABIEncodedTransactionData(constants.ZERO_AMOUNT); + data = exchangeInstance.cancelOrdersUpTo(constants.ZERO_AMOUNT).getABIEncodedTransactionData(); } else if (fnName === ExchangeFunctionName.PreSign) { - data = exchangeInstance.preSign.getABIEncodedTransactionData(orderHashUtils.getOrderHashHex(orders[0])); + data = exchangeInstance.preSign(orderHashUtils.getOrderHashHex(orders[0])).getABIEncodedTransactionData(); } else if (fnName === ExchangeFunctionName.SetSignatureValidatorApproval) { - data = exchangeInstance.setSignatureValidatorApproval.getABIEncodedTransactionData( - constants.NULL_ADDRESS, - true, - ); + data = exchangeInstance + .setSignatureValidatorApproval(constants.NULL_ADDRESS, true) + .getABIEncodedTransactionData(); } else { throw new Error(`Error: ${fnName} not a supported function`); } diff --git a/contracts/exchange/test/utils/exchange_wrapper.ts b/contracts/exchange/test/utils/exchange_wrapper.ts index dead507440..51672aa602 100644 --- a/contracts/exchange/test/utils/exchange_wrapper.ts +++ b/contracts/exchange/test/utils/exchange_wrapper.ts @@ -24,17 +24,14 @@ export class ExchangeWrapper { opts: { takerAssetFillAmount?: BigNumber } = {}, ): Promise { const params = orderUtils.createFill(signedOrder, opts.takerAssetFillAmount); - const txReceipt = await this.exchangeContract.fillOrder.awaitTransactionSuccessAsync( - params.order, - params.takerAssetFillAmount, - params.signature, - { from }, - ); + const txReceipt = await this.exchangeContract + .fillOrder(params.order, params.takerAssetFillAmount, params.signature) + .awaitTransactionSuccessAsync({ from }); return txReceipt; } public async cancelOrderAsync(signedOrder: SignedOrder, from: string): Promise { const params = orderUtils.createCancel(signedOrder); - const txReceipt = await this.exchangeContract.cancelOrder.awaitTransactionSuccessAsync(params.order, { from }); + const txReceipt = await this.exchangeContract.cancelOrder(params.order).awaitTransactionSuccessAsync({ from }); return txReceipt; } public async fillOrKillOrderAsync( @@ -43,12 +40,9 @@ export class ExchangeWrapper { opts: { takerAssetFillAmount?: BigNumber; gasPrice?: BigNumber } = {}, ): Promise { const params = orderUtils.createFill(signedOrder, opts.takerAssetFillAmount); - const txReceipt = await this.exchangeContract.fillOrKillOrder.awaitTransactionSuccessAsync( - params.order, - params.takerAssetFillAmount, - params.signature, - { from, gasPrice: opts.gasPrice }, - ); + const txReceipt = await this.exchangeContract + .fillOrKillOrder(params.order, params.takerAssetFillAmount, params.signature) + .awaitTransactionSuccessAsync({ from, gasPrice: opts.gasPrice }); return txReceipt; } public async batchFillOrdersAsync( @@ -56,111 +50,113 @@ export class ExchangeWrapper { from: string, opts: { takerAssetFillAmounts?: BigNumber[]; gasPrice?: BigNumber } = {}, ): Promise { - return this.exchangeContract.batchFillOrders.awaitTransactionSuccessAsync( - orders, - opts.takerAssetFillAmounts === undefined - ? orders.map(signedOrder => signedOrder.takerAssetAmount) - : opts.takerAssetFillAmounts, - orders.map(signedOrder => signedOrder.signature), - { from, gasPrice: opts.gasPrice }, - ); + return this.exchangeContract + .batchFillOrders( + orders, + opts.takerAssetFillAmounts === undefined + ? orders.map(signedOrder => signedOrder.takerAssetAmount) + : opts.takerAssetFillAmounts, + orders.map(signedOrder => signedOrder.signature), + ) + .awaitTransactionSuccessAsync({ from, gasPrice: opts.gasPrice }); } public async batchFillOrKillOrdersAsync( orders: SignedOrder[], from: string, opts: { takerAssetFillAmounts?: BigNumber[]; gasPrice?: BigNumber } = {}, ): Promise { - return this.exchangeContract.batchFillOrKillOrders.awaitTransactionSuccessAsync( - orders, - opts.takerAssetFillAmounts === undefined - ? orders.map(signedOrder => signedOrder.takerAssetAmount) - : opts.takerAssetFillAmounts, - orders.map(signedOrder => signedOrder.signature), - { from, gasPrice: opts.gasPrice }, - ); + return this.exchangeContract + .batchFillOrKillOrders( + orders, + opts.takerAssetFillAmounts === undefined + ? orders.map(signedOrder => signedOrder.takerAssetAmount) + : opts.takerAssetFillAmounts, + orders.map(signedOrder => signedOrder.signature), + ) + .awaitTransactionSuccessAsync({ from, gasPrice: opts.gasPrice }); } public async batchFillOrdersNoThrowAsync( orders: SignedOrder[], from: string, opts: { takerAssetFillAmounts?: BigNumber[]; gas?: number; gasPrice?: BigNumber } = {}, ): Promise { - return this.exchangeContract.batchFillOrdersNoThrow.awaitTransactionSuccessAsync( - orders, - opts.takerAssetFillAmounts === undefined - ? orders.map(signedOrder => signedOrder.takerAssetAmount) - : opts.takerAssetFillAmounts, - orders.map(signedOrder => signedOrder.signature), - { from, gas: opts.gas, gasPrice: opts.gasPrice }, - ); + return this.exchangeContract + .batchFillOrdersNoThrow( + orders, + opts.takerAssetFillAmounts === undefined + ? orders.map(signedOrder => signedOrder.takerAssetAmount) + : opts.takerAssetFillAmounts, + orders.map(signedOrder => signedOrder.signature), + ) + .awaitTransactionSuccessAsync({ from, gas: opts.gas, gasPrice: opts.gasPrice }); } public async marketSellOrdersNoThrowAsync( orders: SignedOrder[], from: string, opts: { takerAssetFillAmount: BigNumber; gas?: number; gasPrice?: BigNumber }, ): Promise { - return this.exchangeContract.marketSellOrdersNoThrow.awaitTransactionSuccessAsync( - orders, - opts.takerAssetFillAmount, - orders.map(signedOrder => signedOrder.signature), - { from, gas: opts.gas, gasPrice: opts.gasPrice }, - ); + return this.exchangeContract + .marketSellOrdersNoThrow( + orders, + opts.takerAssetFillAmount, + orders.map(signedOrder => signedOrder.signature), + ) + .awaitTransactionSuccessAsync({ from, gas: opts.gas, gasPrice: opts.gasPrice }); } public async marketBuyOrdersNoThrowAsync( orders: SignedOrder[], from: string, opts: { makerAssetFillAmount: BigNumber; gas?: number; gasPrice?: BigNumber }, ): Promise { - return this.exchangeContract.marketBuyOrdersNoThrow.awaitTransactionSuccessAsync( - orders, - opts.makerAssetFillAmount, - orders.map(signedOrder => signedOrder.signature), - { from, gas: opts.gas }, - ); + return this.exchangeContract + .marketBuyOrdersNoThrow(orders, opts.makerAssetFillAmount, orders.map(signedOrder => signedOrder.signature)) + .awaitTransactionSuccessAsync({ from, gas: opts.gas }); } public async marketSellOrdersFillOrKillAsync( orders: SignedOrder[], from: string, opts: { takerAssetFillAmount: BigNumber; gas?: number }, ): Promise { - return this.exchangeContract.marketSellOrdersFillOrKill.awaitTransactionSuccessAsync( - orders, - opts.takerAssetFillAmount, - orders.map(signedOrder => signedOrder.signature), - { from, gas: opts.gas }, - ); + return this.exchangeContract + .marketSellOrdersFillOrKill( + orders, + opts.takerAssetFillAmount, + orders.map(signedOrder => signedOrder.signature), + ) + .awaitTransactionSuccessAsync({ from, gas: opts.gas }); } public async marketBuyOrdersFillOrKillAsync( orders: SignedOrder[], from: string, opts: { makerAssetFillAmount: BigNumber; gas?: number }, ): Promise { - return this.exchangeContract.marketBuyOrdersFillOrKill.awaitTransactionSuccessAsync( - orders, - opts.makerAssetFillAmount, - orders.map(signedOrder => signedOrder.signature), - { from, gas: opts.gas }, - ); + return this.exchangeContract + .marketBuyOrdersFillOrKill( + orders, + opts.makerAssetFillAmount, + orders.map(signedOrder => signedOrder.signature), + ) + .awaitTransactionSuccessAsync({ from, gas: opts.gas }); } public async batchCancelOrdersAsync( orders: SignedOrder[], from: string, ): Promise { - return this.exchangeContract.batchCancelOrders.awaitTransactionSuccessAsync(orders, { from }); + return this.exchangeContract.batchCancelOrders(orders).awaitTransactionSuccessAsync({ from }); } public async cancelOrdersUpToAsync(salt: BigNumber, from: string): Promise { - const txReceipt = await this.exchangeContract.cancelOrdersUpTo.awaitTransactionSuccessAsync(salt, { from }); + const txReceipt = await this.exchangeContract.cancelOrdersUpTo(salt).awaitTransactionSuccessAsync({ from }); return txReceipt; } public async registerAssetProxyAsync( assetProxyAddress: string, from: string, ): Promise { - const txReceipt = await this.exchangeContract.registerAssetProxy.awaitTransactionSuccessAsync( - assetProxyAddress, - { + const txReceipt = await this.exchangeContract + .registerAssetProxy(assetProxyAddress) + .awaitTransactionSuccessAsync({ from, - }, - ); + }); return txReceipt; } public async executeTransactionAsync( @@ -168,11 +164,9 @@ export class ExchangeWrapper { from: string, opts: { gasPrice?: BigNumber } = {}, ): Promise { - return this.exchangeContract.executeTransaction.awaitTransactionSuccessAsync( - signedTransaction, - signedTransaction.signature, - { from, gasPrice: opts.gasPrice }, - ); + return this.exchangeContract + .executeTransaction(signedTransaction, signedTransaction.signature) + .awaitTransactionSuccessAsync({ from, gasPrice: opts.gasPrice }); } public async batchExecuteTransactionsAsync( signedTransactions: SignedZeroExTransaction[], @@ -180,29 +174,27 @@ export class ExchangeWrapper { opts: { gasPrice?: BigNumber } = {}, ): Promise { const signatures = signedTransactions.map(signedTransaction => signedTransaction.signature); - return this.exchangeContract.batchExecuteTransactions.awaitTransactionSuccessAsync( - signedTransactions, - signatures, - { + return this.exchangeContract + .batchExecuteTransactions(signedTransactions, signatures) + .awaitTransactionSuccessAsync({ from, gasPrice: opts.gasPrice, - }, - ); + }); } public async getTakerAssetFilledAmountAsync(orderHashHex: string): Promise { - const filledAmount = await this.exchangeContract.filled.callAsync(orderHashHex); + const filledAmount = await this.exchangeContract.filled(orderHashHex).callAsync(); return filledAmount; } public async isCancelledAsync(orderHashHex: string): Promise { - const isCancelled = await this.exchangeContract.cancelled.callAsync(orderHashHex); + const isCancelled = await this.exchangeContract.cancelled(orderHashHex).callAsync(); return isCancelled; } public async getOrderEpochAsync(makerAddress: string, senderAddress: string): Promise { - const orderEpoch = await this.exchangeContract.orderEpoch.callAsync(makerAddress, senderAddress); + const orderEpoch = await this.exchangeContract.orderEpoch(makerAddress, senderAddress).callAsync(); return orderEpoch; } public async getOrderInfoAsync(signedOrder: SignedOrder): Promise { - const orderInfo = await this.exchangeContract.getOrderInfo.callAsync(signedOrder); + const orderInfo = await this.exchangeContract.getOrderInfo(signedOrder).callAsync(); return orderInfo; } public async batchMatchOrdersAsync( @@ -212,26 +204,18 @@ export class ExchangeWrapper { opts: { gasPrice?: BigNumber } = {}, ): Promise { const params = orderUtils.createBatchMatchOrders(signedOrdersLeft, signedOrdersRight); - return this.exchangeContract.batchMatchOrders.awaitTransactionSuccessAsync( - params.leftOrders, - params.rightOrders, - params.leftSignatures, - params.rightSignatures, - { from, gasPrice: opts.gasPrice }, - ); + return this.exchangeContract + .batchMatchOrders(params.leftOrders, params.rightOrders, params.leftSignatures, params.rightSignatures) + .awaitTransactionSuccessAsync({ from, gasPrice: opts.gasPrice }); } public async batchMatchOrdersRawAsync( params: BatchMatchOrder, from: string, opts: { gasPrice?: BigNumber } = {}, ): Promise { - return this.exchangeContract.batchMatchOrders.awaitTransactionSuccessAsync( - params.leftOrders, - params.rightOrders, - params.leftSignatures, - params.rightSignatures, - { from, gasPrice: opts.gasPrice }, - ); + return this.exchangeContract + .batchMatchOrders(params.leftOrders, params.rightOrders, params.leftSignatures, params.rightSignatures) + .awaitTransactionSuccessAsync({ from, gasPrice: opts.gasPrice }); } public async getBatchMatchOrdersResultsAsync( signedOrdersLeft: SignedOrder[], @@ -240,13 +224,9 @@ export class ExchangeWrapper { opts: { gasPrice?: BigNumber } = {}, ): Promise { const params = orderUtils.createBatchMatchOrders(signedOrdersLeft, signedOrdersRight); - const batchMatchedFillResults = await this.exchangeContract.batchMatchOrders.callAsync( - params.leftOrders, - params.rightOrders, - params.leftSignatures, - params.rightSignatures, - { from, gasPrice: opts.gasPrice }, - ); + const batchMatchedFillResults = await this.exchangeContract + .batchMatchOrders(params.leftOrders, params.rightOrders, params.leftSignatures, params.rightSignatures) + .callAsync({ from, gasPrice: opts.gasPrice }); return batchMatchedFillResults; } public async batchMatchOrdersWithMaximalFillAsync( @@ -256,26 +236,28 @@ export class ExchangeWrapper { opts: { gasPrice?: BigNumber } = {}, ): Promise { const params = orderUtils.createBatchMatchOrders(signedOrdersLeft, signedOrdersRight); - return this.exchangeContract.batchMatchOrdersWithMaximalFill.awaitTransactionSuccessAsync( - params.leftOrders, - params.rightOrders, - params.leftSignatures, - params.rightSignatures, - { from, gasPrice: opts.gasPrice }, - ); + return this.exchangeContract + .batchMatchOrdersWithMaximalFill( + params.leftOrders, + params.rightOrders, + params.leftSignatures, + params.rightSignatures, + ) + .awaitTransactionSuccessAsync({ from, gasPrice: opts.gasPrice }); } public async batchMatchOrdersWithMaximalFillRawAsync( params: BatchMatchOrder, from: string, opts: { gasPrice?: BigNumber } = {}, ): Promise { - return this.exchangeContract.batchMatchOrdersWithMaximalFill.awaitTransactionSuccessAsync( - params.leftOrders, - params.rightOrders, - params.leftSignatures, - params.rightSignatures, - { from, gasPrice: opts.gasPrice }, - ); + return this.exchangeContract + .batchMatchOrdersWithMaximalFill( + params.leftOrders, + params.rightOrders, + params.leftSignatures, + params.rightSignatures, + ) + .awaitTransactionSuccessAsync({ from, gasPrice: opts.gasPrice }); } public async getBatchMatchOrdersWithMaximalFillResultsAsync( signedOrdersLeft: SignedOrder[], @@ -284,13 +266,14 @@ export class ExchangeWrapper { opts: { gasPrice?: BigNumber } = {}, ): Promise { const params = orderUtils.createBatchMatchOrders(signedOrdersLeft, signedOrdersRight); - const batchMatchedFillResults = await this.exchangeContract.batchMatchOrdersWithMaximalFill.callAsync( - params.leftOrders, - params.rightOrders, - params.leftSignatures, - params.rightSignatures, - { from, gasPrice: opts.gasPrice }, - ); + const batchMatchedFillResults = await this.exchangeContract + .batchMatchOrdersWithMaximalFill( + params.leftOrders, + params.rightOrders, + params.leftSignatures, + params.rightSignatures, + ) + .callAsync({ from, gasPrice: opts.gasPrice }); return batchMatchedFillResults; } public async matchOrdersAsync( @@ -300,13 +283,9 @@ export class ExchangeWrapper { opts: { gasPrice?: BigNumber } = {}, ): Promise { const params = orderUtils.createMatchOrders(signedOrderLeft, signedOrderRight); - const txReceipt = await this.exchangeContract.matchOrders.awaitTransactionSuccessAsync( - params.left, - params.right, - params.leftSignature, - params.rightSignature, - { from, gasPrice: opts.gasPrice }, - ); + const txReceipt = await this.exchangeContract + .matchOrders(params.left, params.right, params.leftSignature, params.rightSignature) + .awaitTransactionSuccessAsync({ from, gasPrice: opts.gasPrice }); return txReceipt; } public async getMatchOrdersResultsAsync( @@ -316,13 +295,9 @@ export class ExchangeWrapper { opts: { gasPrice?: BigNumber } = {}, ): Promise { const params = orderUtils.createMatchOrders(signedOrderLeft, signedOrderRight); - const matchedFillResults = await this.exchangeContract.matchOrders.callAsync( - params.left, - params.right, - params.leftSignature, - params.rightSignature, - { from, gasPrice: opts.gasPrice }, - ); + const matchedFillResults = await this.exchangeContract + .matchOrders(params.left, params.right, params.leftSignature, params.rightSignature) + .callAsync({ from, gasPrice: opts.gasPrice }); return matchedFillResults; } public async matchOrdersWithMaximalFillAsync( @@ -332,13 +307,9 @@ export class ExchangeWrapper { opts: { gasPrice?: BigNumber } = {}, ): Promise { const params = orderUtils.createMatchOrders(signedOrderLeft, signedOrderRight); - return this.exchangeContract.matchOrdersWithMaximalFill.awaitTransactionSuccessAsync( - params.left, - params.right, - params.leftSignature, - params.rightSignature, - { from, gasPrice: opts.gasPrice }, - ); + return this.exchangeContract + .matchOrdersWithMaximalFill(params.left, params.right, params.leftSignature, params.rightSignature) + .awaitTransactionSuccessAsync({ from, gasPrice: opts.gasPrice }); } public async getMatchOrdersWithMaximalFillResultsAsync( signedOrderLeft: SignedOrder, @@ -347,13 +318,9 @@ export class ExchangeWrapper { opts: { gasPrice?: BigNumber }, ): Promise { const params = orderUtils.createMatchOrders(signedOrderLeft, signedOrderRight); - const matchedFillResults = await this.exchangeContract.matchOrdersWithMaximalFill.callAsync( - params.left, - params.right, - params.leftSignature, - params.rightSignature, - { from, gasPrice: opts.gasPrice }, - ); + const matchedFillResults = await this.exchangeContract + .matchOrdersWithMaximalFill(params.left, params.right, params.leftSignature, params.rightSignature) + .callAsync({ from, gasPrice: opts.gasPrice }); return matchedFillResults; } public async getFillOrderResultsAsync( @@ -362,21 +329,16 @@ export class ExchangeWrapper { opts: { takerAssetFillAmount?: BigNumber; gasPrice?: BigNumber } = {}, ): Promise { const params = orderUtils.createFill(signedOrder, opts.takerAssetFillAmount); - const fillResults = await this.exchangeContract.fillOrder.callAsync( - params.order, - params.takerAssetFillAmount, - params.signature, - { from, gasPrice: opts.gasPrice }, - ); + const fillResults = await this.exchangeContract + .fillOrder(params.order, params.takerAssetFillAmount, params.signature) + .callAsync({ from, gasPrice: opts.gasPrice }); return fillResults; } public abiEncodeFillOrder(signedOrder: SignedOrder, opts: { takerAssetFillAmount?: BigNumber } = {}): string { const params = orderUtils.createFill(signedOrder, opts.takerAssetFillAmount); - const data = this.exchangeContract.fillOrder.getABIEncodedTransactionData( - params.order, - params.takerAssetFillAmount, - params.signature, - ); + const data = this.exchangeContract + .fillOrder(params.order, params.takerAssetFillAmount, params.signature) + .getABIEncodedTransactionData(); return data; } public abiDecodeFillOrder(data: string): AbiDecodedFillOrderData { diff --git a/contracts/exchange/test/utils/fill_order_combinatorial_utils.ts b/contracts/exchange/test/utils/fill_order_combinatorial_utils.ts index 006088efea..3f6c9dbd8b 100644 --- a/contracts/exchange/test/utils/fill_order_combinatorial_utils.ts +++ b/contracts/exchange/test/utils/fill_order_combinatorial_utils.ts @@ -125,37 +125,37 @@ export async function fillOrderCombinatorialUtilsFactoryAsync( await exchangeWrapper.registerAssetProxyAsync(erc1155Proxy.address, ownerAddress); await exchangeWrapper.registerAssetProxyAsync(multiAssetProxy.address, ownerAddress); - await erc20Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(exchangeContract.address, { + await erc20Proxy.addAuthorizedAddress(exchangeContract.address).awaitTransactionSuccessAsync({ from: ownerAddress, }); - await erc721Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(exchangeContract.address, { + await erc721Proxy.addAuthorizedAddress(exchangeContract.address).awaitTransactionSuccessAsync({ from: ownerAddress, }); - await erc1155Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(exchangeContract.address, { + await erc1155Proxy.addAuthorizedAddress(exchangeContract.address).awaitTransactionSuccessAsync({ from: ownerAddress, }); - await multiAssetProxy.addAuthorizedAddress.awaitTransactionSuccessAsync(exchangeContract.address, { + await multiAssetProxy.addAuthorizedAddress(exchangeContract.address).awaitTransactionSuccessAsync({ from: ownerAddress, }); - await erc20Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(multiAssetProxy.address, { from: ownerAddress }); + await erc20Proxy.addAuthorizedAddress(multiAssetProxy.address).awaitTransactionSuccessAsync({ from: ownerAddress }); - await erc721Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(multiAssetProxy.address, { + await erc721Proxy.addAuthorizedAddress(multiAssetProxy.address).awaitTransactionSuccessAsync({ from: ownerAddress, }); - await erc1155Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(multiAssetProxy.address, { + await erc1155Proxy.addAuthorizedAddress(multiAssetProxy.address).awaitTransactionSuccessAsync({ from: ownerAddress, }); - await multiAssetProxy.registerAssetProxy.awaitTransactionSuccessAsync(erc20Proxy.address, { from: ownerAddress }); + await multiAssetProxy.registerAssetProxy(erc20Proxy.address).awaitTransactionSuccessAsync({ from: ownerAddress }); - await multiAssetProxy.registerAssetProxy.awaitTransactionSuccessAsync(erc721Proxy.address, { from: ownerAddress }); + await multiAssetProxy.registerAssetProxy(erc721Proxy.address).awaitTransactionSuccessAsync({ from: ownerAddress }); - await multiAssetProxy.registerAssetProxy.awaitTransactionSuccessAsync(erc1155Proxy.address, { from: ownerAddress }); + await multiAssetProxy.registerAssetProxy(erc1155Proxy.address).awaitTransactionSuccessAsync({ from: ownerAddress }); const orderFactory = new OrderFactoryFromScenario( devUtils, diff --git a/contracts/exchange/test/utils/isolated_exchange_wrapper.ts b/contracts/exchange/test/utils/isolated_exchange_wrapper.ts index 0d6f948068..e1ea62b01e 100644 --- a/contracts/exchange/test/utils/isolated_exchange_wrapper.ts +++ b/contracts/exchange/test/utils/isolated_exchange_wrapper.ts @@ -1,10 +1,4 @@ -import { - constants, - filterLogsToArguments, - MutatorContractFunction, - TransactionHelper, - txDefaults as testTxDefaults, -} from '@0x/contracts-test-utils'; +import { constants, filterLogsToArguments, txDefaults as testTxDefaults } from '@0x/contracts-test-utils'; import { orderHashUtils } from '@0x/order-utils'; import { FillResults, Order, OrderInfo, SignatureType } from '@0x/types'; import { BigNumber } from '@0x/utils'; @@ -40,7 +34,6 @@ export const DEFAULT_BAD_SIGNATURE = createBadSignature(); export class IsolatedExchangeWrapper { public static readonly CHAIN_ID = 1337; public readonly instance: IsolatedExchangeContract; - public readonly txHelper: TransactionHelper; public lastTxEvents: IsolatedExchangeEvents = createEmptyEvents(); public lastTxBalanceChanges: AssetBalances = {}; @@ -70,19 +63,18 @@ export class IsolatedExchangeWrapper { public constructor(web3Wrapper: Web3Wrapper, instance: IsolatedExchangeContract) { this.instance = instance; - this.txHelper = new TransactionHelper(web3Wrapper, artifacts); } public async getTakerAssetFilledAmountAsync(order: Order): Promise { - return this.instance.filled.callAsync(this.getOrderHash(order)); + return this.instance.filled(this.getOrderHash(order)).callAsync(); } public async cancelOrderAsync(order: Order, txOpts?: TxData): Promise { - await this.instance.cancelOrder.awaitTransactionSuccessAsync(order, txOpts); + await this.instance.cancelOrder(order).awaitTransactionSuccessAsync(txOpts); } public async cancelOrdersUpToAsync(epoch: BigNumber, txOpts?: TxData): Promise { - await this.instance.cancelOrdersUpTo.awaitTransactionSuccessAsync(epoch, txOpts); + await this.instance.cancelOrdersUpTo(epoch).awaitTransactionSuccessAsync(txOpts); } public async fillOrderAsync( @@ -91,13 +83,14 @@ export class IsolatedExchangeWrapper { signature: string = DEFAULT_GOOD_SIGNATURE, txOpts?: TxData, ): Promise { - return this._runFillContractFunctionAsync( - this.instance.fillOrder, - order, - new BigNumber(takerAssetFillAmount), - signature, - txOpts, - ); + this.lastTxEvents = createEmptyEvents(); + this.lastTxBalanceChanges = {}; + const fillOrderFn = this.instance.fillOrder(order, new BigNumber(takerAssetFillAmount), signature); + const result = await fillOrderFn.callAsync(); + const receipt = await fillOrderFn.awaitTransactionSuccessAsync(txOpts); + this.lastTxEvents = extractEvents(receipt.logs); + this.lastTxBalanceChanges = getBalanceChangesFromTransferFromCalls(this.lastTxEvents.transferFromCalls); + return result; } public getOrderHash(order: Order): string { @@ -109,7 +102,7 @@ export class IsolatedExchangeWrapper { } public async getOrderInfoAsync(order: Order): Promise { - return this.instance.getOrderInfo.callAsync(order); + return this.instance.getOrderInfo(order).callAsync(); } public getBalanceChange(assetData: string, address: string): BigNumber { @@ -121,23 +114,6 @@ export class IsolatedExchangeWrapper { } return constants.ZERO_AMOUNT; } - - protected async _runFillContractFunctionAsync< - TCallAsyncArgs extends any[], - TAwaitTransactionSuccessAsyncArgs extends any[], - TResult - >( - contractFunction: MutatorContractFunction, - // tslint:disable-next-line: trailing-comma - ...args: TAwaitTransactionSuccessAsyncArgs - ): Promise { - this.lastTxEvents = createEmptyEvents(); - this.lastTxBalanceChanges = {}; - const [result, receipt] = await this.txHelper.getResultAndReceiptAsync(contractFunction, ...args); - this.lastTxEvents = extractEvents(receipt.logs); - this.lastTxBalanceChanges = getBalanceChangesFromTransferFromCalls(this.lastTxEvents.transferFromCalls); - return result; - } } /** diff --git a/contracts/exchange/test/utils/match_order_tester.ts b/contracts/exchange/test/utils/match_order_tester.ts index 3fe9ff906a..e8ec9a42b0 100644 --- a/contracts/exchange/test/utils/match_order_tester.ts +++ b/contracts/exchange/test/utils/match_order_tester.ts @@ -631,11 +631,11 @@ async function transferAssetAsync( matchResults: MatchResults, devUtils: DevUtilsContract, ): Promise { - const assetProxyId = await devUtils.decodeAssetProxyId.callAsync(assetData); + const assetProxyId = await devUtils.decodeAssetProxyId(assetData).callAsync(); switch (assetProxyId) { case AssetProxyId.ERC20: { // tslint:disable-next-line:no-unused-variable - const [proxyId, assetAddress] = await devUtils.decodeERC20AssetData.callAsync(assetData); // tslint:disable-line-no-unused-variable + const [proxyId, assetAddress] = await devUtils.decodeERC20AssetData(assetData).callAsync(); // tslint:disable-line-no-unused-variable const fromBalances = matchResults.balances.erc20[fromAddress]; const toBalances = matchResults.balances.erc20[toAddress]; fromBalances[assetAddress] = fromBalances[assetAddress].minus(amount); @@ -644,7 +644,7 @@ async function transferAssetAsync( } case AssetProxyId.ERC721: { // tslint:disable-next-line:no-unused-variable - const [proxyId, assetAddress, tokenId] = await devUtils.decodeERC721AssetData.callAsync(assetData); // tslint:disable-line-no-unused-variable + const [proxyId, assetAddress, tokenId] = await devUtils.decodeERC721AssetData(assetData).callAsync(); // tslint:disable-line-no-unused-variable const fromTokens = matchResults.balances.erc721[fromAddress][assetAddress]; const toTokens = matchResults.balances.erc721[toAddress][assetAddress]; if (amount.gte(1)) { @@ -658,9 +658,9 @@ async function transferAssetAsync( } case AssetProxyId.ERC1155: { // tslint:disable-next-line:no-unused-variable - const [proxyId, assetAddress, tokenIds, tokenValues] = await devUtils.decodeERC1155AssetData.callAsync( - assetData, - ); + const [proxyId, assetAddress, tokenIds, tokenValues] = await devUtils + .decodeERC1155AssetData(assetData) + .callAsync(); const fromBalances = matchResults.balances.erc1155[fromAddress][assetAddress]; const toBalances = matchResults.balances.erc1155[toAddress][assetAddress]; for (const i of _.times(tokenIds.length)) { @@ -685,7 +685,7 @@ async function transferAssetAsync( } case AssetProxyId.MultiAsset: { // tslint:disable-next-line:no-unused-variable - const [proxyId, amounts, nestedAssetData] = await devUtils.decodeMultiAssetData.callAsync(assetData); // tslint:disable-line-no-unused-variable + const [proxyId, amounts, nestedAssetData] = await devUtils.decodeMultiAssetData(assetData).callAsync(); // tslint:disable-line-no-unused-variable for (const i of _.times(amounts.length)) { const nestedAmount = amount.times(amounts[i]); const _nestedAssetData = nestedAssetData[i]; diff --git a/contracts/exchange/test/utils/order_factory_from_scenario.ts b/contracts/exchange/test/utils/order_factory_from_scenario.ts index b25a5a85ab..9b0f510f25 100644 --- a/contracts/exchange/test/utils/order_factory_from_scenario.ts +++ b/contracts/exchange/test/utils/order_factory_from_scenario.ts @@ -96,52 +96,59 @@ export class OrderFactoryFromScenario { switch (orderScenario.makerAssetDataScenario) { case AssetDataScenario.ERC20EighteenDecimals: - makerAssetData = await this._devUtils.encodeERC20AssetData.callAsync( - this._erc20EighteenDecimalTokenAddresses[0], - ); + makerAssetData = await this._devUtils + .encodeERC20AssetData(this._erc20EighteenDecimalTokenAddresses[0]) + .callAsync(); break; case AssetDataScenario.ERC20FiveDecimals: - makerAssetData = await this._devUtils.encodeERC20AssetData.callAsync( - this._erc20FiveDecimalTokenAddresses[0], - ); + makerAssetData = await this._devUtils + .encodeERC20AssetData(this._erc20FiveDecimalTokenAddresses[0]) + .callAsync(); break; case AssetDataScenario.ERC721: - makerAssetData = await this._devUtils.encodeERC721AssetData.callAsync( - this._erc721TokenAddress, - erc721MakerAssetIds[0], - ); + makerAssetData = await this._devUtils + .encodeERC721AssetData(this._erc721TokenAddress, erc721MakerAssetIds[0]) + .callAsync(); break; case AssetDataScenario.ERC20ZeroDecimals: - makerAssetData = await this._devUtils.encodeERC20AssetData.callAsync( - this._erc20ZeroDecimalTokenAddresses[0], - ); + makerAssetData = await this._devUtils + .encodeERC20AssetData(this._erc20ZeroDecimalTokenAddresses[0]) + .callAsync(); break; case AssetDataScenario.ERC1155Fungible: - makerAssetData = await this._devUtils.encodeERC1155AssetData.callAsync( - this._erc1155TokenAddress, - [erc1155FungibleMakerTokenIds[0]], - [ONE_UNITS_ZERO_DECIMALS], - erc1155CallbackData, - ); + makerAssetData = await this._devUtils + .encodeERC1155AssetData( + this._erc1155TokenAddress, + [erc1155FungibleMakerTokenIds[0]], + [ONE_UNITS_ZERO_DECIMALS], + erc1155CallbackData, + ) + .callAsync(); break; case AssetDataScenario.ERC1155NonFungible: - makerAssetData = await this._devUtils.encodeERC1155AssetData.callAsync( - this._erc1155TokenAddress, - [erc1155NonFungibleMakerTokenIds[0]], - [ONE_UNITS_ZERO_DECIMALS], - erc1155CallbackData, - ); + makerAssetData = await this._devUtils + .encodeERC1155AssetData( + this._erc1155TokenAddress, + [erc1155NonFungibleMakerTokenIds[0]], + [ONE_UNITS_ZERO_DECIMALS], + erc1155CallbackData, + ) + .callAsync(); break; case AssetDataScenario.MultiAssetERC20: - makerAssetData = await this._devUtils.encodeMultiAssetData.callAsync( - [ONE_UNITS_EIGHTEEN_DECIMALS, ONE_UNITS_FIVE_DECIMALS], - [ - await this._devUtils.encodeERC20AssetData.callAsync( - this._erc20EighteenDecimalTokenAddresses[0], - ), - await this._devUtils.encodeERC20AssetData.callAsync(this._erc20FiveDecimalTokenAddresses[0]), - ], - ); + makerAssetData = await this._devUtils + .encodeMultiAssetData( + [ONE_UNITS_EIGHTEEN_DECIMALS, ONE_UNITS_FIVE_DECIMALS], + [ + await this._devUtils + .encodeERC20AssetData(this._erc20EighteenDecimalTokenAddresses[0]) + .callAsync(), + await this._devUtils + .encodeERC20AssetData(this._erc20FiveDecimalTokenAddresses[0]) + .callAsync(), + ], + ) + .callAsync(); break; default: throw errorUtils.spawnSwitchErr('AssetDataScenario', orderScenario.makerAssetDataScenario); @@ -149,52 +156,59 @@ export class OrderFactoryFromScenario { switch (orderScenario.takerAssetDataScenario) { case AssetDataScenario.ERC20EighteenDecimals: - takerAssetData = await this._devUtils.encodeERC20AssetData.callAsync( - this._erc20EighteenDecimalTokenAddresses[1], - ); + takerAssetData = await this._devUtils + .encodeERC20AssetData(this._erc20EighteenDecimalTokenAddresses[1]) + .callAsync(); break; case AssetDataScenario.ERC20FiveDecimals: - takerAssetData = await this._devUtils.encodeERC20AssetData.callAsync( - this._erc20FiveDecimalTokenAddresses[1], - ); + takerAssetData = await this._devUtils + .encodeERC20AssetData(this._erc20FiveDecimalTokenAddresses[1]) + .callAsync(); break; case AssetDataScenario.ERC721: - takerAssetData = await this._devUtils.encodeERC721AssetData.callAsync( - this._erc721TokenAddress, - erc721TakerAssetIds[0], - ); + takerAssetData = await this._devUtils + .encodeERC721AssetData(this._erc721TokenAddress, erc721TakerAssetIds[0]) + .callAsync(); break; case AssetDataScenario.ERC20ZeroDecimals: - takerAssetData = await this._devUtils.encodeERC20AssetData.callAsync( - this._erc20ZeroDecimalTokenAddresses[1], - ); + takerAssetData = await this._devUtils + .encodeERC20AssetData(this._erc20ZeroDecimalTokenAddresses[1]) + .callAsync(); break; case AssetDataScenario.ERC1155Fungible: - takerAssetData = await this._devUtils.encodeERC1155AssetData.callAsync( - this._erc1155TokenAddress, - [erc1155FungibleTakerTokenIds[1]], - [ONE_UNITS_ZERO_DECIMALS], - erc1155CallbackData, - ); + takerAssetData = await this._devUtils + .encodeERC1155AssetData( + this._erc1155TokenAddress, + [erc1155FungibleTakerTokenIds[1]], + [ONE_UNITS_ZERO_DECIMALS], + erc1155CallbackData, + ) + .callAsync(); break; case AssetDataScenario.ERC1155NonFungible: - takerAssetData = await this._devUtils.encodeERC1155AssetData.callAsync( - this._erc1155TokenAddress, - [erc1155NonFungibleTakerTokenIds[0]], - [ONE_UNITS_ZERO_DECIMALS], - erc1155CallbackData, - ); + takerAssetData = await this._devUtils + .encodeERC1155AssetData( + this._erc1155TokenAddress, + [erc1155NonFungibleTakerTokenIds[0]], + [ONE_UNITS_ZERO_DECIMALS], + erc1155CallbackData, + ) + .callAsync(); break; case AssetDataScenario.MultiAssetERC20: - takerAssetData = await this._devUtils.encodeMultiAssetData.callAsync( - [ONE_UNITS_EIGHTEEN_DECIMALS, ONE_UNITS_FIVE_DECIMALS], - [ - await this._devUtils.encodeERC20AssetData.callAsync( - this._erc20EighteenDecimalTokenAddresses[1], - ), - await this._devUtils.encodeERC20AssetData.callAsync(this._erc20FiveDecimalTokenAddresses[1]), - ], - ); + takerAssetData = await this._devUtils + .encodeMultiAssetData( + [ONE_UNITS_EIGHTEEN_DECIMALS, ONE_UNITS_FIVE_DECIMALS], + [ + await this._devUtils + .encodeERC20AssetData(this._erc20EighteenDecimalTokenAddresses[1]) + .callAsync(), + await this._devUtils + .encodeERC20AssetData(this._erc20FiveDecimalTokenAddresses[1]) + .callAsync(), + ], + ) + .callAsync(); break; default: throw errorUtils.spawnSwitchErr('AssetDataScenario', orderScenario.takerAssetDataScenario); @@ -327,53 +341,61 @@ export class OrderFactoryFromScenario { case FeeAssetDataScenario.ERC20EighteenDecimals: return [ feeAmount, - await this._devUtils.encodeERC20AssetData.callAsync(erc20EighteenDecimalTokenAddress), + await this._devUtils.encodeERC20AssetData(erc20EighteenDecimalTokenAddress).callAsync(), ]; case FeeAssetDataScenario.ERC20FiveDecimals: return [ feeAmount, - await this._devUtils.encodeERC20AssetData.callAsync(erc20FiveDecimalTokenAddress), + await this._devUtils.encodeERC20AssetData(erc20FiveDecimalTokenAddress).callAsync(), ]; case FeeAssetDataScenario.ERC20ZeroDecimals: return [ feeAmount, - await this._devUtils.encodeERC20AssetData.callAsync(erc20ZeroDecimalTokenAddress), + await this._devUtils.encodeERC20AssetData(erc20ZeroDecimalTokenAddress).callAsync(), ]; case FeeAssetDataScenario.ERC721: return [ feeAmount, - await this._devUtils.encodeERC721AssetData.callAsync(this._erc721TokenAddress, erc721AssetId), + await this._devUtils.encodeERC721AssetData(this._erc721TokenAddress, erc721AssetId).callAsync(), ]; case FeeAssetDataScenario.ERC1155Fungible: return [ feeAmount, - await this._devUtils.encodeERC1155AssetData.callAsync( - this._erc1155TokenAddress, - [erc1155FungibleTokenId], - [ONE_UNITS_ZERO_DECIMALS], - erc1155CallbackData, - ), + await this._devUtils + .encodeERC1155AssetData( + this._erc1155TokenAddress, + [erc1155FungibleTokenId], + [ONE_UNITS_ZERO_DECIMALS], + erc1155CallbackData, + ) + .callAsync(), ]; case FeeAssetDataScenario.ERC1155NonFungible: return [ feeAmount, - await this._devUtils.encodeERC1155AssetData.callAsync( - this._erc1155TokenAddress, - [erc1155NonFungibleAssetId], - [ONE_UNITS_ZERO_DECIMALS], - erc1155CallbackData, - ), + await this._devUtils + .encodeERC1155AssetData( + this._erc1155TokenAddress, + [erc1155NonFungibleAssetId], + [ONE_UNITS_ZERO_DECIMALS], + erc1155CallbackData, + ) + .callAsync(), ]; case FeeAssetDataScenario.MultiAssetERC20: return [ feeAmount, - await this._devUtils.encodeMultiAssetData.callAsync( - [POINT_ZERO_FIVE_UNITS_EIGHTEEN_DECIMALS, POINT_ZERO_FIVE_UNITS_FIVE_DECIMALS], - [ - await this._devUtils.encodeERC20AssetData.callAsync(erc20EighteenDecimalTokenAddress), - await this._devUtils.encodeERC20AssetData.callAsync(erc20FiveDecimalTokenAddress), - ], - ), + await this._devUtils + .encodeMultiAssetData( + [POINT_ZERO_FIVE_UNITS_EIGHTEEN_DECIMALS, POINT_ZERO_FIVE_UNITS_FIVE_DECIMALS], + [ + await this._devUtils + .encodeERC20AssetData(erc20EighteenDecimalTokenAddress) + .callAsync(), + await this._devUtils.encodeERC20AssetData(erc20FiveDecimalTokenAddress).callAsync(), + ], + ) + .callAsync(), ]; default: throw errorUtils.spawnSwitchErr('FeeAssetDataScenario', feeAssetDataScenario); diff --git a/contracts/exchange/test/wrapper_unit_tests.ts b/contracts/exchange/test/wrapper_unit_tests.ts index 13ae715025..69ebd113c7 100644 --- a/contracts/exchange/test/wrapper_unit_tests.ts +++ b/contracts/exchange/test/wrapper_unit_tests.ts @@ -1,1329 +1,1327 @@ -import { ReferenceFunctions as LibReferenceFunctions } from '@0x/contracts-exchange-libs'; -import { - blockchainTests, - constants, - describe, - expect, - hexRandom, - MutatorContractFunction, - TransactionHelper, -} from '@0x/contracts-test-utils'; -import { ReferenceFunctions as UtilReferenceFunctions } from '@0x/contracts-utils'; -import { ExchangeRevertErrors, orderHashUtils } from '@0x/order-utils'; -import { FillResults, Order } from '@0x/types'; -import { AnyRevertError, BigNumber, SafeMathRevertErrors, StringRevertError } from '@0x/utils'; -import { LogEntry, LogWithDecodedArgs } from 'ethereum-types'; -import * as ethjs from 'ethereumjs-util'; -import * as _ from 'lodash'; - -import { - artifacts, - TestWrapperFunctionsCancelOrderCalledEventArgs as CancelOrderCalledEventArgs, - TestWrapperFunctionsContract, - TestWrapperFunctionsFillOrderCalledEventArgs as FillOrderCalledEventArgs, -} from '../src'; - -blockchainTests('Exchange wrapper functions unit tests.', env => { - const CHAIN_ID = 0x74657374; - const { ONE_ETHER, MAX_UINT256 } = constants; - const { addFillResults, getPartialAmountFloor } = LibReferenceFunctions; - const { safeSub } = UtilReferenceFunctions; - const protocolFeeMultiplier = new BigNumber(150000); - const randomAddress = () => hexRandom(constants.ADDRESS_LENGTH); - const randomAssetData = () => hexRandom(34); - const randomAmount = (maxAmount: BigNumber = ONE_ETHER) => maxAmount.times(_.random(0, 100, true).toFixed(12)); - const randomTimestamp = () => new BigNumber(Math.floor(_.now() / 1000) + _.random(0, 34560)); - const randomSalt = () => new BigNumber(hexRandom(constants.WORD_LENGTH).substr(2), 16); - const ALWAYS_FAILING_SALT = constants.MAX_UINT256; - const ALWAYS_FAILING_SALT_REVERT_ERROR = new StringRevertError('ALWAYS_FAILING_SALT'); - const EMPTY_FILL_RESULTS = { - makerAssetFilledAmount: constants.ZERO_AMOUNT, - takerAssetFilledAmount: constants.ZERO_AMOUNT, - makerFeePaid: constants.ZERO_AMOUNT, - takerFeePaid: constants.ZERO_AMOUNT, - protocolFeePaid: constants.ZERO_AMOUNT, - }; - let testContract: TestWrapperFunctionsContract; - let txHelper: TransactionHelper; - let owner: string; - let senderAddress: string; - - before(async () => { - [owner, senderAddress] = await env.getAccountAddressesAsync(); - txHelper = new TransactionHelper(env.web3Wrapper, artifacts); - testContract = await TestWrapperFunctionsContract.deployFrom0xArtifactAsync( - artifacts.TestWrapperFunctions, - env.provider, - { - ...env.txDefaults, - from: owner, - }, - {}, - ); - - // Set the protocol fee multiplier. - await testContract.setProtocolFeeMultiplier.awaitTransactionSuccessAsync(protocolFeeMultiplier, { - from: owner, - }); - }); - - function randomOrder(fields?: Partial): Order { - return { - makerAddress: randomAddress(), - takerAddress: randomAddress(), - feeRecipientAddress: randomAddress(), - senderAddress: randomAddress(), - takerAssetAmount: randomAmount(), - makerAssetAmount: randomAmount(), - makerFee: randomAmount(), - takerFee: randomAmount(), - expirationTimeSeconds: randomTimestamp(), - salt: randomSalt(), - makerAssetData: randomAssetData(), - takerAssetData: randomAssetData(), - makerFeeAssetData: randomAssetData(), - takerFeeAssetData: randomAssetData(), - exchangeAddress: constants.NULL_ADDRESS, - chainId: CHAIN_ID, - ...(fields || {}), - }; - } - - // Computes the expected (fake) fill results from `TestWrapperFunctions` `_fillOrder` implementation. - function getExpectedFillResults(order: Order, signature: string): FillResults { - if (order.salt === ALWAYS_FAILING_SALT) { - return EMPTY_FILL_RESULTS; - } - return { - makerAssetFilledAmount: order.makerAssetAmount, - takerAssetFilledAmount: order.takerAssetAmount, - makerFeePaid: order.makerFee, - takerFeePaid: order.takerFee, - protocolFeePaid: protocolFeeMultiplier, - }; - } - - // Creates a deterministic order signature, even though no signature validation - // actually occurs in the test contract. - function createOrderSignature(order: Order): string { - return ethjs.bufferToHex(ethjs.sha3(ethjs.toBuffer(orderHashUtils.getOrderHashHex(order)))); - } - - // Asserts that `_fillOrder()` was called in the same order and with the same - // arguments as given by examining receipt logs. - function assertFillOrderCallsFromLogs(logs: LogEntry[], calls: Array<[Order, BigNumber, string]>): void { - expect(logs.length).to.eq(calls.length); - for (const i of _.times(calls.length)) { - const log = (logs[i] as any) as LogWithDecodedArgs; - const [expectedOrder, expectedTakerAssetFillAmount, expectedSignature] = calls[i]; - expect(log.event).to.eq('FillOrderCalled'); - assertSameOrderFromEvent(log.args.order as any, expectedOrder); - expect(log.args.takerAssetFillAmount).to.bignumber.eq(expectedTakerAssetFillAmount); - expect(log.args.signature).to.eq(expectedSignature); - } - } - - function assertSameOrderFromEvent(actual: any[], expected: Order): void { - expect(actual.length === 14); - expect(actual[0].toLowerCase()).to.be.eq(expected.makerAddress); - expect(actual[1].toLowerCase()).to.be.eq(expected.takerAddress); - expect(actual[2].toLowerCase()).to.be.eq(expected.feeRecipientAddress); - expect(actual[3].toLowerCase()).to.be.eq(expected.senderAddress); - expect(actual[4]).to.be.bignumber.eq(expected.makerAssetAmount); - expect(actual[5]).to.be.bignumber.eq(expected.takerAssetAmount); - expect(actual[6]).to.be.bignumber.eq(expected.makerFee); - expect(actual[7]).to.be.bignumber.eq(expected.takerFee); - expect(actual[8]).to.be.bignumber.eq(expected.expirationTimeSeconds); - expect(actual[9]).to.be.bignumber.eq(expected.salt); - expect(actual[10]).to.be.eq(expected.makerAssetData); - expect(actual[11]).to.be.eq(expected.takerAssetData); - expect(actual[12]).to.be.eq(expected.makerFeeAssetData); - expect(actual[13]).to.be.eq(expected.takerFeeAssetData); - } - - describe('fillOrKillOrder', () => { - it('works if the order is filled by exactly `takerAssetFillAmount`', async () => { - const fillAmount = randomAmount(); - const order = randomOrder({ - // `_fillOrder()` is overridden to always return `order.takerAssetAmount` as - // the `takerAssetFilledAmount`. - takerAssetAmount: fillAmount, - }); - const signature = createOrderSignature(order); - const expectedResult = getExpectedFillResults(order, signature); - const expectedCalls = [[order, fillAmount, signature]]; - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - testContract.fillOrKillOrder, - order, - fillAmount, - signature, - ); - expect(actualResult).to.deep.eq(expectedResult); - assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); - }); - - it('reverts if the order is filled by less than `takerAssetFillAmount`', async () => { - const fillAmount = randomAmount(); - const order = randomOrder({ - // `_fillOrder()` is overridden to always return `order.takerAssetAmount` as - // the `takerAssetFilledAmount`. - takerAssetAmount: fillAmount.minus(1), - }); - const signature = createOrderSignature(order); - const expectedError = new ExchangeRevertErrors.IncompleteFillError( - ExchangeRevertErrors.IncompleteFillErrorCode.IncompleteFillOrder, - fillAmount, - fillAmount.minus(1), - ); - const tx = testContract.fillOrKillOrder.awaitTransactionSuccessAsync(order, fillAmount, signature); - return expect(tx).to.revertWith(expectedError); - }); - - it('reverts if the order is filled by greater than `takerAssetFillAmount`', async () => { - const fillAmount = randomAmount(); - const order = randomOrder({ - // `_fillOrder()` is overridden to always return `order.takerAssetAmount` as - // the `takerAssetFilledAmount`. - takerAssetAmount: fillAmount.plus(1), - }); - const signature = createOrderSignature(order); - const expectedError = new ExchangeRevertErrors.IncompleteFillError( - ExchangeRevertErrors.IncompleteFillErrorCode.IncompleteFillOrder, - fillAmount, - fillAmount.plus(1), - ); - const tx = testContract.fillOrKillOrder.awaitTransactionSuccessAsync(order, fillAmount, signature); - return expect(tx).to.revertWith(expectedError); - }); - - it('reverts if `_fillOrder()` reverts', async () => { - const fillAmount = randomAmount(); - const order = randomOrder({ - salt: ALWAYS_FAILING_SALT, - }); - const signature = createOrderSignature(order); - const expectedError = ALWAYS_FAILING_SALT_REVERT_ERROR; - const tx = testContract.fillOrKillOrder.awaitTransactionSuccessAsync(order, fillAmount, signature); - return expect(tx).to.revertWith(expectedError); - }); - }); - - describe('fillOrderNoThrow', () => { - it('calls `fillOrder()` and returns its result', async () => { - const fillAmount = randomAmount(); - const order = randomOrder(); - const signature = createOrderSignature(order); - const expectedResult = getExpectedFillResults(order, signature); - const expectedCalls = [[order, fillAmount, signature]]; - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - testContract.fillOrderNoThrow, - order, - fillAmount, - signature, - ); - expect(actualResult).to.deep.eq(expectedResult); - assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); - }); - - it('does not revert if `fillOrder()` reverts', async () => { - const fillAmount = randomAmount(); - const order = randomOrder({ - salt: ALWAYS_FAILING_SALT, - }); - const signature = createOrderSignature(order); - const expectedResult = EMPTY_FILL_RESULTS; - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - testContract.fillOrderNoThrow, - order, - fillAmount, - signature, - ); - expect(actualResult).to.deep.eq(expectedResult); - assertFillOrderCallsFromLogs(receipt.logs, []); - }); - }); - - describe('batchFillOrders', () => { - it('works with no fills', async () => { - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - testContract.batchFillOrders, - [], - [], - [], - ); - expect(actualResult).to.deep.eq([]); - assertFillOrderCallsFromLogs(receipt.logs, []); - }); - - it('works with one fill', async () => { - const COUNT = 1; - const orders = _.times(COUNT, () => randomOrder()); - const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); - const expectedCalls = _.zip(orders, fillAmounts, signatures); - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - testContract.batchFillOrders, - orders, - fillAmounts, - signatures, - ); - expect(actualResult).to.deep.eq(expectedResult); - assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); - }); - - it('works with many fills', async () => { - const COUNT = 8; - const orders = _.times(COUNT, () => randomOrder()); - const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); - const expectedCalls = _.zip(orders, fillAmounts, signatures); - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - testContract.batchFillOrders, - orders, - fillAmounts, - signatures, - ); - expect(actualResult).to.deep.eq(expectedResult); - assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); - }); - - it('works with duplicate orders', async () => { - const NUM_UNIQUE_ORDERS = 2; - const COUNT = 4; - const uniqueOrders = _.times(NUM_UNIQUE_ORDERS, () => randomOrder()); - const orders = _.shuffle(_.flatten(_.times(COUNT / NUM_UNIQUE_ORDERS, () => uniqueOrders))); - const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount.dividedToIntegerBy(COUNT)); - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); - const expectedCalls = _.zip(orders, fillAmounts, signatures); - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - testContract.batchFillOrders, - orders, - fillAmounts, - signatures, - ); - expect(actualResult).to.deep.eq(expectedResult); - assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); - }); - - it('reverts if there are more orders than fill amounts', async () => { - const COUNT = 8; - const orders = _.times(COUNT, () => randomOrder()); - const fillAmounts = _.times(COUNT - 1, i => orders[i].takerAssetAmount); - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - const expectedError = new AnyRevertError(); // Just a generic revert. - const tx = txHelper.getResultAndReceiptAsync(testContract.batchFillOrders, orders, fillAmounts, signatures); - return expect(tx).to.revertWith(expectedError); - }); - - it('reverts if there are more orders than signatures', async () => { - const COUNT = 8; - const orders = _.times(COUNT, () => randomOrder()); - const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); - const signatures = _.times(COUNT - 1, i => createOrderSignature(orders[i])); - const expectedError = new AnyRevertError(); // Just a generic revert. - const tx = txHelper.getResultAndReceiptAsync(testContract.batchFillOrders, orders, fillAmounts, signatures); - return expect(tx).to.revertWith(expectedError); - }); - }); - - describe('batchFillOrKillOrders', () => { - it('works with no fills', async () => { - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - testContract.batchFillOrKillOrders, - [], - [], - [], - ); - expect(actualResult).to.deep.eq([]); - assertFillOrderCallsFromLogs(receipt.logs, []); - }); - - it('works with one fill', async () => { - const COUNT = 1; - const orders = _.times(COUNT, () => randomOrder()); - const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); - const expectedCalls = _.zip(orders, fillAmounts, signatures); - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - testContract.batchFillOrKillOrders, - orders, - fillAmounts, - signatures, - ); - expect(actualResult).to.deep.eq(expectedResult); - assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); - }); - - it('works with many fills', async () => { - const COUNT = 8; - const orders = _.times(COUNT, () => randomOrder()); - const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); - const expectedCalls = _.zip(orders, fillAmounts, signatures); - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - testContract.batchFillOrKillOrders, - orders, - fillAmounts, - signatures, - ); - expect(actualResult).to.deep.eq(expectedResult); - assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); - }); - - it('works with duplicate orders', async () => { - const NUM_UNIQUE_ORDERS = 2; - const COUNT = 4; - const uniqueOrders = _.times(NUM_UNIQUE_ORDERS, () => randomOrder()); - const orders = _.shuffle(_.flatten(_.times(COUNT / NUM_UNIQUE_ORDERS, () => uniqueOrders))); - const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); - const expectedCalls = _.zip(orders, fillAmounts, signatures); - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - testContract.batchFillOrKillOrders, - orders, - fillAmounts, - signatures, - ); - expect(actualResult).to.deep.eq(expectedResult); - assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); - }); - - it('reverts if any fill sells less than its takerAssetFillAmount', async () => { - const COUNT = 8; - const FAILING_ORDER_INDEX = 6; - const orders = _.times(COUNT, () => randomOrder()); - const failingOrder = orders[FAILING_ORDER_INDEX]; - const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); - const failingAmount = fillAmounts[FAILING_ORDER_INDEX]; - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - // `_fillOrder()` is overridden to always return `order.takerAssetAmount` as - // the `takerAssetFilledAmount`. - failingOrder.takerAssetAmount = failingOrder.takerAssetAmount.minus(1); - const expectedError = new ExchangeRevertErrors.IncompleteFillError( - ExchangeRevertErrors.IncompleteFillErrorCode.IncompleteFillOrder, - failingAmount, - failingAmount.minus(1), - ); - const tx = txHelper.getResultAndReceiptAsync( - testContract.batchFillOrKillOrders, - orders, - fillAmounts, - signatures, - ); - return expect(tx).to.revertWith(expectedError); - }); - - it('reverts if any fill sells more than its takerAssetFillAmount', async () => { - const COUNT = 8; - const FAILING_ORDER_INDEX = 6; - const orders = _.times(COUNT, () => randomOrder()); - const failingOrder = orders[FAILING_ORDER_INDEX]; - const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); - const failingAmount = fillAmounts[FAILING_ORDER_INDEX]; - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - // `_fillOrder()` is overridden to always return `order.takerAssetAmount` as - // the `takerAssetFilledAmount`. - failingOrder.takerAssetAmount = failingOrder.takerAssetAmount.plus(1); - const expectedError = new ExchangeRevertErrors.IncompleteFillError( - ExchangeRevertErrors.IncompleteFillErrorCode.IncompleteFillOrder, - failingAmount, - failingAmount.plus(1), - ); - const tx = txHelper.getResultAndReceiptAsync( - testContract.batchFillOrKillOrders, - orders, - fillAmounts, - signatures, - ); - return expect(tx).to.revertWith(expectedError); - }); - - it('reverts if there are more orders than fill amounts', async () => { - const COUNT = 8; - const orders = _.times(COUNT, () => randomOrder()); - const fillAmounts = _.times(COUNT - 1, i => orders[i].takerAssetAmount); - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - const expectedError = new AnyRevertError(); // Just a generic revert. - const tx = txHelper.getResultAndReceiptAsync( - testContract.batchFillOrKillOrders, - orders, - fillAmounts, - signatures, - ); - return expect(tx).to.revertWith(expectedError); - }); - - it('reverts if there are more orders than signatures', async () => { - const COUNT = 8; - const orders = _.times(COUNT, () => randomOrder()); - const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); - const signatures = _.times(COUNT - 1, i => createOrderSignature(orders[i])); - const expectedError = new AnyRevertError(); // Just a generic revert. - const tx = txHelper.getResultAndReceiptAsync( - testContract.batchFillOrKillOrders, - orders, - fillAmounts, - signatures, - ); - return expect(tx).to.revertWith(expectedError); - }); - }); - - describe('batchFillOrdersNoThrow', () => { - it('works with no fills', async () => { - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - testContract.batchFillOrdersNoThrow, - [], - [], - [], - ); - expect(actualResult).to.deep.eq([]); - assertFillOrderCallsFromLogs(receipt.logs, []); - }); - - it('works with one fill', async () => { - const COUNT = 1; - const orders = _.times(COUNT, () => randomOrder()); - const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); - const expectedCalls = _.zip(orders, fillAmounts, signatures); - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - testContract.batchFillOrdersNoThrow, - orders, - fillAmounts, - signatures, - ); - expect(actualResult).to.deep.eq(expectedResult); - assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); - }); - - it('works with many fills', async () => { - const COUNT = 8; - const orders = _.times(COUNT, () => randomOrder()); - const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); - const expectedCalls = _.zip(orders, fillAmounts, signatures); - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - testContract.batchFillOrdersNoThrow, - orders, - fillAmounts, - signatures, - ); - expect(actualResult).to.deep.eq(expectedResult); - assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); - }); - - it('works with duplicate orders', async () => { - const NUM_UNIQUE_ORDERS = 2; - const COUNT = 4; - const uniqueOrders = _.times(NUM_UNIQUE_ORDERS, () => randomOrder()); - const orders = _.shuffle(_.flatten(_.times(COUNT / NUM_UNIQUE_ORDERS, () => uniqueOrders))); - const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount.dividedToIntegerBy(COUNT)); - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); - const expectedCalls = _.zip(orders, fillAmounts, signatures); - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - testContract.batchFillOrdersNoThrow, - orders, - fillAmounts, - signatures, - ); - expect(actualResult).to.deep.eq(expectedResult); - assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); - }); - - it('works if a fill fails', async () => { - const COUNT = 8; - const FAILING_ORDER_INDEX = 6; - const orders = _.times(COUNT, () => randomOrder()); - const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - const failingOrder = orders[FAILING_ORDER_INDEX]; - failingOrder.salt = ALWAYS_FAILING_SALT; - const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); - const expectedCalls = _.zip(orders, fillAmounts, signatures); - expectedCalls.splice(FAILING_ORDER_INDEX, 1); - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - testContract.batchFillOrdersNoThrow, - orders, - fillAmounts, - signatures, - ); - expect(actualResult).to.deep.eq(expectedResult); - assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); - }); - - it('reverts if there are more orders than fill amounts', async () => { - const COUNT = 8; - const orders = _.times(COUNT, () => randomOrder()); - const fillAmounts = _.times(COUNT - 1, i => orders[i].takerAssetAmount); - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - const expectedError = new AnyRevertError(); // Just a generic revert. - const tx = txHelper.getResultAndReceiptAsync( - testContract.batchFillOrdersNoThrow, - orders, - fillAmounts, - signatures, - ); - return expect(tx).to.revertWith(expectedError); - }); - - it('reverts if there are more orders than signatures', async () => { - const COUNT = 8; - const orders = _.times(COUNT, () => randomOrder()); - const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); - const signatures = _.times(COUNT - 1, i => createOrderSignature(orders[i])); - const expectedError = new AnyRevertError(); // Just a generic revert. - const tx = txHelper.getResultAndReceiptAsync( - testContract.batchFillOrdersNoThrow, - orders, - fillAmounts, - signatures, - ); - return expect(tx).to.revertWith(expectedError); - }); - }); - - type ExpectedFillOrderCallArgs = [Order, BigNumber, string]; - type MarketSellBuyArgs = [Order[], BigNumber, string[], ...any[]]; - type MarketSellBuyContractFunction = MutatorContractFunction; - type MarketSellBuySimulator = (...args: MarketSellBuyArgs) => [FillResults, ExpectedFillOrderCallArgs[]]; - - describe('marketSell*', () => { - function defineCommonMarketSellOrdersTests( - getContractFn: () => MarketSellBuyContractFunction, - simulator: MarketSellBuySimulator, - ): void { - it('works with one order', async () => { - const COUNT = 1; - const orders = _.times(COUNT, () => randomOrder()); - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - const takerAssetFillAmount = _.reduce( - orders, - (total, o) => o.takerAssetAmount.plus(total), - constants.ZERO_AMOUNT, - ); - const [expectedResult, expectedCalls] = simulator(orders, takerAssetFillAmount, signatures); - expect(expectedCalls.length).to.eq(COUNT); - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - getContractFn(), - orders, - takerAssetFillAmount, - signatures, - ); - expect(actualResult).to.deep.eq(expectedResult); - assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); - }); - - it('works with many orders', async () => { - const COUNT = 8; - const orders = _.times(COUNT, () => randomOrder()); - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - const takerAssetFillAmount = _.reduce( - orders, - (total, o) => o.takerAssetAmount.plus(total), - constants.ZERO_AMOUNT, - ); - const [expectedResult, expectedCalls] = simulator(orders, takerAssetFillAmount, signatures); - expect(expectedCalls.length).to.eq(COUNT); - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - getContractFn(), - orders, - takerAssetFillAmount, - signatures, - ); - expect(actualResult).to.deep.eq(expectedResult); - assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); - }); - - it('works with duplicate orders', async () => { - const NUM_UNIQUE_ORDERS = 2; - const COUNT = 4; - const uniqueOrders = _.times(NUM_UNIQUE_ORDERS, () => randomOrder()); - const orders = _.shuffle(_.flatten(_.times(COUNT / NUM_UNIQUE_ORDERS, () => uniqueOrders))); - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - const takerAssetFillAmount = _.reduce( - orders, - (total, o) => o.takerAssetAmount.plus(total), - constants.ZERO_AMOUNT, - ); - const [expectedResult, expectedCalls] = simulator(orders, takerAssetFillAmount, signatures); - expect(expectedCalls.length).to.eq(COUNT); - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - getContractFn(), - orders, - takerAssetFillAmount, - signatures, - ); - expect(actualResult).to.deep.eq(expectedResult); - assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); - }); - - it('stops when filled == `takerAssetFillAmount`', async () => { - const COUNT = 4; - const orders = _.times(COUNT, () => randomOrder()); - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - // Skip the last order in our `takerAssetFillAmount` calculation. - const takerAssetFillAmount = _.reduce( - orders.slice(0, COUNT - 1), - (total, o) => o.takerAssetAmount.plus(total), - constants.ZERO_AMOUNT, - ); - const [expectedResult, expectedCalls] = simulator(orders, takerAssetFillAmount, signatures); - // It should stop filling after the penultimate order. - expect(expectedCalls.length).to.eq(COUNT - 1); - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - getContractFn(), - orders, - takerAssetFillAmount, - signatures, - ); - expect(actualResult).to.deep.eq(expectedResult); - assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); - }); - - it('stops when filled > `takerAssetFillAmount`', async () => { - const COUNT = 4; - const orders = _.times(COUNT, () => randomOrder()); - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - const takerAssetFillAmount = _.reduce( - orders, - (total, o) => o.takerAssetAmount.plus(total), - constants.ZERO_AMOUNT, - ); - // Because `TestWrapperFunctions` always fills `takerAssetAmount` - // setting the first order's `takerAssetAmount` to larger than - // `takerAssetFillAmount` will cause an overfill. - orders[0].takerAssetAmount = takerAssetFillAmount.plus(1); - const [expectedResult, expectedCalls] = simulator(orders, takerAssetFillAmount, signatures); - // It should stop filling after first order. - expect(expectedCalls.length).to.eq(1); - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - getContractFn(), - orders, - takerAssetFillAmount, - signatures, - ); - expect(actualResult).to.deep.eq(expectedResult); - assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); - }); - - it('reverts when an overflow occurs when summing fill results', async () => { - const COUNT = 2; - const orders = _.times(COUNT, () => randomOrder()); - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - orders[1].takerAssetAmount = MAX_UINT256; - const takerAssetFillAmount = MAX_UINT256; - const expectedError = new SafeMathRevertErrors.Uint256BinOpError( - SafeMathRevertErrors.BinOpErrorCodes.AdditionOverflow, - orders[0].takerAssetAmount, - orders[1].takerAssetAmount, - ); - const tx = txHelper.getResultAndReceiptAsync(getContractFn(), orders, takerAssetFillAmount, signatures); - return expect(tx).to.revertWith(expectedError); - }); - - it('returns empty fill results with no orders', async () => { - const [expectedResult, expectedCalls] = simulator([], constants.ZERO_AMOUNT, []); - expect(expectedCalls.length).to.eq(0); - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - getContractFn(), - [], - constants.ZERO_AMOUNT, - [], - ); - - expect(actualResult).to.deep.eq(expectedResult); - assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); - }); - } - - function simulateMarketSellOrders( - orders: Order[], - takerAssetFillAmount: BigNumber, - signatures: string[], - ): [FillResults, ExpectedFillOrderCallArgs[]] { - const fillOrderCalls = []; - let fillResults = _.cloneDeep(EMPTY_FILL_RESULTS); - for (const [order, signature] of _.zip(orders, signatures) as [[Order, string]]) { - const remainingTakerAssetFillAmount = safeSub(takerAssetFillAmount, fillResults.takerAssetFilledAmount); - if (order.salt !== ALWAYS_FAILING_SALT) { - fillOrderCalls.push([order, remainingTakerAssetFillAmount, signature]); - } - fillResults = addFillResults(fillResults, getExpectedFillResults(order, signature)); - if (fillResults.takerAssetFilledAmount.gte(takerAssetFillAmount)) { - break; - } - } - return [fillResults, fillOrderCalls as any]; - } - - describe('marketSellOrdersNoThrow', () => { - defineCommonMarketSellOrdersTests(() => testContract.marketSellOrdersNoThrow, simulateMarketSellOrders); - - it('works when any fills revert', async () => { - const COUNT = 4; - const BAD_ORDERS_COUNT = 2; - const orders = _.times(COUNT, () => randomOrder()); - const badOrders = _.sampleSize(orders, BAD_ORDERS_COUNT); - for (const order of badOrders) { - order.salt = ALWAYS_FAILING_SALT; - } - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - const takerAssetFillAmount = _.reduce( - orders, - (total, o) => o.takerAssetAmount.plus(total), - constants.ZERO_AMOUNT, - ); - const [expectedResult, expectedCalls] = simulateMarketSellOrders( - orders, - takerAssetFillAmount, - signatures, - ); - expect(expectedCalls.length).to.eq(COUNT - BAD_ORDERS_COUNT); - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - testContract.marketSellOrdersNoThrow, - orders, - takerAssetFillAmount, - signatures, - ); - expect(actualResult).to.deep.eq(expectedResult); - assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); - }); - - it('works when all fills revert', async () => { - const COUNT = 4; - const orders = _.times(COUNT, () => randomOrder({ salt: ALWAYS_FAILING_SALT })); - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - const takerAssetFillAmount = _.reduce( - orders, - (total, o) => o.takerAssetAmount.plus(total), - constants.ZERO_AMOUNT, - ); - const [expectedResult, expectedCalls] = simulateMarketSellOrders( - orders, - takerAssetFillAmount, - signatures, - ); - expect(expectedCalls.length).to.eq(0); - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - testContract.marketSellOrdersNoThrow, - orders, - takerAssetFillAmount, - signatures, - ); - expect(actualResult).to.deep.eq(expectedResult); - assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); - }); - }); - - describe('marketSellOrdersFillOrKill', () => { - defineCommonMarketSellOrdersTests(() => testContract.marketSellOrdersNoThrow, simulateMarketSellOrders); - - it('reverts when filled < `takerAssetFillAmount`', async () => { - const COUNT = 4; - const orders = _.times(COUNT, () => randomOrder()); - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - const takerAssetFillAmount = _.reduce( - orders, - (total, o) => o.takerAssetAmount.plus(total), - constants.ZERO_AMOUNT, - ).plus(1); - const expectedError = new ExchangeRevertErrors.IncompleteFillError( - ExchangeRevertErrors.IncompleteFillErrorCode.IncompleteMarketSellOrders, - takerAssetFillAmount, - takerAssetFillAmount.minus(1), - ); - const tx = txHelper.getResultAndReceiptAsync( - testContract.marketSellOrdersFillOrKill, - orders, - takerAssetFillAmount, - signatures, - ); - return expect(tx).to.revertWith(expectedError); - }); - - it('works when fills fail but can still sell `takerAssetFillAmount`', async () => { - const COUNT = 4; - const BAD_ORDERS_COUNT = 2; - const orders = _.times(COUNT, () => randomOrder()); - const badOrders = _.sampleSize(orders, BAD_ORDERS_COUNT); - for (const order of badOrders) { - order.salt = ALWAYS_FAILING_SALT; - } - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - const takerAssetFillAmount = _.reduce( - orders, - (total, o) => o.takerAssetAmount.plus(total), - constants.ZERO_AMOUNT, - ).minus(_.reduce(badOrders, (total, o) => o.takerAssetAmount.plus(total), constants.ZERO_AMOUNT)); - const [expectedResult, expectedCalls] = simulateMarketSellOrders( - orders, - takerAssetFillAmount, - signatures, - ); - expect(expectedCalls.length).to.eq(COUNT - BAD_ORDERS_COUNT); - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - testContract.marketSellOrdersFillOrKill, - orders, - takerAssetFillAmount, - signatures, - ); - expect(actualResult).to.deep.eq(expectedResult); - assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); - }); - - it('reverts when a failed fill results in selling less than `takerAssetFillAmount`', async () => { - const COUNT = 4; - const BAD_ORDERS_COUNT = 2; - const orders = _.times(COUNT, () => randomOrder()); - const badOrders = _.sampleSize(orders, BAD_ORDERS_COUNT); - for (const order of badOrders) { - order.salt = ALWAYS_FAILING_SALT; - } - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - const badOrdersAmount = _.reduce( - badOrders, - (total, o) => o.takerAssetAmount.plus(total), - constants.ZERO_AMOUNT, - ); - const takerAssetFillAmount = _.reduce( - orders, - (total, o) => o.takerAssetAmount.plus(total), - constants.ZERO_AMOUNT, - ) - .minus(badOrdersAmount) - .plus(1); - const expectedError = new ExchangeRevertErrors.IncompleteFillError( - ExchangeRevertErrors.IncompleteFillErrorCode.IncompleteMarketSellOrders, - takerAssetFillAmount, - takerAssetFillAmount.minus(1), - ); - const tx = txHelper.getResultAndReceiptAsync( - testContract.marketSellOrdersFillOrKill, - orders, - takerAssetFillAmount, - signatures, - ); - return expect(tx).to.revertWith(expectedError); - }); - }); - }); - - describe('marketBuy*', () => { - function defineCommonMarketBuyOrdersTests( - getContractFn: () => MarketSellBuyContractFunction, - simulator: MarketSellBuySimulator, - ): void { - it('works with one order', async () => { - const COUNT = 1; - const orders = _.times(COUNT, () => randomOrder()); - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - const makerAssetFillAmount = _.reduce( - orders, - (total, o) => o.makerAssetAmount.plus(total), - constants.ZERO_AMOUNT, - ); - const [expectedResult, expectedCalls] = simulator(orders, makerAssetFillAmount, signatures); - expect(expectedCalls.length).to.eq(COUNT); - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - getContractFn(), - orders, - makerAssetFillAmount, - signatures, - ); - expect(actualResult).to.deep.eq(expectedResult); - assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); - }); - - it('works with many orders', async () => { - const COUNT = 8; - const orders = _.times(COUNT, () => randomOrder()); - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - const makerAssetFillAmount = _.reduce( - orders, - (total, o) => o.makerAssetAmount.plus(total), - constants.ZERO_AMOUNT, - ); - const [expectedResult, expectedCalls] = simulator(orders, makerAssetFillAmount, signatures); - expect(expectedCalls.length).to.eq(COUNT); - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - getContractFn(), - orders, - makerAssetFillAmount, - signatures, - ); - expect(actualResult).to.deep.eq(expectedResult); - assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); - }); - - it('works with duplicate orders', async () => { - const NUM_UNIQUE_ORDERS = 2; - const COUNT = 4; - const uniqueOrders = _.times(NUM_UNIQUE_ORDERS, () => randomOrder()); - const orders = _.shuffle(_.flatten(_.times(COUNT / NUM_UNIQUE_ORDERS, () => uniqueOrders))); - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - const makerAssetFillAmount = _.reduce( - orders, - (total, o) => o.makerAssetAmount.plus(total), - constants.ZERO_AMOUNT, - ); - const [expectedResult, expectedCalls] = simulator(orders, makerAssetFillAmount, signatures); - expect(expectedCalls.length).to.eq(COUNT); - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - getContractFn(), - orders, - makerAssetFillAmount, - signatures, - ); - expect(actualResult).to.deep.eq(expectedResult); - assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); - }); - - it('stops when filled == `makerAssetFillAmount`', async () => { - const COUNT = 4; - const orders = _.times(COUNT, () => randomOrder()); - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - // Skip the last order in our `makerAssetFillAmount` calculation. - const makerAssetFillAmount = _.reduce( - orders.slice(0, COUNT - 1), - (total, o) => o.makerAssetAmount.plus(total), - constants.ZERO_AMOUNT, - ); - const [expectedResult, expectedCalls] = simulator(orders, makerAssetFillAmount, signatures); - // It should stop filling after the penultimate order. - expect(expectedCalls.length).to.eq(COUNT - 1); - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - getContractFn(), - orders, - makerAssetFillAmount, - signatures, - ); - expect(actualResult).to.deep.eq(expectedResult); - assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); - }); - - it('stops when filled > `makerAssetFillAmount`', async () => { - const COUNT = 4; - const orders = _.times(COUNT, () => randomOrder()); - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - const makerAssetFillAmount = _.reduce( - orders, - (total, o) => o.makerAssetAmount.plus(total), - constants.ZERO_AMOUNT, - ); - // Because `TestWrapperFunctions` always fills `makerAssetAmount` - // setting the first order's `makerAssetAmount` to larger than - // `makerAssetFillAmount` will cause an overfill. - orders[0].makerAssetAmount = makerAssetFillAmount.plus(1); - const [expectedResult, expectedCalls] = simulator(orders, makerAssetFillAmount, signatures); - // It should stop filling after first order. - expect(expectedCalls.length).to.eq(1); - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - getContractFn(), - orders, - makerAssetFillAmount, - signatures, - ); - expect(actualResult).to.deep.eq(expectedResult); - assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); - }); - - it('reverts when an overflow occurs when computing `remainingTakerAssetFillAmount`', async () => { - const orders = [randomOrder({ takerAssetAmount: MAX_UINT256 })]; - const signatures = _.times(orders.length, i => createOrderSignature(orders[i])); - const makerAssetFillAmount = new BigNumber(2); - const expectedError = new SafeMathRevertErrors.Uint256BinOpError( - SafeMathRevertErrors.BinOpErrorCodes.MultiplicationOverflow, - orders[0].takerAssetAmount, - makerAssetFillAmount, - ); - const tx = txHelper.getResultAndReceiptAsync(getContractFn(), orders, makerAssetFillAmount, signatures); - return expect(tx).to.revertWith(expectedError); - }); - - it("reverts when an order's `makerAssetAmount` is zero", async () => { - const orders = [randomOrder({ makerAssetAmount: constants.ZERO_AMOUNT })]; - const signatures = _.times(orders.length, i => createOrderSignature(orders[i])); - const makerAssetFillAmount = ONE_ETHER; - const expectedError = new SafeMathRevertErrors.Uint256BinOpError( - SafeMathRevertErrors.BinOpErrorCodes.DivisionByZero, - orders[0].takerAssetAmount.times(makerAssetFillAmount), - orders[0].makerAssetAmount, - ); - const tx = txHelper.getResultAndReceiptAsync(getContractFn(), orders, makerAssetFillAmount, signatures); - return expect(tx).to.revertWith(expectedError); - }); - - it('reverts when an overflow occurs when summing fill results', async () => { - const orders = [ - randomOrder({ - takerAssetAmount: new BigNumber(1), - makerAssetAmount: new BigNumber(1), - }), - randomOrder({ - takerAssetAmount: new BigNumber(1), - makerAssetAmount: MAX_UINT256, - }), - ]; - const signatures = _.times(orders.length, i => createOrderSignature(orders[i])); - const makerAssetFillAmount = new BigNumber(2); - const expectedError = new SafeMathRevertErrors.Uint256BinOpError( - SafeMathRevertErrors.BinOpErrorCodes.AdditionOverflow, - orders[0].makerAssetAmount, - orders[1].makerAssetAmount, - ); - const tx = txHelper.getResultAndReceiptAsync(getContractFn(), orders, makerAssetFillAmount, signatures); - return expect(tx).to.revertWith(expectedError); - }); - - it('returns empty fill results with no orders', async () => { - const [expectedResult, expectedCalls] = simulator([], constants.ZERO_AMOUNT, []); - expect(expectedCalls.length).to.eq(0); - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - getContractFn(), - [], - constants.ZERO_AMOUNT, - [], - ); - - expect(actualResult).to.deep.eq(expectedResult); - assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); - }); - } - - function simulateMarketBuyOrdersNoThrow( - orders: Order[], - makerAssetFillAmount: BigNumber, - signatures: string[], - ): [FillResults, ExpectedFillOrderCallArgs[]] { - const fillOrderCalls = []; - let fillResults = _.cloneDeep(EMPTY_FILL_RESULTS); - for (const [order, signature] of _.zip(orders, signatures) as [[Order, string]]) { - const remainingMakerAssetFillAmount = safeSub(makerAssetFillAmount, fillResults.makerAssetFilledAmount); - const remainingTakerAssetFillAmount = getPartialAmountFloor( - order.takerAssetAmount, - order.makerAssetAmount, - remainingMakerAssetFillAmount, - ); - if (order.salt !== ALWAYS_FAILING_SALT) { - fillOrderCalls.push([order, remainingTakerAssetFillAmount, signature]); - } - fillResults = addFillResults(fillResults, getExpectedFillResults(order, signature)); - if (fillResults.makerAssetFilledAmount.gte(makerAssetFillAmount)) { - break; - } - } - return [fillResults, fillOrderCalls as any]; - } - - describe('marketBuyOrdersNoThrow', () => { - defineCommonMarketBuyOrdersTests(() => testContract.marketBuyOrdersNoThrow, simulateMarketBuyOrdersNoThrow); - - it('works when any fills revert', async () => { - const COUNT = 4; - const BAD_ORDERS_COUNT = 2; - const orders = _.times(COUNT, () => randomOrder()); - const badOrders = _.sampleSize(orders, BAD_ORDERS_COUNT); - for (const order of badOrders) { - order.salt = ALWAYS_FAILING_SALT; - } - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - const makerAssetFillAmount = _.reduce( - orders, - (total, o) => o.makerAssetAmount.plus(total), - constants.ZERO_AMOUNT, - ); - const [expectedResult, expectedCalls] = simulateMarketBuyOrdersNoThrow( - orders, - makerAssetFillAmount, - signatures, - ); - expect(expectedCalls.length).to.eq(COUNT - BAD_ORDERS_COUNT); - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - testContract.marketBuyOrdersNoThrow, - orders, - makerAssetFillAmount, - signatures, - ); - expect(actualResult).to.deep.eq(expectedResult); - assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); - }); - - it('works when all fills revert', async () => { - const COUNT = 4; - const orders = _.times(COUNT, () => randomOrder({ salt: ALWAYS_FAILING_SALT })); - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - const makerAssetFillAmount = _.reduce( - orders, - (total, o) => o.makerAssetAmount.plus(total), - constants.ZERO_AMOUNT, - ); - const [expectedResult, expectedCalls] = simulateMarketBuyOrdersNoThrow( - orders, - makerAssetFillAmount, - signatures, - ); - expect(expectedCalls.length).to.eq(0); - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - testContract.marketBuyOrdersNoThrow, - orders, - makerAssetFillAmount, - signatures, - ); - expect(actualResult).to.deep.eq(expectedResult); - assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); - }); - }); - - describe('marketBuyOrdersFillOrKill', () => { - defineCommonMarketBuyOrdersTests( - () => testContract.marketBuyOrdersFillOrKill, - simulateMarketBuyOrdersNoThrow, - ); - - it('reverts when filled < `makerAssetFillAmount`', async () => { - const COUNT = 4; - const orders = _.times(COUNT, () => randomOrder()); - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - const makerAssetFillAmount = _.reduce( - orders, - (total, o) => o.makerAssetAmount.plus(total), - constants.ZERO_AMOUNT, - ).plus(1); - const expectedError = new ExchangeRevertErrors.IncompleteFillError( - ExchangeRevertErrors.IncompleteFillErrorCode.IncompleteMarketBuyOrders, - makerAssetFillAmount, - makerAssetFillAmount.minus(1), - ); - const tx = txHelper.getResultAndReceiptAsync( - testContract.marketBuyOrdersFillOrKill, - orders, - makerAssetFillAmount, - signatures, - ); - return expect(tx).to.revertWith(expectedError); - }); - - it('works when fills fail but can still buy `makerAssetFillAmount`', async () => { - const COUNT = 4; - const BAD_ORDERS_COUNT = 2; - const orders = _.times(COUNT, () => randomOrder()); - const badOrders = _.sampleSize(orders, BAD_ORDERS_COUNT); - for (const order of badOrders) { - order.salt = ALWAYS_FAILING_SALT; - } - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - const makerAssetFillAmount = _.reduce( - orders, - (total, o) => o.makerAssetAmount.plus(total), - constants.ZERO_AMOUNT, - ).minus(_.reduce(badOrders, (total, o) => o.makerAssetAmount.plus(total), constants.ZERO_AMOUNT)); - const [expectedResult, expectedCalls] = simulateMarketBuyOrdersNoThrow( - orders, - makerAssetFillAmount, - signatures, - ); - expect(expectedCalls.length).to.eq(COUNT - BAD_ORDERS_COUNT); - const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( - testContract.marketBuyOrdersFillOrKill, - orders, - makerAssetFillAmount, - signatures, - ); - expect(actualResult).to.deep.eq(expectedResult); - assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); - }); - - it('reverts when a failed fill results in buying less than `makerAssetFillAmount`', async () => { - const COUNT = 4; - const BAD_ORDERS_COUNT = 2; - const orders = _.times(COUNT, () => randomOrder()); - const badOrders = _.sampleSize(orders, BAD_ORDERS_COUNT); - for (const order of badOrders) { - order.salt = ALWAYS_FAILING_SALT; - } - const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); - const badOrdersAmount = _.reduce( - badOrders, - (total, o) => o.makerAssetAmount.plus(total), - constants.ZERO_AMOUNT, - ); - const makerAssetFillAmount = _.reduce( - orders, - (total, o) => o.makerAssetAmount.plus(total), - constants.ZERO_AMOUNT, - ) - .minus(badOrdersAmount) - .plus(1); - const expectedError = new ExchangeRevertErrors.IncompleteFillError( - ExchangeRevertErrors.IncompleteFillErrorCode.IncompleteMarketBuyOrders, - makerAssetFillAmount, - makerAssetFillAmount.minus(1), - ); - const tx = txHelper.getResultAndReceiptAsync( - testContract.marketBuyOrdersFillOrKill, - orders, - makerAssetFillAmount, - signatures, - ); - return expect(tx).to.revertWith(expectedError); - }); - }); - }); - - describe('batchCancelOrders', () => { - // Asserts that `_cancelOrder()` was called in the same order and with the same - // arguments as given by examining receipt logs. - function assertCancelOrderCallsFromLogs(logs: LogEntry[], calls: Order[]): void { - expect(logs.length).to.eq(calls.length); - for (const i of _.times(calls.length)) { - const log = (logs[i] as any) as LogWithDecodedArgs; - const expectedOrder = calls[i]; - expect(log.event).to.eq('CancelOrderCalled'); - assertSameOrderFromEvent(log.args.order as any, expectedOrder); - } - } - - it('works with no orders', async () => { - const [, receipt] = await txHelper.getResultAndReceiptAsync(testContract.batchCancelOrders, []); - assertCancelOrderCallsFromLogs(receipt.logs, []); - }); - - it('works with many orders', async () => { - const COUNT = 8; - const orders = _.times(COUNT, () => randomOrder({ makerAddress: senderAddress })); - const [, receipt] = await txHelper.getResultAndReceiptAsync(testContract.batchCancelOrders, orders); - assertCancelOrderCallsFromLogs(receipt.logs, orders); - }); - - it('works with duplicate orders', async () => { - const UNIQUE_ORDERS = 2; - const COUNT = 6; - const uniqueOrders = _.times(UNIQUE_ORDERS, () => randomOrder({ makerAddress: senderAddress })); - const orders = _.shuffle(_.flatten(_.times(COUNT / UNIQUE_ORDERS, () => uniqueOrders))); - const [, receipt] = await txHelper.getResultAndReceiptAsync(testContract.batchCancelOrders, orders); - assertCancelOrderCallsFromLogs(receipt.logs, orders); - }); - - it('reverts if one `_cancelOrder()` reverts', async () => { - const COUNT = 8; - const FAILING_ORDER_INDEX = 4; - const orders = _.times(COUNT, () => randomOrder({ makerAddress: senderAddress })); - const failingOrder = orders[FAILING_ORDER_INDEX]; - failingOrder.salt = ALWAYS_FAILING_SALT; - const expectedError = ALWAYS_FAILING_SALT_REVERT_ERROR; - const tx = txHelper.getResultAndReceiptAsync(testContract.batchCancelOrders, orders); - return expect(tx).to.revertWith(expectedError); - }); - }); -}); -// tslint:disable-next-line: max-file-line-count +// import { ReferenceFunctions as LibReferenceFunctions } from '@0x/contracts-exchange-libs'; +// import { +// blockchainTests, +// constants, +// describe, +// expect, +// hexRandom, +// MutatorContractFunction, +// transactionHelper, +// } from '@0x/contracts-test-utils'; +// import { ReferenceFunctions as UtilReferenceFunctions } from '@0x/contracts-utils'; +// import { ExchangeRevertErrors, orderHashUtils } from '@0x/order-utils'; +// import { FillResults, Order } from '@0x/types'; +// import { AnyRevertError, BigNumber, SafeMathRevertErrors, StringRevertError } from '@0x/utils'; +// import { LogEntry, LogWithDecodedArgs } from 'ethereum-types'; +// import * as ethjs from 'ethereumjs-util'; +// import * as _ from 'lodash'; + +// import { +// artifacts, +// TestWrapperFunctionsCancelOrderCalledEventArgs as CancelOrderCalledEventArgs, +// TestWrapperFunctionsContract, +// TestWrapperFunctionsFillOrderCalledEventArgs as FillOrderCalledEventArgs, +// } from '../src'; + +// blockchainTests('Exchange wrapper functions unit tests.', env => { +// const CHAIN_ID = 0x74657374; +// const { ONE_ETHER, MAX_UINT256 } = constants; +// const { addFillResults, getPartialAmountFloor } = LibReferenceFunctions; +// const { safeSub } = UtilReferenceFunctions; +// const protocolFeeMultiplier = new BigNumber(150000); +// const randomAddress = () => hexRandom(constants.ADDRESS_LENGTH); +// const randomAssetData = () => hexRandom(34); +// const randomAmount = (maxAmount: BigNumber = ONE_ETHER) => maxAmount.times(_.random(0, 100, true).toFixed(12)); +// const randomTimestamp = () => new BigNumber(Math.floor(_.now() / 1000) + _.random(0, 34560)); +// const randomSalt = () => new BigNumber(hexRandom(constants.WORD_LENGTH).substr(2), 16); +// const ALWAYS_FAILING_SALT = constants.MAX_UINT256; +// const ALWAYS_FAILING_SALT_REVERT_ERROR = new StringRevertError('ALWAYS_FAILING_SALT'); +// const EMPTY_FILL_RESULTS = { +// makerAssetFilledAmount: constants.ZERO_AMOUNT, +// takerAssetFilledAmount: constants.ZERO_AMOUNT, +// makerFeePaid: constants.ZERO_AMOUNT, +// takerFeePaid: constants.ZERO_AMOUNT, +// protocolFeePaid: constants.ZERO_AMOUNT, +// }; +// let testContract: TestWrapperFunctionsContract; +// let owner: string; +// let senderAddress: string; + +// before(async () => { +// [owner, senderAddress] = await env.getAccountAddressesAsync(); +// testContract = await TestWrapperFunctionsContract.deployFrom0xArtifactAsync( +// artifacts.TestWrapperFunctions, +// env.provider, +// { +// ...env.txDefaults, +// from: owner, +// }, +// {}, +// ); + +// // Set the protocol fee multiplier. +// await testContract.setProtocolFeeMultiplier(protocolFeeMultiplier).awaitTransactionSuccessAsync({ +// from: owner, +// }); +// }); + +// function randomOrder(fields?: Partial): Order { +// return { +// makerAddress: randomAddress(), +// takerAddress: randomAddress(), +// feeRecipientAddress: randomAddress(), +// senderAddress: randomAddress(), +// takerAssetAmount: randomAmount(), +// makerAssetAmount: randomAmount(), +// makerFee: randomAmount(), +// takerFee: randomAmount(), +// expirationTimeSeconds: randomTimestamp(), +// salt: randomSalt(), +// makerAssetData: randomAssetData(), +// takerAssetData: randomAssetData(), +// makerFeeAssetData: randomAssetData(), +// takerFeeAssetData: randomAssetData(), +// exchangeAddress: constants.NULL_ADDRESS, +// chainId: CHAIN_ID, +// ...(fields || {}), +// }; +// } + +// // Computes the expected (fake) fill results from `TestWrapperFunctions` `_fillOrder` implementation. +// function getExpectedFillResults(order: Order, signature: string): FillResults { +// if (order.salt === ALWAYS_FAILING_SALT) { +// return EMPTY_FILL_RESULTS; +// } +// return { +// makerAssetFilledAmount: order.makerAssetAmount, +// takerAssetFilledAmount: order.takerAssetAmount, +// makerFeePaid: order.makerFee, +// takerFeePaid: order.takerFee, +// protocolFeePaid: protocolFeeMultiplier, +// }; +// } + +// // Creates a deterministic order signature, even though no signature validation +// // actually occurs in the test contract. +// function createOrderSignature(order: Order): string { +// return ethjs.bufferToHex(ethjs.sha3(ethjs.toBuffer(orderHashUtils.getOrderHashHex(order)))); +// } + +// // Asserts that `_fillOrder()` was called in the same order and with the same +// // arguments as given by examining receipt logs. +// function assertFillOrderCallsFromLogs(logs: LogEntry[], calls: Array<[Order, BigNumber, string]>): void { +// expect(logs.length).to.eq(calls.length); +// for (const i of _.times(calls.length)) { +// const log = (logs[i] as any) as LogWithDecodedArgs; +// const [expectedOrder, expectedTakerAssetFillAmount, expectedSignature] = calls[i]; +// expect(log.event).to.eq('FillOrderCalled'); +// assertSameOrderFromEvent(log.args.order as any, expectedOrder); +// expect(log.args.takerAssetFillAmount).to.bignumber.eq(expectedTakerAssetFillAmount); +// expect(log.args.signature).to.eq(expectedSignature); +// } +// } + +// function assertSameOrderFromEvent(actual: any[], expected: Order): void { +// expect(actual.length === 14); +// expect(actual[0].toLowerCase()).to.be.eq(expected.makerAddress); +// expect(actual[1].toLowerCase()).to.be.eq(expected.takerAddress); +// expect(actual[2].toLowerCase()).to.be.eq(expected.feeRecipientAddress); +// expect(actual[3].toLowerCase()).to.be.eq(expected.senderAddress); +// expect(actual[4]).to.be.bignumber.eq(expected.makerAssetAmount); +// expect(actual[5]).to.be.bignumber.eq(expected.takerAssetAmount); +// expect(actual[6]).to.be.bignumber.eq(expected.makerFee); +// expect(actual[7]).to.be.bignumber.eq(expected.takerFee); +// expect(actual[8]).to.be.bignumber.eq(expected.expirationTimeSeconds); +// expect(actual[9]).to.be.bignumber.eq(expected.salt); +// expect(actual[10]).to.be.eq(expected.makerAssetData); +// expect(actual[11]).to.be.eq(expected.takerAssetData); +// expect(actual[12]).to.be.eq(expected.makerFeeAssetData); +// expect(actual[13]).to.be.eq(expected.takerFeeAssetData); +// } + +// describe('fillOrKillOrder', () => { +// it('works if the order is filled by exactly `takerAssetFillAmount`', async () => { +// const fillAmount = randomAmount(); +// const order = randomOrder({ +// // `_fillOrder()` is overridden to always return `order.takerAssetAmount` as +// // the `takerAssetFilledAmount`. +// takerAssetAmount: fillAmount, +// }); +// const signature = createOrderSignature(order); +// const expectedResult = getExpectedFillResults(order, signature); +// const expectedCalls = [[order, fillAmount, signature]]; +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// testContract.fillOrKillOrder, +// order, +// fillAmount, +// signature, +// ); +// expect(actualResult).to.deep.eq(expectedResult); +// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); +// }); + +// it('reverts if the order is filled by less than `takerAssetFillAmount`', async () => { +// const fillAmount = randomAmount(); +// const order = randomOrder({ +// // `_fillOrder()` is overridden to always return `order.takerAssetAmount` as +// // the `takerAssetFilledAmount`. +// takerAssetAmount: fillAmount.minus(1), +// }); +// const signature = createOrderSignature(order); +// const expectedError = new ExchangeRevertErrors.IncompleteFillError( +// ExchangeRevertErrors.IncompleteFillErrorCode.IncompleteFillOrder, +// fillAmount, +// fillAmount.minus(1), +// ); +// const tx = testContract.fillOrKillOrder(order, fillAmount, signature).awaitTransactionSuccessAsync(); +// return expect(tx).to.revertWith(expectedError); +// }); + +// it('reverts if the order is filled by greater than `takerAssetFillAmount`', async () => { +// const fillAmount = randomAmount(); +// const order = randomOrder({ +// // `_fillOrder()` is overridden to always return `order.takerAssetAmount` as +// // the `takerAssetFilledAmount`. +// takerAssetAmount: fillAmount.plus(1), +// }); +// const signature = createOrderSignature(order); +// const expectedError = new ExchangeRevertErrors.IncompleteFillError( +// ExchangeRevertErrors.IncompleteFillErrorCode.IncompleteFillOrder, +// fillAmount, +// fillAmount.plus(1), +// ); +// const tx = testContract.fillOrKillOrder(order, fillAmount, signature).awaitTransactionSuccessAsync(); +// return expect(tx).to.revertWith(expectedError); +// }); + +// it('reverts if `_fillOrder()` reverts', async () => { +// const fillAmount = randomAmount(); +// const order = randomOrder({ +// salt: ALWAYS_FAILING_SALT, +// }); +// const signature = createOrderSignature(order); +// const expectedError = ALWAYS_FAILING_SALT_REVERT_ERROR; +// const tx = testContract.fillOrKillOrder(order, fillAmount, signature).awaitTransactionSuccessAsync(); +// return expect(tx).to.revertWith(expectedError); +// }); +// }); + +// describe('fillOrderNoThrow', () => { +// it('calls `fillOrder()` and returns its result', async () => { +// const fillAmount = randomAmount(); +// const order = randomOrder(); +// const signature = createOrderSignature(order); +// const expectedResult = getExpectedFillResults(order, signature); +// const expectedCalls = [[order, fillAmount, signature]]; +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// testContract.fillOrderNoThrow, +// order, +// fillAmount, +// signature, +// ); +// expect(actualResult).to.deep.eq(expectedResult); +// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); +// }); + +// it('does not revert if `fillOrder()` reverts', async () => { +// const fillAmount = randomAmount(); +// const order = randomOrder({ +// salt: ALWAYS_FAILING_SALT, +// }); +// const signature = createOrderSignature(order); +// const expectedResult = EMPTY_FILL_RESULTS; +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// testContract.fillOrderNoThrow, +// order, +// fillAmount, +// signature, +// ); +// expect(actualResult).to.deep.eq(expectedResult); +// assertFillOrderCallsFromLogs(receipt.logs, []); +// }); +// }); + +// describe('batchFillOrders', () => { +// it('works with no fills', async () => { +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// testContract.batchFillOrders, +// [], +// [], +// [], +// ); +// expect(actualResult).to.deep.eq([]); +// assertFillOrderCallsFromLogs(receipt.logs, []); +// }); + +// it('works with one fill', async () => { +// const COUNT = 1; +// const orders = _.times(COUNT, () => randomOrder()); +// const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); +// const expectedCalls = _.zip(orders, fillAmounts, signatures); +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// testContract.batchFillOrders, +// orders, +// fillAmounts, +// signatures, +// ); +// expect(actualResult).to.deep.eq(expectedResult); +// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); +// }); + +// it('works with many fills', async () => { +// const COUNT = 8; +// const orders = _.times(COUNT, () => randomOrder()); +// const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); +// const expectedCalls = _.zip(orders, fillAmounts, signatures); +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// testContract.batchFillOrders, +// orders, +// fillAmounts, +// signatures, +// ); +// expect(actualResult).to.deep.eq(expectedResult); +// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); +// }); + +// it('works with duplicate orders', async () => { +// const NUM_UNIQUE_ORDERS = 2; +// const COUNT = 4; +// const uniqueOrders = _.times(NUM_UNIQUE_ORDERS, () => randomOrder()); +// const orders = _.shuffle(_.flatten(_.times(COUNT / NUM_UNIQUE_ORDERS, () => uniqueOrders))); +// const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount.dividedToIntegerBy(COUNT)); +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); +// const expectedCalls = _.zip(orders, fillAmounts, signatures); +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// testContract.batchFillOrders, +// orders, +// fillAmounts, +// signatures, +// ); +// expect(actualResult).to.deep.eq(expectedResult); +// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); +// }); + +// it('reverts if there are more orders than fill amounts', async () => { +// const COUNT = 8; +// const orders = _.times(COUNT, () => randomOrder()); +// const fillAmounts = _.times(COUNT - 1, i => orders[i].takerAssetAmount); +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// const expectedError = new AnyRevertError(); // Just a generic revert. +// const tx = transactionHelper.getResultAndReceiptAsync(testContract.batchFillOrders, orders, fillAmounts, signatures); +// return expect(tx).to.revertWith(expectedError); +// }); + +// it('reverts if there are more orders than signatures', async () => { +// const COUNT = 8; +// const orders = _.times(COUNT, () => randomOrder()); +// const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); +// const signatures = _.times(COUNT - 1, i => createOrderSignature(orders[i])); +// const expectedError = new AnyRevertError(); // Just a generic revert. +// const tx = transactionHelper.getResultAndReceiptAsync(testContract.batchFillOrders, orders, fillAmounts, signatures); +// return expect(tx).to.revertWith(expectedError); +// }); +// }); + +// describe('batchFillOrKillOrders', () => { +// it('works with no fills', async () => { +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// testContract.batchFillOrKillOrders, +// [], +// [], +// [], +// ); +// expect(actualResult).to.deep.eq([]); +// assertFillOrderCallsFromLogs(receipt.logs, []); +// }); + +// it('works with one fill', async () => { +// const COUNT = 1; +// const orders = _.times(COUNT, () => randomOrder()); +// const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); +// const expectedCalls = _.zip(orders, fillAmounts, signatures); +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// testContract.batchFillOrKillOrders, +// orders, +// fillAmounts, +// signatures, +// ); +// expect(actualResult).to.deep.eq(expectedResult); +// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); +// }); + +// it('works with many fills', async () => { +// const COUNT = 8; +// const orders = _.times(COUNT, () => randomOrder()); +// const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); +// const expectedCalls = _.zip(orders, fillAmounts, signatures); +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// testContract.batchFillOrKillOrders, +// orders, +// fillAmounts, +// signatures, +// ); +// expect(actualResult).to.deep.eq(expectedResult); +// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); +// }); + +// it('works with duplicate orders', async () => { +// const NUM_UNIQUE_ORDERS = 2; +// const COUNT = 4; +// const uniqueOrders = _.times(NUM_UNIQUE_ORDERS, () => randomOrder()); +// const orders = _.shuffle(_.flatten(_.times(COUNT / NUM_UNIQUE_ORDERS, () => uniqueOrders))); +// const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); +// const expectedCalls = _.zip(orders, fillAmounts, signatures); +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// testContract.batchFillOrKillOrders, +// orders, +// fillAmounts, +// signatures, +// ); +// expect(actualResult).to.deep.eq(expectedResult); +// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); +// }); + +// it('reverts if any fill sells less than its takerAssetFillAmount', async () => { +// const COUNT = 8; +// const FAILING_ORDER_INDEX = 6; +// const orders = _.times(COUNT, () => randomOrder()); +// const failingOrder = orders[FAILING_ORDER_INDEX]; +// const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); +// const failingAmount = fillAmounts[FAILING_ORDER_INDEX]; +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// // `_fillOrder()` is overridden to always return `order.takerAssetAmount` as +// // the `takerAssetFilledAmount`. +// failingOrder.takerAssetAmount = failingOrder.takerAssetAmount.minus(1); +// const expectedError = new ExchangeRevertErrors.IncompleteFillError( +// ExchangeRevertErrors.IncompleteFillErrorCode.IncompleteFillOrder, +// failingAmount, +// failingAmount.minus(1), +// ); +// const tx = transactionHelper.getResultAndReceiptAsync( +// testContract.batchFillOrKillOrders, +// orders, +// fillAmounts, +// signatures, +// ); +// return expect(tx).to.revertWith(expectedError); +// }); + +// it('reverts if any fill sells more than its takerAssetFillAmount', async () => { +// const COUNT = 8; +// const FAILING_ORDER_INDEX = 6; +// const orders = _.times(COUNT, () => randomOrder()); +// const failingOrder = orders[FAILING_ORDER_INDEX]; +// const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); +// const failingAmount = fillAmounts[FAILING_ORDER_INDEX]; +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// // `_fillOrder()` is overridden to always return `order.takerAssetAmount` as +// // the `takerAssetFilledAmount`. +// failingOrder.takerAssetAmount = failingOrder.takerAssetAmount.plus(1); +// const expectedError = new ExchangeRevertErrors.IncompleteFillError( +// ExchangeRevertErrors.IncompleteFillErrorCode.IncompleteFillOrder, +// failingAmount, +// failingAmount.plus(1), +// ); +// const tx = transactionHelper.getResultAndReceiptAsync( +// testContract.batchFillOrKillOrders, +// orders, +// fillAmounts, +// signatures, +// ); +// return expect(tx).to.revertWith(expectedError); +// }); + +// it('reverts if there are more orders than fill amounts', async () => { +// const COUNT = 8; +// const orders = _.times(COUNT, () => randomOrder()); +// const fillAmounts = _.times(COUNT - 1, i => orders[i].takerAssetAmount); +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// const expectedError = new AnyRevertError(); // Just a generic revert. +// const tx = transactionHelper.getResultAndReceiptAsync( +// testContract.batchFillOrKillOrders, +// orders, +// fillAmounts, +// signatures, +// ); +// return expect(tx).to.revertWith(expectedError); +// }); + +// it('reverts if there are more orders than signatures', async () => { +// const COUNT = 8; +// const orders = _.times(COUNT, () => randomOrder()); +// const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); +// const signatures = _.times(COUNT - 1, i => createOrderSignature(orders[i])); +// const expectedError = new AnyRevertError(); // Just a generic revert. +// const tx = transactionHelper.getResultAndReceiptAsync( +// testContract.batchFillOrKillOrders, +// orders, +// fillAmounts, +// signatures, +// ); +// return expect(tx).to.revertWith(expectedError); +// }); +// }); + +// describe('batchFillOrdersNoThrow', () => { +// it('works with no fills', async () => { +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// testContract.batchFillOrdersNoThrow, +// [], +// [], +// [], +// ); +// expect(actualResult).to.deep.eq([]); +// assertFillOrderCallsFromLogs(receipt.logs, []); +// }); + +// it('works with one fill', async () => { +// const COUNT = 1; +// const orders = _.times(COUNT, () => randomOrder()); +// const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); +// const expectedCalls = _.zip(orders, fillAmounts, signatures); +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// testContract.batchFillOrdersNoThrow, +// orders, +// fillAmounts, +// signatures, +// ); +// expect(actualResult).to.deep.eq(expectedResult); +// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); +// }); + +// it('works with many fills', async () => { +// const COUNT = 8; +// const orders = _.times(COUNT, () => randomOrder()); +// const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); +// const expectedCalls = _.zip(orders, fillAmounts, signatures); +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// testContract.batchFillOrdersNoThrow, +// orders, +// fillAmounts, +// signatures, +// ); +// expect(actualResult).to.deep.eq(expectedResult); +// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); +// }); + +// it('works with duplicate orders', async () => { +// const NUM_UNIQUE_ORDERS = 2; +// const COUNT = 4; +// const uniqueOrders = _.times(NUM_UNIQUE_ORDERS, () => randomOrder()); +// const orders = _.shuffle(_.flatten(_.times(COUNT / NUM_UNIQUE_ORDERS, () => uniqueOrders))); +// const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount.dividedToIntegerBy(COUNT)); +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); +// const expectedCalls = _.zip(orders, fillAmounts, signatures); +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// testContract.batchFillOrdersNoThrow, +// orders, +// fillAmounts, +// signatures, +// ); +// expect(actualResult).to.deep.eq(expectedResult); +// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); +// }); + +// it('works if a fill fails', async () => { +// const COUNT = 8; +// const FAILING_ORDER_INDEX = 6; +// const orders = _.times(COUNT, () => randomOrder()); +// const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// const failingOrder = orders[FAILING_ORDER_INDEX]; +// failingOrder.salt = ALWAYS_FAILING_SALT; +// const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); +// const expectedCalls = _.zip(orders, fillAmounts, signatures); +// expectedCalls.splice(FAILING_ORDER_INDEX, 1); +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// testContract.batchFillOrdersNoThrow, +// orders, +// fillAmounts, +// signatures, +// ); +// expect(actualResult).to.deep.eq(expectedResult); +// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); +// }); + +// it('reverts if there are more orders than fill amounts', async () => { +// const COUNT = 8; +// const orders = _.times(COUNT, () => randomOrder()); +// const fillAmounts = _.times(COUNT - 1, i => orders[i].takerAssetAmount); +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// const expectedError = new AnyRevertError(); // Just a generic revert. +// const tx = transactionHelper.getResultAndReceiptAsync( +// testContract.batchFillOrdersNoThrow, +// orders, +// fillAmounts, +// signatures, +// ); +// return expect(tx).to.revertWith(expectedError); +// }); + +// it('reverts if there are more orders than signatures', async () => { +// const COUNT = 8; +// const orders = _.times(COUNT, () => randomOrder()); +// const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); +// const signatures = _.times(COUNT - 1, i => createOrderSignature(orders[i])); +// const expectedError = new AnyRevertError(); // Just a generic revert. +// const tx = transactionHelper.getResultAndReceiptAsync( +// testContract.batchFillOrdersNoThrow, +// orders, +// fillAmounts, +// signatures, +// ); +// return expect(tx).to.revertWith(expectedError); +// }); +// }); + +// type ExpectedFillOrderCallArgs = [Order, BigNumber, string]; +// type MarketSellBuyArgs = [Order[], BigNumber, string[], ...any[]]; +// type MarketSellBuyContractFunction = () => MutatorContractFunction<[FillResults, ExpectedFillOrderCallArgs[]]>; +// type MarketSellBuySimulator = (...args: MarketSellBuyArgs) => [FillResults, ExpectedFillOrderCallArgs[]]; + +// describe('marketSell*', () => { +// function defineCommonMarketSellOrdersTests( +// getContractFn: MarketSellBuyContractFunction, +// simulator: MarketSellBuySimulator, +// ): void { +// it('works with one order', async () => { +// const COUNT = 1; +// const orders = _.times(COUNT, () => randomOrder()); +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// const takerAssetFillAmount = _.reduce( +// orders, +// (total, o) => o.takerAssetAmount.plus(total), +// constants.ZERO_AMOUNT, +// ); +// const [expectedResult, expectedCalls] = simulator(orders, takerAssetFillAmount, signatures); +// expect(expectedCalls.length).to.eq(COUNT); +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// getContractFn, +// orders, +// takerAssetFillAmount, +// signatures, +// ); +// expect(actualResult).to.deep.eq(expectedResult); +// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); +// }); + +// it('works with many orders', async () => { +// const COUNT = 8; +// const orders = _.times(COUNT, () => randomOrder()); +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// const takerAssetFillAmount = _.reduce( +// orders, +// (total, o) => o.takerAssetAmount.plus(total), +// constants.ZERO_AMOUNT, +// ); +// const [expectedResult, expectedCalls] = simulator(orders, takerAssetFillAmount, signatures); +// expect(expectedCalls.length).to.eq(COUNT); +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// getContractFn, +// orders, +// takerAssetFillAmount, +// signatures, +// ); +// expect(actualResult).to.deep.eq(expectedResult); +// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); +// }); + +// it('works with duplicate orders', async () => { +// const NUM_UNIQUE_ORDERS = 2; +// const COUNT = 4; +// const uniqueOrders = _.times(NUM_UNIQUE_ORDERS, () => randomOrder()); +// const orders = _.shuffle(_.flatten(_.times(COUNT / NUM_UNIQUE_ORDERS, () => uniqueOrders))); +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// const takerAssetFillAmount = _.reduce( +// orders, +// (total, o) => o.takerAssetAmount.plus(total), +// constants.ZERO_AMOUNT, +// ); +// const [expectedResult, expectedCalls] = simulator(orders, takerAssetFillAmount, signatures); +// expect(expectedCalls.length).to.eq(COUNT); +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// getContractFn, +// orders, +// takerAssetFillAmount, +// signatures, +// ); +// expect(actualResult).to.deep.eq(expectedResult); +// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); +// }); + +// it('stops when filled == `takerAssetFillAmount`', async () => { +// const COUNT = 4; +// const orders = _.times(COUNT, () => randomOrder()); +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// // Skip the last order in our `takerAssetFillAmount` calculation. +// const takerAssetFillAmount = _.reduce( +// orders.slice(0, COUNT - 1), +// (total, o) => o.takerAssetAmount.plus(total), +// constants.ZERO_AMOUNT, +// ); +// const [expectedResult, expectedCalls] = simulator(orders, takerAssetFillAmount, signatures); +// // It should stop filling after the penultimate order. +// expect(expectedCalls.length).to.eq(COUNT - 1); +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// getContractFn, +// orders, +// takerAssetFillAmount, +// signatures, +// ); +// expect(actualResult).to.deep.eq(expectedResult); +// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); +// }); + +// it('stops when filled > `takerAssetFillAmount`', async () => { +// const COUNT = 4; +// const orders = _.times(COUNT, () => randomOrder()); +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// const takerAssetFillAmount = _.reduce( +// orders, +// (total, o) => o.takerAssetAmount.plus(total), +// constants.ZERO_AMOUNT, +// ); +// // Because `TestWrapperFunctions` always fills `takerAssetAmount` +// // setting the first order's `takerAssetAmount` to larger than +// // `takerAssetFillAmount` will cause an overfill. +// orders[0].takerAssetAmount = takerAssetFillAmount.plus(1); +// const [expectedResult, expectedCalls] = simulator(orders, takerAssetFillAmount, signatures); +// // It should stop filling after first order. +// expect(expectedCalls.length).to.eq(1); +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// getContractFn, +// orders, +// takerAssetFillAmount, +// signatures, +// ); +// expect(actualResult).to.deep.eq(expectedResult); +// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); +// }); + +// it('reverts when an overflow occurs when summing fill results', async () => { +// const COUNT = 2; +// const orders = _.times(COUNT, () => randomOrder()); +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// orders[1].takerAssetAmount = MAX_UINT256; +// const takerAssetFillAmount = MAX_UINT256; +// const expectedError = new SafeMathRevertErrors.Uint256BinOpError( +// SafeMathRevertErrors.BinOpErrorCodes.AdditionOverflow, +// orders[0].takerAssetAmount, +// orders[1].takerAssetAmount, +// ); +// const tx = transactionHelper.getResultAndReceiptAsync(getContractFn, orders, takerAssetFillAmount, signatures); +// return expect(tx).to.revertWith(expectedError); +// }); + +// it('returns empty fill results with no orders', async () => { +// const [expectedResult, expectedCalls] = simulator([], constants.ZERO_AMOUNT, []); +// expect(expectedCalls.length).to.eq(0); +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// getContractFn, +// [], +// constants.ZERO_AMOUNT, +// [], +// ); + +// expect(actualResult).to.deep.eq(expectedResult); +// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); +// }); +// } + +// function simulateMarketSellOrders( +// orders: Order[], +// takerAssetFillAmount: BigNumber, +// signatures: string[], +// ): [FillResults, ExpectedFillOrderCallArgs[]] { +// const fillOrderCalls = []; +// let fillResults = _.cloneDeep(EMPTY_FILL_RESULTS); +// for (const [order, signature] of _.zip(orders, signatures) as [[Order, string]]) { +// const remainingTakerAssetFillAmount = safeSub(takerAssetFillAmount, fillResults.takerAssetFilledAmount); +// if (order.salt !== ALWAYS_FAILING_SALT) { +// fillOrderCalls.push([order, remainingTakerAssetFillAmount, signature]); +// } +// fillResults = addFillResults(fillResults, getExpectedFillResults(order, signature)); +// if (fillResults.takerAssetFilledAmount.gte(takerAssetFillAmount)) { +// break; +// } +// } +// return [fillResults, fillOrderCalls as any]; +// } + +// describe('marketSellOrdersNoThrow', () => { +// defineCommonMarketSellOrdersTests(() => testContract.marketSellOrdersNoThrow, simulateMarketSellOrders); + +// it('works when any fills revert', async () => { +// const COUNT = 4; +// const BAD_ORDERS_COUNT = 2; +// const orders = _.times(COUNT, () => randomOrder()); +// const badOrders = _.sampleSize(orders, BAD_ORDERS_COUNT); +// for (const order of badOrders) { +// order.salt = ALWAYS_FAILING_SALT; +// } +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// const takerAssetFillAmount = _.reduce( +// orders, +// (total, o) => o.takerAssetAmount.plus(total), +// constants.ZERO_AMOUNT, +// ); +// const [expectedResult, expectedCalls] = simulateMarketSellOrders( +// orders, +// takerAssetFillAmount, +// signatures, +// ); +// expect(expectedCalls.length).to.eq(COUNT - BAD_ORDERS_COUNT); +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// testContract.marketSellOrdersNoThrow, +// orders, +// takerAssetFillAmount, +// signatures, +// ); +// expect(actualResult).to.deep.eq(expectedResult); +// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); +// }); + +// it('works when all fills revert', async () => { +// const COUNT = 4; +// const orders = _.times(COUNT, () => randomOrder({ salt: ALWAYS_FAILING_SALT })); +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// const takerAssetFillAmount = _.reduce( +// orders, +// (total, o) => o.takerAssetAmount.plus(total), +// constants.ZERO_AMOUNT, +// ); +// const [expectedResult, expectedCalls] = simulateMarketSellOrders( +// orders, +// takerAssetFillAmount, +// signatures, +// ); +// expect(expectedCalls.length).to.eq(0); +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// testContract.marketSellOrdersNoThrow, +// orders, +// takerAssetFillAmount, +// signatures, +// ); +// expect(actualResult).to.deep.eq(expectedResult); +// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); +// }); +// }); + +// describe('marketSellOrdersFillOrKill', () => { +// defineCommonMarketSellOrdersTests(() => testContract.marketSellOrdersNoThrow, simulateMarketSellOrders); + +// it('reverts when filled < `takerAssetFillAmount`', async () => { +// const COUNT = 4; +// const orders = _.times(COUNT, () => randomOrder()); +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// const takerAssetFillAmount = _.reduce( +// orders, +// (total, o) => o.takerAssetAmount.plus(total), +// constants.ZERO_AMOUNT, +// ).plus(1); +// const expectedError = new ExchangeRevertErrors.IncompleteFillError( +// ExchangeRevertErrors.IncompleteFillErrorCode.IncompleteMarketSellOrders, +// takerAssetFillAmount, +// takerAssetFillAmount.minus(1), +// ); +// const tx = transactionHelper.getResultAndReceiptAsync( +// testContract.marketSellOrdersFillOrKill, +// orders, +// takerAssetFillAmount, +// signatures, +// ); +// return expect(tx).to.revertWith(expectedError); +// }); + +// it('works when fills fail but can still sell `takerAssetFillAmount`', async () => { +// const COUNT = 4; +// const BAD_ORDERS_COUNT = 2; +// const orders = _.times(COUNT, () => randomOrder()); +// const badOrders = _.sampleSize(orders, BAD_ORDERS_COUNT); +// for (const order of badOrders) { +// order.salt = ALWAYS_FAILING_SALT; +// } +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// const takerAssetFillAmount = _.reduce( +// orders, +// (total, o) => o.takerAssetAmount.plus(total), +// constants.ZERO_AMOUNT, +// ).minus(_.reduce(badOrders, (total, o) => o.takerAssetAmount.plus(total), constants.ZERO_AMOUNT)); +// const [expectedResult, expectedCalls] = simulateMarketSellOrders( +// orders, +// takerAssetFillAmount, +// signatures, +// ); +// expect(expectedCalls.length).to.eq(COUNT - BAD_ORDERS_COUNT); +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// testContract.marketSellOrdersFillOrKill, +// orders, +// takerAssetFillAmount, +// signatures, +// ); +// expect(actualResult).to.deep.eq(expectedResult); +// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); +// }); + +// it('reverts when a failed fill results in selling less than `takerAssetFillAmount`', async () => { +// const COUNT = 4; +// const BAD_ORDERS_COUNT = 2; +// const orders = _.times(COUNT, () => randomOrder()); +// const badOrders = _.sampleSize(orders, BAD_ORDERS_COUNT); +// for (const order of badOrders) { +// order.salt = ALWAYS_FAILING_SALT; +// } +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// const badOrdersAmount = _.reduce( +// badOrders, +// (total, o) => o.takerAssetAmount.plus(total), +// constants.ZERO_AMOUNT, +// ); +// const takerAssetFillAmount = _.reduce( +// orders, +// (total, o) => o.takerAssetAmount.plus(total), +// constants.ZERO_AMOUNT, +// ) +// .minus(badOrdersAmount) +// .plus(1); +// const expectedError = new ExchangeRevertErrors.IncompleteFillError( +// ExchangeRevertErrors.IncompleteFillErrorCode.IncompleteMarketSellOrders, +// takerAssetFillAmount, +// takerAssetFillAmount.minus(1), +// ); +// const tx = transactionHelper.getResultAndReceiptAsync( +// testContract.marketSellOrdersFillOrKill, +// orders, +// takerAssetFillAmount, +// signatures, +// ); +// return expect(tx).to.revertWith(expectedError); +// }); +// }); +// }); + +// describe('marketBuy*', () => { +// function defineCommonMarketBuyOrdersTests( +// getContractFn: () => MarketSellBuyContractFunction, +// simulator: MarketSellBuySimulator, +// ): void { +// it('works with one order', async () => { +// const COUNT = 1; +// const orders = _.times(COUNT, () => randomOrder()); +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// const makerAssetFillAmount = _.reduce( +// orders, +// (total, o) => o.makerAssetAmount.plus(total), +// constants.ZERO_AMOUNT, +// ); +// const [expectedResult, expectedCalls] = simulator(orders, makerAssetFillAmount, signatures); +// expect(expectedCalls.length).to.eq(COUNT); +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// getContractFn, +// orders, +// makerAssetFillAmount, +// signatures, +// ); +// expect(actualResult).to.deep.eq(expectedResult); +// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); +// }); + +// it('works with many orders', async () => { +// const COUNT = 8; +// const orders = _.times(COUNT, () => randomOrder()); +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// const makerAssetFillAmount = _.reduce( +// orders, +// (total, o) => o.makerAssetAmount.plus(total), +// constants.ZERO_AMOUNT, +// ); +// const [expectedResult, expectedCalls] = simulator(orders, makerAssetFillAmount, signatures); +// expect(expectedCalls.length).to.eq(COUNT); +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// getContractFn, +// orders, +// makerAssetFillAmount, +// signatures, +// ); +// expect(actualResult).to.deep.eq(expectedResult); +// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); +// }); + +// it('works with duplicate orders', async () => { +// const NUM_UNIQUE_ORDERS = 2; +// const COUNT = 4; +// const uniqueOrders = _.times(NUM_UNIQUE_ORDERS, () => randomOrder()); +// const orders = _.shuffle(_.flatten(_.times(COUNT / NUM_UNIQUE_ORDERS, () => uniqueOrders))); +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// const makerAssetFillAmount = _.reduce( +// orders, +// (total, o) => o.makerAssetAmount.plus(total), +// constants.ZERO_AMOUNT, +// ); +// const [expectedResult, expectedCalls] = simulator(orders, makerAssetFillAmount, signatures); +// expect(expectedCalls.length).to.eq(COUNT); +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// getContractFn(), +// orders, +// makerAssetFillAmount, +// signatures, +// ); +// expect(actualResult).to.deep.eq(expectedResult); +// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); +// }); + +// it('stops when filled == `makerAssetFillAmount`', async () => { +// const COUNT = 4; +// const orders = _.times(COUNT, () => randomOrder()); +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// // Skip the last order in our `makerAssetFillAmount` calculation. +// const makerAssetFillAmount = _.reduce( +// orders.slice(0, COUNT - 1), +// (total, o) => o.makerAssetAmount.plus(total), +// constants.ZERO_AMOUNT, +// ); +// const [expectedResult, expectedCalls] = simulator(orders, makerAssetFillAmount, signatures); +// // It should stop filling after the penultimate order. +// expect(expectedCalls.length).to.eq(COUNT - 1); +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// getContractFn(), +// orders, +// makerAssetFillAmount, +// signatures, +// ); +// expect(actualResult).to.deep.eq(expectedResult); +// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); +// }); + +// it('stops when filled > `makerAssetFillAmount`', async () => { +// const COUNT = 4; +// const orders = _.times(COUNT, () => randomOrder()); +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// const makerAssetFillAmount = _.reduce( +// orders, +// (total, o) => o.makerAssetAmount.plus(total), +// constants.ZERO_AMOUNT, +// ); +// // Because `TestWrapperFunctions` always fills `makerAssetAmount` +// // setting the first order's `makerAssetAmount` to larger than +// // `makerAssetFillAmount` will cause an overfill. +// orders[0].makerAssetAmount = makerAssetFillAmount.plus(1); +// const [expectedResult, expectedCalls] = simulator(orders, makerAssetFillAmount, signatures); +// // It should stop filling after first order. +// expect(expectedCalls.length).to.eq(1); +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// getContractFn(), +// orders, +// makerAssetFillAmount, +// signatures, +// ); +// expect(actualResult).to.deep.eq(expectedResult); +// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); +// }); + +// it('reverts when an overflow occurs when computing `remainingTakerAssetFillAmount`', async () => { +// const orders = [randomOrder({ takerAssetAmount: MAX_UINT256 })]; +// const signatures = _.times(orders.length, i => createOrderSignature(orders[i])); +// const makerAssetFillAmount = new BigNumber(2); +// const expectedError = new SafeMathRevertErrors.Uint256BinOpError( +// SafeMathRevertErrors.BinOpErrorCodes.MultiplicationOverflow, +// orders[0].takerAssetAmount, +// makerAssetFillAmount, +// ); +// const tx = transactionHelper.getResultAndReceiptAsync(getContractFn(), orders, makerAssetFillAmount, signatures); +// return expect(tx).to.revertWith(expectedError); +// }); + +// it("reverts when an order's `makerAssetAmount` is zero", async () => { +// const orders = [randomOrder({ makerAssetAmount: constants.ZERO_AMOUNT })]; +// const signatures = _.times(orders.length, i => createOrderSignature(orders[i])); +// const makerAssetFillAmount = ONE_ETHER; +// const expectedError = new SafeMathRevertErrors.Uint256BinOpError( +// SafeMathRevertErrors.BinOpErrorCodes.DivisionByZero, +// orders[0].takerAssetAmount.times(makerAssetFillAmount), +// orders[0].makerAssetAmount, +// ); +// const tx = transactionHelper.getResultAndReceiptAsync(getContractFn(), orders, makerAssetFillAmount, signatures); +// return expect(tx).to.revertWith(expectedError); +// }); + +// it('reverts when an overflow occurs when summing fill results', async () => { +// const orders = [ +// randomOrder({ +// takerAssetAmount: new BigNumber(1), +// makerAssetAmount: new BigNumber(1), +// }), +// randomOrder({ +// takerAssetAmount: new BigNumber(1), +// makerAssetAmount: MAX_UINT256, +// }), +// ]; +// const signatures = _.times(orders.length, i => createOrderSignature(orders[i])); +// const makerAssetFillAmount = new BigNumber(2); +// const expectedError = new SafeMathRevertErrors.Uint256BinOpError( +// SafeMathRevertErrors.BinOpErrorCodes.AdditionOverflow, +// orders[0].makerAssetAmount, +// orders[1].makerAssetAmount, +// ); +// const tx = transactionHelper.getResultAndReceiptAsync(getContractFn(), orders, makerAssetFillAmount, signatures); +// return expect(tx).to.revertWith(expectedError); +// }); + +// it('returns empty fill results with no orders', async () => { +// const [expectedResult, expectedCalls] = simulator([], constants.ZERO_AMOUNT, []); +// expect(expectedCalls.length).to.eq(0); +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// getContractFn(), +// [], +// constants.ZERO_AMOUNT, +// [], +// ); + +// expect(actualResult).to.deep.eq(expectedResult); +// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); +// }); +// } + +// function simulateMarketBuyOrdersNoThrow( +// orders: Order[], +// makerAssetFillAmount: BigNumber, +// signatures: string[], +// ): [FillResults, ExpectedFillOrderCallArgs[]] { +// const fillOrderCalls = []; +// let fillResults = _.cloneDeep(EMPTY_FILL_RESULTS); +// for (const [order, signature] of _.zip(orders, signatures) as [[Order, string]]) { +// const remainingMakerAssetFillAmount = safeSub(makerAssetFillAmount, fillResults.makerAssetFilledAmount); +// const remainingTakerAssetFillAmount = getPartialAmountFloor( +// order.takerAssetAmount, +// order.makerAssetAmount, +// remainingMakerAssetFillAmount, +// ); +// if (order.salt !== ALWAYS_FAILING_SALT) { +// fillOrderCalls.push([order, remainingTakerAssetFillAmount, signature]); +// } +// fillResults = addFillResults(fillResults, getExpectedFillResults(order, signature)); +// if (fillResults.makerAssetFilledAmount.gte(makerAssetFillAmount)) { +// break; +// } +// } +// return [fillResults, fillOrderCalls as any]; +// } + +// describe('marketBuyOrdersNoThrow', () => { +// defineCommonMarketBuyOrdersTests(() => testContract.marketBuyOrdersNoThrow, simulateMarketBuyOrdersNoThrow); + +// it('works when any fills revert', async () => { +// const COUNT = 4; +// const BAD_ORDERS_COUNT = 2; +// const orders = _.times(COUNT, () => randomOrder()); +// const badOrders = _.sampleSize(orders, BAD_ORDERS_COUNT); +// for (const order of badOrders) { +// order.salt = ALWAYS_FAILING_SALT; +// } +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// const makerAssetFillAmount = _.reduce( +// orders, +// (total, o) => o.makerAssetAmount.plus(total), +// constants.ZERO_AMOUNT, +// ); +// const [expectedResult, expectedCalls] = simulateMarketBuyOrdersNoThrow( +// orders, +// makerAssetFillAmount, +// signatures, +// ); +// expect(expectedCalls.length).to.eq(COUNT - BAD_ORDERS_COUNT); +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// testContract.marketBuyOrdersNoThrow, +// orders, +// makerAssetFillAmount, +// signatures, +// ); +// expect(actualResult).to.deep.eq(expectedResult); +// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); +// }); + +// it('works when all fills revert', async () => { +// const COUNT = 4; +// const orders = _.times(COUNT, () => randomOrder({ salt: ALWAYS_FAILING_SALT })); +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// const makerAssetFillAmount = _.reduce( +// orders, +// (total, o) => o.makerAssetAmount.plus(total), +// constants.ZERO_AMOUNT, +// ); +// const [expectedResult, expectedCalls] = simulateMarketBuyOrdersNoThrow( +// orders, +// makerAssetFillAmount, +// signatures, +// ); +// expect(expectedCalls.length).to.eq(0); +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// testContract.marketBuyOrdersNoThrow, +// orders, +// makerAssetFillAmount, +// signatures, +// ); +// expect(actualResult).to.deep.eq(expectedResult); +// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); +// }); +// }); + +// describe('marketBuyOrdersFillOrKill', () => { +// defineCommonMarketBuyOrdersTests( +// () => testContract.marketBuyOrdersFillOrKill, +// simulateMarketBuyOrdersNoThrow, +// ); + +// it('reverts when filled < `makerAssetFillAmount`', async () => { +// const COUNT = 4; +// const orders = _.times(COUNT, () => randomOrder()); +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// const makerAssetFillAmount = _.reduce( +// orders, +// (total, o) => o.makerAssetAmount.plus(total), +// constants.ZERO_AMOUNT, +// ).plus(1); +// const expectedError = new ExchangeRevertErrors.IncompleteFillError( +// ExchangeRevertErrors.IncompleteFillErrorCode.IncompleteMarketBuyOrders, +// makerAssetFillAmount, +// makerAssetFillAmount.minus(1), +// ); +// const tx = transactionHelper.getResultAndReceiptAsync( +// testContract.marketBuyOrdersFillOrKill, +// orders, +// makerAssetFillAmount, +// signatures, +// ); +// return expect(tx).to.revertWith(expectedError); +// }); + +// it('works when fills fail but can still buy `makerAssetFillAmount`', async () => { +// const COUNT = 4; +// const BAD_ORDERS_COUNT = 2; +// const orders = _.times(COUNT, () => randomOrder()); +// const badOrders = _.sampleSize(orders, BAD_ORDERS_COUNT); +// for (const order of badOrders) { +// order.salt = ALWAYS_FAILING_SALT; +// } +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// const makerAssetFillAmount = _.reduce( +// orders, +// (total, o) => o.makerAssetAmount.plus(total), +// constants.ZERO_AMOUNT, +// ).minus(_.reduce(badOrders, (total, o) => o.makerAssetAmount.plus(total), constants.ZERO_AMOUNT)); +// const [expectedResult, expectedCalls] = simulateMarketBuyOrdersNoThrow( +// orders, +// makerAssetFillAmount, +// signatures, +// ); +// expect(expectedCalls.length).to.eq(COUNT - BAD_ORDERS_COUNT); +// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( +// testContract.marketBuyOrdersFillOrKill, +// orders, +// makerAssetFillAmount, +// signatures, +// ); +// expect(actualResult).to.deep.eq(expectedResult); +// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); +// }); + +// it('reverts when a failed fill results in buying less than `makerAssetFillAmount`', async () => { +// const COUNT = 4; +// const BAD_ORDERS_COUNT = 2; +// const orders = _.times(COUNT, () => randomOrder()); +// const badOrders = _.sampleSize(orders, BAD_ORDERS_COUNT); +// for (const order of badOrders) { +// order.salt = ALWAYS_FAILING_SALT; +// } +// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); +// const badOrdersAmount = _.reduce( +// badOrders, +// (total, o) => o.makerAssetAmount.plus(total), +// constants.ZERO_AMOUNT, +// ); +// const makerAssetFillAmount = _.reduce( +// orders, +// (total, o) => o.makerAssetAmount.plus(total), +// constants.ZERO_AMOUNT, +// ) +// .minus(badOrdersAmount) +// .plus(1); +// const expectedError = new ExchangeRevertErrors.IncompleteFillError( +// ExchangeRevertErrors.IncompleteFillErrorCode.IncompleteMarketBuyOrders, +// makerAssetFillAmount, +// makerAssetFillAmount.minus(1), +// ); +// const tx = transactionHelper.getResultAndReceiptAsync( +// testContract.marketBuyOrdersFillOrKill, +// orders, +// makerAssetFillAmount, +// signatures, +// ); +// return expect(tx).to.revertWith(expectedError); +// }); +// }); +// }); + +// describe('batchCancelOrders', () => { +// // Asserts that `_cancelOrder()` was called in the same order and with the same +// // arguments as given by examining receipt logs. +// function assertCancelOrderCallsFromLogs(logs: LogEntry[], calls: Order[]): void { +// expect(logs.length).to.eq(calls.length); +// for (const i of _.times(calls.length)) { +// const log = (logs[i] as any) as LogWithDecodedArgs; +// const expectedOrder = calls[i]; +// expect(log.event).to.eq('CancelOrderCalled'); +// assertSameOrderFromEvent(log.args.order as any, expectedOrder); +// } +// } + +// it('works with no orders', async () => { +// const [, receipt] = await transactionHelper.getResultAndReceiptAsync(testContract.batchCancelOrders, []); +// assertCancelOrderCallsFromLogs(receipt.logs, []); +// }); + +// it('works with many orders', async () => { +// const COUNT = 8; +// const orders = _.times(COUNT, () => randomOrder({ makerAddress: senderAddress })); +// const [, receipt] = await transactionHelper.getResultAndReceiptAsync(testContract.batchCancelOrders, orders); +// assertCancelOrderCallsFromLogs(receipt.logs, orders); +// }); + +// it('works with duplicate orders', async () => { +// const UNIQUE_ORDERS = 2; +// const COUNT = 6; +// const uniqueOrders = _.times(UNIQUE_ORDERS, () => randomOrder({ makerAddress: senderAddress })); +// const orders = _.shuffle(_.flatten(_.times(COUNT / UNIQUE_ORDERS, () => uniqueOrders))); +// const [, receipt] = await transactionHelper.getResultAndReceiptAsync(testContract.batchCancelOrders, orders); +// assertCancelOrderCallsFromLogs(receipt.logs, orders); +// }); + +// it('reverts if one `_cancelOrder()` reverts', async () => { +// const COUNT = 8; +// const FAILING_ORDER_INDEX = 4; +// const orders = _.times(COUNT, () => randomOrder({ makerAddress: senderAddress })); +// const failingOrder = orders[FAILING_ORDER_INDEX]; +// failingOrder.salt = ALWAYS_FAILING_SALT; +// const expectedError = ALWAYS_FAILING_SALT_REVERT_ERROR; +// const tx = transactionHelper.getResultAndReceiptAsync(testContract.batchCancelOrders, orders); +// return expect(tx).to.revertWith(expectedError); +// }); +// }); +// }); +// // tslint:disable-next-line: max-file-line-count diff --git a/contracts/extensions/test/balance_threshold_filter.ts b/contracts/extensions/test/balance_threshold_filter.ts index 7fe4ee5566..e1549c4707 100644 --- a/contracts/extensions/test/balance_threshold_filter.ts +++ b/contracts/extensions/test/balance_threshold_filter.ts @@ -126,7 +126,7 @@ describe(ContractName.BalanceThresholdFilter, () => { ); defaultMakerAssetAddress = erc20TokenA.address; defaultTakerAssetAddress = erc20TokenB.address; - zrxAssetData = await devUtils.encodeERC20AssetData.callAsync(zrxToken.address); + zrxAssetData = await devUtils.encodeERC20AssetData(zrxToken.address).callAsync(); // Create proxies const erc20Proxy = await erc20Wrapper.deployProxyAsync(); await erc20Wrapper.setBalancesAndAllowancesAsync(); @@ -142,7 +142,7 @@ describe(ContractName.BalanceThresholdFilter, () => { exchangeWrapper = new ExchangeWrapper(exchangeInstance); // Register proxies await exchangeWrapper.registerAssetProxyAsync(erc20Proxy.address, owner); - await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(exchangeInstance.address, { + await erc20Proxy.addAuthorizedAddress(exchangeInstance.address).sendTransactionAsync({ from: owner, }); // Deploy Balance Threshold Filters @@ -173,8 +173,8 @@ describe(ContractName.BalanceThresholdFilter, () => { // Default order parameters defaultOrderParams = { feeRecipientAddress, - makerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultMakerAssetAddress), - takerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultTakerAssetAddress), + makerAssetData: await devUtils.encodeERC20AssetData(defaultMakerAssetAddress).callAsync(), + takerAssetData: await devUtils.encodeERC20AssetData(defaultTakerAssetAddress).callAsync(), makerAssetAmount, takerAssetAmount, makerFee: Web3Wrapper.toBaseUnitAmount(new BigNumber(100), DECIMALS_DEFAULT), @@ -296,12 +296,9 @@ describe(ContractName.BalanceThresholdFilter, () => { const badSelectorHex = '0x00000000'; const signatureHex = '0x'; // Call valid forwarder - const tx = erc721BalanceThresholdFilterInstance.executeTransaction.sendTransactionAsync( - salt, - validTakerAddress, - badSelectorHex, - signatureHex, - ); + const tx = erc721BalanceThresholdFilterInstance + .executeTransaction(salt, validTakerAddress, badSelectorHex, signatureHex) + .sendTransactionAsync(); return expect(tx).to.revertWith(RevertReason.InvalidOrBlockedExchangeSelector); }); it('should revert if senderAddress is not set to the valid forwarding contract', async () => { @@ -1239,8 +1236,8 @@ describe(ContractName.BalanceThresholdFilter, () => { feeRecipientAddress, }); const signedOrderRight = await orderFactory2.newSignedOrderAsync({ - makerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultTakerAssetAddress), - takerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultMakerAssetAddress), + makerAssetData: await devUtils.encodeERC20AssetData(defaultTakerAssetAddress).callAsync(), + takerAssetData: await devUtils.encodeERC20AssetData(defaultMakerAssetAddress).callAsync(), makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(75), 0), takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(13), 0), makerFee: Web3Wrapper.toBaseUnitAmount(new BigNumber(1), 18), diff --git a/contracts/extensions/test/dutch_auction.ts b/contracts/extensions/test/dutch_auction.ts index c7cfab18ab..83df0c61c3 100644 --- a/contracts/extensions/test/dutch_auction.ts +++ b/contracts/extensions/test/dutch_auction.ts @@ -89,7 +89,7 @@ describe(ContractName.DutchAuction, () => { wethContract = await WETH9Contract.deployFrom0xArtifactAsync(artifacts.WETH9, provider, txDefaults, artifacts); erc20Wrapper.addDummyTokenContract(wethContract as any); - const zrxAssetData = await devUtils.encodeERC20AssetData.callAsync(zrxToken.address); + const zrxAssetData = await devUtils.encodeERC20AssetData(zrxToken.address).callAsync(); const exchangeInstance = await ExchangeContract.deployFrom0xArtifactAsync( artifacts.Exchange, provider, @@ -102,10 +102,10 @@ describe(ContractName.DutchAuction, () => { await exchangeWrapper.registerAssetProxyAsync(erc20Proxy.address, owner); await exchangeWrapper.registerAssetProxyAsync(erc721Proxy.address, owner); - await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(exchangeInstance.address, { + await erc20Proxy.addAuthorizedAddress(exchangeInstance.address).sendTransactionAsync({ from: owner, }); - await erc721Proxy.addAuthorizedAddress.sendTransactionAsync(exchangeInstance.address, { + await erc721Proxy.addAuthorizedAddress(exchangeInstance.address).sendTransactionAsync({ from: owner, }); @@ -130,11 +130,9 @@ describe(ContractName.DutchAuction, () => { }), ); await web3Wrapper.awaitTransactionSuccessAsync( - await wethContract.approve.sendTransactionAsync( - erc20Proxy.address, - constants.UNLIMITED_ALLOWANCE_IN_BASE_UNITS, - { from: takerAddress }, - ), + await wethContract + .approve(erc20Proxy.address, constants.UNLIMITED_ALLOWANCE_IN_BASE_UNITS) + .sendTransactionAsync({ from: takerAddress }), ); web3Wrapper.abiDecoder.addABI(exchangeInstance.abi); web3Wrapper.abiDecoder.addABI(zrxToken.abi); @@ -156,11 +154,11 @@ describe(ContractName.DutchAuction, () => { // taker address or sender address should be set to the ducth auction contract takerAddress: dutchAuctionContract.address, makerAssetData: assetDataUtils.encodeDutchAuctionAssetData( - await devUtils.encodeERC20AssetData.callAsync(defaultMakerAssetAddress), + await devUtils.encodeERC20AssetData(defaultMakerAssetAddress).callAsync(), auctionBeginTimeSeconds, auctionBeginAmount, ), - takerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultTakerAssetAddress), + takerAssetData: await devUtils.encodeERC20AssetData(defaultTakerAssetAddress).callAsync(), makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(200), DECIMALS_DEFAULT), takerAssetAmount: auctionEndAmount, expirationTimeSeconds: auctionEndTimeSeconds, @@ -182,7 +180,7 @@ describe(ContractName.DutchAuction, () => { const takerPrivateKey = constants.TESTRPC_PRIVATE_KEYS[accounts.indexOf(takerAddress)]; sellerOrderFactory = new OrderFactory(makerPrivateKey, sellerDefaultOrderParams); buyerOrderFactory = new OrderFactory(takerPrivateKey, buyerDefaultOrderParams); - defaultERC20MakerAssetData = await devUtils.encodeERC20AssetData.callAsync(defaultMakerAssetAddress); + defaultERC20MakerAssetData = await devUtils.encodeERC20AssetData(defaultMakerAssetAddress).callAsync(); }); after(async () => { await blockchainLifecycle.revertAsync(); @@ -321,7 +319,7 @@ describe(ContractName.DutchAuction, () => { }); it('asset data contains auction parameters', async () => { sellOrder = await sellerOrderFactory.newSignedOrderAsync({ - makerAssetData: await devUtils.encodeERC20AssetData.callAsync(defaultMakerAssetAddress), + makerAssetData: await devUtils.encodeERC20AssetData(defaultMakerAssetAddress).callAsync(), }); const tx = dutchAuctionTestWrapper.matchOrdersAsync(buyOrder, sellOrder, takerAddress); return expect(tx).to.revertWith(RevertReason.InvalidAssetData); @@ -330,10 +328,9 @@ describe(ContractName.DutchAuction, () => { describe('ERC721', () => { it('should match orders when ERC721', async () => { const makerAssetId = erc721MakerAssetIds[0]; - const erc721MakerAssetData = await devUtils.encodeERC721AssetData.callAsync( - erc721Token.address, - makerAssetId, - ); + const erc721MakerAssetData = await devUtils + .encodeERC721AssetData(erc721Token.address, makerAssetId) + .callAsync(); const makerAssetData = assetDataUtils.encodeDutchAuctionAssetData( erc721MakerAssetData, auctionBeginTimeSeconds, @@ -356,7 +353,7 @@ describe(ContractName.DutchAuction, () => { expect(newBalances[makerAddress][wethContract.address]).to.be.bignumber.gte( erc20Balances[makerAddress][wethContract.address].plus(afterAuctionDetails.currentAmount), ); - const newOwner = await erc721Token.ownerOf.callAsync(makerAssetId); + const newOwner = await erc721Token.ownerOf(makerAssetId).callAsync(); expect(newOwner).to.be.bignumber.equal(takerAddress); }); }); diff --git a/contracts/extensions/test/order_matcher.ts b/contracts/extensions/test/order_matcher.ts index bd85592601..079ae9b937 100644 --- a/contracts/extensions/test/order_matcher.ts +++ b/contracts/extensions/test/order_matcher.ts @@ -114,7 +114,7 @@ describe('OrderMatcher', () => { provider, txDefaults, artifacts, - await devUtils.encodeERC20AssetData.callAsync(zrxToken.address), + await devUtils.encodeERC20AssetData(zrxToken.address).callAsync(), new BigNumber(chainId), ); exchangeWrapper = new ExchangeWrapper(exchange); @@ -122,7 +122,7 @@ describe('OrderMatcher', () => { await exchangeWrapper.registerAssetProxyAsync(erc721Proxy.address, owner); // Authorize ERC20 trades by exchange await web3Wrapper.awaitTransactionSuccessAsync( - await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, { + await erc20Proxy.addAuthorizedAddress(exchange.address).sendTransactionAsync({ from: owner, }), constants.AWAIT_TRANSACTION_MINED_MS, @@ -138,35 +138,33 @@ describe('OrderMatcher', () => { // Set default addresses defaultERC20MakerAssetAddress = erc20TokenA.address; defaultERC20TakerAssetAddress = erc20TokenB.address; - leftMakerAssetData = await devUtils.encodeERC20AssetData.callAsync(defaultERC20MakerAssetAddress); - leftTakerAssetData = await devUtils.encodeERC20AssetData.callAsync(defaultERC20TakerAssetAddress); + leftMakerAssetData = await devUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress).callAsync(); + leftTakerAssetData = await devUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress).callAsync(); // Set OrderMatcher balances and allowances await web3Wrapper.awaitTransactionSuccessAsync( - await erc20TokenA.setBalance.sendTransactionAsync(orderMatcher.address, constants.INITIAL_ERC20_BALANCE, { + await erc20TokenA.setBalance(orderMatcher.address, constants.INITIAL_ERC20_BALANCE).sendTransactionAsync({ from: owner, }), constants.AWAIT_TRANSACTION_MINED_MS, ); await web3Wrapper.awaitTransactionSuccessAsync( - await erc20TokenB.setBalance.sendTransactionAsync(orderMatcher.address, constants.INITIAL_ERC20_BALANCE, { + await erc20TokenB.setBalance(orderMatcher.address, constants.INITIAL_ERC20_BALANCE).sendTransactionAsync({ from: owner, }), constants.AWAIT_TRANSACTION_MINED_MS, ); - await web3Wrapper.awaitTransactionSuccessAsync( - await orderMatcher.approveAssetProxy.sendTransactionAsync( - leftMakerAssetData, - constants.INITIAL_ERC20_ALLOWANCE, - ), - constants.AWAIT_TRANSACTION_MINED_MS, - ); - await web3Wrapper.awaitTransactionSuccessAsync( - await orderMatcher.approveAssetProxy.sendTransactionAsync( - leftTakerAssetData, - constants.INITIAL_ERC20_ALLOWANCE, - ), - constants.AWAIT_TRANSACTION_MINED_MS, - ); + await web3Wrapper + .awaitTransactionSuccessAsync( + await orderMatcher.approveAssetProxy(leftMakerAssetData, constants.INITIAL_ERC20_ALLOWANCE), + constants.AWAIT_TRANSACTION_MINED_MS, + ) + .sendTransactionAsync(); + await web3Wrapper + .awaitTransactionSuccessAsync( + await orderMatcher.approveAssetProxy(leftTakerAssetData, constants.INITIAL_ERC20_ALLOWANCE), + constants.AWAIT_TRANSACTION_MINED_MS, + ) + .sendTransactionAsync(); // Create default order parameters const defaultOrderParamsLeft = { @@ -238,12 +236,9 @@ describe('OrderMatcher', () => { makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(10), 18), takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(2), 18), }); - const data = exchange.matchOrders.getABIEncodedTransactionData( - signedOrderLeft, - signedOrderRight, - signedOrderLeft.signature, - signedOrderRight.signature, - ); + const data = exchange + .matchOrders(signedOrderLeft, signedOrderRight, signedOrderLeft.signature, signedOrderRight.signature) + .getABIEncodedTransactionData(); const tx = web3Wrapper.sendTransactionAsync({ data, to: orderMatcher.address, @@ -273,13 +268,10 @@ describe('OrderMatcher', () => { // Taker leftMakerAssetSpreadAmount: signedOrderLeft.makerAssetAmount.minus(signedOrderRight.takerAssetAmount), }; - const initialLeftMakerAssetTakerBalance = await erc20TokenA.balanceOf.callAsync(orderMatcher.address); - const data = exchange.matchOrders.getABIEncodedTransactionData( - signedOrderLeft, - signedOrderRight, - signedOrderLeft.signature, - signedOrderRight.signature, - ); + const initialLeftMakerAssetTakerBalance = await erc20TokenA.balanceOf(orderMatcher.address).callAsync(); + const data = exchange + .matchOrders(signedOrderLeft, signedOrderRight, signedOrderLeft.signature, signedOrderRight.signature) + .getABIEncodedTransactionData(); await web3Wrapper.awaitTransactionSuccessAsync( await web3Wrapper.sendTransactionAsync({ data, @@ -289,7 +281,7 @@ describe('OrderMatcher', () => { }), constants.AWAIT_TRANSACTION_MINED_MS, ); - const newLeftMakerAssetTakerBalance = await erc20TokenA.balanceOf.callAsync(orderMatcher.address); + const newLeftMakerAssetTakerBalance = await erc20TokenA.balanceOf(orderMatcher.address).callAsync(); const newErc20Balances = await erc20Wrapper.getBalancesAsync(); expect(newErc20Balances[makerAddressLeft][defaultERC20MakerAssetAddress]).to.be.bignumber.equal( erc20BalancesByOwner[makerAddressLeft][defaultERC20MakerAssetAddress].minus( @@ -334,13 +326,10 @@ describe('OrderMatcher', () => { amountSoldByRightMaker: signedOrderRight.makerAssetAmount, amountBoughtByRightMaker: signedOrderRight.takerAssetAmount, }; - const initialLeftMakerAssetTakerBalance = await erc20TokenA.balanceOf.callAsync(orderMatcher.address); - const data = exchange.matchOrders.getABIEncodedTransactionData( - signedOrderLeft, - signedOrderRight, - signedOrderLeft.signature, - signedOrderRight.signature, - ); + const initialLeftMakerAssetTakerBalance = await erc20TokenA.balanceOf(orderMatcher.address).callAsync(); + const data = exchange + .matchOrders(signedOrderLeft, signedOrderRight, signedOrderLeft.signature, signedOrderRight.signature) + .getABIEncodedTransactionData(); await web3Wrapper.awaitTransactionSuccessAsync( await web3Wrapper.sendTransactionAsync({ data, @@ -350,7 +339,7 @@ describe('OrderMatcher', () => { }), constants.AWAIT_TRANSACTION_MINED_MS, ); - const newLeftMakerAssetTakerBalance = await erc20TokenA.balanceOf.callAsync(orderMatcher.address); + const newLeftMakerAssetTakerBalance = await erc20TokenA.balanceOf(orderMatcher.address).callAsync(); const newErc20Balances = await erc20Wrapper.getBalancesAsync(); expect(newErc20Balances[makerAddressLeft][defaultERC20MakerAssetAddress]).to.be.bignumber.equal( erc20BalancesByOwner[makerAddressLeft][defaultERC20MakerAssetAddress].minus( @@ -396,15 +385,12 @@ describe('OrderMatcher', () => { leftMakerAssetSpreadAmount: signedOrderLeft.makerAssetAmount.minus(signedOrderRight.takerAssetAmount), leftTakerAssetSpreadAmount: signedOrderRight.makerAssetAmount.minus(signedOrderLeft.takerAssetAmount), }; - const initialLeftMakerAssetTakerBalance = await erc20TokenA.balanceOf.callAsync(orderMatcher.address); - const initialLeftTakerAssetTakerBalance = await erc20TokenB.balanceOf.callAsync(orderMatcher.address); + const initialLeftMakerAssetTakerBalance = await erc20TokenA.balanceOf(orderMatcher.address).callAsync(); + const initialLeftTakerAssetTakerBalance = await erc20TokenB.balanceOf(orderMatcher.address).callAsync(); // Match signedOrderLeft with signedOrderRight - const data = exchange.matchOrders.getABIEncodedTransactionData( - signedOrderLeft, - signedOrderRight, - signedOrderLeft.signature, - signedOrderRight.signature, - ); + const data = exchange + .matchOrders(signedOrderLeft, signedOrderRight, signedOrderLeft.signature, signedOrderRight.signature) + .getABIEncodedTransactionData(); await web3Wrapper.awaitTransactionSuccessAsync( await web3Wrapper.sendTransactionAsync({ data, @@ -414,8 +400,8 @@ describe('OrderMatcher', () => { }), constants.AWAIT_TRANSACTION_MINED_MS, ); - const newLeftMakerAssetTakerBalance = await erc20TokenA.balanceOf.callAsync(orderMatcher.address); - const newLeftTakerAssetTakerBalance = await erc20TokenB.balanceOf.callAsync(orderMatcher.address); + const newLeftMakerAssetTakerBalance = await erc20TokenA.balanceOf(orderMatcher.address).callAsync(); + const newLeftTakerAssetTakerBalance = await erc20TokenB.balanceOf(orderMatcher.address).callAsync(); const newErc20Balances = await erc20Wrapper.getBalancesAsync(); expect(newErc20Balances[makerAddressLeft][defaultERC20MakerAssetAddress]).to.be.bignumber.equal( erc20BalancesByOwner[makerAddressLeft][defaultERC20MakerAssetAddress].minus( @@ -454,12 +440,9 @@ describe('OrderMatcher', () => { makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(10), 18), takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(2), 18), }); - const data = exchange.matchOrders.getABIEncodedTransactionData( - signedOrderLeft, - signedOrderRight, - signedOrderLeft.signature, - signedOrderRight.signature, - ); + const data = exchange + .matchOrders(signedOrderLeft, signedOrderRight, signedOrderLeft.signature, signedOrderRight.signature) + .getABIEncodedTransactionData(); const logDecoder = new LogDecoder(web3Wrapper, artifacts); const txReceipt = await logDecoder.getTxWithDecodedLogsAsync( await web3Wrapper.sendTransactionAsync({ @@ -492,12 +475,9 @@ describe('OrderMatcher', () => { await exchangeWrapper.fillOrderAsync(signedOrderRight, takerAddress, { takerAssetFillAmount: signedOrderRight.takerAssetAmount.dividedToIntegerBy(5), }); - const data = exchange.matchOrders.getABIEncodedTransactionData( - signedOrderLeft, - signedOrderRight, - signedOrderLeft.signature, - signedOrderRight.signature, - ); + const data = exchange + .matchOrders(signedOrderLeft, signedOrderRight, signedOrderLeft.signature, signedOrderRight.signature) + .getABIEncodedTransactionData(); const logDecoder = new LogDecoder(web3Wrapper, artifacts); const txReceipt = await logDecoder.getTxWithDecodedLogsAsync( await web3Wrapper.sendTransactionAsync({ @@ -540,15 +520,12 @@ describe('OrderMatcher', () => { leftMakerAssetSpreadAmount: constants.ZERO_AMOUNT, leftTakerAssetSpreadAmount, }; - const initialLeftMakerAssetTakerBalance = await erc20TokenA.balanceOf.callAsync(orderMatcher.address); - const initialLeftTakerAssetTakerBalance = await erc20TokenB.balanceOf.callAsync(orderMatcher.address); + const initialLeftMakerAssetTakerBalance = await erc20TokenA.balanceOf(orderMatcher.address).callAsync(); + const initialLeftTakerAssetTakerBalance = await erc20TokenB.balanceOf(orderMatcher.address).callAsync(); // Match signedOrderLeft with signedOrderRight - const data = exchange.matchOrders.getABIEncodedTransactionData( - signedOrderLeft, - signedOrderRight, - signedOrderLeft.signature, - signedOrderRight.signature, - ); + const data = exchange + .matchOrders(signedOrderLeft, signedOrderRight, signedOrderLeft.signature, signedOrderRight.signature) + .getABIEncodedTransactionData(); await web3Wrapper.awaitTransactionSuccessAsync( await web3Wrapper.sendTransactionAsync({ data, @@ -558,8 +535,8 @@ describe('OrderMatcher', () => { }), constants.AWAIT_TRANSACTION_MINED_MS, ); - const newLeftMakerAssetTakerBalance = await erc20TokenA.balanceOf.callAsync(orderMatcher.address); - const newLeftTakerAssetTakerBalance = await erc20TokenB.balanceOf.callAsync(orderMatcher.address); + const newLeftMakerAssetTakerBalance = await erc20TokenA.balanceOf(orderMatcher.address).callAsync(); + const newLeftTakerAssetTakerBalance = await erc20TokenB.balanceOf(orderMatcher.address).callAsync(); const newErc20Balances = await erc20Wrapper.getBalancesAsync(); expect(newErc20Balances[makerAddressLeft][defaultERC20MakerAssetAddress]).to.be.bignumber.equal( erc20BalancesByOwner[makerAddressLeft][defaultERC20MakerAssetAddress].minus( @@ -610,17 +587,14 @@ describe('OrderMatcher', () => { leftMakerAssetSpreadAmount: signedOrderLeft.makerAssetAmount.minus(signedOrderRight.takerAssetAmount), leftTakerAssetSpreadAmount: signedOrderRight.makerAssetAmount.minus(signedOrderLeft.takerAssetAmount), }; - const initialLeftMakerAssetTakerBalance = await erc20TokenA.balanceOf.callAsync(orderMatcher.address); - const initialLeftTakerAssetTakerBalance = await erc20TokenB.balanceOf.callAsync(orderMatcher.address); + const initialLeftMakerAssetTakerBalance = await erc20TokenA.balanceOf(orderMatcher.address).callAsync(); + const initialLeftTakerAssetTakerBalance = await erc20TokenB.balanceOf(orderMatcher.address).callAsync(); // Match signedOrderLeft with signedOrderRight signedOrderRight.makerAssetData = constants.NULL_BYTES; signedOrderRight.takerAssetData = constants.NULL_BYTES; - const data = exchange.matchOrders.getABIEncodedTransactionData( - signedOrderLeft, - signedOrderRight, - signedOrderLeft.signature, - signedOrderRight.signature, - ); + const data = exchange + .matchOrders(signedOrderLeft, signedOrderRight, signedOrderLeft.signature, signedOrderRight.signature) + .getABIEncodedTransactionData(); await web3Wrapper.awaitTransactionSuccessAsync( await web3Wrapper.sendTransactionAsync({ data, @@ -630,8 +604,8 @@ describe('OrderMatcher', () => { }), constants.AWAIT_TRANSACTION_MINED_MS, ); - const newLeftMakerAssetTakerBalance = await erc20TokenA.balanceOf.callAsync(orderMatcher.address); - const newLeftTakerAssetTakerBalance = await erc20TokenB.balanceOf.callAsync(orderMatcher.address); + const newLeftMakerAssetTakerBalance = await erc20TokenA.balanceOf(orderMatcher.address).callAsync(); + const newLeftTakerAssetTakerBalance = await erc20TokenB.balanceOf(orderMatcher.address).callAsync(); const newErc20Balances = await erc20Wrapper.getBalancesAsync(); expect(newErc20Balances[makerAddressLeft][defaultERC20MakerAssetAddress]).to.be.bignumber.equal( erc20BalancesByOwner[makerAddressLeft][defaultERC20MakerAssetAddress].minus( @@ -671,12 +645,9 @@ describe('OrderMatcher', () => { takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(5), 18), }); signedOrderRight.signature = `0xff${signedOrderRight.signature.slice(4)}`; - const data = exchange.matchOrders.getABIEncodedTransactionData( - signedOrderLeft, - signedOrderRight, - signedOrderLeft.signature, - signedOrderRight.signature, - ); + const data = exchange + .matchOrders(signedOrderLeft, signedOrderRight, signedOrderLeft.signature, signedOrderRight.signature) + .getABIEncodedTransactionData(); const expectedError = new ExchangeRevertErrors.SignatureError(); const tx = web3Wrapper.sendTransactionAsync({ data, @@ -698,17 +669,14 @@ describe('OrderMatcher', () => { }); // Matcher will not have enough allowance to fill rightOrder await web3Wrapper.awaitTransactionSuccessAsync( - await orderMatcher.approveAssetProxy.sendTransactionAsync(leftMakerAssetData, constants.ZERO_AMOUNT, { + await orderMatcher.approveAssetProxy(leftMakerAssetData, constants.ZERO_AMOUNT).sendTransactionAsync({ from: owner, }), constants.AWAIT_TRANSACTION_MINED_MS, ); - const data = exchange.matchOrders.getABIEncodedTransactionData( - signedOrderLeft, - signedOrderRight, - signedOrderLeft.signature, - signedOrderRight.signature, - ); + const data = exchange + .matchOrders(signedOrderLeft, signedOrderRight, signedOrderLeft.signature, signedOrderRight.signature) + .getABIEncodedTransactionData(); const expectedError = new ExchangeRevertErrors.AssetProxyTransferError(); const tx = web3Wrapper.sendTransactionAsync({ data, @@ -721,14 +689,14 @@ describe('OrderMatcher', () => { }); describe('withdrawAsset', () => { it('should allow owner to withdraw ERC20 tokens', async () => { - const erc20AWithdrawAmount = await erc20TokenA.balanceOf.callAsync(orderMatcher.address); + const erc20AWithdrawAmount = await erc20TokenA.balanceOf(orderMatcher.address).callAsync(); expect(erc20AWithdrawAmount).to.be.bignumber.gt(constants.ZERO_AMOUNT); await web3Wrapper.awaitTransactionSuccessAsync( - await orderMatcher.withdrawAsset.sendTransactionAsync(leftMakerAssetData, erc20AWithdrawAmount, { + await orderMatcher.withdrawAsset(leftMakerAssetData, erc20AWithdrawAmount).sendTransactionAsync({ from: owner, }), ); - const newBalance = await erc20TokenA.balanceOf.callAsync(orderMatcher.address); + const newBalance = await erc20TokenA.balanceOf(orderMatcher.address).callAsync(); expect(newBalance).to.be.bignumber.equal(constants.ZERO_AMOUNT); }); it('should allow owner to withdraw ERC721 tokens', async () => { @@ -742,22 +710,22 @@ describe('OrderMatcher', () => { ); const tokenId = new BigNumber(1); await web3Wrapper.awaitTransactionSuccessAsync( - await erc721Token.mint.sendTransactionAsync(orderMatcher.address, tokenId, { from: owner }), + await erc721Token.mint(orderMatcher.address, tokenId).sendTransactionAsync({ from: owner }), constants.AWAIT_TRANSACTION_MINED_MS, ); - const assetData = await devUtils.encodeERC721AssetData.callAsync(erc721Token.address, tokenId); + const assetData = await devUtils.encodeERC721AssetData(erc721Token.address, tokenId).callAsync(); const withdrawAmount = new BigNumber(1); await web3Wrapper.awaitTransactionSuccessAsync( - await orderMatcher.withdrawAsset.sendTransactionAsync(assetData, withdrawAmount, { from: owner }), + await orderMatcher.withdrawAsset(assetData, withdrawAmount).sendTransactionAsync({ from: owner }), constants.AWAIT_TRANSACTION_MINED_MS, ); - const erc721Owner = await erc721Token.ownerOf.callAsync(tokenId); + const erc721Owner = await erc721Token.ownerOf(tokenId).callAsync(); expect(erc721Owner).to.be.equal(owner); }); it('should revert if not called by owner', async () => { - const erc20AWithdrawAmount = await erc20TokenA.balanceOf.callAsync(orderMatcher.address); + const erc20AWithdrawAmount = await erc20TokenA.balanceOf(orderMatcher.address).callAsync(); expect(erc20AWithdrawAmount).to.be.bignumber.gt(constants.ZERO_AMOUNT); - const tx = orderMatcher.withdrawAsset.sendTransactionAsync(leftMakerAssetData, erc20AWithdrawAmount, { + const tx = orderMatcher.withdrawAsset(leftMakerAssetData, erc20AWithdrawAmount).sendTransactionAsync({ from: takerAddress, }); return expect(tx).to.revertWith(RevertReason.OnlyContractOwner); @@ -767,12 +735,12 @@ describe('OrderMatcher', () => { it('should be able to set an allowance for ERC20 tokens', async () => { const allowance = new BigNumber(55465465426546); await web3Wrapper.awaitTransactionSuccessAsync( - await orderMatcher.approveAssetProxy.sendTransactionAsync(leftMakerAssetData, allowance, { + await orderMatcher.approveAssetProxy(leftMakerAssetData, allowance).sendTransactionAsync({ from: owner, }), constants.AWAIT_TRANSACTION_MINED_MS, ); - const newAllowance = await erc20TokenA.allowance.callAsync(orderMatcher.address, erc20Proxy.address); + const newAllowance = await erc20TokenA.allowance(orderMatcher.address, erc20Proxy.address).callAsync(); expect(newAllowance).to.be.bignumber.equal(allowance); }); it('should be able to approve an ERC721 token by passing in allowance = 1', async () => { @@ -784,16 +752,17 @@ describe('OrderMatcher', () => { constants.DUMMY_TOKEN_NAME, constants.DUMMY_TOKEN_SYMBOL, ); - const assetData = await devUtils.encodeERC721AssetData.callAsync( - erc721Token.address, - constants.ZERO_AMOUNT, - ); + const assetData = await devUtils + .encodeERC721AssetData(erc721Token.address, constants.ZERO_AMOUNT) + .callAsync(); const allowance = new BigNumber(1); await web3Wrapper.awaitTransactionSuccessAsync( - await orderMatcher.approveAssetProxy.sendTransactionAsync(assetData, allowance, { from: owner }), + await orderMatcher.approveAssetProxy(assetData, allowance).sendTransactionAsync({ from: owner }), constants.AWAIT_TRANSACTION_MINED_MS, ); - const isApproved = await erc721Token.isApprovedForAll.callAsync(orderMatcher.address, erc721Proxy.address); + const isApproved = await erc721Token + .isApprovedForAll(orderMatcher.address, erc721Proxy.address) + .callAsync(); expect(isApproved).to.be.equal(true); }); it('should be able to approve an ERC721 token by passing in allowance > 1', async () => { @@ -805,21 +774,22 @@ describe('OrderMatcher', () => { constants.DUMMY_TOKEN_NAME, constants.DUMMY_TOKEN_SYMBOL, ); - const assetData = await devUtils.encodeERC721AssetData.callAsync( - erc721Token.address, - constants.ZERO_AMOUNT, - ); + const assetData = await devUtils + .encodeERC721AssetData(erc721Token.address, constants.ZERO_AMOUNT) + .callAsync(); const allowance = new BigNumber(2); await web3Wrapper.awaitTransactionSuccessAsync( - await orderMatcher.approveAssetProxy.sendTransactionAsync(assetData, allowance, { from: owner }), + await orderMatcher.approveAssetProxy(assetData, allowance).sendTransactionAsync({ from: owner }), constants.AWAIT_TRANSACTION_MINED_MS, ); - const isApproved = await erc721Token.isApprovedForAll.callAsync(orderMatcher.address, erc721Proxy.address); + const isApproved = await erc721Token + .isApprovedForAll(orderMatcher.address, erc721Proxy.address) + .callAsync(); expect(isApproved).to.be.equal(true); }); it('should revert if not called by owner', async () => { const approval = new BigNumber(1); - const tx = orderMatcher.approveAssetProxy.sendTransactionAsync(leftMakerAssetData, approval, { + const tx = orderMatcher.approveAssetProxy(leftMakerAssetData, approval).sendTransactionAsync({ from: takerAddress, }); return expect(tx).to.revertWith(RevertReason.OnlyContractOwner); diff --git a/contracts/extensions/test/utils/balance_threshold_wrapper.ts b/contracts/extensions/test/utils/balance_threshold_wrapper.ts index 30d1798aeb..f1983e092b 100644 --- a/contracts/extensions/test/utils/balance_threshold_wrapper.ts +++ b/contracts/extensions/test/utils/balance_threshold_wrapper.ts @@ -39,11 +39,9 @@ export class BalanceThresholdWrapper { opts: { takerAssetFillAmount?: BigNumber } = {}, ): Promise { const params = orderUtils.createFill(signedOrder, opts.takerAssetFillAmount); - const data = this._exchange.fillOrder.getABIEncodedTransactionData( - params.order, - params.takerAssetFillAmount, - params.signature, - ); + const data = this._exchange + .fillOrder(params.order, params.takerAssetFillAmount, params.signature) + .getABIEncodedTransactionData(); const txReceipt = this._executeTransactionAsync(data, from); return txReceipt; } @@ -53,11 +51,9 @@ export class BalanceThresholdWrapper { opts: { takerAssetFillAmount?: BigNumber } = {}, ): Promise { const params = orderUtils.createFill(signedOrder, opts.takerAssetFillAmount); - const data = this._exchange.fillOrKillOrder.getABIEncodedTransactionData( - params.order, - params.takerAssetFillAmount, - params.signature, - ); + const data = this._exchange + .fillOrKillOrder(params.order, params.takerAssetFillAmount, params.signature) + .getABIEncodedTransactionData(); const txReceipt = this._executeTransactionAsync(data, from); return txReceipt; } @@ -67,11 +63,9 @@ export class BalanceThresholdWrapper { opts: { takerAssetFillAmount?: BigNumber; gas?: number } = {}, ): Promise { const params = orderUtils.createFill(signedOrder, opts.takerAssetFillAmount); - const data = this._exchange.fillOrderNoThrow.getABIEncodedTransactionData( - params.order, - params.takerAssetFillAmount, - params.signature, - ); + const data = this._exchange + .fillOrderNoThrow(params.order, params.takerAssetFillAmount, params.signature) + .getABIEncodedTransactionData(); const txReceipt = this._executeTransactionAsync(data, from, opts.gas); return txReceipt; } @@ -81,11 +75,9 @@ export class BalanceThresholdWrapper { opts: { takerAssetFillAmounts?: BigNumber[] } = {}, ): Promise { const params = formatters.createBatchFill(orders, opts.takerAssetFillAmounts); - const data = this._exchange.batchFillOrders.getABIEncodedTransactionData( - params.orders, - params.takerAssetFillAmounts, - params.signatures, - ); + const data = this._exchange + .batchFillOrders(params.orders, params.takerAssetFillAmounts, params.signatures) + .getABIEncodedTransactionData(); const txReceipt = this._executeTransactionAsync(data, from); return txReceipt; } @@ -95,11 +87,9 @@ export class BalanceThresholdWrapper { opts: { takerAssetFillAmounts?: BigNumber[] } = {}, ): Promise { const params = formatters.createBatchFill(orders, opts.takerAssetFillAmounts); - const data = this._exchange.batchFillOrKillOrders.getABIEncodedTransactionData( - params.orders, - params.takerAssetFillAmounts, - params.signatures, - ); + const data = this._exchange + .batchFillOrKillOrders(params.orders, params.takerAssetFillAmounts, params.signatures) + .getABIEncodedTransactionData(); const txReceipt = this._executeTransactionAsync(data, from); return txReceipt; } @@ -109,11 +99,9 @@ export class BalanceThresholdWrapper { opts: { takerAssetFillAmounts?: BigNumber[]; gas?: number } = {}, ): Promise { const params = formatters.createBatchFill(orders, opts.takerAssetFillAmounts); - const data = this._exchange.batchFillOrKillOrders.getABIEncodedTransactionData( - params.orders, - params.takerAssetFillAmounts, - params.signatures, - ); + const data = this._exchange + .batchFillOrKillOrders(params.orders, params.takerAssetFillAmounts, params.signatures) + .getABIEncodedTransactionData(); const txReceipt = this._executeTransactionAsync(data, from, opts.gas); return txReceipt; } @@ -123,11 +111,9 @@ export class BalanceThresholdWrapper { opts: { takerAssetFillAmount: BigNumber }, ): Promise { const params = formatters.createMarketSellOrders(orders, opts.takerAssetFillAmount); - const data = this._exchange.marketSellOrders.getABIEncodedTransactionData( - params.orders, - params.takerAssetFillAmount, - params.signatures, - ); + const data = this._exchange + .marketSellOrders(params.orders, params.takerAssetFillAmount, params.signatures) + .getABIEncodedTransactionData(); const txReceipt = this._executeTransactionAsync(data, from); return txReceipt; } @@ -137,11 +123,9 @@ export class BalanceThresholdWrapper { opts: { takerAssetFillAmount: BigNumber; gas?: number }, ): Promise { const params = formatters.createMarketSellOrders(orders, opts.takerAssetFillAmount); - const data = this._exchange.marketSellOrdersNoThrow.getABIEncodedTransactionData( - params.orders, - params.takerAssetFillAmount, - params.signatures, - ); + const data = this._exchange + .marketSellOrdersNoThrow(params.orders, params.takerAssetFillAmount, params.signatures) + .getABIEncodedTransactionData(); const txReceipt = this._executeTransactionAsync(data, from, opts.gas); return txReceipt; } @@ -151,11 +135,9 @@ export class BalanceThresholdWrapper { opts: { makerAssetFillAmount: BigNumber }, ): Promise { const params = formatters.createMarketBuyOrders(orders, opts.makerAssetFillAmount); - const data = this._exchange.marketBuyOrders.getABIEncodedTransactionData( - params.orders, - params.makerAssetFillAmount, - params.signatures, - ); + const data = this._exchange + .marketBuyOrders(params.orders, params.makerAssetFillAmount, params.signatures) + .getABIEncodedTransactionData(); const txReceipt = this._executeTransactionAsync(data, from); return txReceipt; } @@ -165,17 +147,15 @@ export class BalanceThresholdWrapper { opts: { makerAssetFillAmount: BigNumber; gas?: number }, ): Promise { const params = formatters.createMarketBuyOrders(orders, opts.makerAssetFillAmount); - const data = this._exchange.marketBuyOrdersNoThrow.getABIEncodedTransactionData( - params.orders, - params.makerAssetFillAmount, - params.signatures, - ); + const data = this._exchange + .marketBuyOrdersNoThrow(params.orders, params.makerAssetFillAmount, params.signatures) + .getABIEncodedTransactionData(); const txReceipt = this._executeTransactionAsync(data, from, opts.gas); return txReceipt; } public async cancelOrderAsync(signedOrder: SignedOrder, from: string): Promise { const params = orderUtils.createCancel(signedOrder); - const data = this._exchange.cancelOrder.getABIEncodedTransactionData(params.order); + const data = this._exchange.cancelOrder(params.order).getABIEncodedTransactionData(); const txReceipt = this._executeTransactionAsync(data, from); return txReceipt; } @@ -184,33 +164,33 @@ export class BalanceThresholdWrapper { from: string, ): Promise { const params = formatters.createBatchCancel(orders); - const data = this._exchange.batchCancelOrders.getABIEncodedTransactionData(params.orders); + const data = this._exchange.batchCancelOrders(params.orders).getABIEncodedTransactionData(); const txReceipt = this._executeTransactionAsync(data, from); return txReceipt; } public async cancelOrdersUpToAsync(salt: BigNumber, from: string): Promise { - const data = this._exchange.cancelOrdersUpTo.getABIEncodedTransactionData(salt); + const data = this._exchange.cancelOrdersUpTo(salt).getABIEncodedTransactionData(); const txReceipt = this._executeTransactionAsync(data, from); return txReceipt; } public async getTakerAssetFilledAmountAsync(orderHashHex: string): Promise { - const filledAmount = await this._exchange.filled.callAsync(orderHashHex); + const filledAmount = await this._exchange.filled(orderHashHex).callAsync(); return filledAmount; } public async isCancelledAsync(orderHashHex: string): Promise { - const isCancelled = await this._exchange.cancelled.callAsync(orderHashHex); + const isCancelled = await this._exchange.cancelled(orderHashHex).callAsync(); return isCancelled; } public async getOrderEpochAsync(makerAddress: string, senderAddress: string): Promise { - const orderEpoch = await this._exchange.orderEpoch.callAsync(makerAddress, senderAddress); + const orderEpoch = await this._exchange.orderEpoch(makerAddress, senderAddress).callAsync(); return orderEpoch; } public async getOrderInfoAsync(signedOrder: SignedOrder): Promise { - const orderInfo = await this._exchange.getOrderInfo.callAsync(signedOrder); + const orderInfo = await this._exchange.getOrderInfo(signedOrder).callAsync(); return orderInfo; } public async getOrdersInfoAsync(signedOrders: SignedOrder[]): Promise { - const ordersInfo = (await this._exchange.getOrdersInfo.callAsync(signedOrders)) as OrderInfo[]; + const ordersInfo = (await this._exchange.getOrdersInfo(signedOrders)).callAsync() as OrderInfo[]; return ordersInfo; } public async matchOrdersAsync( @@ -219,12 +199,9 @@ export class BalanceThresholdWrapper { from: string, ): Promise { const params = orderUtils.createMatchOrders(signedOrderLeft, signedOrderRight); - const data = this._exchange.matchOrders.getABIEncodedTransactionData( - params.left, - params.right, - params.leftSignature, - params.rightSignature, - ); + const data = this._exchange + .matchOrders(params.left, params.right, params.leftSignature, params.rightSignature) + .getABIEncodedTransactionData(); const txReceipt = this._executeTransactionAsync(data, from); return txReceipt; } @@ -234,21 +211,16 @@ export class BalanceThresholdWrapper { opts: { takerAssetFillAmount?: BigNumber } = {}, ): Promise { const params = orderUtils.createFill(signedOrder, opts.takerAssetFillAmount); - const fillResults = await this._exchange.fillOrder.callAsync( - params.order, - params.takerAssetFillAmount, - params.signature, - { from }, - ); + const fillResults = await this._exchange + .fillOrder(params.order, params.takerAssetFillAmount, params.signature) + .callAsync({ from }); return fillResults; } public abiEncodeFillOrder(signedOrder: SignedOrder, opts: { takerAssetFillAmount?: BigNumber } = {}): string { const params = orderUtils.createFill(signedOrder, opts.takerAssetFillAmount); - const data = this._exchange.fillOrder.getABIEncodedTransactionData( - params.order, - params.takerAssetFillAmount, - params.signature, - ); + const data = this._exchange + .fillOrder(params.order, params.takerAssetFillAmount, params.signature) + .getABIEncodedTransactionData(); return data; } public getBalanceThresholdAddress(): string { @@ -264,13 +236,15 @@ export class BalanceThresholdWrapper { ): Promise { const signedExchangeTx = this._signerTransactionFactory.newSignedTransaction(abiEncodedExchangeTxData); const txOpts = gas === undefined ? { from } : { from, gas }; - const txHash = await this._balanceThresholdFilter.executeTransaction.sendTransactionAsync( - signedExchangeTx.salt, - signedExchangeTx.signerAddress, - signedExchangeTx.data, - signedExchangeTx.signature, - txOpts, - ); + const txHash = await this._balanceThresholdFilter + .executeTransaction( + signedExchangeTx.salt, + signedExchangeTx.signerAddress, + signedExchangeTx.data, + signedExchangeTx.signature, + txOpts, + ) + .sendTransactionAsync(); const txReceipt = await this._logDecoder.getTxWithDecodedLogsAsync(txHash); return txReceipt; } diff --git a/contracts/extensions/test/utils/dutch_auction_test_wrapper.ts b/contracts/extensions/test/utils/dutch_auction_test_wrapper.ts index 193ee1cfa4..3e98c6a94a 100644 --- a/contracts/extensions/test/utils/dutch_auction_test_wrapper.ts +++ b/contracts/extensions/test/utils/dutch_auction_test_wrapper.ts @@ -38,15 +38,11 @@ export class DutchAuctionTestWrapper { sellOrder: SignedOrder, from: string, ): Promise { - const txHash = await this._dutchAuctionContract.matchOrders.sendTransactionAsync( - buyOrder, - sellOrder, - buyOrder.signature, - sellOrder.signature, - { + const txHash = await this._dutchAuctionContract + .matchOrders(buyOrder, sellOrder, buyOrder.signature, sellOrder.signature) + .sendTransactionAsync({ from, - }, - ); + }); const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash); return tx; } @@ -56,7 +52,7 @@ export class DutchAuctionTestWrapper { * @return The dutch auction details. */ public async getAuctionDetailsAsync(sellOrder: SignedOrder): Promise { - const auctionDetails = await this._dutchAuctionContract.getAuctionDetails.callAsync(sellOrder); + const auctionDetails = await this._dutchAuctionContract.getAuctionDetails(sellOrder).callAsync(); return auctionDetails; } } diff --git a/contracts/integrations/test/actors/base.ts b/contracts/integrations/test/actors/base.ts index a763e02f8d..e2d2c2e618 100644 --- a/contracts/integrations/test/actors/base.ts +++ b/contracts/integrations/test/actors/base.ts @@ -46,22 +46,19 @@ export class Actor { amount?: BigNumber, ): Promise { if (token instanceof DummyERC20TokenContract) { - await token.setBalance.awaitTransactionSuccessAsync( - this.address, - amount || constants.INITIAL_ERC20_BALANCE, - ); + await token + .setBalance(this.address, amount || constants.INITIAL_ERC20_BALANCE) + .awaitTransactionSuccessAsync(); } else { - await token.deposit.awaitTransactionSuccessAsync({ + await token.deposit().awaitTransactionSuccessAsync({ from: this.address, value: amount || constants.ONE_ETHER, }); } - await token.approve.awaitTransactionSuccessAsync( - spender || this.deployment.assetProxies.erc20Proxy.address, - constants.MAX_UINT256, - { from: this.address }, - ); + await token + .approve(spender || this.deployment.assetProxies.erc20Proxy.address, constants.MAX_UINT256) + .awaitTransactionSuccessAsync({ from: this.address }); } /** @@ -76,19 +73,17 @@ export class Actor { const tokenIds: BigNumber[] = []; _.times(numToMint, async () => { const tokenId = getRandomInteger(constants.ZERO_AMOUNT, constants.MAX_UINT256); - await token.mint.awaitTransactionSuccessAsync(this.address, tokenId, { + await token.mint(this.address, tokenId).awaitTransactionSuccessAsync({ from: this.address, }); tokenIds.push(tokenId); }); - await token.setApprovalForAll.awaitTransactionSuccessAsync( - spender || this.deployment.assetProxies.erc721Proxy.address, - true, - { + await token + .setApprovalForAll(spender || this.deployment.assetProxies.erc721Proxy.address, true) + .awaitTransactionSuccessAsync({ from: this.address, - }, - ); + }); return tokenIds; } diff --git a/contracts/integrations/test/actors/keeper.ts b/contracts/integrations/test/actors/keeper.ts index 9389d136aa..b16182b749 100644 --- a/contracts/integrations/test/actors/keeper.ts +++ b/contracts/integrations/test/actors/keeper.ts @@ -37,14 +37,14 @@ export function KeeperMixin(Base: TBase): TBase & Con if (shouldFastForward) { // increase timestamp of next block by how many seconds we need to // get to the next epoch. - const epochEndTime = await stakingWrapper.getCurrentEpochEarliestEndTimeInSeconds.callAsync(); + const epochEndTime = await stakingWrapper.getCurrentEpochEarliestEndTimeInSeconds().callAsync(); const lastBlockTime = await web3Wrapper.getBlockTimestampAsync('latest'); const dt = Math.max(0, epochEndTime.minus(lastBlockTime).toNumber()); await web3Wrapper.increaseTimeAsync(dt); // mine next block await web3Wrapper.mineBlockAsync(); } - return stakingWrapper.endEpoch.awaitTransactionSuccessAsync({ from: this.actor.address }); + return stakingWrapper.endEpoch().awaitTransactionSuccessAsync({ from: this.actor.address }); } /** @@ -55,7 +55,7 @@ export function KeeperMixin(Base: TBase): TBase & Con const { stakingWrapper } = this.actor.deployment.staking; // If no poolIds provided, finalize all active pools from the previous epoch if (poolIds.length === 0) { - const previousEpoch = (await stakingWrapper.currentEpoch.callAsync()).minus(1); + const previousEpoch = (await stakingWrapper.currentEpoch().callAsync()).minus(1); const events = filterLogsToArguments( await stakingWrapper.getLogsAsync( TestStakingEvents.StakingPoolEarnedRewardsInEpoch, @@ -69,7 +69,7 @@ export function KeeperMixin(Base: TBase): TBase & Con return Promise.all( poolIds.map(async poolId => - stakingWrapper.finalizePool.awaitTransactionSuccessAsync(poolId, { + stakingWrapper.finalizePool(poolId).awaitTransactionSuccessAsync({ from: this.actor.address, }), ), diff --git a/contracts/integrations/test/actors/maker.ts b/contracts/integrations/test/actors/maker.ts index 8e9bcb9f79..e9ebab6006 100644 --- a/contracts/integrations/test/actors/maker.ts +++ b/contracts/integrations/test/actors/maker.ts @@ -59,7 +59,7 @@ export function MakerMixin(Base: TBase): TBase & Cons */ public async cancelOrderAsync(order: SignedOrder): Promise { const params = orderUtils.createCancel(order); - return this.actor.deployment.exchange.cancelOrder.awaitTransactionSuccessAsync(params.order, { + return this.actor.deployment.exchange.cancelOrder(params.order).awaitTransactionSuccessAsync({ from: this.actor.address, }); } @@ -70,7 +70,7 @@ export function MakerMixin(Base: TBase): TBase & Cons public async joinStakingPoolAsync(poolId: string): Promise { const stakingContract = this.actor.deployment.staking.stakingWrapper; this.makerPoolId = poolId; - return stakingContract.joinStakingPoolAsMaker.awaitTransactionSuccessAsync(poolId, { + return stakingContract.joinStakingPoolAsMaker(poolId).awaitTransactionSuccessAsync({ from: this.actor.address, }); } diff --git a/contracts/integrations/test/actors/pool_operator.ts b/contracts/integrations/test/actors/pool_operator.ts index 22763f76ba..249aad85b6 100644 --- a/contracts/integrations/test/actors/pool_operator.ts +++ b/contracts/integrations/test/actors/pool_operator.ts @@ -43,11 +43,9 @@ export function PoolOperatorMixin(Base: TBase): TBase addOperatorAsMaker: boolean = false, ): Promise { const stakingContract = this.actor.deployment.staking.stakingWrapper; - const txReceipt = await stakingContract.createStakingPool.awaitTransactionSuccessAsync( - operatorShare, - addOperatorAsMaker, - { from: this.actor.address }, - ); + const txReceipt = await stakingContract + .createStakingPool(operatorShare, addOperatorAsMaker) + .awaitTransactionSuccessAsync({ from: this.actor.address }); const createStakingPoolLog = txReceipt.logs[0]; const poolId = (createStakingPoolLog as any).args.poolId; @@ -64,11 +62,9 @@ export function PoolOperatorMixin(Base: TBase): TBase ): Promise { const stakingContract = this.actor.deployment.staking.stakingWrapper; this.operatorShares[poolId] = newOperatorShare; - return stakingContract.decreaseStakingPoolOperatorShare.awaitTransactionSuccessAsync( - poolId, - newOperatorShare, - { from: this.actor.address }, - ); + return stakingContract + .decreaseStakingPoolOperatorShare(poolId, newOperatorShare) + .awaitTransactionSuccessAsync({ from: this.actor.address }); } }; } diff --git a/contracts/integrations/test/actors/staker.ts b/contracts/integrations/test/actors/staker.ts index 0e2c48e8c6..77fa8e9636 100644 --- a/contracts/integrations/test/actors/staker.ts +++ b/contracts/integrations/test/actors/staker.ts @@ -32,16 +32,17 @@ export function StakerMixin(Base: TBase): TBase & Con */ public async stakeAsync(amount: BigNumber, poolId?: string): Promise { const { stakingWrapper } = this.actor.deployment.staking; - await stakingWrapper.stake.awaitTransactionSuccessAsync(amount, { + await stakingWrapper.stake(amount).awaitTransactionSuccessAsync({ from: this.actor.address, }); if (poolId !== undefined) { - await stakingWrapper.moveStake.awaitTransactionSuccessAsync( - new StakeInfo(StakeStatus.Undelegated), - new StakeInfo(StakeStatus.Delegated, poolId), - amount, - { from: this.actor.address }, - ); + await stakingWrapper + .moveStake( + new StakeInfo(StakeStatus.Undelegated), + new StakeInfo(StakeStatus.Delegated, poolId), + amount, + ) + .awaitTransactionSuccessAsync({ from: this.actor.address }); } } }; diff --git a/contracts/integrations/test/actors/taker.ts b/contracts/integrations/test/actors/taker.ts index a63311b139..36ad4237e8 100644 --- a/contracts/integrations/test/actors/taker.ts +++ b/contracts/integrations/test/actors/taker.ts @@ -41,17 +41,14 @@ export function TakerMixin(Base: TBase): TBase & Cons fillAmount: BigNumber, txData: Partial = {}, ): Promise { - return this.actor.deployment.exchange.fillOrder.awaitTransactionSuccessAsync( - order, - fillAmount, - order.signature, - { + return this.actor.deployment.exchange + .fillOrder(order, fillAmount, order.signature) + .awaitTransactionSuccessAsync({ from: this.actor.address, gasPrice: DeploymentManager.gasPrice, value: DeploymentManager.protocolFee, ...txData, - }, - ); + }); } }; } diff --git a/contracts/integrations/test/coordinator/coordinator_test.ts b/contracts/integrations/test/coordinator/coordinator_test.ts index d953739a3f..7409b64af7 100644 --- a/contracts/integrations/test/coordinator/coordinator_test.ts +++ b/contracts/integrations/test/coordinator/coordinator_test.ts @@ -64,10 +64,10 @@ blockchainTests.resets('Coordinator integration tests', env => { orderConfig: { senderAddress: coordinator.address, feeRecipientAddress: feeRecipient.address, - makerAssetData: await devUtils.encodeERC20AssetData.callAsync(makerToken.address), - takerAssetData: await devUtils.encodeERC20AssetData.callAsync(takerToken.address), - makerFeeAssetData: await devUtils.encodeERC20AssetData.callAsync(makerFeeToken.address), - takerFeeAssetData: await devUtils.encodeERC20AssetData.callAsync(takerFeeToken.address), + makerAssetData: await devUtils.encodeERC20AssetData(makerToken.address).callAsync(), + takerAssetData: await devUtils.encodeERC20AssetData(takerToken.address).callAsync(), + makerFeeAssetData: await devUtils.encodeERC20AssetData(makerFeeToken.address).callAsync(), + takerFeeAssetData: await devUtils.encodeERC20AssetData(takerFeeToken.address).callAsync(), }, }); @@ -141,7 +141,7 @@ blockchainTests.resets('Coordinator integration tests', env => { taker.address, deployment.staking.stakingProxy.address, DeploymentManager.protocolFee, - await devUtils.encodeERC20AssetData.callAsync(deployment.tokens.weth.address), + await devUtils.encodeERC20AssetData(deployment.tokens.weth.address).callAsync(), ); } } @@ -187,13 +187,9 @@ blockchainTests.resets('Coordinator integration tests', env => { it(`${fnName} should fill the order with a signed approval`, async () => { await balanceStore.updateBalancesAsync(); - const txReceipt = await coordinator.executeTransaction.awaitTransactionSuccessAsync( - transaction, - taker.address, - transaction.signature, - [approval.signature], - { from: taker.address, value: DeploymentManager.protocolFee }, - ); + const txReceipt = await coordinator + .executeTransaction(transaction, taker.address, transaction.signature, [approval.signature]) + .awaitTransactionSuccessAsync({ from: taker.address, value: DeploymentManager.protocolFee }); const expectedBalances = await simulateFillsAsync([order], txReceipt, DeploymentManager.protocolFee); await balanceStore.updateBalancesAsync(); @@ -202,13 +198,9 @@ blockchainTests.resets('Coordinator integration tests', env => { }); it(`${fnName} should fill the order if called by approver (eth protocol fee, no refund)`, async () => { await balanceStore.updateBalancesAsync(); - const txReceipt = await coordinator.executeTransaction.awaitTransactionSuccessAsync( - transaction, - feeRecipient.address, - transaction.signature, - [], - { from: feeRecipient.address, value: DeploymentManager.protocolFee }, - ); + const txReceipt = await coordinator + .executeTransaction(transaction, feeRecipient.address, transaction.signature, []) + .awaitTransactionSuccessAsync({ from: feeRecipient.address, value: DeploymentManager.protocolFee }); const expectedBalances = await simulateFillsAsync([order], txReceipt, DeploymentManager.protocolFee); await balanceStore.updateBalancesAsync(); @@ -217,13 +209,12 @@ blockchainTests.resets('Coordinator integration tests', env => { }); it(`${fnName} should fill the order if called by approver (eth protocol fee, refund)`, async () => { await balanceStore.updateBalancesAsync(); - const txReceipt = await coordinator.executeTransaction.awaitTransactionSuccessAsync( - transaction, - feeRecipient.address, - transaction.signature, - [], - { from: feeRecipient.address, value: DeploymentManager.protocolFee.plus(1) }, - ); + const txReceipt = await coordinator + .executeTransaction(transaction, feeRecipient.address, transaction.signature, []) + .awaitTransactionSuccessAsync({ + from: feeRecipient.address, + value: DeploymentManager.protocolFee.plus(1), + }); const expectedBalances = await simulateFillsAsync( [order], @@ -236,13 +227,9 @@ blockchainTests.resets('Coordinator integration tests', env => { }); it(`${fnName} should fill the order if called by approver (weth protocol fee, no refund)`, async () => { await balanceStore.updateBalancesAsync(); - const txReceipt = await coordinator.executeTransaction.awaitTransactionSuccessAsync( - transaction, - feeRecipient.address, - transaction.signature, - [], - { from: feeRecipient.address }, - ); + const txReceipt = await coordinator + .executeTransaction(transaction, feeRecipient.address, transaction.signature, []) + .awaitTransactionSuccessAsync({ from: feeRecipient.address }); const expectedBalances = await simulateFillsAsync([order], txReceipt); await balanceStore.updateBalancesAsync(); @@ -251,13 +238,9 @@ blockchainTests.resets('Coordinator integration tests', env => { }); it(`${fnName} should fill the order if called by approver (weth protocol fee, refund)`, async () => { await balanceStore.updateBalancesAsync(); - const txReceipt = await coordinator.executeTransaction.awaitTransactionSuccessAsync( - transaction, - feeRecipient.address, - transaction.signature, - [], - { from: feeRecipient.address, value: new BigNumber(1) }, - ); + const txReceipt = await coordinator + .executeTransaction(transaction, feeRecipient.address, transaction.signature, []) + .awaitTransactionSuccessAsync({ from: feeRecipient.address, value: new BigNumber(1) }); const expectedBalances = await simulateFillsAsync([order], txReceipt, new BigNumber(1)); await balanceStore.updateBalancesAsync(); @@ -266,13 +249,9 @@ blockchainTests.resets('Coordinator integration tests', env => { }); it(`${fnName} should revert with no approval signature`, async () => { const transactionHash = transactionHashUtils.getTransactionHashHex(transaction); - const tx = coordinator.executeTransaction.awaitTransactionSuccessAsync( - transaction, - taker.address, - transaction.signature, - [], - { from: taker.address, value: DeploymentManager.protocolFee }, - ); + const tx = coordinator + .executeTransaction(transaction, taker.address, transaction.signature, []) + .awaitTransactionSuccessAsync({ from: taker.address, value: DeploymentManager.protocolFee }); const expectedError = new CoordinatorRevertErrors.InvalidApprovalSignatureError( transactionHash, @@ -287,13 +266,9 @@ blockchainTests.resets('Coordinator integration tests', env => { hexSlice(approval.signature, 6), ); const transactionHash = transactionHashUtils.getTransactionHashHex(transaction); - const tx = coordinator.executeTransaction.awaitTransactionSuccessAsync( - transaction, - taker.address, - transaction.signature, - [approvalSignature], - { from: taker.address, value: DeploymentManager.protocolFee }, - ); + const tx = coordinator + .executeTransaction(transaction, taker.address, transaction.signature, [approvalSignature]) + .awaitTransactionSuccessAsync({ from: taker.address, value: DeploymentManager.protocolFee }); const expectedError = new CoordinatorRevertErrors.InvalidApprovalSignatureError( transactionHash, @@ -302,13 +277,9 @@ blockchainTests.resets('Coordinator integration tests', env => { return expect(tx).to.revertWith(expectedError); }); it(`${fnName} should revert if not called by tx signer or approver`, async () => { - const tx = coordinator.executeTransaction.awaitTransactionSuccessAsync( - transaction, - taker.address, - transaction.signature, - [approval.signature], - { from: maker.address, value: DeploymentManager.protocolFee }, - ); + const tx = coordinator + .executeTransaction(transaction, taker.address, transaction.signature, [approval.signature]) + .awaitTransactionSuccessAsync({ from: maker.address, value: DeploymentManager.protocolFee }); const expectedError = new CoordinatorRevertErrors.InvalidOriginError(taker.address); return expect(tx).to.revertWith(expectedError); @@ -335,13 +306,9 @@ blockchainTests.resets('Coordinator integration tests', env => { it(`${fnName} should fill the orders with a signed approval`, async () => { await balanceStore.updateBalancesAsync(); const value = DeploymentManager.protocolFee.times(orders.length); - const txReceipt = await coordinator.executeTransaction.awaitTransactionSuccessAsync( - transaction, - taker.address, - transaction.signature, - [approval.signature], - { from: taker.address, value }, - ); + const txReceipt = await coordinator + .executeTransaction(transaction, taker.address, transaction.signature, [approval.signature]) + .awaitTransactionSuccessAsync({ from: taker.address, value }); const expectedBalances = await simulateFillsAsync(orders, txReceipt, value); await balanceStore.updateBalancesAsync(); @@ -351,13 +318,9 @@ blockchainTests.resets('Coordinator integration tests', env => { it(`${fnName} should fill the orders if called by approver (eth fee, no refund)`, async () => { await balanceStore.updateBalancesAsync(); const value = DeploymentManager.protocolFee.times(orders.length); - const txReceipt = await coordinator.executeTransaction.awaitTransactionSuccessAsync( - transaction, - feeRecipient.address, - transaction.signature, - [], - { from: feeRecipient.address, value }, - ); + const txReceipt = await coordinator + .executeTransaction(transaction, feeRecipient.address, transaction.signature, []) + .awaitTransactionSuccessAsync({ from: feeRecipient.address, value }); const expectedBalances = await simulateFillsAsync(orders, txReceipt, value); await balanceStore.updateBalancesAsync(); @@ -367,13 +330,9 @@ blockchainTests.resets('Coordinator integration tests', env => { it(`${fnName} should fill the orders if called by approver (mixed fees, refund)`, async () => { await balanceStore.updateBalancesAsync(); const value = DeploymentManager.protocolFee.plus(1); - const txReceipt = await coordinator.executeTransaction.awaitTransactionSuccessAsync( - transaction, - feeRecipient.address, - transaction.signature, - [], - { from: feeRecipient.address, value }, - ); + const txReceipt = await coordinator + .executeTransaction(transaction, feeRecipient.address, transaction.signature, []) + .awaitTransactionSuccessAsync({ from: feeRecipient.address, value }); const expectedBalances = await simulateFillsAsync(orders, txReceipt, value); await balanceStore.updateBalancesAsync(); @@ -387,13 +346,12 @@ blockchainTests.resets('Coordinator integration tests', env => { hexSlice(approval.signature, 6), ); const transactionHash = transactionHashUtils.getTransactionHashHex(transaction); - const tx = coordinator.executeTransaction.awaitTransactionSuccessAsync( - transaction, - taker.address, - transaction.signature, - [approvalSignature], - { from: taker.address, value: DeploymentManager.protocolFee.times(orders.length) }, - ); + const tx = coordinator + .executeTransaction(transaction, taker.address, transaction.signature, [approvalSignature]) + .awaitTransactionSuccessAsync({ + from: taker.address, + value: DeploymentManager.protocolFee.times(orders.length), + }); const expectedError = new CoordinatorRevertErrors.InvalidApprovalSignatureError( transactionHash, feeRecipient.address, @@ -401,13 +359,12 @@ blockchainTests.resets('Coordinator integration tests', env => { return expect(tx).to.revertWith(expectedError); }); it(`${fnName} should revert if not called by tx signer or approver`, async () => { - const tx = coordinator.executeTransaction.awaitTransactionSuccessAsync( - transaction, - taker.address, - transaction.signature, - [approval.signature], - { from: maker.address, value: DeploymentManager.protocolFee.times(orders.length) }, - ); + const tx = coordinator + .executeTransaction(transaction, taker.address, transaction.signature, [approval.signature]) + .awaitTransactionSuccessAsync({ + from: maker.address, + value: DeploymentManager.protocolFee.times(orders.length), + }); const expectedError = new CoordinatorRevertErrors.InvalidOriginError(taker.address); return expect(tx).to.revertWith(expectedError); }); @@ -432,13 +389,9 @@ blockchainTests.resets('Coordinator integration tests', env => { data, gasPrice: DeploymentManager.gasPrice, }); - const txReceipt = await coordinator.executeTransaction.awaitTransactionSuccessAsync( - transaction, - maker.address, - transaction.signature, - [], - { from: maker.address }, - ); + const txReceipt = await coordinator + .executeTransaction(transaction, maker.address, transaction.signature, []) + .awaitTransactionSuccessAsync({ from: maker.address }); verifyEvents(txReceipt, [expectedCancelEvent(order)], ExchangeEvents.Cancel); }); @@ -449,13 +402,9 @@ blockchainTests.resets('Coordinator integration tests', env => { data, gasPrice: DeploymentManager.gasPrice, }); - const txReceipt = await coordinator.executeTransaction.awaitTransactionSuccessAsync( - transaction, - maker.address, - transaction.signature, - [], - { from: maker.address }, - ); + const txReceipt = await coordinator + .executeTransaction(transaction, maker.address, transaction.signature, []) + .awaitTransactionSuccessAsync({ from: maker.address }); verifyEvents(txReceipt, orders.map(order => expectedCancelEvent(order)), ExchangeEvents.Cancel); }); @@ -465,13 +414,9 @@ blockchainTests.resets('Coordinator integration tests', env => { data, gasPrice: DeploymentManager.gasPrice, }); - const txReceipt = await coordinator.executeTransaction.awaitTransactionSuccessAsync( - transaction, - maker.address, - transaction.signature, - [], - { from: maker.address }, - ); + const txReceipt = await coordinator + .executeTransaction(transaction, maker.address, transaction.signature, []) + .awaitTransactionSuccessAsync({ from: maker.address }); const expectedEvent: ExchangeCancelUpToEventArgs = { makerAddress: maker.address, diff --git a/contracts/integrations/test/forwarder/forwarder_test.ts b/contracts/integrations/test/forwarder/forwarder_test.ts index f521b9e44c..9bc82e4762 100644 --- a/contracts/integrations/test/forwarder/forwarder_test.ts +++ b/contracts/integrations/test/forwarder/forwarder_test.ts @@ -57,8 +57,8 @@ blockchainTests('Forwarder integration tests', env => { [makerToken, makerFeeToken, anotherErc20Token] = deployment.tokens.erc20; [erc721Token] = deployment.tokens.erc721; - wethAssetData = await devUtils.encodeERC20AssetData.callAsync(deployment.tokens.weth.address); - makerAssetData = await devUtils.encodeERC20AssetData.callAsync(makerToken.address); + wethAssetData = await devUtils.encodeERC20AssetData(deployment.tokens.weth.address).callAsync(); + makerAssetData = await devUtils.encodeERC20AssetData(makerToken.address).callAsync(); taker = new Actor({ name: 'Taker', deployment }); orderFeeRecipient = new FeeRecipient({ @@ -79,7 +79,7 @@ blockchainTests('Forwarder integration tests', env => { makerAssetData, takerAssetData: wethAssetData, takerFee: constants.ZERO_AMOUNT, - makerFeeAssetData: await devUtils.encodeERC20AssetData.callAsync(makerFeeToken.address), + makerFeeAssetData: await devUtils.encodeERC20AssetData(makerFeeToken.address).callAsync(), takerFeeAssetData: wethAssetData, }, }); @@ -87,7 +87,7 @@ blockchainTests('Forwarder integration tests', env => { await maker.configureERC20TokenAsync(makerToken); await maker.configureERC20TokenAsync(makerFeeToken); await maker.configureERC20TokenAsync(anotherErc20Token); - await forwarder.approveMakerAssetProxy.awaitTransactionSuccessAsync(makerAssetData); + await forwarder.approveMakerAssetProxy(makerAssetData).awaitTransactionSuccessAsync(); [nftId] = await maker.configureERC721TokenAsync(erc721Token); const tokenOwners = { @@ -171,7 +171,7 @@ blockchainTests('Forwarder integration tests', env => { await testFactory.marketSellTestAsync(orders, 1.34); }); it('should fail to fill an order with a percentage fee if the asset proxy is not yet approved', async () => { - const unapprovedAsset = await devUtils.encodeERC20AssetData.callAsync(anotherErc20Token.address); + const unapprovedAsset = await devUtils.encodeERC20AssetData(anotherErc20Token.address).callAsync(); const order = await maker.signOrderAsync({ makerAssetData: unapprovedAsset, takerFee: toBaseUnitAmount(2), @@ -180,16 +180,17 @@ blockchainTests('Forwarder integration tests', env => { await balanceStore.updateBalancesAsync(); // Execute test case - const tx = await forwarder.marketSellOrdersWithEth.awaitTransactionSuccessAsync( - [order], - [order.signature], - constants.ZERO_AMOUNT, - forwarderFeeRecipient.address, - { + const tx = await forwarder + .marketSellOrdersWithEth( + [order], + [order.signature], + constants.ZERO_AMOUNT, + forwarderFeeRecipient.address, + ) + .awaitTransactionSuccessAsync({ value: order.takerAssetAmount.plus(DeploymentManager.protocolFee), from: taker.address, - }, - ); + }); const expectedBalances = LocalBalanceStore.create(devUtils, balanceStore); expectedBalances.burnGas(tx.from, DeploymentManager.gasPrice.times(tx.gasUsed)); @@ -223,16 +224,17 @@ blockchainTests('Forwarder integration tests', env => { const order = await maker.signOrderAsync(); const ethValue = order.takerAssetAmount.plus(DeploymentManager.protocolFee).plus(2); const takerEthBalanceBefore = await env.web3Wrapper.getBalanceInWeiAsync(taker.address); - const tx = await forwarder.marketSellOrdersWithEth.awaitTransactionSuccessAsync( - [order], - [order.signature], - constants.ZERO_AMOUNT, - forwarderFeeRecipient.address, - { + const tx = await forwarder + .marketSellOrdersWithEth( + [order], + [order.signature], + constants.ZERO_AMOUNT, + forwarderFeeRecipient.address, + ) + .awaitTransactionSuccessAsync({ value: ethValue, from: taker.address, - }, - ); + }); const takerEthBalanceAfter = await env.web3Wrapper.getBalanceInWeiAsync(taker.address); const totalEthSpent = order.takerAssetAmount .plus(DeploymentManager.protocolFee) @@ -241,16 +243,18 @@ blockchainTests('Forwarder integration tests', env => { }); it('should fill orders with different makerAssetData', async () => { const firstOrder = await maker.signOrderAsync(); - const secondOrderMakerAssetData = await devUtils.encodeERC20AssetData.callAsync(anotherErc20Token.address); + const secondOrderMakerAssetData = await devUtils + .encodeERC20AssetData(anotherErc20Token.address) + .callAsync(); const secondOrder = await maker.signOrderAsync({ makerAssetData: secondOrderMakerAssetData, }); - await forwarder.approveMakerAssetProxy.awaitTransactionSuccessAsync(secondOrderMakerAssetData); + await forwarder.approveMakerAssetProxy(secondOrderMakerAssetData).awaitTransactionSuccessAsync(); const orders = [firstOrder, secondOrder]; await testFactory.marketSellTestAsync(orders, 1.5); }); it('should fail to fill an order with a fee denominated in an asset other than makerAsset or WETH', async () => { - const takerFeeAssetData = await devUtils.encodeERC20AssetData.callAsync(anotherErc20Token.address); + const takerFeeAssetData = await devUtils.encodeERC20AssetData(anotherErc20Token.address).callAsync(); const order = await maker.signOrderAsync({ takerFeeAssetData, takerFee: toBaseUnitAmount(1), @@ -341,11 +345,13 @@ blockchainTests('Forwarder integration tests', env => { }); it('should buy exactly makerAssetBuyAmount in orders with different makerAssetData', async () => { const firstOrder = await maker.signOrderAsync(); - const secondOrderMakerAssetData = await devUtils.encodeERC20AssetData.callAsync(anotherErc20Token.address); + const secondOrderMakerAssetData = await devUtils + .encodeERC20AssetData(anotherErc20Token.address) + .callAsync(); const secondOrder = await maker.signOrderAsync({ makerAssetData: secondOrderMakerAssetData, }); - await forwarder.approveMakerAssetProxy.awaitTransactionSuccessAsync(secondOrderMakerAssetData); + await forwarder.approveMakerAssetProxy(secondOrderMakerAssetData).awaitTransactionSuccessAsync(); const orders = [firstOrder, secondOrder]; await testFactory.marketBuyTestAsync(orders, 1.5); }); @@ -390,7 +396,7 @@ blockchainTests('Forwarder integration tests', env => { it('should buy an ERC721 asset from a single order', async () => { const erc721Order = await maker.signOrderAsync({ makerAssetAmount: new BigNumber(1), - makerAssetData: await devUtils.encodeERC721AssetData.callAsync(erc721Token.address, nftId), + makerAssetData: await devUtils.encodeERC721AssetData(erc721Token.address, nftId).callAsync(), takerFeeAssetData: wethAssetData, }); await testFactory.marketBuyTestAsync([erc721Order], 1); @@ -398,14 +404,14 @@ blockchainTests('Forwarder integration tests', env => { it('should buy an ERC721 asset and pay a WETH fee', async () => { const erc721orderWithWethFee = await maker.signOrderAsync({ makerAssetAmount: new BigNumber(1), - makerAssetData: await devUtils.encodeERC721AssetData.callAsync(erc721Token.address, nftId), + makerAssetData: await devUtils.encodeERC721AssetData(erc721Token.address, nftId).callAsync(), takerFee: toBaseUnitAmount(1), takerFeeAssetData: wethAssetData, }); await testFactory.marketBuyTestAsync([erc721orderWithWethFee], 1); }); it('should fail to fill an order with a fee denominated in an asset other than makerAsset or WETH', async () => { - const takerFeeAssetData = await devUtils.encodeERC20AssetData.callAsync(anotherErc20Token.address); + const takerFeeAssetData = await devUtils.encodeERC20AssetData(anotherErc20Token.address).callAsync(); const order = await maker.signOrderAsync({ takerFeeAssetData, takerFee: toBaseUnitAmount(1), @@ -483,17 +489,18 @@ blockchainTests('Forwarder integration tests', env => { await balanceStore.updateBalancesAsync(); // Execute test case - const tx = await forwarder.marketBuyOrdersWithEth.awaitTransactionSuccessAsync( - [order], - desiredMakerAssetFillAmount, - [order.signature], - constants.ZERO_AMOUNT, - forwarderFeeRecipient.address, - { + const tx = await forwarder + .marketBuyOrdersWithEth( + [order], + desiredMakerAssetFillAmount, + [order.signature], + constants.ZERO_AMOUNT, + forwarderFeeRecipient.address, + ) + .awaitTransactionSuccessAsync({ value: ethValue, from: taker.address, - }, - ); + }); // Compute expected balances const expectedBalances = LocalBalanceStore.create(devUtils, balanceStore); @@ -539,17 +546,18 @@ blockchainTests('Forwarder integration tests', env => { await balanceStore.updateBalancesAsync(); // Execute test case - const tx = await forwarder.marketBuyOrdersWithEth.awaitTransactionSuccessAsync( - [order], - desiredMakerAssetFillAmount, - [order.signature], - constants.ZERO_AMOUNT, - forwarderFeeRecipient.address, - { + const tx = await forwarder + .marketBuyOrdersWithEth( + [order], + desiredMakerAssetFillAmount, + [order.signature], + constants.ZERO_AMOUNT, + forwarderFeeRecipient.address, + ) + .awaitTransactionSuccessAsync({ value: takerAssetFillAmount.plus(DeploymentManager.protocolFee), from: taker.address, - }, - ); + }); // Compute expected balances const expectedBalances = LocalBalanceStore.create(devUtils, balanceStore); diff --git a/contracts/integrations/test/forwarder/forwarder_test_factory.ts b/contracts/integrations/test/forwarder/forwarder_test_factory.ts index fcc0b83199..70be41d387 100644 --- a/contracts/integrations/test/forwarder/forwarder_test_factory.ts +++ b/contracts/integrations/test/forwarder/forwarder_test_factory.ts @@ -46,7 +46,7 @@ export class ForwarderTestFactory { const forwarderFeePercentage = options.forwarderFeePercentage || 0; const orderInfoBefore = await Promise.all( - orders.map(order => this._deployment.exchange.getOrderInfo.callAsync(order)), + orders.map(order => this._deployment.exchange.getOrderInfo(order).callAsync()), ); const expectedOrderStatuses = orderInfoBefore.map((orderInfo, i) => fractionalNumberOfOrdersToFill >= i + 1 && orderInfo.orderStatus === OrderStatus.Fillable @@ -63,17 +63,18 @@ export class ForwarderTestFactory { const ethSpentOnForwarderFee = getPercentageOfValue(wethSpentAmount, forwarderFeePercentage); const feePercentage = getPercentageOfValue(constants.PERCENTAGE_DENOMINATOR, forwarderFeePercentage); - const tx = this._forwarder.marketBuyOrdersWithEth.awaitTransactionSuccessAsync( - orders, - makerAssetAcquiredAmount, - orders.map(signedOrder => signedOrder.signature), - feePercentage, - this._forwarderFeeRecipient.address, - { + const tx = this._forwarder + .marketBuyOrdersWithEth( + orders, + makerAssetAcquiredAmount, + orders.map(signedOrder => signedOrder.signature), + feePercentage, + this._forwarderFeeRecipient.address, + ) + .awaitTransactionSuccessAsync({ value: wethSpentAmount.plus(ethSpentOnForwarderFee).plus(ethValueAdjustment), from: this._taker.address, - }, - ); + }); if (options.revertError !== undefined) { await expect(tx).to.revertWith(options.revertError); @@ -89,7 +90,7 @@ export class ForwarderTestFactory { options: Partial = {}, ): Promise { const orderInfoBefore = await Promise.all( - orders.map(order => this._deployment.exchange.getOrderInfo.callAsync(order)), + orders.map(order => this._deployment.exchange.getOrderInfo(order).callAsync()), ); const expectedOrderStatuses = orderInfoBefore.map((orderInfo, i) => fractionalNumberOfOrdersToFill >= i + 1 && orderInfo.orderStatus === OrderStatus.Fillable @@ -108,16 +109,17 @@ export class ForwarderTestFactory { const ethSpentOnForwarderFee = getPercentageOfValue(wethSpentAmount, forwarderFeePercentage); const feePercentage = getPercentageOfValue(constants.PERCENTAGE_DENOMINATOR, forwarderFeePercentage); - const tx = this._forwarder.marketSellOrdersWithEth.awaitTransactionSuccessAsync( - orders, - orders.map(signedOrder => signedOrder.signature), - feePercentage, - this._forwarderFeeRecipient.address, - { + const tx = this._forwarder + .marketSellOrdersWithEth( + orders, + orders.map(signedOrder => signedOrder.signature), + feePercentage, + this._forwarderFeeRecipient.address, + ) + .awaitTransactionSuccessAsync({ value: wethSpentAmount.plus(ethSpentOnForwarderFee), from: this._taker.address, - }, - ); + }); if (options.revertError !== undefined) { await expect(tx).to.revertWith(options.revertError); @@ -141,7 +143,7 @@ export class ForwarderTestFactory { // Get updated order info const orderInfoAfter = await Promise.all( - orders.map(order => this._deployment.exchange.getOrderInfo.callAsync(order)), + orders.map(order => this._deployment.exchange.getOrderInfo(order).callAsync()), ); // Check order statuses for (const [i, orderInfo] of orderInfoAfter.entries()) { diff --git a/contracts/integrations/test/framework-unit-tests/deployment_manager_test.ts b/contracts/integrations/test/framework-unit-tests/deployment_manager_test.ts index 7cc4a15424..f5e92e2b3e 100644 --- a/contracts/integrations/test/framework-unit-tests/deployment_manager_test.ts +++ b/contracts/integrations/test/framework-unit-tests/deployment_manager_test.ts @@ -18,20 +18,20 @@ blockchainTests('Deployment Manager', env => { authorizedContracts: Authorizable[], ): Promise { for (const authorized of authorizedContracts) { - expect(await authorized.authorized.callAsync(authorizedAddress)).to.be.true(); + expect(await authorized.authorized(authorizedAddress).callAsync()).to.be.true(); } } async function batchAssertOwnerAsync(ownerAddress: string, owners: Ownable[]): Promise { for (const ownerContract of owners) { - expect(await ownerContract.owner.callAsync()).to.be.eq(ownerAddress); + expect(await ownerContract.owner().callAsync()).to.be.eq(ownerAddress); } } describe('asset proxy owner', () => { it('should be owned by `owner`', async () => { // Ensure that the owners of the asset proxy only contain the owner. - const owners = await deploymentManager.governor.getOwners.callAsync(); + const owners = await deploymentManager.governor.getOwners().callAsync(); expect(owners).to.be.deep.eq([owner]); }); }); @@ -65,25 +65,33 @@ blockchainTests('Deployment Manager', env => { it('should have the correct authorities list', async () => { // The multi-asset proxy should only have the exchange in the authorities list. - const authorities = await deploymentManager.assetProxies.multiAssetProxy.getAuthorizedAddresses.callAsync(); + const authorities = await deploymentManager.assetProxies.multiAssetProxy + .getAuthorizedAddresses() + .callAsync(); expect(authorities).to.be.deep.eq([deploymentManager.exchange.address]); // The other asset proxies should have the exchange and the multi-asset proxy in their // authorities list. - const erc20ProxyAuthorities = await deploymentManager.assetProxies.erc20Proxy.getAuthorizedAddresses.callAsync(); + const erc20ProxyAuthorities = await deploymentManager.assetProxies.erc20Proxy + .getAuthorizedAddresses() + .callAsync(); expect(erc20ProxyAuthorities).to.deep.eq([ deploymentManager.staking.zrxVault.address, deploymentManager.assetProxies.multiAssetProxy.address, deploymentManager.exchange.address, ]); - const erc1155ProxyAuthorities = await deploymentManager.assetProxies.erc1155Proxy.getAuthorizedAddresses.callAsync(); + const erc1155ProxyAuthorities = await deploymentManager.assetProxies.erc1155Proxy + .getAuthorizedAddresses() + .callAsync(); expect(erc1155ProxyAuthorities).to.deep.eq([ deploymentManager.assetProxies.multiAssetProxy.address, deploymentManager.exchange.address, ]); - const erc721ProxyAuthorities = await deploymentManager.assetProxies.erc721Proxy.getAuthorizedAddresses.callAsync(); + const erc721ProxyAuthorities = await deploymentManager.assetProxies.erc721Proxy + .getAuthorizedAddresses() + .callAsync(); expect(erc721ProxyAuthorities).to.deep.eq([ deploymentManager.assetProxies.multiAssetProxy.address, deploymentManager.exchange.address, @@ -93,7 +101,7 @@ blockchainTests('Deployment Manager', env => { describe('exchange', () => { it('should be owned by the asset proxy owner', async () => { - const exchangeOwner = await deploymentManager.exchange.owner.callAsync(); + const exchangeOwner = await deploymentManager.exchange.owner().callAsync(); expect(exchangeOwner).to.be.eq(deploymentManager.governor.address); }); @@ -101,66 +109,66 @@ blockchainTests('Deployment Manager', env => { TODO(jalextowle): This test should be enabled once the Exchange is made an Authorizable contract. it('should have authorized the asset proxy owner', async () => { - const isAuthorized = await deploymentManager.exchange.owner.callAsync( + const isAuthorized = await deploymentManager.exchange.owner( deploymentManager.governor.address, - ); + ).callAsync(); expect(isAuthorized).to.be.true(); }); */ it('should have registered the staking proxy', async () => { - const feeCollector = await deploymentManager.exchange.protocolFeeCollector.callAsync(); + const feeCollector = await deploymentManager.exchange.protocolFeeCollector().callAsync(); expect(feeCollector).to.be.eq(deploymentManager.staking.stakingProxy.address); }); it('should have set the protocol fee multiplier', async () => { - const feeMultiplier = await deploymentManager.exchange.protocolFeeMultiplier.callAsync(); + const feeMultiplier = await deploymentManager.exchange.protocolFeeMultiplier().callAsync(); expect(feeMultiplier).bignumber.to.be.eq(DeploymentManager.protocolFeeMultiplier); }); }); describe('staking', () => { it('should be owned by the asset proxy owner', async () => { - const stakingOwner = await deploymentManager.staking.stakingProxy.owner.callAsync(); + const stakingOwner = await deploymentManager.staking.stakingProxy.owner().callAsync(); expect(stakingOwner).to.be.eq(deploymentManager.governor.address); }); it('should have authorized the asset proxy owner in the staking proxy', async () => { - const isAuthorized = await deploymentManager.staking.stakingProxy.authorized.callAsync( - deploymentManager.governor.address, - ); + const isAuthorized = await deploymentManager.staking.stakingProxy + .authorized(deploymentManager.governor.address) + .callAsync(); expect(isAuthorized).to.be.true(); }); it('should have registered the exchange in the staking proxy', async () => { - const isValid = await deploymentManager.staking.stakingProxy.validExchanges.callAsync( - deploymentManager.exchange.address, - ); + const isValid = await deploymentManager.staking.stakingProxy + .validExchanges(deploymentManager.exchange.address) + .callAsync(); expect(isValid).to.be.true(); }); it('should have registered the staking contract in the staking proxy', async () => { - const stakingContract = await deploymentManager.staking.stakingProxy.stakingContract.callAsync(); + const stakingContract = await deploymentManager.staking.stakingProxy.stakingContract().callAsync(); expect(stakingContract).to.be.eq(deploymentManager.staking.stakingLogic.address); }); it('should have registered the weth contract in the staking contract', async () => { - const weth = await deploymentManager.staking.stakingWrapper.testWethAddress.callAsync(); + const weth = await deploymentManager.staking.stakingWrapper.testWethAddress().callAsync(); expect(weth).to.be.eq(deploymentManager.tokens.weth.address); }); it('should have registered the zrx vault in the staking contract', async () => { - const zrxVault = await deploymentManager.staking.stakingWrapper.testZrxVaultAddress.callAsync(); + const zrxVault = await deploymentManager.staking.stakingWrapper.testZrxVaultAddress().callAsync(); expect(zrxVault).to.be.eq(deploymentManager.staking.zrxVault.address); }); it('should have registered the staking proxy in the zrx vault', async () => { - const stakingProxy = await deploymentManager.staking.zrxVault.stakingProxyAddress.callAsync(); + const stakingProxy = await deploymentManager.staking.zrxVault.stakingProxyAddress().callAsync(); expect(stakingProxy).to.be.eq(deploymentManager.staking.stakingProxy.address); }); it('should have correctly set the params', async () => { - const params = await deploymentManager.staking.stakingWrapper.getParams.callAsync(); + const params = await deploymentManager.staking.stakingWrapper.getParams().callAsync(); expect(params).to.be.deep.eq([ stakingConstants.DEFAULT_PARAMS.epochDurationInSeconds, stakingConstants.DEFAULT_PARAMS.rewardDelegatedStakeWeight, diff --git a/contracts/integrations/test/framework-unit-tests/function_assertion_test.ts b/contracts/integrations/test/framework-unit-tests/function_assertion_test.ts index f10ec1efb7..b9158c16dd 100644 --- a/contracts/integrations/test/framework-unit-tests/function_assertion_test.ts +++ b/contracts/integrations/test/framework-unit-tests/function_assertion_test.ts @@ -45,7 +45,7 @@ blockchainTests.resets('FunctionAssertion Unit Tests', env => { }); it('should not fail immediately if the wrapped function fails', async () => { - const assertion = new FunctionAssertion<{}>(exampleContract.emptyRevert); + const assertion = new FunctionAssertion<{}, void>(exampleContract.emptyRevert); await assertion.executeAsync(); }); diff --git a/contracts/integrations/test/internal-integration-tests/deployment_test.ts b/contracts/integrations/test/internal-integration-tests/deployment_test.ts index d6e49e0e09..bbee978626 100644 --- a/contracts/integrations/test/internal-integration-tests/deployment_test.ts +++ b/contracts/integrations/test/internal-integration-tests/deployment_test.ts @@ -116,7 +116,7 @@ blockchainTests('Deployment and Configuration End to End Tests', env => { ); // Authorize owner in the staking proxy. - await stakingProxy.addAuthorizedAddress.awaitTransactionSuccessAsync(owner); + await stakingProxy.addAuthorizedAddress(owner).awaitTransactionSuccessAsync(); // Deploy the asset proxy contracts. erc20Proxy = await ERC20ProxyContract.deployFrom0xArtifactAsync( @@ -164,12 +164,11 @@ blockchainTests('Deployment and Configuration End to End Tests', env => { assetProxyId: string, ): Promise { // Register the asset proxy. - const receipt = await registrationContract.registerAssetProxy.awaitTransactionSuccessAsync( - assetProxyAddress, - { + const receipt = await registrationContract + .registerAssetProxy(assetProxyAddress) + .awaitTransactionSuccessAsync({ from: owner, - }, - ); + }); // Ensure that the correct event was logged. const logs = filterLogsToArguments( @@ -179,7 +178,7 @@ blockchainTests('Deployment and Configuration End to End Tests', env => { expect(logs).to.be.deep.eq([{ id: assetProxyId, assetProxy: assetProxyAddress }]); // Ensure that the asset proxy was actually registered. - const proxyAddress = await registrationContract.getAssetProxy.callAsync(assetProxyId); + const proxyAddress = await registrationContract.getAssetProxy(assetProxyId).callAsync(); expect(proxyAddress).to.be.eq(assetProxyAddress); } @@ -189,10 +188,9 @@ blockchainTests('Deployment and Configuration End to End Tests', env => { newAuthorityAddress: string, ): Promise { // Authorize the address. - const receipt = await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync( - newAuthorityAddress, - { from: owner }, - ); + const receipt = await authorizable + .addAuthorizedAddress(newAuthorityAddress) + .awaitTransactionSuccessAsync({ from: owner }); // Ensure that the correct log was emitted. const logs = filterLogsToArguments( @@ -202,7 +200,7 @@ blockchainTests('Deployment and Configuration End to End Tests', env => { expect(logs).to.be.deep.eq([{ target: newAuthorityAddress, caller: owner }]); // Ensure that the address was actually authorized. - const wasAuthorized = await authorizable.authorized.callAsync(newAuthorityAddress); + const wasAuthorized = await authorizable.authorized(newAuthorityAddress).callAsync(); expect(wasAuthorized).to.be.true(); } @@ -262,13 +260,13 @@ blockchainTests('Deployment and Configuration End to End Tests', env => { describe('staking specific', () => { it('should have properly configured the staking proxy with the logic contract', async () => { // Ensure that the registered staking contract is correct. - const stakingAddress = await stakingProxy.stakingContract.callAsync(); + const stakingAddress = await stakingProxy.stakingContract().callAsync(); expect(stakingAddress).to.be.eq(staking.address); }); it('should have initialized the correct parameters in the staking proxy', async () => { // Ensure that the correct parameters were set. - const params = await stakingWrapper.getParams.callAsync(); + const params = await stakingWrapper.getParams().callAsync(); expect(params).to.be.deep.eq([ stakingConstants.DEFAULT_PARAMS.epochDurationInSeconds, stakingConstants.DEFAULT_PARAMS.rewardDelegatedStakeWeight, @@ -282,7 +280,7 @@ blockchainTests('Deployment and Configuration End to End Tests', env => { describe('exchange and staking integration', () => { it('should successfully register the exchange in the staking contract', async () => { // Register the exchange. - const receipt = await stakingWrapper.addExchangeAddress.awaitTransactionSuccessAsync(exchange.address, { + const receipt = await stakingWrapper.addExchangeAddress(exchange.address).awaitTransactionSuccessAsync({ from: owner, }); @@ -294,18 +292,17 @@ blockchainTests('Deployment and Configuration End to End Tests', env => { expect(logs).to.be.deep.eq([{ exchangeAddress: exchange.address }]); // Ensure that the exchange was registered. - const wasRegistered = await stakingWrapper.validExchanges.callAsync(exchange.address); + const wasRegistered = await stakingWrapper.validExchanges(exchange.address).callAsync(); expect(wasRegistered).to.be.true(); }); it('should successfully register the staking contract in the exchange', async () => { // Register the staking contract. - const receipt = await exchange.setProtocolFeeCollectorAddress.awaitTransactionSuccessAsync( - stakingProxy.address, - { + const receipt = await exchange + .setProtocolFeeCollectorAddress(stakingProxy.address) + .awaitTransactionSuccessAsync({ from: owner, - }, - ); + }); // Ensure that the correct events were logged. const logs = filterLogsToArguments( @@ -320,15 +317,15 @@ blockchainTests('Deployment and Configuration End to End Tests', env => { ]); // Ensure that the staking contract was registered. - const feeCollector = await exchange.protocolFeeCollector.callAsync(); + const feeCollector = await exchange.protocolFeeCollector().callAsync(); expect(feeCollector).to.be.eq(stakingProxy.address); }); it('should successfully update the protocol fee multiplier in the staking contract', async () => { // Update the protocol fee multiplier. - const receipt = await exchange.setProtocolFeeMultiplier.awaitTransactionSuccessAsync( - protocolFeeMultiplier, - ); + const receipt = await exchange + .setProtocolFeeMultiplier(protocolFeeMultiplier) + .awaitTransactionSuccessAsync(); // Ensure that the correct events were logged. const logs = filterLogsToArguments( @@ -343,7 +340,7 @@ blockchainTests('Deployment and Configuration End to End Tests', env => { ]); // Ensure that the protocol fee multiplier was set correctly. - const multiplier = await exchange.protocolFeeMultiplier.callAsync(); + const multiplier = await exchange.protocolFeeMultiplier().callAsync(); expect(multiplier).bignumber.to.be.eq(protocolFeeMultiplier); }); }); @@ -354,7 +351,7 @@ blockchainTests('Deployment and Configuration End to End Tests', env => { // to the asset proxy owner. async function transferAuthorizationAndAssertSuccessAsync(contract: Authorizable): Promise { // Remove authorization from the old owner. - let receipt = await contract.removeAuthorizedAddress.awaitTransactionSuccessAsync(owner, { from: owner }); + let receipt = await contract.removeAuthorizedAddress(owner).awaitTransactionSuccessAsync({ from: owner }); // Ensure that the correct log was recorded. let logs = filterLogsToArguments( @@ -364,11 +361,11 @@ blockchainTests('Deployment and Configuration End to End Tests', env => { expect(logs).to.be.deep.eq([{ target: owner, caller: owner }]); // Ensure that the owner was actually removed. - let isAuthorized = await contract.authorized.callAsync(owner); + let isAuthorized = await contract.authorized(owner).callAsync(); expect(isAuthorized).to.be.false(); // Authorize the asset-proxy owner. - receipt = await contract.addAuthorizedAddress.awaitTransactionSuccessAsync(governor.address, { + receipt = await contract.addAuthorizedAddress(governor.address).awaitTransactionSuccessAsync({ from: owner, }); @@ -380,17 +377,17 @@ blockchainTests('Deployment and Configuration End to End Tests', env => { expect(logs).to.be.deep.eq([{ target: governor.address, caller: owner }]); // Ensure that the asset-proxy owner was actually authorized. - isAuthorized = await contract.authorized.callAsync(governor.address); + isAuthorized = await contract.authorized(governor.address).callAsync(); expect(isAuthorized).to.be.true(); } // Transfers ownership of a contract to the asset-proxy owner, and ensures that the change was actually made. async function transferOwnershipAndAssertSuccessAsync(contract: Ownable): Promise { // Transfer ownership to the new owner. - await contract.transferOwnership.awaitTransactionSuccessAsync(governor.address, { from: owner }); + await contract.transferOwnership(governor.address).awaitTransactionSuccessAsync({ from: owner }); // Ensure that the owner address has been updated. - const ownerAddress = await contract.owner.callAsync(); + const ownerAddress = await contract.owner().callAsync(); expect(ownerAddress).to.be.eq(governor.address); } diff --git a/contracts/integrations/test/internal-integration-tests/exchange_wrapper_test.ts b/contracts/integrations/test/internal-integration-tests/exchange_wrapper_test.ts index 2ba36dcce6..0889c28606 100644 --- a/contracts/integrations/test/internal-integration-tests/exchange_wrapper_test.ts +++ b/contracts/integrations/test/internal-integration-tests/exchange_wrapper_test.ts @@ -19,7 +19,7 @@ import { Numberish, provider, toBaseUnitAmount, - TransactionHelper, + transactionHelper, verifyEvents, } from '@0x/contracts-test-utils'; import { ExchangeRevertErrors, orderHashUtils } from '@0x/order-utils'; @@ -55,7 +55,6 @@ blockchainTests.resets('Exchange wrappers', env => { let localBalances: LocalBalanceStore; let wethAssetData: string; - let txHelper: TransactionHelper; before(async () => { [feeRecipient] = await env.getAccountAddressesAsync(); @@ -70,10 +69,10 @@ blockchainTests.resets('Exchange wrappers', env => { name: 'market maker', deployment, orderConfig: { - makerAssetData: await devUtils.encodeERC20AssetData.callAsync(deployment.tokens.erc20[0].address), - takerAssetData: await devUtils.encodeERC20AssetData.callAsync(deployment.tokens.erc20[1].address), - makerFeeAssetData: await devUtils.encodeERC20AssetData.callAsync(deployment.tokens.erc20[2].address), - takerFeeAssetData: await devUtils.encodeERC20AssetData.callAsync(deployment.tokens.erc20[2].address), + makerAssetData: await devUtils.encodeERC20AssetData(deployment.tokens.erc20[0].address).callAsync(), + takerAssetData: await devUtils.encodeERC20AssetData(deployment.tokens.erc20[1].address).callAsync(), + makerFeeAssetData: await devUtils.encodeERC20AssetData(deployment.tokens.erc20[2].address).callAsync(), + takerFeeAssetData: await devUtils.encodeERC20AssetData(deployment.tokens.erc20[2].address).callAsync(), feeRecipientAddress: feeRecipient, }, }); @@ -111,13 +110,7 @@ blockchainTests.resets('Exchange wrappers', env => { initialLocalBalances = LocalBalanceStore.create(devUtils, blockchainBalances); - wethAssetData = await devUtils.encodeERC20AssetData.callAsync(deployment.tokens.weth.address); - - txHelper = new TransactionHelper(env.web3Wrapper, { - ...assetProxyArtifacts, - ...exchangeArtifacts, - ...stakingArtifacts, - }); + wethAssetData = await devUtils.encodeERC20AssetData(deployment.tokens.weth.address).callAsync(); }); beforeEach(async () => { @@ -324,7 +317,7 @@ blockchainTests.resets('Exchange wrappers', env => { }); const takerAssetFilledAmount = signedOrder.takerAssetAmount.div(2); - const [fillResults, receipt] = await txHelper.getResultAndReceiptAsync( + const [fillResults, receipt] = await transactionHelper.getResultAndReceiptAsync( deployment.exchange.fillOrKillOrder, signedOrder, takerAssetFilledAmount, @@ -368,12 +361,13 @@ blockchainTests.resets('Exchange wrappers', env => { }); const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder); const expectedError = new ExchangeRevertErrors.OrderStatusError(orderHashHex, OrderStatus.Expired); - const tx = deployment.exchange.fillOrKillOrder.awaitTransactionSuccessAsync( - signedOrder, - signedOrder.takerAssetAmount, - signedOrder.signature, - { from: taker.address, gasPrice: DeploymentManager.gasPrice, value: DeploymentManager.protocolFee }, - ); + const tx = deployment.exchange + .fillOrKillOrder(signedOrder, signedOrder.takerAssetAmount, signedOrder.signature) + .awaitTransactionSuccessAsync({ + from: taker.address, + gasPrice: DeploymentManager.gasPrice, + value: DeploymentManager.protocolFee, + }); return expect(tx).to.revertWith(expectedError); }); @@ -381,23 +375,25 @@ blockchainTests.resets('Exchange wrappers', env => { const signedOrder = await maker.signOrderAsync(); const takerAssetFillAmount = signedOrder.takerAssetAmount; - await deployment.exchange.fillOrder.awaitTransactionSuccessAsync( - signedOrder, - signedOrder.takerAssetAmount.dividedToIntegerBy(2), - signedOrder.signature, - { from: taker.address, gasPrice: DeploymentManager.gasPrice, value: DeploymentManager.protocolFee }, - ); + await deployment.exchange + .fillOrder(signedOrder, signedOrder.takerAssetAmount.dividedToIntegerBy(2), signedOrder.signature) + .awaitTransactionSuccessAsync({ + from: taker.address, + gasPrice: DeploymentManager.gasPrice, + value: DeploymentManager.protocolFee, + }); const expectedError = new ExchangeRevertErrors.IncompleteFillError( ExchangeRevertErrors.IncompleteFillErrorCode.IncompleteFillOrder, takerAssetFillAmount, takerAssetFillAmount.dividedToIntegerBy(2), ); - const tx = deployment.exchange.fillOrKillOrder.awaitTransactionSuccessAsync( - signedOrder, - signedOrder.takerAssetAmount, - signedOrder.signature, - { from: taker.address, gasPrice: DeploymentManager.gasPrice, value: DeploymentManager.protocolFee }, - ); + const tx = deployment.exchange + .fillOrKillOrder(signedOrder, signedOrder.takerAssetAmount, signedOrder.signature) + .awaitTransactionSuccessAsync({ + from: taker.address, + gasPrice: DeploymentManager.gasPrice, + value: DeploymentManager.protocolFee, + }); return expect(tx).to.revertWith(expectedError); }); }); @@ -440,7 +436,7 @@ blockchainTests.resets('Exchange wrappers', env => { await simulateFillAsync(signedOrder, expectedFillResults, shouldPayWethFees); } - const [fillResults, receipt] = await txHelper.getResultAndReceiptAsync( + const [fillResults, receipt] = await transactionHelper.getResultAndReceiptAsync( deployment.exchange.batchFillOrders, signedOrders, takerAssetFillAmounts, @@ -502,7 +498,7 @@ blockchainTests.resets('Exchange wrappers', env => { await simulateFillAsync(signedOrder, expectedFillResults, shouldPayWethFees); } - const [fillResults, receipt] = await txHelper.getResultAndReceiptAsync( + const [fillResults, receipt] = await transactionHelper.getResultAndReceiptAsync( deployment.exchange.batchFillOrKillOrders, signedOrders, takerAssetFillAmounts, @@ -534,25 +530,27 @@ blockchainTests.resets('Exchange wrappers', env => { it('should revert if a single signedOrder does not fill the expected amount', async () => { const takerAssetFillAmounts = signedOrders.map(signedOrder => signedOrder.takerAssetAmount.div(2)); - await deployment.exchange.fillOrKillOrder.awaitTransactionSuccessAsync( - signedOrders[0], - signedOrders[0].takerAssetAmount, - signedOrders[0].signature, - { from: taker.address, gasPrice: DeploymentManager.gasPrice, value: DeploymentManager.protocolFee }, - ); + await deployment.exchange + .fillOrKillOrder(signedOrders[0], signedOrders[0].takerAssetAmount, signedOrders[0].signature) + .awaitTransactionSuccessAsync({ + from: taker.address, + gasPrice: DeploymentManager.gasPrice, + value: DeploymentManager.protocolFee, + }); const orderHashHex = orderHashUtils.getOrderHashHex(signedOrders[0]); const expectedError = new ExchangeRevertErrors.OrderStatusError(orderHashHex, OrderStatus.FullyFilled); - const tx = deployment.exchange.batchFillOrKillOrders.awaitTransactionSuccessAsync( - signedOrders, - takerAssetFillAmounts, - signedOrders.map(order => order.signature), - { + const tx = deployment.exchange + .batchFillOrKillOrders( + signedOrders, + takerAssetFillAmounts, + signedOrders.map(order => order.signature), + ) + .awaitTransactionSuccessAsync({ from: taker.address, gasPrice: DeploymentManager.gasPrice, value: DeploymentManager.protocolFee.times(signedOrders.length), - }, - ); + }); return expect(tx).to.revertWith(expectedError); }); }); @@ -596,7 +594,7 @@ blockchainTests.resets('Exchange wrappers', env => { } } - const [fillResults, receipt] = await txHelper.getResultAndReceiptAsync( + const [fillResults, receipt] = await transactionHelper.getResultAndReceiptAsync( deployment.exchange.batchFillOrdersNoThrow, signedOrdersWithValidity.map(signedOrderWithValidity => signedOrderWithValidity.signedOrder), takerAssetFillAmounts, @@ -711,7 +709,7 @@ blockchainTests.resets('Exchange wrappers', env => { } } - const [fillResults, receipt] = await txHelper.getResultAndReceiptAsync( + const [fillResults, receipt] = await transactionHelper.getResultAndReceiptAsync( deployment.exchange.marketSellOrdersNoThrow, signedOrdersWithValidity.map(orderWithValidity => orderWithValidity.signedOrder), takerAssetFillAmount, @@ -781,9 +779,9 @@ blockchainTests.resets('Exchange wrappers', env => { }); it('should fill a signedOrder that does not use the same takerAssetAddress (eth protocol fee)', async () => { - const differentTakerAssetData = await devUtils.encodeERC20AssetData.callAsync( - deployment.tokens.erc20[2].address, - ); + const differentTakerAssetData = await devUtils + .encodeERC20AssetData(deployment.tokens.erc20[2].address) + .callAsync(); signedOrders = [ await maker.signOrderAsync(), @@ -804,9 +802,9 @@ blockchainTests.resets('Exchange wrappers', env => { }); it('should fill a signedOrder that does not use the same takerAssetAddress (weth protocol fee)', async () => { - const differentTakerAssetData = await devUtils.encodeERC20AssetData.callAsync( - deployment.tokens.erc20[2].address, - ); + const differentTakerAssetData = await devUtils + .encodeERC20AssetData(deployment.tokens.erc20[2].address) + .callAsync(); signedOrders = [ await maker.signOrderAsync(), @@ -909,7 +907,7 @@ blockchainTests.resets('Exchange wrappers', env => { } } - const [fillResults, receipt] = await txHelper.getResultAndReceiptAsync( + const [fillResults, receipt] = await transactionHelper.getResultAndReceiptAsync( deployment.exchange.marketBuyOrdersNoThrow, signedOrdersWithValidity.map(orderWithValidity => orderWithValidity.signedOrder), makerAssetFillAmount, @@ -979,9 +977,9 @@ blockchainTests.resets('Exchange wrappers', env => { }); it('should fill a signedOrder that does not use the same makerAssetAddress (eth protocol fee)', async () => { - const differentMakerAssetData = await devUtils.encodeERC20AssetData.callAsync( - deployment.tokens.erc20[2].address, - ); + const differentMakerAssetData = await devUtils + .encodeERC20AssetData(deployment.tokens.erc20[2].address) + .callAsync(); signedOrders = [ await maker.signOrderAsync(), @@ -1003,9 +1001,9 @@ blockchainTests.resets('Exchange wrappers', env => { }); it('should fill a signedOrder that does not use the same makerAssetAddress (weth protocol fee)', async () => { - const differentMakerAssetData = await devUtils.encodeERC20AssetData.callAsync( - deployment.tokens.erc20[2].address, - ); + const differentMakerAssetData = await devUtils + .encodeERC20AssetData(deployment.tokens.erc20[2].address) + .callAsync(); signedOrders = [ await maker.signOrderAsync(), @@ -1069,7 +1067,7 @@ blockchainTests.resets('Exchange wrappers', env => { describe('batchCancelOrders', () => { it('should be able to cancel multiple signedOrders', async () => { - const receipt = await deployment.exchange.batchCancelOrders.awaitTransactionSuccessAsync(signedOrders, { + const receipt = await deployment.exchange.batchCancelOrders(signedOrders).awaitTransactionSuccessAsync({ from: maker.address, }); const expectedOrderHashes = signedOrders.map(order => orderHashUtils.getOrderHashHex(order)); @@ -1080,13 +1078,13 @@ blockchainTests.resets('Exchange wrappers', env => { }); it('should not revert if a single cancel noops', async () => { - await deployment.exchange.cancelOrder.awaitTransactionSuccessAsync(signedOrders[1], { + await deployment.exchange.cancelOrder(signedOrders[1]).awaitTransactionSuccessAsync({ from: maker.address, }); const expectedOrderHashes = [signedOrders[0], ...signedOrders.slice(2)].map(order => orderHashUtils.getOrderHashHex(order), ); - const receipt = await deployment.exchange.batchCancelOrders.awaitTransactionSuccessAsync(signedOrders, { + const receipt = await deployment.exchange.batchCancelOrders(signedOrders).awaitTransactionSuccessAsync({ from: maker.address, }); diff --git a/contracts/integrations/test/internal-integration-tests/fillorder_test.ts b/contracts/integrations/test/internal-integration-tests/fillorder_test.ts index 16f532f609..21f556ad16 100644 --- a/contracts/integrations/test/internal-integration-tests/fillorder_test.ts +++ b/contracts/integrations/test/internal-integration-tests/fillorder_test.ts @@ -50,10 +50,10 @@ blockchainTests.resets('fillOrder integration tests', env => { }); const orderConfig = { feeRecipientAddress: feeRecipient.address, - makerAssetData: await devUtils.encodeERC20AssetData.callAsync(makerToken.address), - takerAssetData: await devUtils.encodeERC20AssetData.callAsync(takerToken.address), - makerFeeAssetData: await devUtils.encodeERC20AssetData.callAsync(makerToken.address), - takerFeeAssetData: await devUtils.encodeERC20AssetData.callAsync(takerToken.address), + makerAssetData: await devUtils.encodeERC20AssetData(makerToken.address).callAsync(), + takerAssetData: await devUtils.encodeERC20AssetData(takerToken.address).callAsync(), + makerFeeAssetData: await devUtils.encodeERC20AssetData(makerToken.address).callAsync(), + takerFeeAssetData: await devUtils.encodeERC20AssetData(takerToken.address).callAsync(), makerFee: constants.ZERO_AMOUNT, takerFee: constants.ZERO_AMOUNT, }; @@ -133,7 +133,7 @@ blockchainTests.resets('fillOrder integration tests', env => { taker.address, deployment.staking.stakingProxy.address, DeploymentManager.protocolFee, - await devUtils.encodeERC20AssetData.callAsync(deployment.tokens.weth.address), + await devUtils.encodeERC20AssetData(deployment.tokens.weth.address).callAsync(), ); } @@ -224,7 +224,7 @@ blockchainTests.resets('fillOrder integration tests', env => { // now expect a `StakingPoolEarnedRewardsInEpoch` event to be emitted because the staking // pool now has enough stake in the current epoch to earn rewards. verifyFillEvents(order, receipt); - const currentEpoch = await deployment.staking.stakingWrapper.currentEpoch.callAsync(); + const currentEpoch = await deployment.staking.stakingWrapper.currentEpoch().callAsync(); verifyEvents( receipt, [ @@ -253,7 +253,7 @@ blockchainTests.resets('fillOrder integration tests', env => { // End the epoch. This should wrap the staking proxy's ETH balance. const endEpochReceipt = await delegator.endEpochAsync(); - const newEpoch = await deployment.staking.stakingWrapper.currentEpoch.callAsync(); + const newEpoch = await deployment.staking.stakingWrapper.currentEpoch().callAsync(); // Check balances expectedBalances.wrapEth( @@ -295,7 +295,7 @@ blockchainTests.resets('fillOrder integration tests', env => { deployment.staking.stakingProxy.address, operator.address, operatorReward, - await devUtils.encodeERC20AssetData.callAsync(deployment.tokens.weth.address), + await devUtils.encodeERC20AssetData(deployment.tokens.weth.address).callAsync(), ); expectedBalances.burnGas(delegator.address, DeploymentManager.gasPrice.times(finalizePoolReceipt.gasUsed)); await balanceStore.updateBalancesAsync(); @@ -336,7 +336,7 @@ blockchainTests.resets('fillOrder integration tests', env => { await taker.fillOrderAsync(order, order.takerAssetAmount); // Check that the pool has collected fees from the above fill. - const poolStats = await deployment.staking.stakingWrapper.getStakingPoolStatsThisEpoch.callAsync(poolId); + const poolStats = await deployment.staking.stakingWrapper.getStakingPoolStatsThisEpoch(poolId).callAsync(); expect(poolStats.feesCollected).to.bignumber.equal(DeploymentManager.protocolFee); }); it('should collect WETH fees and pay out rewards', async () => { @@ -375,7 +375,7 @@ blockchainTests.resets('fillOrder integration tests', env => { deployment.staking.stakingProxy.address, operator.address, operatorReward, - await devUtils.encodeERC20AssetData.callAsync(deployment.tokens.weth.address), + await devUtils.encodeERC20AssetData(deployment.tokens.weth.address).callAsync(), ); expectedBalances.burnGas(delegator.address, DeploymentManager.gasPrice.times(finalizePoolReceipt.gasUsed)); await balanceStore.updateBalancesAsync(); diff --git a/contracts/integrations/test/utils/deployment_manager.ts b/contracts/integrations/test/utils/deployment_manager.ts index b67008cbf1..93a8ebd3a8 100644 --- a/contracts/integrations/test/utils/deployment_manager.ts +++ b/contracts/integrations/test/utils/deployment_manager.ts @@ -41,7 +41,7 @@ async function batchAddAuthorizedAddressAsync( ): Promise { for (const authorizer of authorizers) { for (const authority of authorities) { - await authorizer.addAuthorizedAddress.awaitTransactionSuccessAsync(authority, { from: owner }); + await authorizer.addAuthorizedAddress(authority).awaitTransactionSuccessAsync({ from: owner }); } } } @@ -59,7 +59,7 @@ async function batchRegisterAssetProxyAsync( ): Promise { for (const registry of registries) { for (const proxy of proxies) { - await registry.registerAssetProxy.awaitTransactionSuccessAsync(proxy, { from: owner }); + await registry.registerAssetProxy(proxy).awaitTransactionSuccessAsync({ from: owner }); } } } @@ -76,7 +76,7 @@ async function batchTransferOwnershipAsync( ownedContracts: Ownable[], ): Promise { for (const ownedContract of ownedContracts) { - await ownedContract.transferOwnership.awaitTransactionSuccessAsync(newOwner.address, { from: owner }); + await ownedContract.transferOwnership(newOwner.address).awaitTransactionSuccessAsync({ from: owner }); } } @@ -174,16 +174,16 @@ export class DeploymentManager { await DeploymentManager._configureExchangeWithStakingAsync(exchange, staking, owner); // Authorize the asset-proxy owner in the staking proxy and in the zrx vault. - await staking.stakingProxy.addAuthorizedAddress.awaitTransactionSuccessAsync(governor.address, { + await staking.stakingProxy.addAuthorizedAddress(governor.address).awaitTransactionSuccessAsync({ from: owner, }); - await staking.zrxVault.addAuthorizedAddress.awaitTransactionSuccessAsync(governor.address, { + await staking.zrxVault.addAuthorizedAddress(governor.address).awaitTransactionSuccessAsync({ from: owner, }); // Remove authorization for the original owner address. - await staking.stakingProxy.removeAuthorizedAddress.awaitTransactionSuccessAsync(owner, { from: owner }); - await staking.zrxVault.removeAuthorizedAddress.awaitTransactionSuccessAsync(owner, { from: owner }); + await staking.stakingProxy.removeAuthorizedAddress(owner).awaitTransactionSuccessAsync({ from: owner }); + await staking.zrxVault.removeAuthorizedAddress(owner).awaitTransactionSuccessAsync({ from: owner }); // Transfer complete ownership of the system to the asset proxy owner. await batchTransferOwnershipAsync(owner, governor, [ @@ -266,13 +266,13 @@ export class DeploymentManager { owner: string, ): Promise { // Configure the exchange for staking. - await exchange.setProtocolFeeCollectorAddress.awaitTransactionSuccessAsync(staking.stakingProxy.address, { + await exchange.setProtocolFeeCollectorAddress(staking.stakingProxy.address).awaitTransactionSuccessAsync({ from: owner, }); - await exchange.setProtocolFeeMultiplier.awaitTransactionSuccessAsync(DeploymentManager.protocolFeeMultiplier); + await exchange.setProtocolFeeMultiplier(DeploymentManager.protocolFeeMultiplier).awaitTransactionSuccessAsync(); // Register the exchange contract in staking. - await staking.stakingWrapper.addExchangeAddress.awaitTransactionSuccessAsync(exchange.address, { from: owner }); + await staking.stakingWrapper.addExchangeAddress(exchange.address).awaitTransactionSuccessAsync({ from: owner }); } /** @@ -365,20 +365,20 @@ export class DeploymentManager { const stakingWrapper = new TestStakingContract(stakingProxy.address, environment.provider, txDefaults); // Add the zrx vault and the weth contract to the staking proxy. - await stakingWrapper.setWethContract.awaitTransactionSuccessAsync(tokens.weth.address, { from: owner }); - await stakingWrapper.setZrxVault.awaitTransactionSuccessAsync(zrxVault.address, { from: owner }); + await stakingWrapper.setWethContract(tokens.weth.address).awaitTransactionSuccessAsync({ from: owner }); + await stakingWrapper.setZrxVault(zrxVault.address).awaitTransactionSuccessAsync({ from: owner }); // Authorize the owner address in the staking proxy and the zrx vault. - await stakingProxy.addAuthorizedAddress.awaitTransactionSuccessAsync(owner, { from: owner }); - await zrxVault.addAuthorizedAddress.awaitTransactionSuccessAsync(owner, { from: owner }); + await stakingProxy.addAuthorizedAddress(owner).awaitTransactionSuccessAsync({ from: owner }); + await zrxVault.addAuthorizedAddress(owner).awaitTransactionSuccessAsync({ from: owner }); // Authorize the zrx vault in the erc20 proxy - await assetProxies.erc20Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(zrxVault.address, { + await assetProxies.erc20Proxy.addAuthorizedAddress(zrxVault.address).awaitTransactionSuccessAsync({ from: owner, }); // Configure the zrx vault and the staking contract. - await zrxVault.setStakingProxy.awaitTransactionSuccessAsync(stakingProxy.address, { from: owner }); + await zrxVault.setStakingProxy(stakingProxy.address).awaitTransactionSuccessAsync({ from: owner }); return { stakingLogic, diff --git a/contracts/integrations/test/utils/function_assertions.ts b/contracts/integrations/test/utils/function_assertions.ts index 37ebceb2cc..c3bb3c6ccf 100644 --- a/contracts/integrations/test/utils/function_assertions.ts +++ b/contracts/integrations/test/utils/function_assertions.ts @@ -1,16 +1,10 @@ -import { PromiseWithTransactionHash } from '@0x/base-contract'; +import { ContractFunctionObj, ContractTxFunctionObj, PromiseWithTransactionHash } from '@0x/base-contract'; import { TransactionReceiptWithDecodedLogs } from 'ethereum-types'; import * as _ from 'lodash'; // tslint:disable:max-classes-per-file -export interface ContractGetterFunction { - callAsync: (...args: any[]) => Promise; -} - -export interface ContractWrapperFunction extends ContractGetterFunction { - awaitTransactionSuccessAsync?: (...args: any[]) => PromiseWithTransactionHash; -} +export type GenericContractFunction = (...args: any[]) => ContractFunctionObj; export interface Result { data?: any; @@ -53,14 +47,21 @@ export interface RunResult { * This class implements `Assertion` and represents a "Hoare Triple" that can be * executed. */ -export class FunctionAssertion implements Assertion { +export class FunctionAssertion implements Assertion { // A condition that will be applied to `wrapperFunction`. public condition: Condition; // The wrapper function that will be wrapped in assertions. - public wrapperFunction: ContractWrapperFunction; + public wrapperFunction: ( + ...args: any[] + ) => ContractTxFunctionObj | ContractFunctionObj; - constructor(wrapperFunction: ContractWrapperFunction, condition: Partial> = {}) { + constructor( + wrapperFunction: ( + ...args: any[] + ) => ContractTxFunctionObj | ContractFunctionObj, + condition: Partial> = {}, + ) { this.condition = { before: _.noop.bind(this), after: _.noop.bind(this), @@ -83,10 +84,11 @@ export class FunctionAssertion implements Assertion { // Try to make the call to the function. If it is successful, pass the // result and receipt to the after condition. try { - callResult.data = await this.wrapperFunction.callAsync(...args); + const functionWithArgs = this.wrapperFunction(...args) as ContractTxFunctionObj; + callResult.data = await functionWithArgs.callAsync(); callResult.receipt = - this.wrapperFunction.awaitTransactionSuccessAsync !== undefined - ? await this.wrapperFunction.awaitTransactionSuccessAsync(...args) + functionWithArgs.awaitTransactionSuccessAsync !== undefined + ? await functionWithArgs.awaitTransactionSuccessAsync() : undefined; } catch (error) { callResult.data = error; diff --git a/contracts/multisig/test/multi_sig_with_time_lock.ts b/contracts/multisig/test/multi_sig_with_time_lock.ts index 6f59a7f60b..3eff2c87ea 100644 --- a/contracts/multisig/test/multi_sig_with_time_lock.ts +++ b/contracts/multisig/test/multi_sig_with_time_lock.ts @@ -125,9 +125,9 @@ describe('MultiSigWalletWithTimeLock', () => { }); it('should confirm transaction for caller but not reset the confirmation time if tx is already fully confirmed', async () => { await multiSigWrapper.confirmTransactionAsync(txId, owners[1]); - const confirmationTimeBefore = await multiSig.confirmationTimes.callAsync(txId); + const confirmationTimeBefore = await multiSig.confirmationTimes(txId).callAsync(); const txReceipt = await multiSigWrapper.confirmTransactionAsync(txId, owners[2]); - const confirmationTimeAfter = await multiSig.confirmationTimes.callAsync(txId); + const confirmationTimeAfter = await multiSig.confirmationTimes(txId).callAsync(); expect(confirmationTimeBefore).to.bignumber.equal(confirmationTimeAfter); expect(txReceipt.logs.length).to.equal(1); const log = txReceipt.logs[0] as LogWithDecodedArgs; @@ -255,25 +255,25 @@ describe('MultiSigWalletWithTimeLock', () => { it('should revert when not called by wallet', async () => { return expectTransactionFailedWithoutReasonAsync( - multiSig.changeTimeLock.sendTransactionAsync(SECONDS_TIME_LOCKED, { from: owners[0] }), + multiSig.changeTimeLock(SECONDS_TIME_LOCKED).sendTransactionAsync({ from: owners[0] }), ); }); it('should revert without enough confirmations', async () => { const destination = multiSig.address; - const changeTimeLockData = multiSig.changeTimeLock.getABIEncodedTransactionData(SECONDS_TIME_LOCKED); + const changeTimeLockData = multiSig.changeTimeLock(SECONDS_TIME_LOCKED).getABIEncodedTransactionData(); const res = await multiSigWrapper.submitTransactionAsync(destination, changeTimeLockData, owners[0]); const log = res.logs[0] as LogWithDecodedArgs; const txId = log.args.transactionId; return expectTransactionFailedAsync( - multiSig.executeTransaction.sendTransactionAsync(txId, { from: owners[0] }), + multiSig.executeTransaction(txId).sendTransactionAsync({ from: owners[0] }), RevertReason.TxNotFullyConfirmed, ); }); it('should set confirmation time with enough confirmations', async () => { const destination = multiSig.address; - const changeTimeLockData = multiSig.changeTimeLock.getABIEncodedTransactionData(SECONDS_TIME_LOCKED); + const changeTimeLockData = multiSig.changeTimeLock(SECONDS_TIME_LOCKED).getABIEncodedTransactionData(); const subRes = await multiSigWrapper.submitTransactionAsync(destination, changeTimeLockData, owners[0]); const subLog = subRes.logs[0] as LogWithDecodedArgs; const txId = subLog.args.transactionId; @@ -287,14 +287,14 @@ describe('MultiSigWalletWithTimeLock', () => { throw new Error(`Unexpectedly failed to fetch block at #${blockNum}`); } const timestamp = new BigNumber(blockInfo.timestamp); - const confirmationTimeBigNum = new BigNumber(await multiSig.confirmationTimes.callAsync(txId)); + const confirmationTimeBigNum = new BigNumber(await multiSig.confirmationTimes(txId).callAsync()); expect(timestamp).to.be.bignumber.equal(confirmationTimeBigNum); }); it('should be executable with enough confirmations and secondsTimeLocked of 0', async () => { const destination = multiSig.address; - const changeTimeLockData = multiSig.changeTimeLock.getABIEncodedTransactionData(SECONDS_TIME_LOCKED); + const changeTimeLockData = multiSig.changeTimeLock(SECONDS_TIME_LOCKED).getABIEncodedTransactionData(); const subRes = await multiSigWrapper.submitTransactionAsync(destination, changeTimeLockData, owners[0]); const subLog = subRes.logs[0] as LogWithDecodedArgs; const txId = subLog.args.transactionId; @@ -302,7 +302,7 @@ describe('MultiSigWalletWithTimeLock', () => { await multiSigWrapper.confirmTransactionAsync(txId, owners[1]); await multiSigWrapper.executeTransactionAsync(txId, owners[1]); - const secondsTimeLocked = new BigNumber(await multiSig.secondsTimeLocked.callAsync()); + const secondsTimeLocked = new BigNumber(await multiSig.secondsTimeLocked().callAsync()); expect(secondsTimeLocked).to.be.bignumber.equal(SECONDS_TIME_LOCKED); }); }); @@ -327,7 +327,7 @@ describe('MultiSigWalletWithTimeLock', () => { ); multiSigWrapper = new MultiSigWrapper(multiSig, provider); - const changeTimeLockData = multiSig.changeTimeLock.getABIEncodedTransactionData(newSecondsTimeLocked); + const changeTimeLockData = multiSig.changeTimeLock(newSecondsTimeLocked).getABIEncodedTransactionData(); const res = await multiSigWrapper.submitTransactionAsync( multiSig.address, changeTimeLockData, @@ -340,19 +340,21 @@ describe('MultiSigWalletWithTimeLock', () => { it('should revert if it has enough confirmations but is not past the time lock', async () => { return expectTransactionFailedAsync( - multiSig.executeTransaction.sendTransactionAsync(txId, { from: owners[0] }), + multiSig.executeTransaction(txId).sendTransactionAsync({ from: owners[0] }), RevertReason.TimeLockIncomplete, ); }); it('should execute if it has enough confirmations and is past the time lock', async () => { await increaseTimeAndMineBlockAsync(SECONDS_TIME_LOCKED.toNumber()); - await web3Wrapper.awaitTransactionSuccessAsync( - await multiSig.executeTransaction.sendTransactionAsync(txId, { from: owners[0] }), - constants.AWAIT_TRANSACTION_MINED_MS, - ); + await multiSig + .executeTransaction(txId) + .awaitTransactionSuccessAsync( + { from: owners[0] }, + { pollingIntervalMs: constants.AWAIT_TRANSACTION_MINED_MS }, + ); - const secondsTimeLocked = new BigNumber(await multiSig.secondsTimeLocked.callAsync()); + const secondsTimeLocked = new BigNumber(await multiSig.secondsTimeLocked().callAsync()); expect(secondsTimeLocked).to.be.bignumber.equal(newSecondsTimeLocked); }); }); diff --git a/contracts/multisig/test/utils/multi_sig_wrapper.ts b/contracts/multisig/test/utils/multi_sig_wrapper.ts index 11f2ce51eb..077d577272 100644 --- a/contracts/multisig/test/utils/multi_sig_wrapper.ts +++ b/contracts/multisig/test/utils/multi_sig_wrapper.ts @@ -25,19 +25,19 @@ export class MultiSigWrapper { opts: { value?: BigNumber } = {}, ): Promise { const value = opts.value === undefined ? new BigNumber(0) : opts.value; - const txHash = await this._multiSig.submitTransaction.sendTransactionAsync(destination, value, data, { + const txHash = await this._multiSig.submitTransaction(destination, value, data).sendTransactionAsync({ from, }); const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash); return tx; } public async confirmTransactionAsync(txId: BigNumber, from: string): Promise { - const txHash = await this._multiSig.confirmTransaction.sendTransactionAsync(txId, { from }); + const txHash = await this._multiSig.confirmTransaction(txId).sendTransactionAsync({ from }); const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash); return tx; } public async revokeConfirmationAsync(txId: BigNumber, from: string): Promise { - const txHash = await this._multiSig.revokeConfirmation.sendTransactionAsync(txId, { from }); + const txHash = await this._multiSig.revokeConfirmation(txId).sendTransactionAsync({ from }); const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash); return tx; } @@ -46,7 +46,7 @@ export class MultiSigWrapper { from: string, opts: { gas?: number } = {}, ): Promise { - const txHash = await this._multiSig.executeTransaction.sendTransactionAsync(txId, { + const txHash = await this._multiSig.executeTransaction(txId).sendTransactionAsync({ from, gas: opts.gas, }); diff --git a/contracts/multisig/test/utils/zero_ex_governor_wrapper.ts b/contracts/multisig/test/utils/zero_ex_governor_wrapper.ts index 19a0688fd9..8adcdc8435 100644 --- a/contracts/multisig/test/utils/zero_ex_governor_wrapper.ts +++ b/contracts/multisig/test/utils/zero_ex_governor_wrapper.ts @@ -20,12 +20,13 @@ export class ZeroExGovernorWrapper { const values = opts.values === undefined ? data.map(() => constants.ZERO_AMOUNT) : opts.values; const batchTransactionEncoder = AbiEncoder.create('(bytes[],address[],uint256[])'); const batchTransactionData = batchTransactionEncoder.encode([data, destinations, values]); - const txReceipt = await this._governor.submitTransaction.awaitTransactionSuccessAsync( - hexRandom(20), // submitTransaction will fail if this is a null address - constants.ZERO_AMOUNT, - batchTransactionData, - { from }, - ); + const txReceipt = await this._governor + .submitTransaction( + hexRandom(20), // submitTransaction will fail if this is a null address + constants.ZERO_AMOUNT, + batchTransactionData, + ) + .awaitTransactionSuccessAsync({ from }); const txId = (txReceipt.logs[0] as LogWithDecodedArgs).args.transactionId; return { txReceipt, txId }; } @@ -39,15 +40,16 @@ export class ZeroExGovernorWrapper { const submitResults = await this.submitTransactionAsync(data, destinations, signerAddresses[0], opts); const requiredSignatures = opts.requiredSignatures === undefined ? 2 : opts.requiredSignatures; for (const index of _.range(1, requiredSignatures)) { - await this._governor.confirmTransaction.awaitTransactionSuccessAsync(submitResults.txId, { + await this._governor.confirmTransaction(submitResults.txId).awaitTransactionSuccessAsync({ from: signerAddresses[index], }); } await increaseTimeAndMineBlockAsync(increaseTimeSeconds); - const executionTxReceipt = await this._governor.executeTransaction.awaitTransactionSuccessAsync( - submitResults.txId, - { from: opts.executeFromAddress === undefined ? signerAddresses[0] : opts.executeFromAddress }, - ); + const executionTxReceipt = await this._governor + .executeTransaction(submitResults.txId) + .awaitTransactionSuccessAsync({ + from: opts.executeFromAddress === undefined ? signerAddresses[0] : opts.executeFromAddress, + }); return { executionTxReceipt, txId: submitResults.txId }; } } diff --git a/contracts/multisig/test/zero_ex_governor.ts b/contracts/multisig/test/zero_ex_governor.ts index 9615070613..ff2345b036 100644 --- a/contracts/multisig/test/zero_ex_governor.ts +++ b/contracts/multisig/test/zero_ex_governor.ts @@ -157,10 +157,9 @@ blockchainTests.resets('ZeroExGovernor', env => { new BigNumber(REQUIRED_SIGNERS), new BigNumber(DEFAULT_TIME_LOCK), ); - const timelock = await governorContract.functionCallTimeLocks.callAsync( - reg.functionSelectors[0], - reg.destinations[0], - ); + const timelock = await governorContract + .functionCallTimeLocks(reg.functionSelectors[0], reg.destinations[0]) + .callAsync(); expect(timelock[0]).to.equal(true); expect(timelock[1]).to.bignumber.equal(reg.functionCallTimeLockSeconds[0]); }); @@ -179,10 +178,9 @@ blockchainTests.resets('ZeroExGovernor', env => { new BigNumber(DEFAULT_TIME_LOCK), ); for (const [index, selector] of reg.functionSelectors.entries()) { - const timelock = await governorContract.functionCallTimeLocks.callAsync( - selector, - reg.destinations[index], - ); + const timelock = await governorContract + .functionCallTimeLocks(selector, reg.destinations[index]) + .callAsync(); expect(timelock[0]).to.equal(true); expect(timelock[1]).to.bignumber.equal(reg.functionCallTimeLockSeconds[index]); } @@ -192,23 +190,26 @@ blockchainTests.resets('ZeroExGovernor', env => { blockchainTests.resets('registerFunctionCall', () => { it('should revert if not called by wallet', async () => { const reg = createFunctionRegistration(1, 1, 1); - const tx = governor.registerFunctionCall.awaitTransactionSuccessAsync( - true, - reg.functionSelectors[0], - reg.destinations[0], - reg.functionCallTimeLockSeconds[0], - { from: signerAddresses[0] }, - ); + const tx = governor + .registerFunctionCall( + true, + reg.functionSelectors[0], + reg.destinations[0], + reg.functionCallTimeLockSeconds[0], + ) + .awaitTransactionSuccessAsync({ from: signerAddresses[0] }); expect(tx).to.revertWith(RevertReason.OnlyCallableByWallet); }); it('should register a function call', async () => { const reg = createFunctionRegistration(1, 1, 1); - const txReceipt = await governor.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync( - true, - reg.functionSelectors[0], - reg.destinations[0], - reg.functionCallTimeLockSeconds[0], - ); + const txReceipt = await governor + .registerFunctionCallBypassWallet( + true, + reg.functionSelectors[0], + reg.destinations[0], + reg.functionCallTimeLockSeconds[0], + ) + .awaitTransactionSuccessAsync(); expect(txReceipt.logs.length).to.eq(1); const logArgs = (txReceipt.logs[0] as LogWithDecodedArgs< ZeroExGovernorFunctionCallTimeLockRegistrationEventArgs @@ -217,53 +218,53 @@ blockchainTests.resets('ZeroExGovernor', env => { expect(logArgs.destination).to.eq(reg.destinations[0]); expect(logArgs.hasCustomTimeLock).to.eq(true); expect(logArgs.newSecondsTimeLocked).to.bignumber.eq(reg.functionCallTimeLockSeconds[0]); - const timelock = await governor.functionCallTimeLocks.callAsync( - reg.functionSelectors[0], - reg.destinations[0], - ); + const timelock = await governor + .functionCallTimeLocks(reg.functionSelectors[0], reg.destinations[0]) + .callAsync(); expect(timelock[0]).to.equal(true); expect(timelock[1]).to.bignumber.equal(reg.functionCallTimeLockSeconds[0]); }); it('should be able to overwrite existing function calls', async () => { const reg = createFunctionRegistration(1, 1, 1); - await governor.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync( - true, - reg.functionSelectors[0], - reg.destinations[0], - reg.functionCallTimeLockSeconds[0], - ); + await governor + .registerFunctionCallBypassWallet( + true, + reg.functionSelectors[0], + reg.destinations[0], + reg.functionCallTimeLockSeconds[0], + ) + .awaitTransactionSuccessAsync(); const newTimeLock = reg.functionCallTimeLockSeconds[0].plus(1000); - await governor.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync( - true, - reg.functionSelectors[0], - reg.destinations[0], - newTimeLock, - ); - const timelock = await governor.functionCallTimeLocks.callAsync( - reg.functionSelectors[0], - reg.destinations[0], - ); + await governor + .registerFunctionCallBypassWallet(true, reg.functionSelectors[0], reg.destinations[0], newTimeLock) + .awaitTransactionSuccessAsync(); + const timelock = await governor + .functionCallTimeLocks(reg.functionSelectors[0], reg.destinations[0]) + .callAsync(); expect(timelock[0]).to.equal(true); expect(timelock[1]).to.bignumber.equal(newTimeLock); }); it('should clear the function timelock if hasCustomTimeLock is set to false', async () => { const reg = createFunctionRegistration(1, 1, 1); - await governor.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync( - true, - reg.functionSelectors[0], - reg.destinations[0], - reg.functionCallTimeLockSeconds[0], - ); - await governor.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync( - false, - reg.functionSelectors[0], - reg.destinations[0], - reg.functionCallTimeLockSeconds[0], - ); - const timelock = await governor.functionCallTimeLocks.callAsync( - reg.functionSelectors[0], - reg.destinations[0], - ); + await governor + .registerFunctionCallBypassWallet( + true, + reg.functionSelectors[0], + reg.destinations[0], + reg.functionCallTimeLockSeconds[0], + ) + .awaitTransactionSuccessAsync(); + await governor + .registerFunctionCallBypassWallet( + false, + reg.functionSelectors[0], + reg.destinations[0], + reg.functionCallTimeLockSeconds[0], + ) + .awaitTransactionSuccessAsync(); + const timelock = await governor + .functionCallTimeLocks(reg.functionSelectors[0], reg.destinations[0]) + .callAsync(); expect(timelock[0]).to.equal(false); expect(timelock[1]).to.bignumber.equal(constants.ZERO_AMOUNT); }); @@ -271,11 +272,9 @@ blockchainTests.resets('ZeroExGovernor', env => { describe('assertValidFunctionCall', () => { it('should revert if the data is less than 4 bytes long', async () => { - const result = governor.assertValidFunctionCall.callAsync( - constants.ZERO_AMOUNT, - constants.NULL_BYTES, - constants.NULL_ADDRESS, - ); + const result = governor + .assertValidFunctionCall(constants.ZERO_AMOUNT, constants.NULL_BYTES, constants.NULL_ADDRESS) + .callAsync(); const expectedError = new LibBytesRevertErrors.InvalidByteOperationError( LibBytesRevertErrors.InvalidByteOperationErrorCodes.LengthGreaterThanOrEqualsFourRequired, constants.ZERO_AMOUNT, @@ -287,91 +286,87 @@ blockchainTests.resets('ZeroExGovernor', env => { const latestTimestamp = await getLatestBlockTimestampAsync(); const transactionConfirmationTime = new BigNumber(latestTimestamp); const reg = createFunctionRegistration(1, 1, 1); - const result = governor.assertValidFunctionCall.callAsync( - transactionConfirmationTime, - reg.functionSelectors[0], - reg.destinations[0], - ); + const result = governor + .assertValidFunctionCall(transactionConfirmationTime, reg.functionSelectors[0], reg.destinations[0]) + .callAsync(); expect(result).to.revertWith(RevertReason.DefaultTimeLockIncomplete); }); it('should revert if a registered function is called before the custom timelock', async () => { const reg = createFunctionRegistration(1, 1, 1); - await governor.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync( - true, - reg.functionSelectors[0], - reg.destinations[0], - reg.functionCallTimeLockSeconds[0], - ); + await governor + .registerFunctionCallBypassWallet( + true, + reg.functionSelectors[0], + reg.destinations[0], + reg.functionCallTimeLockSeconds[0], + ) + .awaitTransactionSuccessAsync(); const latestTimestamp = await getLatestBlockTimestampAsync(); const transactionConfirmationTime = new BigNumber(latestTimestamp); - const result = governor.assertValidFunctionCall.callAsync( - transactionConfirmationTime, - reg.functionSelectors[0], - reg.destinations[0], - ); + const result = governor + .assertValidFunctionCall(transactionConfirmationTime, reg.functionSelectors[0], reg.destinations[0]) + .callAsync(); expect(result).to.revertWith(RevertReason.CustomTimeLockIncomplete); }); it('should revert if a registered function is called before the custom timelock and after the default timelock', async () => { const reg = createFunctionRegistration(1, 1, 1); - await governor.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync( - true, - reg.functionSelectors[0], - reg.destinations[0], - new BigNumber(DEFAULT_TIME_LOCK).times(2), - ); + await governor + .registerFunctionCallBypassWallet( + true, + reg.functionSelectors[0], + reg.destinations[0], + new BigNumber(DEFAULT_TIME_LOCK).times(2), + ) + .awaitTransactionSuccessAsync(); const latestTimestamp = await getLatestBlockTimestampAsync(); const transactionConfirmationTime = new BigNumber(latestTimestamp).minus(DEFAULT_TIME_LOCK); - const result = governor.assertValidFunctionCall.callAsync( - transactionConfirmationTime, - reg.functionSelectors[0], - reg.destinations[0], - ); + const result = governor + .assertValidFunctionCall(transactionConfirmationTime, reg.functionSelectors[0], reg.destinations[0]) + .callAsync(); expect(result).to.revertWith(RevertReason.CustomTimeLockIncomplete); }); it('should be successful if an unregistered function is called after the default timelock', async () => { const latestTimestamp = await getLatestBlockTimestampAsync(); const transactionConfirmationTime = new BigNumber(latestTimestamp).minus(DEFAULT_TIME_LOCK); const reg = createFunctionRegistration(1, 1, 1); - const result = governor.assertValidFunctionCall.callAsync( - transactionConfirmationTime, - reg.functionSelectors[0], - reg.destinations[0], - ); + const result = governor + .assertValidFunctionCall(transactionConfirmationTime, reg.functionSelectors[0], reg.destinations[0]) + .callAsync(); expect(result).to.be.fulfilled(''); }); it('should be successful if a registered function is called after the custom timelock', async () => { const reg = createFunctionRegistration(1, 1, 1); - await governor.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync( - true, - reg.functionSelectors[0], - reg.destinations[0], - reg.functionCallTimeLockSeconds[0], - ); + await governor + .registerFunctionCallBypassWallet( + true, + reg.functionSelectors[0], + reg.destinations[0], + reg.functionCallTimeLockSeconds[0], + ) + .awaitTransactionSuccessAsync(); const latestTimestamp = await getLatestBlockTimestampAsync(); const transactionConfirmationTime = new BigNumber(latestTimestamp).minus( reg.functionCallTimeLockSeconds[0], ); - const result = governor.assertValidFunctionCall.callAsync( - transactionConfirmationTime, - reg.functionSelectors[0], - reg.destinations[0], - ); + const result = governor + .assertValidFunctionCall(transactionConfirmationTime, reg.functionSelectors[0], reg.destinations[0]) + .callAsync(); expect(result).to.be.fulfilled(''); }); it('should allow a custom timelock to be set to 0', async () => { const reg = createFunctionRegistration(1, 1, 1); - await governor.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync( - true, - reg.functionSelectors[0], - reg.destinations[0], - constants.ZERO_AMOUNT, - ); + await governor + .registerFunctionCallBypassWallet( + true, + reg.functionSelectors[0], + reg.destinations[0], + constants.ZERO_AMOUNT, + ) + .awaitTransactionSuccessAsync(); const latestTimestamp = await getLatestBlockTimestampAsync(); - const result = governor.assertValidFunctionCall.callAsync( - new BigNumber(latestTimestamp), - reg.functionSelectors[0], - reg.destinations[0], - ); + const result = governor + .assertValidFunctionCall(new BigNumber(latestTimestamp), reg.functionSelectors[0], reg.destinations[0]) + .callAsync(); expect(result).to.be.fulfilled(''); }); }); @@ -401,7 +396,7 @@ blockchainTests.resets('ZeroExGovernor', env => { const data = [hexRandom()]; const destinations = [receiver.address]; const results = await governorWrapper.submitTransactionAsync(data, destinations, signerAddresses[0]); - const tx = governor.executeTransaction.awaitTransactionSuccessAsync(results.txId, { + const tx = governor.executeTransaction(results.txId).awaitTransactionSuccessAsync({ from: signerAddresses[1], }); expect(tx).to.revertWith(RevertReason.TxNotFullyConfirmed); @@ -410,7 +405,7 @@ blockchainTests.resets('ZeroExGovernor', env => { const data = [hexRandom()]; const destinations = [receiver.address]; const results = await governorWrapper.submitTransactionAsync(data, destinations, signerAddresses[0]); - const tx = governor.executeTransaction.awaitTransactionSuccessAsync(results.txId, { + const tx = governor.executeTransaction(results.txId).awaitTransactionSuccessAsync({ from: signerAddresses[0], }); expect(tx).to.revertWith(RevertReason.TxNotFullyConfirmed); @@ -443,12 +438,9 @@ blockchainTests.resets('ZeroExGovernor', env => { const data = [hexRandom()]; const destinations = [receiver.address]; const newTimeLock = new BigNumber(DEFAULT_TIME_LOCK).dividedToIntegerBy(2); - await governor.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync( - true, - data[0].slice(0, 10), - receiver.address, - newTimeLock, - ); + await governor + .registerFunctionCallBypassWallet(true, data[0].slice(0, 10), receiver.address, newTimeLock) + .awaitTransactionSuccessAsync(); const results = await governorWrapper.submitConfirmAndExecuteTransactionAsync( data, destinations, @@ -461,12 +453,9 @@ blockchainTests.resets('ZeroExGovernor', env => { const data = [hexRandom()]; const destinations = [receiver.address]; const newTimeLock = constants.ZERO_AMOUNT; - await governor.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync( - true, - data[0].slice(0, 10), - receiver.address, - newTimeLock, - ); + await governor + .registerFunctionCallBypassWallet(true, data[0].slice(0, 10), receiver.address, newTimeLock) + .awaitTransactionSuccessAsync(); const results = await governorWrapper.submitConfirmAndExecuteTransactionAsync( data, destinations, @@ -479,12 +468,9 @@ blockchainTests.resets('ZeroExGovernor', env => { const data = [hexRandom()]; const destinations = [receiver.address]; const newTimeLock = new BigNumber(DEFAULT_TIME_LOCK).dividedToIntegerBy(2); - await governor.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync( - true, - data[0].slice(0, 10), - receiver.address, - newTimeLock, - ); + await governor + .registerFunctionCallBypassWallet(true, data[0].slice(0, 10), receiver.address, newTimeLock) + .awaitTransactionSuccessAsync(); const values = [INITIAL_BALANCE]; const results = await governorWrapper.submitConfirmAndExecuteTransactionAsync( data, @@ -529,12 +515,9 @@ blockchainTests.resets('ZeroExGovernor', env => { const data = [hexRandom(), hexRandom()]; const destinations = [receiver.address, receiver.address]; const newTimeLock = new BigNumber(DEFAULT_TIME_LOCK).dividedToIntegerBy(2); - await governor.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync( - true, - data[0].slice(0, 10), - receiver.address, - newTimeLock, - ); + await governor + .registerFunctionCallBypassWallet(true, data[0].slice(0, 10), receiver.address, newTimeLock) + .awaitTransactionSuccessAsync(); const results = await governorWrapper.submitConfirmAndExecuteTransactionAsync( data, destinations, @@ -547,12 +530,9 @@ blockchainTests.resets('ZeroExGovernor', env => { const data = [hexRandom(), hexRandom()]; const destinations = [receiver.address, receiver.address]; const newTimeLock = new BigNumber(DEFAULT_TIME_LOCK).dividedToIntegerBy(2); - await governor.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync( - true, - data[0].slice(0, 10), - receiver.address, - newTimeLock, - ); + await governor + .registerFunctionCallBypassWallet(true, data[0].slice(0, 10), receiver.address, newTimeLock) + .awaitTransactionSuccessAsync(); const tx = governorWrapper.submitConfirmAndExecuteTransactionAsync( data, destinations, @@ -629,7 +609,7 @@ blockchainTests.resets('ZeroExGovernor', env => { signerAddresses, DEFAULT_TIME_LOCK, ); - const tx = governor.executeTransaction.awaitTransactionSuccessAsync(results.txId); + const tx = governor.executeTransaction(results.txId).awaitTransactionSuccessAsync(); expect(tx).to.revertWith(RevertReason.TxAlreadyExecuted); }); it('should revert if the only call is unsuccessful', async () => { @@ -659,12 +639,14 @@ blockchainTests.resets('ZeroExGovernor', env => { it('should be able to call registerFunctionCall after the default timelock', async () => { const reg = createFunctionRegistration(1, 1, 1); const data = [ - governor.registerFunctionCall.getABIEncodedTransactionData( - true, - reg.functionSelectors[0], - reg.destinations[0], - reg.functionCallTimeLockSeconds[0], - ), + governor + .registerFunctionCall( + true, + reg.functionSelectors[0], + reg.destinations[0], + reg.functionCallTimeLockSeconds[0], + ) + .getABIEncodedTransactionData(), ]; const destinations = [governor.address]; const results = await governorWrapper.submitConfirmAndExecuteTransactionAsync( diff --git a/contracts/staking/test/actors/finalizer_actor.ts b/contracts/staking/test/actors/finalizer_actor.ts index 2d2e099b3c..08a95554e0 100644 --- a/contracts/staking/test/actors/finalizer_actor.ts +++ b/contracts/staking/test/actors/finalizer_actor.ts @@ -131,9 +131,9 @@ export class FinalizerActor extends BaseActor { for (const delegator of delegators) { let balance = new BigNumber(delegatorBalancesByPoolId[poolId][delegator] || 0); if (delegator === operator) { - balance = balance.plus(await computeRewardBalanceOfOperator.callAsync(poolId)); + balance = balance.plus(await computeRewardBalanceOfOperator(poolId).callAsync()); } else { - balance = balance.plus(await computeRewardBalanceOfDelegator.callAsync(poolId, delegator)); + balance = balance.plus(await computeRewardBalanceOfDelegator(poolId, delegator).callAsync()); } delegatorBalancesByPoolId[poolId][delegator] = balance; } @@ -150,10 +150,10 @@ export class FinalizerActor extends BaseActor { const delegators = delegatorsByPoolId[poolId]; delegatorBalancesByPoolId[poolId] = {}; for (const delegator of delegators) { - delegatorBalancesByPoolId[poolId][delegator] = (await getStakeDelegatedToPoolByOwner.callAsync( + delegatorBalancesByPoolId[poolId][delegator] = (await getStakeDelegatedToPoolByOwner( delegator, poolId, - )).currentEpochBalance; + ).callAsync()).currentEpochBalance; } } return delegatorBalancesByPoolId; @@ -208,9 +208,9 @@ export class FinalizerActor extends BaseActor { ): Promise { const operatorBalanceByPoolId: OperatorBalanceByPoolId = {}; for (const poolId of Object.keys(operatorByPoolId)) { - operatorBalanceByPoolId[poolId] = await this._stakingApiWrapper.wethContract.balanceOf.callAsync( - operatorByPoolId[poolId], - ); + operatorBalanceByPoolId[poolId] = await this._stakingApiWrapper.wethContract + .balanceOf(operatorByPoolId[poolId]) + .callAsync(); } return operatorBalanceByPoolId; } @@ -219,7 +219,7 @@ export class FinalizerActor extends BaseActor { const operatorShareByPoolId: OperatorShareByPoolId = {}; for (const poolId of poolIds) { operatorShareByPoolId[poolId] = new BigNumber( - (await this._stakingApiWrapper.stakingContract.getStakingPool.callAsync(poolId)).operatorShare, + (await this._stakingApiWrapper.stakingContract.getStakingPool(poolId).callAsync()).operatorShare, ); } return operatorShareByPoolId; @@ -228,9 +228,9 @@ export class FinalizerActor extends BaseActor { private async _getRewardBalanceByPoolIdAsync(poolIds: string[]): Promise { const rewardBalanceByPoolId: RewardBalanceByPoolId = {}; for (const poolId of poolIds) { - rewardBalanceByPoolId[poolId] = await this._stakingApiWrapper.stakingContract.rewardsByPoolId.callAsync( - poolId, - ); + rewardBalanceByPoolId[poolId] = await this._stakingApiWrapper.stakingContract + .rewardsByPoolId(poolId) + .callAsync(); } return rewardBalanceByPoolId; } @@ -238,7 +238,7 @@ export class FinalizerActor extends BaseActor { private async _getRewardByPoolIdAsync(poolIds: string[]): Promise { const activePools = await Promise.all( poolIds.map(async poolId => - this._stakingApiWrapper.stakingContract.getStakingPoolStatsThisEpoch.callAsync(poolId), + this._stakingApiWrapper.stakingContract.getStakingPoolStatsThisEpoch(poolId).callAsync(), ), ); const totalRewards = await this._stakingApiWrapper.utils.getAvailableRewardsBalanceAsync(); diff --git a/contracts/staking/test/actors/maker_actor.ts b/contracts/staking/test/actors/maker_actor.ts index 144aeee11b..f5331ae473 100644 --- a/contracts/staking/test/actors/maker_actor.ts +++ b/contracts/staking/test/actors/maker_actor.ts @@ -7,17 +7,16 @@ import { PoolOperatorActor } from './pool_operator_actor'; export class MakerActor extends PoolOperatorActor { public async joinStakingPoolAsMakerAsync(poolId: string, revertError?: RevertError): Promise { // add maker - const txReceiptPromise = this._stakingApiWrapper.stakingContract.joinStakingPoolAsMaker.awaitTransactionSuccessAsync( - poolId, - { from: this.getOwner() }, - ); + const txReceiptPromise = this._stakingApiWrapper.stakingContract + .joinStakingPoolAsMaker(poolId) + .awaitTransactionSuccessAsync({ from: this.getOwner() }); if (revertError !== undefined) { await expect(txReceiptPromise).to.revertWith(revertError); return; } await txReceiptPromise; // check the pool id of the maker - const poolIdOfMaker = await this._stakingApiWrapper.stakingContract.poolIdByMaker.callAsync(this.getOwner()); + const poolIdOfMaker = await this._stakingApiWrapper.stakingContract.poolIdByMaker(this.getOwner()).callAsync(); expect(poolIdOfMaker, 'pool id of maker').to.be.equal(poolId); } } diff --git a/contracts/staking/test/actors/pool_operator_actor.ts b/contracts/staking/test/actors/pool_operator_actor.ts index e7fd5f7e78..2bc1e124bc 100644 --- a/contracts/staking/test/actors/pool_operator_actor.ts +++ b/contracts/staking/test/actors/pool_operator_actor.ts @@ -22,12 +22,12 @@ export class PoolOperatorActor extends BaseActor { } const poolId = await poolIdPromise; // validate pool id - const lastPoolId = await this._stakingApiWrapper.stakingContract.lastPoolId.callAsync(); + const lastPoolId = await this._stakingApiWrapper.stakingContract.lastPoolId().callAsync(); expect(poolId, 'pool id').to.be.bignumber.equal(lastPoolId); if (addOperatorAsMaker) { // check the pool id of the operator - const poolIdOfMaker = await this._stakingApiWrapper.stakingContract.poolIdByMaker.callAsync(this._owner); + const poolIdOfMaker = await this._stakingApiWrapper.stakingContract.poolIdByMaker(this._owner).callAsync(); expect(poolIdOfMaker, 'pool id of maker').to.be.equal(poolId); } return poolId; @@ -38,18 +38,16 @@ export class PoolOperatorActor extends BaseActor { revertError?: RevertError, ): Promise { // decrease operator share - const txReceiptPromise = this._stakingApiWrapper.stakingContract.decreaseStakingPoolOperatorShare.awaitTransactionSuccessAsync( - poolId, - newOperatorShare, - { from: this._owner }, - ); + const txReceiptPromise = this._stakingApiWrapper.stakingContract + .decreaseStakingPoolOperatorShare(poolId, newOperatorShare) + .awaitTransactionSuccessAsync({ from: this._owner }); if (revertError !== undefined) { await expect(txReceiptPromise).to.revertWith(revertError); return; } await txReceiptPromise; // Check operator share - const pool = await this._stakingApiWrapper.stakingContract.getStakingPool.callAsync(poolId); + const pool = await this._stakingApiWrapper.stakingContract.getStakingPool(poolId).callAsync(); expect(pool.operatorShare, 'updated operator share').to.be.bignumber.equal(newOperatorShare); } } diff --git a/contracts/staking/test/actors/staker_actor.ts b/contracts/staking/test/actors/staker_actor.ts index 469f235730..7f5dee39f8 100644 --- a/contracts/staking/test/actors/staker_actor.ts +++ b/contracts/staking/test/actors/staker_actor.ts @@ -39,13 +39,12 @@ export class StakerActor extends BaseActor { const initZrxBalanceOfVault = await this._stakingApiWrapper.utils.getZrxTokenBalanceOfZrxVaultAsync(); const initBalances = await this._getBalancesAsync(); // move stake - const txReceiptPromise = this._stakingApiWrapper.stakingProxyContract.batchExecute.awaitTransactionSuccessAsync( - [ - this._stakingApiWrapper.stakingContract.stake.getABIEncodedTransactionData(amount), - this._stakingApiWrapper.stakingContract.moveStake.getABIEncodedTransactionData(from, to, amount), - ], - { from: this._owner }, - ); + const txReceiptPromise = this._stakingApiWrapper.stakingProxyContract + .batchExecute([ + this._stakingApiWrapper.stakingContract.stake(amount).getABIEncodedTransactionData(), + this._stakingApiWrapper.stakingContract.moveStake(from, to, amount).getABIEncodedTransactionData(), + ]) + .awaitTransactionSuccessAsync({ from: this._owner }); if (revertError !== undefined) { await expect(txReceiptPromise, 'expected revert error').to.revertWith(revertError); return; @@ -70,7 +69,7 @@ export class StakerActor extends BaseActor { const initZrxBalanceOfVault = await this._stakingApiWrapper.utils.getZrxTokenBalanceOfZrxVaultAsync(); const initBalances = await this._getBalancesAsync(); // deposit stake - const txReceiptPromise = this._stakingApiWrapper.stakingContract.stake.awaitTransactionSuccessAsync(amount, { + const txReceiptPromise = this._stakingApiWrapper.stakingContract.stake(amount).awaitTransactionSuccessAsync({ from: this._owner, }); if (revertError !== undefined) { @@ -93,7 +92,7 @@ export class StakerActor extends BaseActor { const initZrxBalanceOfVault = await this._stakingApiWrapper.utils.getZrxTokenBalanceOfZrxVaultAsync(); const initBalances = await this._getBalancesAsync(); // deposit stake - const txReceiptPromise = this._stakingApiWrapper.stakingContract.unstake.awaitTransactionSuccessAsync(amount, { + const txReceiptPromise = this._stakingApiWrapper.stakingContract.unstake(amount).awaitTransactionSuccessAsync({ from: this._owner, }); if (revertError !== undefined) { @@ -127,12 +126,9 @@ export class StakerActor extends BaseActor { // Calculate the expected outcome after the move. const expectedBalances = await this._calculateExpectedBalancesAfterMoveAsync(from, to, amount); // move stake - const txReceiptPromise = this._stakingApiWrapper.stakingContract.moveStake.awaitTransactionSuccessAsync( - from, - to, - amount, - { from: this._owner }, - ); + const txReceiptPromise = this._stakingApiWrapper.stakingContract + .moveStake(from, to, amount) + .awaitTransactionSuccessAsync({ from: this._owner }); if (revertError !== undefined) { await expect(txReceiptPromise).to.revertWith(revertError); return; @@ -155,10 +151,9 @@ export class StakerActor extends BaseActor { } public async withdrawDelegatorRewardsAsync(poolId: string, revertError?: RevertError): Promise { - const txReceiptPromise = this._stakingApiWrapper.stakingContract.withdrawDelegatorRewards.awaitTransactionSuccessAsync( - poolId, - { from: this._owner }, - ); + const txReceiptPromise = this._stakingApiWrapper.stakingContract + .withdrawDelegatorRewards(poolId) + .awaitTransactionSuccessAsync({ from: this._owner }); if (revertError !== undefined) { await expect(txReceiptPromise, 'expected revert error').to.revertWith(revertError); return; @@ -196,36 +191,33 @@ export class StakerActor extends BaseActor { } private async _getBalancesAsync(): Promise { const balances: StakeBalances = { - currentEpoch: await this._stakingApiWrapper.stakingContract.currentEpoch.callAsync(), - zrxBalance: await this._stakingApiWrapper.zrxTokenContract.balanceOf.callAsync(this._owner), - stakeBalance: await this._stakingApiWrapper.stakingContract.getTotalStake.callAsync(this._owner), - stakeBalanceInVault: await this._stakingApiWrapper.zrxVaultContract.balanceOf.callAsync(this._owner), - undelegatedStakeBalance: await this._stakingApiWrapper.stakingContract.getOwnerStakeByStatus.callAsync( - this._owner, - StakeStatus.Undelegated, - ), - delegatedStakeBalance: await this._stakingApiWrapper.stakingContract.getOwnerStakeByStatus.callAsync( - this._owner, - StakeStatus.Delegated, - ), - globalUndelegatedStakeBalance: await this._stakingApiWrapper.stakingContract.getGlobalStakeByStatus.callAsync( - StakeStatus.Undelegated, - ), - globalDelegatedStakeBalance: await this._stakingApiWrapper.stakingContract.getGlobalStakeByStatus.callAsync( - StakeStatus.Delegated, - ), + currentEpoch: await this._stakingApiWrapper.stakingContract.currentEpoch().callAsync(), + zrxBalance: await this._stakingApiWrapper.zrxTokenContract.balanceOf(this._owner).callAsync(), + stakeBalance: await this._stakingApiWrapper.stakingContract.getTotalStake(this._owner).callAsync(), + stakeBalanceInVault: await this._stakingApiWrapper.zrxVaultContract.balanceOf(this._owner).callAsync(), + undelegatedStakeBalance: await this._stakingApiWrapper.stakingContract + .getOwnerStakeByStatus(this._owner, StakeStatus.Undelegated) + .callAsync(), + delegatedStakeBalance: await this._stakingApiWrapper.stakingContract + .getOwnerStakeByStatus(this._owner, StakeStatus.Delegated) + .callAsync(), + globalUndelegatedStakeBalance: await this._stakingApiWrapper.stakingContract + .getGlobalStakeByStatus(StakeStatus.Undelegated) + .callAsync(), + globalDelegatedStakeBalance: await this._stakingApiWrapper.stakingContract + .getGlobalStakeByStatus(StakeStatus.Delegated) + .callAsync(), delegatedStakeByPool: {}, totalDelegatedStakeByPool: {}, }; // lookup for each pool for (const poolId of this._poolIds) { - const delegatedStakeBalanceByPool = await this._stakingApiWrapper.stakingContract.getStakeDelegatedToPoolByOwner.callAsync( - this._owner, - poolId, - ); - const totalDelegatedStakeBalanceByPool = await this._stakingApiWrapper.stakingContract.getTotalStakeDelegatedToPool.callAsync( - poolId, - ); + const delegatedStakeBalanceByPool = await this._stakingApiWrapper.stakingContract + .getStakeDelegatedToPoolByOwner(this._owner, poolId) + .callAsync(); + const totalDelegatedStakeBalanceByPool = await this._stakingApiWrapper.stakingContract + .getTotalStakeDelegatedToPool(poolId) + .callAsync(); balances.delegatedStakeByPool[poolId] = delegatedStakeBalanceByPool; balances.totalDelegatedStakeByPool[poolId] = totalDelegatedStakeBalanceByPool; } diff --git a/contracts/staking/test/epoch_test.ts b/contracts/staking/test/epoch_test.ts index ab5d470f34..03191b65bc 100644 --- a/contracts/staking/test/epoch_test.ts +++ b/contracts/staking/test/epoch_test.ts @@ -32,14 +32,14 @@ blockchainTests('Epochs', env => { ///// 2/3 Validate Initial Epoch & TimeLock Period ///// { // epoch - const currentEpoch = await stakingApiWrapper.stakingContract.currentEpoch.callAsync(); + const currentEpoch = await stakingApiWrapper.stakingContract.currentEpoch().callAsync(); expect(currentEpoch).to.be.bignumber.equal(stakingConstants.INITIAL_EPOCH); } ///// 3/3 Increment Epoch (TimeLock Should Not Increment) ///// await stakingApiWrapper.utils.skipToNextEpochAndFinalizeAsync(); { // epoch - const currentEpoch = await stakingApiWrapper.stakingContract.currentEpoch.callAsync(); + const currentEpoch = await stakingApiWrapper.stakingContract.currentEpoch().callAsync(); expect(currentEpoch).to.be.bignumber.equal(stakingConstants.INITIAL_EPOCH.plus(1)); } }); diff --git a/contracts/staking/test/migration_test.ts b/contracts/staking/test/migration_test.ts index d6f9b50f2a..43e4e2475d 100644 --- a/contracts/staking/test/migration_test.ts +++ b/contracts/staking/test/migration_test.ts @@ -28,7 +28,7 @@ blockchainTests('Migration tests', env => { env.txDefaults, artifacts, ); - await stakingContract.addAuthorizedAddress.awaitTransactionSuccessAsync(authorizedAddress); + await stakingContract.addAuthorizedAddress(authorizedAddress).awaitTransactionSuccessAsync(); }); describe('StakingProxy', () => { @@ -45,7 +45,7 @@ blockchainTests('Migration tests', env => { artifacts, stakingContractAddress || constants.NULL_ADDRESS, ); - await proxyContract.addAuthorizedAddress.awaitTransactionSuccessAsync(authorizedAddress); + await proxyContract.addAuthorizedAddress(authorizedAddress).awaitTransactionSuccessAsync(); return proxyContract; } @@ -57,7 +57,7 @@ blockchainTests('Migration tests', env => { env.txDefaults, artifacts, ); - revertAddress = await initTargetContract.SHOULD_REVERT_ADDRESS.callAsync(); + revertAddress = await initTargetContract.SHOULD_REVERT_ADDRESS().callAsync(); }); async function enableInitRevertsAsync(): Promise { @@ -75,12 +75,12 @@ blockchainTests('Migration tests', env => { } async function assertInitStateAsync(proxyContract: TestStakingProxyContract): Promise { - const [senderAddress, thisAddress] = await initTargetContract.getInitState.callAsync({ + const [senderAddress, thisAddress] = await initTargetContract.getInitState().callAsync({ to: proxyContract.address, }); expect(senderAddress).to.eq(authorizedAddress); expect(thisAddress).to.eq(proxyContract.address); - const attachedAddress = await proxyContract.stakingContract.callAsync(); + const attachedAddress = await proxyContract.stakingContract().callAsync(); expect(attachedAddress).to.eq(initTargetContract.address); } @@ -115,7 +115,7 @@ blockchainTests('Migration tests', env => { env.provider, env.txDefaults, ); - const params = await stakingProxyContract.getParams.callAsync(); + const params = await stakingProxyContract.getParams().callAsync(); expect(params[0]).to.bignumber.eq(stakingConstants.DEFAULT_PARAMS.epochDurationInSeconds); expect(params[1]).to.bignumber.eq(stakingConstants.DEFAULT_PARAMS.rewardDelegatedStakeWeight); expect(params[2]).to.bignumber.eq(stakingConstants.DEFAULT_PARAMS.minimumPoolStake); @@ -132,25 +132,24 @@ blockchainTests('Migration tests', env => { }); it('throws if not called by an authorized address', async () => { - const tx = proxyContract.attachStakingContract.awaitTransactionSuccessAsync( - initTargetContract.address, - { + const tx = proxyContract + .attachStakingContract(initTargetContract.address) + .awaitTransactionSuccessAsync({ from: notAuthorizedAddress, - }, - ); + }); const expectedError = new AuthorizableRevertErrors.SenderNotAuthorizedError(notAuthorizedAddress); return expect(tx).to.revertWith(expectedError); }); it('calls init() and attaches the contract', async () => { - await proxyContract.attachStakingContract.awaitTransactionSuccessAsync(initTargetContract.address); + await proxyContract.attachStakingContract(initTargetContract.address).awaitTransactionSuccessAsync(); await assertInitStateAsync(proxyContract); }); it('emits a `StakingContractAttachedToProxy` event', async () => { - const receipt = await proxyContract.attachStakingContract.awaitTransactionSuccessAsync( - initTargetContract.address, - ); + const receipt = await proxyContract + .attachStakingContract(initTargetContract.address) + .awaitTransactionSuccessAsync(); const logsArgs = filterLogsToArguments( receipt.logs, 'StakingContractAttachedToProxy', @@ -164,12 +163,14 @@ blockchainTests('Migration tests', env => { it('reverts if init() reverts', async () => { await enableInitRevertsAsync(); - const tx = proxyContract.attachStakingContract.awaitTransactionSuccessAsync(initTargetContract.address); + const tx = proxyContract + .attachStakingContract(initTargetContract.address) + .awaitTransactionSuccessAsync(); return expect(tx).to.revertWith(INIT_REVERT_ERROR); }); it('reverts if assertValidStorageParams() fails', async () => { - const tx = proxyContract.attachStakingContract.awaitTransactionSuccessAsync(revertAddress); + const tx = proxyContract.attachStakingContract(revertAddress).awaitTransactionSuccessAsync(); return expect(tx).to.revertWith(STORAGE_PARAMS_REVERT_ERROR); }); }); @@ -177,8 +178,8 @@ blockchainTests('Migration tests', env => { blockchainTests.resets('upgrades', async () => { it('modifies prior state', async () => { const proxyContract = await deployStakingProxyAsync(initTargetContract.address); - await proxyContract.attachStakingContract.awaitTransactionSuccessAsync(initTargetContract.address); - const initCounter = await initTargetContract.getInitCounter.callAsync({ to: proxyContract.address }); + await proxyContract.attachStakingContract(initTargetContract.address).awaitTransactionSuccessAsync(); + const initCounter = await initTargetContract.getInitCounter().callAsync({ to: proxyContract.address }); expect(initCounter).to.bignumber.eq(2); }); }); @@ -186,7 +187,7 @@ blockchainTests('Migration tests', env => { blockchainTests.resets('Staking.init()', async () => { it('throws if not called by an authorized address', async () => { - const tx = stakingContract.init.awaitTransactionSuccessAsync({ + const tx = stakingContract.init().awaitTransactionSuccessAsync({ from: notAuthorizedAddress, }); const expectedError = new AuthorizableRevertErrors.SenderNotAuthorizedError(notAuthorizedAddress); @@ -194,8 +195,8 @@ blockchainTests('Migration tests', env => { }); it('throws if already intitialized', async () => { - await stakingContract.init.awaitTransactionSuccessAsync(); - const tx = stakingContract.init.awaitTransactionSuccessAsync(); + await stakingContract.init().awaitTransactionSuccessAsync(); + const tx = stakingContract.init().awaitTransactionSuccessAsync(); const expectedError = new StakingRevertErrors.InitializationError(); return expect(tx).to.revertWith(expectedError); }); @@ -215,96 +216,116 @@ blockchainTests('Migration tests', env => { }); it('succeeds if all params are valid', async () => { - const tx = proxyContract.setAndAssertParams.awaitTransactionSuccessAsync(stakingConstants.DEFAULT_PARAMS); + const tx = proxyContract.setAndAssertParams(stakingConstants.DEFAULT_PARAMS).awaitTransactionSuccessAsync(); expect(tx).to.be.fulfilled(''); }); it('reverts if epoch duration is < 5 days', async () => { - const tx = proxyContract.setAndAssertParams.awaitTransactionSuccessAsync({ - ...stakingConstants.DEFAULT_PARAMS, - epochDurationInSeconds: fiveDays.minus(1), - }); + const tx = proxyContract + .setAndAssertParams({ + ...stakingConstants.DEFAULT_PARAMS, + epochDurationInSeconds: fiveDays.minus(1), + }) + .awaitTransactionSuccessAsync(); const expectedError = new StakingRevertErrors.InvalidParamValueError( StakingRevertErrors.InvalidParamValueErrorCodes.InvalidEpochDuration, ); return expect(tx).to.revertWith(expectedError); }); it('reverts if epoch duration is > 30 days', async () => { - const tx = proxyContract.setAndAssertParams.awaitTransactionSuccessAsync({ - ...stakingConstants.DEFAULT_PARAMS, - epochDurationInSeconds: thirtyDays.plus(1), - }); + const tx = proxyContract + .setAndAssertParams({ + ...stakingConstants.DEFAULT_PARAMS, + epochDurationInSeconds: thirtyDays.plus(1), + }) + .awaitTransactionSuccessAsync(); const expectedError = new StakingRevertErrors.InvalidParamValueError( StakingRevertErrors.InvalidParamValueErrorCodes.InvalidEpochDuration, ); return expect(tx).to.revertWith(expectedError); }); it('succeeds if epoch duration is 5 days', async () => { - const tx = proxyContract.setAndAssertParams.awaitTransactionSuccessAsync({ - ...stakingConstants.DEFAULT_PARAMS, - epochDurationInSeconds: fiveDays, - }); + const tx = proxyContract + .setAndAssertParams({ + ...stakingConstants.DEFAULT_PARAMS, + epochDurationInSeconds: fiveDays, + }) + .awaitTransactionSuccessAsync(); return expect(tx).to.be.fulfilled(''); }); it('succeeds if epoch duration is 30 days', async () => { - const tx = proxyContract.setAndAssertParams.awaitTransactionSuccessAsync({ - ...stakingConstants.DEFAULT_PARAMS, - epochDurationInSeconds: thirtyDays, - }); + const tx = proxyContract + .setAndAssertParams({ + ...stakingConstants.DEFAULT_PARAMS, + epochDurationInSeconds: thirtyDays, + }) + .awaitTransactionSuccessAsync(); return expect(tx).to.be.fulfilled(''); }); it('reverts if alpha denominator is 0', async () => { - const tx = proxyContract.setAndAssertParams.awaitTransactionSuccessAsync({ - ...stakingConstants.DEFAULT_PARAMS, - cobbDouglasAlphaDenominator: constants.ZERO_AMOUNT, - }); + const tx = proxyContract + .setAndAssertParams({ + ...stakingConstants.DEFAULT_PARAMS, + cobbDouglasAlphaDenominator: constants.ZERO_AMOUNT, + }) + .awaitTransactionSuccessAsync(); const expectedError = new StakingRevertErrors.InvalidParamValueError( StakingRevertErrors.InvalidParamValueErrorCodes.InvalidCobbDouglasAlpha, ); return expect(tx).to.revertWith(expectedError); }); it('reverts if alpha > 1', async () => { - const tx = proxyContract.setAndAssertParams.awaitTransactionSuccessAsync({ - ...stakingConstants.DEFAULT_PARAMS, - cobbDouglasAlphaNumerator: new BigNumber(101), - cobbDouglasAlphaDenominator: new BigNumber(100), - }); + const tx = proxyContract + .setAndAssertParams({ + ...stakingConstants.DEFAULT_PARAMS, + cobbDouglasAlphaNumerator: new BigNumber(101), + cobbDouglasAlphaDenominator: new BigNumber(100), + }) + .awaitTransactionSuccessAsync(); const expectedError = new StakingRevertErrors.InvalidParamValueError( StakingRevertErrors.InvalidParamValueErrorCodes.InvalidCobbDouglasAlpha, ); return expect(tx).to.revertWith(expectedError); }); it('succeeds if alpha == 1', async () => { - const tx = proxyContract.setAndAssertParams.awaitTransactionSuccessAsync({ - ...stakingConstants.DEFAULT_PARAMS, - cobbDouglasAlphaNumerator: new BigNumber(1), - cobbDouglasAlphaDenominator: new BigNumber(1), - }); + const tx = proxyContract + .setAndAssertParams({ + ...stakingConstants.DEFAULT_PARAMS, + cobbDouglasAlphaNumerator: new BigNumber(1), + cobbDouglasAlphaDenominator: new BigNumber(1), + }) + .awaitTransactionSuccessAsync(); return expect(tx).to.be.fulfilled(''); }); it('succeeds if alpha == 0', async () => { - const tx = proxyContract.setAndAssertParams.awaitTransactionSuccessAsync({ - ...stakingConstants.DEFAULT_PARAMS, - cobbDouglasAlphaNumerator: constants.ZERO_AMOUNT, - cobbDouglasAlphaDenominator: new BigNumber(1), - }); + const tx = proxyContract + .setAndAssertParams({ + ...stakingConstants.DEFAULT_PARAMS, + cobbDouglasAlphaNumerator: constants.ZERO_AMOUNT, + cobbDouglasAlphaDenominator: new BigNumber(1), + }) + .awaitTransactionSuccessAsync(); return expect(tx).to.be.fulfilled(''); }); it('reverts if delegation weight is > 100%', async () => { - const tx = proxyContract.setAndAssertParams.awaitTransactionSuccessAsync({ - ...stakingConstants.DEFAULT_PARAMS, - rewardDelegatedStakeWeight: new BigNumber(stakingConstants.PPM).plus(1), - }); + const tx = proxyContract + .setAndAssertParams({ + ...stakingConstants.DEFAULT_PARAMS, + rewardDelegatedStakeWeight: new BigNumber(stakingConstants.PPM).plus(1), + }) + .awaitTransactionSuccessAsync(); const expectedError = new StakingRevertErrors.InvalidParamValueError( StakingRevertErrors.InvalidParamValueErrorCodes.InvalidRewardDelegatedStakeWeight, ); return expect(tx).to.revertWith(expectedError); }); it('succeeds if delegation weight is 100%', async () => { - const tx = proxyContract.setAndAssertParams.awaitTransactionSuccessAsync({ - ...stakingConstants.DEFAULT_PARAMS, - rewardDelegatedStakeWeight: new BigNumber(stakingConstants.PPM), - }); + const tx = proxyContract + .setAndAssertParams({ + ...stakingConstants.DEFAULT_PARAMS, + rewardDelegatedStakeWeight: new BigNumber(stakingConstants.PPM), + }) + .awaitTransactionSuccessAsync(); return expect(tx).to.be.fulfilled(''); }); }); diff --git a/contracts/staking/test/pools_test.ts b/contracts/staking/test/pools_test.ts index 7dc69c08c8..7e0c5fe944 100644 --- a/contracts/staking/test/pools_test.ts +++ b/contracts/staking/test/pools_test.ts @@ -40,7 +40,7 @@ blockchainTests('Staking Pool Management', env => { const poolId = await poolOperator.createStakingPoolAsync(operatorShare, false); expect(poolId).to.be.equal(stakingConstants.INITIAL_POOL_ID); // check that the next pool id was incremented - const lastPoolId = await stakingApiWrapper.stakingContract.lastPoolId.callAsync(); + const lastPoolId = await stakingApiWrapper.stakingContract.lastPoolId().callAsync(); expect(lastPoolId).to.be.equal(stakingConstants.INITIAL_POOL_ID); }); it('Should successfully create several staking pools, as long as the operator is only a maker in one', async () => { @@ -77,7 +77,7 @@ blockchainTests('Staking Pool Management', env => { const poolId = await poolOperator.createStakingPoolAsync(operatorShare, true); expect(poolId).to.be.equal(stakingConstants.INITIAL_POOL_ID); // check that the next pool id was incremented - const lastPoolId = await stakingApiWrapper.stakingContract.lastPoolId.callAsync(); + const lastPoolId = await stakingApiWrapper.stakingContract.lastPoolId().callAsync(); expect(lastPoolId).to.be.equal(stakingConstants.INITIAL_POOL_ID); }); it('Should throw if operatorShare is > PPM_DENOMINATOR', async () => { diff --git a/contracts/staking/test/rewards_test.ts b/contracts/staking/test/rewards_test.ts index 0f0c4f5172..2974a53782 100644 --- a/contracts/staking/test/rewards_test.ts +++ b/contracts/staking/test/rewards_test.ts @@ -58,7 +58,7 @@ blockchainTests.resets('Testing Rewards', env => { poolOperatorStaker = new StakerActor(poolOperator.getOwner(), stakingApiWrapper); await poolOperatorStaker.stakeWithPoolAsync(poolId, new BigNumber(2)); // set exchange address - await stakingApiWrapper.stakingContract.addExchangeAddress.awaitTransactionSuccessAsync(exchangeAddress); + await stakingApiWrapper.stakingContract.addExchangeAddress(exchangeAddress).awaitTransactionSuccessAsync(); // associate operators for tracking in Finalizer const operatorByPoolId: OperatorByPoolId = {}; operatorByPoolId[poolId] = poolOperator.getOwner(); @@ -117,21 +117,19 @@ blockchainTests.resets('Testing Rewards', env => { }; const finalEndBalancesAsArray = await Promise.all([ // staker 1 - stakingApiWrapper.stakingContract.computeRewardBalanceOfDelegator.callAsync( - poolId, - stakers[0].getOwner(), - ), - stakingApiWrapper.wethContract.balanceOf.callAsync(stakers[0].getOwner()), + stakingApiWrapper.stakingContract + .computeRewardBalanceOfDelegator(poolId, stakers[0].getOwner()) + .callAsync(), + stakingApiWrapper.wethContract.balanceOf(stakers[0].getOwner()).callAsync(), // staker 2 - stakingApiWrapper.stakingContract.computeRewardBalanceOfDelegator.callAsync( - poolId, - stakers[1].getOwner(), - ), - stakingApiWrapper.wethContract.balanceOf.callAsync(stakers[1].getOwner()), + stakingApiWrapper.stakingContract + .computeRewardBalanceOfDelegator(poolId, stakers[1].getOwner()) + .callAsync(), + stakingApiWrapper.wethContract.balanceOf(stakers[1].getOwner()).callAsync(), // operator - stakingApiWrapper.wethContract.balanceOf.callAsync(poolOperator.getOwner()), + stakingApiWrapper.wethContract.balanceOf(poolOperator.getOwner()).callAsync(), // undivided balance in reward pool - stakingApiWrapper.stakingContract.rewardsByPoolId.callAsync(poolId), + stakingApiWrapper.stakingContract.rewardsByPoolId(poolId).callAsync(), ]); expect(finalEndBalancesAsArray[0], 'stakerRewardBalance_1').to.be.bignumber.equal( expectedEndBalances.stakerRewardBalance_1, @@ -155,12 +153,9 @@ blockchainTests.resets('Testing Rewards', env => { const payProtocolFeeAndFinalize = async (_fee?: BigNumber) => { const fee = _fee !== undefined ? _fee : constants.ZERO_AMOUNT; if (!fee.eq(constants.ZERO_AMOUNT)) { - await stakingApiWrapper.stakingContract.payProtocolFee.awaitTransactionSuccessAsync( - poolOperator.getOwner(), - takerAddress, - fee, - { from: exchangeAddress, value: fee }, - ); + await stakingApiWrapper.stakingContract + .payProtocolFee(poolOperator.getOwner(), takerAddress, fee) + .awaitTransactionSuccessAsync({ from: exchangeAddress, value: fee }); } await finalizer.finalizeAsync(); }; @@ -168,7 +163,7 @@ blockchainTests.resets('Testing Rewards', env => { // sanity balances - all zero await validateEndBalances({}); }); - it('Reward balance should be zero if not delegated, when epoch is greater than 0', async () => { + it.only('Reward balance should be zero if not delegated, when epoch is greater than 0', async () => { await payProtocolFeeAndFinalize(); // sanity balances - all zero await validateEndBalances({}); @@ -574,7 +569,7 @@ blockchainTests.resets('Testing Rewards', env => { await payProtocolFeeAndFinalize(); // this should go to the delegator await payProtocolFeeAndFinalize(rewardForDelegator); - await stakingApiWrapper.stakingContract.withdrawDelegatorRewards.awaitTransactionSuccessAsync(poolId, { + await stakingApiWrapper.stakingContract.withdrawDelegatorRewards(poolId).awaitTransactionSuccessAsync({ from: stakers[0].getOwner(), }); // sanity check final balances @@ -594,18 +589,15 @@ blockchainTests.resets('Testing Rewards', env => { new StakeInfo(StakeStatus.Delegated, poolId), stakeAmount, ); - await stakingApiWrapper.stakingContract.payProtocolFee.awaitTransactionSuccessAsync( - poolOperator.getOwner(), - takerAddress, - rewardForDelegator, - { from: exchangeAddress, value: rewardForDelegator }, - ); - const currentEpoch = await stakingApiWrapper.stakingContract.currentEpoch.callAsync(); + await stakingApiWrapper.stakingContract + .payProtocolFee(poolOperator.getOwner(), takerAddress, rewardForDelegator) + .awaitTransactionSuccessAsync({ from: exchangeAddress, value: rewardForDelegator }); + const currentEpoch = await stakingApiWrapper.stakingContract.currentEpoch().callAsync(); await stakingApiWrapper.utils.fastForwardToNextEpochAsync(); await stakingApiWrapper.utils.endEpochAsync(); const expectedError = new StakingRevertErrors.PoolNotFinalizedError(poolId, currentEpoch); expect( - stakingApiWrapper.stakingContract.withdrawDelegatorRewards.awaitTransactionSuccessAsync(poolId, { + stakingApiWrapper.stakingContract.withdrawDelegatorRewards(poolId).awaitTransactionSuccessAsync({ from: stakers[0].getOwner(), }), ).to.revertWith(expectedError); @@ -688,16 +680,18 @@ blockchainTests.resets('Testing Rewards', env => { const sneakyStakerExpectedWethBalance = expectedStakerRewards[0]; await sneakyStaker.withdrawDelegatorRewardsAsync(poolId); // Should have been credited the correct amount of rewards. - let sneakyStakerWethBalance = await stakingApiWrapper.wethContract.balanceOf.callAsync( - sneakyStaker.getOwner(), - ); + let sneakyStakerWethBalance = await stakingApiWrapper.wethContract + .balanceOf(sneakyStaker.getOwner()) + .callAsync(); expect(sneakyStakerWethBalance, 'WETH balance after first undelegate').to.bignumber.eq( sneakyStakerExpectedWethBalance, ); // Now he'll try to do it again to see if he gets credited twice. await sneakyStaker.withdrawDelegatorRewardsAsync(poolId); /// The total amount credited should remain the same. - sneakyStakerWethBalance = await stakingApiWrapper.wethContract.balanceOf.callAsync(sneakyStaker.getOwner()); + sneakyStakerWethBalance = await stakingApiWrapper.wethContract + .balanceOf(sneakyStaker.getOwner()) + .callAsync(); expect(sneakyStakerWethBalance, 'WETH balance after second undelegate').to.bignumber.eq( sneakyStakerExpectedWethBalance, ); diff --git a/contracts/staking/test/stake_test.ts b/contracts/staking/test/stake_test.ts index 065178d80a..806d57a2a1 100644 --- a/contracts/staking/test/stake_test.ts +++ b/contracts/staking/test/stake_test.ts @@ -44,7 +44,7 @@ blockchainTests.resets('Stake Statuses', env => { await stakingApiWrapper.utils.createStakingPoolAsync(poolOperator, 4, false), await stakingApiWrapper.utils.createStakingPoolAsync(poolOperator, 5, false), ]); - const lastPoolId = await stakingApiWrapper.stakingContract.lastPoolId.callAsync(); + const lastPoolId = await stakingApiWrapper.stakingContract.lastPoolId().callAsync(); unusedPoolId = `0x${new BigNumber(lastPoolId) .plus(1) .toString(16) diff --git a/contracts/staking/test/unit_tests/delegator_reward_test.ts b/contracts/staking/test/unit_tests/delegator_reward_test.ts index 58e4855e20..a031ff2e57 100644 --- a/contracts/staking/test/unit_tests/delegator_reward_test.ts +++ b/contracts/staking/test/unit_tests/delegator_reward_test.ts @@ -56,13 +56,15 @@ blockchainTests.resets('Delegator rewards unit tests', env => { }; // Generate a deterministic operator address based on the poolId. _opts.operator = poolIdToOperator(_opts.poolId); - await testContract.syncPoolRewards.awaitTransactionSuccessAsync( - _opts.poolId, - _opts.operator, - new BigNumber(_opts.operatorReward), - new BigNumber(_opts.membersReward), - new BigNumber(_opts.membersStake), - ); + await testContract + .syncPoolRewards( + _opts.poolId, + _opts.operator, + new BigNumber(_opts.operatorReward), + new BigNumber(_opts.membersReward), + new BigNumber(_opts.membersStake), + ) + .awaitTransactionSuccessAsync(); // Because the operator share is implicitly defined by the member and // operator reward, and is stored as a uint32, there will be precision // loss when the reward is combined then split again in the contracts. @@ -86,13 +88,15 @@ blockchainTests.resets('Delegator rewards unit tests', env => { }; // Generate a deterministic operator address based on the poolId. _opts.operator = poolIdToOperator(_opts.poolId); - await testContract.setUnfinalizedPoolReward.awaitTransactionSuccessAsync( - _opts.poolId, - _opts.operator, - new BigNumber(_opts.operatorReward), - new BigNumber(_opts.membersReward), - new BigNumber(_opts.membersStake), - ); + await testContract + .setUnfinalizedPoolReward( + _opts.poolId, + _opts.operator, + new BigNumber(_opts.operatorReward), + new BigNumber(_opts.membersReward), + new BigNumber(_opts.membersStake), + ) + .awaitTransactionSuccessAsync(); // Because the operator share is implicitly defined by the member and // operator reward, and is stored as a uint32, there will be precision // loss when the reward is combined then split again in the contracts. @@ -149,7 +153,7 @@ blockchainTests.resets('Delegator rewards unit tests', env => { ...opts, }; const fn = now ? testContract.delegateStakeNow : testContract.delegateStake; - const receipt = await fn.awaitTransactionSuccessAsync(_opts.delegator, poolId, new BigNumber(_opts.stake)); + const receipt = await fn(_opts.delegator, poolId, new BigNumber(_opts.stake)).awaitTransactionSuccessAsync(); const delegatorTransfers = getTransfersFromLogs(receipt.logs, _opts.delegator); return { ..._opts, @@ -164,9 +168,9 @@ blockchainTests.resets('Delegator rewards unit tests', env => { ): Promise> { const _stake = new BigNumber( stake || - (await testContract.getStakeDelegatedToPoolByOwner.callAsync(delegator, poolId)).currentEpochBalance, + (await testContract.getStakeDelegatedToPoolByOwner(delegator, poolId).callAsync()).currentEpochBalance, ); - const receipt = await testContract.undelegateStake.awaitTransactionSuccessAsync(delegator, poolId, _stake); + const receipt = await testContract.undelegateStake(delegator, poolId, _stake).awaitTransactionSuccessAsync(); const delegatorTransfers = getTransfersFromLogs(receipt.logs, delegator); return { stake: _stake, @@ -189,17 +193,17 @@ blockchainTests.resets('Delegator rewards unit tests', env => { } async function advanceEpochAsync(): Promise { - await testContract.advanceEpoch.awaitTransactionSuccessAsync(); - const epoch = await testContract.currentEpoch.callAsync(); + await testContract.advanceEpoch().awaitTransactionSuccessAsync(); + const epoch = await testContract.currentEpoch().callAsync(); return epoch.toNumber(); } async function getDelegatorRewardBalanceAsync(poolId: string, delegator: string): Promise { - return testContract.computeRewardBalanceOfDelegator.callAsync(poolId, delegator); + return testContract.computeRewardBalanceOfDelegator(poolId, delegator).callAsync(); } async function getOperatorRewardBalanceAsync(poolId: string): Promise { - return testContract.computeRewardBalanceOfOperator.callAsync(poolId); + return testContract.computeRewardBalanceOfOperator(poolId).callAsync(); } async function touchStakeAsync(poolId: string, delegator: string): Promise> { @@ -207,7 +211,7 @@ blockchainTests.resets('Delegator rewards unit tests', env => { } async function finalizePoolAsync(poolId: string): Promise> { - const receipt = await testContract.finalizePool.awaitTransactionSuccessAsync(poolId); + const receipt = await testContract.finalizePool(poolId).awaitTransactionSuccessAsync(); const delegatorTransfers = getTransfersFromLogs(receipt.logs, poolId); return { delegatorTransfers, diff --git a/contracts/staking/test/unit_tests/exchange_test.ts b/contracts/staking/test/unit_tests/exchange_test.ts index 6f21999d87..8dc9e9532e 100644 --- a/contracts/staking/test/unit_tests/exchange_test.ts +++ b/contracts/staking/test/unit_tests/exchange_test.ts @@ -38,22 +38,22 @@ blockchainTests.resets('Exchange Unit Tests', env => { ); // Register the exchange. - await exchangeManager.setValidExchange.awaitTransactionSuccessAsync(exchange); + await exchangeManager.setValidExchange(exchange).awaitTransactionSuccessAsync(); // Register an authority. - await exchangeManager.addAuthorizedAddress.awaitTransactionSuccessAsync(authority, { from: owner }); + await exchangeManager.addAuthorizedAddress(authority).awaitTransactionSuccessAsync({ from: owner }); }); describe('onlyExchange', () => { it('should revert if called by an unregistered exchange', async () => { const expectedError = new StakingRevertErrors.OnlyCallableByExchangeError(nonExchange); - return expect(exchangeManager.onlyExchangeFunction.callAsync({ from: nonExchange })).to.revertWith( + return expect(exchangeManager.onlyExchangeFunction().callAsync({ from: nonExchange })).to.revertWith( expectedError, ); }); it('should succeed if called by a registered exchange', async () => { - const didSucceed = await exchangeManager.onlyExchangeFunction.callAsync({ from: exchange }); + const didSucceed = await exchangeManager.onlyExchangeFunction().callAsync({ from: exchange }); expect(didSucceed).to.be.true(); }); }); @@ -89,7 +89,7 @@ blockchainTests.resets('Exchange Unit Tests', env => { describe('addExchangeAddress', () => { it('should revert if called by an unauthorized address', async () => { const expectedError = new AuthorizableRevertErrors.SenderNotAuthorizedError(nonAuthority); - const tx = exchangeManager.addExchangeAddress.awaitTransactionSuccessAsync(nonExchange, { + const tx = exchangeManager.addExchangeAddress(nonExchange).awaitTransactionSuccessAsync({ from: nonAuthority, }); return expect(tx).to.revertWith(expectedError); @@ -97,7 +97,7 @@ blockchainTests.resets('Exchange Unit Tests', env => { it('should revert when adding an exchange if called by the (non-authorized) owner', async () => { const expectedError = new AuthorizableRevertErrors.SenderNotAuthorizedError(owner); - const tx = exchangeManager.addExchangeAddress.awaitTransactionSuccessAsync(nonExchange, { + const tx = exchangeManager.addExchangeAddress(nonExchange).awaitTransactionSuccessAsync({ from: owner, }); return expect(tx).to.revertWith(expectedError); @@ -105,7 +105,7 @@ blockchainTests.resets('Exchange Unit Tests', env => { it('should successfully add an exchange if called by an authorized address', async () => { // Register a new exchange. - const receipt = await exchangeManager.addExchangeAddress.awaitTransactionSuccessAsync(nonExchange, { + const receipt = await exchangeManager.addExchangeAddress(nonExchange).awaitTransactionSuccessAsync({ from: authority, }); @@ -113,7 +113,7 @@ blockchainTests.resets('Exchange Unit Tests', env => { verifyExchangeManagerEvent(ExchangeManagerEventType.ExchangeAdded, nonExchange, receipt); // Ensure that the exchange was successfully registered. - const isValidExchange = await exchangeManager.validExchanges.callAsync(nonExchange); + const isValidExchange = await exchangeManager.validExchanges(nonExchange).callAsync(); expect(isValidExchange).to.be.true(); }); @@ -122,7 +122,7 @@ blockchainTests.resets('Exchange Unit Tests', env => { StakingRevertErrors.ExchangeManagerErrorCodes.ExchangeAlreadyRegistered, exchange, ); - const tx = exchangeManager.addExchangeAddress.awaitTransactionSuccessAsync(exchange, { from: authority }); + const tx = exchangeManager.addExchangeAddress(exchange).awaitTransactionSuccessAsync({ from: authority }); return expect(tx).to.revertWith(expectedError); }); }); @@ -130,7 +130,7 @@ blockchainTests.resets('Exchange Unit Tests', env => { describe('removeExchangeAddress', () => { it('should revert if called by an unauthorized address', async () => { const expectedError = new AuthorizableRevertErrors.SenderNotAuthorizedError(nonAuthority); - const tx = exchangeManager.removeExchangeAddress.awaitTransactionSuccessAsync(exchange, { + const tx = exchangeManager.removeExchangeAddress(exchange).awaitTransactionSuccessAsync({ from: nonAuthority, }); return expect(tx).to.revertWith(expectedError); @@ -138,7 +138,7 @@ blockchainTests.resets('Exchange Unit Tests', env => { it('should revert when removing an exchange if called by the (non-authorized) owner', async () => { const expectedError = new AuthorizableRevertErrors.SenderNotAuthorizedError(owner); - const tx = exchangeManager.removeExchangeAddress.awaitTransactionSuccessAsync(nonExchange, { + const tx = exchangeManager.removeExchangeAddress(nonExchange).awaitTransactionSuccessAsync({ from: owner, }); return expect(tx).to.revertWith(expectedError); @@ -146,7 +146,7 @@ blockchainTests.resets('Exchange Unit Tests', env => { it('should successfully remove a registered exchange if called by an authorized address', async () => { // Remove the registered exchange. - const receipt = await exchangeManager.removeExchangeAddress.awaitTransactionSuccessAsync(exchange, { + const receipt = await exchangeManager.removeExchangeAddress(exchange).awaitTransactionSuccessAsync({ from: authority, }); @@ -154,7 +154,7 @@ blockchainTests.resets('Exchange Unit Tests', env => { verifyExchangeManagerEvent(ExchangeManagerEventType.ExchangeRemoved, exchange, receipt); // Ensure that the exchange was removed. - const isValidExchange = await exchangeManager.validExchanges.callAsync(exchange); + const isValidExchange = await exchangeManager.validExchanges(exchange).callAsync(); expect(isValidExchange).to.be.false(); }); @@ -163,7 +163,7 @@ blockchainTests.resets('Exchange Unit Tests', env => { StakingRevertErrors.ExchangeManagerErrorCodes.ExchangeNotRegistered, nonExchange, ); - const tx = exchangeManager.removeExchangeAddress.awaitTransactionSuccessAsync(nonExchange, { + const tx = exchangeManager.removeExchangeAddress(nonExchange).awaitTransactionSuccessAsync({ from: authority, }); return expect(tx).to.revertWith(expectedError); diff --git a/contracts/staking/test/unit_tests/finalizer_test.ts b/contracts/staking/test/unit_tests/finalizer_test.ts index 8143917b34..1b3ca90fc2 100644 --- a/contracts/staking/test/unit_tests/finalizer_test.ts +++ b/contracts/staking/test/unit_tests/finalizer_test.ts @@ -75,13 +75,15 @@ blockchainTests.resets('Finalizer unit tests', env => { weightedStake: getRandomInteger(0, maxAmount), ...opts, }; - await testContract.addActivePool.awaitTransactionSuccessAsync( - _opts.poolId, - new BigNumber(_opts.operatorShare * constants.PPM_DENOMINATOR).integerValue(), - new BigNumber(_opts.feesCollected), - new BigNumber(_opts.membersStake), - new BigNumber(_opts.weightedStake), - ); + await testContract + .addActivePool( + _opts.poolId, + new BigNumber(_opts.operatorShare * constants.PPM_DENOMINATOR).integerValue(), + new BigNumber(_opts.feesCollected), + new BigNumber(_opts.membersStake), + new BigNumber(_opts.weightedStake), + ) + .awaitTransactionSuccessAsync(); return _opts; } @@ -94,13 +96,13 @@ blockchainTests.resets('Finalizer unit tests', env => { } async function getUnfinalizedStateAsync(): Promise { - return testContract.getAggregatedStatsForPreviousEpoch.callAsync(); + return testContract.getAggregatedStatsForPreviousEpoch().callAsync(); } async function finalizePoolsAsync(poolIds: string[]): Promise { const logs = [] as LogEntry[]; for (const poolId of poolIds) { - const receipt = await testContract.finalizePool.awaitTransactionSuccessAsync(poolId); + const receipt = await testContract.finalizePool(poolId).awaitTransactionSuccessAsync(); logs.splice(logs.length, 0, ...receipt.logs); } return logs; @@ -207,13 +209,15 @@ blockchainTests.resets('Finalizer unit tests', env => { if (feesCollected.isZero()) { continue; } - poolRewards[i] = await testContract.cobbDouglas.callAsync( - new BigNumber(rewardsAvailable), - new BigNumber(feesCollected), - new BigNumber(totalFees), - new BigNumber(pool.weightedStake), - new BigNumber(totalStake), - ); + poolRewards[i] = await testContract + .cobbDouglas( + new BigNumber(rewardsAvailable), + new BigNumber(feesCollected), + new BigNumber(totalFees), + new BigNumber(pool.weightedStake), + new BigNumber(totalStake), + ) + .callAsync(); } return poolRewards; } @@ -256,7 +260,7 @@ blockchainTests.resets('Finalizer unit tests', env => { } async function getCurrentEpochAsync(): Promise { - return testContract.currentEpoch.callAsync(); + return testContract.currentEpoch().callAsync(); } async function getBalanceOfAsync(whom: string): Promise { @@ -265,13 +269,13 @@ blockchainTests.resets('Finalizer unit tests', env => { describe('endEpoch()', () => { it('advances the epoch', async () => { - await testContract.endEpoch.awaitTransactionSuccessAsync(); - const currentEpoch = await testContract.currentEpoch.callAsync(); + await testContract.endEpoch().awaitTransactionSuccessAsync(); + const currentEpoch = await testContract.currentEpoch().callAsync(); expect(currentEpoch).to.bignumber.eq(stakingConstants.INITIAL_EPOCH.plus(1)); }); it('emits an `EpochEnded` event', async () => { - const receipt = await testContract.endEpoch.awaitTransactionSuccessAsync(); + const receipt = await testContract.endEpoch().awaitTransactionSuccessAsync(); assertEpochEndedEvent(receipt.logs, { epoch: stakingConstants.INITIAL_EPOCH, numActivePools: ZERO_AMOUNT, @@ -282,7 +286,7 @@ blockchainTests.resets('Finalizer unit tests', env => { }); it('immediately finalizes if there are no pools to finalize', async () => { - const receipt = await testContract.endEpoch.awaitTransactionSuccessAsync(); + const receipt = await testContract.endEpoch().awaitTransactionSuccessAsync(); assertEpochFinalizedEvent(receipt.logs, { epoch: stakingConstants.INITIAL_EPOCH, rewardsPaid: ZERO_AMOUNT, @@ -292,7 +296,7 @@ blockchainTests.resets('Finalizer unit tests', env => { it('does not immediately finalize if there is a pool to finalize', async () => { await addActivePoolAsync(); - const receipt = await testContract.endEpoch.awaitTransactionSuccessAsync(); + const receipt = await testContract.endEpoch().awaitTransactionSuccessAsync(); const events = filterLogsToArguments( receipt.logs, IStakingEventsEvents.EpochFinalized, @@ -303,7 +307,7 @@ blockchainTests.resets('Finalizer unit tests', env => { it('prepares unfinalized state', async () => { // Add a pool so there is state to clear. const pool = await addActivePoolAsync(); - await testContract.endEpoch.awaitTransactionSuccessAsync(); + await testContract.endEpoch().awaitTransactionSuccessAsync(); return assertUnfinalizedStateAsync({ numPoolsToFinalize: 1, rewardsAvailable: INITIAL_BALANCE, @@ -314,9 +318,9 @@ blockchainTests.resets('Finalizer unit tests', env => { it("correctly stores the epoch's aggregated stats after ending the epoch", async () => { const pool = await addActivePoolAsync(); - const epoch = await testContract.currentEpoch.callAsync(); - await testContract.endEpoch.awaitTransactionSuccessAsync(); - const aggregatedStats = await testContract.aggregatedStatsByEpoch.callAsync(epoch); + const epoch = await testContract.currentEpoch().callAsync(); + await testContract.endEpoch().awaitTransactionSuccessAsync(); + const aggregatedStats = await testContract.aggregatedStatsByEpoch(epoch).callAsync(); expect(aggregatedStats).to.be.deep.equal([ INITIAL_BALANCE, new BigNumber(1), // pools to finalize @@ -328,8 +332,8 @@ blockchainTests.resets('Finalizer unit tests', env => { it('reverts if the prior epoch is unfinalized', async () => { await addActivePoolAsync(); - await testContract.endEpoch.awaitTransactionSuccessAsync(); - const tx = testContract.endEpoch.awaitTransactionSuccessAsync(); + await testContract.endEpoch().awaitTransactionSuccessAsync(); + const tx = testContract.endEpoch().awaitTransactionSuccessAsync(); const expectedError = new StakingRevertErrors.PreviousEpochNotFinalizedError( stakingConstants.INITIAL_EPOCH, 1, @@ -340,7 +344,7 @@ blockchainTests.resets('Finalizer unit tests', env => { describe('_finalizePool()', () => { it('does nothing if there were no pools to finalize', async () => { - await testContract.endEpoch.awaitTransactionSuccessAsync(); + await testContract.endEpoch().awaitTransactionSuccessAsync(); const poolId = hexRandom(); const logs = await finalizePoolsAsync([poolId]); expect(logs).to.deep.eq([]); @@ -348,21 +352,21 @@ blockchainTests.resets('Finalizer unit tests', env => { it('can finalize a pool', async () => { const pool = await addActivePoolAsync(); - await testContract.endEpoch.awaitTransactionSuccessAsync(); + await testContract.endEpoch().awaitTransactionSuccessAsync(); const logs = await finalizePoolsAsync([pool.poolId]); return assertFinalizationLogsAndBalancesAsync(INITIAL_BALANCE, [pool], logs); }); it('can finalize multiple pools over multiple transactions', async () => { const pools = await Promise.all(_.times(2, async () => addActivePoolAsync())); - await testContract.endEpoch.awaitTransactionSuccessAsync(); + await testContract.endEpoch().awaitTransactionSuccessAsync(); const logs = await finalizePoolsAsync(pools.map(p => p.poolId)); return assertFinalizationLogsAndBalancesAsync(INITIAL_BALANCE, pools, logs); }); it('ignores a finalized pool', async () => { const pools = await Promise.all(_.times(3, async () => addActivePoolAsync())); - await testContract.endEpoch.awaitTransactionSuccessAsync(); + await testContract.endEpoch().awaitTransactionSuccessAsync(); const [finalizedPool] = _.sampleSize(pools, 1); await finalizePoolsAsync([finalizedPool.poolId]); const logs = await finalizePoolsAsync([finalizedPool.poolId]); @@ -373,12 +377,11 @@ blockchainTests.resets('Finalizer unit tests', env => { it('resets pool state after finalizing it', async () => { const pools = await Promise.all(_.times(3, async () => addActivePoolAsync())); const pool = _.sample(pools) as ActivePoolOpts; - await testContract.endEpoch.awaitTransactionSuccessAsync(); + await testContract.endEpoch().awaitTransactionSuccessAsync(); await finalizePoolsAsync([pool.poolId]); - const poolState = await testContract.getPoolStatsFromEpoch.callAsync( - stakingConstants.INITIAL_EPOCH, - pool.poolId, - ); + const poolState = await testContract + .getPoolStatsFromEpoch(stakingConstants.INITIAL_EPOCH, pool.poolId) + .callAsync(); expect(poolState.feesCollected).to.bignumber.eq(0); expect(poolState.weightedStake).to.bignumber.eq(0); expect(poolState.membersStake).to.bignumber.eq(0); @@ -386,7 +389,7 @@ blockchainTests.resets('Finalizer unit tests', env => { it('`rewardsPaid` <= `rewardsAvailable` <= contract balance at the end of the epoch', async () => { const pools = await Promise.all(_.times(3, async () => addActivePoolAsync())); - const receipt = await testContract.endEpoch.awaitTransactionSuccessAsync(); + const receipt = await testContract.endEpoch().awaitTransactionSuccessAsync(); const { rewardsAvailable } = getEpochEndedEvents(receipt.logs)[0]; expect(rewardsAvailable).to.bignumber.lte(INITIAL_BALANCE); const logs = await finalizePoolsAsync(pools.map(r => r.poolId)); @@ -397,7 +400,7 @@ blockchainTests.resets('Finalizer unit tests', env => { it('`rewardsPaid` <= `rewardsAvailable` with two equal pools', async () => { const pool1 = await addActivePoolAsync(); const pool2 = await addActivePoolAsync(_.omit(pool1, 'poolId')); - const receipt = await testContract.endEpoch.awaitTransactionSuccessAsync(); + const receipt = await testContract.endEpoch().awaitTransactionSuccessAsync(); const { rewardsAvailable } = getEpochEndedEvents(receipt.logs)[0]; const logs = await finalizePoolsAsync([pool1, pool2].map(r => r.poolId)); const { rewardsPaid } = getEpochFinalizedEvents(logs)[0]; @@ -410,7 +413,7 @@ blockchainTests.resets('Finalizer unit tests', env => { const numPools = _.random(1, 32); it(`${i + 1}/${numTests} \`rewardsPaid\` <= \`rewardsAvailable\` (${numPools} pools)`, async () => { const pools = await Promise.all(_.times(numPools, async () => addActivePoolAsync())); - const receipt = await testContract.endEpoch.awaitTransactionSuccessAsync(); + const receipt = await testContract.endEpoch().awaitTransactionSuccessAsync(); const { rewardsAvailable } = getEpochEndedEvents(receipt.logs)[0]; const logs = await finalizePoolsAsync(pools.map(r => r.poolId)); const { rewardsPaid } = getEpochFinalizedEvents(logs)[0]; @@ -423,18 +426,18 @@ blockchainTests.resets('Finalizer unit tests', env => { describe('lifecycle', () => { it('can advance the epoch after the prior epoch is finalized', async () => { const pool = await addActivePoolAsync(); - await testContract.endEpoch.awaitTransactionSuccessAsync(); + await testContract.endEpoch().awaitTransactionSuccessAsync(); await finalizePoolsAsync([pool.poolId]); - await testContract.endEpoch.awaitTransactionSuccessAsync(); + await testContract.endEpoch().awaitTransactionSuccessAsync(); return expect(getCurrentEpochAsync()).to.become(stakingConstants.INITIAL_EPOCH.plus(2)); }); it('does not reward a pool that only earned rewards 2 epochs ago', async () => { const pool1 = await addActivePoolAsync(); - await testContract.endEpoch.awaitTransactionSuccessAsync(); + await testContract.endEpoch().awaitTransactionSuccessAsync(); await finalizePoolsAsync([pool1.poolId]); await addActivePoolAsync(); - await testContract.endEpoch.awaitTransactionSuccessAsync(); + await testContract.endEpoch().awaitTransactionSuccessAsync(); expect(getCurrentEpochAsync()).to.become(stakingConstants.INITIAL_EPOCH.plus(2)); const logs = await finalizePoolsAsync([pool1.poolId]); const rewardsPaidEvents = getRewardsPaidEvents(logs); @@ -443,11 +446,11 @@ blockchainTests.resets('Finalizer unit tests', env => { it('does not reward a pool that only earned rewards 3 epochs ago', async () => { const pool1 = await addActivePoolAsync(); - await testContract.endEpoch.awaitTransactionSuccessAsync(); + await testContract.endEpoch().awaitTransactionSuccessAsync(); await finalizePoolsAsync([pool1.poolId]); - await testContract.endEpoch.awaitTransactionSuccessAsync(); + await testContract.endEpoch().awaitTransactionSuccessAsync(); await addActivePoolAsync(); - await testContract.endEpoch.awaitTransactionSuccessAsync(); + await testContract.endEpoch().awaitTransactionSuccessAsync(); expect(getCurrentEpochAsync()).to.become(stakingConstants.INITIAL_EPOCH.plus(3)); const logs = await finalizePoolsAsync([pool1.poolId]); const rewardsPaidEvents = getRewardsPaidEvents(logs); @@ -457,11 +460,11 @@ blockchainTests.resets('Finalizer unit tests', env => { it('rolls over leftover rewards into the next epoch', async () => { const poolIds = _.times(3, () => hexRandom()); await Promise.all(poolIds.map(async id => addActivePoolAsync({ poolId: id }))); - await testContract.endEpoch.awaitTransactionSuccessAsync(); + await testContract.endEpoch().awaitTransactionSuccessAsync(); const finalizeLogs = await finalizePoolsAsync(poolIds); const { rewardsRemaining: rolledOverRewards } = getEpochFinalizedEvents(finalizeLogs)[0]; await Promise.all(poolIds.map(async id => addActivePoolAsync({ poolId: id }))); - const { logs: endEpochLogs } = await testContract.endEpoch.awaitTransactionSuccessAsync(); + const { logs: endEpochLogs } = await testContract.endEpoch().awaitTransactionSuccessAsync(); const { rewardsAvailable } = getEpochEndedEvents(endEpochLogs)[0]; expect(rewardsAvailable).to.bignumber.eq(rolledOverRewards); }); @@ -476,7 +479,7 @@ blockchainTests.resets('Finalizer unit tests', env => { poolId: string, expected: Partial, ): Promise { - const actual = await testContract.getUnfinalizedPoolRewards.callAsync(poolId); + const actual = await testContract.getUnfinalizedPoolRewards(poolId).callAsync(); if (expected.totalReward !== undefined) { expect(actual.totalReward).to.bignumber.eq(expected.totalReward); } @@ -497,7 +500,7 @@ blockchainTests.resets('Finalizer unit tests', env => { }); it('returns empty if pool did not earn rewards', async () => { - await testContract.endEpoch.awaitTransactionSuccessAsync(); + await testContract.endEpoch().awaitTransactionSuccessAsync(); const poolId = hexRandom(); return assertUnfinalizedPoolRewardsAsync(poolId, ZERO_REWARDS); }); @@ -509,7 +512,7 @@ blockchainTests.resets('Finalizer unit tests', env => { it('returns empty if pool only earned rewards in the 2 epochs ago', async () => { const pool = await addActivePoolAsync(); - await testContract.endEpoch.awaitTransactionSuccessAsync(); + await testContract.endEpoch().awaitTransactionSuccessAsync(); await finalizePoolsAsync([pool.poolId]); return assertUnfinalizedPoolRewardsAsync(pool.poolId, ZERO_REWARDS); }); @@ -517,14 +520,14 @@ blockchainTests.resets('Finalizer unit tests', env => { it('returns empty if pool was already finalized', async () => { const pools = await Promise.all(_.times(3, async () => addActivePoolAsync())); const [pool] = _.sampleSize(pools, 1); - await testContract.endEpoch.awaitTransactionSuccessAsync(); + await testContract.endEpoch().awaitTransactionSuccessAsync(); await finalizePoolsAsync([pool.poolId]); return assertUnfinalizedPoolRewardsAsync(pool.poolId, ZERO_REWARDS); }); it('computes one reward among one pool', async () => { const pool = await addActivePoolAsync(); - await testContract.endEpoch.awaitTransactionSuccessAsync(); + await testContract.endEpoch().awaitTransactionSuccessAsync(); const expectedTotalRewards = INITIAL_BALANCE; return assertUnfinalizedPoolRewardsAsync(pool.poolId, { totalReward: expectedTotalRewards, @@ -534,7 +537,7 @@ blockchainTests.resets('Finalizer unit tests', env => { it('computes one reward among multiple pools', async () => { const pools = await Promise.all(_.times(3, async () => addActivePoolAsync())); - await testContract.endEpoch.awaitTransactionSuccessAsync(); + await testContract.endEpoch().awaitTransactionSuccessAsync(); const expectedPoolRewards = await calculatePoolRewardsAsync(INITIAL_BALANCE, pools); const [pool, reward] = _.sampleSize(shortZip(pools, expectedPoolRewards), 1)[0]; return assertUnfinalizedPoolRewardsAsync(pool.poolId, { @@ -545,7 +548,7 @@ blockchainTests.resets('Finalizer unit tests', env => { it('computes a reward with 0% operatorShare', async () => { const pool = await addActivePoolAsync({ operatorShare: 0 }); - await testContract.endEpoch.awaitTransactionSuccessAsync(); + await testContract.endEpoch().awaitTransactionSuccessAsync(); return assertUnfinalizedPoolRewardsAsync(pool.poolId, { totalReward: INITIAL_BALANCE, membersStake: pool.membersStake, @@ -554,7 +557,7 @@ blockchainTests.resets('Finalizer unit tests', env => { it('computes a reward with 0% < operatorShare < 100%', async () => { const pool = await addActivePoolAsync({ operatorShare: Math.random() }); - await testContract.endEpoch.awaitTransactionSuccessAsync(); + await testContract.endEpoch().awaitTransactionSuccessAsync(); return assertUnfinalizedPoolRewardsAsync(pool.poolId, { totalReward: INITIAL_BALANCE, membersStake: pool.membersStake, @@ -563,7 +566,7 @@ blockchainTests.resets('Finalizer unit tests', env => { it('computes a reward with 100% operatorShare', async () => { const pool = await addActivePoolAsync({ operatorShare: 1 }); - await testContract.endEpoch.awaitTransactionSuccessAsync(); + await testContract.endEpoch().awaitTransactionSuccessAsync(); return assertUnfinalizedPoolRewardsAsync(pool.poolId, { totalReward: INITIAL_BALANCE, membersStake: pool.membersStake, diff --git a/contracts/staking/test/unit_tests/lib_cobb_douglas_test.ts b/contracts/staking/test/unit_tests/lib_cobb_douglas_test.ts index e0080e560e..787c5405c4 100644 --- a/contracts/staking/test/unit_tests/lib_cobb_douglas_test.ts +++ b/contracts/staking/test/unit_tests/lib_cobb_douglas_test.ts @@ -55,18 +55,19 @@ blockchainTests('LibCobbDouglas unit tests', env => { ...DEFAULT_COBB_DOUGLAS_PARAMS, ...params, }; - return testContract.cobbDouglas.callAsync( - new BigNumber(_params.totalRewards), - new BigNumber(_params.ownerFees), - new BigNumber(_params.totalFees), - new BigNumber(_params.ownerStake), - new BigNumber(_params.totalStake), - new BigNumber(_params.alphaNumerator), - new BigNumber(_params.alphaDenominator), - { + return testContract + .cobbDouglas( + new BigNumber(_params.totalRewards), + new BigNumber(_params.ownerFees), + new BigNumber(_params.totalFees), + new BigNumber(_params.ownerStake), + new BigNumber(_params.totalStake), + new BigNumber(_params.alphaNumerator), + new BigNumber(_params.alphaDenominator), + ) + .callAsync({ gas: TX_GAS_FEE + (_params.gas === undefined ? MAX_COBB_DOUGLAS_GAS : _params.gas), - }, - ); + }); } function cobbDouglas(params?: Partial): BigNumber { diff --git a/contracts/staking/test/unit_tests/lib_fixed_math_test.ts b/contracts/staking/test/unit_tests/lib_fixed_math_test.ts index 2e98089a67..c53f1ec7d8 100644 --- a/contracts/staking/test/unit_tests/lib_fixed_math_test.ts +++ b/contracts/staking/test/unit_tests/lib_fixed_math_test.ts @@ -40,7 +40,7 @@ blockchainTests('LibFixedMath unit tests', env => { describe('one()', () => { it('equals 1', async () => { - const r = await testContract.one.callAsync(); + const r = await testContract.one().callAsync(); assertFixedEquals(r, 1); }); }); @@ -48,25 +48,25 @@ blockchainTests('LibFixedMath unit tests', env => { describe('abs()', () => { it('abs(n) == n', async () => { const n = 1337.5912; - const r = await testContract.abs.callAsync(toFixed(n)); + const r = await testContract.abs(toFixed(n)).callAsync(); assertFixedEquals(r, n); }); it('abs(-n) == n', async () => { const n = -1337.5912; - const r = await testContract.abs.callAsync(toFixed(n)); + const r = await testContract.abs(toFixed(n)).callAsync(); assertFixedEquals(r, -n); }); it('abs(0) == 0', async () => { const n = 0; - const r = await testContract.abs.callAsync(toFixed(n)); + const r = await testContract.abs(toFixed(n)).callAsync(); expect(r).to.bignumber.eq(0); }); it('abs(MAX_FIXED) == MAX_FIXED', async () => { const n = MAX_FIXED_VALUE; - const r = await testContract.abs.callAsync(n); + const r = await testContract.abs(n).callAsync(); expect(r).to.bignumber.eq(n); }); @@ -76,19 +76,19 @@ blockchainTests('LibFixedMath unit tests', env => { FixedMathRevertErrors.ValueErrorCodes.TooSmall, n, ); - const tx = testContract.abs.callAsync(n); + const tx = testContract.abs(n).callAsync(); return expect(tx).to.revertWith(expectedError); }); it('abs(int(-1)) == int(1)', async () => { const n = -1; - const r = await testContract.abs.callAsync(new BigNumber(n)); + const r = await testContract.abs(new BigNumber(n)).callAsync(); expect(r).to.bignumber.eq(1); }); it('abs(int(1)) == int(1)', async () => { const n = 1; - const r = await testContract.abs.callAsync(new BigNumber(n)); + const r = await testContract.abs(new BigNumber(n)).callAsync(); expect(r).to.bignumber.eq(1); }); }); @@ -96,19 +96,19 @@ blockchainTests('LibFixedMath unit tests', env => { describe('invert()', () => { it('invert(1) == 1', async () => { const n = 1; - const r = await testContract.invert.callAsync(toFixed(n)); + const r = await testContract.invert(toFixed(n)).callAsync(); assertFixedEquals(r, n); }); it('invert(n) == 1 / n', async () => { const n = 1337.5912; - const r = await testContract.invert.callAsync(toFixed(n)); + const r = await testContract.invert(toFixed(n)).callAsync(); assertFixedRoughlyEquals(r, 1 / n); }); it('invert(-n) == -1 / n', async () => { const n = -1337.5912; - const r = await testContract.invert.callAsync(toFixed(n)); + const r = await testContract.invert(toFixed(n)).callAsync(); assertFixedRoughlyEquals(r, 1 / n); }); @@ -116,7 +116,7 @@ blockchainTests('LibFixedMath unit tests', env => { const expectedError = new FixedMathRevertErrors.BinOpError( FixedMathRevertErrors.BinOpErrorCodes.DivisionByZero, ); - const tx = testContract.invert.callAsync(toFixed(0)); + const tx = testContract.invert(toFixed(0)).callAsync(); return expect(tx).to.revertWith(expectedError); }); }); @@ -124,31 +124,31 @@ blockchainTests('LibFixedMath unit tests', env => { describe('mulDiv()', () => { it('mulDiv(0, 0, 1) == 0', async () => { const [a, n, d] = [0, 0, 1]; - const r = await testContract.mulDiv.callAsync(toFixed(a), new BigNumber(n), new BigNumber(d)); + const r = await testContract.mulDiv(toFixed(a), new BigNumber(n), new BigNumber(d)).callAsync(); assertFixedEquals(r, 0); }); it('mulDiv(0, x, y) == 0', async () => { const [a, n, d] = [0, 13, 300]; - const r = await testContract.mulDiv.callAsync(toFixed(a), new BigNumber(n), new BigNumber(d)); + const r = await testContract.mulDiv(toFixed(a), new BigNumber(n), new BigNumber(d)).callAsync(); assertFixedEquals(r, 0); }); it('mulDiv(x, y, y) == x', async () => { const [a, n, d] = [1.2345, 149, 149]; - const r = await testContract.mulDiv.callAsync(toFixed(a), new BigNumber(n), new BigNumber(d)); + const r = await testContract.mulDiv(toFixed(a), new BigNumber(n), new BigNumber(d)).callAsync(); assertFixedEquals(r, a); }); it('mulDiv(x, -y, y) == -x', async () => { const [a, n, d] = [1.2345, -149, 149]; - const r = await testContract.mulDiv.callAsync(toFixed(a), new BigNumber(n), new BigNumber(d)); + const r = await testContract.mulDiv(toFixed(a), new BigNumber(n), new BigNumber(d)).callAsync(); assertFixedEquals(r, -a); }); it('mulDiv(-x, -y, y) == x', async () => { const [a, n, d] = [-1.2345, -149, 149]; - const r = await testContract.mulDiv.callAsync(toFixed(a), new BigNumber(n), new BigNumber(d)); + const r = await testContract.mulDiv(toFixed(a), new BigNumber(n), new BigNumber(d)).callAsync(); assertFixedEquals(r, -a); }); @@ -157,19 +157,19 @@ blockchainTests('LibFixedMath unit tests', env => { const expectedError = new FixedMathRevertErrors.BinOpError( FixedMathRevertErrors.BinOpErrorCodes.DivisionByZero, ); - const tx = testContract.mulDiv.callAsync(toFixed(a), new BigNumber(n), new BigNumber(d)); + const tx = testContract.mulDiv(toFixed(a), new BigNumber(n), new BigNumber(d)).callAsync(); return expect(tx).to.revertWith(expectedError); }); it('mulDiv(int(-1), int(1), int(-1)) == int(1)', async () => { const [a, n, d] = [-1, 1, -1]; - const r = await testContract.mulDiv.callAsync(new BigNumber(a), new BigNumber(n), new BigNumber(d)); + const r = await testContract.mulDiv(new BigNumber(a), new BigNumber(n), new BigNumber(d)).callAsync(); assertFixedEquals(r, fromFixed(1)); }); it('mulDiv(int(1), int(-1), int(-1)) == int(1)', async () => { const [a, n, d] = [1, -1, -1]; - const r = await testContract.mulDiv.callAsync(new BigNumber(a), new BigNumber(n), new BigNumber(d)); + const r = await testContract.mulDiv(new BigNumber(a), new BigNumber(n), new BigNumber(d)).callAsync(); assertFixedEquals(r, fromFixed(1)); }); @@ -180,7 +180,7 @@ blockchainTests('LibFixedMath unit tests', env => { a, n, ); - const tx = testContract.mulDiv.callAsync(a, new BigNumber(n), new BigNumber(d)); + const tx = testContract.mulDiv(a, new BigNumber(n), new BigNumber(d)).callAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -191,7 +191,7 @@ blockchainTests('LibFixedMath unit tests', env => { a, n, ); - const tx = testContract.mulDiv.callAsync(new BigNumber(a), n, new BigNumber(d)); + const tx = testContract.mulDiv(new BigNumber(a), n, new BigNumber(d)).callAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -202,19 +202,19 @@ blockchainTests('LibFixedMath unit tests', env => { a, d, ); - const tx = testContract.mulDiv.callAsync(a, new BigNumber(n), new BigNumber(d)); + const tx = testContract.mulDiv(a, new BigNumber(n), new BigNumber(d)).callAsync(); return expect(tx).to.revertWith(expectedError); }); it('mulDiv(MAX_FIXED, int(-1), int(1)) == -MAX_FIXED', async () => { const [a, n, d] = [MAX_FIXED_VALUE, -1, 1]; - const r = await testContract.mulDiv.callAsync(a, new BigNumber(n), new BigNumber(d)); + const r = await testContract.mulDiv(a, new BigNumber(n), new BigNumber(d)).callAsync(); expect(r).to.bignumber.eq(MAX_FIXED_VALUE.negated()); }); it('mulDiv(MAX_FIXED, int(1), int(-1)) == -MAX_FIXED', async () => { const [a, n, d] = [MAX_FIXED_VALUE, 1, -1]; - const r = await testContract.mulDiv.callAsync(a, new BigNumber(n), new BigNumber(d)); + const r = await testContract.mulDiv(a, new BigNumber(n), new BigNumber(d)).callAsync(); expect(r).to.bignumber.eq(MAX_FIXED_VALUE.negated()); }); }); @@ -226,19 +226,19 @@ blockchainTests('LibFixedMath unit tests', env => { it('0 + 0 == 0', async () => { const [a, b] = [0, 0]; - const r = await testContract.add.callAsync(toFixed(a), toFixed(b)); + const r = await testContract.add(toFixed(a), toFixed(b)).callAsync(); assertFixedEquals(r, 0); }); it('adds two positive decimals', async () => { const [a, b] = ['9310841.31841', '491021921.318948193']; - const r = await testContract.add.callAsync(toFixed(a), toFixed(b)); + const r = await testContract.add(toFixed(a), toFixed(b)).callAsync(); assertFixedEquals(r, add(a, b)); }); it('adds two mixed decimals', async () => { const [a, b] = ['9310841.31841', '-491021921.318948193']; - const r = await testContract.add.callAsync(toFixed(a), toFixed(b)); + const r = await testContract.add(toFixed(a), toFixed(b)).callAsync(); assertFixedEquals(r, add(a, b)); }); @@ -249,7 +249,7 @@ blockchainTests('LibFixedMath unit tests', env => { a, b, ); - const tx = testContract.add.callAsync(a, b); + const tx = testContract.add(a, b).callAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -260,7 +260,7 @@ blockchainTests('LibFixedMath unit tests', env => { a, b, ); - const tx = testContract.add.callAsync(a, b); + const tx = testContract.add(a, b).callAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -271,7 +271,7 @@ blockchainTests('LibFixedMath unit tests', env => { a, b, ); - const tx = testContract.add.callAsync(a, b); + const tx = testContract.add(a, b).callAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -282,19 +282,19 @@ blockchainTests('LibFixedMath unit tests', env => { a, b, ); - const tx = testContract.add.callAsync(a, b); + const tx = testContract.add(a, b).callAsync(); return expect(tx).to.revertWith(expectedError); }); it('MIN_FIXED + MAX_FIXED == int(-1)', async () => { const [a, b] = [MIN_FIXED_VALUE, MAX_FIXED_VALUE]; - const r = await testContract.add.callAsync(a, b); + const r = await testContract.add(a, b).callAsync(); expect(r).to.bignumber.eq(-1); }); it('MAX_FIXED + (MIN_FIXED + int(1)) == 0', async () => { const [a, b] = [MAX_FIXED_VALUE, MIN_FIXED_VALUE.plus(1)]; - const r = await testContract.add.callAsync(a, b); + const r = await testContract.add(a, b).callAsync(); expect(r).to.bignumber.eq(0); }); }); @@ -306,19 +306,19 @@ blockchainTests('LibFixedMath unit tests', env => { it('0 - 0 == 0', async () => { const [a, b] = [0, 0]; - const r = await testContract.sub.callAsync(toFixed(a), toFixed(b)); + const r = await testContract.sub(toFixed(a), toFixed(b)).callAsync(); assertFixedEquals(r, 0); }); it('subtracts two positive decimals', async () => { const [a, b] = ['9310841.31841', '491021921.318948193']; - const r = await testContract.sub.callAsync(toFixed(a), toFixed(b)); + const r = await testContract.sub(toFixed(a), toFixed(b)).callAsync(); assertFixedEquals(r, sub(a, b)); }); it('subtracts two mixed decimals', async () => { const [a, b] = ['9310841.31841', '-491021921.318948193']; - const r = await testContract.sub.callAsync(toFixed(a), toFixed(b)); + const r = await testContract.sub(toFixed(a), toFixed(b)).callAsync(); assertFixedEquals(r, sub(a, b)); }); @@ -329,7 +329,7 @@ blockchainTests('LibFixedMath unit tests', env => { a, b.negated(), ); - const tx = testContract.sub.callAsync(a, b); + const tx = testContract.sub(a, b).callAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -340,7 +340,7 @@ blockchainTests('LibFixedMath unit tests', env => { a, b.negated(), ); - const tx = testContract.sub.callAsync(a, b); + const tx = testContract.sub(a, b).callAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -352,13 +352,13 @@ blockchainTests('LibFixedMath unit tests', env => { FixedMathRevertErrors.ValueErrorCodes.TooSmall, b, ); - const tx = testContract.sub.callAsync(a, b); + const tx = testContract.sub(a, b).callAsync(); return expect(tx).to.revertWith(expectedError); }); it('MAX_FIXED - MAX_FIXED == 0', async () => { const [a, b] = [MAX_FIXED_VALUE, MAX_FIXED_VALUE]; - const r = await testContract.sub.callAsync(a, b); + const r = await testContract.sub(a, b).callAsync(); expect(r).to.bignumber.eq(0); }); @@ -369,7 +369,7 @@ blockchainTests('LibFixedMath unit tests', env => { a, b.negated(), ); - const tx = testContract.sub.callAsync(a, b); + const tx = testContract.sub(a, b).callAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -379,7 +379,7 @@ blockchainTests('LibFixedMath unit tests', env => { FixedMathRevertErrors.ValueErrorCodes.TooSmall, b, ); - const tx = testContract.sub.callAsync(a, b); + const tx = testContract.sub(a, b).callAsync(); return expect(tx).to.revertWith(expectedError); }); }); @@ -395,31 +395,31 @@ blockchainTests('LibFixedMath unit tests', env => { it('x * 0 == 0', async () => { const [a, b] = [1337, 0]; - const r = await testContract.mul.callAsync(toFixed(a), toFixed(b)); + const r = await testContract.mul(toFixed(a), toFixed(b)).callAsync(); assertFixedEquals(r, b); }); it('x * 1 == x', async () => { const [a, b] = [0.5, 1]; - const r = await testContract.mul.callAsync(toFixed(a), toFixed(b)); + const r = await testContract.mul(toFixed(a), toFixed(b)).callAsync(); assertFixedEquals(r, a); }); it('x * -1 == -x', async () => { const [a, b] = [0.5, -1]; - const r = await testContract.mul.callAsync(toFixed(a), toFixed(b)); + const r = await testContract.mul(toFixed(a), toFixed(b)).callAsync(); assertFixedEquals(r, -a); }); it('multiplies two positive decimals', async () => { const [a, b] = ['1.25394912112', '0.03413318948193']; - const r = await testContract.mul.callAsync(toFixed(a), toFixed(b)); + const r = await testContract.mul(toFixed(a), toFixed(b)).callAsync(); assertFixedEquals(r, mul(a, b)); }); it('multiplies two mixed decimals', async () => { const [a, b] = ['1.25394912112', '-0.03413318948193']; - const r = await testContract.mul.callAsync(toFixed(a), toFixed(b)); + const r = await testContract.mul(toFixed(a), toFixed(b)).callAsync(); assertFixedEquals(r, mul(a, b)); }); @@ -430,7 +430,7 @@ blockchainTests('LibFixedMath unit tests', env => { a, b, ); - const tx = testContract.mul.callAsync(a, b); + const tx = testContract.mul(a, b).callAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -441,13 +441,13 @@ blockchainTests('LibFixedMath unit tests', env => { a, b, ); - const tx = testContract.mul.callAsync(a, b); + const tx = testContract.mul(a, b).callAsync(); return expect(tx).to.revertWith(expectedError); }); it('MAX_FIXED * int(1) == MAX_FIXED / FIXED_1', async () => { const [a, b] = [MAX_FIXED_VALUE, 1]; - const r = await testContract.mul.callAsync(a, new BigNumber(b)); + const r = await testContract.mul(a, new BigNumber(b)).callAsync(); expect(r).to.bignumber.eq(MAX_FIXED_VALUE.dividedToIntegerBy(FIXED_1)); }); @@ -458,7 +458,7 @@ blockchainTests('LibFixedMath unit tests', env => { a, b, ); - const tx = testContract.mul.callAsync(a, new BigNumber(b)); + const tx = testContract.mul(a, new BigNumber(b)).callAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -469,7 +469,7 @@ blockchainTests('LibFixedMath unit tests', env => { a, b, ); - const tx = testContract.mul.callAsync(a, b); + const tx = testContract.mul(a, b).callAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -480,7 +480,7 @@ blockchainTests('LibFixedMath unit tests', env => { a, b, ); - const tx = testContract.mul.callAsync(a, b); + const tx = testContract.mul(a, b).callAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -491,7 +491,7 @@ blockchainTests('LibFixedMath unit tests', env => { a, b, ); - const tx = testContract.mul.callAsync(a, b); + const tx = testContract.mul(a, b).callAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -502,7 +502,7 @@ blockchainTests('LibFixedMath unit tests', env => { a, b, ); - const tx = testContract.mul.callAsync(a, new BigNumber(b)); + const tx = testContract.mul(a, new BigNumber(b)).callAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -513,13 +513,13 @@ blockchainTests('LibFixedMath unit tests', env => { a, b, ); - const tx = testContract.mul.callAsync(new BigNumber(a), b); + const tx = testContract.mul(new BigNumber(a), b).callAsync(); return expect(tx).to.revertWith(expectedError); }); it('MAX_FIXED * int(-1) == -MAX_FIXED / FIXED_1', async () => { const [a, b] = [MAX_FIXED_VALUE, -1]; - const r = await testContract.mul.callAsync(a, new BigNumber(b)); + const r = await testContract.mul(a, new BigNumber(b)).callAsync(); expect(r).to.bignumber.eq(MAX_FIXED_VALUE.negated().dividedToIntegerBy(FIXED_1)); }); }); @@ -540,31 +540,31 @@ blockchainTests('LibFixedMath unit tests', env => { toFixed(a).times(FIXED_POINT_DIVISOR), toFixed(b), ); - const tx = testContract.div.callAsync(toFixed(a), toFixed(b)); + const tx = testContract.div(toFixed(a), toFixed(b)).callAsync(); return expect(tx).to.revertWith(expectedError); }); it('x / 1 == x', async () => { const [a, b] = [1.41214552, 1]; - const r = await testContract.div.callAsync(toFixed(a), toFixed(b)); + const r = await testContract.div(toFixed(a), toFixed(b)).callAsync(); assertFixedEquals(r, a); }); it('x / -1 == -x', async () => { const [a, b] = [1.109312, -1]; - const r = await testContract.div.callAsync(toFixed(a), toFixed(b)); + const r = await testContract.div(toFixed(a), toFixed(b)).callAsync(); assertFixedEquals(r, -a); }); it('divides two positive decimals', async () => { const [a, b] = ['1.25394912112', '0.03413318948193']; - const r = await testContract.div.callAsync(toFixed(a), toFixed(b)); + const r = await testContract.div(toFixed(a), toFixed(b)).callAsync(); assertFixedEquals(r, div(a, b)); }); it('divides two mixed decimals', async () => { const [a, b] = ['1.25394912112', '-0.03413318948193']; - const r = await testContract.div.callAsync(toFixed(a), toFixed(b)); + const r = await testContract.div(toFixed(a), toFixed(b)).callAsync(); assertFixedEquals(r, div(a, b)); }); @@ -575,7 +575,7 @@ blockchainTests('LibFixedMath unit tests', env => { a, FIXED_1, ); - const tx = testContract.div.callAsync(a, new BigNumber(b)); + const tx = testContract.div(a, new BigNumber(b)).callAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -586,13 +586,13 @@ blockchainTests('LibFixedMath unit tests', env => { a, FIXED_1, ); - const tx = testContract.div.callAsync(a, new BigNumber(b)); + const tx = testContract.div(a, new BigNumber(b)).callAsync(); return expect(tx).to.revertWith(expectedError); }); it('int(-1) / MIN_FIXED == 0', async () => { const [a, b] = [-1, MIN_FIXED_VALUE]; - const r = await testContract.div.callAsync(new BigNumber(a), b); + const r = await testContract.div(new BigNumber(a), b).callAsync(); expect(r).to.bignumber.eq(0); }); }); @@ -600,31 +600,31 @@ blockchainTests('LibFixedMath unit tests', env => { describe('uintMul()', () => { it('0 * x == 0', async () => { const [a, b] = [0, 1234]; - const r = await testContract.uintMul.callAsync(toFixed(a), new BigNumber(b)); + const r = await testContract.uintMul(toFixed(a), new BigNumber(b)).callAsync(); expect(r).to.bignumber.eq(0); }); it('1 * x == int(x)', async () => { const [a, b] = [1, 1234]; - const r = await testContract.uintMul.callAsync(toFixed(a), new BigNumber(b)); + const r = await testContract.uintMul(toFixed(a), new BigNumber(b)).callAsync(); expect(r).to.bignumber.eq(Math.trunc(b)); }); it('-1 * x == 0', async () => { const [a, b] = [-1, 1234]; - const r = await testContract.uintMul.callAsync(toFixed(a), new BigNumber(b)); + const r = await testContract.uintMul(toFixed(a), new BigNumber(b)).callAsync(); expect(r).to.bignumber.eq(0); }); it('0.5 * x == x/2', async () => { const [a, b] = [0.5, 1234]; - const r = await testContract.uintMul.callAsync(toFixed(a), new BigNumber(b)); + const r = await testContract.uintMul(toFixed(a), new BigNumber(b)).callAsync(); expect(r).to.bignumber.eq(b / 2); }); it('0.5 * x == 0 if x = 1', async () => { const [a, b] = [0.5, 1]; - const r = await testContract.uintMul.callAsync(toFixed(a), new BigNumber(b)); + const r = await testContract.uintMul(toFixed(a), new BigNumber(b)).callAsync(); expect(r).to.bignumber.eq(0); }); @@ -634,7 +634,7 @@ blockchainTests('LibFixedMath unit tests', env => { FixedMathRevertErrors.ValueErrorCodes.TooLarge, b, ); - const tx = testContract.uintMul.callAsync(a, b); + const tx = testContract.uintMul(a, b).callAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -645,7 +645,7 @@ blockchainTests('LibFixedMath unit tests', env => { a, b, ); - const tx = testContract.uintMul.callAsync(a, b); + const tx = testContract.uintMul(a, b).callAsync(); return expect(tx).to.revertWith(expectedError); }); }); @@ -653,31 +653,31 @@ blockchainTests('LibFixedMath unit tests', env => { describe('toInteger()', () => { it('toInteger(n) == int(n)', async () => { const n = 1337.5912; - const r = await testContract.toInteger.callAsync(toFixed(n)); + const r = await testContract.toInteger(toFixed(n)).callAsync(); expect(r).to.bignumber.eq(Math.trunc(n)); }); it('toInteger(-n) == -int(n)', async () => { const n = -1337.5912; - const r = await testContract.toInteger.callAsync(toFixed(n)); + const r = await testContract.toInteger(toFixed(n)).callAsync(); expect(r).to.bignumber.eq(Math.trunc(n)); }); it('toInteger(n) == 0, when 0 < n < 1', async () => { const n = 0.9995; - const r = await testContract.toInteger.callAsync(toFixed(n)); + const r = await testContract.toInteger(toFixed(n)).callAsync(); expect(r).to.bignumber.eq(0); }); it('toInteger(-n) == 0, when -1 < n < 0', async () => { const n = -0.9995; - const r = await testContract.toInteger.callAsync(toFixed(n)); + const r = await testContract.toInteger(toFixed(n)).callAsync(); expect(r).to.bignumber.eq(0); }); it('toInteger(0) == 0', async () => { const n = 0; - const r = await testContract.toInteger.callAsync(toFixed(n)); + const r = await testContract.toInteger(toFixed(n)).callAsync(); expect(r).to.bignumber.eq(0); }); }); @@ -686,37 +686,37 @@ blockchainTests('LibFixedMath unit tests', env => { describe('signed', () => { it('converts a positive integer', async () => { const n = 1337; - const r = await testContract.toFixedSigned1.callAsync(new BigNumber(n)); + const r = await testContract.toFixedSigned1(new BigNumber(n)).callAsync(); assertFixedEquals(r, n); }); it('converts a negative integer', async () => { const n = -1337; - const r = await testContract.toFixedSigned1.callAsync(new BigNumber(n)); + const r = await testContract.toFixedSigned1(new BigNumber(n)).callAsync(); assertFixedEquals(r, n); }); it('converts a fraction with a positive numerator and denominator', async () => { const [n, d] = [1337, 1000]; - const r = await testContract.toFixedSigned2.callAsync(new BigNumber(n), new BigNumber(d)); + const r = await testContract.toFixedSigned2(new BigNumber(n), new BigNumber(d)).callAsync(); assertFixedEquals(r, n / d); }); it('converts a fraction with a negative numerator and positive denominator', async () => { const [n, d] = [-1337, 1000]; - const r = await testContract.toFixedSigned2.callAsync(new BigNumber(n), new BigNumber(d)); + const r = await testContract.toFixedSigned2(new BigNumber(n), new BigNumber(d)).callAsync(); assertFixedEquals(r, n / d); }); it('converts a fraction with a negative numerator and denominator', async () => { const [n, d] = [-1337, -1000]; - const r = await testContract.toFixedSigned2.callAsync(new BigNumber(n), new BigNumber(d)); + const r = await testContract.toFixedSigned2(new BigNumber(n), new BigNumber(d)).callAsync(); assertFixedEquals(r, n / d); }); it('converts a fraction with a negative numerator and negative denominator', async () => { const [n, d] = [-1337, -1000]; - const r = await testContract.toFixedSigned2.callAsync(new BigNumber(n), new BigNumber(d)); + const r = await testContract.toFixedSigned2(new BigNumber(n), new BigNumber(d)).callAsync(); assertFixedEquals(r, n / d); }); @@ -727,7 +727,7 @@ blockchainTests('LibFixedMath unit tests', env => { n, FIXED_POINT_DIVISOR, ); - const tx = testContract.toFixedSigned2.callAsync(n, d); + const tx = testContract.toFixedSigned2(n, d).callAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -738,7 +738,7 @@ blockchainTests('LibFixedMath unit tests', env => { n.times(FIXED_POINT_DIVISOR), d, ); - const tx = testContract.toFixedSigned2.callAsync(n, d); + const tx = testContract.toFixedSigned2(n, d).callAsync(); return expect(tx).to.revertWith(expectedError); }); }); @@ -746,13 +746,13 @@ blockchainTests('LibFixedMath unit tests', env => { describe('unsigned', () => { it('converts an integer', async () => { const n = 1337; - const r = await testContract.toFixedUnsigned1.callAsync(new BigNumber(n)); + const r = await testContract.toFixedUnsigned1(new BigNumber(n)).callAsync(); assertFixedEquals(r, n); }); it('converts a fraction', async () => { const [n, d] = [1337, 1000]; - const r = await testContract.toFixedUnsigned2.callAsync(new BigNumber(n), new BigNumber(d)); + const r = await testContract.toFixedUnsigned2(new BigNumber(n), new BigNumber(d)).callAsync(); assertFixedEquals(r, n / d); }); @@ -762,7 +762,7 @@ blockchainTests('LibFixedMath unit tests', env => { FixedMathRevertErrors.ValueErrorCodes.TooLarge, n, ); - const tx = testContract.toFixedUnsigned2.callAsync(n, d); + const tx = testContract.toFixedUnsigned2(n, d).callAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -772,7 +772,7 @@ blockchainTests('LibFixedMath unit tests', env => { FixedMathRevertErrors.ValueErrorCodes.TooLarge, d, ); - const tx = testContract.toFixedUnsigned2.callAsync(n, d); + const tx = testContract.toFixedUnsigned2(n, d).callAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -783,7 +783,7 @@ blockchainTests('LibFixedMath unit tests', env => { n, FIXED_POINT_DIVISOR, ); - const tx = testContract.toFixedUnsigned2.callAsync(n, d); + const tx = testContract.toFixedUnsigned2(n, d).callAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -794,7 +794,7 @@ blockchainTests('LibFixedMath unit tests', env => { n.times(FIXED_POINT_DIVISOR), d, ); - const tx = testContract.toFixedUnsigned2.callAsync(n, d); + const tx = testContract.toFixedUnsigned2(n, d).callAsync(); return expect(tx).to.revertWith(expectedError); }); }); @@ -823,7 +823,7 @@ blockchainTests('LibFixedMath unit tests', env => { FixedMathRevertErrors.ValueErrorCodes.TooSmall, x, ); - const tx = testContract.ln.callAsync(x); + const tx = testContract.ln(x).callAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -833,7 +833,7 @@ blockchainTests('LibFixedMath unit tests', env => { FixedMathRevertErrors.ValueErrorCodes.TooLarge, x, ); - const tx = testContract.ln.callAsync(x); + const tx = testContract.ln(x).callAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -843,37 +843,37 @@ blockchainTests('LibFixedMath unit tests', env => { FixedMathRevertErrors.ValueErrorCodes.TooSmall, x, ); - const tx = testContract.ln.callAsync(x); + const tx = testContract.ln(x).callAsync(); return expect(tx).to.revertWith(expectedError); }); it('ln(x = 1) == 0', async () => { const x = toFixed(1); - const r = await testContract.ln.callAsync(x); + const r = await testContract.ln(x).callAsync(); assertFixedEquals(r, 0); }); it('ln(x < LN_MIN_VAL) == EXP_MIN_VAL', async () => { const x = toFixed(MIN_LN_NUMBER).minus(1); - const r = await testContract.ln.callAsync(x); + const r = await testContract.ln(x).callAsync(); assertFixedEquals(r, MIN_EXP_NUMBER); }); it('ln(x), where x is close to 0', async () => { const x = new BigNumber('1e-27'); - const r = await testContract.ln.callAsync(toFixed(x)); + const r = await testContract.ln(toFixed(x)).callAsync(); assertFixedRoughlyEquals(r, ln(x), 12); }); it('ln(x), where x is close to 1', async () => { const x = new BigNumber(1).minus('1e-27'); - const r = await testContract.ln.callAsync(toFixed(x)); + const r = await testContract.ln(toFixed(x)).callAsync(); assertFixedRoughlyEquals(r, ln(x), LN_PRECISION); }); it('ln(x = 0.85)', async () => { const x = 0.85; - const r = await testContract.ln.callAsync(toFixed(x)); + const r = await testContract.ln(toFixed(x)).callAsync(); assertFixedRoughlyEquals(r, ln(x), LN_PRECISION); }); @@ -881,7 +881,7 @@ blockchainTests('LibFixedMath unit tests', env => { const inputs = _.times(FUZZ_COUNT, () => getRandomDecimal(0, 1)); for (const x of inputs) { it(`ln(${x.toString(10)})`, async () => { - const r = await testContract.ln.callAsync(toFixed(x)); + const r = await testContract.ln(toFixed(x)).callAsync(); assertFixedRoughlyEquals(r, ln(x), LN_PRECISION); }); } @@ -901,7 +901,7 @@ blockchainTests('LibFixedMath unit tests', env => { it('exp(x = 0) == 1', async () => { const x = toFixed(0); - const r = await testContract.exp.callAsync(x); + const r = await testContract.exp(x).callAsync(); assertFixedEquals(r, 1); }); @@ -911,31 +911,31 @@ blockchainTests('LibFixedMath unit tests', env => { FixedMathRevertErrors.ValueErrorCodes.TooLarge, x, ); - const tx = testContract.exp.callAsync(x); + const tx = testContract.exp(x).callAsync(); return expect(tx).to.revertWith(expectedError); }); it('exp(x < EXP_MIN_VAL) == 0', async () => { const x = toFixed(MIN_EXP_NUMBER).minus(1); - const r = await testContract.exp.callAsync(x); + const r = await testContract.exp(x).callAsync(); assertFixedEquals(r, 0); }); it('exp(x < 0), where x is close to 0', async () => { const x = new BigNumber('-1e-18'); - const r = await testContract.exp.callAsync(toFixed(x)); + const r = await testContract.exp(toFixed(x)).callAsync(); assertFixedRoughlyEquals(r, exp(x), EXP_PRECISION); }); it('exp(x), where x is close to EXP_MIN_VAL', async () => { const x = MIN_EXP_NUMBER.plus('1e-18'); - const r = await testContract.exp.callAsync(toFixed(x)); + const r = await testContract.exp(toFixed(x)).callAsync(); assertFixedRoughlyEquals(r, exp(x), EXP_PRECISION); }); it('exp(x = -0.85)', async () => { const x = -0.85; - const r = await testContract.exp.callAsync(toFixed(x)); + const r = await testContract.exp(toFixed(x)).callAsync(); assertFixedRoughlyEquals(r, exp(x), EXP_PRECISION); }); @@ -943,7 +943,7 @@ blockchainTests('LibFixedMath unit tests', env => { const inputs = _.times(FUZZ_COUNT, () => getRandomDecimal(MIN_EXP_NUMBER, MAX_EXP_NUMBER)); for (const x of inputs) { it(`exp(${x.toString(10)})`, async () => { - const r = await testContract.exp.callAsync(toFixed(x)); + const r = await testContract.exp(toFixed(x)).callAsync(); assertFixedRoughlyEquals(r, exp(x), EXP_PRECISION); }); } diff --git a/contracts/staking/test/unit_tests/lib_safe_downcast_test.ts b/contracts/staking/test/unit_tests/lib_safe_downcast_test.ts index 9a3ac8931e..f296a21574 100644 --- a/contracts/staking/test/unit_tests/lib_safe_downcast_test.ts +++ b/contracts/staking/test/unit_tests/lib_safe_downcast_test.ts @@ -21,7 +21,7 @@ blockchainTests('LibSafeDowncast unit tests', env => { describe('downcastToUint96', () => { async function verifyCorrectDowncastAsync(n: Numberish): Promise { - const actual = await testContract.downcastToUint96.callAsync(new BigNumber(n)); + const actual = await testContract.downcastToUint96(new BigNumber(n)).callAsync(); expect(actual).to.bignumber.eq(n); } function toDowncastError(n: Numberish): SafeMathRevertErrors.Uint256DowncastError { @@ -52,7 +52,7 @@ blockchainTests('LibSafeDowncast unit tests', env => { describe('downcastToUint64', () => { async function verifyCorrectDowncastAsync(n: Numberish): Promise { - const actual = await testContract.downcastToUint64.callAsync(new BigNumber(n)); + const actual = await testContract.downcastToUint64(new BigNumber(n)).callAsync(); expect(actual).to.bignumber.eq(n); } function toDowncastError(n: Numberish): SafeMathRevertErrors.Uint256DowncastError { diff --git a/contracts/staking/test/unit_tests/mixin_cumulative_rewards_test.ts b/contracts/staking/test/unit_tests/mixin_cumulative_rewards_test.ts index 97dcb1753c..462bd10d4d 100644 --- a/contracts/staking/test/unit_tests/mixin_cumulative_rewards_test.ts +++ b/contracts/staking/test/unit_tests/mixin_cumulative_rewards_test.ts @@ -40,89 +40,79 @@ blockchainTests.resets('MixinCumulativeRewards unit tests', env => { // Create a test pool const operatorShare = new BigNumber(1); const addOperatorAsMaker = true; - const txReceipt = await testContract.createStakingPool.awaitTransactionSuccessAsync( - operatorShare, - addOperatorAsMaker, - ); + const txReceipt = await testContract + .createStakingPool(operatorShare, addOperatorAsMaker) + .awaitTransactionSuccessAsync(); const createStakingPoolLog = txReceipt.logs[0]; testPoolId = (createStakingPoolLog as any).args.poolId; }); describe('_isCumulativeRewardSet', () => { it('Should return true iff denominator is non-zero', async () => { - const isSet = await testContract.isCumulativeRewardSet.callAsync({ - numerator: ZERO, - denominator: new BigNumber(1), - }); + const isSet = await testContract + .isCumulativeRewardSet({ + numerator: ZERO, + denominator: new BigNumber(1), + }) + .callAsync(); expect(isSet).to.be.true(); }); it('Should return false iff denominator is zero', async () => { - const isSet = await testContract.isCumulativeRewardSet.callAsync({ - numerator: new BigNumber(1), - denominator: ZERO, - }); + const isSet = await testContract + .isCumulativeRewardSet({ + numerator: new BigNumber(1), + denominator: ZERO, + }) + .callAsync(); expect(isSet).to.be.false(); }); }); describe('_addCumulativeReward', () => { it('Should set value to `reward/stake` if this is the first cumulative reward', async () => { - await testContract.addCumulativeReward.awaitTransactionSuccessAsync( - testPoolId, - testRewards[0].numerator, - testRewards[0].denominator, - ); - const mostRecentCumulativeReward = await testContract.getMostRecentCumulativeReward.callAsync(testPoolId); + await testContract + .addCumulativeReward(testPoolId, testRewards[0].numerator, testRewards[0].denominator) + .awaitTransactionSuccessAsync(); + const mostRecentCumulativeReward = await testContract.getMostRecentCumulativeReward(testPoolId).callAsync(); expect(mostRecentCumulativeReward).to.deep.equal(testRewards[0]); }); it('Should do nothing if a cumulative reward has already been recorded in the current epoch (`lastStoredEpoch == currentEpoch_`)', async () => { - await testContract.addCumulativeReward.awaitTransactionSuccessAsync( - testPoolId, - testRewards[0].numerator, - testRewards[0].denominator, - ); + await testContract + .addCumulativeReward(testPoolId, testRewards[0].numerator, testRewards[0].denominator) + .awaitTransactionSuccessAsync(); // this call should not overwrite existing value (testRewards[0]) - await testContract.addCumulativeReward.awaitTransactionSuccessAsync( - testPoolId, - testRewards[1].numerator, - testRewards[1].denominator, - ); - const mostRecentCumulativeReward = await testContract.getMostRecentCumulativeReward.callAsync(testPoolId); + await testContract + .addCumulativeReward(testPoolId, testRewards[1].numerator, testRewards[1].denominator) + .awaitTransactionSuccessAsync(); + const mostRecentCumulativeReward = await testContract.getMostRecentCumulativeReward(testPoolId).callAsync(); expect(mostRecentCumulativeReward).to.deep.equal(testRewards[0]); }); it('Should set value to normalized sum of `reward/stake` plus most recent cumulative reward, given one exists', async () => { - await testContract.addCumulativeReward.awaitTransactionSuccessAsync( - testPoolId, - testRewards[0].numerator, - testRewards[0].denominator, - ); - await testContract.incrementEpoch.awaitTransactionSuccessAsync(); - await testContract.addCumulativeReward.awaitTransactionSuccessAsync( - testPoolId, - testRewards[1].numerator, - testRewards[1].denominator, - ); - const mostRecentCumulativeReward = await testContract.getMostRecentCumulativeReward.callAsync(testPoolId); + await testContract + .addCumulativeReward(testPoolId, testRewards[0].numerator, testRewards[0].denominator) + .awaitTransactionSuccessAsync(); + await testContract.incrementEpoch().awaitTransactionSuccessAsync(); + await testContract + .addCumulativeReward(testPoolId, testRewards[1].numerator, testRewards[1].denominator) + .awaitTransactionSuccessAsync(); + const mostRecentCumulativeReward = await testContract.getMostRecentCumulativeReward(testPoolId).callAsync(); expect(mostRecentCumulativeReward).to.deep.equal(sumOfTestRewardsNormalized); }); }); describe('_updateCumulativeReward', () => { it('Should set current cumulative reward to most recent cumulative reward', async () => { - await testContract.addCumulativeReward.awaitTransactionSuccessAsync( - testPoolId, - testRewards[0].numerator, - testRewards[0].denominator, - ); - await testContract.incrementEpoch.awaitTransactionSuccessAsync(); - await testContract.updateCumulativeReward.awaitTransactionSuccessAsync(testPoolId); + await testContract + .addCumulativeReward(testPoolId, testRewards[0].numerator, testRewards[0].denominator) + .awaitTransactionSuccessAsync(); + await testContract.incrementEpoch().awaitTransactionSuccessAsync(); + await testContract.updateCumulativeReward(testPoolId).awaitTransactionSuccessAsync(); const epoch = new BigNumber(2); - const mostRecentCumulativeReward = await testContract.getCumulativeRewardAtEpochRaw.callAsync( - testPoolId, - epoch, - ); + const mostRecentCumulativeReward = await testContract + .getCumulativeRewardAtEpochRaw(testPoolId, epoch) + .callAsync(); expect(mostRecentCumulativeReward).to.deep.equal(testRewards[0]); }); }); @@ -136,22 +126,15 @@ blockchainTests.resets('MixinCumulativeRewards unit tests', env => { epochOfIntervalEnd: BigNumber, ): Promise => { // Simulate earning reward - await testContract.storeCumulativeReward.awaitTransactionSuccessAsync( - testPoolId, - testRewards[0], - epochOfFirstReward, - ); - await testContract.storeCumulativeReward.awaitTransactionSuccessAsync( - testPoolId, - sumOfTestRewardsNormalized, - epochOfSecondReward, - ); - const reward = await testContract.computeMemberRewardOverInterval.callAsync( - testPoolId, - amountToStake, - epochOfIntervalStart, - epochOfIntervalEnd, - ); + await testContract + .storeCumulativeReward(testPoolId, testRewards[0], epochOfFirstReward) + .awaitTransactionSuccessAsync(); + await testContract + .storeCumulativeReward(testPoolId, sumOfTestRewardsNormalized, epochOfSecondReward) + .awaitTransactionSuccessAsync(); + const reward = await testContract + .computeMemberRewardOverInterval(testPoolId, amountToStake, epochOfIntervalStart, epochOfIntervalEnd) + .callAsync(); // Compute expected reward const lhs = sumOfTestRewardsNormalized.numerator.dividedBy(sumOfTestRewardsNormalized.denominator); const rhs = testRewards[0].numerator.dividedBy(testRewards[0].denominator); @@ -212,12 +195,9 @@ blockchainTests.resets('MixinCumulativeRewards unit tests', env => { const stake = toBaseUnitAmount(1); const beginEpoch = new BigNumber(1); const endEpoch = new BigNumber(2); - const reward = await testContract.computeMemberRewardOverInterval.callAsync( - testPoolId, - stake, - beginEpoch, - endEpoch, - ); + const reward = await testContract + .computeMemberRewardOverInterval(testPoolId, stake, beginEpoch, endEpoch) + .callAsync(); expect(reward).to.bignumber.equal(ZERO); }); @@ -225,12 +205,9 @@ blockchainTests.resets('MixinCumulativeRewards unit tests', env => { const stake = toBaseUnitAmount(0); const beginEpoch = new BigNumber(1); const endEpoch = new BigNumber(2); - const reward = await testContract.computeMemberRewardOverInterval.callAsync( - testPoolId, - stake, - beginEpoch, - endEpoch, - ); + const reward = await testContract + .computeMemberRewardOverInterval(testPoolId, stake, beginEpoch, endEpoch) + .callAsync(); expect(reward).to.bignumber.equal(ZERO); }); @@ -238,12 +215,9 @@ blockchainTests.resets('MixinCumulativeRewards unit tests', env => { const stake = toBaseUnitAmount(1); const beginEpoch = new BigNumber(1); const endEpoch = new BigNumber(1); - const reward = await testContract.computeMemberRewardOverInterval.callAsync( - testPoolId, - stake, - beginEpoch, - endEpoch, - ); + const reward = await testContract + .computeMemberRewardOverInterval(testPoolId, stake, beginEpoch, endEpoch) + .callAsync(); expect(reward).to.bignumber.equal(ZERO); }); @@ -251,7 +225,9 @@ blockchainTests.resets('MixinCumulativeRewards unit tests', env => { const stake = toBaseUnitAmount(1); const beginEpoch = new BigNumber(2); const endEpoch = new BigNumber(1); - const tx = testContract.computeMemberRewardOverInterval.callAsync(testPoolId, stake, beginEpoch, endEpoch); + const tx = testContract + .computeMemberRewardOverInterval(testPoolId, stake, beginEpoch, endEpoch) + .callAsync(); return expect(tx).to.revertWith('CR_INTERVAL_INVALID'); }); }); diff --git a/contracts/staking/test/unit_tests/mixin_scheduler_test.ts b/contracts/staking/test/unit_tests/mixin_scheduler_test.ts index b8e49225b8..444109f3d2 100644 --- a/contracts/staking/test/unit_tests/mixin_scheduler_test.ts +++ b/contracts/staking/test/unit_tests/mixin_scheduler_test.ts @@ -29,10 +29,12 @@ blockchainTests.resets('MixinScheduler unit tests', env => { describe('getCurrentEpochEarliestEndTimeInSeconds', () => { it('Should return the sum of `epoch start time + epoch duration`', async () => { - const testDeployedTimestamp = await testContract.testDeployedTimestamp.callAsync(); - const epochDurationInSeconds = await testContract.epochDurationInSeconds.callAsync(); + const testDeployedTimestamp = await testContract.testDeployedTimestamp().callAsync(); + const epochDurationInSeconds = await testContract.epochDurationInSeconds().callAsync(); const expectedCurrentEpochEarliestEndTimeInSeconds = testDeployedTimestamp.plus(epochDurationInSeconds); - const currentEpochEarliestEndTimeInSeconds = await testContract.getCurrentEpochEarliestEndTimeInSeconds.callAsync(); + const currentEpochEarliestEndTimeInSeconds = await testContract + .getCurrentEpochEarliestEndTimeInSeconds() + .callAsync(); expect(currentEpochEarliestEndTimeInSeconds).to.bignumber.equal( expectedCurrentEpochEarliestEndTimeInSeconds, ); @@ -42,23 +44,23 @@ blockchainTests.resets('MixinScheduler unit tests', env => { describe('_initMixinScheduler', () => { it('Should succeed if scheduler is not yet initialized (`currentEpochStartTimeInSeconds == 0`)', async () => { const initCurrentEpochStartTimeInSeconds = constants.ZERO_AMOUNT; - const txReceipt = await testContract.initMixinSchedulerTest.awaitTransactionSuccessAsync( - initCurrentEpochStartTimeInSeconds, - ); + const txReceipt = await testContract + .initMixinSchedulerTest(initCurrentEpochStartTimeInSeconds) + .awaitTransactionSuccessAsync(); // Assert `currentEpochStartTimeInSeconds` was properly initialized const blockTimestamp = await env.web3Wrapper.getBlockTimestampAsync(txReceipt.blockNumber); - const currentEpochStartTimeInSeconds = await testContract.currentEpochStartTimeInSeconds.callAsync(); + const currentEpochStartTimeInSeconds = await testContract.currentEpochStartTimeInSeconds().callAsync(); expect(currentEpochStartTimeInSeconds).to.bignumber.equal(blockTimestamp); // Assert `currentEpoch` was properly initialized - const currentEpoch = await testContract.currentEpoch.callAsync(); + const currentEpoch = await testContract.currentEpoch().callAsync(); expect(currentEpoch).to.bignumber.equal(1); }); it('Should revert if scheduler is already initialized (`currentEpochStartTimeInSeconds != 0`)', async () => { const initCurrentEpochStartTimeInSeconds = new BigNumber(10); - const tx = testContract.initMixinSchedulerTest.awaitTransactionSuccessAsync( - initCurrentEpochStartTimeInSeconds, - ); + const tx = testContract + .initMixinSchedulerTest(initCurrentEpochStartTimeInSeconds) + .awaitTransactionSuccessAsync(); return expect(tx).to.revertWith( new StakingRevertErrors.InitializationError( StakingRevertErrors.InitializationErrorCodes.MixinSchedulerAlreadyInitialized, @@ -70,9 +72,9 @@ blockchainTests.resets('MixinScheduler unit tests', env => { describe('_goToNextEpoch', () => { it('Should succeed if epoch end time is strictly less than to block timestamp', async () => { const epochEndTimeDelta = new BigNumber(-10); - const txReceipt = await testContract.goToNextEpochTest.awaitTransactionSuccessAsync(epochEndTimeDelta); - const currentEpoch = await testContract.currentEpoch.callAsync(); - const currentEpochStartTimeInSeconds = await testContract.currentEpochStartTimeInSeconds.callAsync(); + const txReceipt = await testContract.goToNextEpochTest(epochEndTimeDelta).awaitTransactionSuccessAsync(); + const currentEpoch = await testContract.currentEpoch().callAsync(); + const currentEpochStartTimeInSeconds = await testContract.currentEpochStartTimeInSeconds().callAsync(); verifyEventsFromLogs( txReceipt.logs, [ @@ -87,20 +89,20 @@ blockchainTests.resets('MixinScheduler unit tests', env => { it('Should succeed if epoch end time is equal to block timestamp', async () => { const epochEndTimeDelta = constants.ZERO_AMOUNT; - const txReceipt = await testContract.goToNextEpochTest.awaitTransactionSuccessAsync(epochEndTimeDelta); + const txReceipt = await testContract.goToNextEpochTest(epochEndTimeDelta).awaitTransactionSuccessAsync(); // tslint:disable-next-line no-unnecessary-type-assertion const testLog: TestMixinSchedulerGoToNextEpochTestInfoEventArgs = (txReceipt.logs[0] as LogWithDecodedArgs< TestMixinSchedulerGoToNextEpochTestInfoEventArgs >).args; - const currentEpoch = await testContract.currentEpoch.callAsync(); - const currentEpochStartTimeInSeconds = await testContract.currentEpochStartTimeInSeconds.callAsync(); + const currentEpoch = await testContract.currentEpoch().callAsync(); + const currentEpochStartTimeInSeconds = await testContract.currentEpochStartTimeInSeconds().callAsync(); expect(currentEpoch).to.bignumber.equal(testLog.oldEpoch.plus(1)); expect(currentEpochStartTimeInSeconds).to.bignumber.equal(testLog.blockTimestamp); }); it('Should revert if epoch end time is strictly greater than block timestamp', async () => { const epochEndTimeDelta = new BigNumber(10); - const tx = testContract.goToNextEpochTest.awaitTransactionSuccessAsync(epochEndTimeDelta); + const tx = testContract.goToNextEpochTest(epochEndTimeDelta).awaitTransactionSuccessAsync(); return expect(tx).to.revertWith(new StakingRevertErrors.BlockTimestampTooLowError()); }); }); diff --git a/contracts/staking/test/unit_tests/mixin_stake_storage_test.ts b/contracts/staking/test/unit_tests/mixin_stake_storage_test.ts index 066e4077a4..ed4b57f6c9 100644 --- a/contracts/staking/test/unit_tests/mixin_stake_storage_test.ts +++ b/contracts/staking/test/unit_tests/mixin_stake_storage_test.ts @@ -24,7 +24,7 @@ blockchainTests.resets('MixinStakeStorage unit tests', env => { env.txDefaults, artifacts, ); - await testContract.setCurrentEpoch.awaitTransactionSuccessAsync(CURRENT_EPOCH); + await testContract.setCurrentEpoch(CURRENT_EPOCH).awaitTransactionSuccessAsync(); defaultUninitializedBalance = { currentEpoch: constants.INITIAL_EPOCH, currentEpochBalance: new BigNumber(0), @@ -48,7 +48,7 @@ blockchainTests.resets('MixinStakeStorage unit tests', env => { storedBalance.currentEpoch, storedBalance.currentEpochBalance, storedBalance.nextEpochBalance, - ] = await testContract.testBalances.callAsync(new BigNumber(index)); + ] = await testContract.testBalances(new BigNumber(index)).callAsync(); return storedBalance as StoredBalance; } @@ -58,9 +58,9 @@ blockchainTests.resets('MixinStakeStorage unit tests', env => { toBalance: StoredBalance, amount: BigNumber, ): Promise { - await testContract.setStoredBalance.awaitTransactionSuccessAsync(fromBalance, INDEX_ZERO); - await testContract.setStoredBalance.awaitTransactionSuccessAsync(toBalance, INDEX_ONE); - await testContract.moveStake.awaitTransactionSuccessAsync(INDEX_ZERO, INDEX_ONE, amount); + await testContract.setStoredBalance(fromBalance, INDEX_ZERO).awaitTransactionSuccessAsync(); + await testContract.setStoredBalance(toBalance, INDEX_ONE).awaitTransactionSuccessAsync(); + await testContract.moveStake(INDEX_ZERO, INDEX_ONE, amount).awaitTransactionSuccessAsync(); const actualBalances = await Promise.all([ getTestBalancesAsync(INDEX_ZERO), @@ -100,20 +100,18 @@ blockchainTests.resets('MixinStakeStorage unit tests', env => { ); }); it('Noop if pointers are equal', async () => { - await testContract.setStoredBalance.awaitTransactionSuccessAsync(defaultSyncedBalance, INDEX_ZERO); + await testContract.setStoredBalance(defaultSyncedBalance, INDEX_ZERO).awaitTransactionSuccessAsync(); // If the pointers weren't equal, this would revert with InsufficientBalanceError - await testContract.moveStake.awaitTransactionSuccessAsync( - INDEX_ZERO, - INDEX_ZERO, - defaultSyncedBalance.nextEpochBalance.plus(1), - ); + await testContract + .moveStake(INDEX_ZERO, INDEX_ZERO, defaultSyncedBalance.nextEpochBalance.plus(1)) + .awaitTransactionSuccessAsync(); const actualBalance = await getTestBalancesAsync(INDEX_ZERO); expect(actualBalance).to.deep.equal(defaultSyncedBalance); }); it("Reverts if attempting to move more than next epoch's balance", async () => { - await testContract.setStoredBalance.awaitTransactionSuccessAsync(defaultSyncedBalance, INDEX_ZERO); + await testContract.setStoredBalance(defaultSyncedBalance, INDEX_ZERO).awaitTransactionSuccessAsync(); const amount = defaultSyncedBalance.nextEpochBalance.plus(1); - const tx = testContract.moveStake.awaitTransactionSuccessAsync(INDEX_ZERO, INDEX_ONE, amount); + const tx = testContract.moveStake(INDEX_ZERO, INDEX_ONE, amount).awaitTransactionSuccessAsync(); await expect(tx).to.revertWith( new StakingRevertErrors.InsufficientBalanceError(amount, defaultSyncedBalance.nextEpochBalance), ); @@ -122,32 +120,32 @@ blockchainTests.resets('MixinStakeStorage unit tests', env => { describe('Load balance', () => { it('Balance does not change state if balance was previously synced in the current epoch', async () => { - await testContract.setStoredBalance.awaitTransactionSuccessAsync(defaultSyncedBalance, INDEX_ZERO); - const actualBalance = await testContract.loadCurrentBalance.callAsync(INDEX_ZERO); + await testContract.setStoredBalance(defaultSyncedBalance, INDEX_ZERO).awaitTransactionSuccessAsync(); + const actualBalance = await testContract.loadCurrentBalance(INDEX_ZERO).callAsync(); expect(actualBalance).to.deep.equal(defaultSyncedBalance); }); it('Balance updates current epoch fields if the balance has not yet been synced in the current epoch', async () => { - await testContract.setStoredBalance.awaitTransactionSuccessAsync(defaultUnsyncedBalance, INDEX_ZERO); - const actualBalance = await testContract.loadCurrentBalance.callAsync(INDEX_ZERO); + await testContract.setStoredBalance(defaultUnsyncedBalance, INDEX_ZERO).awaitTransactionSuccessAsync(); + const actualBalance = await testContract.loadCurrentBalance(INDEX_ZERO).callAsync(); expect(actualBalance).to.deep.equal(defaultSyncedBalance); }); it('Balance loads unsynced balance from storage without changing fields', async () => { - await testContract.setStoredBalance.awaitTransactionSuccessAsync(defaultUnsyncedBalance, INDEX_ZERO); - const actualBalance = await testContract.loadStaleBalance.callAsync(INDEX_ZERO); + await testContract.setStoredBalance(defaultUnsyncedBalance, INDEX_ZERO).awaitTransactionSuccessAsync(); + const actualBalance = await testContract.loadStaleBalance(INDEX_ZERO).callAsync(); expect(actualBalance).to.deep.equal(defaultUnsyncedBalance); }); it('Balance loads synced balance from storage without changing fields', async () => { - await testContract.setStoredBalance.awaitTransactionSuccessAsync(defaultSyncedBalance, INDEX_ZERO); - const actualBalance = await testContract.loadStaleBalance.callAsync(INDEX_ZERO); + await testContract.setStoredBalance(defaultSyncedBalance, INDEX_ZERO).awaitTransactionSuccessAsync(); + const actualBalance = await testContract.loadStaleBalance(INDEX_ZERO).callAsync(); expect(actualBalance).to.deep.equal(defaultSyncedBalance); }); }); describe('Increase/decrease balance', () => { it('_increaseCurrentAndNextBalance', async () => { - await testContract.setStoredBalance.awaitTransactionSuccessAsync(defaultUnsyncedBalance, INDEX_ZERO); + await testContract.setStoredBalance(defaultUnsyncedBalance, INDEX_ZERO).awaitTransactionSuccessAsync(); const amount = defaultUnsyncedBalance.currentEpochBalance.dividedToIntegerBy(2); - await testContract.increaseCurrentAndNextBalance.awaitTransactionSuccessAsync(INDEX_ZERO, amount); + await testContract.increaseCurrentAndNextBalance(INDEX_ZERO, amount).awaitTransactionSuccessAsync(); const actualBalance = await getTestBalancesAsync(INDEX_ZERO); expect(actualBalance).to.deep.equal({ ...defaultSyncedBalance, @@ -156,16 +154,16 @@ blockchainTests.resets('MixinStakeStorage unit tests', env => { }); }); it('_increaseCurrentAndNextBalance (previously uninitialized)', async () => { - await testContract.setStoredBalance.awaitTransactionSuccessAsync(defaultUninitializedBalance, INDEX_ZERO); + await testContract.setStoredBalance(defaultUninitializedBalance, INDEX_ZERO).awaitTransactionSuccessAsync(); const amount = defaultSyncedBalance.currentEpochBalance; - await testContract.increaseCurrentAndNextBalance.awaitTransactionSuccessAsync(INDEX_ZERO, amount); + await testContract.increaseCurrentAndNextBalance(INDEX_ZERO, amount).awaitTransactionSuccessAsync(); const actualBalance = await getTestBalancesAsync(INDEX_ZERO); expect(actualBalance).to.deep.equal(defaultSyncedBalance); }); it('_decreaseCurrentAndNextBalance', async () => { - await testContract.setStoredBalance.awaitTransactionSuccessAsync(defaultUnsyncedBalance, INDEX_ZERO); + await testContract.setStoredBalance(defaultUnsyncedBalance, INDEX_ZERO).awaitTransactionSuccessAsync(); const amount = defaultUnsyncedBalance.currentEpochBalance.dividedToIntegerBy(2); - await testContract.decreaseCurrentAndNextBalance.awaitTransactionSuccessAsync(INDEX_ZERO, amount); + await testContract.decreaseCurrentAndNextBalance(INDEX_ZERO, amount).awaitTransactionSuccessAsync(); const actualBalance = await getTestBalancesAsync(INDEX_ZERO); expect(actualBalance).to.deep.equal({ ...defaultSyncedBalance, @@ -174,9 +172,9 @@ blockchainTests.resets('MixinStakeStorage unit tests', env => { }); }); it('_increaseNextBalance', async () => { - await testContract.setStoredBalance.awaitTransactionSuccessAsync(defaultUnsyncedBalance, INDEX_ZERO); + await testContract.setStoredBalance(defaultUnsyncedBalance, INDEX_ZERO).awaitTransactionSuccessAsync(); const amount = defaultUnsyncedBalance.currentEpochBalance.dividedToIntegerBy(2); - await testContract.increaseNextBalance.awaitTransactionSuccessAsync(INDEX_ZERO, amount); + await testContract.increaseNextBalance(INDEX_ZERO, amount).awaitTransactionSuccessAsync(); const actualBalance = await getTestBalancesAsync(INDEX_ZERO); expect(actualBalance).to.deep.equal({ ...defaultSyncedBalance, @@ -184,9 +182,9 @@ blockchainTests.resets('MixinStakeStorage unit tests', env => { }); }); it('_increaseCurrentAndNextBalance (previously uninitialized)', async () => { - await testContract.setStoredBalance.awaitTransactionSuccessAsync(defaultUninitializedBalance, INDEX_ZERO); + await testContract.setStoredBalance(defaultUninitializedBalance, INDEX_ZERO).awaitTransactionSuccessAsync(); const amount = defaultSyncedBalance.currentEpochBalance; - await testContract.increaseNextBalance.awaitTransactionSuccessAsync(INDEX_ZERO, amount); + await testContract.increaseNextBalance(INDEX_ZERO, amount).awaitTransactionSuccessAsync(); const actualBalance = await getTestBalancesAsync(INDEX_ZERO); expect(actualBalance).to.deep.equal({ ...defaultSyncedBalance, @@ -194,9 +192,9 @@ blockchainTests.resets('MixinStakeStorage unit tests', env => { }); }); it('_decreaseNextBalance', async () => { - await testContract.setStoredBalance.awaitTransactionSuccessAsync(defaultUnsyncedBalance, INDEX_ZERO); + await testContract.setStoredBalance(defaultUnsyncedBalance, INDEX_ZERO).awaitTransactionSuccessAsync(); const amount = defaultUnsyncedBalance.currentEpochBalance.dividedToIntegerBy(2); - await testContract.decreaseNextBalance.awaitTransactionSuccessAsync(INDEX_ZERO, amount); + await testContract.decreaseNextBalance(INDEX_ZERO, amount).awaitTransactionSuccessAsync(); const actualBalance = await getTestBalancesAsync(INDEX_ZERO); expect(actualBalance).to.deep.equal({ ...defaultSyncedBalance, diff --git a/contracts/staking/test/unit_tests/mixin_staking_pool_rewards.ts b/contracts/staking/test/unit_tests/mixin_staking_pool_rewards.ts index 88e344f3be..2dc4580a35 100644 --- a/contracts/staking/test/unit_tests/mixin_staking_pool_rewards.ts +++ b/contracts/staking/test/unit_tests/mixin_staking_pool_rewards.ts @@ -8,7 +8,7 @@ import { hexRandom, Numberish, randomAddress, - TransactionHelper, + transactionHelper, verifyEventsFromLogs, } from '@0x/contracts-test-utils'; import { BigNumber } from '@0x/utils'; @@ -20,7 +20,6 @@ import { artifacts, TestMixinStakingPoolRewardsContract, TestMixinStakingPoolRew blockchainTests.resets('MixinStakingPoolRewards unit tests', env => { let testContract: TestMixinStakingPoolRewardsContract; - let txHelper: TransactionHelper; const POOL_ID = hexRandom(); const OPERATOR = randomAddress(); @@ -34,12 +33,13 @@ blockchainTests.resets('MixinStakingPoolRewards unit tests', env => { env.txDefaults, artifacts, ); - await testContract.setPool.awaitTransactionSuccessAsync(POOL_ID, { - operator: OPERATOR, - operatorShare: OPERATOR_SHARE, - }); + await testContract + .setPool(POOL_ID, { + operator: OPERATOR, + operatorShare: OPERATOR_SHARE, + }) + .awaitTransactionSuccessAsync(); [caller] = await env.getAccountAddressesAsync(); - txHelper = new TransactionHelper(env.web3Wrapper, artifacts); }); async function setUnfinalizedPoolRewardsAsync( @@ -47,11 +47,9 @@ blockchainTests.resets('MixinStakingPoolRewards unit tests', env => { reward: Numberish, membersStake: Numberish, ): Promise { - await testContract.setUnfinalizedPoolRewards.awaitTransactionSuccessAsync( - poolId, - new BigNumber(reward), - new BigNumber(membersStake), - ); + await testContract + .setUnfinalizedPoolRewards(poolId, new BigNumber(reward), new BigNumber(membersStake)) + .awaitTransactionSuccessAsync(); } // Set the delegated stake of a delegator in a pool. @@ -67,11 +65,13 @@ blockchainTests.resets('MixinStakingPoolRewards unit tests', env => { nextEpochBalance: getRandomInteger(1, 1e18), ...stake, }; - await testContract.setDelegatedStakeToPoolByOwner.awaitTransactionSuccessAsync(delegator, poolId, { - currentEpoch: _stake.currentEpoch, - currentEpochBalance: _stake.currentEpochBalance, - nextEpochBalance: _stake.nextEpochBalance, - }); + await testContract + .setDelegatedStakeToPoolByOwner(delegator, poolId, { + currentEpoch: _stake.currentEpoch, + currentEpochBalance: _stake.currentEpochBalance, + nextEpochBalance: _stake.nextEpochBalance, + }) + .awaitTransactionSuccessAsync(); return _stake; } @@ -82,25 +82,29 @@ blockchainTests.resets('MixinStakingPoolRewards unit tests', env => { delegator: string, finalizedReward?: Numberish, ): Promise { - const stake = await testContract.delegatedStakeToPoolByOwner.callAsync(delegator, poolId); + const stake = await testContract.delegatedStakeToPoolByOwner(delegator, poolId).callAsync(); // Split the rewards up across the two calls to `_computeMemberRewardOverInterval()` const reward = finalizedReward === undefined ? getRandomInteger(1, 1e18) : new BigNumber(finalizedReward); const oldRewards = getRandomPortion(reward); - await testContract.setMemberRewardsOverInterval.awaitTransactionSuccessAsync( - poolId, - stake.currentEpochBalance, - stake.currentEpoch, - stake.currentEpoch.plus(1), - oldRewards, - ); + await testContract + .setMemberRewardsOverInterval( + poolId, + stake.currentEpochBalance, + stake.currentEpoch, + stake.currentEpoch.plus(1), + oldRewards, + ) + .awaitTransactionSuccessAsync(); const newRewards = reward.minus(oldRewards); - await testContract.setMemberRewardsOverInterval.awaitTransactionSuccessAsync( - poolId, - stake.nextEpochBalance, - stake.currentEpoch.plus(1), - await testContract.currentEpoch.callAsync(), - newRewards, - ); + await testContract + .setMemberRewardsOverInterval( + poolId, + stake.nextEpochBalance, + stake.currentEpoch.plus(1), + await testContract.currentEpoch().callAsync(), + newRewards, + ) + .awaitTransactionSuccessAsync(); return reward; } @@ -118,7 +122,7 @@ blockchainTests.resets('MixinStakingPoolRewards unit tests', env => { describe('withdrawDelegatorRewards()', () => { it('calls `_withdrawAndSyncDelegatorRewards()` with the sender as the member', async () => { - const { logs } = await testContract.withdrawDelegatorRewards.awaitTransactionSuccessAsync(POOL_ID); + const { logs } = await testContract.withdrawDelegatorRewards(POOL_ID).awaitTransactionSuccessAsync(); verifyEventsFromLogs( logs, [{ poolId: POOL_ID, delegator: caller }], @@ -135,14 +139,14 @@ blockchainTests.resets('MixinStakingPoolRewards unit tests', env => { before(async () => { stake = await setStakeAsync(POOL_ID, DELEGATOR); - await testContract.setPoolRewards.awaitTransactionSuccessAsync(POOL_ID, POOL_REWARD); - await testContract.setWethReservedForPoolRewards.awaitTransactionSuccessAsync( - WETH_RESERVED_FOR_POOL_REWARDS, - ); + await testContract.setPoolRewards(POOL_ID, POOL_REWARD).awaitTransactionSuccessAsync(); + await testContract + .setWethReservedForPoolRewards(WETH_RESERVED_FOR_POOL_REWARDS) + .awaitTransactionSuccessAsync(); }); async function withdrawAndSyncDelegatorRewardsAsync(): Promise { - return testContract.withdrawAndSyncDelegatorRewards.awaitTransactionSuccessAsync(POOL_ID, DELEGATOR); + return testContract.withdrawAndSyncDelegatorRewards(POOL_ID, DELEGATOR).awaitTransactionSuccessAsync(); } it('reverts if the pool is not finalized', async () => { @@ -168,20 +172,20 @@ blockchainTests.resets('MixinStakingPoolRewards unit tests', env => { const finalizedReward = getRandomPortion(POOL_REWARD); await setComputeDelegatorRewardStateAsync(POOL_ID, DELEGATOR, finalizedReward); await withdrawAndSyncDelegatorRewardsAsync(); - const poolReward = await testContract.rewardsByPoolId.callAsync(POOL_ID); + const poolReward = await testContract.rewardsByPoolId(POOL_ID).callAsync(); expect(poolReward).to.bignumber.eq(POOL_REWARD.minus(finalizedReward)); }); it('reduces `wethReservedForPoolRewards` for the pool', async () => { const finalizedReward = getRandomPortion(POOL_REWARD); await setComputeDelegatorRewardStateAsync(POOL_ID, DELEGATOR, finalizedReward); await withdrawAndSyncDelegatorRewardsAsync(); - const wethReserved = await testContract.wethReservedForPoolRewards.callAsync(); + const wethReserved = await testContract.wethReservedForPoolRewards().callAsync(); expect(wethReserved).to.bignumber.eq(WETH_RESERVED_FOR_POOL_REWARDS.minus(finalizedReward)); }); it('syncs `_delegatedStakeToPoolByOwner`', async () => { await setComputeDelegatorRewardStateAsync(POOL_ID, DELEGATOR, getRandomPortion(POOL_REWARD)); await withdrawAndSyncDelegatorRewardsAsync(); - const stakeAfter = await testContract.delegatedStakeToPoolByOwner.callAsync(DELEGATOR, POOL_ID); + const stakeAfter = await testContract.delegatedStakeToPoolByOwner(DELEGATOR, POOL_ID).callAsync(); // `_loadCurrentBalance` is overridden to just increment `currentEpoch`. expect(stakeAfter).to.deep.eq({ currentEpoch: stake.currentEpoch.plus(1), @@ -197,7 +201,7 @@ blockchainTests.resets('MixinStakingPoolRewards unit tests', env => { it('no rewards if the delegated stake epoch == current epoch', async () => { // Set some finalized rewards that should be ignored. await setComputeDelegatorRewardStateAsync(POOL_ID, DELEGATOR, getRandomInteger(1, POOL_REWARD)); - await testContract.setCurrentEpoch.awaitTransactionSuccessAsync(stake.currentEpoch); + await testContract.setCurrentEpoch(stake.currentEpoch).awaitTransactionSuccessAsync(); const { logs } = await withdrawAndSyncDelegatorRewardsAsync(); // There will be no Transfer events if computed rewards are zero. verifyEventsFromLogs(logs, [], Events.Transfer); @@ -206,7 +210,7 @@ blockchainTests.resets('MixinStakingPoolRewards unit tests', env => { describe('computeRewardBalanceOfOperator()', () => { async function computeRewardBalanceOfOperatorAsync(): Promise { - return testContract.computeRewardBalanceOfOperator.callAsync(POOL_ID); + return testContract.computeRewardBalanceOfOperator(POOL_ID).callAsync(); } it('returns only unfinalized rewards', async () => { @@ -238,19 +242,23 @@ blockchainTests.resets('MixinStakingPoolRewards unit tests', env => { expect(reward).to.bignumber.eq(unfinalizedReward); }); it('returns no reward if operator share is zero', async () => { - await testContract.setPool.awaitTransactionSuccessAsync(POOL_ID, { - operator: OPERATOR, - operatorShare: constants.ZERO_AMOUNT, - }); + await testContract + .setPool(POOL_ID, { + operator: OPERATOR, + operatorShare: constants.ZERO_AMOUNT, + }) + .awaitTransactionSuccessAsync(); await setUnfinalizedPoolRewardsAsync(POOL_ID, getRandomInteger(1, 1e18), getRandomInteger(1, 1e18)); const reward = await computeRewardBalanceOfOperatorAsync(); expect(reward).to.bignumber.eq(0); }); it('returns all unfinalized reward if operator share is 100%', async () => { - await testContract.setPool.awaitTransactionSuccessAsync(POOL_ID, { - operator: OPERATOR, - operatorShare: constants.PPM_100_PERCENT, - }); + await testContract + .setPool(POOL_ID, { + operator: OPERATOR, + operatorShare: constants.PPM_100_PERCENT, + }) + .awaitTransactionSuccessAsync(); const unfinalizedReward = getRandomInteger(1, 1e18); await setUnfinalizedPoolRewardsAsync(POOL_ID, unfinalizedReward, getRandomInteger(1, 1e18)); const reward = await computeRewardBalanceOfOperatorAsync(); @@ -264,12 +272,12 @@ blockchainTests.resets('MixinStakingPoolRewards unit tests', env => { let stake: StoredBalance; before(async () => { - currentEpoch = await testContract.currentEpoch.callAsync(); + currentEpoch = await testContract.currentEpoch().callAsync(); stake = await setStakeAsync(POOL_ID, DELEGATOR); }); async function computeRewardBalanceOfDelegatorAsync(): Promise { - return testContract.computeRewardBalanceOfDelegator.callAsync(POOL_ID, DELEGATOR); + return testContract.computeRewardBalanceOfDelegator(POOL_ID, DELEGATOR).callAsync(); } function getDelegatorPortionOfUnfinalizedReward( @@ -315,7 +323,7 @@ blockchainTests.resets('MixinStakingPoolRewards unit tests', env => { currentEpoch: new BigNumber(epoch - 2), nextEpochBalance: constants.ZERO_AMOUNT, }); - await testContract.setCurrentEpoch.awaitTransactionSuccessAsync(new BigNumber(epoch)); + await testContract.setCurrentEpoch(new BigNumber(epoch)).awaitTransactionSuccessAsync(); await setUnfinalizedPoolRewardsAsync(POOL_ID, getRandomInteger(1, 1e18), getRandomInteger(1, 1e18)); const reward = await computeRewardBalanceOfDelegatorAsync(); expect(reward).to.bignumber.eq(0); @@ -347,17 +355,17 @@ blockchainTests.resets('MixinStakingPoolRewards unit tests', env => { const WETH_RESERVED_FOR_POOL_REWARDS = POOL_REWARD.plus(getRandomInteger(1, 100e18)); before(async () => { - await testContract.setPoolRewards.awaitTransactionSuccessAsync(POOL_ID, POOL_REWARD); - await testContract.setWethReservedForPoolRewards.awaitTransactionSuccessAsync( - WETH_RESERVED_FOR_POOL_REWARDS, - ); + await testContract.setPoolRewards(POOL_ID, POOL_REWARD).awaitTransactionSuccessAsync(); + await testContract + .setWethReservedForPoolRewards(WETH_RESERVED_FOR_POOL_REWARDS) + .awaitTransactionSuccessAsync(); }); async function syncPoolRewardsAsync( reward: Numberish, membersStake: Numberish, ): Promise<[[BigNumber, BigNumber], LogEntry[]]> { - const [result, receipt] = await txHelper.getResultAndReceiptAsync( + const [result, receipt] = await transactionHelper.getResultAndReceiptAsync( testContract.syncPoolRewards, POOL_ID, new BigNumber(reward), @@ -382,7 +390,7 @@ blockchainTests.resets('MixinStakingPoolRewards unit tests', env => { const membersStake = getRandomInteger(1, 1e18); await syncPoolRewardsAsync(totalReward, membersStake); const expectedMembersReward = toMembersPortion(OPERATOR_SHARE, totalReward); - const poolReward = await testContract.rewardsByPoolId.callAsync(POOL_ID); + const poolReward = await testContract.rewardsByPoolId(POOL_ID).callAsync(); expect(poolReward).to.bignumber.eq(POOL_REWARD.plus(expectedMembersReward)); }); it("increases `wethReservedForPoolRewards` with members' portion of rewards", async () => { @@ -390,7 +398,7 @@ blockchainTests.resets('MixinStakingPoolRewards unit tests', env => { const membersStake = getRandomInteger(1, 1e18); await syncPoolRewardsAsync(totalReward, membersStake); const expectedMembersReward = toMembersPortion(OPERATOR_SHARE, totalReward); - const wethReserved = await testContract.wethReservedForPoolRewards.callAsync(); + const wethReserved = await testContract.wethReservedForPoolRewards().callAsync(); expect(wethReserved).to.bignumber.eq(WETH_RESERVED_FOR_POOL_REWARDS.plus(expectedMembersReward)); }); it("returns operator and members' portion of the reward", async () => { @@ -415,10 +423,12 @@ blockchainTests.resets('MixinStakingPoolRewards unit tests', env => { }); it("gives all rewards to members if operator's share is zero", async () => { const totalReward = getRandomInteger(1, 1e18); - await testContract.setPool.awaitTransactionSuccessAsync(POOL_ID, { - operator: OPERATOR, - operatorShare: constants.ZERO_AMOUNT, - }); + await testContract + .setPool(POOL_ID, { + operator: OPERATOR, + operatorShare: constants.ZERO_AMOUNT, + }) + .awaitTransactionSuccessAsync(); const [[operatorReward, membersReward], logs] = await syncPoolRewardsAsync( totalReward, getRandomInteger(1, 1e18), @@ -435,11 +445,9 @@ blockchainTests.resets('MixinStakingPoolRewards unit tests', env => { const operatorShare = getRandomPortion(constants.PPM_100_PERCENT); const totalReward = getRandomInteger(1, 1e18); const membersStake = constants.ZERO_AMOUNT; - const [operatorReward, membersReward] = await testContract.computePoolRewardsSplit.callAsync( - operatorShare, - totalReward, - membersStake, - ); + const [operatorReward, membersReward] = await testContract + .computePoolRewardsSplit(operatorShare, totalReward, membersStake) + .callAsync(); expect(operatorReward).to.bignumber.eq(totalReward); expect(membersReward).to.bignumber.eq(0); }); @@ -447,11 +455,9 @@ blockchainTests.resets('MixinStakingPoolRewards unit tests', env => { const operatorShare = constants.ZERO_AMOUNT; const totalReward = getRandomInteger(1, 1e18); const membersStake = constants.ZERO_AMOUNT; - const [operatorReward, membersReward] = await testContract.computePoolRewardsSplit.callAsync( - operatorShare, - totalReward, - membersStake, - ); + const [operatorReward, membersReward] = await testContract + .computePoolRewardsSplit(operatorShare, totalReward, membersStake) + .callAsync(); expect(operatorReward).to.bignumber.eq(totalReward); expect(membersReward).to.bignumber.eq(0); }); @@ -459,11 +465,9 @@ blockchainTests.resets('MixinStakingPoolRewards unit tests', env => { const operatorShare = constants.PPM_100_PERCENT; const totalReward = getRandomInteger(1, 1e18); const membersStake = getRandomInteger(1, 1e18); - const [operatorReward, membersReward] = await testContract.computePoolRewardsSplit.callAsync( - operatorShare, - totalReward, - membersStake, - ); + const [operatorReward, membersReward] = await testContract + .computePoolRewardsSplit(operatorShare, totalReward, membersStake) + .callAsync(); expect(operatorReward).to.bignumber.eq(totalReward); expect(membersReward).to.bignumber.eq(0); }); @@ -471,11 +475,9 @@ blockchainTests.resets('MixinStakingPoolRewards unit tests', env => { const operatorShare = constants.ZERO_AMOUNT; const totalReward = getRandomInteger(1, 1e18); const membersStake = getRandomInteger(1, 1e18); - const [operatorReward, membersReward] = await testContract.computePoolRewardsSplit.callAsync( - operatorShare, - totalReward, - membersStake, - ); + const [operatorReward, membersReward] = await testContract + .computePoolRewardsSplit(operatorShare, totalReward, membersStake) + .callAsync(); expect(operatorReward).to.bignumber.eq(0); expect(membersReward).to.bignumber.eq(totalReward); }); @@ -483,11 +485,9 @@ blockchainTests.resets('MixinStakingPoolRewards unit tests', env => { const operatorShare = getRandomPortion(constants.PPM_100_PERCENT); const totalReward = getRandomInteger(1, 1e18); const membersStake = getRandomInteger(1, 1e18); - const [operatorReward, membersReward] = await testContract.computePoolRewardsSplit.callAsync( - operatorShare, - totalReward, - membersStake, - ); + const [operatorReward, membersReward] = await testContract + .computePoolRewardsSplit(operatorShare, totalReward, membersStake) + .callAsync(); expect(operatorReward).to.bignumber.eq(toOperatorPortion(operatorShare, totalReward)); expect(membersReward).to.bignumber.eq(toMembersPortion(operatorShare, totalReward)); }); diff --git a/contracts/staking/test/unit_tests/params_test.ts b/contracts/staking/test/unit_tests/params_test.ts index e49a46a141..59dfad4571 100644 --- a/contracts/staking/test/unit_tests/params_test.ts +++ b/contracts/staking/test/unit_tests/params_test.ts @@ -21,7 +21,7 @@ blockchainTests('Configurable Parameters unit tests', env => { env.txDefaults, artifacts, ); - await testContract.addAuthorizedAddress.awaitTransactionSuccessAsync(authorizedAddress); + await testContract.addAuthorizedAddress(authorizedAddress).awaitTransactionSuccessAsync(); }); blockchainTests.resets('setParams()', () => { @@ -33,14 +33,15 @@ blockchainTests('Configurable Parameters unit tests', env => { ...stakingConstants.DEFAULT_PARAMS, ...params, }; - const receipt = await testContract.setParams.awaitTransactionSuccessAsync( - new BigNumber(_params.epochDurationInSeconds), - new BigNumber(_params.rewardDelegatedStakeWeight), - new BigNumber(_params.minimumPoolStake), - new BigNumber(_params.cobbDouglasAlphaNumerator), - new BigNumber(_params.cobbDouglasAlphaDenominator), - { from }, - ); + const receipt = await testContract + .setParams( + new BigNumber(_params.epochDurationInSeconds), + new BigNumber(_params.rewardDelegatedStakeWeight), + new BigNumber(_params.minimumPoolStake), + new BigNumber(_params.cobbDouglasAlphaNumerator), + new BigNumber(_params.cobbDouglasAlphaDenominator), + ) + .awaitTransactionSuccessAsync({ from }); // Assert event. const events = filterLogsToArguments(receipt.logs, 'ParamsSet'); expect(events.length).to.eq(1); @@ -51,7 +52,7 @@ blockchainTests('Configurable Parameters unit tests', env => { expect(event.cobbDouglasAlphaNumerator).to.bignumber.eq(_params.cobbDouglasAlphaNumerator); expect(event.cobbDouglasAlphaDenominator).to.bignumber.eq(_params.cobbDouglasAlphaDenominator); // Assert `getParams()`. - const actual = await testContract.getParams.callAsync(); + const actual = await testContract.getParams().callAsync(); expect(actual[0]).to.bignumber.eq(_params.epochDurationInSeconds); expect(actual[1]).to.bignumber.eq(_params.rewardDelegatedStakeWeight); expect(actual[2]).to.bignumber.eq(_params.minimumPoolStake); @@ -67,7 +68,7 @@ blockchainTests('Configurable Parameters unit tests', env => { }); it('throws if `assertValidStorageParams()` throws`', async () => { - await testContract.setShouldFailAssertValidStorageParams.awaitTransactionSuccessAsync(true); + await testContract.setShouldFailAssertValidStorageParams(true).awaitTransactionSuccessAsync(); const tx = setParamsAndAssertAsync({}); return expect(tx).to.revertWith('ASSERT_VALID_STORAGE_PARAMS_FAILED'); }); diff --git a/contracts/staking/test/unit_tests/protocol_fees_test.ts b/contracts/staking/test/unit_tests/protocol_fees_test.ts index 1c027fad3a..a80b9f110e 100644 --- a/contracts/staking/test/unit_tests/protocol_fees_test.ts +++ b/contracts/staking/test/unit_tests/protocol_fees_test.ts @@ -45,7 +45,7 @@ blockchainTests('Protocol Fees unit tests', env => { exchangeAddress, ); - minimumStake = (await testContract.getParams.callAsync())[2]; + minimumStake = (await testContract.getParams().callAsync())[2]; }); interface CreateTestPoolOpts { @@ -63,12 +63,14 @@ blockchainTests('Protocol Fees unit tests', env => { makers: _.times(2, () => randomAddress()), ...opts, }; - await testContract.createTestPool.awaitTransactionSuccessAsync( - _opts.poolId, - new BigNumber(_opts.operatorStake), - new BigNumber(_opts.membersStake), - _opts.makers, - ); + await testContract + .createTestPool( + _opts.poolId, + new BigNumber(_opts.operatorStake), + new BigNumber(_opts.membersStake), + _opts.makers, + ) + .awaitTransactionSuccessAsync(); return _opts; } @@ -80,23 +82,17 @@ blockchainTests('Protocol Fees unit tests', env => { describe('forbidden actions', () => { it('should revert if called by a non-exchange', async () => { - const tx = testContract.payProtocolFee.awaitTransactionSuccessAsync( - makerAddress, - payerAddress, - DEFAULT_PROTOCOL_FEE_PAID, - { from: notExchangeAddress }, - ); + const tx = testContract + .payProtocolFee(makerAddress, payerAddress, DEFAULT_PROTOCOL_FEE_PAID) + .awaitTransactionSuccessAsync({ from: notExchangeAddress }); const expectedError = new StakingRevertErrors.OnlyCallableByExchangeError(notExchangeAddress); return expect(tx).to.revertWith(expectedError); }); it('should revert if `protocolFee` is zero with non-zero value sent', async () => { - const tx = testContract.payProtocolFee.awaitTransactionSuccessAsync( - makerAddress, - payerAddress, - ZERO_AMOUNT, - { from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID }, - ); + const tx = testContract + .payProtocolFee(makerAddress, payerAddress, ZERO_AMOUNT) + .awaitTransactionSuccessAsync({ from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID }); const expectedError = new StakingRevertErrors.InvalidProtocolFeePaymentError( ZERO_AMOUNT, DEFAULT_PROTOCOL_FEE_PAID, @@ -105,12 +101,9 @@ blockchainTests('Protocol Fees unit tests', env => { }); it('should revert if `protocolFee` is < than the provided message value', async () => { - const tx = testContract.payProtocolFee.awaitTransactionSuccessAsync( - makerAddress, - payerAddress, - DEFAULT_PROTOCOL_FEE_PAID, - { from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID.minus(1) }, - ); + const tx = testContract + .payProtocolFee(makerAddress, payerAddress, DEFAULT_PROTOCOL_FEE_PAID) + .awaitTransactionSuccessAsync({ from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID.minus(1) }); const expectedError = new StakingRevertErrors.InvalidProtocolFeePaymentError( DEFAULT_PROTOCOL_FEE_PAID, DEFAULT_PROTOCOL_FEE_PAID.minus(1), @@ -119,12 +112,9 @@ blockchainTests('Protocol Fees unit tests', env => { }); it('should revert if `protocolFee` is > than the provided message value', async () => { - const tx = testContract.payProtocolFee.awaitTransactionSuccessAsync( - makerAddress, - payerAddress, - DEFAULT_PROTOCOL_FEE_PAID, - { from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID.plus(1) }, - ); + const tx = testContract + .payProtocolFee(makerAddress, payerAddress, DEFAULT_PROTOCOL_FEE_PAID) + .awaitTransactionSuccessAsync({ from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID.plus(1) }); const expectedError = new StakingRevertErrors.InvalidProtocolFeePaymentError( DEFAULT_PROTOCOL_FEE_PAID, DEFAULT_PROTOCOL_FEE_PAID.plus(1), @@ -134,7 +124,7 @@ blockchainTests('Protocol Fees unit tests', env => { }); async function getProtocolFeesAsync(poolId: string): Promise { - return (await testContract.getStakingPoolStatsThisEpoch.callAsync(poolId)).feesCollected; + return (await testContract.getStakingPoolStatsThisEpoch(poolId).callAsync()).feesCollected; } describe('ETH fees', () => { @@ -148,23 +138,17 @@ blockchainTests('Protocol Fees unit tests', env => { it('should not transfer WETH if value is sent', async () => { await createTestPoolAsync({ operatorStake: minimumStake }); - const receipt = await testContract.payProtocolFee.awaitTransactionSuccessAsync( - makerAddress, - payerAddress, - DEFAULT_PROTOCOL_FEE_PAID, - { from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID }, - ); + const receipt = await testContract + .payProtocolFee(makerAddress, payerAddress, DEFAULT_PROTOCOL_FEE_PAID) + .awaitTransactionSuccessAsync({ from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID }); assertNoWETHTransferLogs(receipt.logs); }); it('should credit pool if the maker is in a pool', async () => { const { poolId } = await createTestPoolAsync({ operatorStake: minimumStake, makers: [makerAddress] }); - const receipt = await testContract.payProtocolFee.awaitTransactionSuccessAsync( - makerAddress, - payerAddress, - DEFAULT_PROTOCOL_FEE_PAID, - { from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID }, - ); + const receipt = await testContract + .payProtocolFee(makerAddress, payerAddress, DEFAULT_PROTOCOL_FEE_PAID) + .awaitTransactionSuccessAsync({ from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID }); assertNoWETHTransferLogs(receipt.logs); const poolFees = await getProtocolFeesAsync(poolId); @@ -173,12 +157,9 @@ blockchainTests('Protocol Fees unit tests', env => { it('should not credit the pool if maker is not in a pool', async () => { const { poolId } = await createTestPoolAsync({ operatorStake: minimumStake }); - const receipt = await testContract.payProtocolFee.awaitTransactionSuccessAsync( - makerAddress, - payerAddress, - DEFAULT_PROTOCOL_FEE_PAID, - { from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID }, - ); + const receipt = await testContract + .payProtocolFee(makerAddress, payerAddress, DEFAULT_PROTOCOL_FEE_PAID) + .awaitTransactionSuccessAsync({ from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID }); assertNoWETHTransferLogs(receipt.logs); const poolFees = await getProtocolFeesAsync(poolId); expect(poolFees).to.bignumber.eq(ZERO_AMOUNT); @@ -187,12 +168,9 @@ blockchainTests('Protocol Fees unit tests', env => { it('fees paid to the same maker should go to the same pool', async () => { const { poolId } = await createTestPoolAsync({ operatorStake: minimumStake, makers: [makerAddress] }); const payAsync = async () => { - const receipt = await testContract.payProtocolFee.awaitTransactionSuccessAsync( - makerAddress, - payerAddress, - DEFAULT_PROTOCOL_FEE_PAID, - { from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID }, - ); + const receipt = await testContract + .payProtocolFee(makerAddress, payerAddress, DEFAULT_PROTOCOL_FEE_PAID) + .awaitTransactionSuccessAsync({ from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID }); assertNoWETHTransferLogs(receipt.logs); }; await payAsync(); @@ -219,23 +197,17 @@ blockchainTests('Protocol Fees unit tests', env => { it('should transfer WETH if no value is sent and the maker is not in a pool', async () => { await createTestPoolAsync({ operatorStake: minimumStake }); - const receipt = await testContract.payProtocolFee.awaitTransactionSuccessAsync( - makerAddress, - payerAddress, - DEFAULT_PROTOCOL_FEE_PAID, - { from: exchangeAddress, value: ZERO_AMOUNT }, - ); + const receipt = await testContract + .payProtocolFee(makerAddress, payerAddress, DEFAULT_PROTOCOL_FEE_PAID) + .awaitTransactionSuccessAsync({ from: exchangeAddress, value: ZERO_AMOUNT }); assertWETHTransferLogs(receipt.logs, payerAddress, DEFAULT_PROTOCOL_FEE_PAID); }); it('should update `protocolFeesThisEpochByPool` if the maker is in a pool', async () => { const { poolId } = await createTestPoolAsync({ operatorStake: minimumStake, makers: [makerAddress] }); - const receipt = await testContract.payProtocolFee.awaitTransactionSuccessAsync( - makerAddress, - payerAddress, - DEFAULT_PROTOCOL_FEE_PAID, - { from: exchangeAddress, value: ZERO_AMOUNT }, - ); + const receipt = await testContract + .payProtocolFee(makerAddress, payerAddress, DEFAULT_PROTOCOL_FEE_PAID) + .awaitTransactionSuccessAsync({ from: exchangeAddress, value: ZERO_AMOUNT }); assertWETHTransferLogs(receipt.logs, payerAddress, DEFAULT_PROTOCOL_FEE_PAID); const poolFees = await getProtocolFeesAsync(poolId); expect(poolFees).to.bignumber.eq(DEFAULT_PROTOCOL_FEE_PAID); @@ -243,12 +215,9 @@ blockchainTests('Protocol Fees unit tests', env => { it('should not update `protocolFeesThisEpochByPool` if maker is not in a pool', async () => { const { poolId } = await createTestPoolAsync({ operatorStake: minimumStake }); - const receipt = await testContract.payProtocolFee.awaitTransactionSuccessAsync( - makerAddress, - payerAddress, - DEFAULT_PROTOCOL_FEE_PAID, - { from: exchangeAddress, value: ZERO_AMOUNT }, - ); + const receipt = await testContract + .payProtocolFee(makerAddress, payerAddress, DEFAULT_PROTOCOL_FEE_PAID) + .awaitTransactionSuccessAsync({ from: exchangeAddress, value: ZERO_AMOUNT }); assertWETHTransferLogs(receipt.logs, payerAddress, DEFAULT_PROTOCOL_FEE_PAID); const poolFees = await getProtocolFeesAsync(poolId); expect(poolFees).to.bignumber.eq(ZERO_AMOUNT); @@ -257,12 +226,9 @@ blockchainTests('Protocol Fees unit tests', env => { it('fees paid to the same maker should go to the same pool', async () => { const { poolId } = await createTestPoolAsync({ operatorStake: minimumStake, makers: [makerAddress] }); const payAsync = async () => { - const receipt = await testContract.payProtocolFee.awaitTransactionSuccessAsync( - makerAddress, - payerAddress, - DEFAULT_PROTOCOL_FEE_PAID, - { from: exchangeAddress, value: ZERO_AMOUNT }, - ); + const receipt = await testContract + .payProtocolFee(makerAddress, payerAddress, DEFAULT_PROTOCOL_FEE_PAID) + .awaitTransactionSuccessAsync({ from: exchangeAddress, value: ZERO_AMOUNT }); assertWETHTransferLogs(receipt.logs, payerAddress, DEFAULT_PROTOCOL_FEE_PAID); }; await payAsync(); @@ -275,15 +241,12 @@ blockchainTests('Protocol Fees unit tests', env => { it('fees paid to the same maker in WETH then ETH should go to the same pool', async () => { const { poolId } = await createTestPoolAsync({ operatorStake: minimumStake, makers: [makerAddress] }); const payAsync = async (inWETH: boolean) => { - await testContract.payProtocolFee.awaitTransactionSuccessAsync( - makerAddress, - payerAddress, - DEFAULT_PROTOCOL_FEE_PAID, - { + await testContract + .payProtocolFee(makerAddress, payerAddress, DEFAULT_PROTOCOL_FEE_PAID) + .awaitTransactionSuccessAsync({ from: exchangeAddress, value: inWETH ? ZERO_AMOUNT : DEFAULT_PROTOCOL_FEE_PAID, - }, - ); + }); }; await payAsync(true); await payAsync(false); @@ -300,12 +263,9 @@ blockchainTests('Protocol Fees unit tests', env => { membersStake: 0, makers: [makerAddress], }); - await testContract.payProtocolFee.awaitTransactionSuccessAsync( - makerAddress, - constants.NULL_ADDRESS, - DEFAULT_PROTOCOL_FEE_PAID, - { from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID }, - ); + await testContract + .payProtocolFee(makerAddress, constants.NULL_ADDRESS, DEFAULT_PROTOCOL_FEE_PAID) + .awaitTransactionSuccessAsync({ from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID }); const feesCredited = await getProtocolFeesAsync(poolId); expect(feesCredited).to.bignumber.eq(DEFAULT_PROTOCOL_FEE_PAID); }); @@ -316,12 +276,9 @@ blockchainTests('Protocol Fees unit tests', env => { membersStake: 0, makers: [makerAddress], }); - await testContract.payProtocolFee.awaitTransactionSuccessAsync( - makerAddress, - constants.NULL_ADDRESS, - DEFAULT_PROTOCOL_FEE_PAID, - { from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID }, - ); + await testContract + .payProtocolFee(makerAddress, constants.NULL_ADDRESS, DEFAULT_PROTOCOL_FEE_PAID) + .awaitTransactionSuccessAsync({ from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID }); const feesCredited = await getProtocolFeesAsync(poolId); expect(feesCredited).to.bignumber.eq(DEFAULT_PROTOCOL_FEE_PAID); }); @@ -332,12 +289,9 @@ blockchainTests('Protocol Fees unit tests', env => { membersStake: 0, makers: [makerAddress], }); - await testContract.payProtocolFee.awaitTransactionSuccessAsync( - makerAddress, - constants.NULL_ADDRESS, - DEFAULT_PROTOCOL_FEE_PAID, - { from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID }, - ); + await testContract + .payProtocolFee(makerAddress, constants.NULL_ADDRESS, DEFAULT_PROTOCOL_FEE_PAID) + .awaitTransactionSuccessAsync({ from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID }); const feesCredited = await getProtocolFeesAsync(poolId); expect(feesCredited).to.bignumber.eq(0); }); @@ -347,7 +301,7 @@ blockchainTests('Protocol Fees unit tests', env => { let membersStakeWeight: number; before(async () => { - membersStakeWeight = (await testContract.getParams.callAsync())[1]; + membersStakeWeight = (await testContract.getParams().callAsync())[1]; }); interface FinalizationState { @@ -357,7 +311,7 @@ blockchainTests('Protocol Fees unit tests', env => { } async function getFinalizationStateAsync(): Promise { - const aggregatedStats = await testContract.getAggregatedStatsForCurrentEpoch.callAsync(); + const aggregatedStats = await testContract.getAggregatedStatsForCurrentEpoch().callAsync(); return { numPoolsToFinalize: aggregatedStats.numPoolsToFinalize, totalFeesCollected: aggregatedStats.totalFeesCollected, @@ -372,12 +326,9 @@ blockchainTests('Protocol Fees unit tests', env => { async function payToMakerAsync(poolMaker: string, fee?: Numberish): Promise { const _fee = fee === undefined ? getRandomInteger(1, '1e18') : fee; - const receipt = await testContract.payProtocolFee.awaitTransactionSuccessAsync( - poolMaker, - payerAddress, - new BigNumber(_fee), - { from: exchangeAddress, value: _fee }, - ); + const receipt = await testContract + .payProtocolFee(poolMaker, payerAddress, new BigNumber(_fee)) + .awaitTransactionSuccessAsync({ from: exchangeAddress, value: _fee }); const events = filterLogsToArguments( receipt.logs, IStakingEventsEvents.StakingPoolEarnedRewardsInEpoch, @@ -404,7 +355,7 @@ blockchainTests('Protocol Fees unit tests', env => { it('pool is not registered to start', async () => { const { poolId } = await createTestPoolAsync(); - const pool = await testContract.getStakingPoolStatsThisEpoch.callAsync(poolId); + const pool = await testContract.getStakingPoolStatsThisEpoch(poolId).callAsync(); expect(pool.feesCollected).to.bignumber.eq(0); expect(pool.membersStake).to.bignumber.eq(0); expect(pool.weightedStake).to.bignumber.eq(0); @@ -419,7 +370,7 @@ blockchainTests('Protocol Fees unit tests', env => { const { fee, poolEarnedRewardsEvents } = await payToMakerAsync(poolMaker); expect(poolEarnedRewardsEvents.length).to.eq(1); expect(poolEarnedRewardsEvents[0].poolId).to.eq(poolId); - const actualPoolStats = await testContract.getStakingPoolStatsThisEpoch.callAsync(poolId); + const actualPoolStats = await testContract.getStakingPoolStatsThisEpoch(poolId).callAsync(); const expectedWeightedStake = toWeightedStake(pool.operatorStake, pool.membersStake); expect(actualPoolStats.feesCollected).to.bignumber.eq(fee); expect(actualPoolStats.membersStake).to.bignumber.eq(pool.membersStake); @@ -439,7 +390,7 @@ blockchainTests('Protocol Fees unit tests', env => { const { fee: fee1 } = await payToMakerAsync(poolMaker); const { fee: fee2, poolEarnedRewardsEvents } = await payToMakerAsync(poolMaker); expect(poolEarnedRewardsEvents).to.deep.eq([]); - const actualPoolStats = await testContract.getStakingPoolStatsThisEpoch.callAsync(poolId); + const actualPoolStats = await testContract.getStakingPoolStatsThisEpoch(poolId).callAsync(); const expectedWeightedStake = toWeightedStake(pool.operatorStake, pool.membersStake); const fees = BigNumber.sum(fee1, fee2); expect(actualPoolStats.feesCollected).to.bignumber.eq(fees); @@ -463,7 +414,7 @@ blockchainTests('Protocol Fees unit tests', env => { const { fee, poolEarnedRewardsEvents } = await payToMakerAsync(poolMaker); expect(poolEarnedRewardsEvents.length).to.eq(1); expect(poolEarnedRewardsEvents[0].poolId).to.eq(poolId); - const actualPoolStats = await testContract.getStakingPoolStatsThisEpoch.callAsync(poolId); + const actualPoolStats = await testContract.getStakingPoolStatsThisEpoch(poolId).callAsync(); const expectedWeightedStake = toWeightedStake(pool.operatorStake, pool.membersStake); expect(actualPoolStats.feesCollected).to.bignumber.eq(fee); expect(actualPoolStats.membersStake).to.bignumber.eq(pool.membersStake); @@ -484,8 +435,8 @@ blockchainTests('Protocol Fees unit tests', env => { makers: [poolMaker], } = pool; await payToMakerAsync(poolMaker); - await testContract.advanceEpoch.awaitTransactionSuccessAsync(); - const actualPoolStats = await testContract.getStakingPoolStatsThisEpoch.callAsync(poolId); + await testContract.advanceEpoch().awaitTransactionSuccessAsync(); + const actualPoolStats = await testContract.getStakingPoolStatsThisEpoch(poolId).callAsync(); expect(actualPoolStats.feesCollected).to.bignumber.eq(0); expect(actualPoolStats.membersStake).to.bignumber.eq(0); expect(actualPoolStats.weightedStake).to.bignumber.eq(0); diff --git a/contracts/staking/test/unit_tests/stake_balances_test.ts b/contracts/staking/test/unit_tests/stake_balances_test.ts index 019a4487b1..8c5d6cd930 100644 --- a/contracts/staking/test/unit_tests/stake_balances_test.ts +++ b/contracts/staking/test/unit_tests/stake_balances_test.ts @@ -59,11 +59,10 @@ blockchainTests.resets('MixinStakeBalances unit tests', env => { ); before(async () => { - await testContract.setGlobalStakeByStatus.awaitTransactionSuccessAsync( - StakeStatus.Delegated, - delegatedBalance, - ); - await testContract.setBalanceOfZrxVault.awaitTransactionSuccessAsync(zrxVaultBalance); + await testContract + .setGlobalStakeByStatus(StakeStatus.Delegated, delegatedBalance) + .awaitTransactionSuccessAsync(); + await testContract.setBalanceOfZrxVault(zrxVaultBalance).awaitTransactionSuccessAsync(); }); it('undelegated stake is the difference between zrx vault balance and global delegated stake', async () => { @@ -72,12 +71,12 @@ blockchainTests.resets('MixinStakeBalances unit tests', env => { currentEpochBalance: zrxVaultBalance.minus(delegatedBalance.currentEpochBalance), nextEpochBalance: zrxVaultBalance.minus(delegatedBalance.nextEpochBalance), }; - const actualBalance = await testContract.getGlobalStakeByStatus.callAsync(StakeStatus.Undelegated); + const actualBalance = await testContract.getGlobalStakeByStatus(StakeStatus.Undelegated).callAsync(); expect(actualBalance).to.deep.eq(expectedBalance); }); it('delegated stake is the global delegated stake', async () => { - const actualBalance = await testContract.getGlobalStakeByStatus.callAsync(StakeStatus.Delegated); + const actualBalance = await testContract.getGlobalStakeByStatus(StakeStatus.Delegated).callAsync(); expect(actualBalance).to.deep.eq(toCurrentBalance(delegatedBalance)); }); @@ -86,8 +85,8 @@ blockchainTests.resets('MixinStakeBalances unit tests', env => { delegatedBalance.currentEpochBalance, delegatedBalance.nextEpochBalance, ).minus(1); - await testContract.setBalanceOfZrxVault.awaitTransactionSuccessAsync(_zrxVaultBalance); - const tx = testContract.getGlobalStakeByStatus.callAsync(StakeStatus.Undelegated); + await testContract.setBalanceOfZrxVault(_zrxVaultBalance).awaitTransactionSuccessAsync(); + const tx = testContract.getGlobalStakeByStatus(StakeStatus.Undelegated).callAsync(); const expectedError = new SafeMathRevertErrors.Uint256BinOpError( SafeMathRevertErrors.BinOpErrorCodes.SubtractionUnderflow, _zrxVaultBalance, @@ -99,7 +98,7 @@ blockchainTests.resets('MixinStakeBalances unit tests', env => { }); it('throws if unknown stake status is passed in', async () => { - const tx = testContract.getGlobalStakeByStatus.callAsync(2); + const tx = testContract.getGlobalStakeByStatus(2).callAsync(); return expect(tx).to.be.rejected(); }); }); @@ -111,40 +110,36 @@ blockchainTests.resets('MixinStakeBalances unit tests', env => { const undelegatedStake = randomStoredBalance(); before(async () => { - await testContract.setOwnerStakeByStatus.awaitTransactionSuccessAsync( - staker, - StakeStatus.Delegated, - delegatedStake, - ); - await testContract.setOwnerStakeByStatus.awaitTransactionSuccessAsync( - staker, - StakeStatus.Undelegated, - undelegatedStake, - ); + await testContract + .setOwnerStakeByStatus(staker, StakeStatus.Delegated, delegatedStake) + .awaitTransactionSuccessAsync(); + await testContract + .setOwnerStakeByStatus(staker, StakeStatus.Undelegated, undelegatedStake) + .awaitTransactionSuccessAsync(); }); it('throws if unknown stake status is passed in', async () => { - const tx = testContract.getOwnerStakeByStatus.callAsync(staker, 2); + const tx = testContract.getOwnerStakeByStatus(staker, 2).callAsync(); return expect(tx).to.be.rejected(); }); it('returns empty delegated stake for an unstaked owner', async () => { - const balance = await testContract.getOwnerStakeByStatus.callAsync(notStaker, StakeStatus.Delegated); + const balance = await testContract.getOwnerStakeByStatus(notStaker, StakeStatus.Delegated).callAsync(); expect(balance).to.deep.eq(EMPTY_BALANCE); }); it('returns empty undelegated stake for an unstaked owner', async () => { - const balance = await testContract.getOwnerStakeByStatus.callAsync(notStaker, StakeStatus.Undelegated); + const balance = await testContract.getOwnerStakeByStatus(notStaker, StakeStatus.Undelegated).callAsync(); expect(balance).to.deep.eq(EMPTY_BALANCE); }); it('returns undelegated stake for a staked owner', async () => { - const balance = await testContract.getOwnerStakeByStatus.callAsync(staker, StakeStatus.Undelegated); + const balance = await testContract.getOwnerStakeByStatus(staker, StakeStatus.Undelegated).callAsync(); expect(balance).to.deep.eq(toCurrentBalance(undelegatedStake)); }); it('returns delegated stake for a staked owner', async () => { - const balance = await testContract.getOwnerStakeByStatus.callAsync(staker, StakeStatus.Delegated); + const balance = await testContract.getOwnerStakeByStatus(staker, StakeStatus.Delegated).callAsync(); expect(balance).to.deep.eq(toCurrentBalance(delegatedStake)); }); }); @@ -155,16 +150,16 @@ blockchainTests.resets('MixinStakeBalances unit tests', env => { const stakerAmount = randomAmount(); before(async () => { - await testContract.setZrxBalanceOf.awaitTransactionSuccessAsync(staker, stakerAmount); + await testContract.setZrxBalanceOf(staker, stakerAmount).awaitTransactionSuccessAsync(); }); it('returns empty for unstaked owner', async () => { - const amount = await testContract.getTotalStake.callAsync(notStaker); + const amount = await testContract.getTotalStake(notStaker).callAsync(); expect(amount).to.bignumber.eq(0); }); it('returns stake for staked owner', async () => { - const amount = await testContract.getTotalStake.callAsync(staker); + const amount = await testContract.getTotalStake(staker).callAsync(); expect(amount).to.bignumber.eq(stakerAmount); }); }); @@ -177,25 +172,23 @@ blockchainTests.resets('MixinStakeBalances unit tests', env => { const delegatedBalance = randomStoredBalance(); before(async () => { - await testContract.setDelegatedStakeToPoolByOwner.awaitTransactionSuccessAsync( - staker, - poolId, - delegatedBalance, - ); + await testContract + .setDelegatedStakeToPoolByOwner(staker, poolId, delegatedBalance) + .awaitTransactionSuccessAsync(); }); it('returns empty for unstaked owner', async () => { - const balance = await testContract.getStakeDelegatedToPoolByOwner.callAsync(notStaker, poolId); + const balance = await testContract.getStakeDelegatedToPoolByOwner(notStaker, poolId).callAsync(); expect(balance).to.deep.eq(EMPTY_BALANCE); }); it('returns empty for empty pool', async () => { - const balance = await testContract.getStakeDelegatedToPoolByOwner.callAsync(staker, notPoolId); + const balance = await testContract.getStakeDelegatedToPoolByOwner(staker, notPoolId).callAsync(); expect(balance).to.deep.eq(EMPTY_BALANCE); }); it('returns stake for staked owner in their pool', async () => { - const balance = await testContract.getStakeDelegatedToPoolByOwner.callAsync(staker, poolId); + const balance = await testContract.getStakeDelegatedToPoolByOwner(staker, poolId).callAsync(); expect(balance).to.deep.eq(toCurrentBalance(delegatedBalance)); }); }); @@ -206,16 +199,16 @@ blockchainTests.resets('MixinStakeBalances unit tests', env => { const delegatedBalance = randomStoredBalance(); before(async () => { - await testContract.setDelegatedStakeByPoolId.awaitTransactionSuccessAsync(poolId, delegatedBalance); + await testContract.setDelegatedStakeByPoolId(poolId, delegatedBalance).awaitTransactionSuccessAsync(); }); it('returns empty for empty pool', async () => { - const balance = await testContract.getTotalStakeDelegatedToPool.callAsync(notPoolId); + const balance = await testContract.getTotalStakeDelegatedToPool(notPoolId).callAsync(); expect(balance).to.deep.eq(EMPTY_BALANCE); }); it('returns stake for staked pool', async () => { - const balance = await testContract.getTotalStakeDelegatedToPool.callAsync(poolId); + const balance = await testContract.getTotalStakeDelegatedToPool(poolId).callAsync(); expect(balance).to.deep.eq(toCurrentBalance(delegatedBalance)); }); }); diff --git a/contracts/staking/test/unit_tests/stake_test.ts b/contracts/staking/test/unit_tests/stake_test.ts index 76e5dd5d47..080d0c71ef 100644 --- a/contracts/staking/test/unit_tests/stake_test.ts +++ b/contracts/staking/test/unit_tests/stake_test.ts @@ -46,17 +46,16 @@ blockchainTests.resets('MixinStake unit tests', env => { env.txDefaults, artifacts, ); - currentEpoch = await testContract.currentEpoch.callAsync(); - stakerUndelegatedStakeSlot = await testContract.getOwnerStakeByStatusSlot.callAsync( - staker, - StakeStatus.Undelegated, - ); + currentEpoch = await testContract.currentEpoch().callAsync(); + stakerUndelegatedStakeSlot = await testContract + .getOwnerStakeByStatusSlot(staker, StakeStatus.Undelegated) + .callAsync(); }); describe('stake()', () => { it('deposits funds into the ZRX vault', async () => { const amount = getRandomInteger(0, 100e18); - const { logs } = await testContract.stake.awaitTransactionSuccessAsync(amount); + const { logs } = await testContract.stake(amount).awaitTransactionSuccessAsync(); const events = filterLogsToArguments(logs, StakeEvents.ZrxVaultDepositFrom); expect(events).to.be.length(1); expect(events[0].staker).to.eq(staker); @@ -65,7 +64,7 @@ blockchainTests.resets('MixinStake unit tests', env => { it('increases current and next undelegated stake balance', async () => { const amount = getRandomInteger(0, 100e18); - const { logs } = await testContract.stake.awaitTransactionSuccessAsync(amount); + const { logs } = await testContract.stake(amount).awaitTransactionSuccessAsync(); const events = filterLogsToArguments( logs, StakeEvents.IncreaseCurrentAndNextBalance, @@ -77,7 +76,7 @@ blockchainTests.resets('MixinStake unit tests', env => { it('raises a `Stake` event', async () => { const amount = getRandomInteger(0, 100e18); - const { logs } = await testContract.stake.awaitTransactionSuccessAsync(amount); + const { logs } = await testContract.stake(amount).awaitTransactionSuccessAsync(); const events = filterLogsToArguments(logs, StakeEvents.Stake); expect(events).to.be.length(1); expect(events[0].staker).to.eq(staker); @@ -90,17 +89,19 @@ blockchainTests.resets('MixinStake unit tests', env => { currentEpochBalance: Numberish, nextEpochBalance: Numberish, ): Promise { - await testContract.setOwnerStakeByStatus.awaitTransactionSuccessAsync(staker, StakeStatus.Undelegated, { - currentEpoch, - currentEpochBalance: new BigNumber(currentEpochBalance), - nextEpochBalance: new BigNumber(nextEpochBalance), - }); + await testContract + .setOwnerStakeByStatus(staker, StakeStatus.Undelegated, { + currentEpoch, + currentEpochBalance: new BigNumber(currentEpochBalance), + nextEpochBalance: new BigNumber(nextEpochBalance), + }) + .awaitTransactionSuccessAsync(); } it('throws if not enough undelegated stake in the current epoch', async () => { const amount = getRandomInteger(0, 100e18); await setUndelegatedStakeAsync(amount.minus(1), amount); - const tx = testContract.unstake.awaitTransactionSuccessAsync(amount); + const tx = testContract.unstake(amount).awaitTransactionSuccessAsync(); const expectedError = new StakingRevertErrors.InsufficientBalanceError(amount, amount.minus(1)); return expect(tx).to.revertWith(expectedError); }); @@ -108,7 +109,7 @@ blockchainTests.resets('MixinStake unit tests', env => { it('throws if not enough undelegated stake in the next epoch', async () => { const amount = getRandomInteger(0, 100e18); await setUndelegatedStakeAsync(amount, amount.minus(1)); - const tx = testContract.unstake.awaitTransactionSuccessAsync(amount); + const tx = testContract.unstake(amount).awaitTransactionSuccessAsync(); const expectedError = new StakingRevertErrors.InsufficientBalanceError(amount, amount.minus(1)); return expect(tx).to.revertWith(expectedError); }); @@ -116,7 +117,7 @@ blockchainTests.resets('MixinStake unit tests', env => { it('throws if not enough undelegated stake in both epochs', async () => { const amount = getRandomInteger(0, 100e18); await setUndelegatedStakeAsync(amount.minus(1), amount.minus(1)); - const tx = testContract.unstake.awaitTransactionSuccessAsync(amount); + const tx = testContract.unstake(amount).awaitTransactionSuccessAsync(); const expectedError = new StakingRevertErrors.InsufficientBalanceError(amount, amount.minus(1)); return expect(tx).to.revertWith(expectedError); }); @@ -124,7 +125,7 @@ blockchainTests.resets('MixinStake unit tests', env => { it('decreases current and next undelegated stake balance', async () => { const amount = getRandomInteger(0, 100e18); await setUndelegatedStakeAsync(amount, amount); - const { logs } = await testContract.unstake.awaitTransactionSuccessAsync(amount); + const { logs } = await testContract.unstake(amount).awaitTransactionSuccessAsync(); const events = filterLogsToArguments( logs, StakeEvents.DecreaseCurrentAndNextBalance, @@ -137,7 +138,7 @@ blockchainTests.resets('MixinStake unit tests', env => { it('withdraws funds from the ZRX vault', async () => { const amount = getRandomInteger(0, 100e18); await setUndelegatedStakeAsync(amount, amount); - const { logs } = await testContract.unstake.awaitTransactionSuccessAsync(amount); + const { logs } = await testContract.unstake(amount).awaitTransactionSuccessAsync(); const events = filterLogsToArguments(logs, StakeEvents.ZrxVaultWithdrawFrom); expect(events).to.be.length(1); expect(events[0].staker).to.eq(staker); @@ -147,7 +148,7 @@ blockchainTests.resets('MixinStake unit tests', env => { it('emits an `Unstake` event', async () => { const amount = getRandomInteger(0, 100e18); await setUndelegatedStakeAsync(amount, amount); - const { logs } = await testContract.unstake.awaitTransactionSuccessAsync(amount); + const { logs } = await testContract.unstake(amount).awaitTransactionSuccessAsync(); const events = filterLogsToArguments(logs, StakeEvents.Unstake); expect(events).to.be.length(1); expect(events[0].staker).to.eq(staker); @@ -167,52 +168,59 @@ blockchainTests.resets('MixinStake unit tests', env => { before(async () => { delegatedStakeToPoolByOwnerSlots = await Promise.all( VALID_POOL_IDS.map(async poolId => - testContract.getDelegatedStakeToPoolByOwnerSlot.callAsync(poolId, staker), + testContract.getDelegatedStakeToPoolByOwnerSlot(poolId, staker).callAsync(), ), ); delegatedStakeByPoolIdSlots = await Promise.all( - VALID_POOL_IDS.map(async poolId => testContract.getDelegatedStakeByPoolIdSlot.callAsync(poolId)), - ); - globalDelegatedStakeSlot = await testContract.getGlobalStakeByStatusSlot.callAsync(StakeStatus.Delegated); - stakerDelegatedStakeSlot = await testContract.getOwnerStakeByStatusSlot.callAsync( - staker, - StakeStatus.Delegated, + VALID_POOL_IDS.map(async poolId => testContract.getDelegatedStakeByPoolIdSlot(poolId).callAsync()), ); + globalDelegatedStakeSlot = await testContract.getGlobalStakeByStatusSlot(StakeStatus.Delegated).callAsync(); + stakerDelegatedStakeSlot = await testContract + .getOwnerStakeByStatusSlot(staker, StakeStatus.Delegated) + .callAsync(); }); it('throws if the "from" pool is invalid', async () => { - const tx = testContract.moveStake.awaitTransactionSuccessAsync( - { status: StakeStatus.Delegated, poolId: INVALID_POOL_ID }, - { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[0] }, - getRandomInteger(0, 100e18), - ); + const tx = testContract + .moveStake( + { status: StakeStatus.Delegated, poolId: INVALID_POOL_ID }, + { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[0] }, + getRandomInteger(0, 100e18), + ) + .awaitTransactionSuccessAsync(); return expect(tx).to.revertWith(INVALID_POOL_ERROR); }); it('throws if the "to" pool is invalid', async () => { - const tx = testContract.moveStake.awaitTransactionSuccessAsync( - { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[0] }, - { status: StakeStatus.Delegated, poolId: INVALID_POOL_ID }, - getRandomInteger(0, 100e18), - ); + const tx = testContract + .moveStake( + { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[0] }, + { status: StakeStatus.Delegated, poolId: INVALID_POOL_ID }, + getRandomInteger(0, 100e18), + ) + .awaitTransactionSuccessAsync(); return expect(tx).to.revertWith(INVALID_POOL_ERROR); }); it('throws if the "from" and "to" pools are invalid', async () => { - const tx = testContract.moveStake.awaitTransactionSuccessAsync( - { status: StakeStatus.Delegated, poolId: INVALID_POOL_ID }, - { status: StakeStatus.Delegated, poolId: INVALID_POOL_ID }, - getRandomInteger(0, 100e18), - ); + const tx = testContract + .moveStake( + { status: StakeStatus.Delegated, poolId: INVALID_POOL_ID }, + { status: StakeStatus.Delegated, poolId: INVALID_POOL_ID }, + getRandomInteger(0, 100e18), + ) + .awaitTransactionSuccessAsync(); return expect(tx).to.revertWith(INVALID_POOL_ERROR); }); it('withdraws delegator rewards when "from" stake is delegated', async () => { - const { logs } = await testContract.moveStake.awaitTransactionSuccessAsync( - { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[0] }, - { status: StakeStatus.Undelegated, poolId: VALID_POOL_IDS[1] }, - getRandomInteger(0, 100e18), - ); + const { logs } = await testContract + .moveStake( + { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[0] }, + { status: StakeStatus.Undelegated, poolId: VALID_POOL_IDS[1] }, + getRandomInteger(0, 100e18), + ) + .awaitTransactionSuccessAsync(); const events = filterLogsToArguments( logs, StakeEvents.WithdrawAndSyncDelegatorRewards, @@ -223,11 +231,13 @@ blockchainTests.resets('MixinStake unit tests', env => { }); it('withdraws delegator rewards when "to" stake is delegated', async () => { - const { logs } = await testContract.moveStake.awaitTransactionSuccessAsync( - { status: StakeStatus.Undelegated, poolId: VALID_POOL_IDS[0] }, - { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[1] }, - getRandomInteger(0, 100e18), - ); + const { logs } = await testContract + .moveStake( + { status: StakeStatus.Undelegated, poolId: VALID_POOL_IDS[0] }, + { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[1] }, + getRandomInteger(0, 100e18), + ) + .awaitTransactionSuccessAsync(); const events = filterLogsToArguments( logs, StakeEvents.WithdrawAndSyncDelegatorRewards, @@ -238,11 +248,13 @@ blockchainTests.resets('MixinStake unit tests', env => { }); it('withdraws delegator rewards when both stakes are both delegated', async () => { - const { logs } = await testContract.moveStake.awaitTransactionSuccessAsync( - { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[0] }, - { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[1] }, - getRandomInteger(0, 100e18), - ); + const { logs } = await testContract + .moveStake( + { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[0] }, + { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[1] }, + getRandomInteger(0, 100e18), + ) + .awaitTransactionSuccessAsync(); const events = filterLogsToArguments( logs, StakeEvents.WithdrawAndSyncDelegatorRewards, @@ -255,11 +267,13 @@ blockchainTests.resets('MixinStake unit tests', env => { }); it('does not withdraw delegator rewards when both stakes are both undelegated', async () => { - const { logs } = await testContract.moveStake.awaitTransactionSuccessAsync( - { status: StakeStatus.Undelegated, poolId: VALID_POOL_IDS[0] }, - { status: StakeStatus.Undelegated, poolId: VALID_POOL_IDS[1] }, - getRandomInteger(0, 100e18), - ); + const { logs } = await testContract + .moveStake( + { status: StakeStatus.Undelegated, poolId: VALID_POOL_IDS[0] }, + { status: StakeStatus.Undelegated, poolId: VALID_POOL_IDS[1] }, + getRandomInteger(0, 100e18), + ) + .awaitTransactionSuccessAsync(); const events = filterLogsToArguments( logs, StakeEvents.WithdrawAndSyncDelegatorRewards, @@ -269,11 +283,13 @@ blockchainTests.resets('MixinStake unit tests', env => { it('decreases pool and global delegated stake counters when "from" stake is delegated', async () => { const amount = getRandomInteger(0, 100e18); - const { logs } = await testContract.moveStake.awaitTransactionSuccessAsync( - { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[0] }, - { status: StakeStatus.Undelegated, poolId: VALID_POOL_IDS[1] }, - amount, - ); + const { logs } = await testContract + .moveStake( + { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[0] }, + { status: StakeStatus.Undelegated, poolId: VALID_POOL_IDS[1] }, + amount, + ) + .awaitTransactionSuccessAsync(); const decreaseNextBalanceEvents = filterLogsToArguments( logs, StakeEvents.DecreaseNextBalance, @@ -292,11 +308,13 @@ blockchainTests.resets('MixinStake unit tests', env => { it('increases pool and global delegated stake counters when "to" stake is delegated', async () => { const amount = getRandomInteger(0, 100e18); - const { logs } = await testContract.moveStake.awaitTransactionSuccessAsync( - { status: StakeStatus.Undelegated, poolId: VALID_POOL_IDS[0] }, - { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[1] }, - amount, - ); + const { logs } = await testContract + .moveStake( + { status: StakeStatus.Undelegated, poolId: VALID_POOL_IDS[0] }, + { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[1] }, + amount, + ) + .awaitTransactionSuccessAsync(); const increaseNextBalanceEvents = filterLogsToArguments( logs, StakeEvents.IncreaseNextBalance, @@ -315,11 +333,13 @@ blockchainTests.resets('MixinStake unit tests', env => { it('decreases then increases pool and global delegated stake counters when both stakes are delegated', async () => { const amount = getRandomInteger(0, 100e18); - const { logs } = await testContract.moveStake.awaitTransactionSuccessAsync( - { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[0] }, - { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[1] }, - amount, - ); + const { logs } = await testContract + .moveStake( + { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[0] }, + { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[1] }, + amount, + ) + .awaitTransactionSuccessAsync(); const decreaseNextBalanceEvents = filterLogs( logs, StakeEvents.DecreaseNextBalance, @@ -356,11 +376,13 @@ blockchainTests.resets('MixinStake unit tests', env => { it('does not change pool and global delegated stake counters when both stakes are undelegated', async () => { const amount = getRandomInteger(0, 100e18); - const { logs } = await testContract.moveStake.awaitTransactionSuccessAsync( - { status: StakeStatus.Undelegated, poolId: VALID_POOL_IDS[0] }, - { status: StakeStatus.Undelegated, poolId: VALID_POOL_IDS[1] }, - amount, - ); + const { logs } = await testContract + .moveStake( + { status: StakeStatus.Undelegated, poolId: VALID_POOL_IDS[0] }, + { status: StakeStatus.Undelegated, poolId: VALID_POOL_IDS[1] }, + amount, + ) + .awaitTransactionSuccessAsync(); const decreaseNextBalanceEvents = filterLogsToArguments( logs, StakeEvents.DecreaseNextBalance, @@ -375,33 +397,39 @@ blockchainTests.resets('MixinStake unit tests', env => { it('does nothing when moving the owner stake from undelegated to undelegated', async () => { const amount = getRandomInteger(0, 100e18); - const { logs } = await testContract.moveStake.awaitTransactionSuccessAsync( - { status: StakeStatus.Undelegated, poolId: VALID_POOL_IDS[0] }, - { status: StakeStatus.Undelegated, poolId: VALID_POOL_IDS[1] }, - amount, - ); + const { logs } = await testContract + .moveStake( + { status: StakeStatus.Undelegated, poolId: VALID_POOL_IDS[0] }, + { status: StakeStatus.Undelegated, poolId: VALID_POOL_IDS[1] }, + amount, + ) + .awaitTransactionSuccessAsync(); const events = filterLogsToArguments(logs, StakeEvents.MoveStakeStorage); expect(events).to.be.length(0); }); it('does nothing when moving zero stake', async () => { const amount = new BigNumber(0); - const { logs } = await testContract.moveStake.awaitTransactionSuccessAsync( - { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[0] }, - { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[1] }, - amount, - ); + const { logs } = await testContract + .moveStake( + { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[0] }, + { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[1] }, + amount, + ) + .awaitTransactionSuccessAsync(); const events = filterLogsToArguments(logs, StakeEvents.MoveStakeStorage); expect(events).to.be.length(0); }); it('moves the owner stake between the same pointer when both are delegated', async () => { const amount = getRandomInteger(0, 100e18); - const { logs } = await testContract.moveStake.awaitTransactionSuccessAsync( - { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[0] }, - { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[1] }, - amount, - ); + const { logs } = await testContract + .moveStake( + { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[0] }, + { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[1] }, + amount, + ) + .awaitTransactionSuccessAsync(); const events = filterLogsToArguments(logs, StakeEvents.MoveStakeStorage); expect(events).to.be.length(1); expect(events[0].fromBalanceSlot).to.eq(stakerDelegatedStakeSlot); @@ -411,11 +439,13 @@ blockchainTests.resets('MixinStake unit tests', env => { it('moves the owner stake between different pointers when "from" is undelegated and "to" is delegated', async () => { const amount = getRandomInteger(0, 100e18); - const { logs } = await testContract.moveStake.awaitTransactionSuccessAsync( - { status: StakeStatus.Undelegated, poolId: VALID_POOL_IDS[0] }, - { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[1] }, - amount, - ); + const { logs } = await testContract + .moveStake( + { status: StakeStatus.Undelegated, poolId: VALID_POOL_IDS[0] }, + { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[1] }, + amount, + ) + .awaitTransactionSuccessAsync(); const events = filterLogsToArguments(logs, StakeEvents.MoveStakeStorage); expect(events).to.be.length(1); expect(events[0].fromBalanceSlot).to.eq(stakerUndelegatedStakeSlot); @@ -425,11 +455,13 @@ blockchainTests.resets('MixinStake unit tests', env => { it('moves the owner stake between different pointers when "from" is delegated and "to" is undelegated', async () => { const amount = getRandomInteger(0, 100e18); - const { logs } = await testContract.moveStake.awaitTransactionSuccessAsync( - { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[0] }, - { status: StakeStatus.Undelegated, poolId: VALID_POOL_IDS[1] }, - amount, - ); + const { logs } = await testContract + .moveStake( + { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[0] }, + { status: StakeStatus.Undelegated, poolId: VALID_POOL_IDS[1] }, + amount, + ) + .awaitTransactionSuccessAsync(); const events = filterLogsToArguments(logs, StakeEvents.MoveStakeStorage); expect(events).to.be.length(1); expect(events[0].fromBalanceSlot).to.eq(stakerDelegatedStakeSlot); @@ -439,11 +471,13 @@ blockchainTests.resets('MixinStake unit tests', env => { it('emits a `MoveStake` event', async () => { const amount = getRandomInteger(0, 100e18); - const { logs } = await testContract.moveStake.awaitTransactionSuccessAsync( - { status: StakeStatus.Undelegated, poolId: VALID_POOL_IDS[0] }, - { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[1] }, - amount, - ); + const { logs } = await testContract + .moveStake( + { status: StakeStatus.Undelegated, poolId: VALID_POOL_IDS[0] }, + { status: StakeStatus.Delegated, poolId: VALID_POOL_IDS[1] }, + amount, + ) + .awaitTransactionSuccessAsync(); const events = filterLogsToArguments(logs, StakeEvents.MoveStake); expect(events).to.be.length(1); expect(events[0].staker).to.eq(staker); diff --git a/contracts/staking/test/unit_tests/staking_pool_test.ts b/contracts/staking/test/unit_tests/staking_pool_test.ts index fef82105fb..88f31a4d9c 100644 --- a/contracts/staking/test/unit_tests/staking_pool_test.ts +++ b/contracts/staking/test/unit_tests/staking_pool_test.ts @@ -56,34 +56,36 @@ blockchainTests.resets('MixinStakingPool unit tests', env => { operatorShare: randomOperatorShare(), ...opts, }; - await testContract.setPoolById.awaitTransactionSuccessAsync(_opts.poolId, { - operator: _opts.operator, - operatorShare: _opts.operatorShare, - }); + await testContract + .setPoolById(_opts.poolId, { + operator: _opts.operator, + operatorShare: _opts.operatorShare, + }) + .awaitTransactionSuccessAsync(); return _opts; } async function addMakerToPoolAsync(poolId: string, _maker: string): Promise { - await testContract.setPoolIdByMaker.awaitTransactionSuccessAsync(poolId, _maker); + await testContract.setPoolIdByMaker(poolId, _maker).awaitTransactionSuccessAsync(); } describe('onlyStakingPoolOperator modifier', () => { it('fails if not called by the pool operator', async () => { const { poolId } = await createPoolAsync(); - const tx = testContract.testOnlyStakingPoolOperatorModifier.callAsync(poolId, { from: notOperatorOrMaker }); + const tx = testContract.testOnlyStakingPoolOperatorModifier(poolId).callAsync({ from: notOperatorOrMaker }); const expectedError = new StakingRevertErrors.OnlyCallableByPoolOperatorError(notOperatorOrMaker, poolId); return expect(tx).to.revertWith(expectedError); }); it('fails if called by a pool maker', async () => { const { poolId } = await createPoolAsync(); await addMakerToPoolAsync(poolId, maker); - const tx = testContract.testOnlyStakingPoolOperatorModifier.callAsync(poolId, { from: maker }); + const tx = testContract.testOnlyStakingPoolOperatorModifier(poolId).callAsync({ from: maker }); const expectedError = new StakingRevertErrors.OnlyCallableByPoolOperatorError(maker, poolId); return expect(tx).to.revertWith(expectedError); }); it('succeeds if called by the pool operator', async () => { const { poolId } = await createPoolAsync(); - await testContract.testOnlyStakingPoolOperatorModifier.callAsync(poolId, { from: operator }); + await testContract.testOnlyStakingPoolOperatorModifier(poolId).callAsync({ from: operator }); }); }); @@ -91,12 +93,12 @@ blockchainTests.resets('MixinStakingPool unit tests', env => { let nextPoolId: string; before(async () => { - nextPoolId = toNextPoolId(await testContract.lastPoolId.callAsync()); + nextPoolId = toNextPoolId(await testContract.lastPoolId().callAsync()); }); it('fails if the next pool ID overflows', async () => { - await testContract.setLastPoolId.awaitTransactionSuccessAsync(toHex(constants.MAX_UINT256)); - const tx = testContract.createStakingPool.awaitTransactionSuccessAsync(randomOperatorShare(), false); + await testContract.setLastPoolId(toHex(constants.MAX_UINT256)).awaitTransactionSuccessAsync(); + const tx = testContract.createStakingPool(randomOperatorShare(), false).awaitTransactionSuccessAsync(); const expectedError = new SafeMathRevertErrors.Uint256BinOpError( SafeMathRevertErrors.BinOpErrorCodes.AdditionOverflow, constants.MAX_UINT256, @@ -106,7 +108,7 @@ blockchainTests.resets('MixinStakingPool unit tests', env => { }); it('fails if the operator share is invalid', async () => { const operatorShare = constants.PPM_100_PERCENT + 1; - const tx = testContract.createStakingPool.awaitTransactionSuccessAsync(operatorShare, false); + const tx = testContract.createStakingPool(operatorShare, false).awaitTransactionSuccessAsync(); const expectedError = new StakingRevertErrors.OperatorShareError( StakingRevertErrors.OperatorShareErrorCodes.OperatorShareTooLarge, nextPoolId, @@ -115,14 +117,12 @@ blockchainTests.resets('MixinStakingPool unit tests', env => { return expect(tx).to.revertWith(expectedError); }); it('operator can create and own multiple pools', async () => { - const { logs: logs1 } = await testContract.createStakingPool.awaitTransactionSuccessAsync( - randomOperatorShare(), - false, - ); - const { logs: logs2 } = await testContract.createStakingPool.awaitTransactionSuccessAsync( - randomOperatorShare(), - false, - ); + const { logs: logs1 } = await testContract + .createStakingPool(randomOperatorShare(), false) + .awaitTransactionSuccessAsync(); + const { logs: logs2 } = await testContract + .createStakingPool(randomOperatorShare(), false) + .awaitTransactionSuccessAsync(); const createEvents = filterLogsToArguments( [...logs1, ...logs2], TestMixinStakingPoolEvents.StakingPoolCreated, @@ -130,27 +130,27 @@ blockchainTests.resets('MixinStakingPool unit tests', env => { expect(createEvents).to.be.length(2); const poolIds = createEvents.map(e => e.poolId); expect(poolIds[0]).to.not.eq(poolIds[1]); - const pools = await Promise.all(poolIds.map(async poolId => testContract.getStakingPool.callAsync(poolId))); + const pools = await Promise.all( + poolIds.map(async poolId => testContract.getStakingPool(poolId).callAsync()), + ); expect(pools[0].operator).to.eq(pools[1].operator); }); it('operator can only be maker of one pool', async () => { - await testContract.createStakingPool.awaitTransactionSuccessAsync(randomOperatorShare(), true); - const { logs } = await testContract.createStakingPool.awaitTransactionSuccessAsync( - randomOperatorShare(), - true, - ); + await testContract.createStakingPool(randomOperatorShare(), true).awaitTransactionSuccessAsync(); + const { logs } = await testContract + .createStakingPool(randomOperatorShare(), true) + .awaitTransactionSuccessAsync(); const createEvents = filterLogsToArguments( logs, TestMixinStakingPoolEvents.StakingPoolCreated, ); - const makerPool = await testContract.poolIdByMaker.callAsync(operator); + const makerPool = await testContract.poolIdByMaker(operator).callAsync(); expect(makerPool).to.eq(createEvents[0].poolId); }); it('computes correct next pool ID', async () => { - const { logs } = await testContract.createStakingPool.awaitTransactionSuccessAsync( - randomOperatorShare(), - false, - ); + const { logs } = await testContract + .createStakingPool(randomOperatorShare(), false) + .awaitTransactionSuccessAsync(); const createEvents = filterLogsToArguments( logs, TestMixinStakingPoolEvents.StakingPoolCreated, @@ -159,32 +159,32 @@ blockchainTests.resets('MixinStakingPool unit tests', env => { expect(poolId).to.eq(nextPoolId); }); it('increments last pool ID counter', async () => { - await testContract.createStakingPool.awaitTransactionSuccessAsync(randomOperatorShare(), false); - const lastPoolIdAfter = await testContract.lastPoolId.callAsync(); + await testContract.createStakingPool(randomOperatorShare(), false).awaitTransactionSuccessAsync(); + const lastPoolIdAfter = await testContract.lastPoolId().callAsync(); expect(lastPoolIdAfter).to.eq(nextPoolId); }); it('records pool details', async () => { const operatorShare = randomOperatorShare(); - await testContract.createStakingPool.awaitTransactionSuccessAsync(operatorShare, false, { from: operator }); - const pool = await testContract.getStakingPool.callAsync(nextPoolId); + await testContract.createStakingPool(operatorShare, false).awaitTransactionSuccessAsync({ from: operator }); + const pool = await testContract.getStakingPool(nextPoolId).callAsync(); expect(pool.operator).to.eq(operator); expect(pool.operatorShare).to.bignumber.eq(operatorShare); }); it('returns the next pool ID', async () => { - const poolId = await testContract.createStakingPool.callAsync(randomOperatorShare(), false, { + const poolId = await testContract.createStakingPool(randomOperatorShare(), false).callAsync({ from: operator, }); expect(poolId).to.eq(nextPoolId); }); it('can add operator as a maker', async () => { const operatorShare = randomOperatorShare(); - await testContract.createStakingPool.awaitTransactionSuccessAsync(operatorShare, true, { from: operator }); - const makerPoolId = await testContract.poolIdByMaker.callAsync(operator); + await testContract.createStakingPool(operatorShare, true).awaitTransactionSuccessAsync({ from: operator }); + const makerPoolId = await testContract.poolIdByMaker(operator).callAsync(); expect(makerPoolId).to.eq(nextPoolId); }); it('emits a `StakingPoolCreated` event', async () => { const operatorShare = randomOperatorShare(); - const { logs } = await testContract.createStakingPool.awaitTransactionSuccessAsync(operatorShare, false, { + const { logs } = await testContract.createStakingPool(operatorShare, false).awaitTransactionSuccessAsync({ from: operator, }); verifyEventsFromLogs( @@ -201,7 +201,7 @@ blockchainTests.resets('MixinStakingPool unit tests', env => { }); it('emits a `MakerStakingPoolSet` event when also joining as a maker', async () => { const operatorShare = randomOperatorShare(); - const { logs } = await testContract.createStakingPool.awaitTransactionSuccessAsync(operatorShare, true, { + const { logs } = await testContract.createStakingPool(operatorShare, true).awaitTransactionSuccessAsync({ from: operator, }); verifyEventsFromLogs( @@ -220,32 +220,26 @@ blockchainTests.resets('MixinStakingPool unit tests', env => { describe('decreaseStakingPoolOperatorShare()', () => { it('fails if not called by operator', async () => { const { poolId, operatorShare } = await createPoolAsync(); - const tx = testContract.decreaseStakingPoolOperatorShare.awaitTransactionSuccessAsync( - poolId, - operatorShare - 1, - { from: notOperatorOrMaker }, - ); + const tx = testContract + .decreaseStakingPoolOperatorShare(poolId, operatorShare - 1) + .awaitTransactionSuccessAsync({ from: notOperatorOrMaker }); const expectedError = new StakingRevertErrors.OnlyCallableByPoolOperatorError(notOperatorOrMaker, poolId); return expect(tx).to.revertWith(expectedError); }); it('fails if called by maker', async () => { const { poolId, operatorShare } = await createPoolAsync(); await addMakerToPoolAsync(poolId, maker); - const tx = testContract.decreaseStakingPoolOperatorShare.awaitTransactionSuccessAsync( - poolId, - operatorShare - 1, - { from: maker }, - ); + const tx = testContract + .decreaseStakingPoolOperatorShare(poolId, operatorShare - 1) + .awaitTransactionSuccessAsync({ from: maker }); const expectedError = new StakingRevertErrors.OnlyCallableByPoolOperatorError(maker, poolId); return expect(tx).to.revertWith(expectedError); }); it('fails if operator share is equal to current', async () => { const { poolId, operatorShare } = await createPoolAsync(); - const tx = testContract.decreaseStakingPoolOperatorShare.awaitTransactionSuccessAsync( - poolId, - operatorShare, - { from: operator }, - ); + const tx = testContract + .decreaseStakingPoolOperatorShare(poolId, operatorShare) + .awaitTransactionSuccessAsync({ from: operator }); const expectedError = new StakingRevertErrors.OperatorShareError( StakingRevertErrors.OperatorShareErrorCodes.CanOnlyDecreaseOperatorShare, poolId, @@ -255,11 +249,9 @@ blockchainTests.resets('MixinStakingPool unit tests', env => { }); it('fails if operator share is greater than current', async () => { const { poolId, operatorShare } = await createPoolAsync(); - const tx = testContract.decreaseStakingPoolOperatorShare.awaitTransactionSuccessAsync( - poolId, - operatorShare + 1, - { from: operator }, - ); + const tx = testContract + .decreaseStakingPoolOperatorShare(poolId, operatorShare + 1) + .awaitTransactionSuccessAsync({ from: operator }); const expectedError = new StakingRevertErrors.OperatorShareError( StakingRevertErrors.OperatorShareErrorCodes.CanOnlyDecreaseOperatorShare, poolId, @@ -269,11 +261,9 @@ blockchainTests.resets('MixinStakingPool unit tests', env => { }); it('fails if operator share is greater than PPM_100_PERCENT', async () => { const { poolId } = await createPoolAsync(); - const tx = testContract.decreaseStakingPoolOperatorShare.awaitTransactionSuccessAsync( - poolId, - constants.PPM_100_PERCENT + 1, - { from: operator }, - ); + const tx = testContract + .decreaseStakingPoolOperatorShare(poolId, constants.PPM_100_PERCENT + 1) + .awaitTransactionSuccessAsync({ from: operator }); const expectedError = new StakingRevertErrors.OperatorShareError( StakingRevertErrors.OperatorShareErrorCodes.OperatorShareTooLarge, poolId, @@ -283,31 +273,25 @@ blockchainTests.resets('MixinStakingPool unit tests', env => { }); it('records new operator share', async () => { const { poolId, operatorShare } = await createPoolAsync(); - await testContract.decreaseStakingPoolOperatorShare.awaitTransactionSuccessAsync( - poolId, - operatorShare - 1, - { from: operator }, - ); - const pool = await testContract.getStakingPool.callAsync(poolId); + await testContract + .decreaseStakingPoolOperatorShare(poolId, operatorShare - 1) + .awaitTransactionSuccessAsync({ from: operator }); + const pool = await testContract.getStakingPool(poolId).callAsync(); expect(pool.operatorShare).to.bignumber.eq(operatorShare - 1); }); it('does not modify operator', async () => { const { poolId, operatorShare } = await createPoolAsync(); - await testContract.decreaseStakingPoolOperatorShare.awaitTransactionSuccessAsync( - poolId, - operatorShare - 1, - { from: operator }, - ); - const pool = await testContract.getStakingPool.callAsync(poolId); + await testContract + .decreaseStakingPoolOperatorShare(poolId, operatorShare - 1) + .awaitTransactionSuccessAsync({ from: operator }); + const pool = await testContract.getStakingPool(poolId).callAsync(); expect(pool.operator).to.eq(operator); }); it('emits an `OperatorShareDecreased` event', async () => { const { poolId, operatorShare } = await createPoolAsync(); - const { logs } = await testContract.decreaseStakingPoolOperatorShare.awaitTransactionSuccessAsync( - poolId, - operatorShare - 1, - { from: operator }, - ); + const { logs } = await testContract + .decreaseStakingPoolOperatorShare(poolId, operatorShare - 1) + .awaitTransactionSuccessAsync({ from: operator }); verifyEventsFromLogs( logs, [ @@ -325,36 +309,36 @@ blockchainTests.resets('MixinStakingPool unit tests', env => { describe('joinStakingPoolAsMaker()', () => { it('records sender as maker for the pool', async () => { const { poolId } = await createPoolAsync(); - await testContract.joinStakingPoolAsMaker.awaitTransactionSuccessAsync(poolId, { from: maker }); - const makerPoolId = await testContract.poolIdByMaker.callAsync(maker); + await testContract.joinStakingPoolAsMaker(poolId).awaitTransactionSuccessAsync({ from: maker }); + const makerPoolId = await testContract.poolIdByMaker(maker).callAsync(); expect(makerPoolId).to.eq(poolId); }); it('operator can join as maker for the pool', async () => { const { poolId } = await createPoolAsync(); - await testContract.joinStakingPoolAsMaker.awaitTransactionSuccessAsync(poolId, { from: operator }); - const makerPoolId = await testContract.poolIdByMaker.callAsync(operator); + await testContract.joinStakingPoolAsMaker(poolId).awaitTransactionSuccessAsync({ from: operator }); + const makerPoolId = await testContract.poolIdByMaker(operator).callAsync(); expect(makerPoolId).to.eq(poolId); }); it('can join the same pool as a maker twice', async () => { const { poolId } = await createPoolAsync(); - await testContract.joinStakingPoolAsMaker.awaitTransactionSuccessAsync(poolId, { from: maker }); - await testContract.joinStakingPoolAsMaker.awaitTransactionSuccessAsync(poolId, { from: maker }); - const makerPoolId = await testContract.poolIdByMaker.callAsync(maker); + await testContract.joinStakingPoolAsMaker(poolId).awaitTransactionSuccessAsync({ from: maker }); + await testContract.joinStakingPoolAsMaker(poolId).awaitTransactionSuccessAsync({ from: maker }); + const makerPoolId = await testContract.poolIdByMaker(maker).callAsync(); expect(makerPoolId).to.eq(poolId); }); it('can only be a maker in one pool at a time', async () => { const { poolId: poolId1 } = await createPoolAsync(); const { poolId: poolId2 } = await createPoolAsync(); - await testContract.joinStakingPoolAsMaker.awaitTransactionSuccessAsync(poolId1, { from: maker }); - let makerPoolId = await testContract.poolIdByMaker.callAsync(maker); + await testContract.joinStakingPoolAsMaker(poolId1).awaitTransactionSuccessAsync({ from: maker }); + let makerPoolId = await testContract.poolIdByMaker(maker).callAsync(); expect(makerPoolId).to.eq(poolId1); - await testContract.joinStakingPoolAsMaker.awaitTransactionSuccessAsync(poolId2, { from: maker }); - makerPoolId = await testContract.poolIdByMaker.callAsync(maker); + await testContract.joinStakingPoolAsMaker(poolId2).awaitTransactionSuccessAsync({ from: maker }); + makerPoolId = await testContract.poolIdByMaker(maker).callAsync(); expect(makerPoolId).to.eq(poolId2); }); it('emits a `MakerStakingPoolSet` event', async () => { const { poolId } = await createPoolAsync(); - const { logs } = await testContract.joinStakingPoolAsMaker.awaitTransactionSuccessAsync(poolId, { + const { logs } = await testContract.joinStakingPoolAsMaker(poolId).awaitTransactionSuccessAsync({ from: maker, }); verifyEventsFromLogs( diff --git a/contracts/staking/test/unit_tests/staking_proxy_test.ts b/contracts/staking/test/unit_tests/staking_proxy_test.ts index 825ed7f2bb..d5333286de 100644 --- a/contracts/staking/test/unit_tests/staking_proxy_test.ts +++ b/contracts/staking/test/unit_tests/staking_proxy_test.ts @@ -59,23 +59,23 @@ blockchainTests.resets('StakingProxy unit tests', env => { ); // Add authorized address to Staking Proxy - await testProxyContract.addAuthorizedAddress.sendTransactionAsync(authorizedAddress, { from: owner }); + await testProxyContract.addAuthorizedAddress(authorizedAddress).sendTransactionAsync({ from: owner }); }); describe('Fallback function', () => { it('should pass back the return value of the destination contract', async () => { - const returnValue = await testContractViaProxy.echo.callAsync(testString); + const returnValue = await testContractViaProxy.echo(testString).callAsync(); expect(returnValue).to.equal(testString); }); it('should revert with correct value when destination reverts', async () => { - return expect(testContractViaProxy.die.callAsync()).to.revertWith(testRevertString); + return expect(testContractViaProxy.die().callAsync()).to.revertWith(testRevertString); }); it('should revert if no staking contract is attached', async () => { - await testProxyContract.detachStakingContract.awaitTransactionSuccessAsync({ from: authorizedAddress }); + await testProxyContract.detachStakingContract().awaitTransactionSuccessAsync({ from: authorizedAddress }); const expectedError = new StakingRevertErrors.ProxyDestinationCannotBeNilError(); - const tx = testContractViaProxy.echo.callAsync(testString); + const tx = testContractViaProxy.echo(testString).callAsync(); return expect(tx).to.revertWith(expectedError); }); }); @@ -83,11 +83,10 @@ blockchainTests.resets('StakingProxy unit tests', env => { describe('attachStakingContract', () => { it('should successfully attaching a new staking contract', async () => { // Cache existing staking contract and attach a new one - const initStakingContractAddress = await testProxyContract.stakingContract.callAsync(); - const txReceipt = await testProxyContract.attachStakingContract.awaitTransactionSuccessAsync( - testContract2.address, - { from: authorizedAddress }, - ); + const initStakingContractAddress = await testProxyContract.stakingContract().callAsync(); + const txReceipt = await testProxyContract + .attachStakingContract(testContract2.address) + .awaitTransactionSuccessAsync({ from: authorizedAddress }); // Validate `ContractAttachedToProxy` event verifyEventsFromLogs( @@ -112,14 +111,14 @@ blockchainTests.resets('StakingProxy unit tests', env => { ); // Validate new staking contract address - const finalStakingContractAddress = await testProxyContract.stakingContract.callAsync(); + const finalStakingContractAddress = await testProxyContract.stakingContract().callAsync(); expect(finalStakingContractAddress).to.be.equal(testContract2.address); expect(finalStakingContractAddress).to.not.equal(initStakingContractAddress); }); it('should revert if call to `init` on new staking contract fails', async () => { - await testProxyContract.setInitFailFlag.awaitTransactionSuccessAsync(); - const tx = testProxyContract.attachStakingContract.awaitTransactionSuccessAsync(testContract2.address, { + await testProxyContract.setInitFailFlag().awaitTransactionSuccessAsync(); + const tx = testProxyContract.attachStakingContract(testContract2.address).awaitTransactionSuccessAsync({ from: authorizedAddress, }); const expectedError = 'INIT_FAIL_FLAG_SET'; @@ -127,7 +126,7 @@ blockchainTests.resets('StakingProxy unit tests', env => { }); it('should revert if called by unauthorized address', async () => { - const tx = testProxyContract.attachStakingContract.awaitTransactionSuccessAsync(testContract2.address, { + const tx = testProxyContract.attachStakingContract(testContract2.address).awaitTransactionSuccessAsync({ from: notAuthorizedAddresses[0], }); const expectedError = new AuthorizableRevertErrors.SenderNotAuthorizedError(notAuthorizedAddresses[0]); @@ -138,8 +137,8 @@ blockchainTests.resets('StakingProxy unit tests', env => { describe('detachStakingContract', () => { it('should detach staking contract', async () => { // Cache existing staking contract and attach a new one - const initStakingContractAddress = await testProxyContract.stakingContract.callAsync(); - const txReceipt = await testProxyContract.detachStakingContract.awaitTransactionSuccessAsync({ + const initStakingContractAddress = await testProxyContract.stakingContract().callAsync(); + const txReceipt = await testProxyContract.detachStakingContract().awaitTransactionSuccessAsync({ from: authorizedAddress, }); @@ -147,13 +146,13 @@ blockchainTests.resets('StakingProxy unit tests', env => { verifyEventsFromLogs(txReceipt.logs, [{}], StakingProxyEvents.StakingContractDetachedFromProxy); // Validate staking contract address was unset - const finalStakingContractAddress = await testProxyContract.stakingContract.callAsync(); + const finalStakingContractAddress = await testProxyContract.stakingContract().callAsync(); expect(finalStakingContractAddress).to.be.equal(stakingConstants.NIL_ADDRESS); expect(finalStakingContractAddress).to.not.equal(initStakingContractAddress); }); it('should revert if called by unauthorized address', async () => { - const tx = testProxyContract.detachStakingContract.awaitTransactionSuccessAsync({ + const tx = testProxyContract.detachStakingContract().awaitTransactionSuccessAsync({ from: notAuthorizedAddresses[0], }); const expectedError = new AuthorizableRevertErrors.SenderNotAuthorizedError(notAuthorizedAddresses[0]); @@ -163,27 +162,27 @@ blockchainTests.resets('StakingProxy unit tests', env => { describe('batchExecute', () => { it('should execute no-op if no calls to make', async () => { - await testProxyContract.batchExecute.awaitTransactionSuccessAsync([]); + await testProxyContract.batchExecute([]).awaitTransactionSuccessAsync(); }); it('should call one function and return the output', async () => { - const calls = [testContract.echo.getABIEncodedTransactionData(testString)]; - const rawResults = await testProxyContract.batchExecute.callAsync(calls); + const calls = [testContract.echo(testString).getABIEncodedTransactionData()]; + const rawResults = await testProxyContract.batchExecute(calls).callAsync(); expect(rawResults.length).to.equal(1); - const returnValues = [testContract.echo.getABIDecodedReturnData(rawResults[0])]; + const returnValues = [testContract.getABIDecodedReturnData('echo', rawResults[0])]; expect(returnValues[0]).to.equal(testString); }); it('should call multiple functions and return their outputs', async () => { const calls = [ - testContract.echo.getABIEncodedTransactionData(testString), - testContract.doMath.getABIEncodedTransactionData(new BigNumber(2), new BigNumber(1)), + testContract.echo(testString).getABIEncodedTransactionData(), + testContract.doMath(new BigNumber(2), new BigNumber(1)).getABIEncodedTransactionData(), ]; - const rawResults = await testProxyContract.batchExecute.callAsync(calls); + const rawResults = await testProxyContract.batchExecute(calls).callAsync(); expect(rawResults.length).to.equal(2); const returnValues = [ - testContract.echo.getABIDecodedReturnData(rawResults[0]), - testContract.doMath.getABIDecodedReturnData(rawResults[1]), + testContract.getABIDecodedReturnData('echo', rawResults[0]), + testContract.getABIDecodedReturnData('doMath', rawResults[1]), ]; expect(returnValues[0]).to.equal(testString); expect(returnValues[1][0]).to.bignumber.equal(new BigNumber(3)); @@ -192,20 +191,20 @@ blockchainTests.resets('StakingProxy unit tests', env => { it('should revert if a call reverts', async () => { const calls = [ - testContract.echo.getABIEncodedTransactionData(testString), - testContract.die.getABIEncodedTransactionData(), - testContract.doMath.getABIEncodedTransactionData(new BigNumber(2), new BigNumber(1)), + testContract.echo(testString).getABIEncodedTransactionData(), + testContract.die().getABIEncodedTransactionData(), + testContract.doMath(new BigNumber(2), new BigNumber(1)).getABIEncodedTransactionData(), ]; - const tx = testProxyContract.batchExecute.callAsync(calls); + const tx = testProxyContract.batchExecute(calls).callAsync(); const expectedError = testRevertString; return expect(tx).to.revertWith(expectedError); }); it('should revert if no staking contract is attached', async () => { - await testProxyContract.detachStakingContract.awaitTransactionSuccessAsync({ from: authorizedAddress }); - const calls = [testContract.echo.getABIEncodedTransactionData(testString)]; + await testProxyContract.detachStakingContract().awaitTransactionSuccessAsync({ from: authorizedAddress }); + const calls = [testContract.echo(testString).getABIEncodedTransactionData()]; - const tx = testProxyContract.batchExecute.callAsync(calls); + const tx = testProxyContract.batchExecute(calls).callAsync(); const expectedError = new StakingRevertErrors.ProxyDestinationCannotBeNilError(); return expect(tx).to.revertWith(expectedError); }); @@ -220,16 +219,16 @@ blockchainTests.resets('StakingProxy unit tests', env => { minimumPoolStake: new BigNumber(100), }; it('should not revert if all storage params are valid', async () => { - await testProxyContract.setTestStorageParams.awaitTransactionSuccessAsync(validStorageParams); - await testProxyContract.assertValidStorageParams.callAsync(); + await testProxyContract.setTestStorageParams(validStorageParams).awaitTransactionSuccessAsync(); + await testProxyContract.assertValidStorageParams().callAsync(); }); it('should revert if `epochDurationInSeconds` is less than 5 days', async () => { const invalidStorageParams = { ...validStorageParams, epochDurationInSeconds: new BigNumber(0), }; - await testProxyContract.setTestStorageParams.awaitTransactionSuccessAsync(invalidStorageParams); - const tx = testProxyContract.assertValidStorageParams.callAsync(); + await testProxyContract.setTestStorageParams(invalidStorageParams).awaitTransactionSuccessAsync(); + const tx = testProxyContract.assertValidStorageParams().callAsync(); const expectedError = new StakingRevertErrors.InvalidParamValueError( StakingRevertErrors.InvalidParamValueErrorCodes.InvalidEpochDuration, ); @@ -240,8 +239,8 @@ blockchainTests.resets('StakingProxy unit tests', env => { ...validStorageParams, epochDurationInSeconds: new BigNumber(stakingConstants.ONE_DAY_IN_SECONDS * 31), }; - await testProxyContract.setTestStorageParams.awaitTransactionSuccessAsync(invalidStorageParams); - const tx = testProxyContract.assertValidStorageParams.callAsync(); + await testProxyContract.setTestStorageParams(invalidStorageParams).awaitTransactionSuccessAsync(); + const tx = testProxyContract.assertValidStorageParams().callAsync(); const expectedError = new StakingRevertErrors.InvalidParamValueError( StakingRevertErrors.InvalidParamValueErrorCodes.InvalidEpochDuration, ); @@ -253,8 +252,8 @@ blockchainTests.resets('StakingProxy unit tests', env => { cobbDouglasAlphaNumerator: new BigNumber(2), cobbDouglasAlphaDenominator: new BigNumber(1), }; - await testProxyContract.setTestStorageParams.awaitTransactionSuccessAsync(invalidStorageParams); - const tx = testProxyContract.assertValidStorageParams.callAsync(); + await testProxyContract.setTestStorageParams(invalidStorageParams).awaitTransactionSuccessAsync(); + const tx = testProxyContract.assertValidStorageParams().callAsync(); const expectedError = new StakingRevertErrors.InvalidParamValueError( StakingRevertErrors.InvalidParamValueErrorCodes.InvalidCobbDouglasAlpha, ); @@ -265,8 +264,8 @@ blockchainTests.resets('StakingProxy unit tests', env => { ...validStorageParams, cobbDouglasAlphaDenominator: new BigNumber(0), }; - await testProxyContract.setTestStorageParams.awaitTransactionSuccessAsync(invalidStorageParams); - const tx = testProxyContract.assertValidStorageParams.callAsync(); + await testProxyContract.setTestStorageParams(invalidStorageParams).awaitTransactionSuccessAsync(); + const tx = testProxyContract.assertValidStorageParams().callAsync(); const expectedError = new StakingRevertErrors.InvalidParamValueError( StakingRevertErrors.InvalidParamValueErrorCodes.InvalidCobbDouglasAlpha, ); @@ -277,8 +276,8 @@ blockchainTests.resets('StakingProxy unit tests', env => { ...validStorageParams, rewardDelegatedStakeWeight: new BigNumber(constants.PPM_DENOMINATOR + 1), }; - await testProxyContract.setTestStorageParams.awaitTransactionSuccessAsync(invalidStorageParams); - const tx = testProxyContract.assertValidStorageParams.callAsync(); + await testProxyContract.setTestStorageParams(invalidStorageParams).awaitTransactionSuccessAsync(); + const tx = testProxyContract.assertValidStorageParams().callAsync(); const expectedError = new StakingRevertErrors.InvalidParamValueError( StakingRevertErrors.InvalidParamValueErrorCodes.InvalidRewardDelegatedStakeWeight, ); @@ -289,8 +288,8 @@ blockchainTests.resets('StakingProxy unit tests', env => { ...validStorageParams, minimumPoolStake: new BigNumber(1), }; - await testProxyContract.setTestStorageParams.awaitTransactionSuccessAsync(invalidStorageParams); - const tx = testProxyContract.assertValidStorageParams.callAsync(); + await testProxyContract.setTestStorageParams(invalidStorageParams).awaitTransactionSuccessAsync(); + const tx = testProxyContract.assertValidStorageParams().callAsync(); const expectedError = new StakingRevertErrors.InvalidParamValueError( StakingRevertErrors.InvalidParamValueErrorCodes.InvalidMinimumPoolStake, ); diff --git a/contracts/staking/test/unit_tests/zrx_vault_test.ts b/contracts/staking/test/unit_tests/zrx_vault_test.ts index 6c2209ce44..3b4a54aba6 100644 --- a/contracts/staking/test/unit_tests/zrx_vault_test.ts +++ b/contracts/staking/test/unit_tests/zrx_vault_test.ts @@ -48,7 +48,7 @@ blockchainTests.resets('ZrxVault unit tests', env => { zrxProxyAddress = erc20ProxyContract.address; // deploy zrx token const [zrxTokenContract] = await erc20Wrapper.deployDummyTokensAsync(1, constants.DUMMY_TOKEN_DECIMALS); - zrxAssetData = await devUtils.encodeERC20AssetData.callAsync(zrxTokenContract.address); + zrxAssetData = await devUtils.encodeERC20AssetData(zrxTokenContract.address).callAsync(); await erc20Wrapper.setBalancesAndAllowancesAsync(); @@ -61,10 +61,10 @@ blockchainTests.resets('ZrxVault unit tests', env => { zrxTokenContract.address, ); - await zrxVault.addAuthorizedAddress.awaitTransactionSuccessAsync(owner); + await zrxVault.addAuthorizedAddress(owner).awaitTransactionSuccessAsync(); // configure erc20 proxy to accept calls from zrx vault - await erc20ProxyContract.addAuthorizedAddress.awaitTransactionSuccessAsync(zrxVault.address); + await erc20ProxyContract.addAuthorizedAddress(zrxVault.address).awaitTransactionSuccessAsync(); }); enum ZrxTransfer { @@ -88,7 +88,7 @@ blockchainTests.resets('ZrxVault unit tests', env => { expect(eventArgs[0].staker).to.equal(staker); expect(eventArgs[0].amount).to.bignumber.equal(amount); - const newVaultBalance = await zrxVault.balanceOf.callAsync(staker); + const newVaultBalance = await zrxVault.balanceOf(staker).callAsync(); const newTokenBalance = await erc20Wrapper.getBalanceAsync(staker, zrxAssetData); const [expectedVaultBalance, expectedTokenBalance] = transferType === ZrxTransfer.Deposit @@ -110,13 +110,13 @@ blockchainTests.resets('ZrxVault unit tests', env => { ); expect(eventArgs.length).to.equal(1); expect(eventArgs[0].stakingProxyAddress).to.equal(newProxy); - const actualAddress = await zrxVault.stakingProxyAddress.callAsync(); + const actualAddress = await zrxVault.stakingProxyAddress().callAsync(); expect(actualAddress).to.equal(newProxy); } it('Owner can set the ZRX proxy', async () => { const newProxy = nonOwnerAddresses[0]; - const receipt = await zrxVault.setZrxProxy.awaitTransactionSuccessAsync(newProxy, { + const receipt = await zrxVault.setZrxProxy(newProxy).awaitTransactionSuccessAsync({ from: owner, }); const eventArgs = filterLogsToArguments(receipt.logs, 'ZrxProxySet'); @@ -125,8 +125,8 @@ blockchainTests.resets('ZrxVault unit tests', env => { }); it('Authorized address can set the ZRX proxy', async () => { const [authorized, newProxy] = nonOwnerAddresses; - await zrxVault.addAuthorizedAddress.awaitTransactionSuccessAsync(authorized, { from: owner }); - const receipt = await zrxVault.setZrxProxy.awaitTransactionSuccessAsync(newProxy, { + await zrxVault.addAuthorizedAddress(authorized).awaitTransactionSuccessAsync({ from: owner }); + const receipt = await zrxVault.setZrxProxy(newProxy).awaitTransactionSuccessAsync({ from: authorized, }); const eventArgs = filterLogsToArguments(receipt.logs, 'ZrxProxySet'); @@ -135,7 +135,7 @@ blockchainTests.resets('ZrxVault unit tests', env => { }); it('Non-authorized address cannot set the ZRX proxy', async () => { const [notAuthorized, newProxy] = nonOwnerAddresses; - const tx = zrxVault.setZrxProxy.awaitTransactionSuccessAsync(newProxy, { + const tx = zrxVault.setZrxProxy(newProxy).awaitTransactionSuccessAsync({ from: notAuthorized, }); const expectedError = new AuthorizableRevertErrors.SenderNotAuthorizedError(notAuthorized); @@ -143,27 +143,27 @@ blockchainTests.resets('ZrxVault unit tests', env => { }); it('Owner can set the staking proxy', async () => { const newProxy = nonOwnerAddresses[0]; - const receipt = await zrxVault.setStakingProxy.awaitTransactionSuccessAsync(newProxy, { + const receipt = await zrxVault.setStakingProxy(newProxy).awaitTransactionSuccessAsync({ from: owner, }); await verifyStakingProxySetAsync(receipt, newProxy); }); it('Authorized address can set the staking proxy', async () => { const [authorized, newProxy] = nonOwnerAddresses; - await zrxVault.addAuthorizedAddress.awaitTransactionSuccessAsync(authorized, { from: owner }); - const receipt = await zrxVault.setStakingProxy.awaitTransactionSuccessAsync(newProxy, { + await zrxVault.addAuthorizedAddress(authorized).awaitTransactionSuccessAsync({ from: owner }); + const receipt = await zrxVault.setStakingProxy(newProxy).awaitTransactionSuccessAsync({ from: authorized, }); await verifyStakingProxySetAsync(receipt, newProxy); }); it('Non-authorized address cannot set the staking proxy', async () => { const [notAuthorized, newProxy] = nonOwnerAddresses; - const tx = zrxVault.setStakingProxy.awaitTransactionSuccessAsync(newProxy, { + const tx = zrxVault.setStakingProxy(newProxy).awaitTransactionSuccessAsync({ from: notAuthorized, }); const expectedError = new AuthorizableRevertErrors.SenderNotAuthorizedError(notAuthorized); expect(tx).to.revertWith(expectedError); - const actualAddress = await zrxVault.stakingProxyAddress.callAsync(); + const actualAddress = await zrxVault.stakingProxyAddress().callAsync(); expect(actualAddress).to.equal(stakingConstants.NIL_ADDRESS); }); }); @@ -175,26 +175,24 @@ blockchainTests.resets('ZrxVault unit tests', env => { before(async () => { [staker, stakingProxy] = nonOwnerAddresses; - await zrxVault.setStakingProxy.awaitTransactionSuccessAsync(stakingProxy, { from: owner }); - await zrxVault.depositFrom.awaitTransactionSuccessAsync(staker, new BigNumber(10), { + await zrxVault.setStakingProxy(stakingProxy).awaitTransactionSuccessAsync({ from: owner }); + await zrxVault.depositFrom(staker, new BigNumber(10)).awaitTransactionSuccessAsync({ from: stakingProxy, }); }); beforeEach(async () => { - initialVaultBalance = await zrxVault.balanceOf.callAsync(staker); + initialVaultBalance = await zrxVault.balanceOf(staker).callAsync(); initialTokenBalance = await erc20Wrapper.getBalanceAsync(staker, zrxAssetData); }); describe('Deposit', () => { it('Staking proxy can deposit zero amount on behalf of staker', async () => { - const receipt = await zrxVault.depositFrom.awaitTransactionSuccessAsync( - staker, - constants.ZERO_AMOUNT, - { + const receipt = await zrxVault + .depositFrom(staker, constants.ZERO_AMOUNT) + .awaitTransactionSuccessAsync({ from: stakingProxy, - }, - ); + }); await verifyTransferPostconditionsAsync( ZrxTransfer.Deposit, staker, @@ -205,7 +203,7 @@ blockchainTests.resets('ZrxVault unit tests', env => { ); }); it('Staking proxy can deposit nonzero amount on behalf of staker', async () => { - const receipt = await zrxVault.depositFrom.awaitTransactionSuccessAsync(staker, new BigNumber(1), { + const receipt = await zrxVault.depositFrom(staker, new BigNumber(1)).awaitTransactionSuccessAsync({ from: stakingProxy, }); await verifyTransferPostconditionsAsync( @@ -218,13 +216,11 @@ blockchainTests.resets('ZrxVault unit tests', env => { ); }); it('Staking proxy can deposit entire ZRX balance on behalf of staker', async () => { - const receipt = await zrxVault.depositFrom.awaitTransactionSuccessAsync( - staker, - initialTokenBalance, - { + const receipt = await zrxVault + .depositFrom(staker, initialTokenBalance) + .awaitTransactionSuccessAsync({ from: stakingProxy, - }, - ); + }); await verifyTransferPostconditionsAsync( ZrxTransfer.Deposit, staker, @@ -235,7 +231,7 @@ blockchainTests.resets('ZrxVault unit tests', env => { ); }); it("Reverts if attempting to deposit more than staker's ZRX balance", async () => { - const tx = zrxVault.depositFrom.sendTransactionAsync(staker, initialTokenBalance.plus(1), { + const tx = zrxVault.depositFrom(staker, initialTokenBalance.plus(1)).sendTransactionAsync({ from: stakingProxy, }); expectTransactionFailedAsync(tx, RevertReason.TransferFailed); @@ -243,13 +239,11 @@ blockchainTests.resets('ZrxVault unit tests', env => { }); describe('Withdrawal', () => { it('Staking proxy can withdraw zero amount on behalf of staker', async () => { - const receipt = await zrxVault.withdrawFrom.awaitTransactionSuccessAsync( - staker, - constants.ZERO_AMOUNT, - { + const receipt = await zrxVault + .withdrawFrom(staker, constants.ZERO_AMOUNT) + .awaitTransactionSuccessAsync({ from: stakingProxy, - }, - ); + }); await verifyTransferPostconditionsAsync( ZrxTransfer.Withdrawal, staker, @@ -260,7 +254,7 @@ blockchainTests.resets('ZrxVault unit tests', env => { ); }); it('Staking proxy can withdraw nonzero amount on behalf of staker', async () => { - const receipt = await zrxVault.withdrawFrom.awaitTransactionSuccessAsync(staker, new BigNumber(1), { + const receipt = await zrxVault.withdrawFrom(staker, new BigNumber(1)).awaitTransactionSuccessAsync({ from: stakingProxy, }); await verifyTransferPostconditionsAsync( @@ -273,13 +267,11 @@ blockchainTests.resets('ZrxVault unit tests', env => { ); }); it('Staking proxy can withdraw entire vault balance on behalf of staker', async () => { - const receipt = await zrxVault.withdrawFrom.awaitTransactionSuccessAsync( - staker, - initialVaultBalance, - { + const receipt = await zrxVault + .withdrawFrom(staker, initialVaultBalance) + .awaitTransactionSuccessAsync({ from: stakingProxy, - }, - ); + }); await verifyTransferPostconditionsAsync( ZrxTransfer.Withdrawal, staker, @@ -290,7 +282,7 @@ blockchainTests.resets('ZrxVault unit tests', env => { ); }); it("Reverts if attempting to withdraw more than staker's vault balance", async () => { - const tx = zrxVault.withdrawFrom.awaitTransactionSuccessAsync(staker, initialVaultBalance.plus(1), { + const tx = zrxVault.withdrawFrom(staker, initialVaultBalance.plus(1)).awaitTransactionSuccessAsync({ from: stakingProxy, }); const expectedError = new SafeMathRevertErrors.Uint256BinOpError( @@ -316,38 +308,38 @@ blockchainTests.resets('ZrxVault unit tests', env => { ); expect(eventArgs.length).to.equal(1); expect(eventArgs[0].sender).to.equal(sender); - expect(await zrxVault.isInCatastrophicFailure.callAsync()).to.be.true(); + expect(await zrxVault.isInCatastrophicFailure().callAsync()).to.be.true(); } it('Owner can turn on Catastrophic Failure Mode', async () => { - const receipt = await zrxVault.enterCatastrophicFailure.awaitTransactionSuccessAsync({ from: owner }); + const receipt = await zrxVault.enterCatastrophicFailure().awaitTransactionSuccessAsync({ from: owner }); await verifyCatastrophicFailureModeAsync(owner, receipt); }); it('Authorized address can turn on Catastrophic Failure Mode', async () => { const authorized = nonOwnerAddresses[0]; - await zrxVault.addAuthorizedAddress.awaitTransactionSuccessAsync(authorized, { from: owner }); - const receipt = await zrxVault.enterCatastrophicFailure.awaitTransactionSuccessAsync({ + await zrxVault.addAuthorizedAddress(authorized).awaitTransactionSuccessAsync({ from: owner }); + const receipt = await zrxVault.enterCatastrophicFailure().awaitTransactionSuccessAsync({ from: authorized, }); await verifyCatastrophicFailureModeAsync(authorized, receipt); }); it('Non-authorized address cannot turn on Catastrophic Failure Mode', async () => { const notAuthorized = nonOwnerAddresses[0]; - const tx = zrxVault.enterCatastrophicFailure.awaitTransactionSuccessAsync({ + const tx = zrxVault.enterCatastrophicFailure().awaitTransactionSuccessAsync({ from: notAuthorized, }); const expectedError = new AuthorizableRevertErrors.SenderNotAuthorizedError(notAuthorized); expect(tx).to.revertWith(expectedError); - expect(await zrxVault.isInCatastrophicFailure.callAsync()).to.be.false(); + expect(await zrxVault.isInCatastrophicFailure().callAsync()).to.be.false(); }); it('Catastrophic Failure Mode can only be turned on once', async () => { const authorized = nonOwnerAddresses[0]; - await zrxVault.addAuthorizedAddress.awaitTransactionSuccessAsync(authorized, { from: owner }); - await zrxVault.enterCatastrophicFailure.awaitTransactionSuccessAsync({ + await zrxVault.addAuthorizedAddress(authorized).awaitTransactionSuccessAsync({ from: owner }); + await zrxVault.enterCatastrophicFailure().awaitTransactionSuccessAsync({ from: authorized, }); const expectedError = new StakingRevertErrors.OnlyCallableIfNotInCatastrophicFailureError(); - return expect(zrxVault.enterCatastrophicFailure.awaitTransactionSuccessAsync()).to.revertWith( + return expect(zrxVault.enterCatastrophicFailure().awaitTransactionSuccessAsync()).to.revertWith( expectedError, ); }); @@ -361,41 +353,41 @@ blockchainTests.resets('ZrxVault unit tests', env => { before(async () => { [staker, stakingProxy, ...nonOwnerAddresses] = nonOwnerAddresses; - await zrxVault.setStakingProxy.awaitTransactionSuccessAsync(stakingProxy, { from: owner }); - await zrxVault.depositFrom.awaitTransactionSuccessAsync(staker, new BigNumber(10), { + await zrxVault.setStakingProxy(stakingProxy).awaitTransactionSuccessAsync({ from: owner }); + await zrxVault.depositFrom(staker, new BigNumber(10)).awaitTransactionSuccessAsync({ from: stakingProxy, }); - await zrxVault.enterCatastrophicFailure.awaitTransactionSuccessAsync({ from: owner }); + await zrxVault.enterCatastrophicFailure().awaitTransactionSuccessAsync({ from: owner }); }); beforeEach(async () => { - initialVaultBalance = await zrxVault.balanceOf.callAsync(staker); + initialVaultBalance = await zrxVault.balanceOf(staker).callAsync(); initialTokenBalance = await erc20Wrapper.getBalanceAsync(staker, zrxAssetData); }); it('Owner cannot set the ZRX proxy', async () => { const newProxy = nonOwnerAddresses[0]; - const tx = zrxVault.setZrxProxy.awaitTransactionSuccessAsync(newProxy, { + const tx = zrxVault.setZrxProxy(newProxy).awaitTransactionSuccessAsync({ from: owner, }); const expectedError = new StakingRevertErrors.OnlyCallableIfNotInCatastrophicFailureError(); expect(tx).to.revertWith(expectedError); - const actualAddress = await zrxVault.zrxAssetProxy.callAsync(); + const actualAddress = await zrxVault.zrxAssetProxy().callAsync(); expect(actualAddress).to.equal(zrxProxyAddress); }); it('Authorized address cannot set the ZRX proxy', async () => { const [authorized, newProxy] = nonOwnerAddresses; - await zrxVault.addAuthorizedAddress.awaitTransactionSuccessAsync(authorized, { from: owner }); - const tx = zrxVault.setZrxProxy.awaitTransactionSuccessAsync(newProxy, { + await zrxVault.addAuthorizedAddress(authorized).awaitTransactionSuccessAsync({ from: owner }); + const tx = zrxVault.setZrxProxy(newProxy).awaitTransactionSuccessAsync({ from: authorized, }); const expectedError = new StakingRevertErrors.OnlyCallableIfNotInCatastrophicFailureError(); expect(tx).to.revertWith(expectedError); - const actualAddress = await zrxVault.zrxAssetProxy.callAsync(); + const actualAddress = await zrxVault.zrxAssetProxy().callAsync(); expect(actualAddress).to.equal(zrxProxyAddress); }); it('Staking proxy cannot deposit ZRX', async () => { - const tx = zrxVault.depositFrom.awaitTransactionSuccessAsync(staker, new BigNumber(1), { + const tx = zrxVault.depositFrom(staker, new BigNumber(1)).awaitTransactionSuccessAsync({ from: stakingProxy, }); const expectedError = new StakingRevertErrors.OnlyCallableIfNotInCatastrophicFailureError(); @@ -404,14 +396,14 @@ blockchainTests.resets('ZrxVault unit tests', env => { describe('Withdrawal', () => { it('Staking proxy cannot call `withdrawFrom`', async () => { - const tx = zrxVault.withdrawFrom.awaitTransactionSuccessAsync(staker, new BigNumber(1), { + const tx = zrxVault.withdrawFrom(staker, new BigNumber(1)).awaitTransactionSuccessAsync({ from: stakingProxy, }); const expectedError = new StakingRevertErrors.OnlyCallableIfNotInCatastrophicFailureError(); expect(tx).to.revertWith(expectedError); }); it('Staker can withdraw all their ZRX', async () => { - const receipt = await zrxVault.withdrawAllFrom.awaitTransactionSuccessAsync(staker, { + const receipt = await zrxVault.withdrawAllFrom(staker).awaitTransactionSuccessAsync({ from: staker, }); await verifyTransferPostconditionsAsync( @@ -424,7 +416,7 @@ blockchainTests.resets('ZrxVault unit tests', env => { ); }); it('Owner can withdraw ZRX on behalf of a staker', async () => { - const receipt = await zrxVault.withdrawAllFrom.awaitTransactionSuccessAsync(staker, { + const receipt = await zrxVault.withdrawAllFrom(staker).awaitTransactionSuccessAsync({ from: owner, }); await verifyTransferPostconditionsAsync( @@ -437,7 +429,7 @@ blockchainTests.resets('ZrxVault unit tests', env => { ); }); it('Non-owner address can withdraw ZRX on behalf of a staker', async () => { - const receipt = await zrxVault.withdrawAllFrom.awaitTransactionSuccessAsync(staker, { + const receipt = await zrxVault.withdrawAllFrom(staker).awaitTransactionSuccessAsync({ from: nonOwnerAddresses[0], }); await verifyTransferPostconditionsAsync( diff --git a/contracts/staking/test/utils/api_wrapper.ts b/contracts/staking/test/utils/api_wrapper.ts index 11fba1b467..922422446e 100644 --- a/contracts/staking/test/utils/api_wrapper.ts +++ b/contracts/staking/test/utils/api_wrapper.ts @@ -36,7 +36,7 @@ export class StakingApiWrapper { fastForwardToNextEpochAsync: async (): Promise => { // increase timestamp of next block by how many seconds we need to // get to the next epoch. - const epochEndTime = await this.stakingContract.getCurrentEpochEarliestEndTimeInSeconds.callAsync(); + const epochEndTime = await this.stakingContract.getCurrentEpochEarliestEndTimeInSeconds().callAsync(); const lastBlockTime = await this._web3Wrapper.getBlockTimestampAsync('latest'); const dt = Math.max(0, epochEndTime.minus(lastBlockTime).toNumber()); await this._web3Wrapper.increaseTimeAsync(dt); @@ -49,7 +49,7 @@ export class StakingApiWrapper { const endOfEpochInfo = await this.utils.endEpochAsync(); const allLogs = [] as DecodedLogs; for (const poolId of endOfEpochInfo.activePoolIds) { - const receipt = await this.stakingContract.finalizePool.awaitTransactionSuccessAsync(poolId); + const receipt = await this.stakingContract.finalizePool(poolId).awaitTransactionSuccessAsync(); allLogs.splice(allLogs.length, 0, ...(receipt.logs as DecodedLogs)); } return allLogs; @@ -57,7 +57,7 @@ export class StakingApiWrapper { endEpochAsync: async (): Promise => { const activePoolIds = await this.utils.findActivePoolIdsAsync(); - const receipt = await this.stakingContract.endEpoch.awaitTransactionSuccessAsync(); + const receipt = await this.stakingContract.endEpoch().awaitTransactionSuccessAsync(); const [epochEndedEvent] = filterLogsToArguments( receipt.logs, TestStakingEvents.EpochEnded, @@ -72,7 +72,7 @@ export class StakingApiWrapper { }, findActivePoolIdsAsync: async (epoch?: number): Promise => { - const _epoch = epoch !== undefined ? epoch : await this.stakingContract.currentEpoch.callAsync(); + const _epoch = epoch !== undefined ? epoch : await this.stakingContract.currentEpoch().callAsync(); const events = filterLogsToArguments( await this.stakingContract.getLogsAsync( TestStakingEvents.StakingPoolEarnedRewardsInEpoch, @@ -90,18 +90,16 @@ export class StakingApiWrapper { operatorShare: number, addOperatorAsMaker: boolean, ): Promise => { - const txReceipt = await this.stakingContract.createStakingPool.awaitTransactionSuccessAsync( - operatorShare, - addOperatorAsMaker, - { from: operatorAddress }, - ); + const txReceipt = await this.stakingContract + .createStakingPool(operatorShare, addOperatorAsMaker) + .awaitTransactionSuccessAsync({ from: operatorAddress }); const createStakingPoolLog = txReceipt.logs[0]; const poolId = (createStakingPoolLog as any).args.poolId; return poolId; }, getZrxTokenBalanceOfZrxVaultAsync: async (): Promise => { - return this.zrxTokenContract.balanceOf.callAsync(this.zrxVaultContract.address); + return this.zrxTokenContract.balanceOf(this.zrxVaultContract.address).callAsync(); }, setParamsAsync: async (params: Partial): Promise => { @@ -109,20 +107,22 @@ export class StakingApiWrapper { ...stakingConstants.DEFAULT_PARAMS, ...params, }; - return this.stakingContract.setParams.awaitTransactionSuccessAsync( - new BigNumber(_params.epochDurationInSeconds), - new BigNumber(_params.rewardDelegatedStakeWeight), - new BigNumber(_params.minimumPoolStake), - new BigNumber(_params.cobbDouglasAlphaNumerator), - new BigNumber(_params.cobbDouglasAlphaDenominator), - ); + return this.stakingContract + .setParams( + new BigNumber(_params.epochDurationInSeconds), + new BigNumber(_params.rewardDelegatedStakeWeight), + new BigNumber(_params.minimumPoolStake), + new BigNumber(_params.cobbDouglasAlphaNumerator), + new BigNumber(_params.cobbDouglasAlphaDenominator), + ) + .awaitTransactionSuccessAsync(); }, getAvailableRewardsBalanceAsync: async (): Promise => { const [ethBalance, wethBalance, reservedRewards] = await Promise.all([ this._web3Wrapper.getBalanceInWeiAsync(this.stakingProxyContract.address), - this.wethContract.balanceOf.callAsync(this.stakingProxyContract.address), - this.stakingContract.wethReservedForPoolRewards.callAsync(), + this.wethContract.balanceOf(this.stakingProxyContract.address).callAsync(), + this.stakingContract.wethReservedForPoolRewards().callAsync(), ]); return BigNumber.sum(ethBalance, wethBalance).minus(reservedRewards); }, @@ -138,7 +138,7 @@ export class StakingApiWrapper { 'wethProxyAddress', 'zrxVaultAddress', ], - await this.stakingContract.getParams.callAsync(), + await this.stakingContract.getParams().callAsync(), ) as any) as StakingParams; }, @@ -150,15 +150,17 @@ export class StakingApiWrapper { totalStake: BigNumber, ): Promise => { const { cobbDouglasAlphaNumerator, cobbDouglasAlphaDenominator } = await this.utils.getParamsAsync(); - return this.cobbDouglasContract.cobbDouglas.callAsync( - totalRewards, - ownerFees, - totalFees, - ownerStake, - totalStake, - new BigNumber(cobbDouglasAlphaNumerator), - new BigNumber(cobbDouglasAlphaDenominator), - ); + return this.cobbDouglasContract + .cobbDouglas( + totalRewards, + ownerFees, + totalFees, + ownerStake, + totalStake, + new BigNumber(cobbDouglasAlphaNumerator), + new BigNumber(cobbDouglasAlphaDenominator), + ) + .callAsync(); }, }; @@ -232,7 +234,7 @@ export async function deployAndConfigureContractsAsync( zrxTokenContract.address, ); - await zrxVaultContract.addAuthorizedAddress.awaitTransactionSuccessAsync(ownerAddress); + await zrxVaultContract.addAuthorizedAddress(ownerAddress).awaitTransactionSuccessAsync(); // deploy staking contract const stakingContract = await TestStakingContract.deployFrom0xArtifactAsync( @@ -253,7 +255,7 @@ export async function deployAndConfigureContractsAsync( stakingContract.address, ); - await stakingProxyContract.addAuthorizedAddress.awaitTransactionSuccessAsync(ownerAddress); + await stakingProxyContract.addAuthorizedAddress(ownerAddress).awaitTransactionSuccessAsync(); // deploy cobb douglas contract const cobbDouglasContract = await TestCobbDouglasContract.deployFrom0xArtifactAsync( @@ -264,9 +266,9 @@ export async function deployAndConfigureContractsAsync( ); // configure erc20 proxy to accept calls from zrx vault - await erc20ProxyContract.addAuthorizedAddress.awaitTransactionSuccessAsync(zrxVaultContract.address); + await erc20ProxyContract.addAuthorizedAddress(zrxVaultContract.address).awaitTransactionSuccessAsync(); // set staking proxy contract in zrx vault - await zrxVaultContract.setStakingProxy.awaitTransactionSuccessAsync(stakingProxyContract.address); + await zrxVaultContract.setStakingProxy(stakingProxyContract.address).awaitTransactionSuccessAsync(); return new StakingApiWrapper( env, ownerAddress, diff --git a/contracts/staking/test/utils/cumulative_reward_tracking_simulation.ts b/contracts/staking/test/utils/cumulative_reward_tracking_simulation.ts index e16f12c323..fedba50527 100644 --- a/contracts/staking/test/utils/cumulative_reward_tracking_simulation.ts +++ b/contracts/staking/test/utils/cumulative_reward_tracking_simulation.ts @@ -73,9 +73,9 @@ export class CumulativeRewardTrackingSimulation { public async deployAndConfigureTestContractsAsync(env: BlockchainTestsEnvironment): Promise { // set exchange address - await this._stakingApiWrapper.stakingContract.addExchangeAddress.awaitTransactionSuccessAsync( - this._exchangeAddress, - ); + await this._stakingApiWrapper.stakingContract + .addExchangeAddress(this._exchangeAddress) + .awaitTransactionSuccessAsync(); this._testCumulativeRewardTrackingContract = await TestCumulativeRewardTrackingContract.deployFrom0xArtifactAsync( artifacts.TestCumulativeRewardTracking, env.provider, @@ -99,9 +99,9 @@ export class CumulativeRewardTrackingSimulation { expectedTestLogs: TestLog[], ): Promise { await this._executeActionsAsync(initActions); - await this._stakingApiWrapper.stakingProxyContract.attachStakingContract.awaitTransactionSuccessAsync( - this.getTestCumulativeRewardTrackingContract().address, - ); + await this._stakingApiWrapper.stakingProxyContract + .attachStakingContract(this.getTestCumulativeRewardTrackingContract().address) + .awaitTransactionSuccessAsync(); const testLogs = await this._executeActionsAsync(testActions); CumulativeRewardTrackingSimulation._assertTestLogs(expectedTestLogs, testLogs); } @@ -117,41 +117,38 @@ export class CumulativeRewardTrackingSimulation { break; case TestAction.Delegate: - await this._stakingApiWrapper.stakingContract.stake.sendTransactionAsync(this._amountToStake, { + await this._stakingApiWrapper.stakingContract.stake(this._amountToStake).sendTransactionAsync({ from: this._staker, }); - receipt = await this._stakingApiWrapper.stakingContract.moveStake.awaitTransactionSuccessAsync( - new StakeInfo(StakeStatus.Undelegated), - new StakeInfo(StakeStatus.Delegated, this._poolId), - this._amountToStake, - { from: this._staker }, - ); + receipt = await this._stakingApiWrapper.stakingContract + .moveStake( + new StakeInfo(StakeStatus.Undelegated), + new StakeInfo(StakeStatus.Delegated, this._poolId), + this._amountToStake, + ) + .awaitTransactionSuccessAsync({ from: this._staker }); break; case TestAction.Undelegate: - receipt = await this._stakingApiWrapper.stakingContract.moveStake.awaitTransactionSuccessAsync( - new StakeInfo(StakeStatus.Delegated, this._poolId), - new StakeInfo(StakeStatus.Undelegated), - this._amountToStake, - { from: this._staker }, - ); + receipt = await this._stakingApiWrapper.stakingContract + .moveStake( + new StakeInfo(StakeStatus.Delegated, this._poolId), + new StakeInfo(StakeStatus.Undelegated), + this._amountToStake, + ) + .awaitTransactionSuccessAsync({ from: this._staker }); break; case TestAction.PayProtocolFee: - receipt = await this._stakingApiWrapper.stakingContract.payProtocolFee.awaitTransactionSuccessAsync( - this._poolOperator, - this._takerAddress, - this._protocolFee, - { from: this._exchangeAddress, value: this._protocolFee }, - ); + receipt = await this._stakingApiWrapper.stakingContract + .payProtocolFee(this._poolOperator, this._takerAddress, this._protocolFee) + .awaitTransactionSuccessAsync({ from: this._exchangeAddress, value: this._protocolFee }); break; case TestAction.CreatePool: - receipt = await this._stakingApiWrapper.stakingContract.createStakingPool.awaitTransactionSuccessAsync( - 0, - true, - { from: this._poolOperator }, - ); + receipt = await this._stakingApiWrapper.stakingContract + .createStakingPool(0, true) + .awaitTransactionSuccessAsync({ from: this._poolOperator }); const createStakingPoolLog = receipt.logs[0]; // tslint:disable-next-line no-unnecessary-type-assertion this._poolId = (createStakingPoolLog as DecodedLogEntry).args.poolId; diff --git a/contracts/test-utils/package.json b/contracts/test-utils/package.json index c629416b19..d1410397eb 100644 --- a/contracts/test-utils/package.json +++ b/contracts/test-utils/package.json @@ -40,6 +40,7 @@ "typescript": "3.0.1" }, "dependencies": { + "@0x/base-contract": "^5.5.0-beta.0", "@0x/dev-utils": "^2.4.0-beta.0", "@0x/order-utils": "^8.5.0-beta.0", "@0x/sol-compiler": "^3.2.0-beta.0", diff --git a/contracts/test-utils/src/index.ts b/contracts/test-utils/src/index.ts index 063859363d..ec7c8afc30 100644 --- a/contracts/test-utils/src/index.ts +++ b/contracts/test-utils/src/index.ts @@ -26,7 +26,7 @@ export { randomAddress } from './address_utils'; export { OrderFactory } from './order_factory'; export { bytes32Values, testCombinatoriallyWithReferenceFunc, uint256Values } from './combinatorial_utils'; export { TransactionFactory } from './transaction_factory'; -export { MutatorContractFunction, TransactionHelper } from './transaction_helper'; +export { MutatorContractFunction, transactionHelper } from './transaction_helper'; export { testWithReferenceFuncAsync } from './test_with_reference'; export { hexConcat, diff --git a/contracts/test-utils/src/transaction_helper.ts b/contracts/test-utils/src/transaction_helper.ts index e861e389f7..b76e625588 100644 --- a/contracts/test-utils/src/transaction_helper.ts +++ b/contracts/test-utils/src/transaction_helper.ts @@ -1,56 +1,21 @@ -import { Web3Wrapper } from '@0x/web3-wrapper'; -import { ContractArtifact, TransactionReceipt } from 'ethereum-types'; - -import { LogDecoder } from './log_decoder'; - -type AsyncFunction = (...args: TArgs) => Promise; - -interface ContractArtifacts { - [contractName: string]: ContractArtifact; -} - -export interface MutatorContractFunction< - TCallAsyncArgs extends any[], - TAwaitTransactionSuccessAsyncArgs extends any[], - TCallAsyncResult -> { - callAsync: AsyncFunction; - sendTransactionAsync: AsyncFunction; -} +import { ContractTxFunctionObj } from '@0x/base-contract'; +import { TransactionReceiptWithDecodedLogs } from 'ethereum-types'; +export type MutatorContractFunction = (...args: any[]) => ContractTxFunctionObj; /** * Helper class for performing non-constant contract functions calls. */ -export class TransactionHelper { - public readonly logDecoder: LogDecoder; - - constructor(web3Wrapper: Web3Wrapper, artifacts: ContractArtifacts) { - this.logDecoder = new LogDecoder(web3Wrapper, artifacts); - } - - /** - * Call a non-constant contract function `contractFunction`, passing `args`. - * This will first perform an 'eth_call' (read-only) call in order to - * retrieve the return value, then a 'sendTransaction' to actually modify - * the state. Returns a tuple of the return value amd receipt, with decoded - * logs. - */ - public async getResultAndReceiptAsync< - TCallAsyncArgs extends any[], - TAwaitTransactionSuccessAsyncArgs extends any[], - TCallAsyncResult - >( - contractFunction: MutatorContractFunction, - // tslint:disable-next-line: trailing-comma - ...args: TAwaitTransactionSuccessAsyncArgs - ): Promise<[TCallAsyncResult, TransactionReceipt]> { +export const transactionHelper = { + async getResultAndReceiptAsync( + contractFunction: MutatorContractFunction, + ...args: any[] // tslint:disable-line:trailing-comma + ): Promise<[O, TransactionReceiptWithDecodedLogs]> { // HACK(dorothy-zbornak): We take advantage of the general rule that // the parameters for `callAsync()` are a subset of the // parameters for `sendTransactionAsync()`. - const result = await contractFunction.callAsync(...((args as any) as TCallAsyncArgs)); - const receipt = await this.logDecoder.getTxWithDecodedLogsAsync( - await contractFunction.sendTransactionAsync(...args), - ); + const contractFunctionObj = contractFunction(...args); + const result = await contractFunctionObj.callAsync(); + const receipt = await contractFunctionObj.awaitTransactionSuccessAsync(); return [result, receipt]; - } -} + }, +}; diff --git a/contracts/tests/test/dev-utils/lib_asset_data.ts b/contracts/tests/test/dev-utils/lib_asset_data.ts index 67c1277162..ea54360bc4 100644 --- a/contracts/tests/test/dev-utils/lib_asset_data.ts +++ b/contracts/tests/test/dev-utils/lib_asset_data.ts @@ -135,11 +135,11 @@ describe('LibAssetData', () => { artifacts, ); - await exchange.registerAssetProxy.awaitTransactionSuccessAsync(erc20Proxy.address); - await exchange.registerAssetProxy.awaitTransactionSuccessAsync(erc721Proxy.address); - await exchange.registerAssetProxy.awaitTransactionSuccessAsync(erc1155Proxy.address); - await exchange.registerAssetProxy.awaitTransactionSuccessAsync(multiAssetProxy.address); - await exchange.registerAssetProxy.awaitTransactionSuccessAsync(staticCallProxy.address); + await exchange.registerAssetProxy(erc20Proxy.address).awaitTransactionSuccessAsync(); + await exchange.registerAssetProxy(erc721Proxy.address).awaitTransactionSuccessAsync(); + await exchange.registerAssetProxy(erc1155Proxy.address).awaitTransactionSuccessAsync(); + await exchange.registerAssetProxy(multiAssetProxy.address).awaitTransactionSuccessAsync(); + await exchange.registerAssetProxy(staticCallProxy.address).awaitTransactionSuccessAsync(); libAssetData = await LibAssetDataContract.deployFrom0xArtifactAsync( artifacts.LibAssetData, @@ -181,7 +181,7 @@ describe('LibAssetData', () => { const transactionMinedPromises = []; for (let i = 0; i < numberOfERC721Tokens; i++) { transactionMinedPromises.push( - erc721Token.mint.awaitTransactionSuccessAsync(tokenOwnerAddress, firstERC721TokenId.plus(i - 1)), + erc721Token.mint(tokenOwnerAddress, firstERC721TokenId.plus(i - 1)).awaitTransactionSuccessAsync(), ); } await Promise.all(transactionMinedPromises); @@ -195,16 +195,14 @@ describe('LibAssetData', () => { const logDecoder = new LogDecoder(web3Wrapper, erc1155Artifacts); const transactionReceipt = await logDecoder.getTxWithDecodedLogsAsync( - await erc1155Token.create.sendTransactionAsync('uri:Dummy', /*isNonFungible:*/ false), + await erc1155Token.create('uri:Dummy', /*isNonFungible:*/ false).sendTransactionAsync(), ); // tslint:disable-next-line no-unnecessary-type-assertion erc1155TokenId = (transactionReceipt.logs[0] as LogWithDecodedArgs).args.id; - await erc1155Token.mintFungible.awaitTransactionSuccessAsync( - erc1155TokenId, - [tokenOwnerAddress], - [new BigNumber(1)], - ); + await erc1155Token + .mintFungible(erc1155TokenId, [tokenOwnerAddress], [new BigNumber(1)]) + .awaitTransactionSuccessAsync(); }); after(async () => { @@ -232,17 +230,17 @@ describe('LibAssetData', () => { ]; for (const [assetData, proxyId] of assetDataScenarios) { - expect(await libAssetData.decodeAssetProxyId.callAsync(assetData)).to.equal(proxyId); + expect(await libAssetData.decodeAssetProxyId(assetData).callAsync()).to.equal(proxyId); } }); it('should encode ERC20 asset data', async () => { - expect(await libAssetData.encodeERC20AssetData.callAsync(KNOWN_ERC20_ENCODING.address)).to.equal( + expect(await libAssetData.encodeERC20AssetData(KNOWN_ERC20_ENCODING.address).callAsync()).to.equal( KNOWN_ERC20_ENCODING.assetData, ); }); it('should decode ERC20 asset data', async () => { - expect(await libAssetData.decodeERC20AssetData.callAsync(KNOWN_ERC20_ENCODING.assetData)).to.deep.equal([ + expect(await libAssetData.decodeERC20AssetData(KNOWN_ERC20_ENCODING.assetData).callAsync()).to.deep.equal([ AssetProxyId.ERC20, KNOWN_ERC20_ENCODING.address, ]); @@ -250,56 +248,57 @@ describe('LibAssetData', () => { it('should encode ERC721 asset data', async () => { expect( - await libAssetData.encodeERC721AssetData.callAsync( - KNOWN_ERC721_ENCODING.address, - KNOWN_ERC721_ENCODING.tokenId, - ), + await libAssetData + .encodeERC721AssetData(KNOWN_ERC721_ENCODING.address, KNOWN_ERC721_ENCODING.tokenId) + .callAsync(), ).to.equal(KNOWN_ERC721_ENCODING.assetData); }); it('should decode ERC721 asset data', async () => { - expect(await libAssetData.decodeERC721AssetData.callAsync(KNOWN_ERC721_ENCODING.assetData)).to.deep.equal([ - AssetProxyId.ERC721, - KNOWN_ERC721_ENCODING.address, - KNOWN_ERC721_ENCODING.tokenId, - ]); + expect(await libAssetData.decodeERC721AssetData(KNOWN_ERC721_ENCODING.assetData).callAsync()).to.deep.equal( + [AssetProxyId.ERC721, KNOWN_ERC721_ENCODING.address, KNOWN_ERC721_ENCODING.tokenId], + ); }); it('should encode ERC1155 asset data', async () => { expect( - await libAssetData.encodeERC1155AssetData.callAsync( - KNOWN_ERC1155_ENCODING.tokenAddress, - KNOWN_ERC1155_ENCODING.tokenIds, - KNOWN_ERC1155_ENCODING.tokenValues, - KNOWN_ERC1155_ENCODING.callbackData, - ), + await libAssetData + .encodeERC1155AssetData( + KNOWN_ERC1155_ENCODING.tokenAddress, + KNOWN_ERC1155_ENCODING.tokenIds, + KNOWN_ERC1155_ENCODING.tokenValues, + KNOWN_ERC1155_ENCODING.callbackData, + ) + .callAsync(), ).to.equal(KNOWN_ERC1155_ENCODING.assetData); }); it('should decode ERC1155 asset data', async () => { - expect(await libAssetData.decodeERC1155AssetData.callAsync(KNOWN_ERC1155_ENCODING.assetData)).to.deep.equal( - [ - AssetProxyId.ERC1155, - KNOWN_ERC1155_ENCODING.tokenAddress, - KNOWN_ERC1155_ENCODING.tokenIds, - KNOWN_ERC1155_ENCODING.tokenValues, - KNOWN_ERC1155_ENCODING.callbackData, - ], - ); + expect( + await libAssetData.decodeERC1155AssetData(KNOWN_ERC1155_ENCODING.assetData).callAsync(), + ).to.deep.equal([ + AssetProxyId.ERC1155, + KNOWN_ERC1155_ENCODING.tokenAddress, + KNOWN_ERC1155_ENCODING.tokenIds, + KNOWN_ERC1155_ENCODING.tokenValues, + KNOWN_ERC1155_ENCODING.callbackData, + ]); }); it('should encode multiasset data', async () => { expect( - await libAssetData.encodeMultiAssetData.callAsync( - KNOWN_MULTI_ASSET_ENCODING.amounts, - KNOWN_MULTI_ASSET_ENCODING.nestedAssetData, - ), + await libAssetData + .encodeMultiAssetData( + KNOWN_MULTI_ASSET_ENCODING.amounts, + KNOWN_MULTI_ASSET_ENCODING.nestedAssetData, + ) + .callAsync(), ).to.equal(KNOWN_MULTI_ASSET_ENCODING.assetData); }); it('should decode multiasset data', async () => { expect( - await libAssetData.decodeMultiAssetData.callAsync(KNOWN_MULTI_ASSET_ENCODING.assetData), + await libAssetData.decodeMultiAssetData(KNOWN_MULTI_ASSET_ENCODING.assetData).callAsync(), ).to.deep.equal([ AssetProxyId.MultiAsset, KNOWN_MULTI_ASSET_ENCODING.amounts, @@ -309,17 +308,19 @@ describe('LibAssetData', () => { it('should encode StaticCall data', async () => { expect( - await libAssetData.encodeStaticCallAssetData.callAsync( - KNOWN_STATIC_CALL_ENCODING.staticCallTargetAddress, - KNOWN_STATIC_CALL_ENCODING.staticCallData, - KNOWN_STATIC_CALL_ENCODING.expectedReturnDataHash, - ), + await libAssetData + .encodeStaticCallAssetData( + KNOWN_STATIC_CALL_ENCODING.staticCallTargetAddress, + KNOWN_STATIC_CALL_ENCODING.staticCallData, + KNOWN_STATIC_CALL_ENCODING.expectedReturnDataHash, + ) + .callAsync(), ).to.equal(KNOWN_STATIC_CALL_ENCODING.assetData); }); it('should decode StaticCall data', async () => { expect( - await libAssetData.decodeStaticCallAssetData.callAsync(KNOWN_STATIC_CALL_ENCODING.assetData), + await libAssetData.decodeStaticCallAssetData(KNOWN_STATIC_CALL_ENCODING.assetData).callAsync(), ).to.deep.equal([ AssetProxyId.StaticCall, KNOWN_STATIC_CALL_ENCODING.staticCallTargetAddress, @@ -339,14 +340,14 @@ describe('LibAssetData', () => { ]; for (const data of assetData) { - await libAssetData.revertIfInvalidAssetData.callAsync(data); + await libAssetData.revertIfInvalidAssetData(data).callAsync(); } return; }); it('should revert for invalid assetProxyId', async () => { const badAssetData = '0x' + crypto.randomBytes(4).toString('hex') + constants.NULL_ADDRESS; - await expect(libAssetData.revertIfInvalidAssetData.callAsync(badAssetData)).to.eventually.be.rejectedWith( + await expect(libAssetData.revertIfInvalidAssetData(badAssetData).callAsync()).to.eventually.be.rejectedWith( StringRevertError, ); }); @@ -357,7 +358,7 @@ describe('LibAssetData', () => { for (const data of assetData) { const badData = data.substring(0, data.length - 2); // drop one byte but retain assetProxyId - await expect(libAssetData.revertIfInvalidAssetData.callAsync(badData)).to.eventually.be.rejectedWith( + await expect(libAssetData.revertIfInvalidAssetData(badData).callAsync()).to.eventually.be.rejectedWith( InvalidByteOperationError, ); } @@ -366,98 +367,98 @@ describe('LibAssetData', () => { describe('getBalance', () => { it('should query ERC20 balance by asset data', async () => { - const assetData = await libAssetData.encodeERC20AssetData.callAsync(erc20Token.address); - expect(await libAssetData.getBalance.callAsync(tokenOwnerAddress, assetData)).to.bignumber.equal( + const assetData = await libAssetData.encodeERC20AssetData(erc20Token.address).callAsync(); + expect(await libAssetData.getBalance(tokenOwnerAddress, assetData).callAsync()).to.bignumber.equal( erc20TokenTotalSupply, ); }); it('should return 0 if ERC20 token does not exist', async () => { - const assetData = await libAssetData.encodeERC20AssetData.callAsync(constants.NULL_ADDRESS); - const balance = await libAssetData.getBalance.callAsync(tokenOwnerAddress, assetData); + const assetData = await libAssetData.encodeERC20AssetData(constants.NULL_ADDRESS).callAsync(); + const balance = await libAssetData.getBalance(tokenOwnerAddress, assetData).callAsync(); expect(balance).to.bignumber.equal(constants.ZERO_AMOUNT); }); it('should query ERC721 balance by asset data', async () => { - const assetData = await libAssetData.encodeERC721AssetData.callAsync( - erc721Token.address, - firstERC721TokenId, - ); - expect(await libAssetData.getBalance.callAsync(tokenOwnerAddress, assetData)).to.bignumber.equal(1); + const assetData = await libAssetData + .encodeERC721AssetData(erc721Token.address, firstERC721TokenId) + .callAsync(); + expect(await libAssetData.getBalance(tokenOwnerAddress, assetData).callAsync()).to.bignumber.equal(1); }); it('should return 0 if ERC721 token does not exist', async () => { - const assetData = await libAssetData.encodeERC721AssetData.callAsync( - constants.NULL_ADDRESS, - firstERC721TokenId, - ); - const balance = await libAssetData.getBalance.callAsync(tokenOwnerAddress, assetData); + const assetData = await libAssetData + .encodeERC721AssetData(constants.NULL_ADDRESS, firstERC721TokenId) + .callAsync(); + const balance = await libAssetData.getBalance(tokenOwnerAddress, assetData).callAsync(); expect(balance).to.bignumber.equal(constants.ZERO_AMOUNT); }); it('should query ERC1155 balances by asset data', async () => { - const assetData = await libAssetData.encodeERC1155AssetData.callAsync( - erc1155Token.address, - [erc1155TokenId], - [new BigNumber(1)], - constants.NULL_BYTES, - ); - expect(await libAssetData.getBalance.callAsync(tokenOwnerAddress, assetData)).to.bignumber.equal(1); + const assetData = await libAssetData + .encodeERC1155AssetData( + erc1155Token.address, + [erc1155TokenId], + [new BigNumber(1)], + constants.NULL_BYTES, + ) + .callAsync(); + expect(await libAssetData.getBalance(tokenOwnerAddress, assetData).callAsync()).to.bignumber.equal(1); }); it('should return 0 if ERC1155 token does not exist', async () => { - const assetData = await libAssetData.encodeERC1155AssetData.callAsync( - constants.NULL_ADDRESS, - [erc1155TokenId], - [new BigNumber(1)], - constants.NULL_BYTES, - ); - const balance = await libAssetData.getBalance.callAsync(tokenOwnerAddress, assetData); + const assetData = await libAssetData + .encodeERC1155AssetData( + constants.NULL_ADDRESS, + [erc1155TokenId], + [new BigNumber(1)], + constants.NULL_BYTES, + ) + .callAsync(); + const balance = await libAssetData.getBalance(tokenOwnerAddress, assetData).callAsync(); expect(balance).to.bignumber.equal(constants.ZERO_AMOUNT); }); it('should query multi-asset batch balance by asset data', async () => { - const assetData = await libAssetData.encodeMultiAssetData.callAsync( - [new BigNumber(1), new BigNumber(1)], - [ - await libAssetData.encodeERC20AssetData.callAsync(erc20Token.address), - await libAssetData.encodeERC721AssetData.callAsync(erc721Token.address, firstERC721TokenId), - ], - ); - expect(await libAssetData.getBalance.callAsync(tokenOwnerAddress, assetData)).to.bignumber.equal( + const assetData = await libAssetData + .encodeMultiAssetData( + [new BigNumber(1), new BigNumber(1)], + [ + await libAssetData.encodeERC20AssetData(erc20Token.address).callAsync(), + await libAssetData.encodeERC721AssetData(erc721Token.address, firstERC721TokenId).callAsync(), + ], + ) + .callAsync(); + expect(await libAssetData.getBalance(tokenOwnerAddress, assetData).callAsync()).to.bignumber.equal( Math.min(erc20TokenTotalSupply.toNumber(), numberOfERC721Tokens), ); }); it('should return a balance of 0 if the assetData does not correspond to an AssetProxy contract', async () => { const fakeAssetData = '0x01020304'; - const balance = await libAssetData.getBalance.callAsync(tokenOwnerAddress, fakeAssetData); + const balance = await libAssetData.getBalance(tokenOwnerAddress, fakeAssetData).callAsync(); expect(balance).to.bignumber.equal(constants.ZERO_AMOUNT); }); it('should return a balance of MAX_UINT256 if the the StaticCallProxy assetData contains data for a successful staticcall', async () => { - const staticCallData = staticCallTarget.isOddNumber.getABIEncodedTransactionData(new BigNumber(1)); + const staticCallData = staticCallTarget.isOddNumber(new BigNumber(1)).getABIEncodedTransactionData(); const trueAsBuffer = ethUtil.toBuffer('0x0000000000000000000000000000000000000000000000000000000000000001'); const expectedResultHash = ethUtil.bufferToHex(ethUtil.sha3(trueAsBuffer)); - const assetData = await libAssetData.encodeStaticCallAssetData.callAsync( - staticCallTarget.address, - staticCallData, - expectedResultHash, - ); - const balance = await libAssetData.getBalance.callAsync(tokenOwnerAddress, assetData); + const assetData = await libAssetData + .encodeStaticCallAssetData(staticCallTarget.address, staticCallData, expectedResultHash) + .callAsync(); + const balance = await libAssetData.getBalance(tokenOwnerAddress, assetData).callAsync(); expect(balance).to.bignumber.equal(constants.UNLIMITED_ALLOWANCE_IN_BASE_UNITS); }); it('should return a balance of 0 if the the StaticCallProxy assetData contains data for an unsuccessful staticcall', async () => { - const staticCallData = staticCallTarget.isOddNumber.getABIEncodedTransactionData(new BigNumber(0)); + const staticCallData = staticCallTarget.isOddNumber(new BigNumber(0)).getABIEncodedTransactionData(); const trueAsBuffer = ethUtil.toBuffer('0x0000000000000000000000000000000000000000000000000000000000000001'); const expectedResultHash = ethUtil.bufferToHex(ethUtil.sha3(trueAsBuffer)); - const assetData = await libAssetData.encodeStaticCallAssetData.callAsync( - staticCallTarget.address, - staticCallData, - expectedResultHash, - ); - const balance = await libAssetData.getBalance.callAsync(tokenOwnerAddress, assetData); + const assetData = await libAssetData + .encodeStaticCallAssetData(staticCallTarget.address, staticCallData, expectedResultHash) + .callAsync(); + const balance = await libAssetData.getBalance(tokenOwnerAddress, assetData).callAsync(); expect(balance).to.bignumber.equal(constants.ZERO_AMOUNT); }); }); @@ -465,104 +466,103 @@ describe('LibAssetData', () => { describe('getAssetProxyAllowance', () => { it('should query ERC20 allowances by asset data', async () => { const allowance = new BigNumber(1); - await erc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, allowance, { + await erc20Token.approve(erc20Proxy.address, allowance).awaitTransactionSuccessAsync({ from: tokenOwnerAddress, }); - const assetData = await libAssetData.encodeERC20AssetData.callAsync(erc20Token.address); + const assetData = await libAssetData.encodeERC20AssetData(erc20Token.address).callAsync(); expect( - await libAssetData.getAssetProxyAllowance.callAsync(tokenOwnerAddress, assetData), + await libAssetData.getAssetProxyAllowance(tokenOwnerAddress, assetData).callAsync(), ).to.bignumber.equal(allowance); }); it('should query ERC721 approval by asset data', async () => { - await erc721Token.approve.awaitTransactionSuccessAsync(erc721Proxy.address, firstERC721TokenId, { + await erc721Token.approve(erc721Proxy.address, firstERC721TokenId).awaitTransactionSuccessAsync({ from: tokenOwnerAddress, }); - const assetData = await libAssetData.encodeERC721AssetData.callAsync( - erc721Token.address, - firstERC721TokenId, - ); + const assetData = await libAssetData + .encodeERC721AssetData(erc721Token.address, firstERC721TokenId) + .callAsync(); expect( - await libAssetData.getAssetProxyAllowance.callAsync(tokenOwnerAddress, assetData), + await libAssetData.getAssetProxyAllowance(tokenOwnerAddress, assetData).callAsync(), ).to.bignumber.equal(1); }); it('should query ERC721 approvalForAll by assetData', async () => { - await erc721Token.setApprovalForAll.awaitTransactionSuccessAsync(erc721Proxy.address, true, { + await erc721Token.setApprovalForAll(erc721Proxy.address, true).awaitTransactionSuccessAsync({ from: tokenOwnerAddress, }); - const assetData = await libAssetData.encodeERC721AssetData.callAsync( - erc721Token.address, - firstERC721TokenId, - ); + const assetData = await libAssetData + .encodeERC721AssetData(erc721Token.address, firstERC721TokenId) + .callAsync(); expect( - await libAssetData.getAssetProxyAllowance.callAsync(tokenOwnerAddress, assetData), + await libAssetData.getAssetProxyAllowance(tokenOwnerAddress, assetData).callAsync(), ).to.bignumber.equal(constants.UNLIMITED_ALLOWANCE_IN_BASE_UNITS); }); it('should query ERC1155 allowances by asset data', async () => { - await erc1155Token.setApprovalForAll.awaitTransactionSuccessAsync(erc1155Proxy.address, true, { + await erc1155Token.setApprovalForAll(erc1155Proxy.address, true).awaitTransactionSuccessAsync({ from: tokenOwnerAddress, }); - const assetData = await libAssetData.encodeERC1155AssetData.callAsync( - erc1155Token.address, - [erc1155TokenId], - [new BigNumber(1)], - constants.NULL_BYTES, - ); + const assetData = await libAssetData + .encodeERC1155AssetData( + erc1155Token.address, + [erc1155TokenId], + [new BigNumber(1)], + constants.NULL_BYTES, + ) + .callAsync(); expect( - await libAssetData.getAssetProxyAllowance.callAsync(tokenOwnerAddress, assetData), + await libAssetData.getAssetProxyAllowance(tokenOwnerAddress, assetData).callAsync(), ).to.bignumber.equal(constants.UNLIMITED_ALLOWANCE_IN_BASE_UNITS); }); it('should query multi-asset allowances by asset data', async () => { const allowance = new BigNumber(1); - await erc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, allowance, { + await erc20Token.approve(erc20Proxy.address, allowance).awaitTransactionSuccessAsync({ from: tokenOwnerAddress, }); - await erc721Token.approve.awaitTransactionSuccessAsync(erc721Proxy.address, firstERC721TokenId, { + await erc721Token.approve(erc721Proxy.address, firstERC721TokenId).awaitTransactionSuccessAsync({ from: tokenOwnerAddress, }); - const assetData = await libAssetData.encodeMultiAssetData.callAsync( - [new BigNumber(1), new BigNumber(1)], - [ - await libAssetData.encodeERC20AssetData.callAsync(erc20Token.address), - await libAssetData.encodeERC721AssetData.callAsync(erc721Token.address, firstERC721TokenId), - ], - ); + const assetData = await libAssetData + .encodeMultiAssetData( + [new BigNumber(1), new BigNumber(1)], + [ + await libAssetData.encodeERC20AssetData(erc20Token.address).callAsync(), + await libAssetData.encodeERC721AssetData(erc721Token.address, firstERC721TokenId).callAsync(), + ], + ) + .callAsync(); expect( - await libAssetData.getAssetProxyAllowance.callAsync(tokenOwnerAddress, assetData), + await libAssetData.getAssetProxyAllowance(tokenOwnerAddress, assetData).callAsync(), ).to.bignumber.equal(1); return; }); it('should return an allowance of 0 if the assetData does not correspond to an AssetProxy contract', async () => { const fakeAssetData = '0x01020304'; - const allowance = await libAssetData.getAssetProxyAllowance.callAsync(tokenOwnerAddress, fakeAssetData); + const allowance = await libAssetData.getAssetProxyAllowance(tokenOwnerAddress, fakeAssetData).callAsync(); expect(allowance).to.bignumber.equal(constants.ZERO_AMOUNT); }); it('should return an allowance of MAX_UINT256 for any staticCallAssetData', async () => { const staticCallData = AssetProxyId.StaticCall; - const assetData = await libAssetData.encodeStaticCallAssetData.callAsync( - staticCallTarget.address, - staticCallData, - constants.KECCAK256_NULL, - ); - const allowance = await libAssetData.getAssetProxyAllowance.callAsync(tokenOwnerAddress, assetData); + const assetData = await libAssetData + .encodeStaticCallAssetData(staticCallTarget.address, staticCallData, constants.KECCAK256_NULL) + .callAsync(); + const allowance = await libAssetData.getAssetProxyAllowance(tokenOwnerAddress, assetData).callAsync(); expect(allowance).to.bignumber.equal(constants.UNLIMITED_ALLOWANCE_IN_BASE_UNITS); }); }); describe('getBatchBalances', () => { it('should query balances for a batch of asset data strings', async () => { - const erc20AssetData = await libAssetData.encodeERC20AssetData.callAsync(erc20Token.address); - const erc721AssetData = await libAssetData.encodeERC721AssetData.callAsync( - erc721Token.address, - firstERC721TokenId, - ); + const erc20AssetData = await libAssetData.encodeERC20AssetData(erc20Token.address).callAsync(); + const erc721AssetData = await libAssetData + .encodeERC721AssetData(erc721Token.address, firstERC721TokenId) + .callAsync(); expect( - await libAssetData.getBatchBalances.callAsync(tokenOwnerAddress, [erc20AssetData, erc721AssetData]), + await libAssetData.getBatchBalances(tokenOwnerAddress, [erc20AssetData, erc721AssetData]).callAsync(), ).to.deep.equal([new BigNumber(erc20TokenTotalSupply), new BigNumber(1)]); }); }); @@ -570,24 +570,24 @@ describe('LibAssetData', () => { describe('getBalanceAndAllowance', () => { it('should query balance and allowance together, from asset data', async () => { const allowance = new BigNumber(1); - await erc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, allowance, { + await erc20Token.approve(erc20Proxy.address, allowance).awaitTransactionSuccessAsync({ from: tokenOwnerAddress, }); - const assetData = await libAssetData.encodeERC20AssetData.callAsync(erc20Token.address); + const assetData = await libAssetData.encodeERC20AssetData(erc20Token.address).callAsync(); expect( - await libAssetData.getBalanceAndAssetProxyAllowance.callAsync(tokenOwnerAddress, assetData), + await libAssetData.getBalanceAndAssetProxyAllowance(tokenOwnerAddress, assetData).callAsync(), ).to.deep.equal([new BigNumber(erc20TokenTotalSupply), allowance]); }); }); describe('getBatchBalancesAndAllowances', () => { it('should query balances and allowances together, from an asset data array', async () => { const allowance = new BigNumber(1); - await erc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, allowance, { + await erc20Token.approve(erc20Proxy.address, allowance).awaitTransactionSuccessAsync({ from: tokenOwnerAddress, }); - const assetData = await libAssetData.encodeERC20AssetData.callAsync(erc20Token.address); + const assetData = await libAssetData.encodeERC20AssetData(erc20Token.address).callAsync(); expect( - await libAssetData.getBatchBalancesAndAssetProxyAllowances.callAsync(tokenOwnerAddress, [assetData]), + await libAssetData.getBatchBalancesAndAssetProxyAllowances(tokenOwnerAddress, [assetData]).callAsync(), ).to.deep.equal([[new BigNumber(erc20TokenTotalSupply)], [allowance]]); }); }); @@ -595,22 +595,20 @@ describe('LibAssetData', () => { describe('getBatchAssetProxyAllowances', () => { it('should query allowances for a batch of asset data strings', async () => { const allowance = new BigNumber(1); - await erc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, allowance, { + await erc20Token.approve(erc20Proxy.address, allowance).awaitTransactionSuccessAsync({ from: tokenOwnerAddress, }); - await erc721Token.approve.awaitTransactionSuccessAsync(erc721Proxy.address, firstERC721TokenId, { + await erc721Token.approve(erc721Proxy.address, firstERC721TokenId).awaitTransactionSuccessAsync({ from: tokenOwnerAddress, }); - const erc20AssetData = await libAssetData.encodeERC20AssetData.callAsync(erc20Token.address); - const erc721AssetData = await libAssetData.encodeERC721AssetData.callAsync( - erc721Token.address, - firstERC721TokenId, - ); + const erc20AssetData = await libAssetData.encodeERC20AssetData(erc20Token.address).callAsync(); + const erc721AssetData = await libAssetData + .encodeERC721AssetData(erc721Token.address, firstERC721TokenId) + .callAsync(); expect( - await libAssetData.getBatchAssetProxyAllowances.callAsync(tokenOwnerAddress, [ - erc20AssetData, - erc721AssetData, - ]), + await libAssetData + .getBatchAssetProxyAllowances(tokenOwnerAddress, [erc20AssetData, erc721AssetData]) + .callAsync(), ).to.deep.equal([new BigNumber(1), new BigNumber(1)]); }); }); diff --git a/contracts/tests/test/dev-utils/lib_transaction_decoder.ts b/contracts/tests/test/dev-utils/lib_transaction_decoder.ts index 9fe5ee13d6..f0cbeb08fb 100644 --- a/contracts/tests/test/dev-utils/lib_transaction_decoder.ts +++ b/contracts/tests/test/dev-utils/lib_transaction_decoder.ts @@ -47,8 +47,8 @@ describe('LibTransactionDecoder', () => { }); it('should decode an Exchange.batchCancelOrders() transaction', async () => { - const input = exchangeInterface.batchCancelOrders.getABIEncodedTransactionData([order, order]); - expect(await libTxDecoder.decodeZeroExTransactionData.callAsync(input)).to.deep.equal([ + const input = exchangeInterface.batchCancelOrders([order, order]).getABIEncodedTransactionData(); + expect(await libTxDecoder.decodeZeroExTransactionData(input).callAsync()).to.deep.equal([ 'batchCancelOrders', [order, order], [], @@ -57,13 +57,11 @@ describe('LibTransactionDecoder', () => { }); for (const func of ['batchFillOrders', 'batchFillOrdersNoThrow', 'batchFillOrKillOrders']) { - const input = (exchangeInterface as any)[func].getABIEncodedTransactionData( - [order, order], - [takerAssetFillAmount, takerAssetFillAmount], - [signature, signature], - ); + const input = (exchangeInterface as any) + [func]([order, order], [takerAssetFillAmount, takerAssetFillAmount], [signature, signature]) + .getABIEncodedTransactionData(); it(`should decode an Exchange.${func}() transaction`, async () => { - expect(await libTxDecoder.decodeZeroExTransactionData.callAsync(input)).to.deep.equal([ + expect(await libTxDecoder.decodeZeroExTransactionData(input).callAsync()).to.deep.equal([ func, [order, order], [takerAssetFillAmount, takerAssetFillAmount], @@ -73,8 +71,8 @@ describe('LibTransactionDecoder', () => { } it('should decode an Exchange.cancelOrder() transaction', async () => { - const input = exchangeInterface.cancelOrder.getABIEncodedTransactionData(order); - expect(await libTxDecoder.decodeZeroExTransactionData.callAsync(input)).to.deep.equal([ + const input = exchangeInterface.cancelOrder(order).getABIEncodedTransactionData(); + expect(await libTxDecoder.decodeZeroExTransactionData(input).callAsync()).to.deep.equal([ 'cancelOrder', [order], [], @@ -83,13 +81,11 @@ describe('LibTransactionDecoder', () => { }); for (const func of ['fillOrder', 'fillOrKillOrder']) { - const input = (exchangeInterface as any)[func].getABIEncodedTransactionData( - order, - takerAssetFillAmount, - signature, - ); + const input = (exchangeInterface as any) + [func](order, takerAssetFillAmount, signature) + .getABIEncodedTransactionData(); it(`should decode an Exchange.${func}() transaction`, async () => { - expect(await libTxDecoder.decodeZeroExTransactionData.callAsync(input)).to.deep.equal([ + expect(await libTxDecoder.decodeZeroExTransactionData(input).callAsync()).to.deep.equal([ func, [order], [takerAssetFillAmount], @@ -104,13 +100,11 @@ describe('LibTransactionDecoder', () => { 'marketBuyOrdersFillOrKill', 'marketSellOrdersFillOrKill', ]) { - const input = (exchangeInterface as any)[func].getABIEncodedTransactionData( - [order, order], - takerAssetFillAmount, - [signature, signature], - ); + const input = (exchangeInterface as any) + [func]([order, order], takerAssetFillAmount, [signature, signature]) + .getABIEncodedTransactionData(); it(`should decode an Exchange.${func}() transaction`, async () => { - expect(await libTxDecoder.decodeZeroExTransactionData.callAsync(input)).to.deep.equal([ + expect(await libTxDecoder.decodeZeroExTransactionData(input).callAsync()).to.deep.equal([ func, [order, order], [takerAssetFillAmount], @@ -133,13 +127,10 @@ describe('LibTransactionDecoder', () => { makerFeeAssetData: order.takerFeeAssetData, takerFeeAssetData: order.makerFeeAssetData, }; - const input = exchangeInterface.matchOrders.getABIEncodedTransactionData( - order, - complementaryOrder, - signature, - signature, - ); - expect(await libTxDecoder.decodeZeroExTransactionData.callAsync(input)).to.deep.equal([ + const input = exchangeInterface + .matchOrders(order, complementaryOrder, signature, signature) + .getABIEncodedTransactionData(); + expect(await libTxDecoder.decodeZeroExTransactionData(input).callAsync()).to.deep.equal([ 'matchOrders', [order, complementaryOrder], [order.takerAssetAmount, complementaryOrder.takerAssetAmount], diff --git a/contracts/tests/test/dev-utils/order_validation_utils.ts b/contracts/tests/test/dev-utils/order_validation_utils.ts index 05f5ea8da5..aca3010448 100644 --- a/contracts/tests/test/dev-utils/order_validation_utils.ts +++ b/contracts/tests/test/dev-utils/order_validation_utils.ts @@ -97,8 +97,8 @@ describe('OrderValidationUtils/OrderTransferSimulatorUtils', () => { await exchangeWrapper.registerAssetProxyAsync(erc20Proxy.address, owner); await exchangeWrapper.registerAssetProxyAsync(erc721Proxy.address, owner); await exchangeWrapper.registerAssetProxyAsync(multiAssetProxy.address, owner); - await erc20Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(exchange.address, { from: owner }); - await erc721Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(exchange.address, { from: owner }); + await erc20Proxy.addAuthorizedAddress(exchange.address).awaitTransactionSuccessAsync({ from: owner }); + await erc721Proxy.addAuthorizedAddress(exchange.address).awaitTransactionSuccessAsync({ from: owner }); devUtils = await DevUtilsContract.deployFrom0xArtifactAsync( artifacts.DevUtils, @@ -108,10 +108,10 @@ describe('OrderValidationUtils/OrderTransferSimulatorUtils', () => { exchange.address, ); - feeAssetData = await devUtils.encodeERC20AssetData.callAsync(feeErc20Token.address); - erc20AssetData = await devUtils.encodeERC20AssetData.callAsync(erc20Token.address); - erc20AssetData2 = await devUtils.encodeERC20AssetData.callAsync(erc20Token2.address); - erc721AssetData = await devUtils.encodeERC721AssetData.callAsync(erc721Token.address, tokenId); + feeAssetData = await devUtils.encodeERC20AssetData(feeErc20Token.address).callAsync(); + erc20AssetData = await devUtils.encodeERC20AssetData(erc20Token.address).callAsync(); + erc20AssetData2 = await devUtils.encodeERC20AssetData(erc20Token2.address).callAsync(); + erc721AssetData = await devUtils.encodeERC721AssetData(erc721Token.address, tokenId).callAsync(); const defaultOrderParams = { ...constants.STATIC_ORDER_PARAMS, makerAddress, @@ -138,48 +138,44 @@ describe('OrderValidationUtils/OrderTransferSimulatorUtils', () => { it('should return the balance when balance < allowance', async () => { const balance = new BigNumber(123); const allowance = new BigNumber(456); - await erc20Token.setBalance.awaitTransactionSuccessAsync(makerAddress, balance); - await erc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, allowance, { + await erc20Token.setBalance(makerAddress, balance).awaitTransactionSuccessAsync(); + await erc20Token.approve(erc20Proxy.address, allowance).awaitTransactionSuccessAsync({ from: makerAddress, }); - const transferableAmount = await devUtils.getTransferableAssetAmount.callAsync( - makerAddress, - erc20AssetData, - ); + const transferableAmount = await devUtils + .getTransferableAssetAmount(makerAddress, erc20AssetData) + .callAsync(); expect(transferableAmount).to.bignumber.equal(balance); }); it('should return the allowance when allowance < balance', async () => { const balance = new BigNumber(456); const allowance = new BigNumber(123); - await erc20Token.setBalance.awaitTransactionSuccessAsync(makerAddress, balance); - await erc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, allowance, { + await erc20Token.setBalance(makerAddress, balance).awaitTransactionSuccessAsync(); + await erc20Token.approve(erc20Proxy.address, allowance).awaitTransactionSuccessAsync({ from: makerAddress, }); - const transferableAmount = await devUtils.getTransferableAssetAmount.callAsync( - makerAddress, - erc20AssetData, - ); + const transferableAmount = await devUtils + .getTransferableAssetAmount(makerAddress, erc20AssetData) + .callAsync(); expect(transferableAmount).to.bignumber.equal(allowance); }); it('should return the correct transferable amount for multiAssetData', async () => { - const multiAssetData = await devUtils.encodeMultiAssetData.callAsync( - [new BigNumber(1), new BigNumber(1)], - [erc20AssetData, erc20AssetData2], - ); + const multiAssetData = await devUtils + .encodeMultiAssetData([new BigNumber(1), new BigNumber(1)], [erc20AssetData, erc20AssetData2]) + .callAsync(); const transferableAmount1 = new BigNumber(10); const transferableAmount2 = new BigNumber(5); - await erc20Token.setBalance.awaitTransactionSuccessAsync(makerAddress, transferableAmount1); - await erc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, transferableAmount1, { + await erc20Token.setBalance(makerAddress, transferableAmount1).awaitTransactionSuccessAsync(); + await erc20Token.approve(erc20Proxy.address, transferableAmount1).awaitTransactionSuccessAsync({ from: makerAddress, }); - await erc20Token2.setBalance.awaitTransactionSuccessAsync(makerAddress, transferableAmount2); - await erc20Token2.approve.awaitTransactionSuccessAsync(erc20Proxy.address, transferableAmount2, { + await erc20Token2.setBalance(makerAddress, transferableAmount2).awaitTransactionSuccessAsync(); + await erc20Token2.approve(erc20Proxy.address, transferableAmount2).awaitTransactionSuccessAsync({ from: makerAddress, }); - const transferableAmount = await devUtils.getTransferableAssetAmount.callAsync( - makerAddress, - multiAssetData, - ); + const transferableAmount = await devUtils + .getTransferableAssetAmount(makerAddress, multiAssetData) + .callAsync(); expect(transferableAmount).to.bignumber.equal(transferableAmount2); }); }); @@ -188,160 +184,143 @@ describe('OrderValidationUtils/OrderTransferSimulatorUtils', () => { signedOrder = await orderFactory.newSignedOrderAsync(); }); it('should return the correct orderInfo when the order is valid', async () => { - const [orderInfo] = await devUtils.getOrderRelevantState.callAsync(signedOrder, signedOrder.signature); + const [orderInfo] = await devUtils.getOrderRelevantState(signedOrder, signedOrder.signature).callAsync(); expect(orderInfo.orderHash).to.equal(orderHashUtils.getOrderHashHex(signedOrder)); expect(orderInfo.orderStatus).to.equal(OrderStatus.Fillable); expect(orderInfo.orderTakerAssetFilledAmount).to.bignumber.equal(constants.ZERO_AMOUNT); }); it('should return isValidSignature=true when the signature is valid', async () => { - const [, , isValidSignature] = await devUtils.getOrderRelevantState.callAsync( - signedOrder, - signedOrder.signature, - ); + const [, , isValidSignature] = await devUtils + .getOrderRelevantState(signedOrder, signedOrder.signature) + .callAsync(); expect(isValidSignature).to.equal(true); }); it('should return isValidSignature=false when the signature is invalid', async () => { const invalidSignature = '0x01'; - const [, , isValidSignature] = await devUtils.getOrderRelevantState.callAsync( - signedOrder, - invalidSignature, - ); + const [, , isValidSignature] = await devUtils + .getOrderRelevantState(signedOrder, invalidSignature) + .callAsync(); expect(isValidSignature).to.equal(false); }); it('should return a fillableTakerAssetAmount of 0 when balances or allowances are insufficient', async () => { - const [, fillableTakerAssetAmount] = await devUtils.getOrderRelevantState.callAsync( - signedOrder, - signedOrder.signature, - ); + const [, fillableTakerAssetAmount] = await devUtils + .getOrderRelevantState(signedOrder, signedOrder.signature) + .callAsync(); expect(fillableTakerAssetAmount).to.bignumber.equal(constants.ZERO_AMOUNT); }); it('should return a fillableTakerAssetAmount of 0 when fee balances/allowances are insufficient', async () => { - await erc20Token.setBalance.awaitTransactionSuccessAsync(makerAddress, signedOrder.makerAssetAmount); - await erc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.makerAssetAmount, { + await erc20Token.setBalance(makerAddress, signedOrder.makerAssetAmount).awaitTransactionSuccessAsync(); + await erc20Token.approve(erc20Proxy.address, signedOrder.makerAssetAmount).awaitTransactionSuccessAsync({ from: makerAddress, }); - const [, fillableTakerAssetAmount] = await devUtils.getOrderRelevantState.callAsync( - signedOrder, - signedOrder.signature, - ); + const [, fillableTakerAssetAmount] = await devUtils + .getOrderRelevantState(signedOrder, signedOrder.signature) + .callAsync(); expect(fillableTakerAssetAmount).to.bignumber.equal(constants.ZERO_AMOUNT); }); it('should return a fillableTakerAssetAmount of 0 when balances/allowances of one asset within a multiAssetData are insufficient', async () => { - const multiAssetData = await devUtils.encodeMultiAssetData.callAsync( - [new BigNumber(1), new BigNumber(1)], - [erc20AssetData, erc20AssetData2], - ); + const multiAssetData = await devUtils + .encodeMultiAssetData([new BigNumber(1), new BigNumber(1)], [erc20AssetData, erc20AssetData2]) + .callAsync(); signedOrder = await orderFactory.newSignedOrderAsync({ makerAssetData: multiAssetData }); - await erc20Token.setBalance.awaitTransactionSuccessAsync(makerAddress, signedOrder.makerAssetAmount); - await erc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.makerAssetAmount, { + await erc20Token.setBalance(makerAddress, signedOrder.makerAssetAmount).awaitTransactionSuccessAsync(); + await erc20Token.approve(erc20Proxy.address, signedOrder.makerAssetAmount).awaitTransactionSuccessAsync({ from: makerAddress, }); - const [, fillableTakerAssetAmount] = await devUtils.getOrderRelevantState.callAsync( - signedOrder, - signedOrder.signature, - ); + const [, fillableTakerAssetAmount] = await devUtils + .getOrderRelevantState(signedOrder, signedOrder.signature) + .callAsync(); expect(fillableTakerAssetAmount).to.bignumber.equal(constants.ZERO_AMOUNT); }); it('should return the correct fillableTakerAssetAmount when fee balances/allowances are partially sufficient', async () => { - await erc20Token.setBalance.awaitTransactionSuccessAsync(makerAddress, signedOrder.makerAssetAmount); - await erc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.makerAssetAmount, { + await erc20Token.setBalance(makerAddress, signedOrder.makerAssetAmount).awaitTransactionSuccessAsync(); + await erc20Token.approve(erc20Proxy.address, signedOrder.makerAssetAmount).awaitTransactionSuccessAsync({ from: makerAddress, }); const divisor = 4; - await feeErc20Token.setBalance.awaitTransactionSuccessAsync( - makerAddress, - signedOrder.makerFee.dividedToIntegerBy(divisor), - ); - await feeErc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.makerFee, { + await feeErc20Token + .setBalance(makerAddress, signedOrder.makerFee.dividedToIntegerBy(divisor)) + .awaitTransactionSuccessAsync(); + await feeErc20Token.approve(erc20Proxy.address, signedOrder.makerFee).awaitTransactionSuccessAsync({ from: makerAddress, }); - const [, fillableTakerAssetAmount] = await devUtils.getOrderRelevantState.callAsync( - signedOrder, - signedOrder.signature, - ); + const [, fillableTakerAssetAmount] = await devUtils + .getOrderRelevantState(signedOrder, signedOrder.signature) + .callAsync(); expect(fillableTakerAssetAmount).to.bignumber.equal( signedOrder.takerAssetAmount.dividedToIntegerBy(divisor), ); }); it('should return the correct fillableTakerAssetAmount when non-fee balances/allowances are partially sufficient', async () => { const divisor = 4; - await erc20Token.setBalance.awaitTransactionSuccessAsync( - makerAddress, - signedOrder.makerAssetAmount.dividedToIntegerBy(divisor), - ); - await erc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.makerAssetAmount, { + await erc20Token + .setBalance(makerAddress, signedOrder.makerAssetAmount.dividedToIntegerBy(divisor)) + .awaitTransactionSuccessAsync(); + await erc20Token.approve(erc20Proxy.address, signedOrder.makerAssetAmount).awaitTransactionSuccessAsync({ from: makerAddress, }); - await feeErc20Token.setBalance.awaitTransactionSuccessAsync(makerAddress, signedOrder.makerFee); - await feeErc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.makerFee, { + await feeErc20Token.setBalance(makerAddress, signedOrder.makerFee).awaitTransactionSuccessAsync(); + await feeErc20Token.approve(erc20Proxy.address, signedOrder.makerFee).awaitTransactionSuccessAsync({ from: makerAddress, }); - const [, fillableTakerAssetAmount] = await devUtils.getOrderRelevantState.callAsync( - signedOrder, - signedOrder.signature, - ); + const [, fillableTakerAssetAmount] = await devUtils + .getOrderRelevantState(signedOrder, signedOrder.signature) + .callAsync(); expect(fillableTakerAssetAmount).to.bignumber.equal( signedOrder.takerAssetAmount.dividedToIntegerBy(divisor), ); }); it('should return the correct fillableTakerAssetAmount when balances/allowances of one asset within a multiAssetData are partially sufficient', async () => { - const multiAssetData = await devUtils.encodeMultiAssetData.callAsync( - [new BigNumber(1), new BigNumber(1)], - [erc20AssetData, erc20AssetData2], - ); + const multiAssetData = await devUtils + .encodeMultiAssetData([new BigNumber(1), new BigNumber(1)], [erc20AssetData, erc20AssetData2]) + .callAsync(); signedOrder = await orderFactory.newSignedOrderAsync({ makerAssetData: multiAssetData }); - await erc20Token.setBalance.awaitTransactionSuccessAsync(makerAddress, signedOrder.makerAssetAmount); - await erc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.makerAssetAmount, { + await erc20Token.setBalance(makerAddress, signedOrder.makerAssetAmount).awaitTransactionSuccessAsync(); + await erc20Token.approve(erc20Proxy.address, signedOrder.makerAssetAmount).awaitTransactionSuccessAsync({ from: makerAddress, }); - await feeErc20Token.setBalance.awaitTransactionSuccessAsync(makerAddress, signedOrder.makerFee); - await feeErc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.makerFee, { + await feeErc20Token.setBalance(makerAddress, signedOrder.makerFee).awaitTransactionSuccessAsync(); + await feeErc20Token.approve(erc20Proxy.address, signedOrder.makerFee).awaitTransactionSuccessAsync({ from: makerAddress, }); const divisor = 4; - await erc20Token2.setBalance.awaitTransactionSuccessAsync( - makerAddress, - signedOrder.makerAssetAmount.dividedToIntegerBy(divisor), - ); - await erc20Token2.approve.awaitTransactionSuccessAsync( - erc20Proxy.address, - signedOrder.makerAssetAmount.dividedToIntegerBy(divisor), - { + await erc20Token2 + .setBalance(makerAddress, signedOrder.makerAssetAmount.dividedToIntegerBy(divisor)) + .awaitTransactionSuccessAsync(); + await erc20Token2 + .approve(erc20Proxy.address, signedOrder.makerAssetAmount.dividedToIntegerBy(divisor)) + .awaitTransactionSuccessAsync({ from: makerAddress, - }, - ); - const [, fillableTakerAssetAmount] = await devUtils.getOrderRelevantState.callAsync( - signedOrder, - signedOrder.signature, - ); + }); + const [, fillableTakerAssetAmount] = await devUtils + .getOrderRelevantState(signedOrder, signedOrder.signature) + .callAsync(); expect(fillableTakerAssetAmount).to.bignumber.equal( signedOrder.takerAssetAmount.dividedToIntegerBy(divisor), ); }); it('should return a fillableTakerAssetAmount of 0 when non-fee balances/allowances are insufficient', async () => { - await feeErc20Token.setBalance.awaitTransactionSuccessAsync(makerAddress, signedOrder.makerFee); - await feeErc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.makerFee, { + await feeErc20Token.setBalance(makerAddress, signedOrder.makerFee).awaitTransactionSuccessAsync(); + await feeErc20Token.approve(erc20Proxy.address, signedOrder.makerFee).awaitTransactionSuccessAsync({ from: makerAddress, }); - const [, fillableTakerAssetAmount] = await devUtils.getOrderRelevantState.callAsync( - signedOrder, - signedOrder.signature, - ); + const [, fillableTakerAssetAmount] = await devUtils + .getOrderRelevantState(signedOrder, signedOrder.signature) + .callAsync(); expect(fillableTakerAssetAmount).to.bignumber.equal(constants.ZERO_AMOUNT); }); it('should return a fillableTakerAssetAmount equal to the takerAssetAmount when the order is unfilled and balances/allowances are sufficient', async () => { - await erc20Token.setBalance.awaitTransactionSuccessAsync(makerAddress, signedOrder.makerAssetAmount); - await erc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.makerAssetAmount, { + await erc20Token.setBalance(makerAddress, signedOrder.makerAssetAmount).awaitTransactionSuccessAsync(); + await erc20Token.approve(erc20Proxy.address, signedOrder.makerAssetAmount).awaitTransactionSuccessAsync({ from: makerAddress, }); - await feeErc20Token.setBalance.awaitTransactionSuccessAsync(makerAddress, signedOrder.makerFee); - await feeErc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.makerFee, { + await feeErc20Token.setBalance(makerAddress, signedOrder.makerFee).awaitTransactionSuccessAsync(); + await feeErc20Token.approve(erc20Proxy.address, signedOrder.makerFee).awaitTransactionSuccessAsync({ from: makerAddress, }); - const [, fillableTakerAssetAmount] = await devUtils.getOrderRelevantState.callAsync( - signedOrder, - signedOrder.signature, - ); + const [, fillableTakerAssetAmount] = await devUtils + .getOrderRelevantState(signedOrder, signedOrder.signature) + .callAsync(); expect(fillableTakerAssetAmount).to.bignumber.equal(signedOrder.takerAssetAmount); }); it('should return the correct fillableTakerAssetAmount when balances/allowances are partially sufficient and makerAsset=makerFeeAsset', async () => { @@ -352,60 +331,54 @@ describe('OrderValidationUtils/OrderTransferSimulatorUtils', () => { makerFee: new BigNumber(40), }); const transferableMakerAssetAmount = new BigNumber(10); - await feeErc20Token.setBalance.awaitTransactionSuccessAsync(makerAddress, transferableMakerAssetAmount); - await feeErc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, transferableMakerAssetAmount, { + await feeErc20Token.setBalance(makerAddress, transferableMakerAssetAmount).awaitTransactionSuccessAsync(); + await feeErc20Token.approve(erc20Proxy.address, transferableMakerAssetAmount).awaitTransactionSuccessAsync({ from: makerAddress, }); const expectedFillableTakerAssetAmount = transferableMakerAssetAmount .times(signedOrder.takerAssetAmount) .dividedToIntegerBy(signedOrder.makerAssetAmount.plus(signedOrder.makerFee)); - const [, fillableTakerAssetAmount] = await devUtils.getOrderRelevantState.callAsync( - signedOrder, - signedOrder.signature, - ); + const [, fillableTakerAssetAmount] = await devUtils + .getOrderRelevantState(signedOrder, signedOrder.signature) + .callAsync(); expect(fillableTakerAssetAmount).to.bignumber.equal(expectedFillableTakerAssetAmount); }); it('should return the correct fillabeTakerassetAmount when makerAsset balances/allowances are sufficient and there are no maker fees', async () => { signedOrder = await orderFactory.newSignedOrderAsync({ makerFee: constants.ZERO_AMOUNT }); - await erc20Token.setBalance.awaitTransactionSuccessAsync(makerAddress, signedOrder.makerAssetAmount); - await erc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.makerAssetAmount, { + await erc20Token.setBalance(makerAddress, signedOrder.makerAssetAmount).awaitTransactionSuccessAsync(); + await erc20Token.approve(erc20Proxy.address, signedOrder.makerAssetAmount).awaitTransactionSuccessAsync({ from: makerAddress, }); - const [, fillableTakerAssetAmount] = await devUtils.getOrderRelevantState.callAsync( - signedOrder, - signedOrder.signature, - ); + const [, fillableTakerAssetAmount] = await devUtils + .getOrderRelevantState(signedOrder, signedOrder.signature) + .callAsync(); expect(fillableTakerAssetAmount).to.bignumber.equal(signedOrder.takerAssetAmount); }); it('should return a fillableTakerAssetAmount when the remaining takerAssetAmount is less than the transferable amount', async () => { - await erc20Token.setBalance.awaitTransactionSuccessAsync(makerAddress, signedOrder.makerAssetAmount); - await erc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.makerAssetAmount, { + await erc20Token.setBalance(makerAddress, signedOrder.makerAssetAmount).awaitTransactionSuccessAsync(); + await erc20Token.approve(erc20Proxy.address, signedOrder.makerAssetAmount).awaitTransactionSuccessAsync({ from: makerAddress, }); - await feeErc20Token.setBalance.awaitTransactionSuccessAsync(makerAddress, signedOrder.makerFee); - await feeErc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.makerFee, { + await feeErc20Token.setBalance(makerAddress, signedOrder.makerFee).awaitTransactionSuccessAsync(); + await feeErc20Token.approve(erc20Proxy.address, signedOrder.makerFee).awaitTransactionSuccessAsync({ from: makerAddress, }); - await erc20Token2.setBalance.awaitTransactionSuccessAsync(takerAddress, signedOrder.takerAssetAmount); - await erc20Token2.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.takerAssetAmount, { + await erc20Token2.setBalance(takerAddress, signedOrder.takerAssetAmount).awaitTransactionSuccessAsync(); + await erc20Token2.approve(erc20Proxy.address, signedOrder.takerAssetAmount).awaitTransactionSuccessAsync({ from: takerAddress, }); - await feeErc20Token.setBalance.awaitTransactionSuccessAsync(takerAddress, signedOrder.takerFee); + await feeErc20Token.setBalance(takerAddress, signedOrder.takerFee).awaitTransactionSuccessAsync(); - await feeErc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.takerFee, { + await feeErc20Token.approve(erc20Proxy.address, signedOrder.takerFee).awaitTransactionSuccessAsync({ from: takerAddress, }); const takerAssetFillAmount = signedOrder.takerAssetAmount.dividedToIntegerBy(4); - await exchange.fillOrder.awaitTransactionSuccessAsync( - signedOrder, - takerAssetFillAmount, - signedOrder.signature, - { from: takerAddress }, - ); - const [, fillableTakerAssetAmount] = await devUtils.getOrderRelevantState.callAsync( - signedOrder, - signedOrder.signature, - ); + await exchange + .fillOrder(signedOrder, takerAssetFillAmount, signedOrder.signature) + .awaitTransactionSuccessAsync({ from: takerAddress }); + const [, fillableTakerAssetAmount] = await devUtils + .getOrderRelevantState(signedOrder, signedOrder.signature) + .callAsync(); expect(fillableTakerAssetAmount).to.bignumber.equal( signedOrder.takerAssetAmount.minus(takerAssetFillAmount), ); @@ -417,15 +390,13 @@ describe('OrderValidationUtils/OrderTransferSimulatorUtils', () => { makerFeeAssetData: '0x', takerFeeAssetData: '0x', }); - await erc20Token.setBalance.awaitTransactionSuccessAsync(makerAddress, signedOrder.makerAssetAmount); - await erc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.makerAssetAmount, { + await erc20Token.setBalance(makerAddress, signedOrder.makerAssetAmount).awaitTransactionSuccessAsync(); + await erc20Token.approve(erc20Proxy.address, signedOrder.makerAssetAmount).awaitTransactionSuccessAsync({ from: makerAddress, }); - const [ - orderInfo, - fillableTakerAssetAmount, - isValidSignature, - ] = await devUtils.getOrderRelevantState.callAsync(signedOrder, signedOrder.signature); + const [orderInfo, fillableTakerAssetAmount, isValidSignature] = await devUtils + .getOrderRelevantState(signedOrder, signedOrder.signature) + .callAsync(); expect(orderInfo.orderHash).to.equal(orderHashUtils.getOrderHashHex(signedOrder)); expect(orderInfo.orderStatus).to.equal(OrderStatus.Fillable); expect(orderInfo.orderTakerAssetFilledAmount).to.bignumber.equal(constants.ZERO_AMOUNT); @@ -436,25 +407,20 @@ describe('OrderValidationUtils/OrderTransferSimulatorUtils', () => { describe('getOrderRelevantStates', async () => { it('should return the correct information for multiple orders', async () => { signedOrder = await orderFactory.newSignedOrderAsync(); - await erc20Token.setBalance.awaitTransactionSuccessAsync(makerAddress, signedOrder.makerAssetAmount); - await erc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.makerAssetAmount, { + await erc20Token.setBalance(makerAddress, signedOrder.makerAssetAmount).awaitTransactionSuccessAsync(); + await erc20Token.approve(erc20Proxy.address, signedOrder.makerAssetAmount).awaitTransactionSuccessAsync({ from: makerAddress, }); - await feeErc20Token.setBalance.awaitTransactionSuccessAsync(makerAddress, signedOrder.makerFee); - await feeErc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.makerFee, { + await feeErc20Token.setBalance(makerAddress, signedOrder.makerFee).awaitTransactionSuccessAsync(); + await feeErc20Token.approve(erc20Proxy.address, signedOrder.makerFee).awaitTransactionSuccessAsync({ from: makerAddress, }); const signedOrder2 = await orderFactory.newSignedOrderAsync({ makerAssetData: erc721AssetData }); const invalidSignature = '0x01'; - await exchange.cancelOrder.awaitTransactionSuccessAsync(signedOrder2, { from: makerAddress }); - const [ - ordersInfo, - fillableTakerAssetAmounts, - isValidSignature, - ] = await devUtils.getOrderRelevantStates.callAsync( - [signedOrder, signedOrder2], - [signedOrder.signature, invalidSignature], - ); + await exchange.cancelOrder(signedOrder2).awaitTransactionSuccessAsync({ from: makerAddress }); + const [ordersInfo, fillableTakerAssetAmounts, isValidSignature] = await devUtils + .getOrderRelevantStates([signedOrder, signedOrder2], [signedOrder.signature, invalidSignature]) + .callAsync(); expect(ordersInfo[0].orderHash).to.equal(orderHashUtils.getOrderHashHex(signedOrder)); expect(ordersInfo[1].orderHash).to.equal(orderHashUtils.getOrderHashHex(signedOrder2)); expect(ordersInfo[0].orderStatus).to.equal(OrderStatus.Fillable); @@ -472,177 +438,162 @@ describe('OrderValidationUtils/OrderTransferSimulatorUtils', () => { signedOrder = await orderFactory.newSignedOrderAsync(); }); it('should return TakerAssetDataFailed if the takerAsset transfer fails', async () => { - const orderTransferResults = await devUtils.getSimulatedOrderTransferResults.callAsync( - signedOrder, - takerAddress, - signedOrder.takerAssetAmount, - ); + const orderTransferResults = await devUtils + .getSimulatedOrderTransferResults(signedOrder, takerAddress, signedOrder.takerAssetAmount) + .callAsync(); expect(orderTransferResults).to.equal(OrderTransferResults.TakerAssetDataFailed); }); it('should return MakerAssetDataFailed if the makerAsset transfer fails', async () => { - await erc20Token2.setBalance.awaitTransactionSuccessAsync(takerAddress, signedOrder.takerAssetAmount, { + await erc20Token2.setBalance(takerAddress, signedOrder.takerAssetAmount).awaitTransactionSuccessAsync({ from: owner, }); - await erc20Token2.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.takerAssetAmount, { + await erc20Token2.approve(erc20Proxy.address, signedOrder.takerAssetAmount).awaitTransactionSuccessAsync({ from: takerAddress, }); - const orderTransferResults = await devUtils.getSimulatedOrderTransferResults.callAsync( - signedOrder, - takerAddress, - signedOrder.takerAssetAmount, - ); + const orderTransferResults = await devUtils + .getSimulatedOrderTransferResults(signedOrder, takerAddress, signedOrder.takerAssetAmount) + .callAsync(); expect(orderTransferResults).to.equal(OrderTransferResults.MakerAssetDataFailed); }); it('should return TakerFeeAssetDataFailed if the takerFeeAsset transfer fails', async () => { - await erc20Token2.setBalance.awaitTransactionSuccessAsync(takerAddress, signedOrder.takerAssetAmount, { + await erc20Token2.setBalance(takerAddress, signedOrder.takerAssetAmount).awaitTransactionSuccessAsync({ from: owner, }); - await erc20Token2.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.takerAssetAmount, { + await erc20Token2.approve(erc20Proxy.address, signedOrder.takerAssetAmount).awaitTransactionSuccessAsync({ from: takerAddress, }); - await erc20Token.setBalance.awaitTransactionSuccessAsync(makerAddress, signedOrder.makerAssetAmount, { + await erc20Token.setBalance(makerAddress, signedOrder.makerAssetAmount).awaitTransactionSuccessAsync({ from: owner, }); - await erc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.makerAssetAmount, { + await erc20Token.approve(erc20Proxy.address, signedOrder.makerAssetAmount).awaitTransactionSuccessAsync({ from: makerAddress, }); - const orderTransferResults = await devUtils.getSimulatedOrderTransferResults.callAsync( - signedOrder, - takerAddress, - signedOrder.takerAssetAmount, - ); + const orderTransferResults = await devUtils + .getSimulatedOrderTransferResults(signedOrder, takerAddress, signedOrder.takerAssetAmount) + .callAsync(); expect(orderTransferResults).to.equal(OrderTransferResults.TakerFeeAssetDataFailed); }); it('should return MakerFeeAssetDataFailed if the makerFeeAsset transfer fails', async () => { - await erc20Token2.setBalance.awaitTransactionSuccessAsync(takerAddress, signedOrder.takerAssetAmount, { + await erc20Token2.setBalance(takerAddress, signedOrder.takerAssetAmount).awaitTransactionSuccessAsync({ from: owner, }); - await erc20Token2.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.takerAssetAmount, { + await erc20Token2.approve(erc20Proxy.address, signedOrder.takerAssetAmount).awaitTransactionSuccessAsync({ from: takerAddress, }); - await erc20Token.setBalance.awaitTransactionSuccessAsync(makerAddress, signedOrder.makerAssetAmount, { + await erc20Token.setBalance(makerAddress, signedOrder.makerAssetAmount).awaitTransactionSuccessAsync({ from: owner, }); - await erc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.makerAssetAmount, { + await erc20Token.approve(erc20Proxy.address, signedOrder.makerAssetAmount).awaitTransactionSuccessAsync({ from: makerAddress, }); - await feeErc20Token.setBalance.awaitTransactionSuccessAsync(takerAddress, signedOrder.takerFee, { + await feeErc20Token.setBalance(takerAddress, signedOrder.takerFee).awaitTransactionSuccessAsync({ from: owner, }); - await feeErc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.takerFee, { + await feeErc20Token.approve(erc20Proxy.address, signedOrder.takerFee).awaitTransactionSuccessAsync({ from: takerAddress, }); - const orderTransferResults = await devUtils.getSimulatedOrderTransferResults.callAsync( - signedOrder, - takerAddress, - signedOrder.takerAssetAmount, - ); + const orderTransferResults = await devUtils + .getSimulatedOrderTransferResults(signedOrder, takerAddress, signedOrder.takerAssetAmount) + .callAsync(); expect(orderTransferResults).to.equal(OrderTransferResults.MakerFeeAssetDataFailed); }); it('should return TransfersSuccessful if all transfers succeed', async () => { - await erc20Token2.setBalance.awaitTransactionSuccessAsync(takerAddress, signedOrder.takerAssetAmount, { + await erc20Token2.setBalance(takerAddress, signedOrder.takerAssetAmount).awaitTransactionSuccessAsync({ from: owner, }); - await erc20Token2.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.takerAssetAmount, { + await erc20Token2.approve(erc20Proxy.address, signedOrder.takerAssetAmount).awaitTransactionSuccessAsync({ from: takerAddress, }); - await erc20Token.setBalance.awaitTransactionSuccessAsync(makerAddress, signedOrder.makerAssetAmount, { + await erc20Token.setBalance(makerAddress, signedOrder.makerAssetAmount).awaitTransactionSuccessAsync({ from: owner, }); - await erc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.makerAssetAmount, { + await erc20Token.approve(erc20Proxy.address, signedOrder.makerAssetAmount).awaitTransactionSuccessAsync({ from: makerAddress, }); - await feeErc20Token.setBalance.awaitTransactionSuccessAsync(takerAddress, signedOrder.takerFee, { + await feeErc20Token.setBalance(takerAddress, signedOrder.takerFee).awaitTransactionSuccessAsync({ from: owner, }); - await feeErc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.takerFee, { + await feeErc20Token.approve(erc20Proxy.address, signedOrder.takerFee).awaitTransactionSuccessAsync({ from: takerAddress, }); - await feeErc20Token.setBalance.awaitTransactionSuccessAsync(makerAddress, signedOrder.makerFee, { + await feeErc20Token.setBalance(makerAddress, signedOrder.makerFee).awaitTransactionSuccessAsync({ from: owner, }); - await feeErc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.makerFee, { + await feeErc20Token.approve(erc20Proxy.address, signedOrder.makerFee).awaitTransactionSuccessAsync({ from: makerAddress, }); - const orderTransferResults = await devUtils.getSimulatedOrderTransferResults.callAsync( - signedOrder, - takerAddress, - signedOrder.takerAssetAmount, - ); + const orderTransferResults = await devUtils + .getSimulatedOrderTransferResults(signedOrder, takerAddress, signedOrder.takerAssetAmount) + .callAsync(); expect(orderTransferResults).to.equal(OrderTransferResults.TransfersSuccessful); }); it('should return TransfersSuccessful for a partial fill when taker has ample assets for the fill but not for the whole order', async () => { - await erc20Token2.setBalance.awaitTransactionSuccessAsync( - takerAddress, - signedOrder.takerAssetAmount.dividedBy(2), - { + await erc20Token2 + .setBalance(takerAddress, signedOrder.takerAssetAmount.dividedBy(2)) + .awaitTransactionSuccessAsync({ from: owner, - }, - ); - await erc20Token2.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.takerAssetAmount, { + }); + await erc20Token2.approve(erc20Proxy.address, signedOrder.takerAssetAmount).awaitTransactionSuccessAsync({ from: takerAddress, }); - await erc20Token.setBalance.awaitTransactionSuccessAsync(makerAddress, signedOrder.makerAssetAmount, { + await erc20Token.setBalance(makerAddress, signedOrder.makerAssetAmount).awaitTransactionSuccessAsync({ from: owner, }); - await erc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.makerAssetAmount, { + await erc20Token.approve(erc20Proxy.address, signedOrder.makerAssetAmount).awaitTransactionSuccessAsync({ from: makerAddress, }); - await feeErc20Token.setBalance.awaitTransactionSuccessAsync(takerAddress, signedOrder.takerFee, { + await feeErc20Token.setBalance(takerAddress, signedOrder.takerFee).awaitTransactionSuccessAsync({ from: owner, }); - await feeErc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.takerFee, { + await feeErc20Token.approve(erc20Proxy.address, signedOrder.takerFee).awaitTransactionSuccessAsync({ from: takerAddress, }); - await feeErc20Token.setBalance.awaitTransactionSuccessAsync(makerAddress, signedOrder.makerFee, { + await feeErc20Token.setBalance(makerAddress, signedOrder.makerFee).awaitTransactionSuccessAsync({ from: owner, }); - await feeErc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.makerFee, { + await feeErc20Token.approve(erc20Proxy.address, signedOrder.makerFee).awaitTransactionSuccessAsync({ from: makerAddress, }); - const orderTransferResults = await devUtils.getSimulatedOrderTransferResults.callAsync( - signedOrder, - takerAddress, - signedOrder.takerAssetAmount.dividedBy(2), - ); + const orderTransferResults = await devUtils + .getSimulatedOrderTransferResults(signedOrder, takerAddress, signedOrder.takerAssetAmount.dividedBy(2)) + .callAsync(); expect(orderTransferResults).to.equal(OrderTransferResults.TransfersSuccessful); }); }); describe('getSimulatedOrdersTransferResults', async () => { it('should simulate the transfers of each order independently from one another', async () => { // Set balances and allowances to exactly enough to fill a single order - await erc20Token2.setBalance.awaitTransactionSuccessAsync(takerAddress, signedOrder.takerAssetAmount, { + await erc20Token2.setBalance(takerAddress, signedOrder.takerAssetAmount).awaitTransactionSuccessAsync({ from: owner, }); - await erc20Token2.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.takerAssetAmount, { + await erc20Token2.approve(erc20Proxy.address, signedOrder.takerAssetAmount).awaitTransactionSuccessAsync({ from: takerAddress, }); - await erc20Token.setBalance.awaitTransactionSuccessAsync(makerAddress, signedOrder.makerAssetAmount, { + await erc20Token.setBalance(makerAddress, signedOrder.makerAssetAmount).awaitTransactionSuccessAsync({ from: owner, }); - await erc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.makerAssetAmount, { + await erc20Token.approve(erc20Proxy.address, signedOrder.makerAssetAmount).awaitTransactionSuccessAsync({ from: makerAddress, }); - await feeErc20Token.setBalance.awaitTransactionSuccessAsync(takerAddress, signedOrder.takerFee, { + await feeErc20Token.setBalance(takerAddress, signedOrder.takerFee).awaitTransactionSuccessAsync({ from: owner, }); - await feeErc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.takerFee, { + await feeErc20Token.approve(erc20Proxy.address, signedOrder.takerFee).awaitTransactionSuccessAsync({ from: takerAddress, }); - await feeErc20Token.setBalance.awaitTransactionSuccessAsync(makerAddress, signedOrder.makerFee, { + await feeErc20Token.setBalance(makerAddress, signedOrder.makerFee).awaitTransactionSuccessAsync({ from: owner, }); - await feeErc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, signedOrder.makerFee, { + await feeErc20Token.approve(erc20Proxy.address, signedOrder.makerFee).awaitTransactionSuccessAsync({ from: makerAddress, }); - const [ - orderTransferResults1, - orderTransferResults2, - ] = await devUtils.getSimulatedOrdersTransferResults.callAsync( - [signedOrder, signedOrder], - [takerAddress, takerAddress], - [signedOrder.takerAssetAmount, signedOrder.takerAssetAmount], - ); + const [orderTransferResults1, orderTransferResults2] = await devUtils + .getSimulatedOrdersTransferResults( + [signedOrder, signedOrder], + [takerAddress, takerAddress], + [signedOrder.takerAssetAmount, signedOrder.takerAssetAmount], + ) + .callAsync(); expect(orderTransferResults1).to.equal(OrderTransferResults.TransfersSuccessful); expect(orderTransferResults2).to.equal(OrderTransferResults.TransfersSuccessful); }); diff --git a/contracts/utils/test/authorizable.ts b/contracts/utils/test/authorizable.ts index b2a1a46876..8d11c67f4f 100644 --- a/contracts/utils/test/authorizable.ts +++ b/contracts/utils/test/authorizable.ts @@ -46,68 +46,68 @@ describe('Authorizable', () => { describe('addAuthorizedAddress', () => { it('should revert if not called by owner', async () => { const expectedError = new OwnableRevertErrors.OnlyOwnerError(notOwner, owner); - const tx = authorizable.addAuthorizedAddress.sendTransactionAsync(notOwner, { from: notOwner }); + const tx = authorizable.addAuthorizedAddress(notOwner).sendTransactionAsync({ from: notOwner }); return expect(tx).to.revertWith(expectedError); }); it('should allow owner to add an authorized address', async () => { - await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner }); - const isAuthorized = await authorizable.authorized.callAsync(address); + await authorizable.addAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner }); + const isAuthorized = await authorizable.authorized(address).callAsync(); expect(isAuthorized).to.be.true(); }); it('should revert if owner attempts to authorize the zero address', async () => { const expectedError = new AuthorizableRevertErrors.ZeroCantBeAuthorizedError(); - const tx = authorizable.addAuthorizedAddress.sendTransactionAsync(constants.NULL_ADDRESS, { from: owner }); + const tx = authorizable.addAuthorizedAddress(constants.NULL_ADDRESS).sendTransactionAsync({ from: owner }); return expect(tx).to.revertWith(expectedError); }); it('should revert if owner attempts to authorize a duplicate address', async () => { - await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner }); + await authorizable.addAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner }); const expectedError = new AuthorizableRevertErrors.TargetAlreadyAuthorizedError(address); - const tx = authorizable.addAuthorizedAddress.sendTransactionAsync(address, { from: owner }); + const tx = authorizable.addAuthorizedAddress(address).sendTransactionAsync({ from: owner }); return expect(tx).to.revertWith(expectedError); }); }); describe('removeAuthorizedAddress', () => { it('should revert if not called by owner', async () => { - await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner }); + await authorizable.addAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner }); const expectedError = new OwnableRevertErrors.OnlyOwnerError(notOwner, owner); - const tx = authorizable.removeAuthorizedAddress.sendTransactionAsync(address, { from: notOwner }); + const tx = authorizable.removeAuthorizedAddress(address).sendTransactionAsync({ from: notOwner }); return expect(tx).to.revertWith(expectedError); }); it('should allow owner to remove an authorized address', async () => { - await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner }); - await authorizable.removeAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner }); - const isAuthorized = await authorizable.authorized.callAsync(address); + await authorizable.addAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner }); + await authorizable.removeAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner }); + const isAuthorized = await authorizable.authorized(address).callAsync(); expect(isAuthorized).to.be.false(); }); it('should revert if owner attempts to remove an address that is not authorized', async () => { const expectedError = new AuthorizableRevertErrors.TargetNotAuthorizedError(address); - const tx = authorizable.removeAuthorizedAddress.sendTransactionAsync(address, { from: owner }); + const tx = authorizable.removeAuthorizedAddress(address).sendTransactionAsync({ from: owner }); return expect(tx).to.revertWith(expectedError); }); }); describe('removeAuthorizedAddressAtIndex', () => { it('should revert if not called by owner', async () => { - await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner }); + await authorizable.addAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner }); const index = new BigNumber(0); const expectedError = new OwnableRevertErrors.OnlyOwnerError(notOwner, owner); - const tx = authorizable.removeAuthorizedAddressAtIndex.sendTransactionAsync(address, index, { + const tx = authorizable.removeAuthorizedAddressAtIndex(address, index).sendTransactionAsync({ from: notOwner, }); return expect(tx).to.revertWith(expectedError); }); it('should revert if index is >= authorities.length', async () => { - await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner }); + await authorizable.addAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner }); const index = new BigNumber(1); const expectedError = new AuthorizableRevertErrors.IndexOutOfBoundsError(index, index); - const tx = authorizable.removeAuthorizedAddressAtIndex.sendTransactionAsync(address, index, { + const tx = authorizable.removeAuthorizedAddressAtIndex(address, index).sendTransactionAsync({ from: owner, }); return expect(tx).to.revertWith(expectedError); @@ -116,7 +116,7 @@ describe('Authorizable', () => { it('should revert if owner attempts to remove an address that is not authorized', async () => { const index = new BigNumber(0); const expectedError = new AuthorizableRevertErrors.TargetNotAuthorizedError(address); - const tx = authorizable.removeAuthorizedAddressAtIndex.sendTransactionAsync(address, index, { + const tx = authorizable.removeAuthorizedAddressAtIndex(address, index).sendTransactionAsync({ from: owner, }); return expect(tx).to.revertWith(expectedError); @@ -125,37 +125,37 @@ describe('Authorizable', () => { it('should revert if address at index does not match target', async () => { const address1 = address; const address2 = notOwner; - await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address1, { from: owner }); - await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address2, { from: owner }); + await authorizable.addAuthorizedAddress(address1).awaitTransactionSuccessAsync({ from: owner }); + await authorizable.addAuthorizedAddress(address2).awaitTransactionSuccessAsync({ from: owner }); const address1Index = new BigNumber(0); const expectedError = new AuthorizableRevertErrors.AuthorizedAddressMismatchError(address1, address2); - const tx = authorizable.removeAuthorizedAddressAtIndex.sendTransactionAsync(address2, address1Index, { + const tx = authorizable.removeAuthorizedAddressAtIndex(address2, address1Index).sendTransactionAsync({ from: owner, }); return expect(tx).to.revertWith(expectedError); }); it('should allow owner to remove an authorized address', async () => { - await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner }); + await authorizable.addAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner }); const index = new BigNumber(0); - await authorizable.removeAuthorizedAddressAtIndex.awaitTransactionSuccessAsync(address, index, { + await authorizable.removeAuthorizedAddressAtIndex(address, index).awaitTransactionSuccessAsync({ from: owner, }); - const isAuthorized = await authorizable.authorized.callAsync(address); + const isAuthorized = await authorizable.authorized(address).callAsync(); expect(isAuthorized).to.be.false(); }); }); describe('getAuthorizedAddresses', () => { it('should return all authorized addresses', async () => { - const initial = await authorizable.getAuthorizedAddresses.callAsync(); + const initial = await authorizable.getAuthorizedAddresses().callAsync(); expect(initial).to.have.length(0); - await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner }); - const afterAdd = await authorizable.getAuthorizedAddresses.callAsync(); + await authorizable.addAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner }); + const afterAdd = await authorizable.getAuthorizedAddresses().callAsync(); expect(afterAdd).to.have.length(1); expect(afterAdd).to.include(address); - await authorizable.removeAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner }); - const afterRemove = await authorizable.getAuthorizedAddresses.callAsync(); + await authorizable.removeAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner }); + const afterRemove = await authorizable.getAuthorizedAddresses().callAsync(); expect(afterRemove).to.have.length(0); }); }); diff --git a/contracts/utils/test/lib_address.ts b/contracts/utils/test/lib_address.ts index a538e610c0..41a270befc 100644 --- a/contracts/utils/test/lib_address.ts +++ b/contracts/utils/test/lib_address.ts @@ -30,12 +30,12 @@ describe('LibAddress', () => { describe('isContract', () => { it('should return false for a non-contract address', async () => { - const isContract = await lib.externalIsContract.callAsync(nonContract); + const isContract = await lib.externalIsContract(nonContract).callAsync(); expect(isContract).to.be.false(); }); it('should return true for a non-contract address', async () => { - const isContract = await lib.externalIsContract.callAsync(lib.address); + const isContract = await lib.externalIsContract(lib.address).callAsync(); expect(isContract).to.be.true(); }); }); diff --git a/contracts/utils/test/lib_address_array.ts b/contracts/utils/test/lib_address_array.ts index 5f74cc3659..25923aa4aa 100644 --- a/contracts/utils/test/lib_address_array.ts +++ b/contracts/utils/test/lib_address_array.ts @@ -30,7 +30,7 @@ describe('LibAddressArray', () => { describe('append', () => { it('should append to empty array', async () => { const addr = randomAddress(); - const result = await lib.publicAppend.callAsync([], addr); + const result = await lib.publicAppend([], addr).callAsync(); const expected = [addr]; expect(result).to.deep.equal(expected); }); @@ -39,7 +39,7 @@ describe('LibAddressArray', () => { const arr = _.times(3, () => randomAddress()); const addr = randomAddress(); const expected = [...arr, addr]; - const result = await lib.publicAppend.callAsync(arr, addr); + const result = await lib.publicAppend(arr, addr).callAsync(); expect(result).to.deep.equal(expected); }); @@ -52,7 +52,7 @@ describe('LibAddressArray', () => { addressArrayEndPtr.plus(freeMemOffset), addressArrayEndPtr, ); - return expect(lib.testAppendRealloc.callAsync(arr, freeMemOffset, addr)).to.revertWith(expectedError); + return expect(lib.testAppendRealloc(arr, freeMemOffset, addr).callAsync()).to.revertWith(expectedError); }); it('should keep the same memory address if free memory pointer does not move', async () => { @@ -60,11 +60,9 @@ describe('LibAddressArray', () => { const addr = randomAddress(); const freeMemOffset = new BigNumber(0); const expected = [...arr, addr]; - const [result, oldArrayMemStart, newArrayMemStart] = await lib.testAppendRealloc.callAsync( - arr, - freeMemOffset, - addr, - ); + const [result, oldArrayMemStart, newArrayMemStart] = await lib + .testAppendRealloc(arr, freeMemOffset, addr) + .callAsync(); expect(result).to.deep.equal(expected); expect(newArrayMemStart).bignumber.to.be.equal(oldArrayMemStart); }); @@ -74,11 +72,9 @@ describe('LibAddressArray', () => { const addr = randomAddress(); const freeMemOffset = new BigNumber(1); const expectedArray = [...arr, addr]; - const [result, oldArrayMemStart, newArrayMemStart] = await lib.testAppendRealloc.callAsync( - arr, - freeMemOffset, - addr, - ); + const [result, oldArrayMemStart, newArrayMemStart] = await lib + .testAppendRealloc(arr, freeMemOffset, addr) + .callAsync(); // The new location should be the end of the old array + freeMemOffset. const expectedNewArrayMemStart = oldArrayMemStart.plus((arr.length + 1) * 32).plus(freeMemOffset); expect(result).to.deep.equal(expectedArray); @@ -89,27 +85,27 @@ describe('LibAddressArray', () => { describe('contains', () => { it('should return false on an empty array', async () => { const addr = randomAddress(); - const isFound = await lib.publicContains.callAsync([], addr); + const isFound = await lib.publicContains([], addr).callAsync(); expect(isFound).to.equal(false); }); it('should return false on a missing item', async () => { const arr = _.times(3, () => randomAddress()); const addr = randomAddress(); - const isFound = await lib.publicContains.callAsync(arr, addr); + const isFound = await lib.publicContains(arr, addr).callAsync(); expect(isFound).to.equal(false); }); it('should return true on an included item', async () => { const arr = _.times(4, () => randomAddress()); const addr = _.sample(arr) as string; - const isFound = await lib.publicContains.callAsync(arr, addr); + const isFound = await lib.publicContains(arr, addr).callAsync(); expect(isFound).to.equal(true); }); it('should return true on the only item in the array', async () => { const arr = _.times(1, () => randomAddress()); - const isFound = await lib.publicContains.callAsync(arr, arr[0]); + const isFound = await lib.publicContains(arr, arr[0]).callAsync(); expect(isFound).to.equal(true); }); }); @@ -117,14 +113,14 @@ describe('LibAddressArray', () => { describe('indexOf', () => { it('should fail on an empty array', async () => { const addr = randomAddress(); - const [isSuccess] = await lib.publicIndexOf.callAsync([], addr); + const [isSuccess] = await lib.publicIndexOf([], addr).callAsync(); expect(isSuccess).to.equal(false); }); it('should fail on a missing item', async () => { const arr = _.times(3, () => randomAddress()); const addr = randomAddress(); - const [isSuccess] = await lib.publicIndexOf.callAsync(arr, addr); + const [isSuccess] = await lib.publicIndexOf(arr, addr).callAsync(); expect(isSuccess).to.equal(false); }); @@ -132,14 +128,14 @@ describe('LibAddressArray', () => { const arr = _.times(4, () => randomAddress()); const expectedIndexOf = _.random(0, arr.length - 1); const addr = arr[expectedIndexOf]; - const [isSuccess, index] = await lib.publicIndexOf.callAsync(arr, addr); + const [isSuccess, index] = await lib.publicIndexOf(arr, addr).callAsync(); expect(isSuccess).to.equal(true); expect(index).bignumber.to.equal(expectedIndexOf); }); it('should succeed on the only item in the array', async () => { const arr = _.times(1, () => randomAddress()); - const [isSuccess, index] = await lib.publicIndexOf.callAsync(arr, arr[0]); + const [isSuccess, index] = await lib.publicIndexOf(arr, arr[0]).callAsync(); expect(isSuccess).to.equal(true); expect(index).bignumber.to.equal(0); }); diff --git a/contracts/utils/test/lib_bytes.ts b/contracts/utils/test/lib_bytes.ts index 541ea43dff..90cec2d1ec 100644 --- a/contracts/utils/test/lib_bytes.ts +++ b/contracts/utils/test/lib_bytes.ts @@ -59,17 +59,17 @@ blockchainTests('LibBytes', env => { constants.ZERO_AMOUNT, constants.ZERO_AMOUNT, ); - return expect(libBytes.publicPopLastByte.callAsync(constants.NULL_BYTES)).to.revertWith(expectedError); + return expect(libBytes.publicPopLastByte(constants.NULL_BYTES).callAsync()).to.revertWith(expectedError); }); it('should pop the last byte from the input and return it when array holds more than 1 byte', async () => { - const [newBytes, poppedByte] = await libBytes.publicPopLastByte.callAsync(byteArrayLongerThan32Bytes); + const [newBytes, poppedByte] = await libBytes.publicPopLastByte(byteArrayLongerThan32Bytes).callAsync(); const expectedNewBytes = byteArrayLongerThan32Bytes.slice(0, -2); const expectedPoppedByte = `0x${byteArrayLongerThan32Bytes.slice(-2)}`; expect(newBytes).to.equal(expectedNewBytes); expect(poppedByte).to.equal(expectedPoppedByte); }); it('should pop the last byte from the input and return it when array is exactly 1 byte', async () => { - const [newBytes, poppedByte] = await libBytes.publicPopLastByte.callAsync(testByte); + const [newBytes, poppedByte] = await libBytes.publicPopLastByte(testByte).callAsync(); const expectedNewBytes = '0x'; expect(newBytes).to.equal(expectedNewBytes); return expect(poppedByte).to.be.equal(testByte); @@ -78,51 +78,45 @@ blockchainTests('LibBytes', env => { describe('equals', () => { it('should return true if byte arrays are equal (both arrays < 32 bytes)', async () => { - const isEqual = await libBytes.publicEquals.callAsync( - byteArrayShorterThan32Bytes, - byteArrayShorterThan32Bytes, - ); + const isEqual = await libBytes + .publicEquals(byteArrayShorterThan32Bytes, byteArrayShorterThan32Bytes) + .callAsync(); return expect(isEqual).to.be.true(); }); it('should return true if byte arrays are equal (both arrays > 32 bytes)', async () => { - const isEqual = await libBytes.publicEquals.callAsync( - byteArrayLongerThan32Bytes, - byteArrayLongerThan32Bytes, - ); + const isEqual = await libBytes + .publicEquals(byteArrayLongerThan32Bytes, byteArrayLongerThan32Bytes) + .callAsync(); return expect(isEqual).to.be.true(); }); it('should return false if byte arrays are not equal (first array < 32 bytes, second array > 32 bytes)', async () => { - const isEqual = await libBytes.publicEquals.callAsync( - byteArrayShorterThan32Bytes, - byteArrayLongerThan32Bytes, - ); + const isEqual = await libBytes + .publicEquals(byteArrayShorterThan32Bytes, byteArrayLongerThan32Bytes) + .callAsync(); return expect(isEqual).to.be.false(); }); it('should return false if byte arrays are not equal (first array > 32 bytes, second array < 32 bytes)', async () => { - const isEqual = await libBytes.publicEquals.callAsync( - byteArrayLongerThan32Bytes, - byteArrayShorterThan32Bytes, - ); + const isEqual = await libBytes + .publicEquals(byteArrayLongerThan32Bytes, byteArrayShorterThan32Bytes) + .callAsync(); return expect(isEqual).to.be.false(); }); it('should return false if byte arrays are not equal (same length, but a byte in first word differs)', async () => { - const isEqual = await libBytes.publicEquals.callAsync( - byteArrayLongerThan32BytesFirstBytesSwapped, - byteArrayLongerThan32Bytes, - ); + const isEqual = await libBytes + .publicEquals(byteArrayLongerThan32BytesFirstBytesSwapped, byteArrayLongerThan32Bytes) + .callAsync(); return expect(isEqual).to.be.false(); }); it('should return false if byte arrays are not equal (same length, but a byte in last word differs)', async () => { - const isEqual = await libBytes.publicEquals.callAsync( - byteArrayLongerThan32BytesLastBytesSwapped, - byteArrayLongerThan32Bytes, - ); + const isEqual = await libBytes + .publicEquals(byteArrayLongerThan32BytesLastBytesSwapped, byteArrayLongerThan32Bytes) + .callAsync(); return expect(isEqual).to.be.false(); }); describe('should ignore trailing data', () => { it('should return true when both < 32 bytes', async () => { - const isEqual = await libBytes.publicEqualsPop1.callAsync('0x0102', '0x0103'); + const isEqual = await libBytes.publicEqualsPop1('0x0102', '0x0103').callAsync(); return expect(isEqual).to.be.true(); }); }); @@ -132,7 +126,7 @@ blockchainTests('LibBytes', env => { it('should successfully read address when the address takes up the whole array', async () => { const byteArray = ethUtil.addHexPrefix(testAddress); const testAddressOffset = new BigNumber(0); - const address = await libBytes.publicReadAddress.callAsync(byteArray, testAddressOffset); + const address = await libBytes.publicReadAddress(byteArray, testAddressOffset).callAsync(); return expect(address).to.be.equal(testAddress); }); it('should successfully read address when it is offset in the array', async () => { @@ -141,7 +135,7 @@ blockchainTests('LibBytes', env => { const combinedByteArrayBuffer = Buffer.concat([prefixByteArrayBuffer, addressByteArrayBuffer]); const combinedByteArray = ethUtil.bufferToHex(combinedByteArrayBuffer); const testAddressOffset = new BigNumber(prefixByteArrayBuffer.byteLength); - const address = await libBytes.publicReadAddress.callAsync(combinedByteArray, testAddressOffset); + const address = await libBytes.publicReadAddress(combinedByteArray, testAddressOffset).callAsync(); return expect(address).to.be.equal(testAddress); }); it('should fail if the byte array is too short to hold an address', async () => { @@ -152,7 +146,7 @@ blockchainTests('LibBytes', env => { new BigNumber(3), new BigNumber(20), ); - return expect(libBytes.publicReadAddress.callAsync(shortByteArray, offset)).to.revertWith(expectedError); + return expect(libBytes.publicReadAddress(shortByteArray, offset).callAsync()).to.revertWith(expectedError); }); it('should fail if the length between the offset and end of the byte array is too short to hold an address', async () => { const byteArray = testAddress; @@ -162,7 +156,7 @@ blockchainTests('LibBytes', env => { new BigNumber(20), new BigNumber(40), ); - return expect(libBytes.publicReadAddress.callAsync(byteArray, badOffset)).to.revertWith(expectedError); + return expect(libBytes.publicReadAddress(byteArray, badOffset).callAsync()).to.revertWith(expectedError); }); }); @@ -170,11 +164,9 @@ blockchainTests('LibBytes', env => { it('should successfully write address when the address takes up the whole array', async () => { const byteArray = testAddress; const testAddressOffset = new BigNumber(0); - const newByteArray = await libBytes.publicWriteAddress.callAsync( - byteArray, - testAddressOffset, - testAddressB, - ); + const newByteArray = await libBytes + .publicWriteAddress(byteArray, testAddressOffset, testAddressB) + .callAsync(); return expect(newByteArray).to.be.equal(testAddressB); }); it('should successfully write address when it is offset in the array', async () => { @@ -183,11 +175,9 @@ blockchainTests('LibBytes', env => { const combinedByteArrayBuffer = Buffer.concat([prefixByteArrayBuffer, addressByteArrayBuffer]); const combinedByteArray = ethUtil.bufferToHex(combinedByteArrayBuffer); const testAddressOffset = new BigNumber(prefixByteArrayBuffer.byteLength); - const newByteArray = await libBytes.publicWriteAddress.callAsync( - combinedByteArray, - testAddressOffset, - testAddressB, - ); + const newByteArray = await libBytes + .publicWriteAddress(combinedByteArray, testAddressOffset, testAddressB) + .callAsync(); const newByteArrayBuffer = ethUtil.toBuffer(newByteArray); const addressFromOffsetBuffer = newByteArrayBuffer.slice(prefixByteArrayBuffer.byteLength); const addressFromOffset = ethUtil.addHexPrefix(ethUtil.bufferToHex(addressFromOffsetBuffer)); @@ -202,7 +192,7 @@ blockchainTests('LibBytes', env => { new BigNumber(20), ); return expect( - libBytes.publicWriteAddress.callAsync(byteArrayShorterThan20Bytes, offset, testAddress), + libBytes.publicWriteAddress(byteArrayShorterThan20Bytes, offset, testAddress).callAsync(), ).to.revertWith(expectedError); }); it('should fail if the length between the offset and end of the byte array is too short to hold an address', async () => { @@ -213,7 +203,7 @@ blockchainTests('LibBytes', env => { badOffset, badOffset.plus(new BigNumber(20)), ); - return expect(libBytes.publicWriteAddress.callAsync(byteArray, badOffset, testAddress)).to.revertWith( + return expect(libBytes.publicWriteAddress(byteArray, badOffset, testAddress).callAsync()).to.revertWith( expectedError, ); }); @@ -222,7 +212,7 @@ blockchainTests('LibBytes', env => { describe('readBytes32', () => { it('should successfully read bytes32 when the bytes32 takes up the whole array', async () => { const testBytes32Offset = new BigNumber(0); - const bytes32 = await libBytes.publicReadBytes32.callAsync(testBytes32, testBytes32Offset); + const bytes32 = await libBytes.publicReadBytes32(testBytes32, testBytes32Offset).callAsync(); return expect(bytes32).to.be.equal(testBytes32); }); it('should successfully read bytes32 when it is offset in the array', async () => { @@ -231,7 +221,7 @@ blockchainTests('LibBytes', env => { const combinedByteArrayBuffer = Buffer.concat([prefixByteArrayBuffer, bytes32ByteArrayBuffer]); const combinedByteArray = ethUtil.bufferToHex(combinedByteArrayBuffer); const testBytes32Offset = new BigNumber(prefixByteArrayBuffer.byteLength); - const bytes32 = await libBytes.publicReadBytes32.callAsync(combinedByteArray, testBytes32Offset); + const bytes32 = await libBytes.publicReadBytes32(combinedByteArray, testBytes32Offset).callAsync(); return expect(bytes32).to.be.equal(testBytes32); }); it('should fail if the byte array is too short to hold a bytes32', async () => { @@ -242,7 +232,7 @@ blockchainTests('LibBytes', env => { byteLen, new BigNumber(32), ); - return expect(libBytes.publicReadBytes32.callAsync(byteArrayShorterThan32Bytes, offset)).to.revertWith( + return expect(libBytes.publicReadBytes32(byteArrayShorterThan32Bytes, offset).callAsync()).to.revertWith( expectedError, ); }); @@ -253,7 +243,7 @@ blockchainTests('LibBytes', env => { badOffset, badOffset.plus(new BigNumber(32)), ); - return expect(libBytes.publicReadBytes32.callAsync(testBytes32, badOffset)).to.revertWith(expectedError); + return expect(libBytes.publicReadBytes32(testBytes32, badOffset).callAsync()).to.revertWith(expectedError); }); }); @@ -261,11 +251,9 @@ blockchainTests('LibBytes', env => { it('should successfully write bytes32 when the address takes up the whole array', async () => { const byteArray = testBytes32; const testBytes32Offset = new BigNumber(0); - const newByteArray = await libBytes.publicWriteBytes32.callAsync( - byteArray, - testBytes32Offset, - testBytes32B, - ); + const newByteArray = await libBytes + .publicWriteBytes32(byteArray, testBytes32Offset, testBytes32B) + .callAsync(); return expect(newByteArray).to.be.equal(testBytes32B); }); it('should successfully write bytes32 when it is offset in the array', async () => { @@ -274,11 +262,9 @@ blockchainTests('LibBytes', env => { const combinedByteArrayBuffer = Buffer.concat([prefixByteArrayBuffer, bytes32ByteArrayBuffer]); const combinedByteArray = ethUtil.bufferToHex(combinedByteArrayBuffer); const testBytes32Offset = new BigNumber(prefixByteArrayBuffer.byteLength); - const newByteArray = await libBytes.publicWriteBytes32.callAsync( - combinedByteArray, - testBytes32Offset, - testBytes32B, - ); + const newByteArray = await libBytes + .publicWriteBytes32(combinedByteArray, testBytes32Offset, testBytes32B) + .callAsync(); const newByteArrayBuffer = ethUtil.toBuffer(newByteArray); const bytes32FromOffsetBuffer = newByteArrayBuffer.slice(prefixByteArrayBuffer.byteLength); const bytes32FromOffset = ethUtil.addHexPrefix(ethUtil.bufferToHex(bytes32FromOffsetBuffer)); @@ -293,7 +279,7 @@ blockchainTests('LibBytes', env => { new BigNumber(32), ); return expect( - libBytes.publicWriteBytes32.callAsync(byteArrayShorterThan32Bytes, offset, testBytes32), + libBytes.publicWriteBytes32(byteArrayShorterThan32Bytes, offset, testBytes32).callAsync(), ).to.revertWith(expectedError); }); it('should fail if the length between the offset and end of the byte array is too short to hold a bytes32', async () => { @@ -304,7 +290,7 @@ blockchainTests('LibBytes', env => { badOffset, badOffset.plus(new BigNumber(32)), ); - return expect(libBytes.publicWriteBytes32.callAsync(byteArray, badOffset, testBytes32)).to.revertWith( + return expect(libBytes.publicWriteBytes32(byteArray, badOffset, testBytes32).callAsync()).to.revertWith( expectedError, ); }); @@ -316,7 +302,7 @@ blockchainTests('LibBytes', env => { const testUint256AsBuffer = ethUtil.toBuffer(formattedTestUint256); const byteArray = ethUtil.bufferToHex(testUint256AsBuffer); const testUint256Offset = new BigNumber(0); - const uint256 = await libBytes.publicReadUint256.callAsync(byteArray, testUint256Offset); + const uint256 = await libBytes.publicReadUint256(byteArray, testUint256Offset).callAsync(); return expect(uint256).to.bignumber.equal(testUint256); }); it('should successfully read uint256 when it is offset in the array', async () => { @@ -326,7 +312,7 @@ blockchainTests('LibBytes', env => { const combinedByteArrayBuffer = Buffer.concat([prefixByteArrayBuffer, testUint256AsBuffer]); const combinedByteArray = ethUtil.bufferToHex(combinedByteArrayBuffer); const testUint256Offset = new BigNumber(prefixByteArrayBuffer.byteLength); - const uint256 = await libBytes.publicReadUint256.callAsync(combinedByteArray, testUint256Offset); + const uint256 = await libBytes.publicReadUint256(combinedByteArray, testUint256Offset).callAsync(); return expect(uint256).to.bignumber.equal(testUint256); }); it('should fail if the byte array is too short to hold a uint256', async () => { @@ -337,7 +323,7 @@ blockchainTests('LibBytes', env => { byteLen, new BigNumber(32), ); - return expect(libBytes.publicReadUint256.callAsync(byteArrayShorterThan32Bytes, offset)).to.revertWith( + return expect(libBytes.publicReadUint256(byteArrayShorterThan32Bytes, offset).callAsync()).to.revertWith( expectedError, ); }); @@ -351,7 +337,7 @@ blockchainTests('LibBytes', env => { badOffset, badOffset.plus(new BigNumber(32)), ); - return expect(libBytes.publicReadUint256.callAsync(byteArray, badOffset)).to.revertWith(expectedError); + return expect(libBytes.publicReadUint256(byteArray, badOffset).callAsync()).to.revertWith(expectedError); }); }); @@ -359,11 +345,9 @@ blockchainTests('LibBytes', env => { it('should successfully write uint256 when the address takes up the whole array', async () => { const byteArray = testBytes32; const testUint256Offset = new BigNumber(0); - const newByteArray = await libBytes.publicWriteUint256.callAsync( - byteArray, - testUint256Offset, - testUint256B, - ); + const newByteArray = await libBytes + .publicWriteUint256(byteArray, testUint256Offset, testUint256B) + .callAsync(); const newByteArrayAsUint256 = new BigNumber(newByteArray, 16); return expect(newByteArrayAsUint256).to.be.bignumber.equal(testUint256B); }); @@ -373,11 +357,9 @@ blockchainTests('LibBytes', env => { const combinedByteArrayBuffer = Buffer.concat([prefixByteArrayBuffer, bytes32ByteArrayBuffer]); const combinedByteArray = ethUtil.bufferToHex(combinedByteArrayBuffer); const testUint256Offset = new BigNumber(prefixByteArrayBuffer.byteLength); - const newByteArray = await libBytes.publicWriteUint256.callAsync( - combinedByteArray, - testUint256Offset, - testUint256B, - ); + const newByteArray = await libBytes + .publicWriteUint256(combinedByteArray, testUint256Offset, testUint256B) + .callAsync(); const newByteArrayBuffer = ethUtil.toBuffer(newByteArray); const uint256FromOffsetBuffer = newByteArrayBuffer.slice(prefixByteArrayBuffer.byteLength); const uint256FromOffset = new BigNumber( @@ -395,7 +377,7 @@ blockchainTests('LibBytes', env => { new BigNumber(32), ); return expect( - libBytes.publicWriteUint256.callAsync(byteArrayShorterThan32Bytes, offset, testUint256), + libBytes.publicWriteUint256(byteArrayShorterThan32Bytes, offset, testUint256).callAsync(), ).to.revertWith(expectedError); }); it('should fail if the length between the offset and end of the byte array is too short to hold a uint256', async () => { @@ -406,7 +388,7 @@ blockchainTests('LibBytes', env => { badOffset, badOffset.plus(new BigNumber(32)), ); - return expect(libBytes.publicWriteUint256.callAsync(byteArray, badOffset, testUint256)).to.revertWith( + return expect(libBytes.publicWriteUint256(byteArray, badOffset, testUint256).callAsync()).to.revertWith( expectedError, ); }); @@ -423,18 +405,20 @@ blockchainTests('LibBytes', env => { new BigNumber(byteLen), // length of byteArrayLessThan4Bytes new BigNumber(4), ); - return expect(libBytes.publicReadBytes4.callAsync(byteArrayLessThan4Bytes, offset)).to.revertWith( + return expect(libBytes.publicReadBytes4(byteArrayLessThan4Bytes, offset).callAsync()).to.revertWith( expectedError, ); }); it('should return the first 4 bytes of a byte array of arbitrary length', async () => { - const first4Bytes = await libBytes.publicReadBytes4.callAsync(byteArrayLongerThan32Bytes, new BigNumber(0)); + const first4Bytes = await libBytes + .publicReadBytes4(byteArrayLongerThan32Bytes, new BigNumber(0)) + .callAsync(); const expectedFirst4Bytes = byteArrayLongerThan32Bytes.slice(0, 10); expect(first4Bytes).to.equal(expectedFirst4Bytes); }); it('should successfully read bytes4 when the bytes4 takes up the whole array', async () => { const testBytes4Offset = new BigNumber(0); - const bytes4 = await libBytes.publicReadBytes4.callAsync(testBytes4, testBytes4Offset); + const bytes4 = await libBytes.publicReadBytes4(testBytes4, testBytes4Offset).callAsync(); return expect(bytes4).to.be.equal(testBytes4); }); it('should successfully read bytes4 when it is offset in the array', async () => { @@ -443,7 +427,7 @@ blockchainTests('LibBytes', env => { const combinedByteArrayBuffer = Buffer.concat([prefixByteArrayBuffer, bytes4ByteArrayBuffer]); const combinedByteArray = ethUtil.bufferToHex(combinedByteArrayBuffer); const testBytes4Offset = new BigNumber(prefixByteArrayBuffer.byteLength); - const bytes4 = await libBytes.publicReadBytes4.callAsync(combinedByteArray, testBytes4Offset); + const bytes4 = await libBytes.publicReadBytes4(combinedByteArray, testBytes4Offset).callAsync(); return expect(bytes4).to.be.equal(testBytes4); }); it('should fail if the length between the offset and end of the byte array is too short to hold a bytes4', async () => { @@ -454,7 +438,7 @@ blockchainTests('LibBytes', env => { byteLen, badOffset.plus(new BigNumber(4)), ); - return expect(libBytes.publicReadBytes4.callAsync(testBytes4, badOffset)).to.revertWith(expectedError); + return expect(libBytes.publicReadBytes4(testBytes4, badOffset).callAsync()).to.revertWith(expectedError); }); }); @@ -476,12 +460,9 @@ blockchainTests('LibBytes', env => { tests.forEach(([dest, source, length, job]) => it(job, async () => { const expected = refMemcpy(memory, dest, source, length); - const resultStr = await libBytes.testMemcpy.callAsync( - memHex, - new BigNumber(dest), - new BigNumber(source), - new BigNumber(length), - ); + const resultStr = await libBytes + .testMemcpy(memHex, new BigNumber(dest), new BigNumber(source), new BigNumber(length)) + .callAsync(); const result = fromHex(resultStr); expect(result).to.deep.equal(expected); }), @@ -633,14 +614,14 @@ blockchainTests('LibBytes', env => { from, to, ); - return expect(libBytes.publicSlice.callAsync(byteArrayLongerThan32Bytes, from, to)).to.revertWith( + return expect(libBytes.publicSlice(byteArrayLongerThan32Bytes, from, to).callAsync()).to.revertWith( expectedError, ); }); it('should return a byte array of length 0 if from == to', async () => { const from = new BigNumber(0); const to = from; - const [result, original] = await libBytes.publicSlice.callAsync(byteArrayLongerThan32Bytes, from, to); + const [result, original] = await libBytes.publicSlice(byteArrayLongerThan32Bytes, from, to).callAsync(); expect(original).to.eq(byteArrayLongerThan32Bytes); expect(result).to.eq(constants.NULL_BYTES); }); @@ -648,7 +629,7 @@ blockchainTests('LibBytes', env => { const byteLen = fromHex(byteArrayLongerThan32Bytes).length; const from = new BigNumber(byteLen); const to = from; - const [result, original] = await libBytes.publicSlice.callAsync(byteArrayLongerThan32Bytes, from, to); + const [result, original] = await libBytes.publicSlice(byteArrayLongerThan32Bytes, from, to).callAsync(); expect(original).to.eq(byteArrayLongerThan32Bytes); expect(result).to.eq(constants.NULL_BYTES); }); @@ -661,14 +642,14 @@ blockchainTests('LibBytes', env => { to, new BigNumber(byteLen), ); - return expect(libBytes.publicSlice.callAsync(byteArrayLongerThan32Bytes, from, to)).to.revertWith( + return expect(libBytes.publicSlice(byteArrayLongerThan32Bytes, from, to).callAsync()).to.revertWith( expectedError, ); }); it('should slice a section of the input', async () => { const from = new BigNumber(1); const to = new BigNumber(2); - const [result, original] = await libBytes.publicSlice.callAsync(byteArrayLongerThan32Bytes, from, to); + const [result, original] = await libBytes.publicSlice(byteArrayLongerThan32Bytes, from, to).callAsync(); const expectedResult = `0x${byteArrayLongerThan32Bytes.slice(4, 6)}`; expect(original).to.eq(byteArrayLongerThan32Bytes); expect(result).to.eq(expectedResult); @@ -677,7 +658,7 @@ blockchainTests('LibBytes', env => { const byteLen = fromHex(byteArrayLongerThan32Bytes).length; const from = new BigNumber(0); const to = new BigNumber(byteLen); - const [result, original] = await libBytes.publicSlice.callAsync(byteArrayLongerThan32Bytes, from, to); + const [result, original] = await libBytes.publicSlice(byteArrayLongerThan32Bytes, from, to).callAsync(); expect(original).to.eq(byteArrayLongerThan32Bytes); expect(result).to.eq(byteArrayLongerThan32Bytes); }); @@ -692,21 +673,21 @@ blockchainTests('LibBytes', env => { from, to, ); - return expect(libBytes.publicSlice.callAsync(byteArrayLongerThan32Bytes, from, to)).to.revertWith( + return expect(libBytes.publicSlice(byteArrayLongerThan32Bytes, from, to).callAsync()).to.revertWith( expectedError, ); }); it('should return a byte array of length 0 if from == to', async () => { const from = new BigNumber(0); const to = from; - const [result] = await libBytes.publicSliceDestructive.callAsync(byteArrayLongerThan32Bytes, from, to); + const [result] = await libBytes.publicSliceDestructive(byteArrayLongerThan32Bytes, from, to).callAsync(); expect(result).to.eq(constants.NULL_BYTES); }); it('should return a byte array of length 0 if from == to == b.length', async () => { const byteLen = fromHex(byteArrayLongerThan32Bytes).length; const from = new BigNumber(byteLen); const to = from; - const [result] = await libBytes.publicSliceDestructive.callAsync(byteArrayLongerThan32Bytes, from, to); + const [result] = await libBytes.publicSliceDestructive(byteArrayLongerThan32Bytes, from, to).callAsync(); expect(result).to.eq(constants.NULL_BYTES); }); it('should revert if to > input.length', async () => { @@ -719,13 +700,13 @@ blockchainTests('LibBytes', env => { new BigNumber(byteLen), ); return expect( - libBytes.publicSliceDestructive.callAsync(byteArrayLongerThan32Bytes, from, to), + libBytes.publicSliceDestructive(byteArrayLongerThan32Bytes, from, to).callAsync(), ).to.revertWith(expectedError); }); it('should slice a section of the input', async () => { const from = new BigNumber(1); const to = new BigNumber(2); - const [result] = await libBytes.publicSliceDestructive.callAsync(byteArrayLongerThan32Bytes, from, to); + const [result] = await libBytes.publicSliceDestructive(byteArrayLongerThan32Bytes, from, to).callAsync(); const expectedResult = `0x${byteArrayLongerThan32Bytes.slice(4, 6)}`; expect(result).to.eq(expectedResult); }); @@ -733,37 +714,31 @@ blockchainTests('LibBytes', env => { const byteLen = fromHex(byteArrayLongerThan32Bytes).length; const from = new BigNumber(0); const to = new BigNumber(byteLen); - const [result] = await libBytes.publicSliceDestructive.callAsync(byteArrayLongerThan32Bytes, from, to); + const [result] = await libBytes.publicSliceDestructive(byteArrayLongerThan32Bytes, from, to).callAsync(); expect(result).to.eq(byteArrayLongerThan32Bytes); }); }); describe('writeLength', () => { it('should return a null byte array if length is set to 0', async () => { - const result = await libBytes.publicWriteLength.callAsync( - byteArrayLongerThan32Bytes, - constants.ZERO_AMOUNT, - constants.NULL_BYTES, - ); + const result = await libBytes + .publicWriteLength(byteArrayLongerThan32Bytes, constants.ZERO_AMOUNT, constants.NULL_BYTES) + .callAsync(); expect(result).to.eq(constants.NULL_BYTES); }); it('should return the same byte array if length is unchanged', async () => { const byteLen = fromHex(byteArrayLongerThan32Bytes).length; - const result = await libBytes.publicWriteLength.callAsync( - byteArrayLongerThan32Bytes, - new BigNumber(byteLen), - constants.NULL_BYTES, - ); + const result = await libBytes + .publicWriteLength(byteArrayLongerThan32Bytes, new BigNumber(byteLen), constants.NULL_BYTES) + .callAsync(); expect(result).to.eq(byteArrayLongerThan32Bytes); }); it('should shave off lower order bytes if new length is less than original', async () => { const byteLen = fromHex(byteArrayLongerThan32Bytes).length; const newLen = new BigNumber(byteLen).dividedToIntegerBy(2); - const result = await libBytes.publicWriteLength.callAsync( - byteArrayLongerThan32Bytes, - newLen, - constants.NULL_BYTES, - ); + const result = await libBytes + .publicWriteLength(byteArrayLongerThan32Bytes, newLen, constants.NULL_BYTES) + .callAsync(); expect(result).to.eq( byteArrayLongerThan32Bytes.slice( 0, @@ -777,35 +752,31 @@ blockchainTests('LibBytes', env => { it("should right pad with 0's if new length is greater than original and no extra bytes are appended", async () => { const byteLen = fromHex(byteArrayLongerThan32Bytes).length; const newLen = new BigNumber(byteLen).multipliedBy(2); - const result = await libBytes.publicWriteLength.callAsync( - byteArrayLongerThan32Bytes, - newLen, - constants.NULL_BYTES, - ); + const result = await libBytes + .publicWriteLength(byteArrayLongerThan32Bytes, newLen, constants.NULL_BYTES) + .callAsync(); expect(result).to.eq(`${byteArrayLongerThan32Bytes}${'0'.repeat(byteArrayLongerThan32Bytes.length - 2)}`); }); it('should right pad with extra bytes if specified', async () => { const byteLen = fromHex(byteArrayLongerThan32Bytes).length; const newLen = new BigNumber(byteLen).multipliedBy(2); - const result = await libBytes.publicWriteLength.callAsync( - byteArrayLongerThan32Bytes, - newLen, - byteArrayLongerThan32Bytes, - ); + const result = await libBytes + .publicWriteLength(byteArrayLongerThan32Bytes, newLen, byteArrayLongerThan32Bytes) + .callAsync(); expect(result).to.eq(`${byteArrayLongerThan32Bytes}${byteArrayLongerThan32Bytes.slice(2)}`); }); it('should result in the same byte array if length is reduced and reset', async () => { const byteLen = fromHex(byteArrayLongerThan32Bytes).length; const tempByteLen = new BigNumber(byteLen).dividedToIntegerBy(2); return expect( - libBytes.assertBytesUnchangedAfterLengthReset.callAsync(byteArrayLongerThan32Bytes, tempByteLen), + libBytes.assertBytesUnchangedAfterLengthReset(byteArrayLongerThan32Bytes, tempByteLen).callAsync(), ).to.be.fulfilled(''); }); it('should result in the same byte array if length is increased and reset', async () => { const byteLen = fromHex(byteArrayLongerThan32Bytes).length; const tempByteLen = new BigNumber(byteLen).multipliedBy(2); return expect( - libBytes.assertBytesUnchangedAfterLengthReset.callAsync(byteArrayLongerThan32Bytes, tempByteLen), + libBytes.assertBytesUnchangedAfterLengthReset(byteArrayLongerThan32Bytes, tempByteLen).callAsync(), ).to.be.fulfilled(''); }); }); diff --git a/contracts/utils/test/lib_eip712.ts b/contracts/utils/test/lib_eip712.ts index 34c46eedbb..41fcd134e5 100644 --- a/contracts/utils/test/lib_eip712.ts +++ b/contracts/utils/test/lib_eip712.ts @@ -44,12 +44,9 @@ describe('LibEIP712', () => { chainId, verifyingContract, }); - const actualHash = await lib.externalHashEIP712DomainSeperator.callAsync( - name, - version, - new BigNumber(chainId), - verifyingContract, - ); + const actualHash = await lib + .externalHashEIP712DomainSeperator(name, version, new BigNumber(chainId), verifyingContract) + .callAsync(); expect(actualHash).to.be.eq(hexConcat(expectedHash)); } @@ -83,7 +80,7 @@ describe('LibEIP712', () => { const expectedHash = '0x'.concat(ethUtil.sha3(input).toString('hex')); // Get the actual hash by calling the smart contract - const actualHash = await lib.externalHashEIP712Message.callAsync(domainHash, hashStruct); + const actualHash = await lib.externalHashEIP712Message(domainHash, hashStruct).callAsync(); // Verify that the actual hash matches the expected hash expect(actualHash).to.be.eq(expectedHash); diff --git a/contracts/utils/test/lib_rich_errors.ts b/contracts/utils/test/lib_rich_errors.ts index 3e796ca119..3342c08d8a 100644 --- a/contracts/utils/test/lib_rich_errors.ts +++ b/contracts/utils/test/lib_rich_errors.ts @@ -20,7 +20,7 @@ blockchainTests('LibRichErrors', env => { it('should correctly revert the extra bytes', async () => { const extraBytes = hexRandom(100); try { - await lib.externalRRevert.callAsync(extraBytes); + await lib.externalRRevert(extraBytes).callAsync(); } catch (err) { const revertError = coerceThrownErrorAsRevertError(err); return expect(revertError.encode()).to.eq(extraBytes); @@ -32,7 +32,7 @@ blockchainTests('LibRichErrors', env => { it('should correctly revert a StringRevertError', async () => { const error = new StringRevertError('foo'); - return expect(lib.externalRRevert.callAsync(error.encode())).to.revertWith(error); + return expect(lib.externalRRevert(error.encode()).callAsync()).to.revertWith(error); }); }); }); diff --git a/contracts/utils/test/lib_safe_math.ts b/contracts/utils/test/lib_safe_math.ts index 39e1ae5d1a..ab68ea67e8 100644 --- a/contracts/utils/test/lib_safe_math.ts +++ b/contracts/utils/test/lib_safe_math.ts @@ -28,17 +28,17 @@ blockchainTests('SafeMath', env => { const a = ONE_ETHER; const b = ONE_ETHER.times(2); const expected = ReferenceFunctions.safeMul(a, b); - const actual = await safeMath.externalSafeMul.callAsync(a, b); + const actual = await safeMath.externalSafeMul(a, b).callAsync(); expect(actual).bignumber.to.be.eq(expected); }); it('should return zero if first argument is zero', async () => { - const result = await safeMath.externalSafeMul.callAsync(constants.ZERO_AMOUNT, toBigNumber(1)); + const result = await safeMath.externalSafeMul(constants.ZERO_AMOUNT, toBigNumber(1)).callAsync(); expect(result).bignumber.to.be.eq(constants.ZERO_AMOUNT); }); it('should return zero if second argument is zero', async () => { - const result = await safeMath.externalSafeMul.callAsync(toBigNumber(1), constants.ZERO_AMOUNT); + const result = await safeMath.externalSafeMul(toBigNumber(1), constants.ZERO_AMOUNT).callAsync(); expect(result).bignumber.to.be.eq(constants.ZERO_AMOUNT); }); @@ -50,11 +50,11 @@ blockchainTests('SafeMath', env => { a, b, ); - return expect(safeMath.externalSafeMul.callAsync(a, b)).to.revertWith(expectedError); + return expect(safeMath.externalSafeMul(a, b).callAsync()).to.revertWith(expectedError); }); it("should calculate correct value for values that don't overflow", async () => { - const result = await safeMath.externalSafeMul.callAsync(toBigNumber(15), toBigNumber(13)); + const result = await safeMath.externalSafeMul(toBigNumber(15), toBigNumber(13)).callAsync(); expect(result).bignumber.to.be.eq(toBigNumber(195)); }); }); @@ -64,27 +64,27 @@ blockchainTests('SafeMath', env => { const a = ONE_ETHER; const b = ONE_ETHER.times(2); const expected = ReferenceFunctions.safeDiv(a, b); - const actual = await safeMath.externalSafeDiv.callAsync(a, b); + const actual = await safeMath.externalSafeDiv(a, b).callAsync(); expect(actual).bignumber.to.be.eq(expected); }); it('should return the correct value if both values are the same', async () => { - const result = await safeMath.externalSafeDiv.callAsync(toBigNumber(1), toBigNumber(1)); + const result = await safeMath.externalSafeDiv(toBigNumber(1), toBigNumber(1)).callAsync(); expect(result).bignumber.to.be.eq(toBigNumber(1)); }); it('should return the correct value if the values are different', async () => { - const result = await safeMath.externalSafeDiv.callAsync(toBigNumber(3), toBigNumber(2)); + const result = await safeMath.externalSafeDiv(toBigNumber(3), toBigNumber(2)).callAsync(); expect(result).bignumber.to.be.eq(toBigNumber(1)); }); it('should return zero if the numerator is smaller than the denominator', async () => { - const result = await safeMath.externalSafeDiv.callAsync(toBigNumber(2), toBigNumber(3)); + const result = await safeMath.externalSafeDiv(toBigNumber(2), toBigNumber(3)).callAsync(); expect(result).bignumber.to.be.eq(constants.ZERO_AMOUNT); }); it('should return zero if first argument is zero', async () => { - const result = await safeMath.externalSafeDiv.callAsync(constants.ZERO_AMOUNT, toBigNumber(1)); + const result = await safeMath.externalSafeDiv(constants.ZERO_AMOUNT, toBigNumber(1)).callAsync(); expect(result).bignumber.to.be.eq(constants.ZERO_AMOUNT); }); @@ -96,7 +96,7 @@ blockchainTests('SafeMath', env => { a, b, ); - return expect(safeMath.externalSafeDiv.callAsync(a, b)).to.revertWith(expectedError); + return expect(safeMath.externalSafeDiv(a, b).callAsync()).to.revertWith(expectedError); }); }); @@ -105,7 +105,7 @@ blockchainTests('SafeMath', env => { const a = ONE_ETHER; const b = ONE_ETHER.dividedToIntegerBy(2); const expected = ReferenceFunctions.safeSub(a, b); - const actual = await safeMath.externalSafeSub.callAsync(a, b); + const actual = await safeMath.externalSafeSub(a, b).callAsync(); expect(actual).bignumber.to.be.eq(expected); }); @@ -117,16 +117,16 @@ blockchainTests('SafeMath', env => { a, b, ); - return expect(safeMath.externalSafeSub.callAsync(a, b)).to.revertWith(expectedError); + return expect(safeMath.externalSafeSub(a, b).callAsync()).to.revertWith(expectedError); }); it('should calculate correct value for values that are equal', async () => { - const result = await safeMath.externalSafeMul.callAsync(constants.ZERO_AMOUNT, constants.ZERO_AMOUNT); + const result = await safeMath.externalSafeMul(constants.ZERO_AMOUNT, constants.ZERO_AMOUNT).callAsync(); expect(result).bignumber.to.be.eq(constants.ZERO_AMOUNT); }); it('should calculate correct value for values that are not equal', async () => { - const result = await safeMath.externalSafeSub.callAsync(toBigNumber(15), toBigNumber(13)); + const result = await safeMath.externalSafeSub(toBigNumber(15), toBigNumber(13)).callAsync(); expect(result).bignumber.to.be.eq(toBigNumber(2)); }); }); @@ -136,7 +136,7 @@ blockchainTests('SafeMath', env => { const a = ONE_ETHER; const b = ONE_ETHER.dividedToIntegerBy(2); const expected = ReferenceFunctions.safeAdd(a, b); - const actual = await safeMath.externalSafeAdd.callAsync(a, b); + const actual = await safeMath.externalSafeAdd(a, b).callAsync(); expect(actual).bignumber.to.be.eq(expected); }); @@ -148,55 +148,55 @@ blockchainTests('SafeMath', env => { a, b, ); - return expect(safeMath.externalSafeAdd.callAsync(a, b)).to.revertWith(expectedError); + return expect(safeMath.externalSafeAdd(a, b).callAsync()).to.revertWith(expectedError); }); it('should calculate correct value if addition does not overflow', async () => { - const result = await safeMath.externalSafeAdd.callAsync(toBigNumber(15), toBigNumber(13)); + const result = await safeMath.externalSafeAdd(toBigNumber(15), toBigNumber(13)).callAsync(); expect(result).bignumber.to.be.eq(toBigNumber(28)); }); it('should calculate correct value if first argument is zero', async () => { - const result = await safeMath.externalSafeAdd.callAsync(constants.ZERO_AMOUNT, toBigNumber(13)); + const result = await safeMath.externalSafeAdd(constants.ZERO_AMOUNT, toBigNumber(13)).callAsync(); expect(result).bignumber.to.be.eq(toBigNumber(13)); }); it('should calculate correct value if second argument is zero', async () => { - const result = await safeMath.externalSafeAdd.callAsync(toBigNumber(13), constants.ZERO_AMOUNT); + const result = await safeMath.externalSafeAdd(toBigNumber(13), constants.ZERO_AMOUNT).callAsync(); expect(result).bignumber.to.be.eq(toBigNumber(13)); }); }); describe('maxUint256', () => { it('should return first argument if it is greater than the second', async () => { - const result = await safeMath.externalMaxUint256.callAsync(toBigNumber(13), constants.ZERO_AMOUNT); + const result = await safeMath.externalMaxUint256(toBigNumber(13), constants.ZERO_AMOUNT).callAsync(); expect(result).bignumber.to.be.eq(toBigNumber(13)); }); it('should return first argument if it is equal the second', async () => { - const result = await safeMath.externalMaxUint256.callAsync(constants.ZERO_AMOUNT, constants.ZERO_AMOUNT); + const result = await safeMath.externalMaxUint256(constants.ZERO_AMOUNT, constants.ZERO_AMOUNT).callAsync(); expect(result).bignumber.to.be.eq(constants.ZERO_AMOUNT); }); it('should return second argument if it is greater than the first', async () => { - const result = await safeMath.externalMaxUint256.callAsync(constants.ZERO_AMOUNT, toBigNumber(13)); + const result = await safeMath.externalMaxUint256(constants.ZERO_AMOUNT, toBigNumber(13)).callAsync(); expect(result).bignumber.to.be.eq(toBigNumber(13)); }); }); describe('minUint256', () => { it('should return first argument if it is less than the second', async () => { - const result = await safeMath.externalMaxUint256.callAsync(constants.ZERO_AMOUNT, toBigNumber(13)); + const result = await safeMath.externalMaxUint256(constants.ZERO_AMOUNT, toBigNumber(13)).callAsync(); expect(result).bignumber.to.be.eq(toBigNumber(13)); }); it('should return first argument if it is equal the second', async () => { - const result = await safeMath.externalMaxUint256.callAsync(constants.ZERO_AMOUNT, constants.ZERO_AMOUNT); + const result = await safeMath.externalMaxUint256(constants.ZERO_AMOUNT, constants.ZERO_AMOUNT).callAsync(); expect(result).bignumber.to.be.eq(constants.ZERO_AMOUNT); }); it('should return second argument if it is less than the first', async () => { - const result = await safeMath.externalMaxUint256.callAsync(toBigNumber(13), constants.ZERO_AMOUNT); + const result = await safeMath.externalMaxUint256(toBigNumber(13), constants.ZERO_AMOUNT).callAsync(); expect(result).bignumber.to.be.eq(toBigNumber(13)); }); }); diff --git a/contracts/utils/test/log_decoding.ts b/contracts/utils/test/log_decoding.ts index 13d9d14971..507a0c5459 100644 --- a/contracts/utils/test/log_decoding.ts +++ b/contracts/utils/test/log_decoding.ts @@ -48,19 +48,25 @@ describe('TestLogDecoding', () => { describe('Decoding Log Arguments', () => { it('should decode locally emitted event args when no dependencies are passed into wrapper', async () => { - const txReceipt = await testLogDecodingDeployedWithoutDependencies.emitEvent.awaitTransactionSuccessAsync(); + const txReceipt = await testLogDecodingDeployedWithoutDependencies + .emitEvent() + .awaitTransactionSuccessAsync(); expect(txReceipt.logs.length).to.be.equal(1); // tslint:disable no-unnecessary-type-assertion expect((txReceipt.logs[0] as LogWithDecodedArgs).args).to.be.deep.equal(expectedEvent); }); it('should not decode event args when no dependencies are passed into wrapper', async () => { - const txReceipt = await testLogDecodingDeployedWithoutDependencies.emitEventDownstream.awaitTransactionSuccessAsync(); + const txReceipt = await testLogDecodingDeployedWithoutDependencies + .emitEventDownstream() + .awaitTransactionSuccessAsync(); expect(txReceipt.logs.length).to.be.equal(1); // tslint:disable no-unnecessary-type-assertion expect((txReceipt.logs[0] as LogWithDecodedArgs).args).to.be.undefined(); }); it('should decode args for local but not downstream event when no dependencies are passed into wrapper', async () => { - const txReceipt = await testLogDecodingDeployedWithoutDependencies.emitEventsLocalAndDownstream.awaitTransactionSuccessAsync(); + const txReceipt = await testLogDecodingDeployedWithoutDependencies + .emitEventsLocalAndDownstream() + .awaitTransactionSuccessAsync(); expect(txReceipt.logs.length).to.be.equal(2); // tslint:disable no-unnecessary-type-assertion expect((txReceipt.logs[0] as LogWithDecodedArgs).args).to.be.deep.equal(expectedEvent); @@ -68,13 +74,15 @@ describe('TestLogDecoding', () => { expect((txReceipt.logs[1] as LogWithDecodedArgs).args).to.be.undefined(); }); it('should decode locally emitted event args when dependencies are passed into wrapper', async () => { - const txReceipt = await testLogDecodingWithDependencies.emitEvent.awaitTransactionSuccessAsync(); + const txReceipt = await testLogDecodingWithDependencies.emitEvent().awaitTransactionSuccessAsync(); expect(txReceipt.logs.length).to.be.equal(1); // tslint:disable no-unnecessary-type-assertion expect((txReceipt.logs[0] as LogWithDecodedArgs).args).to.be.deep.equal(expectedEvent); }); it('should decode downstream event args when dependencies are passed into wrapper', async () => { - const txReceipt = await testLogDecodingWithDependencies.emitEventDownstream.awaitTransactionSuccessAsync(); + const txReceipt = await testLogDecodingWithDependencies + .emitEventDownstream() + .awaitTransactionSuccessAsync(); expect(txReceipt.logs.length).to.be.equal(1); // tslint:disable no-unnecessary-type-assertion expect((txReceipt.logs[0] as LogWithDecodedArgs).args).to.be.deep.equal( @@ -82,7 +90,9 @@ describe('TestLogDecoding', () => { ); }); it('should decode args for both local and downstream events when dependencies are passed into wrapper', async () => { - const txReceipt = await testLogDecodingWithDependencies.emitEventsLocalAndDownstream.awaitTransactionSuccessAsync(); + const txReceipt = await testLogDecodingWithDependencies + .emitEventsLocalAndDownstream() + .awaitTransactionSuccessAsync(); expect(txReceipt.logs.length).to.be.equal(2); // tslint:disable no-unnecessary-type-assertion expect((txReceipt.logs[0] as LogWithDecodedArgs).args).to.be.deep.equal(expectedEvent); diff --git a/contracts/utils/test/ownable.ts b/contracts/utils/test/ownable.ts index d4859f730f..e21a7ae82b 100644 --- a/contracts/utils/test/ownable.ts +++ b/contracts/utils/test/ownable.ts @@ -23,11 +23,11 @@ blockchainTests.resets('Ownable', env => { describe('onlyOwner', () => { it('should revert if sender is not the owner', async () => { const expectedError = new OwnableRevertErrors.OnlyOwnerError(nonOwner, owner); - return expect(ownable.externalOnlyOwner.callAsync({ from: nonOwner })).to.revertWith(expectedError); + return expect(ownable.externalOnlyOwner().callAsync({ from: nonOwner })).to.revertWith(expectedError); }); it('should succeed if sender is the owner', async () => { - const isSuccessful = await ownable.externalOnlyOwner.callAsync({ from: owner }); + const isSuccessful = await ownable.externalOnlyOwner().callAsync({ from: owner }); expect(isSuccessful).to.be.true(); }); }); @@ -35,12 +35,12 @@ blockchainTests.resets('Ownable', env => { describe('transferOwnership', () => { it('should revert if the specified new owner is the zero address', async () => { const expectedError = new OwnableRevertErrors.TransferOwnerToZeroError(); - const tx = ownable.transferOwnership.sendTransactionAsync(constants.NULL_ADDRESS, { from: owner }); + const tx = ownable.transferOwnership(constants.NULL_ADDRESS).sendTransactionAsync({ from: owner }); return expect(tx).to.revertWith(expectedError); }); it('should transfer ownership if the specified new owner is not the zero address', async () => { - const receipt = await ownable.transferOwnership.awaitTransactionSuccessAsync(nonOwner, { from: owner }); + const receipt = await ownable.transferOwnership(nonOwner).awaitTransactionSuccessAsync({ from: owner }); // Ensure that the correct logs were emitted. expect(receipt.logs.length).to.be.eq(1); @@ -51,7 +51,7 @@ blockchainTests.resets('Ownable', env => { expect(event).to.be.deep.eq({ previousOwner: owner, newOwner: nonOwner }); // Ensure that the owner was actually updated - const updatedOwner = await ownable.owner.callAsync(); + const updatedOwner = await ownable.owner().callAsync(); expect(updatedOwner).to.be.eq(nonOwner); }); }); diff --git a/contracts/utils/test/reentrancy_guard.ts b/contracts/utils/test/reentrancy_guard.ts index 9018e6f4c0..c816bf550d 100644 --- a/contracts/utils/test/reentrancy_guard.ts +++ b/contracts/utils/test/reentrancy_guard.ts @@ -31,11 +31,11 @@ describe('ReentrancyGuard', () => { describe('nonReentrant', () => { it('should revert if reentrancy occurs', async () => { const expectedError = new ReentrancyGuardRevertErrors.IllegalReentrancyError(); - return expect(guard.guarded.sendTransactionAsync(true)).to.revertWith(expectedError); + return expect(guard.guarded(true).sendTransactionAsync()).to.revertWith(expectedError); }); it('should succeed if reentrancy does not occur', async () => { - const isSuccessful = await guard.guarded.callAsync(false); + const isSuccessful = await guard.guarded(false).callAsync(); expect(isSuccessful).to.be.true(); }); }); diff --git a/contracts/utils/test/refundable.ts b/contracts/utils/test/refundable.ts index 8411716231..d474f139d2 100644 --- a/contracts/utils/test/refundable.ts +++ b/contracts/utils/test/refundable.ts @@ -35,14 +35,14 @@ blockchainTests('Refundable', env => { blockchainTests.resets('refundNonzeroBalance', () => { it('should not send a refund when no value is sent', async () => { // Send 100 wei to the refundable contract that should be refunded. - await receiver.testRefundNonZeroBalance.awaitTransactionSuccessAsync(refundable.address, { + await receiver.testRefundNonZeroBalance(refundable.address).awaitTransactionSuccessAsync({ value: constants.ZERO_AMOUNT, }); }); it('should send a full refund when nonzero value is sent', async () => { // Send 100 wei to the refundable contract that should be refunded. - await receiver.testRefundNonZeroBalance.awaitTransactionSuccessAsync(refundable.address, { + await receiver.testRefundNonZeroBalance(refundable.address).awaitTransactionSuccessAsync({ value: ONE_HUNDRED, }); }); @@ -53,7 +53,7 @@ blockchainTests('Refundable', env => { blockchainTests.resets('refundFinalBalance', () => { it('should fully refund the sender when `shouldNotRefund` is false', async () => { // Send 100 wei to the refundable contract that should be refunded to the receiver contract. - await receiver.testRefundFinalBalance.awaitTransactionSuccessAsync(refundable.address, false, { + await receiver.testRefundFinalBalance(refundable.address, false).awaitTransactionSuccessAsync({ value: ONE_HUNDRED, }); }); @@ -61,19 +61,19 @@ blockchainTests('Refundable', env => { // This test may not be necessary, but it is included here as a sanity check. it('should fully refund the sender when `shouldNotRefund` is false for two calls in a row', async () => { // Send 100 wei to the refundable contract that should be refunded to the receiver contract. - await receiver.testRefundFinalBalance.awaitTransactionSuccessAsync(refundable.address, false, { + await receiver.testRefundFinalBalance(refundable.address, false).awaitTransactionSuccessAsync({ value: ONE_HUNDRED, }); // Send 1000 wei to the refundable contract that should be refunded to the receiver contract. - await receiver.testRefundFinalBalance.awaitTransactionSuccessAsync(refundable.address, false, { + await receiver.testRefundFinalBalance(refundable.address, false).awaitTransactionSuccessAsync({ value: new BigNumber(1000), }); }); it('should not refund the sender if `shouldNotRefund` is true', async () => { /// Send 100 wei to the refundable contract that should not be refunded. - await receiver.testRefundFinalBalance.awaitTransactionSuccessAsync(refundable.address, true, { + await receiver.testRefundFinalBalance(refundable.address, true).awaitTransactionSuccessAsync({ value: new BigNumber(1000), }); }); @@ -84,7 +84,7 @@ blockchainTests('Refundable', env => { blockchainTests.resets('disableRefundUntilEnd', () => { it('should fully refund the sender when `shouldNotRefund` is false', async () => { // Send 100 wei to the refundable contract that should be refunded to the receiver contract. - await receiver.testDisableRefundUntilEnd.awaitTransactionSuccessAsync(refundable.address, false, { + await receiver.testDisableRefundUntilEnd(refundable.address, false).awaitTransactionSuccessAsync({ value: ONE_HUNDRED, }); }); @@ -92,47 +92,47 @@ blockchainTests('Refundable', env => { // This test may not be necessary, but it is included here as a sanity check. it('should fully refund the sender when `shouldNotRefund` is false for two calls in a row', async () => { // Send 100 wei to the refundable contract that should be refunded to the receiver contract. - await receiver.testDisableRefundUntilEnd.awaitTransactionSuccessAsync(refundable.address, false, { + await receiver.testDisableRefundUntilEnd(refundable.address, false).awaitTransactionSuccessAsync({ value: ONE_HUNDRED, }); // Send 1000 wei to the refundable contract that should be refunded to the receiver contract. - await receiver.testDisableRefundUntilEnd.awaitTransactionSuccessAsync(refundable.address, false, { + await receiver.testDisableRefundUntilEnd(refundable.address, false).awaitTransactionSuccessAsync({ value: ONE_THOUSAND, }); }); it('should not refund the sender if `shouldNotRefund` is true', async () => { /// Send 100 wei to the refundable contract that should not be refunded. - await receiver.testDisableRefundUntilEnd.awaitTransactionSuccessAsync(refundable.address, false, { + await receiver.testDisableRefundUntilEnd(refundable.address, false).awaitTransactionSuccessAsync({ value: ONE_HUNDRED, }); }); it('should disable the `disableRefundUntilEnd` modifier and refund when `shouldNotRefund` is false', async () => { /// Send 100 wei to the refundable contract that should be refunded. - await receiver.testNestedDisableRefundUntilEnd.awaitTransactionSuccessAsync(refundable.address, false, { + await receiver.testNestedDisableRefundUntilEnd(refundable.address, false).awaitTransactionSuccessAsync({ value: ONE_HUNDRED, }); }); it('should disable the `refundFinalBalance` modifier and send no refund when `shouldNotRefund` is true', async () => { /// Send 100 wei to the refundable contract that should not be refunded. - await receiver.testNestedDisableRefundUntilEnd.awaitTransactionSuccessAsync(refundable.address, true, { + await receiver.testNestedDisableRefundUntilEnd(refundable.address, true).awaitTransactionSuccessAsync({ value: ONE_HUNDRED, }); }); it('should disable the `refundFinalBalance` modifier and refund when `shouldNotRefund` is false', async () => { /// Send 100 wei to the refundable contract that should be refunded. - await receiver.testMixedRefunds.awaitTransactionSuccessAsync(refundable.address, false, { + await receiver.testMixedRefunds(refundable.address, false).awaitTransactionSuccessAsync({ value: ONE_HUNDRED, }); }); it('should disable the `refundFinalBalance` modifier and send no refund when `shouldNotRefund` is true', async () => { /// Send 100 wei to the refundable contract that should not be refunded. - await receiver.testMixedRefunds.awaitTransactionSuccessAsync(refundable.address, true, { + await receiver.testMixedRefunds(refundable.address, true).awaitTransactionSuccessAsync({ value: ONE_HUNDRED, }); }); diff --git a/packages/asset-buyer/src/asset_buyer.ts b/packages/asset-buyer/src/asset_buyer.ts index 55f972bcd4..953a254228 100644 --- a/packages/asset-buyer/src/asset_buyer.ts +++ b/packages/asset-buyer/src/asset_buyer.ts @@ -177,7 +177,7 @@ export class AssetBuyer { ): Promise { assert.isETHAddressHex('tokenAddress', tokenAddress); assert.isBigNumber('assetBuyAmount', assetBuyAmount); - const assetData = await this._contractWrappers.devUtils.encodeERC20AssetData.callAsync(tokenAddress); + const assetData = await this._contractWrappers.devUtils.encodeERC20AssetData(tokenAddress).callAsync(); const buyQuote = this.getBuyQuoteAsync(assetData, assetBuyAmount, options); return buyQuote; } @@ -267,19 +267,20 @@ export class AssetBuyer { // if no ethAmount is provided, default to the worst ethAmount from buyQuote const value = ethAmount || worstCaseQuoteInfo.totalEthAmount; - const txHash = await this._contractWrappers.forwarder.marketBuyOrdersWithEth.sendTransactionAsync( - orders, - assetBuyAmount, - orders.map(o => o.signature), - formattedFeePercentage, - feeRecipient, - { + const txHash = await this._contractWrappers.forwarder + .marketBuyOrdersWithEth( + orders, + assetBuyAmount, + orders.map(o => o.signature), + formattedFeePercentage, + feeRecipient, + ) + .sendTransactionAsync({ value, from: finalTakerAddress.toLowerCase(), gas: gasLimit, gasPrice, - }, - ); + }); return txHash; } catch (err) { @@ -360,17 +361,17 @@ export class AssetBuyer { * Will throw if WETH does not exist for the current chain. */ private async _getEtherTokenAssetDataOrThrowAsync(): Promise { - return this._contractWrappers.devUtils.encodeERC20AssetData.callAsync( - this._contractWrappers.contractAddresses.etherToken, - ); + return this._contractWrappers.devUtils + .encodeERC20AssetData(this._contractWrappers.contractAddresses.etherToken) + .callAsync(); } /** * Get the assetData that represents the ZRX token. * Will throw if ZRX does not exist for the current chain. */ private async _getZrxTokenAssetDataOrThrowAsync(): Promise { - return this._contractWrappers.devUtils.encodeERC20AssetData.callAsync( - this._contractWrappers.contractAddresses.zrxToken, - ); + return this._contractWrappers.devUtils + .encodeERC20AssetData(this._contractWrappers.contractAddresses.zrxToken) + .callAsync(); } } diff --git a/packages/asset-buyer/src/utils/order_provider_response_processor.ts b/packages/asset-buyer/src/utils/order_provider_response_processor.ts index defd5452c9..c19bab17dc 100644 --- a/packages/asset-buyer/src/utils/order_provider_response_processor.ts +++ b/packages/asset-buyer/src/utils/order_provider_response_processor.ts @@ -44,10 +44,9 @@ export const orderProviderResponseProcessor = { if (orderValidator !== undefined) { const takerAddresses = _.map(filteredOrders, () => constants.NULL_ADDRESS); try { - const [ordersInfo, tradersInfo] = await orderValidator.getOrdersAndTradersInfo.callAsync( - filteredOrders, - takerAddresses, - ); + const [ordersInfo, tradersInfo] = await orderValidator + .getOrdersAndTradersInfo(filteredOrders, takerAddresses) + .callAsync(); const ordersAndTradersInfo = ordersInfo.map((orderInfo, index) => { return { orderInfo, diff --git a/packages/asset-swapper/src/quote_consumers/exchange_swap_quote_consumer.ts b/packages/asset-swapper/src/quote_consumers/exchange_swap_quote_consumer.ts index 7e79b930c7..996a652c10 100644 --- a/packages/asset-swapper/src/quote_consumers/exchange_swap_quote_consumer.ts +++ b/packages/asset-swapper/src/quote_consumers/exchange_swap_quote_consumer.ts @@ -144,28 +144,22 @@ export class ExchangeSwapQuoteConsumer implements SwapQuoteConsumerBase o.signature), - { + txHash = await this._contractWrappers.exchange + .marketBuyOrdersNoThrow(orders, makerAssetFillAmount, orders.map(o => o.signature)) + .sendTransactionAsync({ from: finalTakerAddress, gas: gasLimit, gasPrice, - }, - ); + }); } else { const { takerAssetFillAmount } = quote; - txHash = await this._contractWrappers.exchange.marketSellOrdersNoThrow.sendTransactionAsync( - orders, - takerAssetFillAmount, - orders.map(o => o.signature), - { + txHash = await this._contractWrappers.exchange + .marketSellOrdersNoThrow(orders, takerAssetFillAmount, orders.map(o => o.signature)) + .sendTransactionAsync({ from: finalTakerAddress, gas: gasLimit, gasPrice, - }, - ); + }); } return txHash; } catch (err) { diff --git a/packages/asset-swapper/src/quote_consumers/forwarder_swap_quote_consumer.ts b/packages/asset-swapper/src/quote_consumers/forwarder_swap_quote_consumer.ts index a709fa53db..82420df4a9 100644 --- a/packages/asset-swapper/src/quote_consumers/forwarder_swap_quote_consumer.ts +++ b/packages/asset-swapper/src/quote_consumers/forwarder_swap_quote_consumer.ts @@ -196,32 +196,29 @@ export class ForwarderSwapQuoteConsumer implements SwapQuoteConsumerBase o.signature), - formattedFeePercentage, - feeRecipient, - { + txHash = await this._contractWrappers.forwarder + .marketBuyOrdersWithEth( + orders, + makerAssetFillAmount, + orders.map(o => o.signature), + formattedFeePercentage, + feeRecipient, + ) + .sendTransactionAsync({ value, from: finalTakerAddress.toLowerCase(), gas: gasLimit, gasPrice, - }, - ); + }); } else { - txHash = await this._contractWrappers.forwarder.marketSellOrdersWithEth.sendTransactionAsync( - orders, - orders.map(o => o.signature), - formattedFeePercentage, - feeRecipient, - { + txHash = await this._contractWrappers.forwarder + .marketSellOrdersWithEth(orders, orders.map(o => o.signature), formattedFeePercentage, feeRecipient) + .sendTransactionAsync({ value, from: finalTakerAddress.toLowerCase(), gas: gasLimit, gasPrice, - }, - ); + }); } return txHash; } catch (err) { @@ -236,8 +233,8 @@ export class ForwarderSwapQuoteConsumer implements SwapQuoteConsumerBase { - return this._contractWrappers.devUtils.encodeERC20AssetData.callAsync( - this._contractWrappers.contractAddresses.etherToken, - ); + return this._contractWrappers.devUtils + .encodeERC20AssetData(this._contractWrappers.contractAddresses.etherToken) + .callAsync(); } } diff --git a/packages/asset-swapper/src/swap_quoter.ts b/packages/asset-swapper/src/swap_quoter.ts index a5f43d8350..65e24e3d9f 100644 --- a/packages/asset-swapper/src/swap_quoter.ts +++ b/packages/asset-swapper/src/swap_quoter.ts @@ -216,8 +216,12 @@ export class SwapQuoter { assert.isETHAddressHex('makerTokenAddress', makerTokenAddress); assert.isETHAddressHex('takerTokenAddress', takerTokenAddress); assert.isBigNumber('makerAssetBuyAmount', makerAssetBuyAmount); - const makerAssetData = await this._contractWrappers.devUtils.encodeERC20AssetData.callAsync(makerTokenAddress); - const takerAssetData = await this._contractWrappers.devUtils.encodeERC20AssetData.callAsync(takerTokenAddress); + const makerAssetData = await this._contractWrappers.devUtils + .encodeERC20AssetData(makerTokenAddress) + .callAsync(); + const takerAssetData = await this._contractWrappers.devUtils + .encodeERC20AssetData(takerTokenAddress) + .callAsync(); const swapQuote = this.getMarketBuySwapQuoteForAssetDataAsync( makerAssetData, takerAssetData, @@ -246,8 +250,12 @@ export class SwapQuoter { assert.isETHAddressHex('makerTokenAddress', makerTokenAddress); assert.isETHAddressHex('takerTokenAddress', takerTokenAddress); assert.isBigNumber('takerAssetSellAmount', takerAssetSellAmount); - const makerAssetData = await this._contractWrappers.devUtils.encodeERC20AssetData.callAsync(makerTokenAddress); - const takerAssetData = await this._contractWrappers.devUtils.encodeERC20AssetData.callAsync(takerTokenAddress); + const makerAssetData = await this._contractWrappers.devUtils + .encodeERC20AssetData(makerTokenAddress) + .callAsync(); + const takerAssetData = await this._contractWrappers.devUtils + .encodeERC20AssetData(takerTokenAddress) + .callAsync(); const swapQuote = this.getMarketSellSwapQuoteForAssetDataAsync( makerAssetData, takerAssetData, @@ -374,10 +382,9 @@ export class SwapQuoter { takerAddress: string, ): Promise<[boolean, boolean]> { const orderValidator = this._contractWrappers.orderValidator; - const balanceAndAllowance = await orderValidator.getBalanceAndAllowance.callAsync( - takerAddress, - swapQuote.takerAssetData, - ); + const balanceAndAllowance = await orderValidator + .getBalanceAndAllowance(takerAddress, swapQuote.takerAssetData) + .callAsync(); const allowance = balanceAndAllowance[1]; return [ allowance.isGreaterThanOrEqualTo(swapQuote.bestCaseQuoteInfo.totalTakerTokenAmount), @@ -397,9 +404,9 @@ export class SwapQuoter { * Will throw if ZRX does not exist for the current chain. */ private async _getZrxTokenAssetDataOrThrowAsync(): Promise { - return this._contractWrappers.devUtils.encodeERC20AssetData.callAsync( - this._contractWrappers.contractAddresses.zrxToken, - ); + return this._contractWrappers.devUtils + .encodeERC20AssetData(this._contractWrappers.contractAddresses.zrxToken) + .callAsync(); } /** diff --git a/packages/asset-swapper/src/utils/order_provider_response_processor.ts b/packages/asset-swapper/src/utils/order_provider_response_processor.ts index 82531d0ff4..92442fa52c 100644 --- a/packages/asset-swapper/src/utils/order_provider_response_processor.ts +++ b/packages/asset-swapper/src/utils/order_provider_response_processor.ts @@ -45,10 +45,9 @@ export const orderProviderResponseProcessor = { if (orderValidator !== undefined) { const takerAddresses = _.map(filteredOrders, () => constants.NULL_ADDRESS); try { - const [ordersInfo, tradersInfo] = await orderValidator.getOrdersAndTradersInfo.callAsync( - filteredOrders, - takerAddresses, - ); + const [ordersInfo, tradersInfo] = await orderValidator + .getOrdersAndTradersInfo(filteredOrders, takerAddresses) + .callAsync(); const ordersAndTradersInfo: any[] = ordersInfo.map((orderInfo, index) => { const singleOrderAndTraderInfo = { orderInfo, diff --git a/packages/asset-swapper/src/utils/swap_quote_consumer_utils.ts b/packages/asset-swapper/src/utils/swap_quote_consumer_utils.ts index 3a1fd1c9d8..87be11f339 100644 --- a/packages/asset-swapper/src/utils/swap_quote_consumer_utils.ts +++ b/packages/asset-swapper/src/utils/swap_quote_consumer_utils.ts @@ -52,7 +52,7 @@ export const swapQuoteConsumerUtils = { ): Promise<[BigNumber, BigNumber]> { const web3Wrapper = new Web3Wrapper(provider); const ethBalance = await web3Wrapper.getBalanceInWeiAsync(takerAddress); - const wethBalance = await contractWrappers.weth9.balanceOf.callAsync(takerAddress); + const wethBalance = await contractWrappers.weth9.balanceOf(takerAddress).callAsync(); return [ethBalance, wethBalance]; }, isValidForwarderSwapQuote(swapQuote: SwapQuote, wethAssetData: string): boolean { @@ -84,9 +84,9 @@ export const swapQuoteConsumerUtils = { provider: Provider, opts: Partial, ): Promise { - const wethAssetData = await contractWrappers.devUtils.encodeERC20AssetData.callAsync( - contractWrappers.contractAddresses.etherToken, - ); + const wethAssetData = await contractWrappers.devUtils + .encodeERC20AssetData(contractWrappers.contractAddresses.etherToken) + .callAsync(); if (swapQuoteConsumerUtils.isValidForwarderSwapQuote(quote, wethAssetData)) { if (opts.takerAddress !== undefined) { assert.isETHAddressHex('takerAddress', opts.takerAddress); diff --git a/packages/asset-swapper/test/exchange_swap_quote_consumer_test.ts b/packages/asset-swapper/test/exchange_swap_quote_consumer_test.ts index f48f28c856..880435e249 100644 --- a/packages/asset-swapper/test/exchange_swap_quote_consumer_test.ts +++ b/packages/asset-swapper/test/exchange_swap_quote_consumer_test.ts @@ -66,9 +66,9 @@ describe('ExchangeSwapQuoteConsumer', () => { [coinbaseAddress, takerAddress, makerAddress, feeRecipient] = userAddresses; [makerTokenAddress, takerTokenAddress] = tokenUtils.getDummyERC20TokenAddresses(); [makerAssetData, takerAssetData, wethAssetData] = [ - await contractWrappers.devUtils.encodeERC20AssetData.callAsync(makerTokenAddress), - await contractWrappers.devUtils.encodeERC20AssetData.callAsync(takerTokenAddress), - await contractWrappers.devUtils.encodeERC20AssetData.callAsync(contractAddresses.etherToken), + await contractWrappers.devUtils.encodeERC20AssetData(makerTokenAddress).callAsync(), + await contractWrappers.devUtils.encodeERC20AssetData(takerTokenAddress).callAsync(), + await contractWrappers.devUtils.encodeERC20AssetData(contractAddresses.etherToken).callAsync(), ]; erc20TokenContract = new ERC20TokenContract(makerTokenAddress, provider); @@ -79,12 +79,12 @@ describe('ExchangeSwapQuoteConsumer', () => { takerAddress, makerAssetData, takerAssetData, - makerFeeAssetData: await contractWrappers.devUtils.encodeERC20AssetData.callAsync( - contractAddresses.zrxToken, - ), - takerFeeAssetData: await contractWrappers.devUtils.encodeERC20AssetData.callAsync( - contractAddresses.zrxToken, - ), + makerFeeAssetData: await contractWrappers.devUtils + .encodeERC20AssetData(contractAddresses.zrxToken) + .callAsync(), + takerFeeAssetData: await contractWrappers.devUtils + .encodeERC20AssetData(contractAddresses.zrxToken) + .callAsync(), exchangeAddress: contractAddresses.exchange, chainId, }; @@ -132,24 +132,24 @@ describe('ExchangeSwapQuoteConsumer', () => { * Does not test the validity of the state change performed by the forwarder smart contract */ it('should perform a marketSell execution when provided a MarketSell type swapQuote', async () => { - let makerBalance = await erc20TokenContract.balanceOf.callAsync(makerAddress); - let takerBalance = await erc20TokenContract.balanceOf.callAsync(takerAddress); + let makerBalance = await erc20TokenContract.balanceOf(makerAddress).callAsync(); + let takerBalance = await erc20TokenContract.balanceOf(takerAddress).callAsync(); expect(makerBalance).to.bignumber.equal(new BigNumber(10).multipliedBy(ONE_ETH_IN_WEI)); expect(takerBalance).to.bignumber.equal(constants.ZERO_AMOUNT); await swapQuoteConsumer.executeSwapQuoteOrThrowAsync(marketSellSwapQuote, { takerAddress }); - makerBalance = await erc20TokenContract.balanceOf.callAsync(makerAddress); - takerBalance = await erc20TokenContract.balanceOf.callAsync(takerAddress); + makerBalance = await erc20TokenContract.balanceOf(makerAddress).callAsync(); + takerBalance = await erc20TokenContract.balanceOf(takerAddress).callAsync(); expect(takerBalance).to.bignumber.equal(new BigNumber(10).multipliedBy(ONE_ETH_IN_WEI)); expect(makerBalance).to.bignumber.equal(constants.ZERO_AMOUNT); }); it('should perform a marketBuy execution when provided a MarketBuy type swapQuote', async () => { - let makerBalance = await erc20TokenContract.balanceOf.callAsync(makerAddress); - let takerBalance = await erc20TokenContract.balanceOf.callAsync(takerAddress); + let makerBalance = await erc20TokenContract.balanceOf(makerAddress).callAsync(); + let takerBalance = await erc20TokenContract.balanceOf(takerAddress).callAsync(); expect(makerBalance).to.bignumber.equal(new BigNumber(10).multipliedBy(ONE_ETH_IN_WEI)); expect(takerBalance).to.bignumber.equal(constants.ZERO_AMOUNT); await swapQuoteConsumer.executeSwapQuoteOrThrowAsync(marketBuySwapQuote, { takerAddress }); - makerBalance = await erc20TokenContract.balanceOf.callAsync(makerAddress); - takerBalance = await erc20TokenContract.balanceOf.callAsync(takerAddress); + makerBalance = await erc20TokenContract.balanceOf(makerAddress).callAsync(); + takerBalance = await erc20TokenContract.balanceOf(takerAddress).callAsync(); expect(takerBalance).to.bignumber.equal(new BigNumber(10).multipliedBy(ONE_ETH_IN_WEI)); expect(makerBalance).to.bignumber.equal(constants.ZERO_AMOUNT); }); @@ -192,8 +192,8 @@ describe('ExchangeSwapQuoteConsumer', () => { describe('getCalldataOrThrow', () => { describe('valid swap quote', async () => { it('provide correct and optimized calldata options with default options for a marketSell SwapQuote (no affiliate fees)', async () => { - let makerBalance = await erc20TokenContract.balanceOf.callAsync(makerAddress); - let takerBalance = await erc20TokenContract.balanceOf.callAsync(takerAddress); + let makerBalance = await erc20TokenContract.balanceOf(makerAddress).callAsync(); + let takerBalance = await erc20TokenContract.balanceOf(takerAddress).callAsync(); expect(makerBalance).to.bignumber.equal(new BigNumber(10).multipliedBy(ONE_ETH_IN_WEI)); expect(takerBalance).to.bignumber.equal(constants.ZERO_AMOUNT); const { calldataHexString, toAddress } = await swapQuoteConsumer.getCalldataOrThrowAsync( @@ -207,14 +207,14 @@ describe('ExchangeSwapQuoteConsumer', () => { data: calldataHexString, gas: 4000000, }); - makerBalance = await erc20TokenContract.balanceOf.callAsync(makerAddress); - takerBalance = await erc20TokenContract.balanceOf.callAsync(takerAddress); + makerBalance = await erc20TokenContract.balanceOf(makerAddress).callAsync(); + takerBalance = await erc20TokenContract.balanceOf(takerAddress).callAsync(); expect(takerBalance).to.bignumber.equal(new BigNumber(10).multipliedBy(ONE_ETH_IN_WEI)); expect(makerBalance).to.bignumber.equal(constants.ZERO_AMOUNT); }); it('provide correct and optimized calldata options with default options for a marketBuy SwapQuote (no affiliate fees)', async () => { - let makerBalance = await erc20TokenContract.balanceOf.callAsync(makerAddress); - let takerBalance = await erc20TokenContract.balanceOf.callAsync(takerAddress); + let makerBalance = await erc20TokenContract.balanceOf(makerAddress).callAsync(); + let takerBalance = await erc20TokenContract.balanceOf(takerAddress).callAsync(); expect(makerBalance).to.bignumber.equal(new BigNumber(10).multipliedBy(ONE_ETH_IN_WEI)); expect(takerBalance).to.bignumber.equal(constants.ZERO_AMOUNT); const { calldataHexString, toAddress } = await swapQuoteConsumer.getCalldataOrThrowAsync( @@ -228,8 +228,8 @@ describe('ExchangeSwapQuoteConsumer', () => { data: calldataHexString, gas: 4000000, }); - makerBalance = await erc20TokenContract.balanceOf.callAsync(makerAddress); - takerBalance = await erc20TokenContract.balanceOf.callAsync(takerAddress); + makerBalance = await erc20TokenContract.balanceOf(makerAddress).callAsync(); + takerBalance = await erc20TokenContract.balanceOf(takerAddress).callAsync(); expect(takerBalance).to.bignumber.equal(new BigNumber(10).multipliedBy(ONE_ETH_IN_WEI)); expect(makerBalance).to.bignumber.equal(constants.ZERO_AMOUNT); }); diff --git a/packages/asset-swapper/test/forwarder_swap_quote_consumer_test.ts b/packages/asset-swapper/test/forwarder_swap_quote_consumer_test.ts index 4b6621487e..6de57242e7 100644 --- a/packages/asset-swapper/test/forwarder_swap_quote_consumer_test.ts +++ b/packages/asset-swapper/test/forwarder_swap_quote_consumer_test.ts @@ -66,9 +66,9 @@ describe('ForwarderSwapQuoteConsumer', () => { [makerTokenAddress, takerTokenAddress] = tokenUtils.getDummyERC20TokenAddresses(); erc20Token = new ERC20TokenContract(makerTokenAddress, provider); [makerAssetData, takerAssetData, wethAssetData] = [ - await contractWrappers.devUtils.encodeERC20AssetData.callAsync(makerTokenAddress), - await contractWrappers.devUtils.encodeERC20AssetData.callAsync(takerTokenAddress), - await contractWrappers.devUtils.encodeERC20AssetData.callAsync(contractAddresses.etherToken), + await contractWrappers.devUtils.encodeERC20AssetData(makerTokenAddress).callAsync(), + await contractWrappers.devUtils.encodeERC20AssetData(takerTokenAddress).callAsync(), + await contractWrappers.devUtils.encodeERC20AssetData(contractAddresses.etherToken).callAsync(), ]; }); after(async () => { @@ -84,11 +84,11 @@ describe('ForwarderSwapQuoteConsumer', () => { new BigNumber(0), ); - await erc20Token.transfer.sendTransactionAsync(makerAddress, totalFillableAmount, { + await erc20Token.transfer(makerAddress, totalFillableAmount).sendTransactionAsync({ from: coinbaseAddress, }); - await erc20Token.approve.sendTransactionAsync(erc20ProxyAddress, UNLIMITED_ALLOWANCE, { + await erc20Token.approve(erc20ProxyAddress, UNLIMITED_ALLOWANCE).sendTransactionAsync({ from: makerAddress, }); orders = await getSignedOrdersWithNoFeesAsync( @@ -154,32 +154,32 @@ describe('ForwarderSwapQuoteConsumer', () => { * Does not test the validity of the state change performed by the forwarder smart contract */ it('should perform a marketSell execution when provided a MarketSell type swapQuote', async () => { - let makerBalance = await erc20Token.balanceOf.callAsync(makerAddress); - let takerBalance = await erc20Token.balanceOf.callAsync(takerAddress); + let makerBalance = await erc20Token.balanceOf(makerAddress).callAsync(); + let takerBalance = await erc20Token.balanceOf(takerAddress).callAsync(); expect(makerBalance).to.bignumber.equal(new BigNumber(10).multipliedBy(ONE_ETH_IN_WEI)); expect(takerBalance).to.bignumber.equal(constants.ZERO_AMOUNT); await swapQuoteConsumer.executeSwapQuoteOrThrowAsync(marketSellSwapQuote, { takerAddress }); - makerBalance = await erc20Token.balanceOf.callAsync(makerAddress); - takerBalance = await erc20Token.balanceOf.callAsync(takerAddress); + makerBalance = await erc20Token.balanceOf(makerAddress).callAsync(); + takerBalance = await erc20Token.balanceOf(takerAddress).callAsync(); expect(makerBalance).to.bignumber.equal(new BigNumber(0.5).multipliedBy(ONE_ETH_IN_WEI)); expect(takerBalance).to.bignumber.equal(new BigNumber(9.5).multipliedBy(ONE_ETH_IN_WEI)); }); it('should perform a marketBuy execution when provided a MarketBuy type swapQuote', async () => { - let makerBalance = await erc20Token.balanceOf.callAsync(makerAddress); - let takerBalance = await erc20Token.balanceOf.callAsync(takerAddress); + let makerBalance = await erc20Token.balanceOf(makerAddress).callAsync(); + let takerBalance = await erc20Token.balanceOf(takerAddress).callAsync(); expect(makerBalance).to.bignumber.equal(new BigNumber(10).multipliedBy(ONE_ETH_IN_WEI)); expect(takerBalance).to.bignumber.equal(constants.ZERO_AMOUNT); await swapQuoteConsumer.executeSwapQuoteOrThrowAsync(marketBuySwapQuote, { takerAddress }); - makerBalance = await erc20Token.balanceOf.callAsync(makerAddress); - takerBalance = await erc20Token.balanceOf.callAsync(takerAddress); + makerBalance = await erc20Token.balanceOf(makerAddress).callAsync(); + takerBalance = await erc20Token.balanceOf(takerAddress).callAsync(); expect(takerBalance).to.bignumber.equal(new BigNumber(10).multipliedBy(ONE_ETH_IN_WEI)); expect(makerBalance).to.bignumber.equal(constants.ZERO_AMOUNT); }); it('should perform a marketBuy execution with affiliate fees', async () => { - let makerBalance = await erc20Token.balanceOf.callAsync(makerAddress); - let takerBalance = await erc20Token.balanceOf.callAsync(takerAddress); + let makerBalance = await erc20Token.balanceOf(makerAddress).callAsync(); + let takerBalance = await erc20Token.balanceOf(takerAddress).callAsync(); const feeRecipientEthBalanceBefore = await web3Wrapper.getBalanceInWeiAsync(feeRecipient); expect(makerBalance).to.bignumber.equal(new BigNumber(10).multipliedBy(ONE_ETH_IN_WEI)); expect(takerBalance).to.bignumber.equal(constants.ZERO_AMOUNT); @@ -188,8 +188,8 @@ describe('ForwarderSwapQuoteConsumer', () => { feePercentage: 0.05, feeRecipient, }); - makerBalance = await erc20Token.balanceOf.callAsync(makerAddress); - takerBalance = await erc20Token.balanceOf.callAsync(takerAddress); + makerBalance = await erc20Token.balanceOf(makerAddress).callAsync(); + takerBalance = await erc20Token.balanceOf(takerAddress).callAsync(); const feeRecipientEthBalanceAfter = await web3Wrapper.getBalanceInWeiAsync(feeRecipient); expect(makerBalance).to.bignumber.equal(constants.ZERO_AMOUNT); expect(takerBalance).to.bignumber.equal(new BigNumber(10).multipliedBy(ONE_ETH_IN_WEI)); @@ -200,15 +200,15 @@ describe('ForwarderSwapQuoteConsumer', () => { // TODO(david) Finish marketSell affiliate fee excution testing // it('should perform a marketSell execution with affiliate fees', async () => { - // let makerBalance = await erc20Token.balanceOf.callAsync(makerAddress); - // let takerBalance = await erc20Token.balanceOf.callAsync(takerAddress); + // let makerBalance = await erc20Token.balanceOf(makerAddress).callAsync(); + // let takerBalance = await erc20Token.balanceOf(takerAddress).callAsync(); // const feeRecipientEthBalanceBefore = await web3Wrapper.getBalanceInWeiAsync(feeRecipient); // expect(makerBalance).to.bignumber.equal((new BigNumber(10)).multipliedBy(ONE_ETH_IN_WEI)); // expect(takerBalance).to.bignumber.equal(constants.ZERO_AMOUNT); // console.log(makerBalance, takerBalance, feeRecipientEthBalanceBefore); // await swapQuoteConsumer.executeSwapQuoteOrThrowAsync(marketSellSwapQuote, { takerAddress, feePercentage: 0.05, feeRecipient }); - // makerBalance = await erc20Token.balanceOf.callAsync(makerAddress); - // takerBalance = await erc20Token.balanceOf.callAsync(takerAddress); + // makerBalance = await erc20Token.balanceOf(makerAddress).callAsync(); + // takerBalance = await erc20Token.balanceOf(takerAddress).callAsync(); // const feeRecipientEthBalanceAfter = await web3Wrapper.getBalanceInWeiAsync(feeRecipient); // console.log(makerBalance, takerBalance, feeRecipientEthBalanceAfter); // expect(makerBalance).to.bignumber.equal((new BigNumber(0.5)).multipliedBy(ONE_ETH_IN_WEI)); @@ -364,8 +364,8 @@ describe('ForwarderSwapQuoteConsumer', () => { describe('valid swap quote', async () => { it('provide correct and optimized calldata options with default options for a marketSell SwapQuote (no affiliate fees)', async () => { - let makerBalance = await erc20Token.balanceOf.callAsync(makerAddress); - let takerBalance = await erc20Token.balanceOf.callAsync(takerAddress); + let makerBalance = await erc20Token.balanceOf(makerAddress).callAsync(); + let takerBalance = await erc20Token.balanceOf(takerAddress).callAsync(); expect(makerBalance).to.bignumber.equal(new BigNumber(10).multipliedBy(ONE_ETH_IN_WEI)); expect(takerBalance).to.bignumber.equal(constants.ZERO_AMOUNT); const { calldataHexString, toAddress } = await swapQuoteConsumer.getCalldataOrThrowAsync( @@ -380,14 +380,14 @@ describe('ForwarderSwapQuoteConsumer', () => { value: marketSellSwapQuote.worstCaseQuoteInfo.totalTakerTokenAmount, gas: 4000000, }); - makerBalance = await erc20Token.balanceOf.callAsync(makerAddress); - takerBalance = await erc20Token.balanceOf.callAsync(takerAddress); + makerBalance = await erc20Token.balanceOf(makerAddress).callAsync(); + takerBalance = await erc20Token.balanceOf(takerAddress).callAsync(); expect(makerBalance).to.bignumber.equal(new BigNumber(0.5).multipliedBy(ONE_ETH_IN_WEI)); expect(takerBalance).to.bignumber.equal(new BigNumber(9.5).multipliedBy(ONE_ETH_IN_WEI)); }); it('provide correct and optimized calldata options with default options for a marketBuy SwapQuote (no affiliate fees)', async () => { - let makerBalance = await erc20Token.balanceOf.callAsync(makerAddress); - let takerBalance = await erc20Token.balanceOf.callAsync(takerAddress); + let makerBalance = await erc20Token.balanceOf(makerAddress).callAsync(); + let takerBalance = await erc20Token.balanceOf(takerAddress).callAsync(); expect(makerBalance).to.bignumber.equal(new BigNumber(10).multipliedBy(ONE_ETH_IN_WEI)); expect(takerBalance).to.bignumber.equal(constants.ZERO_AMOUNT); const { calldataHexString, toAddress } = await swapQuoteConsumer.getCalldataOrThrowAsync( @@ -402,8 +402,8 @@ describe('ForwarderSwapQuoteConsumer', () => { value: marketBuySwapQuote.worstCaseQuoteInfo.totalTakerTokenAmount, gas: 4000000, }); - makerBalance = await erc20Token.balanceOf.callAsync(makerAddress); - takerBalance = await erc20Token.balanceOf.callAsync(takerAddress); + makerBalance = await erc20Token.balanceOf(makerAddress).callAsync(); + takerBalance = await erc20Token.balanceOf(takerAddress).callAsync(); expect(takerBalance).to.bignumber.equal(new BigNumber(10).multipliedBy(ONE_ETH_IN_WEI)); expect(makerBalance).to.bignumber.equal(constants.ZERO_AMOUNT); }); diff --git a/packages/asset-swapper/test/swap_quote_consumer_test.ts b/packages/asset-swapper/test/swap_quote_consumer_test.ts index 11cc89af3c..d7682ebbd8 100644 --- a/packages/asset-swapper/test/swap_quote_consumer_test.ts +++ b/packages/asset-swapper/test/swap_quote_consumer_test.ts @@ -60,9 +60,9 @@ describe('SwapQuoteConsumer', () => { [makerTokenAddress, takerTokenAddress] = tokenUtils.getDummyERC20TokenAddresses(); erc20Token = new ERC20TokenContract(makerTokenAddress, provider); [makerAssetData, takerAssetData, wethAssetData] = [ - await contractWrappers.devUtils.encodeERC20AssetData.callAsync(makerTokenAddress), - await contractWrappers.devUtils.encodeERC20AssetData.callAsync(takerTokenAddress), - await contractWrappers.devUtils.encodeERC20AssetData.callAsync(contractAddresses.etherToken), + await contractWrappers.devUtils.encodeERC20AssetData(makerTokenAddress).callAsync(), + await contractWrappers.devUtils.encodeERC20AssetData(takerTokenAddress).callAsync(), + await contractWrappers.devUtils.encodeERC20AssetData(contractAddresses.etherToken).callAsync(), ]; }); after(async () => { @@ -78,11 +78,11 @@ describe('SwapQuoteConsumer', () => { new BigNumber(0), ); - await erc20Token.transfer.sendTransactionAsync(makerAddress, totalFillableAmount, { + await erc20Token.transfer(makerAddress, totalFillableAmount).sendTransactionAsync({ from: coinbaseAddress, }); - await erc20Token.approve.sendTransactionAsync(erc20ProxyAddress, UNLIMITED_ALLOWANCE, { + await erc20Token.approve(erc20ProxyAddress, UNLIMITED_ALLOWANCE).sendTransactionAsync({ from: makerAddress, }); orders = await getSignedOrdersWithNoFeesAsync( @@ -116,24 +116,24 @@ describe('SwapQuoteConsumer', () => { // * Does not test the validity of the state change performed by the forwarder smart contract // */ // it('should perform an asset swap with Forwarder contract when provided corresponding useExtensionContract option', async () => { - // let makerBalance = await erc20TokenContract.balanceOf.callAsync(makerAddress); - // let takerBalance = await erc20TokenContract.balanceOf.callAsync(takerAddress); + // let makerBalance = await erc20TokenContract.balanceOf(makerAddress).callAsync(); + // let takerBalance = await erc20TokenContract.balanceOf(takerAddress).callAsync(); // expect(makerBalance).to.bignumber.equal(new BigNumber(10).multipliedBy(ONE_ETH_IN_WEI)); // expect(takerBalance).to.bignumber.equal(constants.ZERO_AMOUNT); // await swapQuoteConsumer.executeSwapQuoteOrThrowAsync(marketSellSwapQuote, { takerAddress, useExtensionContract: ConsumerType.Forwarder }); - // makerBalance = await erc20TokenContract.balanceOf.callAsync(makerAddress); - // takerBalance = await erc20TokenContract.balanceOf.callAsync(takerAddress); + // makerBalance = await erc20TokenContract.balanceOf(makerAddress).callAsync(); + // takerBalance = await erc20TokenContract.balanceOf(takerAddress).callAsync(); // expect(takerBalance).to.bignumber.equal(new BigNumber(10).multipliedBy(ONE_ETH_IN_WEI)); // expect(makerBalance).to.bignumber.equal(constants.ZERO_AMOUNT); // }); // it('should perform an asset swap with Exchange contract when provided corresponding useExtensionContract option', async () => { - // let makerBalance = await erc20TokenContract.balanceOf.callAsync(makerAddress); - // let takerBalance = await erc20TokenContract.balanceOf.callAsync(takerAddress); + // let makerBalance = await erc20TokenContract.balanceOf(makerAddress).callAsync(); + // let takerBalance = await erc20TokenContract.balanceOf(takerAddress).callAsync(); // expect(makerBalance).to.bignumber.equal(new BigNumber(10).multipliedBy(ONE_ETH_IN_WEI)); // expect(takerBalance).to.bignumber.equal(constants.ZERO_AMOUNT); // await swapQuoteConsumer.executeSwapQuoteOrThrowAsync(marketBuySwapQuote, { takerAddress }); - // makerBalance = await erc20TokenContract.balanceOf.callAsync(makerAddress); - // takerBalance = await erc20TokenContract.balanceOf.callAsync(takerAddress); + // makerBalance = await erc20TokenContract.balanceOf(makerAddress).callAsync(); + // takerBalance = await erc20TokenContract.balanceOf(takerAddress).callAsync(); // expect(takerBalance).to.bignumber.equal(new BigNumber(10).multipliedBy(ONE_ETH_IN_WEI)); // expect(makerBalance).to.bignumber.equal(constants.ZERO_AMOUNT); // }); diff --git a/packages/asset-swapper/test/swap_quote_consumer_utils_test.ts b/packages/asset-swapper/test/swap_quote_consumer_utils_test.ts index b5e782c96a..9252e014fc 100644 --- a/packages/asset-swapper/test/swap_quote_consumer_utils_test.ts +++ b/packages/asset-swapper/test/swap_quote_consumer_utils_test.ts @@ -52,9 +52,9 @@ describe('swapQuoteConsumerUtils', () => { [takerAddress, makerAddress] = userAddresses; [makerTokenAddress, takerTokenAddress] = tokenUtils.getDummyERC20TokenAddresses(); [makerAssetData, takerAssetData, wethAssetData] = [ - await contractWrappers.devUtils.encodeERC20AssetData.callAsync(makerTokenAddress), - await contractWrappers.devUtils.encodeERC20AssetData.callAsync(takerTokenAddress), - await contractWrappers.devUtils.encodeERC20AssetData.callAsync(contractAddresses.etherToken), + await contractWrappers.devUtils.encodeERC20AssetData(makerTokenAddress).callAsync(), + await contractWrappers.devUtils.encodeERC20AssetData(takerTokenAddress).callAsync(), + await contractWrappers.devUtils.encodeERC20AssetData(contractAddresses.etherToken).callAsync(), ]; swapQuoteConsumer = new SwapQuoteConsumer(provider, { @@ -145,7 +145,7 @@ describe('swapQuoteConsumerUtils', () => { }); it('should return exchange consumer if takerAsset is wEth and taker has enough weth', async () => { const etherInWei = new BigNumber(20).multipliedBy(ONE_ETH_IN_WEI); - await contractWrappers.weth9.deposit.sendTransactionAsync({ value: etherInWei, from: takerAddress }); + await contractWrappers.weth9.deposit({ value: etherInWei, from: takerAddress }).sendTransactionAsync(); const extensionContractType = await swapQuoteConsumer.getOptimalExtensionContractTypeAsync( forwarderSwapQuote, { takerAddress }, @@ -154,7 +154,7 @@ describe('swapQuoteConsumerUtils', () => { }); it('should return forwarder consumer if takerAsset is wEth and takerAddress has no available balance in either weth or eth (defaulting behavior)', async () => { const etherInWei = new BigNumber(50).multipliedBy(ONE_ETH_IN_WEI); - await contractWrappers.weth9.deposit.sendTransactionAsync({ value: etherInWei, from: takerAddress }); + await contractWrappers.weth9.deposit({ value: etherInWei, from: takerAddress }).sendTransactionAsync(); const extensionContractType = await swapQuoteConsumer.getOptimalExtensionContractTypeAsync( largeForwarderSwapQuote, { takerAddress }, diff --git a/packages/contract-wrappers/src/coordinator_wrapper.ts b/packages/contract-wrappers/src/coordinator_wrapper.ts index 40250ba9cb..75708f87ab 100644 --- a/packages/contract-wrappers/src/coordinator_wrapper.ts +++ b/packages/contract-wrappers/src/coordinator_wrapper.ts @@ -24,7 +24,6 @@ import { CoordinatorServerResponse, } from './utils/coordinator_server_types'; import { decorators } from './utils/decorators'; -import { getAbiEncodedTransactionData } from './utils/getAbiEncodedTransactionData'; /** * This class includes all the functionality related to filling or cancelling orders through @@ -110,12 +109,9 @@ export class CoordinatorWrapper { assert.doesConformToSchema('orderTransactionOpts', orderTransactionOpts, orderTxOptsSchema, [txOptsSchema]); await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper); - const data = this._getAbiEncodedTransactionData( - 'fillOrder', - signedOrder, - takerAssetFillAmount, - signedOrder.signature, - ); + const data = this._exchangeInstance + .fillOrder(signedOrder, takerAssetFillAmount, signedOrder.signature) + .getABIEncodedTransactionData(); const txHash = await this._handleFillsAsync(data, takerAddress, [signedOrder], orderTransactionOpts); return txHash; } @@ -143,12 +139,9 @@ export class CoordinatorWrapper { assert.doesConformToSchema('orderTransactionOpts', orderTransactionOpts, orderTxOptsSchema, [txOptsSchema]); await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper); - const data = this._getAbiEncodedTransactionData( - 'fillOrKillOrder', - signedOrder, - takerAssetFillAmount, - signedOrder.signature, - ); + const data = this._exchangeInstance + .fillOrKillOrder(signedOrder, takerAssetFillAmount, signedOrder.signature) + .getABIEncodedTransactionData(); const txHash = await this._handleFillsAsync(data, takerAddress, [signedOrder], orderTransactionOpts); return txHash; } @@ -183,12 +176,9 @@ export class CoordinatorWrapper { await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper); const signatures = signedOrders.map(o => o.signature); - const data = this._getAbiEncodedTransactionData( - 'batchFillOrders', - signedOrders, - takerAssetFillAmounts, - signatures, - ); + const data = this._exchangeInstance + .batchFillOrders(signedOrders, takerAssetFillAmounts, signatures) + .getABIEncodedTransactionData(); const txHash = await this._handleFillsAsync(data, takerAddress, signedOrders, orderTransactionOpts); return txHash; } @@ -218,12 +208,9 @@ export class CoordinatorWrapper { await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper); const signatures = signedOrders.map(o => o.signature); - const data = this._getAbiEncodedTransactionData( - 'batchFillOrdersNoThrow', - signedOrders, - takerAssetFillAmounts, - signatures, - ); + const data = this._exchangeInstance + .batchFillOrdersNoThrow(signedOrders, takerAssetFillAmounts, signatures) + .getABIEncodedTransactionData(); const txHash = await this._handleFillsAsync(data, takerAddress, signedOrders, orderTransactionOpts); return txHash; } @@ -253,12 +240,9 @@ export class CoordinatorWrapper { await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper); const signatures = signedOrders.map(o => o.signature); - const data = this._getAbiEncodedTransactionData( - 'batchFillOrKillOrders', - signedOrders, - takerAssetFillAmounts, - signatures, - ); + const data = this._exchangeInstance + .batchFillOrKillOrders(signedOrders, takerAssetFillAmounts, signatures) + .getABIEncodedTransactionData(); const txHash = await this._handleFillsAsync(data, takerAddress, signedOrders, orderTransactionOpts); return txHash; } @@ -286,12 +270,9 @@ export class CoordinatorWrapper { await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper); const signatures = signedOrders.map(o => o.signature); - const data = this._getAbiEncodedTransactionData( - 'marketBuyOrdersNoThrow', - signedOrders, - makerAssetFillAmount, - signatures, - ); + const data = this._exchangeInstance + .marketBuyOrdersNoThrow(signedOrders, makerAssetFillAmount, signatures) + .getABIEncodedTransactionData(); const txHash = await this._handleFillsAsync(data, takerAddress, signedOrders, orderTransactionOpts); return txHash; } @@ -319,12 +300,9 @@ export class CoordinatorWrapper { await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper); const signatures = signedOrders.map(o => o.signature); - const data = this._getAbiEncodedTransactionData( - 'marketSellOrdersNoThrow', - signedOrders, - takerAssetFillAmount, - signatures, - ); + const data = this._exchangeInstance + .marketSellOrdersNoThrow(signedOrders, takerAssetFillAmount, signatures) + .getABIEncodedTransactionData(); const txHash = await this._handleFillsAsync(data, takerAddress, signedOrders, orderTransactionOpts); return txHash; } @@ -341,7 +319,7 @@ export class CoordinatorWrapper { assert.isETHAddressHex('feeRecipientAddress', order.feeRecipientAddress); assert.isSenderAddressAsync('makerAddress', order.makerAddress, this._web3Wrapper); - const data = this._getAbiEncodedTransactionData('cancelOrder', order); + const data = this._exchangeInstance.cancelOrder(order).getABIEncodedTransactionData(); const transaction = await this._generateSignedZeroExTransactionAsync(data, order.makerAddress); const endpoint = await this._getServerEndpointOrThrowAsync(order.feeRecipientAddress); @@ -375,7 +353,7 @@ export class CoordinatorWrapper { assert.doesConformToSchema('orders', orders, schemas.ordersSchema); const makerAddress = getMakerAddressOrThrow(orders); assert.isSenderAddressAsync('makerAddress', makerAddress, this._web3Wrapper); - const data = this._getAbiEncodedTransactionData('batchCancelOrders', orders); + const data = this._exchangeInstance.batchCancelOrders(orders).getABIEncodedTransactionData(); const serverEndpointsToOrders = await this._mapServerEndpointsToOrdersAsync(orders); @@ -433,7 +411,7 @@ export class CoordinatorWrapper { assert.doesConformToSchema('orderTransactionOpts', orderTransactionOpts, orderTxOptsSchema, [txOptsSchema]); await assert.isSenderAddressAsync('makerAddress', order.makerAddress, this._web3Wrapper); - const data = this._getAbiEncodedTransactionData('cancelOrder', order); + const data = this._exchangeInstance.cancelOrder(order).getABIEncodedTransactionData(); const transaction = await this._generateSignedZeroExTransactionAsync(data, order.makerAddress); const approvalSignatures = new Array(); @@ -466,7 +444,7 @@ export class CoordinatorWrapper { assert.doesConformToSchema('orderTransactionOpts', orderTransactionOpts, orderTxOptsSchema, [txOptsSchema]); await assert.isSenderAddressAsync('makerAddress', makerAddress, this._web3Wrapper); - const data = this._getAbiEncodedTransactionData('batchCancelOrders', orders); + const data = this._exchangeInstance.batchCancelOrders(orders).getABIEncodedTransactionData(); const transaction = await this._generateSignedZeroExTransactionAsync(data, makerAddress); const approvalSignatures = new Array(); @@ -501,7 +479,7 @@ export class CoordinatorWrapper { assert.doesConformToSchema('orderTransactionOpts', orderTransactionOpts, orderTxOptsSchema, [txOptsSchema]); await assert.isSenderAddressAsync('senderAddress', senderAddress, this._web3Wrapper); - const data = this._getAbiEncodedTransactionData('cancelOrdersUpTo', targetOrderEpoch); + const data = this._exchangeInstance.cancelOrdersUpTo(targetOrderEpoch).getABIEncodedTransactionData(); const transaction = await this._generateSignedZeroExTransactionAsync(data, senderAddress); const approvalSignatures = new Array(); @@ -543,13 +521,15 @@ export class CoordinatorWrapper { assert.isHexString('approvalSignature', approvalSignature); } - await this._contractInstance.assertValidCoordinatorApprovals.callAsync( - transaction, - txOrigin, - transactionSignature, - approvalExpirationTimeSeconds, - approvalSignatures, - ); + await this._contractInstance + .assertValidCoordinatorApprovals( + transaction, + txOrigin, + transactionSignature, + approvalExpirationTimeSeconds, + approvalSignatures, + ) + .callAsync(); } /** @@ -561,14 +541,10 @@ export class CoordinatorWrapper { public async getSignerAddressAsync(hash: string, signature: string): Promise { assert.isHexString('hash', hash); assert.isHexString('signature', signature); - const signerAddress = await this._contractInstance.getSignerAddress.callAsync(hash, signature); + const signerAddress = await this._contractInstance.getSignerAddress(hash, signature).callAsync(); return signerAddress; } - private _getAbiEncodedTransactionData(methodName: K, ...args: any[]): string { - return getAbiEncodedTransactionData(this._exchangeInstance, methodName, ...args); - } - private async _handleFillsAsync( data: string, takerAddress: string, @@ -665,7 +641,7 @@ export class CoordinatorWrapper { feeRecipient: string, registryInstance: CoordinatorRegistryContract, ): Promise { - const coordinatorOperatorEndpoint = await registryInstance.getCoordinatorEndpoint.callAsync(feeRecipient); + const coordinatorOperatorEndpoint = await registryInstance.getCoordinatorEndpoint(feeRecipient).callAsync(); if (coordinatorOperatorEndpoint === '' || coordinatorOperatorEndpoint === undefined) { throw new Error( `No Coordinator server endpoint found in Coordinator Registry for feeRecipientAddress: ${feeRecipient}. Registry contract address: ${ @@ -744,33 +720,35 @@ export class CoordinatorWrapper { orderTransactionOpts: OrderTransactionOpts, ): Promise { if (orderTransactionOpts.shouldValidate) { - await this._contractInstance.executeTransaction.callAsync( - transaction, - txOrigin, - transactionSignature, - approvalExpirationTimeSeconds, - approvalSignatures, - { + await this._contractInstance + .executeTransaction( + transaction, + txOrigin, + transactionSignature, + approvalExpirationTimeSeconds, + approvalSignatures, + ) + .callAsync({ from: txOrigin, gas: orderTransactionOpts.gasLimit, gasPrice: orderTransactionOpts.gasPrice, nonce: orderTransactionOpts.nonce, - }, - ); + }); } - const txHash = await this._contractInstance.executeTransaction.sendTransactionAsync( - transaction, - txOrigin, - transactionSignature, - approvalExpirationTimeSeconds, - approvalSignatures, - { + const txHash = await this._contractInstance + .executeTransaction( + transaction, + txOrigin, + transactionSignature, + approvalExpirationTimeSeconds, + approvalSignatures, + ) + .sendTransactionAsync({ from: txOrigin, gas: orderTransactionOpts.gasLimit, gasPrice: orderTransactionOpts.gasPrice, nonce: orderTransactionOpts.nonce, - }, - ); + }); return txHash; } diff --git a/packages/contract-wrappers/src/index.ts b/packages/contract-wrappers/src/index.ts index e3576f9f49..743d3b46e2 100644 --- a/packages/contract-wrappers/src/index.ts +++ b/packages/contract-wrappers/src/index.ts @@ -154,8 +154,6 @@ export { SignedZeroExTransaction, SimpleEvmOutput, SimpleEvmBytecodeOutput, - AwaitTransactionSuccessOpts, - SendTransactionOpts, EIP712DomainWithDefaultSchema, EventCallback, DecodedLogEvent, @@ -163,3 +161,4 @@ export { } from '@0x/types'; export { AbiDecoder, DecodedCalldata } from '@0x/utils'; +export { AwaitTransactionSuccessOpts, SendTransactionOpts } from '@0x/base-contract'; diff --git a/packages/contract-wrappers/src/utils/getAbiEncodedTransactionData.ts b/packages/contract-wrappers/src/utils/getAbiEncodedTransactionData.ts deleted file mode 100644 index 79ebd8833b..0000000000 --- a/packages/contract-wrappers/src/utils/getAbiEncodedTransactionData.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { ExchangeContract } from '@0x/abi-gen-wrappers'; - -/** - * Returns the ABI encoded transaction hash for a given method and arguments - * @param methodName Must be a valid name of a function in the Solidity Exchange Contract - * @param params The appropriate arguments for the method given, in order - */ -export function getAbiEncodedTransactionData( - contractInstance: ExchangeContract, - methodName: K, - ...params: any[] // tslint:disable-line:trailing-comma -): string { - // HACK (xianny): we haven't formalised contract method functions into a type interface, and would have to - // differentiate contract method members from other class members to get this to work non-hackily - const method = (contractInstance[methodName] as any) as { - getABIEncodedTransactionData: (...args: any[]) => string; - }; - if (method.getABIEncodedTransactionData) { - const abiEncodedData = method.getABIEncodedTransactionData(...params); - return abiEncodedData; - } else { - return ''; - } -} diff --git a/packages/contract-wrappers/test/calldata_decoder_test.ts b/packages/contract-wrappers/test/calldata_decoder_test.ts index e205e63725..15f74a34e1 100644 --- a/packages/contract-wrappers/test/calldata_decoder_test.ts +++ b/packages/contract-wrappers/test/calldata_decoder_test.ts @@ -7,7 +7,6 @@ import * as _ from 'lodash'; import 'mocha'; import { ContractAddresses, ContractWrappers } from '../src'; -import { getAbiEncodedTransactionData } from '../src/utils/getAbiEncodedTransactionData'; import { chaiSetup } from './utils/chai_setup'; import { migrateOnceAsync } from './utils/migrate'; @@ -56,48 +55,48 @@ describe('ABI Decoding Calldata', () => { // Values are arbitrary, with the exception of maker addresses (generated above). orderLeft = { makerAddress: makerAddressLeft, - makerAssetData: await contractWrappers.devUtils.encodeERC20AssetData.callAsync( - defaultERC20MakerAssetAddress, - ), + makerAssetData: await contractWrappers.devUtils + .encodeERC20AssetData(defaultERC20MakerAssetAddress) + .callAsync(), makerAssetAmount: new BigNumber(10), takerAddress: '0x0000000000000000000000000000000000000000', - takerAssetData: await contractWrappers.devUtils.encodeERC20AssetData.callAsync( - defaultERC20MakerAssetAddress, - ), + takerAssetData: await contractWrappers.devUtils + .encodeERC20AssetData(defaultERC20MakerAssetAddress) + .callAsync(), takerAssetAmount: new BigNumber(1), feeRecipientAddress, makerFee: new BigNumber(0), takerFee: new BigNumber(0), - makerFeeAssetData: await contractWrappers.devUtils.encodeERC20AssetData.callAsync( - defaultERC20MakerAssetAddress, - ), - takerFeeAssetData: await contractWrappers.devUtils.encodeERC20AssetData.callAsync( - defaultERC20MakerAssetAddress, - ), + makerFeeAssetData: await contractWrappers.devUtils + .encodeERC20AssetData(defaultERC20MakerAssetAddress) + .callAsync(), + takerFeeAssetData: await contractWrappers.devUtils + .encodeERC20AssetData(defaultERC20MakerAssetAddress) + .callAsync(), senderAddress: '0x0000000000000000000000000000000000000000', expirationTimeSeconds: new BigNumber(1549498915), salt: new BigNumber(217), }; orderRight = { makerAddress: makerAddressRight, - makerAssetData: await contractWrappers.devUtils.encodeERC20AssetData.callAsync( - defaultERC20MakerAssetAddress, - ), + makerAssetData: await contractWrappers.devUtils + .encodeERC20AssetData(defaultERC20MakerAssetAddress) + .callAsync(), makerAssetAmount: new BigNumber(1), takerAddress: '0x0000000000000000000000000000000000000000', - takerAssetData: await contractWrappers.devUtils.encodeERC20AssetData.callAsync( - defaultERC20MakerAssetAddress, - ), + takerAssetData: await contractWrappers.devUtils + .encodeERC20AssetData(defaultERC20MakerAssetAddress) + .callAsync(), takerAssetAmount: new BigNumber(8), feeRecipientAddress, makerFee: new BigNumber(0), takerFee: new BigNumber(0), - makerFeeAssetData: await contractWrappers.devUtils.encodeERC20AssetData.callAsync( - defaultERC20MakerAssetAddress, - ), - takerFeeAssetData: await contractWrappers.devUtils.encodeERC20AssetData.callAsync( - defaultERC20MakerAssetAddress, - ), + makerFeeAssetData: await contractWrappers.devUtils + .encodeERC20AssetData(defaultERC20MakerAssetAddress) + .callAsync(), + takerFeeAssetData: await contractWrappers.devUtils + .encodeERC20AssetData(defaultERC20MakerAssetAddress) + .callAsync(), senderAddress: '0x0000000000000000000000000000000000000000', expirationTimeSeconds: new BigNumber(1549498915), salt: new BigNumber(50010), @@ -107,14 +106,9 @@ describe('ABI Decoding Calldata', () => { const orderFactoryRight = new OrderFactory(privateKeyRight, orderRight); signedOrderRight = await orderFactoryRight.newSignedOrderAsync(domainInfo); // Encode match orders transaction - matchOrdersTxData = getAbiEncodedTransactionData( - contractWrappers.exchange, - 'matchOrders', - signedOrderLeft, - signedOrderRight, - signedOrderLeft.signature, - signedOrderRight.signature, - ); + matchOrdersTxData = contractWrappers.exchange + .matchOrders(signedOrderLeft, signedOrderRight, signedOrderLeft.signature, signedOrderRight.signature) + .getABIEncodedTransactionData(); }); describe('decode', () => { diff --git a/packages/contract-wrappers/test/coordinator_wrapper_test.ts b/packages/contract-wrappers/test/coordinator_wrapper_test.ts index 6589f2ce3c..ff459a4b5a 100644 --- a/packages/contract-wrappers/test/coordinator_wrapper_test.ts +++ b/packages/contract-wrappers/test/coordinator_wrapper_test.ts @@ -85,9 +85,9 @@ describe.skip('CoordinatorWrapper', () => { [makerTokenAddress, takerTokenAddress] = tokenUtils.getDummyERC20TokenAddresses(); feeTokenAddress = contractAddresses.zrxToken; [makerAssetData, takerAssetData, feeAssetData] = [ - await contractWrappers.devUtils.encodeERC20AssetData.callAsync(makerTokenAddress), - await contractWrappers.devUtils.encodeERC20AssetData.callAsync(takerTokenAddress), - await contractWrappers.devUtils.encodeERC20AssetData.callAsync(feeTokenAddress), + await contractWrappers.devUtils.encodeERC20AssetData(makerTokenAddress).callAsync(), + await contractWrappers.devUtils.encodeERC20AssetData(takerTokenAddress).callAsync(), + await contractWrappers.devUtils.encodeERC20AssetData(feeTokenAddress).callAsync(), ]; // Configure order defaults @@ -190,32 +190,29 @@ describe.skip('CoordinatorWrapper', () => { // register coordinator server await web3Wrapper.awaitTransactionSuccessAsync( - await coordinatorRegistryInstance.setCoordinatorEndpoint.sendTransactionAsync( - `${coordinatorEndpoint}${coordinatorPort}`, - { + await coordinatorRegistryInstance + .setCoordinatorEndpoint(`${coordinatorEndpoint}${coordinatorPort}`) + .sendTransactionAsync({ from: feeRecipientAddressOne, - }, - ), + }), constants.AWAIT_TRANSACTION_MINED_MS, ); await web3Wrapper.awaitTransactionSuccessAsync( - await coordinatorRegistryInstance.setCoordinatorEndpoint.sendTransactionAsync( - `${coordinatorEndpoint}${coordinatorPort}`, - { + await coordinatorRegistryInstance + .setCoordinatorEndpoint(`${coordinatorEndpoint}${coordinatorPort}`) + .sendTransactionAsync({ from: feeRecipientAddressTwo, - }, - ), + }), constants.AWAIT_TRANSACTION_MINED_MS, ); // register another coordinator server await web3Wrapper.awaitTransactionSuccessAsync( - await coordinatorRegistryInstance.setCoordinatorEndpoint.sendTransactionAsync( - `${coordinatorEndpoint}${anotherCoordinatorPort}`, - { + await coordinatorRegistryInstance + .setCoordinatorEndpoint(`${coordinatorEndpoint}${anotherCoordinatorPort}`) + .sendTransactionAsync({ from: feeRecipientAddressThree, - }, - ), + }), constants.AWAIT_TRANSACTION_MINED_MS, ); }); @@ -238,12 +235,12 @@ describe.skip('CoordinatorWrapper', () => { }); describe('test setup', () => { it('should have coordinator registry which returns an endpoint', async () => { - const setCoordinatorEndpoint = await coordinatorRegistryInstance.getCoordinatorEndpoint.callAsync( - feeRecipientAddressOne, - ); - const anotherSetCoordinatorEndpoint = await coordinatorRegistryInstance.getCoordinatorEndpoint.callAsync( - feeRecipientAddressThree, - ); + const setCoordinatorEndpoint = await coordinatorRegistryInstance + .getCoordinatorEndpoint(feeRecipientAddressOne) + .callAsync(); + const anotherSetCoordinatorEndpoint = await coordinatorRegistryInstance + .getCoordinatorEndpoint(feeRecipientAddressThree) + .callAsync(); expect(setCoordinatorEndpoint).to.be.equal(`${coordinatorEndpoint}${coordinatorPort}`); expect(anotherSetCoordinatorEndpoint).to.be.equal(`${coordinatorEndpoint}${anotherCoordinatorPort}`); }); @@ -386,10 +383,9 @@ describe.skip('CoordinatorWrapper', () => { txHash = await contractWrappers.coordinator.hardCancelOrdersUpToAsync(targetOrderEpoch, makerAddress); await web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS); - const orderEpoch = await contractWrappers.exchange.orderEpoch.callAsync( - makerAddress, - contractWrappers.coordinator.address, - ); + const orderEpoch = await contractWrappers.exchange + .orderEpoch(makerAddress, contractWrappers.coordinator.address) + .callAsync(); expect(orderEpoch).to.be.bignumber.equal(targetOrderEpoch.plus(1)); }); }); @@ -406,7 +402,7 @@ describe.skip('CoordinatorWrapper', () => { }); it('should throw error when coordinator endpoint is malformed', async () => { await web3Wrapper.awaitTransactionSuccessAsync( - await coordinatorRegistryInstance.setCoordinatorEndpoint.sendTransactionAsync('localhost', { + await coordinatorRegistryInstance.setCoordinatorEndpoint('localhost').sendTransactionAsync({ from: feeRecipientAddressFour, }), constants.AWAIT_TRANSACTION_MINED_MS, diff --git a/packages/contract-wrappers/test/utils/token_utils.ts b/packages/contract-wrappers/test/utils/token_utils.ts index 903fa5b09d..cf98bddb6a 100644 --- a/packages/contract-wrappers/test/utils/token_utils.ts +++ b/packages/contract-wrappers/test/utils/token_utils.ts @@ -28,7 +28,7 @@ export const tokenUtils = { async mintDummyERC721Async(address: string, tokenOwner: string): Promise { const erc721 = new DummyERC721TokenContract(address, provider, txDefaults); const tokenId = generatePseudoRandomSalt(); - const txHash = await erc721.mint.sendTransactionAsync(tokenOwner, tokenId); + const txHash = await erc721.mint(tokenOwner, tokenId).sendTransactionAsync(); web3Wrapper.awaitTransactionSuccessAsync(txHash); return tokenId; }, diff --git a/packages/migrations/src/migration.ts b/packages/migrations/src/migration.ts index 87982e0086..7bd22f948f 100644 --- a/packages/migrations/src/migration.ts +++ b/packages/migrations/src/migration.ts @@ -143,26 +143,26 @@ export async function runMigrationsAsync( artifacts, ); - await erc20Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(exchange.address, txDefaults); - await erc721Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(exchange.address, txDefaults); - await erc1155Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(exchange.address, txDefaults); - await multiAssetProxy.addAuthorizedAddress.awaitTransactionSuccessAsync(exchange.address, txDefaults); + await erc20Proxy.addAuthorizedAddress(exchange.address).awaitTransactionSuccessAsync(txDefaults); + await erc721Proxy.addAuthorizedAddress(exchange.address).awaitTransactionSuccessAsync(txDefaults); + await erc1155Proxy.addAuthorizedAddress(exchange.address).awaitTransactionSuccessAsync(txDefaults); + await multiAssetProxy.addAuthorizedAddress(exchange.address).awaitTransactionSuccessAsync(txDefaults); // MultiAssetProxy - await erc20Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(multiAssetProxy.address, txDefaults); - await erc721Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(multiAssetProxy.address, txDefaults); - await erc1155Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(multiAssetProxy.address, txDefaults); - await multiAssetProxy.registerAssetProxy.awaitTransactionSuccessAsync(erc20Proxy.address, txDefaults); - await multiAssetProxy.registerAssetProxy.awaitTransactionSuccessAsync(erc721Proxy.address, txDefaults); - await multiAssetProxy.registerAssetProxy.awaitTransactionSuccessAsync(erc1155Proxy.address, txDefaults); - await multiAssetProxy.registerAssetProxy.awaitTransactionSuccessAsync(staticCallProxy.address, txDefaults); + await erc20Proxy.addAuthorizedAddress(multiAssetProxy.address).awaitTransactionSuccessAsync(txDefaults); + await erc721Proxy.addAuthorizedAddress(multiAssetProxy.address).awaitTransactionSuccessAsync(txDefaults); + await erc1155Proxy.addAuthorizedAddress(multiAssetProxy.address).awaitTransactionSuccessAsync(txDefaults); + await multiAssetProxy.registerAssetProxy(erc20Proxy.address).awaitTransactionSuccessAsync(txDefaults); + await multiAssetProxy.registerAssetProxy(erc721Proxy.address).awaitTransactionSuccessAsync(txDefaults); + await multiAssetProxy.registerAssetProxy(erc1155Proxy.address).awaitTransactionSuccessAsync(txDefaults); + await multiAssetProxy.registerAssetProxy(staticCallProxy.address).awaitTransactionSuccessAsync(txDefaults); // Register the Asset Proxies to the Exchange - await exchange.registerAssetProxy.awaitTransactionSuccessAsync(erc20Proxy.address, txDefaults); - await exchange.registerAssetProxy.awaitTransactionSuccessAsync(erc721Proxy.address, txDefaults); - await exchange.registerAssetProxy.awaitTransactionSuccessAsync(erc1155Proxy.address, txDefaults); - await exchange.registerAssetProxy.awaitTransactionSuccessAsync(multiAssetProxy.address, txDefaults); - await exchange.registerAssetProxy.awaitTransactionSuccessAsync(staticCallProxy.address, txDefaults); + await exchange.registerAssetProxy(erc20Proxy.address).awaitTransactionSuccessAsync(txDefaults); + await exchange.registerAssetProxy(erc721Proxy.address).awaitTransactionSuccessAsync(txDefaults); + await exchange.registerAssetProxy(erc1155Proxy.address).awaitTransactionSuccessAsync(txDefaults); + await exchange.registerAssetProxy(multiAssetProxy.address).awaitTransactionSuccessAsync(txDefaults); + await exchange.registerAssetProxy(staticCallProxy.address).awaitTransactionSuccessAsync(txDefaults); // Forwarder const forwarder = await wrappers.ForwarderContract.deployFrom0xArtifactAsync( @@ -217,16 +217,16 @@ export async function runMigrationsAsync( // // Transfer Ownership to the Asset Proxy Owner // await web3Wrapper.awaitTransactionSuccessAsync( - // await erc20Proxy.transferOwnership.sendTransactionAsync(assetProxyOwner.address, txDefaults), + // await erc20Proxy.transferOwnership(assetProxyOwner.address).sendTransactionAsync(txDefaults), // ); // await web3Wrapper.awaitTransactionSuccessAsync( - // await erc721Proxy.transferOwnership.sendTransactionAsync(assetProxyOwner.address, txDefaults), + // await erc721Proxy.transferOwnership(assetProxyOwner.address).sendTransactionAsync(txDefaults), // ); // await web3Wrapper.awaitTransactionSuccessAsync( - // await erc1155Proxy.transferOwnership.sendTransactionAsync(assetProxyOwner.address, txDefaults), + // await erc1155Proxy.transferOwnership(assetProxyOwner.address).sendTransactionAsync(txDefaults), // ); // await web3Wrapper.awaitTransactionSuccessAsync( - // await multiAssetProxy.transferOwnership.sendTransactionAsync(assetProxyOwner.address, txDefaults), + // await multiAssetProxy.transferOwnership(assetProxyOwner.address).sendTransactionAsync(txDefaults), // ); // Fake the above transactions so our nonce increases and we result with the same addresses @@ -237,9 +237,9 @@ export async function runMigrationsAsync( } // Fund the Forwarder with ZRX - const zrxDecimals = await zrxToken.decimals.callAsync(); + const zrxDecimals = await zrxToken.decimals().callAsync(); const zrxForwarderAmount = Web3Wrapper.toBaseUnitAmount(new BigNumber(5000), zrxDecimals); - await zrxToken.transfer.awaitTransactionSuccessAsync(forwarder.address, zrxForwarderAmount, txDefaults); + await zrxToken.transfer(forwarder.address, zrxForwarderAmount).awaitTransactionSuccessAsync(txDefaults); // CoordinatorRegistry const coordinatorRegistry = await wrappers.CoordinatorRegistryContract.deployFrom0xArtifactAsync( diff --git a/packages/migrations/src/test_contract_configs.ts b/packages/migrations/src/test_contract_configs.ts index 9c56e584b7..fcaa16e6c6 100644 --- a/packages/migrations/src/test_contract_configs.ts +++ b/packages/migrations/src/test_contract_configs.ts @@ -45,30 +45,30 @@ async function testContractConfigsAsync(provider: SupportedProvider): Promise { - const exchangeOwner = await exchangeV2.owner.callAsync(); + const exchangeOwner = await exchangeV2.owner().callAsync(); warnIfMismatch(exchangeOwner, governor.address, 'Unexpected ExchangeV2 owner'); - const registeredERC20Proxy = await exchangeV2.getAssetProxy.callAsync(AssetProxyId.ERC20); + const registeredERC20Proxy = await exchangeV2.getAssetProxy(AssetProxyId.ERC20).callAsync(); warnIfMismatch(registeredERC20Proxy, erc20Proxy.address, 'Unexpected ERC20Proxy registered in ExchangeV2'); - const registeredERC721Proxy = await exchangeV2.getAssetProxy.callAsync(AssetProxyId.ERC721); + const registeredERC721Proxy = await exchangeV2.getAssetProxy(AssetProxyId.ERC721).callAsync(); warnIfMismatch(registeredERC721Proxy, erc721Proxy.address, 'Unexpected ERC721Proxy registered in ExchangeV2'); - const registeredERC1155Proxy = await exchangeV2.getAssetProxy.callAsync(AssetProxyId.ERC1155); + const registeredERC1155Proxy = await exchangeV2.getAssetProxy(AssetProxyId.ERC1155).callAsync(); warnIfMismatch( registeredERC1155Proxy, erc1155Proxy.address, 'Unexpected ERC1155Proxy registered in ExchangeV2', ); - const registeredMultiAssetProxy = await exchangeV2.getAssetProxy.callAsync(AssetProxyId.MultiAsset); + const registeredMultiAssetProxy = await exchangeV2.getAssetProxy(AssetProxyId.MultiAsset).callAsync(); warnIfMismatch( registeredMultiAssetProxy, multiAssetProxy.address, 'Unexpected MultiAssetProxy registered in ExchangeV2', ); - const registeredStaticCallProxy = await exchangeV2.getAssetProxy.callAsync(AssetProxyId.StaticCall); + const registeredStaticCallProxy = await exchangeV2.getAssetProxy(AssetProxyId.StaticCall).callAsync(); warnIfMismatch( registeredStaticCallProxy, addresses.staticCallProxy, @@ -77,158 +77,164 @@ async function testContractConfigsAsync(provider: SupportedProvider): Promise { - const exchangeOwner = await exchange.owner.callAsync(); + const exchangeOwner = await exchange.owner().callAsync(); warnIfMismatch(exchangeOwner, governor.address, 'Unexpected Exchange owner'); - const registeredERC20Proxy = await exchange.getAssetProxy.callAsync(AssetProxyId.ERC20); + const registeredERC20Proxy = await exchange.getAssetProxy(AssetProxyId.ERC20).callAsync(); warnIfMismatch(registeredERC20Proxy, erc20Proxy.address, 'Unexpected ERC20Proxy registered in Exchange'); - const registeredERC721Proxy = await exchange.getAssetProxy.callAsync(AssetProxyId.ERC721); + const registeredERC721Proxy = await exchange.getAssetProxy(AssetProxyId.ERC721).callAsync(); warnIfMismatch(registeredERC721Proxy, erc721Proxy.address, 'Unexpected ERC721Proxy registered in Exchange'); - const registeredERC1155Proxy = await exchange.getAssetProxy.callAsync(AssetProxyId.ERC1155); + const registeredERC1155Proxy = await exchange.getAssetProxy(AssetProxyId.ERC1155).callAsync(); warnIfMismatch(registeredERC1155Proxy, erc1155Proxy.address, 'Unexpected ERC1155Proxy registered in Exchange'); - const registeredMultiAssetProxy = await exchange.getAssetProxy.callAsync(AssetProxyId.MultiAsset); + const registeredMultiAssetProxy = await exchange.getAssetProxy(AssetProxyId.MultiAsset).callAsync(); warnIfMismatch( registeredMultiAssetProxy, multiAssetProxy.address, 'Unexpected MultiAssetProxy registered in Exchange', ); - const registeredStaticCallProxy = await exchange.getAssetProxy.callAsync(AssetProxyId.StaticCall); + const registeredStaticCallProxy = await exchange.getAssetProxy(AssetProxyId.StaticCall).callAsync(); warnIfMismatch( registeredStaticCallProxy, addresses.staticCallProxy, 'Unexpected StaticCallProxy registered in Exchange', ); - const protocolFeeCollector = await exchange.protocolFeeCollector.callAsync(); + const protocolFeeCollector = await exchange.protocolFeeCollector().callAsync(); warnIfMismatch(protocolFeeCollector, addresses.stakingProxy, 'Unexpected StakingProxy attached to Exchange'); - const protocolFeeMultiplier = await exchange.protocolFeeMultiplier.callAsync(); + const protocolFeeMultiplier = await exchange.protocolFeeMultiplier().callAsync(); warnIfMismatch(protocolFeeMultiplier.toString(), '150000', 'Unexpected protocolFeeMultiplier in Exchange'); } async function verifyAssetProxyConfigsAsync(): Promise { // Verify ERC20Proxy configs - const erc20ProxyOwner = await erc20Proxy.owner.callAsync(); + const erc20ProxyOwner = await erc20Proxy.owner().callAsync(); warnIfMismatch(erc20ProxyOwner, governor.address, 'Unexpected ERC20Proxy owner'); - const erc20AuthorizedAddresses = await erc20Proxy.getAuthorizedAddresses.callAsync(); + const erc20AuthorizedAddresses = await erc20Proxy.getAuthorizedAddresses().callAsync(); warnIfMismatch(erc20AuthorizedAddresses.length, 4, 'Unexpected number of authorized addresses in ERC20Proxy'); - const isExchangeV2AuthorizedInERC20Proxy = await erc20Proxy.authorized.callAsync(exchangeV2.address); + const isExchangeV2AuthorizedInERC20Proxy = await erc20Proxy.authorized(exchangeV2.address).callAsync(); warnIfMismatch(isExchangeV2AuthorizedInERC20Proxy, true, 'ExchangeV2 not authorized in ERC20Proxy'); - const isExchangeAuthorizedInERC20Proxy = await erc20Proxy.authorized.callAsync(exchange.address); + const isExchangeAuthorizedInERC20Proxy = await erc20Proxy.authorized(exchange.address).callAsync(); warnIfMismatch(isExchangeAuthorizedInERC20Proxy, true, 'Exchange not authorized in ERC20Proxy'); - const isMAPAuthorizedInER20Proxy = await erc20Proxy.authorized.callAsync(multiAssetProxy.address); + const isMAPAuthorizedInER20Proxy = await erc20Proxy.authorized(multiAssetProxy.address).callAsync(); warnIfMismatch(isMAPAuthorizedInER20Proxy, true, 'MultiAssetProxy not authorized in ERC20Proxy'); - const isZrxVaultAuthorizedInER20Proxy = await erc20Proxy.authorized.callAsync(zrxVault.address); + const isZrxVaultAuthorizedInER20Proxy = await erc20Proxy.authorized(zrxVault.address).callAsync(); warnIfMismatch(isZrxVaultAuthorizedInER20Proxy, true, 'ZrxVault not authorized in ERC20Proxy'); // Verify ERC721Proxy configs - const erc721ProxyOwner = await erc721Proxy.owner.callAsync(); + const erc721ProxyOwner = await erc721Proxy.owner().callAsync(); warnIfMismatch(erc721ProxyOwner, governor.address, 'Unexpected ERC721Proxy owner'); - const erc721AuthorizedAddresses = await erc721Proxy.getAuthorizedAddresses.callAsync(); + const erc721AuthorizedAddresses = await erc721Proxy.getAuthorizedAddresses().callAsync(); warnIfMismatch(erc721AuthorizedAddresses.length, 3, 'Unexpected number of authorized addresses in ERC721Proxy'); - const isExchangeV2AuthorizedInERC721Proxy = await erc721Proxy.authorized.callAsync(exchangeV2.address); + const isExchangeV2AuthorizedInERC721Proxy = await erc721Proxy.authorized(exchangeV2.address).callAsync(); warnIfMismatch(isExchangeV2AuthorizedInERC721Proxy, true, 'ExchangeV2 not authorized in ERC721Proxy'); - const isExchangeAuthorizedInERC721Proxy = await erc721Proxy.authorized.callAsync(exchange.address); + const isExchangeAuthorizedInERC721Proxy = await erc721Proxy.authorized(exchange.address).callAsync(); warnIfMismatch(isExchangeAuthorizedInERC721Proxy, true, 'Exchange not authorized in ERC721Proxy'); - const isMAPAuthorizedInER721Proxy = await erc721Proxy.authorized.callAsync(multiAssetProxy.address); + const isMAPAuthorizedInER721Proxy = await erc721Proxy.authorized(multiAssetProxy.address).callAsync(); warnIfMismatch(isMAPAuthorizedInER721Proxy, true, 'MultiAssetProxy not authorized in ERC721Proxy'); // Verify ERC1155Proxy configs - const erc1155ProxyOwner = await erc1155Proxy.owner.callAsync(); + const erc1155ProxyOwner = await erc1155Proxy.owner().callAsync(); warnIfMismatch(erc1155ProxyOwner, governor.address, 'Unexpected ERC1155Proxy owner'); - const erc1155AuthorizedAddresses = await erc1155Proxy.getAuthorizedAddresses.callAsync(); + const erc1155AuthorizedAddresses = await erc1155Proxy.getAuthorizedAddresses().callAsync(); warnIfMismatch( erc1155AuthorizedAddresses.length, 3, 'Unexpected number of authorized addresses in ERC1155Proxy', ); - const isExchangeV2AuthorizedInERC1155Proxy = await erc1155Proxy.authorized.callAsync(exchangeV2.address); + const isExchangeV2AuthorizedInERC1155Proxy = await erc1155Proxy.authorized(exchangeV2.address).callAsync(); warnIfMismatch(isExchangeV2AuthorizedInERC1155Proxy, true, 'ExchangeV2 not authorized in ERC1155Proxy'); - const isExchangeAuthorizedInERC1155Proxy = await erc1155Proxy.authorized.callAsync(exchange.address); + const isExchangeAuthorizedInERC1155Proxy = await erc1155Proxy.authorized(exchange.address).callAsync(); warnIfMismatch(isExchangeAuthorizedInERC1155Proxy, true, 'Exchange not authorized in ERC1155Proxy'); - const isMAPAuthorizedInERC1155Proxy = await erc1155Proxy.authorized.callAsync(multiAssetProxy.address); + const isMAPAuthorizedInERC1155Proxy = await erc1155Proxy.authorized(multiAssetProxy.address).callAsync(); warnIfMismatch(isMAPAuthorizedInERC1155Proxy, true, 'MultiAssetProxy not authorized in ERC1155Proxy'); // Verify ERC20BridgeProxy configs - const erc20BridgeProxyOwner = await erc20BridgeProxy.owner.callAsync(); + const erc20BridgeProxyOwner = await erc20BridgeProxy.owner().callAsync(); warnIfMismatch(erc20BridgeProxyOwner, governor.address, 'Unexpected ERC20BridgeProxy owner'); - const erc20BridgeAuthorizedAddresses = await erc20BridgeProxy.getAuthorizedAddresses.callAsync(); + const erc20BridgeAuthorizedAddresses = await erc20BridgeProxy.getAuthorizedAddresses().callAsync(); warnIfMismatch( erc20BridgeAuthorizedAddresses.length, 2, 'Unexpected number of authorized addresses in ERC20BridgeProxy', ); - const isExchangeAuthorizedInERC20BridgeProxy = await erc20BridgeProxy.authorized.callAsync(exchange.address); + const isExchangeAuthorizedInERC20BridgeProxy = await erc20BridgeProxy.authorized(exchange.address).callAsync(); warnIfMismatch(isExchangeAuthorizedInERC20BridgeProxy, true, 'Exchange not authorized in ERC20BridgeProxy'); - const isMAPAuthorizedInERC20BridgeProxy = await erc20BridgeProxy.authorized.callAsync(multiAssetProxy.address); + const isMAPAuthorizedInERC20BridgeProxy = await erc20BridgeProxy + .authorized(multiAssetProxy.address) + .callAsync(); warnIfMismatch(isMAPAuthorizedInERC20BridgeProxy, true, 'MultiAssetProxy not authorized in ERC20BridgeProxy'); // Verify MultiAssetProxy configs - const multiAssetProxyOwner = await multiAssetProxy.owner.callAsync(); + const multiAssetProxyOwner = await multiAssetProxy.owner().callAsync(); warnIfMismatch(multiAssetProxyOwner, governor.address, 'Unexpected MultiAssetProxy owner'); - const multiAssetProxyAuthorizedAddresses = await multiAssetProxy.getAuthorizedAddresses.callAsync(); + const multiAssetProxyAuthorizedAddresses = await multiAssetProxy.getAuthorizedAddresses().callAsync(); warnIfMismatch( multiAssetProxyAuthorizedAddresses.length, 2, 'Unexpected number of authorized addresses in MultiAssetProxy', ); - const isExchangeV2AuthorizedInMultiAssetProxy = await multiAssetProxy.authorized.callAsync(exchangeV2.address); + const isExchangeV2AuthorizedInMultiAssetProxy = await multiAssetProxy + .authorized(exchangeV2.address) + .callAsync(); warnIfMismatch(isExchangeV2AuthorizedInMultiAssetProxy, true, 'ExchangeV2 not authorized in MultiAssetProxy'); - const isExchangeAuthorizedInMultiAssetProxy = await multiAssetProxy.authorized.callAsync(exchange.address); + const isExchangeAuthorizedInMultiAssetProxy = await multiAssetProxy.authorized(exchange.address).callAsync(); warnIfMismatch(isExchangeAuthorizedInMultiAssetProxy, true, 'Exchange not authorized in MultiAssetProxy'); - const registeredERC20ProxyInMAP = await multiAssetProxy.getAssetProxy.callAsync(AssetProxyId.ERC20); + const registeredERC20ProxyInMAP = await multiAssetProxy.getAssetProxy(AssetProxyId.ERC20).callAsync(); warnIfMismatch( registeredERC20ProxyInMAP, erc20Proxy.address, 'Unexpected ERC20Proxy registered in MultiAssetProxy', ); - const registeredERC721ProxyInMAP = await multiAssetProxy.getAssetProxy.callAsync(AssetProxyId.ERC721); + const registeredERC721ProxyInMAP = await multiAssetProxy.getAssetProxy(AssetProxyId.ERC721).callAsync(); warnIfMismatch( registeredERC721ProxyInMAP, erc721Proxy.address, 'Unexpected ERC721Proxy registered in MultiAssetProxy', ); - const registeredERC1155ProxyInMAP = await multiAssetProxy.getAssetProxy.callAsync(AssetProxyId.ERC1155); + const registeredERC1155ProxyInMAP = await multiAssetProxy.getAssetProxy(AssetProxyId.ERC1155).callAsync(); warnIfMismatch( registeredERC1155ProxyInMAP, erc1155Proxy.address, 'Unexpected ERC1155Proxy registered in MultiAssetProxy', ); - const registeredStaticCallProxyInMAP = await multiAssetProxy.getAssetProxy.callAsync(AssetProxyId.StaticCall); + const registeredStaticCallProxyInMAP = await multiAssetProxy.getAssetProxy(AssetProxyId.StaticCall).callAsync(); warnIfMismatch( registeredStaticCallProxyInMAP, addresses.staticCallProxy, 'Unexpected StaticCallProxy registered in MultiAssetProxy', ); - const registeredERC20BridgeProxyInMAP = await multiAssetProxy.getAssetProxy.callAsync(AssetProxyId.ERC20Bridge); + const registeredERC20BridgeProxyInMAP = await multiAssetProxy + .getAssetProxy(AssetProxyId.ERC20Bridge) + .callAsync(); warnIfMismatch( registeredERC20BridgeProxyInMAP, addresses.erc20BridgeProxy, @@ -237,33 +243,33 @@ async function testContractConfigsAsync(provider: SupportedProvider): Promise { - const stakingLogicAddress = await stakingProxy.stakingContract.callAsync(); + const stakingLogicAddress = await stakingProxy.stakingContract().callAsync(); warnIfMismatch(stakingLogicAddress, addresses.staking, 'Unexpected Staking contract attached to StakingProxy'); - const zrxVaultAddress = await stakingContract.getZrxVault.callAsync(); + const zrxVaultAddress = await stakingContract.getZrxVault().callAsync(); warnIfMismatch(zrxVaultAddress, addresses.zrxVault, 'Unexpected ZrxVault set in Staking contract'); - const wethAddress = await stakingContract.getWethContract.callAsync(); + const wethAddress = await stakingContract.getWethContract().callAsync(); warnIfMismatch(wethAddress, addresses.etherToken, 'Unexpected WETH contract set in Staking contract'); - const stakingProxyOwner = await stakingProxy.owner.callAsync(); + const stakingProxyOwner = await stakingProxy.owner().callAsync(); warnIfMismatch(stakingProxyOwner, addresses.zeroExGovernor, 'Unexpected StakingProxy owner'); - const zrxVaultOwner = await zrxVault.owner.callAsync(); + const zrxVaultOwner = await zrxVault.owner().callAsync(); warnIfMismatch(zrxVaultOwner, addresses.zeroExGovernor, 'Unexpected ZrxVault owner'); - const stakingProxyAuthorizedAddresses = await stakingProxy.getAuthorizedAddresses.callAsync(); + const stakingProxyAuthorizedAddresses = await stakingProxy.getAuthorizedAddresses().callAsync(); warnIfMismatch( stakingProxyAuthorizedAddresses.length, 1, 'Unexpected number of authorized addresses in StakingProxy', ); - const isGovernorAuthorizedInStakingProxy = await stakingProxy.authorized.callAsync(addresses.zeroExGovernor); + const isGovernorAuthorizedInStakingProxy = await stakingProxy.authorized(addresses.zeroExGovernor).callAsync(); warnIfMismatch(isGovernorAuthorizedInStakingProxy, true, 'ZeroExGovernor not authorized in StakingProxy'); - const zrxVaultAuthorizedAddresses = await zrxVault.getAuthorizedAddresses.callAsync(); + const zrxVaultAuthorizedAddresses = await zrxVault.getAuthorizedAddresses().callAsync(); warnIfMismatch(zrxVaultAuthorizedAddresses.length, 1, 'Unexpected number of authorized addresses in ZrxVault'); - const isGovernorAuthorizedInZrxVault = await zrxVault.authorized.callAsync(addresses.zeroExGovernor); + const isGovernorAuthorizedInZrxVault = await zrxVault.authorized(addresses.zeroExGovernor).callAsync(); warnIfMismatch(isGovernorAuthorizedInZrxVault, true, 'ZeroExGovernor not authorized in ZrxVault'); } diff --git a/packages/migrations/src/testnet_migrations.ts b/packages/migrations/src/testnet_migrations.ts index e5bf90c959..341fe02e35 100644 --- a/packages/migrations/src/testnet_migrations.ts +++ b/packages/migrations/src/testnet_migrations.ts @@ -27,15 +27,13 @@ async function submitAndExecuteTransactionAsync( destination: string, data: string, ): Promise { - const txReceipt = await governor.submitTransaction.awaitTransactionSuccessAsync( - destination, - constants.ZERO_AMOUNT, - data, - ); + const txReceipt = await governor + .submitTransaction(destination, constants.ZERO_AMOUNT, data) + .awaitTransactionSuccessAsync(); // tslint:disable-next-line:no-unnecessary-type-assertion const txId = (txReceipt.logs[0] as LogWithDecodedArgs).args.transactionId; logUtils.log(`${txId} submitted`); - await governor.executeTransaction.awaitTransactionSuccessAsync(txId); + await governor.executeTransaction(txId).awaitTransactionSuccessAsync(); logUtils.log(`${txId} executed`); } @@ -100,7 +98,7 @@ export async function runMigrationsAsync(supportedProvider: SupportedProvider, t chainId, ); - const wethAssetData = await devUtils.encodeERC20AssetData.callAsync(deployedAddresses.etherToken); + const wethAssetData = await devUtils.encodeERC20AssetData(deployedAddresses.etherToken).callAsync(); await ForwarderContract.deployFrom0xArtifactAsync( forwarderArtifacts.Forwarder, provider, @@ -117,150 +115,150 @@ export async function runMigrationsAsync(supportedProvider: SupportedProvider, t // AssetProxy timelocks { destination: deployedAddresses.erc20Proxy, - functionSelector: authorizableInterface.removeAuthorizedAddress.getSelector(), + functionSelector: authorizableInterface.getSelector('removeAuthorizedAddress'), secondsTimeLocked: constants.ZERO_AMOUNT, }, { destination: deployedAddresses.erc20Proxy, - functionSelector: authorizableInterface.removeAuthorizedAddressAtIndex.getSelector(), + functionSelector: authorizableInterface.getSelector('removeAuthorizedAddressAtIndex'), secondsTimeLocked: constants.ZERO_AMOUNT, }, { destination: deployedAddresses.erc721Proxy, - functionSelector: authorizableInterface.removeAuthorizedAddress.getSelector(), + functionSelector: authorizableInterface.getSelector('removeAuthorizedAddress'), secondsTimeLocked: constants.ZERO_AMOUNT, }, { destination: deployedAddresses.erc721Proxy, - functionSelector: authorizableInterface.removeAuthorizedAddressAtIndex.getSelector(), + functionSelector: authorizableInterface.getSelector('removeAuthorizedAddressAtIndex'), secondsTimeLocked: constants.ZERO_AMOUNT, }, { destination: deployedAddresses.erc1155Proxy, - functionSelector: authorizableInterface.removeAuthorizedAddress.getSelector(), + functionSelector: authorizableInterface.getSelector('removeAuthorizedAddress'), secondsTimeLocked: constants.ZERO_AMOUNT, }, { destination: deployedAddresses.erc1155Proxy, - functionSelector: authorizableInterface.removeAuthorizedAddressAtIndex.getSelector(), + functionSelector: authorizableInterface.getSelector('removeAuthorizedAddressAtIndex'), secondsTimeLocked: constants.ZERO_AMOUNT, }, { destination: deployedAddresses.multiAssetProxy, - functionSelector: authorizableInterface.removeAuthorizedAddress.getSelector(), + functionSelector: authorizableInterface.getSelector('removeAuthorizedAddress'), secondsTimeLocked: constants.ZERO_AMOUNT, }, { destination: deployedAddresses.multiAssetProxy, - functionSelector: authorizableInterface.removeAuthorizedAddressAtIndex.getSelector(), + functionSelector: authorizableInterface.getSelector('removeAuthorizedAddressAtIndex'), secondsTimeLocked: constants.ZERO_AMOUNT, }, { destination: erc20BridgeProxy.address, - functionSelector: authorizableInterface.removeAuthorizedAddress.getSelector(), + functionSelector: authorizableInterface.getSelector('removeAuthorizedAddress'), secondsTimeLocked: constants.ZERO_AMOUNT, }, { destination: erc20BridgeProxy.address, - functionSelector: authorizableInterface.removeAuthorizedAddressAtIndex.getSelector(), + functionSelector: authorizableInterface.getSelector('removeAuthorizedAddressAtIndex'), secondsTimeLocked: constants.ZERO_AMOUNT, }, // ZrxVault timelocks { destination: deployedAddresses.zrxVault, - functionSelector: zrxVault.enterCatastrophicFailure.getSelector(), + functionSelector: zrxVault.getSelector('enterCatastrophicFailure'), secondsTimeLocked: constants.ZERO_AMOUNT, }, { destination: deployedAddresses.zrxVault, - functionSelector: zrxVault.setStakingProxy.getSelector(), + functionSelector: zrxVault.getSelector('setStakingProxy'), secondsTimeLocked: constants.ZERO_AMOUNT, // 20 days on mainnet }, { destination: deployedAddresses.zrxVault, - functionSelector: zrxVault.setZrxProxy.getSelector(), + functionSelector: zrxVault.getSelector('setZrxProxy'), secondsTimeLocked: constants.ZERO_AMOUNT, // 20 days on mainnet }, { destination: deployedAddresses.zrxVault, - functionSelector: ownableInterface.transferOwnership.getSelector(), + functionSelector: ownableInterface.getSelector('transferOwnership'), secondsTimeLocked: constants.ZERO_AMOUNT, // 20 days on mainnet }, { destination: deployedAddresses.zrxVault, - functionSelector: authorizableInterface.addAuthorizedAddress.getSelector(), + functionSelector: authorizableInterface.getSelector('addAuthorizedAddress'), secondsTimeLocked: constants.ZERO_AMOUNT, // 20 days on mainnet }, { destination: deployedAddresses.zrxVault, - functionSelector: authorizableInterface.removeAuthorizedAddress.getSelector(), + functionSelector: authorizableInterface.getSelector('removeAuthorizedAddress'), secondsTimeLocked: constants.ZERO_AMOUNT, // 20 days on mainnet }, { destination: deployedAddresses.zrxVault, - functionSelector: authorizableInterface.removeAuthorizedAddressAtIndex.getSelector(), + functionSelector: authorizableInterface.getSelector('removeAuthorizedAddressAtIndex'), secondsTimeLocked: constants.ZERO_AMOUNT, // 20 days on mainnet }, // StakingProxy timelocks { destination: deployedAddresses.stakingProxy, - functionSelector: stakingProxy.attachStakingContract.getSelector(), + functionSelector: stakingProxy.getSelector('attachStakingContract'), secondsTimeLocked: constants.ZERO_AMOUNT, // 20 days on mainnet }, { destination: deployedAddresses.stakingProxy, - functionSelector: stakingProxy.detachStakingContract.getSelector(), + functionSelector: stakingProxy.getSelector('detachStakingContract'), secondsTimeLocked: constants.ZERO_AMOUNT, // 20 days on mainnet }, { destination: deployedAddresses.stakingProxy, - functionSelector: stakingLogic.setParams.getSelector(), + functionSelector: stakingLogic.getSelector('setParams'), secondsTimeLocked: constants.ZERO_AMOUNT, // 10 days on mainnet }, { destination: deployedAddresses.stakingProxy, - functionSelector: stakingLogic.addExchangeAddress.getSelector(), + functionSelector: stakingLogic.getSelector('addExchangeAddress'), secondsTimeLocked: constants.ZERO_AMOUNT, // 20 days on mainnet }, { destination: deployedAddresses.stakingProxy, - functionSelector: stakingLogic.removeExchangeAddress.getSelector(), + functionSelector: stakingLogic.getSelector('removeExchangeAddress'), secondsTimeLocked: constants.ZERO_AMOUNT, // 20 days on mainnet }, { destination: deployedAddresses.stakingProxy, - functionSelector: ownableInterface.transferOwnership.getSelector(), + functionSelector: ownableInterface.getSelector('transferOwnership'), secondsTimeLocked: constants.ZERO_AMOUNT, // 20 days on mainnet }, { destination: deployedAddresses.stakingProxy, - functionSelector: authorizableInterface.addAuthorizedAddress.getSelector(), + functionSelector: authorizableInterface.getSelector('addAuthorizedAddress'), secondsTimeLocked: constants.ZERO_AMOUNT, // 20 days on mainnet }, { destination: deployedAddresses.stakingProxy, - functionSelector: authorizableInterface.removeAuthorizedAddress.getSelector(), + functionSelector: authorizableInterface.getSelector('removeAuthorizedAddress'), secondsTimeLocked: constants.ZERO_AMOUNT, // 20 days on mainnet }, { destination: deployedAddresses.stakingProxy, - functionSelector: authorizableInterface.removeAuthorizedAddressAtIndex.getSelector(), + functionSelector: authorizableInterface.getSelector('removeAuthorizedAddressAtIndex'), secondsTimeLocked: constants.ZERO_AMOUNT, // 20 days on mainnet }, // Exchange timelocks { destination: exchange.address, - functionSelector: exchange.setProtocolFeeMultiplier.getSelector(), + functionSelector: exchange.getSelector('setProtocolFeeMultiplier'), secondsTimeLocked: constants.ZERO_AMOUNT, // 10 days on mainnet }, { destination: exchange.address, - functionSelector: exchange.setProtocolFeeCollectorAddress.getSelector(), + functionSelector: exchange.getSelector('setProtocolFeeCollectorAddress'), secondsTimeLocked: constants.ZERO_AMOUNT, // 20 days on mainnet }, { destination: exchange.address, - functionSelector: exchange.detachProtocolFeeCollector.getSelector(), + functionSelector: exchange.getSelector('detachProtocolFeeCollector'), secondsTimeLocked: constants.ZERO_AMOUNT, }, ]; @@ -279,19 +277,19 @@ export async function runMigrationsAsync(supportedProvider: SupportedProvider, t ); logUtils.log('Configuring Exchange...'); - await exchange.transferOwnership.awaitTransactionSuccessAsync(governor.address); + await exchange.transferOwnership(governor.address).awaitTransactionSuccessAsync(); logUtils.log('Exchange configured!'); logUtils.log('Configuring ERC20BridgeProxy...'); - await erc20BridgeProxy.transferOwnership.awaitTransactionSuccessAsync(governor.address); + await erc20BridgeProxy.transferOwnership(governor.address).awaitTransactionSuccessAsync(); logUtils.log('ERC20BridgeProxy configured!'); logUtils.log('Configuring ZrxVault...'); - await zrxVault.transferOwnership.awaitTransactionSuccessAsync(governor.address); + await zrxVault.transferOwnership(governor.address).awaitTransactionSuccessAsync(); logUtils.log('ZrxVault configured!'); logUtils.log('Configuring StakingProxy...'); - await stakingProxy.transferOwnership.awaitTransactionSuccessAsync(governor.address); + await stakingProxy.transferOwnership(governor.address).awaitTransactionSuccessAsync(); logUtils.log('StakingProxy configured!'); logUtils.log('Transfering ownership of 2.0 contracts...'); @@ -299,27 +297,27 @@ export async function runMigrationsAsync(supportedProvider: SupportedProvider, t await submitAndExecuteTransactionAsync( oldAssetProxyOwner, deployedAddresses.exchangeV2, // Exchange 2.1 address - ownableInterface.transferOwnership.getABIEncodedTransactionData(governor.address), + ownableInterface.transferOwnership(governor.address).getABIEncodedTransactionData(), ); await submitAndExecuteTransactionAsync( oldAssetProxyOwner, deployedAddresses.erc20Proxy, - ownableInterface.transferOwnership.getABIEncodedTransactionData(governor.address), + ownableInterface.transferOwnership(governor.address).getABIEncodedTransactionData(), ); await submitAndExecuteTransactionAsync( oldAssetProxyOwner, deployedAddresses.erc721Proxy, - ownableInterface.transferOwnership.getABIEncodedTransactionData(governor.address), + ownableInterface.transferOwnership(governor.address).getABIEncodedTransactionData(), ); await submitAndExecuteTransactionAsync( oldAssetProxyOwner, deployedAddresses.erc1155Proxy, - ownableInterface.transferOwnership.getABIEncodedTransactionData(governor.address), + ownableInterface.transferOwnership(governor.address).getABIEncodedTransactionData(), ); await submitAndExecuteTransactionAsync( oldAssetProxyOwner, deployedAddresses.multiAssetProxy, - ownableInterface.transferOwnership.getABIEncodedTransactionData(governor.address), + ownableInterface.transferOwnership(governor.address).getABIEncodedTransactionData(), ); logUtils.log('Ownership transferred!'); @@ -327,89 +325,89 @@ export async function runMigrationsAsync(supportedProvider: SupportedProvider, t // Exchange staking configs { destination: exchange.address, - data: exchange.setProtocolFeeCollectorAddress.getABIEncodedTransactionData(stakingProxy.address), + data: exchange.setProtocolFeeCollectorAddress(stakingProxy.address).getABIEncodedTransactionData(), }, { destination: exchange.address, - data: exchange.setProtocolFeeMultiplier.getABIEncodedTransactionData(new BigNumber(150000)), + data: exchange.setProtocolFeeMultiplier(new BigNumber(150000)).getABIEncodedTransactionData(), }, // Exchange AssetProxy registrations { destination: exchange.address, - data: exchange.registerAssetProxy.getABIEncodedTransactionData(deployedAddresses.erc20Proxy), + data: exchange.registerAssetProxy(deployedAddresses.erc20Proxy).getABIEncodedTransactionData(), }, { destination: exchange.address, - data: exchange.registerAssetProxy.getABIEncodedTransactionData(deployedAddresses.erc721Proxy), + data: exchange.registerAssetProxy(deployedAddresses.erc721Proxy).getABIEncodedTransactionData(), }, { destination: exchange.address, - data: exchange.registerAssetProxy.getABIEncodedTransactionData(deployedAddresses.erc1155Proxy), + data: exchange.registerAssetProxy(deployedAddresses.erc1155Proxy).getABIEncodedTransactionData(), }, { destination: exchange.address, - data: exchange.registerAssetProxy.getABIEncodedTransactionData(deployedAddresses.multiAssetProxy), + data: exchange.registerAssetProxy(deployedAddresses.multiAssetProxy).getABIEncodedTransactionData(), }, { destination: exchange.address, - data: exchange.registerAssetProxy.getABIEncodedTransactionData(deployedAddresses.staticCallProxy), + data: exchange.registerAssetProxy(deployedAddresses.staticCallProxy).getABIEncodedTransactionData(), }, { destination: exchange.address, - data: exchange.registerAssetProxy.getABIEncodedTransactionData(erc20BridgeProxy.address), + data: exchange.registerAssetProxy(erc20BridgeProxy.address).getABIEncodedTransactionData(), }, // ZrxVault configs { destination: zrxVault.address, - data: authorizableInterface.addAuthorizedAddress.getABIEncodedTransactionData(governor.address), + data: authorizableInterface.addAuthorizedAddress(governor.address).getABIEncodedTransactionData(), }, { destination: zrxVault.address, - data: zrxVault.setStakingProxy.getABIEncodedTransactionData(stakingProxy.address), + data: zrxVault.setStakingProxy(stakingProxy.address).getABIEncodedTransactionData(), }, // StakingProxy configs { destination: stakingProxy.address, - data: authorizableInterface.addAuthorizedAddress.getABIEncodedTransactionData(governor.address), + data: authorizableInterface.addAuthorizedAddress(governor.address).getABIEncodedTransactionData(), }, { destination: stakingProxy.address, - data: stakingLogic.addExchangeAddress.getABIEncodedTransactionData(exchange.address), + data: stakingLogic.addExchangeAddress(exchange.address).getABIEncodedTransactionData(), }, // AssetProxy configs { destination: deployedAddresses.erc20Proxy, - data: authorizableInterface.addAuthorizedAddress.getABIEncodedTransactionData(exchange.address), + data: authorizableInterface.addAuthorizedAddress(exchange.address).getABIEncodedTransactionData(), }, { destination: deployedAddresses.erc20Proxy, - data: authorizableInterface.addAuthorizedAddress.getABIEncodedTransactionData(zrxVault.address), + data: authorizableInterface.addAuthorizedAddress(zrxVault.address).getABIEncodedTransactionData(), }, { destination: deployedAddresses.erc721Proxy, - data: authorizableInterface.addAuthorizedAddress.getABIEncodedTransactionData(exchange.address), + data: authorizableInterface.addAuthorizedAddress(exchange.address).getABIEncodedTransactionData(), }, { destination: deployedAddresses.erc1155Proxy, - data: authorizableInterface.addAuthorizedAddress.getABIEncodedTransactionData(exchange.address), + data: authorizableInterface.addAuthorizedAddress(exchange.address).getABIEncodedTransactionData(), }, { destination: deployedAddresses.multiAssetProxy, - data: authorizableInterface.addAuthorizedAddress.getABIEncodedTransactionData(exchange.address), + data: authorizableInterface.addAuthorizedAddress(exchange.address).getABIEncodedTransactionData(), }, { destination: deployedAddresses.multiAssetProxy, - data: exchange.registerAssetProxy.getABIEncodedTransactionData(erc20BridgeProxy.address), + data: exchange.registerAssetProxy(erc20BridgeProxy.address).getABIEncodedTransactionData(), }, { destination: erc20BridgeProxy.address, - data: authorizableInterface.addAuthorizedAddress.getABIEncodedTransactionData(exchange.address), + data: authorizableInterface.addAuthorizedAddress(exchange.address).getABIEncodedTransactionData(), }, { destination: erc20BridgeProxy.address, - data: authorizableInterface.addAuthorizedAddress.getABIEncodedTransactionData( - deployedAddresses.multiAssetProxy, - ), + data: authorizableInterface + .addAuthorizedAddress(deployedAddresses.multiAssetProxy) + .getABIEncodedTransactionData(), }, ]; diff --git a/packages/order-utils/src/asset_balance_and_proxy_allowance_fetcher.ts b/packages/order-utils/src/asset_balance_and_proxy_allowance_fetcher.ts index 1cef5d3c73..0745747bb6 100644 --- a/packages/order-utils/src/asset_balance_and_proxy_allowance_fetcher.ts +++ b/packages/order-utils/src/asset_balance_and_proxy_allowance_fetcher.ts @@ -10,11 +10,11 @@ export class AssetBalanceAndProxyAllowanceFetcher implements AbstractBalanceAndP this._devUtilsContract = devUtilsContract; } public async getBalanceAsync(assetData: string, userAddress: string): Promise { - const balance = await this._devUtilsContract.getBalance.callAsync(userAddress, assetData); + const balance = await this._devUtilsContract.getBalance(userAddress, assetData).callAsync(); return balance; } public async getProxyAllowanceAsync(assetData: string, userAddress: string): Promise { - const proxyAllowance = await this._devUtilsContract.getAssetProxyAllowance.callAsync(userAddress, assetData); + const proxyAllowance = await this._devUtilsContract.getAssetProxyAllowance(userAddress, assetData).callAsync(); return proxyAllowance; } } diff --git a/packages/order-utils/src/signature_utils.ts b/packages/order-utils/src/signature_utils.ts index 25e92e3457..364f564c39 100644 --- a/packages/order-utils/src/signature_utils.ts +++ b/packages/order-utils/src/signature_utils.ts @@ -125,7 +125,7 @@ export const signatureUtils = { exchangeContract = new ExchangeContract(addresses.exchange, provider); } - const isValid = await exchangeContract.preSigned.callAsync(data, signerAddress); + const isValid = await exchangeContract.preSigned(data, signerAddress).callAsync(); return isValid; }, /** @@ -150,7 +150,7 @@ export const signatureUtils = { const signatureWithoutType = signature.slice(0, -2); const walletContract = new IWalletContract(signerAddress, provider); try { - const magicValue = await walletContract.isValidSignature.callAsync(data, signatureWithoutType); + const magicValue = await walletContract.isValidSignature(data, signatureWithoutType).callAsync(); return magicValue === constants.IS_VALID_WALLET_SIGNATURE_MAGIC_VALUE; } catch (e) { return false; @@ -189,10 +189,9 @@ export const signatureUtils = { } const validatorSignature = signatureUtils.parseValidatorSignature(signature); - const isValidatorApproved = await exchangeContract.allowedValidators.callAsync( - signerAddress, - validatorSignature.validatorAddress, - ); + const isValidatorApproved = await exchangeContract + .allowedValidators(signerAddress, validatorSignature.validatorAddress) + .callAsync(); if (!isValidatorApproved) { throw new Error( `Validator ${validatorSignature.validatorAddress} was not pre-approved by ${signerAddress}.`, @@ -201,11 +200,9 @@ export const signatureUtils = { const validatorContract = new IValidatorContract(validatorSignature.validatorAddress, provider); try { - const magicValue = await validatorContract.isValidSignature.callAsync( - data, - signerAddress, - validatorSignature.signature, - ); + const magicValue = await validatorContract + .isValidSignature(data, signerAddress, validatorSignature.signature) + .callAsync(); return magicValue === constants.IS_VALID_VALIDATOR_SIGNATURE_MAGIC_VALUE; } catch (e) { return false; diff --git a/packages/order-utils/test/exchange_transfer_simulator_test.ts b/packages/order-utils/test/exchange_transfer_simulator_test.ts index 1d64401482..1c06828375 100644 --- a/packages/order-utils/test/exchange_transfer_simulator_test.ts +++ b/packages/order-utils/test/exchange_transfer_simulator_test.ts @@ -72,7 +72,7 @@ describe('ExchangeTransferSimulator', async () => { totalSupply, ); - exampleAssetData = await devUtils.encodeERC20AssetData.callAsync(dummyERC20Token.address); + exampleAssetData = await devUtils.encodeERC20AssetData(dummyERC20Token.address).callAsync(); }); beforeEach(async () => { await blockchainLifecycle.startAsync(); @@ -110,7 +110,7 @@ describe('ExchangeTransferSimulator', async () => { ).to.be.rejectedWith(ExchangeContractErrs.InsufficientTakerAllowance); }); it("throws if the user doesn't have enough balance", async () => { - txHash = await dummyERC20Token.approve.sendTransactionAsync(erc20ProxyAddress, transferAmount, { + txHash = await dummyERC20Token.approve(erc20ProxyAddress, transferAmount).sendTransactionAsync({ from: sender, }); await web3Wrapper.awaitTransactionSuccessAsync(txHash); @@ -126,12 +126,12 @@ describe('ExchangeTransferSimulator', async () => { ).to.be.rejectedWith(ExchangeContractErrs.InsufficientMakerBalance); }); it('updates balances and proxyAllowance after transfer', async () => { - txHash = await dummyERC20Token.transfer.sendTransactionAsync(sender, transferAmount, { + txHash = await dummyERC20Token.transfer(sender, transferAmount).sendTransactionAsync({ from: coinbase, }); await web3Wrapper.awaitTransactionSuccessAsync(txHash); - txHash = await dummyERC20Token.approve.sendTransactionAsync(erc20ProxyAddress, transferAmount, { + txHash = await dummyERC20Token.approve(erc20ProxyAddress, transferAmount).sendTransactionAsync({ from: sender, }); await web3Wrapper.awaitTransactionSuccessAsync(txHash); @@ -153,17 +153,15 @@ describe('ExchangeTransferSimulator', async () => { expect(senderProxyAllowance).to.be.bignumber.equal(0); }); it("doesn't update proxyAllowance after transfer if unlimited", async () => { - txHash = await dummyERC20Token.transfer.sendTransactionAsync(sender, transferAmount, { + txHash = await dummyERC20Token.transfer(sender, transferAmount).sendTransactionAsync({ from: coinbase, }); await web3Wrapper.awaitTransactionSuccessAsync(txHash); - txHash = await dummyERC20Token.approve.sendTransactionAsync( - erc20ProxyAddress, - constants.UNLIMITED_ALLOWANCE_IN_BASE_UNITS, - { + txHash = await dummyERC20Token + .approve(erc20ProxyAddress, constants.UNLIMITED_ALLOWANCE_IN_BASE_UNITS) + .sendTransactionAsync({ from: sender, - }, - ); + }); await web3Wrapper.awaitTransactionSuccessAsync(txHash); await exchangeTransferSimulator.transferFromAsync( exampleAssetData, diff --git a/packages/order-utils/test/utils/simple_erc20_balance_and_proxy_allowance_fetcher.ts b/packages/order-utils/test/utils/simple_erc20_balance_and_proxy_allowance_fetcher.ts index d3ea8b4567..59f25e9d74 100644 --- a/packages/order-utils/test/utils/simple_erc20_balance_and_proxy_allowance_fetcher.ts +++ b/packages/order-utils/test/utils/simple_erc20_balance_and_proxy_allowance_fetcher.ts @@ -13,13 +13,15 @@ export class SimpleERC20BalanceAndProxyAllowanceFetcher implements AbstractBalan public async getBalanceAsync(_assetData: string, userAddress: string): Promise { // HACK: We cheat and don't pass in the assetData since it's always the same token used // in our tests. - const balance = await this._erc20TokenContract.balanceOf.callAsync(userAddress); + const balance = await this._erc20TokenContract.balanceOf(userAddress).callAsync(); return balance; } public async getProxyAllowanceAsync(_assetData: string, userAddress: string): Promise { // HACK: We cheat and don't pass in the assetData since it's always the same token used // in our tests. - const proxyAllowance = await this._erc20TokenContract.allowance.callAsync(userAddress, this._erc20ProxyAddress); + const proxyAllowance = await this._erc20TokenContract + .allowance(userAddress, this._erc20ProxyAddress) + .callAsync(); return proxyAllowance; } } diff --git a/packages/testnet-faucets/src/ts/dispense_asset_tasks.ts b/packages/testnet-faucets/src/ts/dispense_asset_tasks.ts index afe1ceb0cc..d10819c4d5 100644 --- a/packages/testnet-faucets/src/ts/dispense_asset_tasks.ts +++ b/packages/testnet-faucets/src/ts/dispense_asset_tasks.ts @@ -48,7 +48,7 @@ export const dispenseAssetTasks = { } const baseUnitAmount = Web3Wrapper.toBaseUnitAmount(amountToDispense, tokenIfExists.decimals); const erc20Token = new ERC20TokenContract(tokenIfExists.address, provider); - const userBalanceBaseUnits = await erc20Token.balanceOf.callAsync(recipientAddress); + const userBalanceBaseUnits = await erc20Token.balanceOf(recipientAddress).callAsync(); const maxAmountBaseUnits = Web3Wrapper.toBaseUnitAmount( new BigNumber(DISPENSE_MAX_AMOUNT_TOKEN), tokenIfExists.decimals, @@ -59,7 +59,7 @@ export const dispenseAssetTasks = { ); return; } - const txHash = await erc20Token.transfer.sendTransactionAsync(recipientAddress, baseUnitAmount, { + const txHash = await erc20Token.transfer(recipientAddress, baseUnitAmount).sendTransactionAsync({ from: configs.DISPENSER_ADDRESS, }); logUtils.log(`Sent ${amountToDispense} ${tokenSymbol} to ${recipientAddress} tx: ${txHash}`); From 73ffa911c55ba674218629e570c6554a434cb5f6 Mon Sep 17 00:00:00 2001 From: fabioberger Date: Wed, 13 Nov 2019 12:33:19 +0000 Subject: [PATCH 04/20] Fix two contract wrapper calls --- packages/asset-swapper/test/swap_quote_consumer_utils_test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/asset-swapper/test/swap_quote_consumer_utils_test.ts b/packages/asset-swapper/test/swap_quote_consumer_utils_test.ts index 9252e014fc..cc9b02728f 100644 --- a/packages/asset-swapper/test/swap_quote_consumer_utils_test.ts +++ b/packages/asset-swapper/test/swap_quote_consumer_utils_test.ts @@ -145,7 +145,7 @@ describe('swapQuoteConsumerUtils', () => { }); it('should return exchange consumer if takerAsset is wEth and taker has enough weth', async () => { const etherInWei = new BigNumber(20).multipliedBy(ONE_ETH_IN_WEI); - await contractWrappers.weth9.deposit({ value: etherInWei, from: takerAddress }).sendTransactionAsync(); + await contractWrappers.weth9.deposit().sendTransactionAsync({ value: etherInWei, from: takerAddress }); const extensionContractType = await swapQuoteConsumer.getOptimalExtensionContractTypeAsync( forwarderSwapQuote, { takerAddress }, @@ -154,7 +154,7 @@ describe('swapQuoteConsumerUtils', () => { }); it('should return forwarder consumer if takerAsset is wEth and takerAddress has no available balance in either weth or eth (defaulting behavior)', async () => { const etherInWei = new BigNumber(50).multipliedBy(ONE_ETH_IN_WEI); - await contractWrappers.weth9.deposit({ value: etherInWei, from: takerAddress }).sendTransactionAsync(); + await contractWrappers.weth9.deposit().sendTransactionAsync({ value: etherInWei, from: takerAddress }); const extensionContractType = await swapQuoteConsumer.getOptimalExtensionContractTypeAsync( largeForwarderSwapQuote, { takerAddress }, From 552f8404136258b6541a13c2c030ab3ccfe01d9f Mon Sep 17 00:00:00 2001 From: fabioberger Date: Wed, 13 Nov 2019 13:50:42 +0000 Subject: [PATCH 05/20] Export necessary types part of the contract wrapper public interfaces --- packages/0x.js/src/index.ts | 7 ++++++- packages/abi-gen-wrappers/src/index.ts | 8 ++++++++ packages/base-contract/src/index.ts | 9 ++++++++- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/packages/0x.js/src/index.ts b/packages/0x.js/src/index.ts index 9b87cdb91f..f550895cca 100644 --- a/packages/0x.js/src/index.ts +++ b/packages/0x.js/src/index.ts @@ -46,6 +46,12 @@ export { ExchangeProtocolFeeCollectorAddressEventArgs, ExchangeProtocolFeeMultiplierEventArgs, ExchangeTransactionExecutionEventArgs, + ContractEvent, + SendTransactionOpts, + AwaitTransactionSuccessOpts, + ContractFunctionObj, + ContractTxFunctionObj, + SubscriptionErrors, } from '@0x/abi-gen-wrappers'; export import Web3ProviderEngine = require('web3-provider-engine'); @@ -83,7 +89,6 @@ export { SimpleEvmOutput, SimpleEvmBytecodeOutput, EIP712DomainWithDefaultSchema, - AwaitTransactionSuccessOpts, SendTransactionOpts, EventCallback, IndexedFilterValues, diff --git a/packages/abi-gen-wrappers/src/index.ts b/packages/abi-gen-wrappers/src/index.ts index a4ab6b93bf..42b4eaf334 100644 --- a/packages/abi-gen-wrappers/src/index.ts +++ b/packages/abi-gen-wrappers/src/index.ts @@ -158,3 +158,11 @@ export { export { EthBalanceCheckerContract } from './generated-wrappers/eth_balance_checker'; export * from '@0x/contract-addresses'; +export { + ContractEvent, + SendTransactionOpts, + AwaitTransactionSuccessOpts, + ContractFunctionObj, + ContractTxFunctionObj, + SubscriptionErrors, +} from '@0x/base-contract'; diff --git a/packages/base-contract/src/index.ts b/packages/base-contract/src/index.ts index e3076946a0..1eb2d0fd67 100644 --- a/packages/base-contract/src/index.ts +++ b/packages/base-contract/src/index.ts @@ -35,7 +35,14 @@ import { formatABIDataItem } from './utils'; export { SubscriptionManager } from './subscription_manager'; -export * from './types'; +export { + ContractEvent, + SendTransactionOpts, + AwaitTransactionSuccessOpts, + ContractFunctionObj, + ContractTxFunctionObj, + SubscriptionErrors, +} from './types'; export interface AbiEncoderByFunctionSignature { [key: string]: AbiEncoder.Method; From afab60077abd9cf3e036b0627fc5fb91a91143bb Mon Sep 17 00:00:00 2001 From: fabioberger Date: Wed, 13 Nov 2019 13:50:54 +0000 Subject: [PATCH 06/20] Revive and fix wrapper_unit_tests --- contracts/exchange/test/wrapper_unit_tests.ts | 2690 +++++++++-------- 1 file changed, 1363 insertions(+), 1327 deletions(-) diff --git a/contracts/exchange/test/wrapper_unit_tests.ts b/contracts/exchange/test/wrapper_unit_tests.ts index 69ebd113c7..034bd492f0 100644 --- a/contracts/exchange/test/wrapper_unit_tests.ts +++ b/contracts/exchange/test/wrapper_unit_tests.ts @@ -1,1327 +1,1363 @@ -// import { ReferenceFunctions as LibReferenceFunctions } from '@0x/contracts-exchange-libs'; -// import { -// blockchainTests, -// constants, -// describe, -// expect, -// hexRandom, -// MutatorContractFunction, -// transactionHelper, -// } from '@0x/contracts-test-utils'; -// import { ReferenceFunctions as UtilReferenceFunctions } from '@0x/contracts-utils'; -// import { ExchangeRevertErrors, orderHashUtils } from '@0x/order-utils'; -// import { FillResults, Order } from '@0x/types'; -// import { AnyRevertError, BigNumber, SafeMathRevertErrors, StringRevertError } from '@0x/utils'; -// import { LogEntry, LogWithDecodedArgs } from 'ethereum-types'; -// import * as ethjs from 'ethereumjs-util'; -// import * as _ from 'lodash'; - -// import { -// artifacts, -// TestWrapperFunctionsCancelOrderCalledEventArgs as CancelOrderCalledEventArgs, -// TestWrapperFunctionsContract, -// TestWrapperFunctionsFillOrderCalledEventArgs as FillOrderCalledEventArgs, -// } from '../src'; - -// blockchainTests('Exchange wrapper functions unit tests.', env => { -// const CHAIN_ID = 0x74657374; -// const { ONE_ETHER, MAX_UINT256 } = constants; -// const { addFillResults, getPartialAmountFloor } = LibReferenceFunctions; -// const { safeSub } = UtilReferenceFunctions; -// const protocolFeeMultiplier = new BigNumber(150000); -// const randomAddress = () => hexRandom(constants.ADDRESS_LENGTH); -// const randomAssetData = () => hexRandom(34); -// const randomAmount = (maxAmount: BigNumber = ONE_ETHER) => maxAmount.times(_.random(0, 100, true).toFixed(12)); -// const randomTimestamp = () => new BigNumber(Math.floor(_.now() / 1000) + _.random(0, 34560)); -// const randomSalt = () => new BigNumber(hexRandom(constants.WORD_LENGTH).substr(2), 16); -// const ALWAYS_FAILING_SALT = constants.MAX_UINT256; -// const ALWAYS_FAILING_SALT_REVERT_ERROR = new StringRevertError('ALWAYS_FAILING_SALT'); -// const EMPTY_FILL_RESULTS = { -// makerAssetFilledAmount: constants.ZERO_AMOUNT, -// takerAssetFilledAmount: constants.ZERO_AMOUNT, -// makerFeePaid: constants.ZERO_AMOUNT, -// takerFeePaid: constants.ZERO_AMOUNT, -// protocolFeePaid: constants.ZERO_AMOUNT, -// }; -// let testContract: TestWrapperFunctionsContract; -// let owner: string; -// let senderAddress: string; - -// before(async () => { -// [owner, senderAddress] = await env.getAccountAddressesAsync(); -// testContract = await TestWrapperFunctionsContract.deployFrom0xArtifactAsync( -// artifacts.TestWrapperFunctions, -// env.provider, -// { -// ...env.txDefaults, -// from: owner, -// }, -// {}, -// ); - -// // Set the protocol fee multiplier. -// await testContract.setProtocolFeeMultiplier(protocolFeeMultiplier).awaitTransactionSuccessAsync({ -// from: owner, -// }); -// }); - -// function randomOrder(fields?: Partial): Order { -// return { -// makerAddress: randomAddress(), -// takerAddress: randomAddress(), -// feeRecipientAddress: randomAddress(), -// senderAddress: randomAddress(), -// takerAssetAmount: randomAmount(), -// makerAssetAmount: randomAmount(), -// makerFee: randomAmount(), -// takerFee: randomAmount(), -// expirationTimeSeconds: randomTimestamp(), -// salt: randomSalt(), -// makerAssetData: randomAssetData(), -// takerAssetData: randomAssetData(), -// makerFeeAssetData: randomAssetData(), -// takerFeeAssetData: randomAssetData(), -// exchangeAddress: constants.NULL_ADDRESS, -// chainId: CHAIN_ID, -// ...(fields || {}), -// }; -// } - -// // Computes the expected (fake) fill results from `TestWrapperFunctions` `_fillOrder` implementation. -// function getExpectedFillResults(order: Order, signature: string): FillResults { -// if (order.salt === ALWAYS_FAILING_SALT) { -// return EMPTY_FILL_RESULTS; -// } -// return { -// makerAssetFilledAmount: order.makerAssetAmount, -// takerAssetFilledAmount: order.takerAssetAmount, -// makerFeePaid: order.makerFee, -// takerFeePaid: order.takerFee, -// protocolFeePaid: protocolFeeMultiplier, -// }; -// } - -// // Creates a deterministic order signature, even though no signature validation -// // actually occurs in the test contract. -// function createOrderSignature(order: Order): string { -// return ethjs.bufferToHex(ethjs.sha3(ethjs.toBuffer(orderHashUtils.getOrderHashHex(order)))); -// } - -// // Asserts that `_fillOrder()` was called in the same order and with the same -// // arguments as given by examining receipt logs. -// function assertFillOrderCallsFromLogs(logs: LogEntry[], calls: Array<[Order, BigNumber, string]>): void { -// expect(logs.length).to.eq(calls.length); -// for (const i of _.times(calls.length)) { -// const log = (logs[i] as any) as LogWithDecodedArgs; -// const [expectedOrder, expectedTakerAssetFillAmount, expectedSignature] = calls[i]; -// expect(log.event).to.eq('FillOrderCalled'); -// assertSameOrderFromEvent(log.args.order as any, expectedOrder); -// expect(log.args.takerAssetFillAmount).to.bignumber.eq(expectedTakerAssetFillAmount); -// expect(log.args.signature).to.eq(expectedSignature); -// } -// } - -// function assertSameOrderFromEvent(actual: any[], expected: Order): void { -// expect(actual.length === 14); -// expect(actual[0].toLowerCase()).to.be.eq(expected.makerAddress); -// expect(actual[1].toLowerCase()).to.be.eq(expected.takerAddress); -// expect(actual[2].toLowerCase()).to.be.eq(expected.feeRecipientAddress); -// expect(actual[3].toLowerCase()).to.be.eq(expected.senderAddress); -// expect(actual[4]).to.be.bignumber.eq(expected.makerAssetAmount); -// expect(actual[5]).to.be.bignumber.eq(expected.takerAssetAmount); -// expect(actual[6]).to.be.bignumber.eq(expected.makerFee); -// expect(actual[7]).to.be.bignumber.eq(expected.takerFee); -// expect(actual[8]).to.be.bignumber.eq(expected.expirationTimeSeconds); -// expect(actual[9]).to.be.bignumber.eq(expected.salt); -// expect(actual[10]).to.be.eq(expected.makerAssetData); -// expect(actual[11]).to.be.eq(expected.takerAssetData); -// expect(actual[12]).to.be.eq(expected.makerFeeAssetData); -// expect(actual[13]).to.be.eq(expected.takerFeeAssetData); -// } - -// describe('fillOrKillOrder', () => { -// it('works if the order is filled by exactly `takerAssetFillAmount`', async () => { -// const fillAmount = randomAmount(); -// const order = randomOrder({ -// // `_fillOrder()` is overridden to always return `order.takerAssetAmount` as -// // the `takerAssetFilledAmount`. -// takerAssetAmount: fillAmount, -// }); -// const signature = createOrderSignature(order); -// const expectedResult = getExpectedFillResults(order, signature); -// const expectedCalls = [[order, fillAmount, signature]]; -// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( -// testContract.fillOrKillOrder, -// order, -// fillAmount, -// signature, -// ); -// expect(actualResult).to.deep.eq(expectedResult); -// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); -// }); - -// it('reverts if the order is filled by less than `takerAssetFillAmount`', async () => { -// const fillAmount = randomAmount(); -// const order = randomOrder({ -// // `_fillOrder()` is overridden to always return `order.takerAssetAmount` as -// // the `takerAssetFilledAmount`. -// takerAssetAmount: fillAmount.minus(1), -// }); -// const signature = createOrderSignature(order); -// const expectedError = new ExchangeRevertErrors.IncompleteFillError( -// ExchangeRevertErrors.IncompleteFillErrorCode.IncompleteFillOrder, -// fillAmount, -// fillAmount.minus(1), -// ); -// const tx = testContract.fillOrKillOrder(order, fillAmount, signature).awaitTransactionSuccessAsync(); -// return expect(tx).to.revertWith(expectedError); -// }); - -// it('reverts if the order is filled by greater than `takerAssetFillAmount`', async () => { -// const fillAmount = randomAmount(); -// const order = randomOrder({ -// // `_fillOrder()` is overridden to always return `order.takerAssetAmount` as -// // the `takerAssetFilledAmount`. -// takerAssetAmount: fillAmount.plus(1), -// }); -// const signature = createOrderSignature(order); -// const expectedError = new ExchangeRevertErrors.IncompleteFillError( -// ExchangeRevertErrors.IncompleteFillErrorCode.IncompleteFillOrder, -// fillAmount, -// fillAmount.plus(1), -// ); -// const tx = testContract.fillOrKillOrder(order, fillAmount, signature).awaitTransactionSuccessAsync(); -// return expect(tx).to.revertWith(expectedError); -// }); - -// it('reverts if `_fillOrder()` reverts', async () => { -// const fillAmount = randomAmount(); -// const order = randomOrder({ -// salt: ALWAYS_FAILING_SALT, -// }); -// const signature = createOrderSignature(order); -// const expectedError = ALWAYS_FAILING_SALT_REVERT_ERROR; -// const tx = testContract.fillOrKillOrder(order, fillAmount, signature).awaitTransactionSuccessAsync(); -// return expect(tx).to.revertWith(expectedError); -// }); -// }); - -// describe('fillOrderNoThrow', () => { -// it('calls `fillOrder()` and returns its result', async () => { -// const fillAmount = randomAmount(); -// const order = randomOrder(); -// const signature = createOrderSignature(order); -// const expectedResult = getExpectedFillResults(order, signature); -// const expectedCalls = [[order, fillAmount, signature]]; -// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( -// testContract.fillOrderNoThrow, -// order, -// fillAmount, -// signature, -// ); -// expect(actualResult).to.deep.eq(expectedResult); -// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); -// }); - -// it('does not revert if `fillOrder()` reverts', async () => { -// const fillAmount = randomAmount(); -// const order = randomOrder({ -// salt: ALWAYS_FAILING_SALT, -// }); -// const signature = createOrderSignature(order); -// const expectedResult = EMPTY_FILL_RESULTS; -// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( -// testContract.fillOrderNoThrow, -// order, -// fillAmount, -// signature, -// ); -// expect(actualResult).to.deep.eq(expectedResult); -// assertFillOrderCallsFromLogs(receipt.logs, []); -// }); -// }); - -// describe('batchFillOrders', () => { -// it('works with no fills', async () => { -// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( -// testContract.batchFillOrders, -// [], -// [], -// [], -// ); -// expect(actualResult).to.deep.eq([]); -// assertFillOrderCallsFromLogs(receipt.logs, []); -// }); - -// it('works with one fill', async () => { -// const COUNT = 1; -// const orders = _.times(COUNT, () => randomOrder()); -// const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); -// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); -// const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); -// const expectedCalls = _.zip(orders, fillAmounts, signatures); -// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( -// testContract.batchFillOrders, -// orders, -// fillAmounts, -// signatures, -// ); -// expect(actualResult).to.deep.eq(expectedResult); -// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); -// }); - -// it('works with many fills', async () => { -// const COUNT = 8; -// const orders = _.times(COUNT, () => randomOrder()); -// const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); -// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); -// const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); -// const expectedCalls = _.zip(orders, fillAmounts, signatures); -// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( -// testContract.batchFillOrders, -// orders, -// fillAmounts, -// signatures, -// ); -// expect(actualResult).to.deep.eq(expectedResult); -// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); -// }); - -// it('works with duplicate orders', async () => { -// const NUM_UNIQUE_ORDERS = 2; -// const COUNT = 4; -// const uniqueOrders = _.times(NUM_UNIQUE_ORDERS, () => randomOrder()); -// const orders = _.shuffle(_.flatten(_.times(COUNT / NUM_UNIQUE_ORDERS, () => uniqueOrders))); -// const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount.dividedToIntegerBy(COUNT)); -// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); -// const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); -// const expectedCalls = _.zip(orders, fillAmounts, signatures); -// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( -// testContract.batchFillOrders, -// orders, -// fillAmounts, -// signatures, -// ); -// expect(actualResult).to.deep.eq(expectedResult); -// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); -// }); - -// it('reverts if there are more orders than fill amounts', async () => { -// const COUNT = 8; -// const orders = _.times(COUNT, () => randomOrder()); -// const fillAmounts = _.times(COUNT - 1, i => orders[i].takerAssetAmount); -// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); -// const expectedError = new AnyRevertError(); // Just a generic revert. -// const tx = transactionHelper.getResultAndReceiptAsync(testContract.batchFillOrders, orders, fillAmounts, signatures); -// return expect(tx).to.revertWith(expectedError); -// }); - -// it('reverts if there are more orders than signatures', async () => { -// const COUNT = 8; -// const orders = _.times(COUNT, () => randomOrder()); -// const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); -// const signatures = _.times(COUNT - 1, i => createOrderSignature(orders[i])); -// const expectedError = new AnyRevertError(); // Just a generic revert. -// const tx = transactionHelper.getResultAndReceiptAsync(testContract.batchFillOrders, orders, fillAmounts, signatures); -// return expect(tx).to.revertWith(expectedError); -// }); -// }); - -// describe('batchFillOrKillOrders', () => { -// it('works with no fills', async () => { -// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( -// testContract.batchFillOrKillOrders, -// [], -// [], -// [], -// ); -// expect(actualResult).to.deep.eq([]); -// assertFillOrderCallsFromLogs(receipt.logs, []); -// }); - -// it('works with one fill', async () => { -// const COUNT = 1; -// const orders = _.times(COUNT, () => randomOrder()); -// const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); -// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); -// const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); -// const expectedCalls = _.zip(orders, fillAmounts, signatures); -// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( -// testContract.batchFillOrKillOrders, -// orders, -// fillAmounts, -// signatures, -// ); -// expect(actualResult).to.deep.eq(expectedResult); -// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); -// }); - -// it('works with many fills', async () => { -// const COUNT = 8; -// const orders = _.times(COUNT, () => randomOrder()); -// const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); -// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); -// const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); -// const expectedCalls = _.zip(orders, fillAmounts, signatures); -// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( -// testContract.batchFillOrKillOrders, -// orders, -// fillAmounts, -// signatures, -// ); -// expect(actualResult).to.deep.eq(expectedResult); -// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); -// }); - -// it('works with duplicate orders', async () => { -// const NUM_UNIQUE_ORDERS = 2; -// const COUNT = 4; -// const uniqueOrders = _.times(NUM_UNIQUE_ORDERS, () => randomOrder()); -// const orders = _.shuffle(_.flatten(_.times(COUNT / NUM_UNIQUE_ORDERS, () => uniqueOrders))); -// const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); -// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); -// const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); -// const expectedCalls = _.zip(orders, fillAmounts, signatures); -// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( -// testContract.batchFillOrKillOrders, -// orders, -// fillAmounts, -// signatures, -// ); -// expect(actualResult).to.deep.eq(expectedResult); -// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); -// }); - -// it('reverts if any fill sells less than its takerAssetFillAmount', async () => { -// const COUNT = 8; -// const FAILING_ORDER_INDEX = 6; -// const orders = _.times(COUNT, () => randomOrder()); -// const failingOrder = orders[FAILING_ORDER_INDEX]; -// const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); -// const failingAmount = fillAmounts[FAILING_ORDER_INDEX]; -// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); -// // `_fillOrder()` is overridden to always return `order.takerAssetAmount` as -// // the `takerAssetFilledAmount`. -// failingOrder.takerAssetAmount = failingOrder.takerAssetAmount.minus(1); -// const expectedError = new ExchangeRevertErrors.IncompleteFillError( -// ExchangeRevertErrors.IncompleteFillErrorCode.IncompleteFillOrder, -// failingAmount, -// failingAmount.minus(1), -// ); -// const tx = transactionHelper.getResultAndReceiptAsync( -// testContract.batchFillOrKillOrders, -// orders, -// fillAmounts, -// signatures, -// ); -// return expect(tx).to.revertWith(expectedError); -// }); - -// it('reverts if any fill sells more than its takerAssetFillAmount', async () => { -// const COUNT = 8; -// const FAILING_ORDER_INDEX = 6; -// const orders = _.times(COUNT, () => randomOrder()); -// const failingOrder = orders[FAILING_ORDER_INDEX]; -// const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); -// const failingAmount = fillAmounts[FAILING_ORDER_INDEX]; -// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); -// // `_fillOrder()` is overridden to always return `order.takerAssetAmount` as -// // the `takerAssetFilledAmount`. -// failingOrder.takerAssetAmount = failingOrder.takerAssetAmount.plus(1); -// const expectedError = new ExchangeRevertErrors.IncompleteFillError( -// ExchangeRevertErrors.IncompleteFillErrorCode.IncompleteFillOrder, -// failingAmount, -// failingAmount.plus(1), -// ); -// const tx = transactionHelper.getResultAndReceiptAsync( -// testContract.batchFillOrKillOrders, -// orders, -// fillAmounts, -// signatures, -// ); -// return expect(tx).to.revertWith(expectedError); -// }); - -// it('reverts if there are more orders than fill amounts', async () => { -// const COUNT = 8; -// const orders = _.times(COUNT, () => randomOrder()); -// const fillAmounts = _.times(COUNT - 1, i => orders[i].takerAssetAmount); -// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); -// const expectedError = new AnyRevertError(); // Just a generic revert. -// const tx = transactionHelper.getResultAndReceiptAsync( -// testContract.batchFillOrKillOrders, -// orders, -// fillAmounts, -// signatures, -// ); -// return expect(tx).to.revertWith(expectedError); -// }); - -// it('reverts if there are more orders than signatures', async () => { -// const COUNT = 8; -// const orders = _.times(COUNT, () => randomOrder()); -// const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); -// const signatures = _.times(COUNT - 1, i => createOrderSignature(orders[i])); -// const expectedError = new AnyRevertError(); // Just a generic revert. -// const tx = transactionHelper.getResultAndReceiptAsync( -// testContract.batchFillOrKillOrders, -// orders, -// fillAmounts, -// signatures, -// ); -// return expect(tx).to.revertWith(expectedError); -// }); -// }); - -// describe('batchFillOrdersNoThrow', () => { -// it('works with no fills', async () => { -// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( -// testContract.batchFillOrdersNoThrow, -// [], -// [], -// [], -// ); -// expect(actualResult).to.deep.eq([]); -// assertFillOrderCallsFromLogs(receipt.logs, []); -// }); - -// it('works with one fill', async () => { -// const COUNT = 1; -// const orders = _.times(COUNT, () => randomOrder()); -// const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); -// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); -// const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); -// const expectedCalls = _.zip(orders, fillAmounts, signatures); -// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( -// testContract.batchFillOrdersNoThrow, -// orders, -// fillAmounts, -// signatures, -// ); -// expect(actualResult).to.deep.eq(expectedResult); -// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); -// }); - -// it('works with many fills', async () => { -// const COUNT = 8; -// const orders = _.times(COUNT, () => randomOrder()); -// const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); -// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); -// const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); -// const expectedCalls = _.zip(orders, fillAmounts, signatures); -// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( -// testContract.batchFillOrdersNoThrow, -// orders, -// fillAmounts, -// signatures, -// ); -// expect(actualResult).to.deep.eq(expectedResult); -// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); -// }); - -// it('works with duplicate orders', async () => { -// const NUM_UNIQUE_ORDERS = 2; -// const COUNT = 4; -// const uniqueOrders = _.times(NUM_UNIQUE_ORDERS, () => randomOrder()); -// const orders = _.shuffle(_.flatten(_.times(COUNT / NUM_UNIQUE_ORDERS, () => uniqueOrders))); -// const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount.dividedToIntegerBy(COUNT)); -// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); -// const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); -// const expectedCalls = _.zip(orders, fillAmounts, signatures); -// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( -// testContract.batchFillOrdersNoThrow, -// orders, -// fillAmounts, -// signatures, -// ); -// expect(actualResult).to.deep.eq(expectedResult); -// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); -// }); - -// it('works if a fill fails', async () => { -// const COUNT = 8; -// const FAILING_ORDER_INDEX = 6; -// const orders = _.times(COUNT, () => randomOrder()); -// const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); -// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); -// const failingOrder = orders[FAILING_ORDER_INDEX]; -// failingOrder.salt = ALWAYS_FAILING_SALT; -// const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); -// const expectedCalls = _.zip(orders, fillAmounts, signatures); -// expectedCalls.splice(FAILING_ORDER_INDEX, 1); -// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( -// testContract.batchFillOrdersNoThrow, -// orders, -// fillAmounts, -// signatures, -// ); -// expect(actualResult).to.deep.eq(expectedResult); -// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); -// }); - -// it('reverts if there are more orders than fill amounts', async () => { -// const COUNT = 8; -// const orders = _.times(COUNT, () => randomOrder()); -// const fillAmounts = _.times(COUNT - 1, i => orders[i].takerAssetAmount); -// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); -// const expectedError = new AnyRevertError(); // Just a generic revert. -// const tx = transactionHelper.getResultAndReceiptAsync( -// testContract.batchFillOrdersNoThrow, -// orders, -// fillAmounts, -// signatures, -// ); -// return expect(tx).to.revertWith(expectedError); -// }); - -// it('reverts if there are more orders than signatures', async () => { -// const COUNT = 8; -// const orders = _.times(COUNT, () => randomOrder()); -// const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); -// const signatures = _.times(COUNT - 1, i => createOrderSignature(orders[i])); -// const expectedError = new AnyRevertError(); // Just a generic revert. -// const tx = transactionHelper.getResultAndReceiptAsync( -// testContract.batchFillOrdersNoThrow, -// orders, -// fillAmounts, -// signatures, -// ); -// return expect(tx).to.revertWith(expectedError); -// }); -// }); - -// type ExpectedFillOrderCallArgs = [Order, BigNumber, string]; -// type MarketSellBuyArgs = [Order[], BigNumber, string[], ...any[]]; -// type MarketSellBuyContractFunction = () => MutatorContractFunction<[FillResults, ExpectedFillOrderCallArgs[]]>; -// type MarketSellBuySimulator = (...args: MarketSellBuyArgs) => [FillResults, ExpectedFillOrderCallArgs[]]; - -// describe('marketSell*', () => { -// function defineCommonMarketSellOrdersTests( -// getContractFn: MarketSellBuyContractFunction, -// simulator: MarketSellBuySimulator, -// ): void { -// it('works with one order', async () => { -// const COUNT = 1; -// const orders = _.times(COUNT, () => randomOrder()); -// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); -// const takerAssetFillAmount = _.reduce( -// orders, -// (total, o) => o.takerAssetAmount.plus(total), -// constants.ZERO_AMOUNT, -// ); -// const [expectedResult, expectedCalls] = simulator(orders, takerAssetFillAmount, signatures); -// expect(expectedCalls.length).to.eq(COUNT); -// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( -// getContractFn, -// orders, -// takerAssetFillAmount, -// signatures, -// ); -// expect(actualResult).to.deep.eq(expectedResult); -// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); -// }); - -// it('works with many orders', async () => { -// const COUNT = 8; -// const orders = _.times(COUNT, () => randomOrder()); -// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); -// const takerAssetFillAmount = _.reduce( -// orders, -// (total, o) => o.takerAssetAmount.plus(total), -// constants.ZERO_AMOUNT, -// ); -// const [expectedResult, expectedCalls] = simulator(orders, takerAssetFillAmount, signatures); -// expect(expectedCalls.length).to.eq(COUNT); -// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( -// getContractFn, -// orders, -// takerAssetFillAmount, -// signatures, -// ); -// expect(actualResult).to.deep.eq(expectedResult); -// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); -// }); - -// it('works with duplicate orders', async () => { -// const NUM_UNIQUE_ORDERS = 2; -// const COUNT = 4; -// const uniqueOrders = _.times(NUM_UNIQUE_ORDERS, () => randomOrder()); -// const orders = _.shuffle(_.flatten(_.times(COUNT / NUM_UNIQUE_ORDERS, () => uniqueOrders))); -// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); -// const takerAssetFillAmount = _.reduce( -// orders, -// (total, o) => o.takerAssetAmount.plus(total), -// constants.ZERO_AMOUNT, -// ); -// const [expectedResult, expectedCalls] = simulator(orders, takerAssetFillAmount, signatures); -// expect(expectedCalls.length).to.eq(COUNT); -// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( -// getContractFn, -// orders, -// takerAssetFillAmount, -// signatures, -// ); -// expect(actualResult).to.deep.eq(expectedResult); -// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); -// }); - -// it('stops when filled == `takerAssetFillAmount`', async () => { -// const COUNT = 4; -// const orders = _.times(COUNT, () => randomOrder()); -// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); -// // Skip the last order in our `takerAssetFillAmount` calculation. -// const takerAssetFillAmount = _.reduce( -// orders.slice(0, COUNT - 1), -// (total, o) => o.takerAssetAmount.plus(total), -// constants.ZERO_AMOUNT, -// ); -// const [expectedResult, expectedCalls] = simulator(orders, takerAssetFillAmount, signatures); -// // It should stop filling after the penultimate order. -// expect(expectedCalls.length).to.eq(COUNT - 1); -// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( -// getContractFn, -// orders, -// takerAssetFillAmount, -// signatures, -// ); -// expect(actualResult).to.deep.eq(expectedResult); -// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); -// }); - -// it('stops when filled > `takerAssetFillAmount`', async () => { -// const COUNT = 4; -// const orders = _.times(COUNT, () => randomOrder()); -// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); -// const takerAssetFillAmount = _.reduce( -// orders, -// (total, o) => o.takerAssetAmount.plus(total), -// constants.ZERO_AMOUNT, -// ); -// // Because `TestWrapperFunctions` always fills `takerAssetAmount` -// // setting the first order's `takerAssetAmount` to larger than -// // `takerAssetFillAmount` will cause an overfill. -// orders[0].takerAssetAmount = takerAssetFillAmount.plus(1); -// const [expectedResult, expectedCalls] = simulator(orders, takerAssetFillAmount, signatures); -// // It should stop filling after first order. -// expect(expectedCalls.length).to.eq(1); -// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( -// getContractFn, -// orders, -// takerAssetFillAmount, -// signatures, -// ); -// expect(actualResult).to.deep.eq(expectedResult); -// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); -// }); - -// it('reverts when an overflow occurs when summing fill results', async () => { -// const COUNT = 2; -// const orders = _.times(COUNT, () => randomOrder()); -// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); -// orders[1].takerAssetAmount = MAX_UINT256; -// const takerAssetFillAmount = MAX_UINT256; -// const expectedError = new SafeMathRevertErrors.Uint256BinOpError( -// SafeMathRevertErrors.BinOpErrorCodes.AdditionOverflow, -// orders[0].takerAssetAmount, -// orders[1].takerAssetAmount, -// ); -// const tx = transactionHelper.getResultAndReceiptAsync(getContractFn, orders, takerAssetFillAmount, signatures); -// return expect(tx).to.revertWith(expectedError); -// }); - -// it('returns empty fill results with no orders', async () => { -// const [expectedResult, expectedCalls] = simulator([], constants.ZERO_AMOUNT, []); -// expect(expectedCalls.length).to.eq(0); -// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( -// getContractFn, -// [], -// constants.ZERO_AMOUNT, -// [], -// ); - -// expect(actualResult).to.deep.eq(expectedResult); -// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); -// }); -// } - -// function simulateMarketSellOrders( -// orders: Order[], -// takerAssetFillAmount: BigNumber, -// signatures: string[], -// ): [FillResults, ExpectedFillOrderCallArgs[]] { -// const fillOrderCalls = []; -// let fillResults = _.cloneDeep(EMPTY_FILL_RESULTS); -// for (const [order, signature] of _.zip(orders, signatures) as [[Order, string]]) { -// const remainingTakerAssetFillAmount = safeSub(takerAssetFillAmount, fillResults.takerAssetFilledAmount); -// if (order.salt !== ALWAYS_FAILING_SALT) { -// fillOrderCalls.push([order, remainingTakerAssetFillAmount, signature]); -// } -// fillResults = addFillResults(fillResults, getExpectedFillResults(order, signature)); -// if (fillResults.takerAssetFilledAmount.gte(takerAssetFillAmount)) { -// break; -// } -// } -// return [fillResults, fillOrderCalls as any]; -// } - -// describe('marketSellOrdersNoThrow', () => { -// defineCommonMarketSellOrdersTests(() => testContract.marketSellOrdersNoThrow, simulateMarketSellOrders); - -// it('works when any fills revert', async () => { -// const COUNT = 4; -// const BAD_ORDERS_COUNT = 2; -// const orders = _.times(COUNT, () => randomOrder()); -// const badOrders = _.sampleSize(orders, BAD_ORDERS_COUNT); -// for (const order of badOrders) { -// order.salt = ALWAYS_FAILING_SALT; -// } -// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); -// const takerAssetFillAmount = _.reduce( -// orders, -// (total, o) => o.takerAssetAmount.plus(total), -// constants.ZERO_AMOUNT, -// ); -// const [expectedResult, expectedCalls] = simulateMarketSellOrders( -// orders, -// takerAssetFillAmount, -// signatures, -// ); -// expect(expectedCalls.length).to.eq(COUNT - BAD_ORDERS_COUNT); -// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( -// testContract.marketSellOrdersNoThrow, -// orders, -// takerAssetFillAmount, -// signatures, -// ); -// expect(actualResult).to.deep.eq(expectedResult); -// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); -// }); - -// it('works when all fills revert', async () => { -// const COUNT = 4; -// const orders = _.times(COUNT, () => randomOrder({ salt: ALWAYS_FAILING_SALT })); -// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); -// const takerAssetFillAmount = _.reduce( -// orders, -// (total, o) => o.takerAssetAmount.plus(total), -// constants.ZERO_AMOUNT, -// ); -// const [expectedResult, expectedCalls] = simulateMarketSellOrders( -// orders, -// takerAssetFillAmount, -// signatures, -// ); -// expect(expectedCalls.length).to.eq(0); -// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( -// testContract.marketSellOrdersNoThrow, -// orders, -// takerAssetFillAmount, -// signatures, -// ); -// expect(actualResult).to.deep.eq(expectedResult); -// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); -// }); -// }); - -// describe('marketSellOrdersFillOrKill', () => { -// defineCommonMarketSellOrdersTests(() => testContract.marketSellOrdersNoThrow, simulateMarketSellOrders); - -// it('reverts when filled < `takerAssetFillAmount`', async () => { -// const COUNT = 4; -// const orders = _.times(COUNT, () => randomOrder()); -// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); -// const takerAssetFillAmount = _.reduce( -// orders, -// (total, o) => o.takerAssetAmount.plus(total), -// constants.ZERO_AMOUNT, -// ).plus(1); -// const expectedError = new ExchangeRevertErrors.IncompleteFillError( -// ExchangeRevertErrors.IncompleteFillErrorCode.IncompleteMarketSellOrders, -// takerAssetFillAmount, -// takerAssetFillAmount.minus(1), -// ); -// const tx = transactionHelper.getResultAndReceiptAsync( -// testContract.marketSellOrdersFillOrKill, -// orders, -// takerAssetFillAmount, -// signatures, -// ); -// return expect(tx).to.revertWith(expectedError); -// }); - -// it('works when fills fail but can still sell `takerAssetFillAmount`', async () => { -// const COUNT = 4; -// const BAD_ORDERS_COUNT = 2; -// const orders = _.times(COUNT, () => randomOrder()); -// const badOrders = _.sampleSize(orders, BAD_ORDERS_COUNT); -// for (const order of badOrders) { -// order.salt = ALWAYS_FAILING_SALT; -// } -// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); -// const takerAssetFillAmount = _.reduce( -// orders, -// (total, o) => o.takerAssetAmount.plus(total), -// constants.ZERO_AMOUNT, -// ).minus(_.reduce(badOrders, (total, o) => o.takerAssetAmount.plus(total), constants.ZERO_AMOUNT)); -// const [expectedResult, expectedCalls] = simulateMarketSellOrders( -// orders, -// takerAssetFillAmount, -// signatures, -// ); -// expect(expectedCalls.length).to.eq(COUNT - BAD_ORDERS_COUNT); -// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( -// testContract.marketSellOrdersFillOrKill, -// orders, -// takerAssetFillAmount, -// signatures, -// ); -// expect(actualResult).to.deep.eq(expectedResult); -// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); -// }); - -// it('reverts when a failed fill results in selling less than `takerAssetFillAmount`', async () => { -// const COUNT = 4; -// const BAD_ORDERS_COUNT = 2; -// const orders = _.times(COUNT, () => randomOrder()); -// const badOrders = _.sampleSize(orders, BAD_ORDERS_COUNT); -// for (const order of badOrders) { -// order.salt = ALWAYS_FAILING_SALT; -// } -// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); -// const badOrdersAmount = _.reduce( -// badOrders, -// (total, o) => o.takerAssetAmount.plus(total), -// constants.ZERO_AMOUNT, -// ); -// const takerAssetFillAmount = _.reduce( -// orders, -// (total, o) => o.takerAssetAmount.plus(total), -// constants.ZERO_AMOUNT, -// ) -// .minus(badOrdersAmount) -// .plus(1); -// const expectedError = new ExchangeRevertErrors.IncompleteFillError( -// ExchangeRevertErrors.IncompleteFillErrorCode.IncompleteMarketSellOrders, -// takerAssetFillAmount, -// takerAssetFillAmount.minus(1), -// ); -// const tx = transactionHelper.getResultAndReceiptAsync( -// testContract.marketSellOrdersFillOrKill, -// orders, -// takerAssetFillAmount, -// signatures, -// ); -// return expect(tx).to.revertWith(expectedError); -// }); -// }); -// }); - -// describe('marketBuy*', () => { -// function defineCommonMarketBuyOrdersTests( -// getContractFn: () => MarketSellBuyContractFunction, -// simulator: MarketSellBuySimulator, -// ): void { -// it('works with one order', async () => { -// const COUNT = 1; -// const orders = _.times(COUNT, () => randomOrder()); -// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); -// const makerAssetFillAmount = _.reduce( -// orders, -// (total, o) => o.makerAssetAmount.plus(total), -// constants.ZERO_AMOUNT, -// ); -// const [expectedResult, expectedCalls] = simulator(orders, makerAssetFillAmount, signatures); -// expect(expectedCalls.length).to.eq(COUNT); -// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( -// getContractFn, -// orders, -// makerAssetFillAmount, -// signatures, -// ); -// expect(actualResult).to.deep.eq(expectedResult); -// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); -// }); - -// it('works with many orders', async () => { -// const COUNT = 8; -// const orders = _.times(COUNT, () => randomOrder()); -// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); -// const makerAssetFillAmount = _.reduce( -// orders, -// (total, o) => o.makerAssetAmount.plus(total), -// constants.ZERO_AMOUNT, -// ); -// const [expectedResult, expectedCalls] = simulator(orders, makerAssetFillAmount, signatures); -// expect(expectedCalls.length).to.eq(COUNT); -// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( -// getContractFn, -// orders, -// makerAssetFillAmount, -// signatures, -// ); -// expect(actualResult).to.deep.eq(expectedResult); -// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); -// }); - -// it('works with duplicate orders', async () => { -// const NUM_UNIQUE_ORDERS = 2; -// const COUNT = 4; -// const uniqueOrders = _.times(NUM_UNIQUE_ORDERS, () => randomOrder()); -// const orders = _.shuffle(_.flatten(_.times(COUNT / NUM_UNIQUE_ORDERS, () => uniqueOrders))); -// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); -// const makerAssetFillAmount = _.reduce( -// orders, -// (total, o) => o.makerAssetAmount.plus(total), -// constants.ZERO_AMOUNT, -// ); -// const [expectedResult, expectedCalls] = simulator(orders, makerAssetFillAmount, signatures); -// expect(expectedCalls.length).to.eq(COUNT); -// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( -// getContractFn(), -// orders, -// makerAssetFillAmount, -// signatures, -// ); -// expect(actualResult).to.deep.eq(expectedResult); -// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); -// }); - -// it('stops when filled == `makerAssetFillAmount`', async () => { -// const COUNT = 4; -// const orders = _.times(COUNT, () => randomOrder()); -// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); -// // Skip the last order in our `makerAssetFillAmount` calculation. -// const makerAssetFillAmount = _.reduce( -// orders.slice(0, COUNT - 1), -// (total, o) => o.makerAssetAmount.plus(total), -// constants.ZERO_AMOUNT, -// ); -// const [expectedResult, expectedCalls] = simulator(orders, makerAssetFillAmount, signatures); -// // It should stop filling after the penultimate order. -// expect(expectedCalls.length).to.eq(COUNT - 1); -// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( -// getContractFn(), -// orders, -// makerAssetFillAmount, -// signatures, -// ); -// expect(actualResult).to.deep.eq(expectedResult); -// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); -// }); - -// it('stops when filled > `makerAssetFillAmount`', async () => { -// const COUNT = 4; -// const orders = _.times(COUNT, () => randomOrder()); -// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); -// const makerAssetFillAmount = _.reduce( -// orders, -// (total, o) => o.makerAssetAmount.plus(total), -// constants.ZERO_AMOUNT, -// ); -// // Because `TestWrapperFunctions` always fills `makerAssetAmount` -// // setting the first order's `makerAssetAmount` to larger than -// // `makerAssetFillAmount` will cause an overfill. -// orders[0].makerAssetAmount = makerAssetFillAmount.plus(1); -// const [expectedResult, expectedCalls] = simulator(orders, makerAssetFillAmount, signatures); -// // It should stop filling after first order. -// expect(expectedCalls.length).to.eq(1); -// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( -// getContractFn(), -// orders, -// makerAssetFillAmount, -// signatures, -// ); -// expect(actualResult).to.deep.eq(expectedResult); -// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); -// }); - -// it('reverts when an overflow occurs when computing `remainingTakerAssetFillAmount`', async () => { -// const orders = [randomOrder({ takerAssetAmount: MAX_UINT256 })]; -// const signatures = _.times(orders.length, i => createOrderSignature(orders[i])); -// const makerAssetFillAmount = new BigNumber(2); -// const expectedError = new SafeMathRevertErrors.Uint256BinOpError( -// SafeMathRevertErrors.BinOpErrorCodes.MultiplicationOverflow, -// orders[0].takerAssetAmount, -// makerAssetFillAmount, -// ); -// const tx = transactionHelper.getResultAndReceiptAsync(getContractFn(), orders, makerAssetFillAmount, signatures); -// return expect(tx).to.revertWith(expectedError); -// }); - -// it("reverts when an order's `makerAssetAmount` is zero", async () => { -// const orders = [randomOrder({ makerAssetAmount: constants.ZERO_AMOUNT })]; -// const signatures = _.times(orders.length, i => createOrderSignature(orders[i])); -// const makerAssetFillAmount = ONE_ETHER; -// const expectedError = new SafeMathRevertErrors.Uint256BinOpError( -// SafeMathRevertErrors.BinOpErrorCodes.DivisionByZero, -// orders[0].takerAssetAmount.times(makerAssetFillAmount), -// orders[0].makerAssetAmount, -// ); -// const tx = transactionHelper.getResultAndReceiptAsync(getContractFn(), orders, makerAssetFillAmount, signatures); -// return expect(tx).to.revertWith(expectedError); -// }); - -// it('reverts when an overflow occurs when summing fill results', async () => { -// const orders = [ -// randomOrder({ -// takerAssetAmount: new BigNumber(1), -// makerAssetAmount: new BigNumber(1), -// }), -// randomOrder({ -// takerAssetAmount: new BigNumber(1), -// makerAssetAmount: MAX_UINT256, -// }), -// ]; -// const signatures = _.times(orders.length, i => createOrderSignature(orders[i])); -// const makerAssetFillAmount = new BigNumber(2); -// const expectedError = new SafeMathRevertErrors.Uint256BinOpError( -// SafeMathRevertErrors.BinOpErrorCodes.AdditionOverflow, -// orders[0].makerAssetAmount, -// orders[1].makerAssetAmount, -// ); -// const tx = transactionHelper.getResultAndReceiptAsync(getContractFn(), orders, makerAssetFillAmount, signatures); -// return expect(tx).to.revertWith(expectedError); -// }); - -// it('returns empty fill results with no orders', async () => { -// const [expectedResult, expectedCalls] = simulator([], constants.ZERO_AMOUNT, []); -// expect(expectedCalls.length).to.eq(0); -// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( -// getContractFn(), -// [], -// constants.ZERO_AMOUNT, -// [], -// ); - -// expect(actualResult).to.deep.eq(expectedResult); -// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); -// }); -// } - -// function simulateMarketBuyOrdersNoThrow( -// orders: Order[], -// makerAssetFillAmount: BigNumber, -// signatures: string[], -// ): [FillResults, ExpectedFillOrderCallArgs[]] { -// const fillOrderCalls = []; -// let fillResults = _.cloneDeep(EMPTY_FILL_RESULTS); -// for (const [order, signature] of _.zip(orders, signatures) as [[Order, string]]) { -// const remainingMakerAssetFillAmount = safeSub(makerAssetFillAmount, fillResults.makerAssetFilledAmount); -// const remainingTakerAssetFillAmount = getPartialAmountFloor( -// order.takerAssetAmount, -// order.makerAssetAmount, -// remainingMakerAssetFillAmount, -// ); -// if (order.salt !== ALWAYS_FAILING_SALT) { -// fillOrderCalls.push([order, remainingTakerAssetFillAmount, signature]); -// } -// fillResults = addFillResults(fillResults, getExpectedFillResults(order, signature)); -// if (fillResults.makerAssetFilledAmount.gte(makerAssetFillAmount)) { -// break; -// } -// } -// return [fillResults, fillOrderCalls as any]; -// } - -// describe('marketBuyOrdersNoThrow', () => { -// defineCommonMarketBuyOrdersTests(() => testContract.marketBuyOrdersNoThrow, simulateMarketBuyOrdersNoThrow); - -// it('works when any fills revert', async () => { -// const COUNT = 4; -// const BAD_ORDERS_COUNT = 2; -// const orders = _.times(COUNT, () => randomOrder()); -// const badOrders = _.sampleSize(orders, BAD_ORDERS_COUNT); -// for (const order of badOrders) { -// order.salt = ALWAYS_FAILING_SALT; -// } -// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); -// const makerAssetFillAmount = _.reduce( -// orders, -// (total, o) => o.makerAssetAmount.plus(total), -// constants.ZERO_AMOUNT, -// ); -// const [expectedResult, expectedCalls] = simulateMarketBuyOrdersNoThrow( -// orders, -// makerAssetFillAmount, -// signatures, -// ); -// expect(expectedCalls.length).to.eq(COUNT - BAD_ORDERS_COUNT); -// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( -// testContract.marketBuyOrdersNoThrow, -// orders, -// makerAssetFillAmount, -// signatures, -// ); -// expect(actualResult).to.deep.eq(expectedResult); -// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); -// }); - -// it('works when all fills revert', async () => { -// const COUNT = 4; -// const orders = _.times(COUNT, () => randomOrder({ salt: ALWAYS_FAILING_SALT })); -// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); -// const makerAssetFillAmount = _.reduce( -// orders, -// (total, o) => o.makerAssetAmount.plus(total), -// constants.ZERO_AMOUNT, -// ); -// const [expectedResult, expectedCalls] = simulateMarketBuyOrdersNoThrow( -// orders, -// makerAssetFillAmount, -// signatures, -// ); -// expect(expectedCalls.length).to.eq(0); -// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( -// testContract.marketBuyOrdersNoThrow, -// orders, -// makerAssetFillAmount, -// signatures, -// ); -// expect(actualResult).to.deep.eq(expectedResult); -// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); -// }); -// }); - -// describe('marketBuyOrdersFillOrKill', () => { -// defineCommonMarketBuyOrdersTests( -// () => testContract.marketBuyOrdersFillOrKill, -// simulateMarketBuyOrdersNoThrow, -// ); - -// it('reverts when filled < `makerAssetFillAmount`', async () => { -// const COUNT = 4; -// const orders = _.times(COUNT, () => randomOrder()); -// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); -// const makerAssetFillAmount = _.reduce( -// orders, -// (total, o) => o.makerAssetAmount.plus(total), -// constants.ZERO_AMOUNT, -// ).plus(1); -// const expectedError = new ExchangeRevertErrors.IncompleteFillError( -// ExchangeRevertErrors.IncompleteFillErrorCode.IncompleteMarketBuyOrders, -// makerAssetFillAmount, -// makerAssetFillAmount.minus(1), -// ); -// const tx = transactionHelper.getResultAndReceiptAsync( -// testContract.marketBuyOrdersFillOrKill, -// orders, -// makerAssetFillAmount, -// signatures, -// ); -// return expect(tx).to.revertWith(expectedError); -// }); - -// it('works when fills fail but can still buy `makerAssetFillAmount`', async () => { -// const COUNT = 4; -// const BAD_ORDERS_COUNT = 2; -// const orders = _.times(COUNT, () => randomOrder()); -// const badOrders = _.sampleSize(orders, BAD_ORDERS_COUNT); -// for (const order of badOrders) { -// order.salt = ALWAYS_FAILING_SALT; -// } -// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); -// const makerAssetFillAmount = _.reduce( -// orders, -// (total, o) => o.makerAssetAmount.plus(total), -// constants.ZERO_AMOUNT, -// ).minus(_.reduce(badOrders, (total, o) => o.makerAssetAmount.plus(total), constants.ZERO_AMOUNT)); -// const [expectedResult, expectedCalls] = simulateMarketBuyOrdersNoThrow( -// orders, -// makerAssetFillAmount, -// signatures, -// ); -// expect(expectedCalls.length).to.eq(COUNT - BAD_ORDERS_COUNT); -// const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( -// testContract.marketBuyOrdersFillOrKill, -// orders, -// makerAssetFillAmount, -// signatures, -// ); -// expect(actualResult).to.deep.eq(expectedResult); -// assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); -// }); - -// it('reverts when a failed fill results in buying less than `makerAssetFillAmount`', async () => { -// const COUNT = 4; -// const BAD_ORDERS_COUNT = 2; -// const orders = _.times(COUNT, () => randomOrder()); -// const badOrders = _.sampleSize(orders, BAD_ORDERS_COUNT); -// for (const order of badOrders) { -// order.salt = ALWAYS_FAILING_SALT; -// } -// const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); -// const badOrdersAmount = _.reduce( -// badOrders, -// (total, o) => o.makerAssetAmount.plus(total), -// constants.ZERO_AMOUNT, -// ); -// const makerAssetFillAmount = _.reduce( -// orders, -// (total, o) => o.makerAssetAmount.plus(total), -// constants.ZERO_AMOUNT, -// ) -// .minus(badOrdersAmount) -// .plus(1); -// const expectedError = new ExchangeRevertErrors.IncompleteFillError( -// ExchangeRevertErrors.IncompleteFillErrorCode.IncompleteMarketBuyOrders, -// makerAssetFillAmount, -// makerAssetFillAmount.minus(1), -// ); -// const tx = transactionHelper.getResultAndReceiptAsync( -// testContract.marketBuyOrdersFillOrKill, -// orders, -// makerAssetFillAmount, -// signatures, -// ); -// return expect(tx).to.revertWith(expectedError); -// }); -// }); -// }); - -// describe('batchCancelOrders', () => { -// // Asserts that `_cancelOrder()` was called in the same order and with the same -// // arguments as given by examining receipt logs. -// function assertCancelOrderCallsFromLogs(logs: LogEntry[], calls: Order[]): void { -// expect(logs.length).to.eq(calls.length); -// for (const i of _.times(calls.length)) { -// const log = (logs[i] as any) as LogWithDecodedArgs; -// const expectedOrder = calls[i]; -// expect(log.event).to.eq('CancelOrderCalled'); -// assertSameOrderFromEvent(log.args.order as any, expectedOrder); -// } -// } - -// it('works with no orders', async () => { -// const [, receipt] = await transactionHelper.getResultAndReceiptAsync(testContract.batchCancelOrders, []); -// assertCancelOrderCallsFromLogs(receipt.logs, []); -// }); - -// it('works with many orders', async () => { -// const COUNT = 8; -// const orders = _.times(COUNT, () => randomOrder({ makerAddress: senderAddress })); -// const [, receipt] = await transactionHelper.getResultAndReceiptAsync(testContract.batchCancelOrders, orders); -// assertCancelOrderCallsFromLogs(receipt.logs, orders); -// }); - -// it('works with duplicate orders', async () => { -// const UNIQUE_ORDERS = 2; -// const COUNT = 6; -// const uniqueOrders = _.times(UNIQUE_ORDERS, () => randomOrder({ makerAddress: senderAddress })); -// const orders = _.shuffle(_.flatten(_.times(COUNT / UNIQUE_ORDERS, () => uniqueOrders))); -// const [, receipt] = await transactionHelper.getResultAndReceiptAsync(testContract.batchCancelOrders, orders); -// assertCancelOrderCallsFromLogs(receipt.logs, orders); -// }); - -// it('reverts if one `_cancelOrder()` reverts', async () => { -// const COUNT = 8; -// const FAILING_ORDER_INDEX = 4; -// const orders = _.times(COUNT, () => randomOrder({ makerAddress: senderAddress })); -// const failingOrder = orders[FAILING_ORDER_INDEX]; -// failingOrder.salt = ALWAYS_FAILING_SALT; -// const expectedError = ALWAYS_FAILING_SALT_REVERT_ERROR; -// const tx = transactionHelper.getResultAndReceiptAsync(testContract.batchCancelOrders, orders); -// return expect(tx).to.revertWith(expectedError); -// }); -// }); -// }); -// // tslint:disable-next-line: max-file-line-count +import { ReferenceFunctions as LibReferenceFunctions } from '@0x/contracts-exchange-libs'; +import { + blockchainTests, + constants, + describe, + expect, + hexRandom, + MutatorContractFunction, + transactionHelper, +} from '@0x/contracts-test-utils'; +import { ReferenceFunctions as UtilReferenceFunctions } from '@0x/contracts-utils'; +import { ExchangeRevertErrors, orderHashUtils } from '@0x/order-utils'; +import { FillResults, Order } from '@0x/types'; +import { AnyRevertError, BigNumber, SafeMathRevertErrors, StringRevertError } from '@0x/utils'; +import { LogEntry, LogWithDecodedArgs } from 'ethereum-types'; +import * as ethjs from 'ethereumjs-util'; +import * as _ from 'lodash'; + +import { + artifacts, + TestWrapperFunctionsCancelOrderCalledEventArgs as CancelOrderCalledEventArgs, + TestWrapperFunctionsContract, + TestWrapperFunctionsFillOrderCalledEventArgs as FillOrderCalledEventArgs, +} from '../src'; + +blockchainTests('Exchange wrapper functions unit tests.', env => { + const CHAIN_ID = 0x74657374; + const { ONE_ETHER, MAX_UINT256 } = constants; + const { addFillResults, getPartialAmountFloor } = LibReferenceFunctions; + const { safeSub } = UtilReferenceFunctions; + const protocolFeeMultiplier = new BigNumber(150000); + const randomAddress = () => hexRandom(constants.ADDRESS_LENGTH); + const randomAssetData = () => hexRandom(34); + const randomAmount = (maxAmount: BigNumber = ONE_ETHER) => maxAmount.times(_.random(0, 100, true).toFixed(12)); + const randomTimestamp = () => new BigNumber(Math.floor(_.now() / 1000) + _.random(0, 34560)); + const randomSalt = () => new BigNumber(hexRandom(constants.WORD_LENGTH).substr(2), 16); + const ALWAYS_FAILING_SALT = constants.MAX_UINT256; + const ALWAYS_FAILING_SALT_REVERT_ERROR = new StringRevertError('ALWAYS_FAILING_SALT'); + const EMPTY_FILL_RESULTS = { + makerAssetFilledAmount: constants.ZERO_AMOUNT, + takerAssetFilledAmount: constants.ZERO_AMOUNT, + makerFeePaid: constants.ZERO_AMOUNT, + takerFeePaid: constants.ZERO_AMOUNT, + protocolFeePaid: constants.ZERO_AMOUNT, + }; + let testContract: TestWrapperFunctionsContract; + let owner: string; + let senderAddress: string; + + before(async () => { + [owner, senderAddress] = await env.getAccountAddressesAsync(); + testContract = await TestWrapperFunctionsContract.deployFrom0xArtifactAsync( + artifacts.TestWrapperFunctions, + env.provider, + { + ...env.txDefaults, + from: owner, + }, + {}, + ); + + // Set the protocol fee multiplier. + await testContract.setProtocolFeeMultiplier(protocolFeeMultiplier).awaitTransactionSuccessAsync({ + from: owner, + }); + }); + + function randomOrder(fields?: Partial): Order { + return { + makerAddress: randomAddress(), + takerAddress: randomAddress(), + feeRecipientAddress: randomAddress(), + senderAddress: randomAddress(), + takerAssetAmount: randomAmount(), + makerAssetAmount: randomAmount(), + makerFee: randomAmount(), + takerFee: randomAmount(), + expirationTimeSeconds: randomTimestamp(), + salt: randomSalt(), + makerAssetData: randomAssetData(), + takerAssetData: randomAssetData(), + makerFeeAssetData: randomAssetData(), + takerFeeAssetData: randomAssetData(), + exchangeAddress: constants.NULL_ADDRESS, + chainId: CHAIN_ID, + ...(fields || {}), + }; + } + + // Computes the expected (fake) fill results from `TestWrapperFunctions` `_fillOrder` implementation. + function getExpectedFillResults(order: Order, signature: string): FillResults { + if (order.salt === ALWAYS_FAILING_SALT) { + return EMPTY_FILL_RESULTS; + } + return { + makerAssetFilledAmount: order.makerAssetAmount, + takerAssetFilledAmount: order.takerAssetAmount, + makerFeePaid: order.makerFee, + takerFeePaid: order.takerFee, + protocolFeePaid: protocolFeeMultiplier, + }; + } + + // Creates a deterministic order signature, even though no signature validation + // actually occurs in the test contract. + function createOrderSignature(order: Order): string { + return ethjs.bufferToHex(ethjs.sha3(ethjs.toBuffer(orderHashUtils.getOrderHashHex(order)))); + } + + // Asserts that `_fillOrder()` was called in the same order and with the same + // arguments as given by examining receipt logs. + function assertFillOrderCallsFromLogs(logs: LogEntry[], calls: Array<[Order, BigNumber, string]>): void { + expect(logs.length).to.eq(calls.length); + for (const i of _.times(calls.length)) { + const log = (logs[i] as any) as LogWithDecodedArgs; + const [expectedOrder, expectedTakerAssetFillAmount, expectedSignature] = calls[i]; + expect(log.event).to.eq('FillOrderCalled'); + assertSameOrderFromEvent(log.args.order as any, expectedOrder); + expect(log.args.takerAssetFillAmount).to.bignumber.eq(expectedTakerAssetFillAmount); + expect(log.args.signature).to.eq(expectedSignature); + } + } + + function assertSameOrderFromEvent(actual: any[], expected: Order): void { + expect(actual.length === 14); + expect(actual[0].toLowerCase()).to.be.eq(expected.makerAddress); + expect(actual[1].toLowerCase()).to.be.eq(expected.takerAddress); + expect(actual[2].toLowerCase()).to.be.eq(expected.feeRecipientAddress); + expect(actual[3].toLowerCase()).to.be.eq(expected.senderAddress); + expect(actual[4]).to.be.bignumber.eq(expected.makerAssetAmount); + expect(actual[5]).to.be.bignumber.eq(expected.takerAssetAmount); + expect(actual[6]).to.be.bignumber.eq(expected.makerFee); + expect(actual[7]).to.be.bignumber.eq(expected.takerFee); + expect(actual[8]).to.be.bignumber.eq(expected.expirationTimeSeconds); + expect(actual[9]).to.be.bignumber.eq(expected.salt); + expect(actual[10]).to.be.eq(expected.makerAssetData); + expect(actual[11]).to.be.eq(expected.takerAssetData); + expect(actual[12]).to.be.eq(expected.makerFeeAssetData); + expect(actual[13]).to.be.eq(expected.takerFeeAssetData); + } + + describe('fillOrKillOrder', () => { + it('works if the order is filled by exactly `takerAssetFillAmount`', async () => { + const fillAmount = randomAmount(); + const order = randomOrder({ + // `_fillOrder()` is overridden to always return `order.takerAssetAmount` as + // the `takerAssetFilledAmount`. + takerAssetAmount: fillAmount, + }); + const signature = createOrderSignature(order); + const expectedResult = getExpectedFillResults(order, signature); + const expectedCalls = [[order, fillAmount, signature]]; + const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( + testContract.fillOrKillOrder, + order, + fillAmount, + signature, + ); + expect(actualResult).to.deep.eq(expectedResult); + assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); + }); + + it('reverts if the order is filled by less than `takerAssetFillAmount`', async () => { + const fillAmount = randomAmount(); + const order = randomOrder({ + // `_fillOrder()` is overridden to always return `order.takerAssetAmount` as + // the `takerAssetFilledAmount`. + takerAssetAmount: fillAmount.minus(1), + }); + const signature = createOrderSignature(order); + const expectedError = new ExchangeRevertErrors.IncompleteFillError( + ExchangeRevertErrors.IncompleteFillErrorCode.IncompleteFillOrder, + fillAmount, + fillAmount.minus(1), + ); + const tx = testContract.fillOrKillOrder(order, fillAmount, signature).awaitTransactionSuccessAsync(); + return expect(tx).to.revertWith(expectedError); + }); + + it('reverts if the order is filled by greater than `takerAssetFillAmount`', async () => { + const fillAmount = randomAmount(); + const order = randomOrder({ + // `_fillOrder()` is overridden to always return `order.takerAssetAmount` as + // the `takerAssetFilledAmount`. + takerAssetAmount: fillAmount.plus(1), + }); + const signature = createOrderSignature(order); + const expectedError = new ExchangeRevertErrors.IncompleteFillError( + ExchangeRevertErrors.IncompleteFillErrorCode.IncompleteFillOrder, + fillAmount, + fillAmount.plus(1), + ); + const tx = testContract.fillOrKillOrder(order, fillAmount, signature).awaitTransactionSuccessAsync(); + return expect(tx).to.revertWith(expectedError); + }); + + it('reverts if `_fillOrder()` reverts', async () => { + const fillAmount = randomAmount(); + const order = randomOrder({ + salt: ALWAYS_FAILING_SALT, + }); + const signature = createOrderSignature(order); + const expectedError = ALWAYS_FAILING_SALT_REVERT_ERROR; + const tx = testContract.fillOrKillOrder(order, fillAmount, signature).awaitTransactionSuccessAsync(); + return expect(tx).to.revertWith(expectedError); + }); + }); + + describe('fillOrderNoThrow', () => { + it('calls `fillOrder()` and returns its result', async () => { + const fillAmount = randomAmount(); + const order = randomOrder(); + const signature = createOrderSignature(order); + const expectedResult = getExpectedFillResults(order, signature); + const expectedCalls = [[order, fillAmount, signature]]; + const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( + testContract.fillOrderNoThrow, + order, + fillAmount, + signature, + ); + expect(actualResult).to.deep.eq(expectedResult); + assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); + }); + + it('does not revert if `fillOrder()` reverts', async () => { + const fillAmount = randomAmount(); + const order = randomOrder({ + salt: ALWAYS_FAILING_SALT, + }); + const signature = createOrderSignature(order); + const expectedResult = EMPTY_FILL_RESULTS; + const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( + testContract.fillOrderNoThrow, + order, + fillAmount, + signature, + ); + expect(actualResult).to.deep.eq(expectedResult); + assertFillOrderCallsFromLogs(receipt.logs, []); + }); + }); + + describe('batchFillOrders', () => { + it('works with no fills', async () => { + const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( + testContract.batchFillOrders, + [], + [], + [], + ); + expect(actualResult).to.deep.eq([]); + assertFillOrderCallsFromLogs(receipt.logs, []); + }); + + it('works with one fill', async () => { + const COUNT = 1; + const orders = _.times(COUNT, () => randomOrder()); + const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); + const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); + const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); + const expectedCalls = _.zip(orders, fillAmounts, signatures); + const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( + testContract.batchFillOrders, + orders, + fillAmounts, + signatures, + ); + expect(actualResult).to.deep.eq(expectedResult); + assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); + }); + + it('works with many fills', async () => { + const COUNT = 8; + const orders = _.times(COUNT, () => randomOrder()); + const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); + const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); + const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); + const expectedCalls = _.zip(orders, fillAmounts, signatures); + const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( + testContract.batchFillOrders, + orders, + fillAmounts, + signatures, + ); + expect(actualResult).to.deep.eq(expectedResult); + assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); + }); + + it('works with duplicate orders', async () => { + const NUM_UNIQUE_ORDERS = 2; + const COUNT = 4; + const uniqueOrders = _.times(NUM_UNIQUE_ORDERS, () => randomOrder()); + const orders = _.shuffle(_.flatten(_.times(COUNT / NUM_UNIQUE_ORDERS, () => uniqueOrders))); + const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount.dividedToIntegerBy(COUNT)); + const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); + const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); + const expectedCalls = _.zip(orders, fillAmounts, signatures); + const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( + testContract.batchFillOrders, + orders, + fillAmounts, + signatures, + ); + expect(actualResult).to.deep.eq(expectedResult); + assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); + }); + + it('reverts if there are more orders than fill amounts', async () => { + const COUNT = 8; + const orders = _.times(COUNT, () => randomOrder()); + const fillAmounts = _.times(COUNT - 1, i => orders[i].takerAssetAmount); + const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); + const expectedError = new AnyRevertError(); // Just a generic revert. + const tx = transactionHelper.getResultAndReceiptAsync( + testContract.batchFillOrders, + orders, + fillAmounts, + signatures, + ); + return expect(tx).to.revertWith(expectedError); + }); + + it('reverts if there are more orders than signatures', async () => { + const COUNT = 8; + const orders = _.times(COUNT, () => randomOrder()); + const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); + const signatures = _.times(COUNT - 1, i => createOrderSignature(orders[i])); + const expectedError = new AnyRevertError(); // Just a generic revert. + const tx = transactionHelper.getResultAndReceiptAsync( + testContract.batchFillOrders, + orders, + fillAmounts, + signatures, + ); + return expect(tx).to.revertWith(expectedError); + }); + }); + + describe('batchFillOrKillOrders', () => { + it('works with no fills', async () => { + const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( + testContract.batchFillOrKillOrders, + [], + [], + [], + ); + expect(actualResult).to.deep.eq([]); + assertFillOrderCallsFromLogs(receipt.logs, []); + }); + + it('works with one fill', async () => { + const COUNT = 1; + const orders = _.times(COUNT, () => randomOrder()); + const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); + const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); + const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); + const expectedCalls = _.zip(orders, fillAmounts, signatures); + const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( + testContract.batchFillOrKillOrders, + orders, + fillAmounts, + signatures, + ); + expect(actualResult).to.deep.eq(expectedResult); + assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); + }); + + it('works with many fills', async () => { + const COUNT = 8; + const orders = _.times(COUNT, () => randomOrder()); + const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); + const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); + const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); + const expectedCalls = _.zip(orders, fillAmounts, signatures); + const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( + testContract.batchFillOrKillOrders, + orders, + fillAmounts, + signatures, + ); + expect(actualResult).to.deep.eq(expectedResult); + assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); + }); + + it('works with duplicate orders', async () => { + const NUM_UNIQUE_ORDERS = 2; + const COUNT = 4; + const uniqueOrders = _.times(NUM_UNIQUE_ORDERS, () => randomOrder()); + const orders = _.shuffle(_.flatten(_.times(COUNT / NUM_UNIQUE_ORDERS, () => uniqueOrders))); + const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); + const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); + const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); + const expectedCalls = _.zip(orders, fillAmounts, signatures); + const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( + testContract.batchFillOrKillOrders, + orders, + fillAmounts, + signatures, + ); + expect(actualResult).to.deep.eq(expectedResult); + assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); + }); + + it('reverts if any fill sells less than its takerAssetFillAmount', async () => { + const COUNT = 8; + const FAILING_ORDER_INDEX = 6; + const orders = _.times(COUNT, () => randomOrder()); + const failingOrder = orders[FAILING_ORDER_INDEX]; + const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); + const failingAmount = fillAmounts[FAILING_ORDER_INDEX]; + const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); + // `_fillOrder()` is overridden to always return `order.takerAssetAmount` as + // the `takerAssetFilledAmount`. + failingOrder.takerAssetAmount = failingOrder.takerAssetAmount.minus(1); + const expectedError = new ExchangeRevertErrors.IncompleteFillError( + ExchangeRevertErrors.IncompleteFillErrorCode.IncompleteFillOrder, + failingAmount, + failingAmount.minus(1), + ); + const tx = transactionHelper.getResultAndReceiptAsync( + testContract.batchFillOrKillOrders, + orders, + fillAmounts, + signatures, + ); + return expect(tx).to.revertWith(expectedError); + }); + + it('reverts if any fill sells more than its takerAssetFillAmount', async () => { + const COUNT = 8; + const FAILING_ORDER_INDEX = 6; + const orders = _.times(COUNT, () => randomOrder()); + const failingOrder = orders[FAILING_ORDER_INDEX]; + const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); + const failingAmount = fillAmounts[FAILING_ORDER_INDEX]; + const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); + // `_fillOrder()` is overridden to always return `order.takerAssetAmount` as + // the `takerAssetFilledAmount`. + failingOrder.takerAssetAmount = failingOrder.takerAssetAmount.plus(1); + const expectedError = new ExchangeRevertErrors.IncompleteFillError( + ExchangeRevertErrors.IncompleteFillErrorCode.IncompleteFillOrder, + failingAmount, + failingAmount.plus(1), + ); + const tx = transactionHelper.getResultAndReceiptAsync( + testContract.batchFillOrKillOrders, + orders, + fillAmounts, + signatures, + ); + return expect(tx).to.revertWith(expectedError); + }); + + it('reverts if there are more orders than fill amounts', async () => { + const COUNT = 8; + const orders = _.times(COUNT, () => randomOrder()); + const fillAmounts = _.times(COUNT - 1, i => orders[i].takerAssetAmount); + const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); + const expectedError = new AnyRevertError(); // Just a generic revert. + const tx = transactionHelper.getResultAndReceiptAsync( + testContract.batchFillOrKillOrders, + orders, + fillAmounts, + signatures, + ); + return expect(tx).to.revertWith(expectedError); + }); + + it('reverts if there are more orders than signatures', async () => { + const COUNT = 8; + const orders = _.times(COUNT, () => randomOrder()); + const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); + const signatures = _.times(COUNT - 1, i => createOrderSignature(orders[i])); + const expectedError = new AnyRevertError(); // Just a generic revert. + const tx = transactionHelper.getResultAndReceiptAsync( + testContract.batchFillOrKillOrders, + orders, + fillAmounts, + signatures, + ); + return expect(tx).to.revertWith(expectedError); + }); + }); + + describe('batchFillOrdersNoThrow', () => { + it('works with no fills', async () => { + const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( + testContract.batchFillOrdersNoThrow, + [], + [], + [], + ); + expect(actualResult).to.deep.eq([]); + assertFillOrderCallsFromLogs(receipt.logs, []); + }); + + it('works with one fill', async () => { + const COUNT = 1; + const orders = _.times(COUNT, () => randomOrder()); + const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); + const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); + const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); + const expectedCalls = _.zip(orders, fillAmounts, signatures); + const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( + testContract.batchFillOrdersNoThrow, + orders, + fillAmounts, + signatures, + ); + expect(actualResult).to.deep.eq(expectedResult); + assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); + }); + + it('works with many fills', async () => { + const COUNT = 8; + const orders = _.times(COUNT, () => randomOrder()); + const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); + const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); + const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); + const expectedCalls = _.zip(orders, fillAmounts, signatures); + const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( + testContract.batchFillOrdersNoThrow, + orders, + fillAmounts, + signatures, + ); + expect(actualResult).to.deep.eq(expectedResult); + assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); + }); + + it('works with duplicate orders', async () => { + const NUM_UNIQUE_ORDERS = 2; + const COUNT = 4; + const uniqueOrders = _.times(NUM_UNIQUE_ORDERS, () => randomOrder()); + const orders = _.shuffle(_.flatten(_.times(COUNT / NUM_UNIQUE_ORDERS, () => uniqueOrders))); + const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount.dividedToIntegerBy(COUNT)); + const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); + const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); + const expectedCalls = _.zip(orders, fillAmounts, signatures); + const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( + testContract.batchFillOrdersNoThrow, + orders, + fillAmounts, + signatures, + ); + expect(actualResult).to.deep.eq(expectedResult); + assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); + }); + + it('works if a fill fails', async () => { + const COUNT = 8; + const FAILING_ORDER_INDEX = 6; + const orders = _.times(COUNT, () => randomOrder()); + const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); + const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); + const failingOrder = orders[FAILING_ORDER_INDEX]; + failingOrder.salt = ALWAYS_FAILING_SALT; + const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); + const expectedCalls = _.zip(orders, fillAmounts, signatures); + expectedCalls.splice(FAILING_ORDER_INDEX, 1); + const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( + testContract.batchFillOrdersNoThrow, + orders, + fillAmounts, + signatures, + ); + expect(actualResult).to.deep.eq(expectedResult); + assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); + }); + + it('reverts if there are more orders than fill amounts', async () => { + const COUNT = 8; + const orders = _.times(COUNT, () => randomOrder()); + const fillAmounts = _.times(COUNT - 1, i => orders[i].takerAssetAmount); + const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); + const expectedError = new AnyRevertError(); // Just a generic revert. + const tx = transactionHelper.getResultAndReceiptAsync( + testContract.batchFillOrdersNoThrow, + orders, + fillAmounts, + signatures, + ); + return expect(tx).to.revertWith(expectedError); + }); + + it('reverts if there are more orders than signatures', async () => { + const COUNT = 8; + const orders = _.times(COUNT, () => randomOrder()); + const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); + const signatures = _.times(COUNT - 1, i => createOrderSignature(orders[i])); + const expectedError = new AnyRevertError(); // Just a generic revert. + const tx = transactionHelper.getResultAndReceiptAsync( + testContract.batchFillOrdersNoThrow, + orders, + fillAmounts, + signatures, + ); + return expect(tx).to.revertWith(expectedError); + }); + }); + + type ExpectedFillOrderCallArgs = [Order, BigNumber, string]; + type MarketSellBuyArgs = [Order[], BigNumber, string[], ...any[]]; + type MarketSellBuyContractFunction = () => MutatorContractFunction; + type MarketSellBuySimulator = (...args: MarketSellBuyArgs) => [FillResults, ExpectedFillOrderCallArgs[]]; + + describe('marketSell*', () => { + function defineCommonMarketSellOrdersTests( + getContractFn: MarketSellBuyContractFunction, + simulator: MarketSellBuySimulator, + ): void { + it('works with one order', async () => { + const COUNT = 1; + const orders = _.times(COUNT, () => randomOrder()); + const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); + const takerAssetFillAmount = _.reduce( + orders, + (total, o) => o.takerAssetAmount.plus(total), + constants.ZERO_AMOUNT, + ); + const [expectedResult, expectedCalls] = simulator(orders, takerAssetFillAmount, signatures); + expect(expectedCalls.length).to.eq(COUNT); + const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( + getContractFn(), + orders, + takerAssetFillAmount, + signatures, + ); + expect(actualResult).to.deep.eq(expectedResult); + assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); + }); + + it('works with many orders', async () => { + const COUNT = 8; + const orders = _.times(COUNT, () => randomOrder()); + const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); + const takerAssetFillAmount = _.reduce( + orders, + (total, o) => o.takerAssetAmount.plus(total), + constants.ZERO_AMOUNT, + ); + const [expectedResult, expectedCalls] = simulator(orders, takerAssetFillAmount, signatures); + expect(expectedCalls.length).to.eq(COUNT); + const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( + getContractFn(), + orders, + takerAssetFillAmount, + signatures, + ); + expect(actualResult).to.deep.eq(expectedResult); + assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); + }); + + it('works with duplicate orders', async () => { + const NUM_UNIQUE_ORDERS = 2; + const COUNT = 4; + const uniqueOrders = _.times(NUM_UNIQUE_ORDERS, () => randomOrder()); + const orders = _.shuffle(_.flatten(_.times(COUNT / NUM_UNIQUE_ORDERS, () => uniqueOrders))); + const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); + const takerAssetFillAmount = _.reduce( + orders, + (total, o) => o.takerAssetAmount.plus(total), + constants.ZERO_AMOUNT, + ); + const [expectedResult, expectedCalls] = simulator(orders, takerAssetFillAmount, signatures); + expect(expectedCalls.length).to.eq(COUNT); + const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( + getContractFn(), + orders, + takerAssetFillAmount, + signatures, + ); + expect(actualResult).to.deep.eq(expectedResult); + assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); + }); + + it('stops when filled == `takerAssetFillAmount`', async () => { + const COUNT = 4; + const orders = _.times(COUNT, () => randomOrder()); + const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); + // Skip the last order in our `takerAssetFillAmount` calculation. + const takerAssetFillAmount = _.reduce( + orders.slice(0, COUNT - 1), + (total, o) => o.takerAssetAmount.plus(total), + constants.ZERO_AMOUNT, + ); + const [expectedResult, expectedCalls] = simulator(orders, takerAssetFillAmount, signatures); + // It should stop filling after the penultimate order. + expect(expectedCalls.length).to.eq(COUNT - 1); + const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( + getContractFn(), + orders, + takerAssetFillAmount, + signatures, + ); + expect(actualResult).to.deep.eq(expectedResult); + assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); + }); + + it('stops when filled > `takerAssetFillAmount`', async () => { + const COUNT = 4; + const orders = _.times(COUNT, () => randomOrder()); + const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); + const takerAssetFillAmount = _.reduce( + orders, + (total, o) => o.takerAssetAmount.plus(total), + constants.ZERO_AMOUNT, + ); + // Because `TestWrapperFunctions` always fills `takerAssetAmount` + // setting the first order's `takerAssetAmount` to larger than + // `takerAssetFillAmount` will cause an overfill. + orders[0].takerAssetAmount = takerAssetFillAmount.plus(1); + const [expectedResult, expectedCalls] = simulator(orders, takerAssetFillAmount, signatures); + // It should stop filling after first order. + expect(expectedCalls.length).to.eq(1); + const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( + getContractFn(), + orders, + takerAssetFillAmount, + signatures, + ); + expect(actualResult).to.deep.eq(expectedResult); + assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); + }); + + it('reverts when an overflow occurs when summing fill results', async () => { + const COUNT = 2; + const orders = _.times(COUNT, () => randomOrder()); + const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); + orders[1].takerAssetAmount = MAX_UINT256; + const takerAssetFillAmount = MAX_UINT256; + const expectedError = new SafeMathRevertErrors.Uint256BinOpError( + SafeMathRevertErrors.BinOpErrorCodes.AdditionOverflow, + orders[0].takerAssetAmount, + orders[1].takerAssetAmount, + ); + const tx = transactionHelper.getResultAndReceiptAsync( + getContractFn(), + orders, + takerAssetFillAmount, + signatures, + ); + return expect(tx).to.revertWith(expectedError); + }); + + it('returns empty fill results with no orders', async () => { + const [expectedResult, expectedCalls] = simulator([], constants.ZERO_AMOUNT, []); + expect(expectedCalls.length).to.eq(0); + const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( + getContractFn(), + [], + constants.ZERO_AMOUNT, + [], + ); + + expect(actualResult).to.deep.eq(expectedResult); + assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); + }); + } + + function simulateMarketSellOrders( + orders: Order[], + takerAssetFillAmount: BigNumber, + signatures: string[], + ): [FillResults, ExpectedFillOrderCallArgs[]] { + const fillOrderCalls = []; + let fillResults = _.cloneDeep(EMPTY_FILL_RESULTS); + for (const [order, signature] of _.zip(orders, signatures) as [[Order, string]]) { + const remainingTakerAssetFillAmount = safeSub(takerAssetFillAmount, fillResults.takerAssetFilledAmount); + if (order.salt !== ALWAYS_FAILING_SALT) { + fillOrderCalls.push([order, remainingTakerAssetFillAmount, signature]); + } + fillResults = addFillResults(fillResults, getExpectedFillResults(order, signature)); + if (fillResults.takerAssetFilledAmount.gte(takerAssetFillAmount)) { + break; + } + } + return [fillResults, fillOrderCalls as any]; + } + + describe('marketSellOrdersNoThrow', () => { + defineCommonMarketSellOrdersTests(() => testContract.marketSellOrdersNoThrow, simulateMarketSellOrders); + + it('works when any fills revert', async () => { + const COUNT = 4; + const BAD_ORDERS_COUNT = 2; + const orders = _.times(COUNT, () => randomOrder()); + const badOrders = _.sampleSize(orders, BAD_ORDERS_COUNT); + for (const order of badOrders) { + order.salt = ALWAYS_FAILING_SALT; + } + const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); + const takerAssetFillAmount = _.reduce( + orders, + (total, o) => o.takerAssetAmount.plus(total), + constants.ZERO_AMOUNT, + ); + const [expectedResult, expectedCalls] = simulateMarketSellOrders( + orders, + takerAssetFillAmount, + signatures, + ); + expect(expectedCalls.length).to.eq(COUNT - BAD_ORDERS_COUNT); + const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( + testContract.marketSellOrdersNoThrow, + orders, + takerAssetFillAmount, + signatures, + ); + expect(actualResult).to.deep.eq(expectedResult); + assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); + }); + + it('works when all fills revert', async () => { + const COUNT = 4; + const orders = _.times(COUNT, () => randomOrder({ salt: ALWAYS_FAILING_SALT })); + const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); + const takerAssetFillAmount = _.reduce( + orders, + (total, o) => o.takerAssetAmount.plus(total), + constants.ZERO_AMOUNT, + ); + const [expectedResult, expectedCalls] = simulateMarketSellOrders( + orders, + takerAssetFillAmount, + signatures, + ); + expect(expectedCalls.length).to.eq(0); + const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( + testContract.marketSellOrdersNoThrow, + orders, + takerAssetFillAmount, + signatures, + ); + expect(actualResult).to.deep.eq(expectedResult); + assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); + }); + }); + + describe('marketSellOrdersFillOrKill', () => { + defineCommonMarketSellOrdersTests(() => testContract.marketSellOrdersNoThrow, simulateMarketSellOrders); + + it('reverts when filled < `takerAssetFillAmount`', async () => { + const COUNT = 4; + const orders = _.times(COUNT, () => randomOrder()); + const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); + const takerAssetFillAmount = _.reduce( + orders, + (total, o) => o.takerAssetAmount.plus(total), + constants.ZERO_AMOUNT, + ).plus(1); + const expectedError = new ExchangeRevertErrors.IncompleteFillError( + ExchangeRevertErrors.IncompleteFillErrorCode.IncompleteMarketSellOrders, + takerAssetFillAmount, + takerAssetFillAmount.minus(1), + ); + const tx = transactionHelper.getResultAndReceiptAsync( + testContract.marketSellOrdersFillOrKill, + orders, + takerAssetFillAmount, + signatures, + ); + return expect(tx).to.revertWith(expectedError); + }); + + it('works when fills fail but can still sell `takerAssetFillAmount`', async () => { + const COUNT = 4; + const BAD_ORDERS_COUNT = 2; + const orders = _.times(COUNT, () => randomOrder()); + const badOrders = _.sampleSize(orders, BAD_ORDERS_COUNT); + for (const order of badOrders) { + order.salt = ALWAYS_FAILING_SALT; + } + const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); + const takerAssetFillAmount = _.reduce( + orders, + (total, o) => o.takerAssetAmount.plus(total), + constants.ZERO_AMOUNT, + ).minus(_.reduce(badOrders, (total, o) => o.takerAssetAmount.plus(total), constants.ZERO_AMOUNT)); + const [expectedResult, expectedCalls] = simulateMarketSellOrders( + orders, + takerAssetFillAmount, + signatures, + ); + expect(expectedCalls.length).to.eq(COUNT - BAD_ORDERS_COUNT); + const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( + testContract.marketSellOrdersFillOrKill, + orders, + takerAssetFillAmount, + signatures, + ); + expect(actualResult).to.deep.eq(expectedResult); + assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); + }); + + it('reverts when a failed fill results in selling less than `takerAssetFillAmount`', async () => { + const COUNT = 4; + const BAD_ORDERS_COUNT = 2; + const orders = _.times(COUNT, () => randomOrder()); + const badOrders = _.sampleSize(orders, BAD_ORDERS_COUNT); + for (const order of badOrders) { + order.salt = ALWAYS_FAILING_SALT; + } + const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); + const badOrdersAmount = _.reduce( + badOrders, + (total, o) => o.takerAssetAmount.plus(total), + constants.ZERO_AMOUNT, + ); + const takerAssetFillAmount = _.reduce( + orders, + (total, o) => o.takerAssetAmount.plus(total), + constants.ZERO_AMOUNT, + ) + .minus(badOrdersAmount) + .plus(1); + const expectedError = new ExchangeRevertErrors.IncompleteFillError( + ExchangeRevertErrors.IncompleteFillErrorCode.IncompleteMarketSellOrders, + takerAssetFillAmount, + takerAssetFillAmount.minus(1), + ); + const tx = transactionHelper.getResultAndReceiptAsync( + testContract.marketSellOrdersFillOrKill, + orders, + takerAssetFillAmount, + signatures, + ); + return expect(tx).to.revertWith(expectedError); + }); + }); + }); + + describe('marketBuy*', () => { + function defineCommonMarketBuyOrdersTests( + getContractFn: MarketSellBuyContractFunction, + simulator: MarketSellBuySimulator, + ): void { + it('works with one order', async () => { + const COUNT = 1; + const orders = _.times(COUNT, () => randomOrder()); + const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); + const makerAssetFillAmount = _.reduce( + orders, + (total, o) => o.makerAssetAmount.plus(total), + constants.ZERO_AMOUNT, + ); + const [expectedResult, expectedCalls] = simulator(orders, makerAssetFillAmount, signatures); + expect(expectedCalls.length).to.eq(COUNT); + const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( + getContractFn(), + orders, + makerAssetFillAmount, + signatures, + ); + expect(actualResult).to.deep.eq(expectedResult); + assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); + }); + + it('works with many orders', async () => { + const COUNT = 8; + const orders = _.times(COUNT, () => randomOrder()); + const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); + const makerAssetFillAmount = _.reduce( + orders, + (total, o) => o.makerAssetAmount.plus(total), + constants.ZERO_AMOUNT, + ); + const [expectedResult, expectedCalls] = simulator(orders, makerAssetFillAmount, signatures); + expect(expectedCalls.length).to.eq(COUNT); + const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( + getContractFn(), + orders, + makerAssetFillAmount, + signatures, + ); + expect(actualResult).to.deep.eq(expectedResult); + assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); + }); + + it('works with duplicate orders', async () => { + const NUM_UNIQUE_ORDERS = 2; + const COUNT = 4; + const uniqueOrders = _.times(NUM_UNIQUE_ORDERS, () => randomOrder()); + const orders = _.shuffle(_.flatten(_.times(COUNT / NUM_UNIQUE_ORDERS, () => uniqueOrders))); + const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); + const makerAssetFillAmount = _.reduce( + orders, + (total, o) => o.makerAssetAmount.plus(total), + constants.ZERO_AMOUNT, + ); + const [expectedResult, expectedCalls] = simulator(orders, makerAssetFillAmount, signatures); + expect(expectedCalls.length).to.eq(COUNT); + const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( + getContractFn(), + orders, + makerAssetFillAmount, + signatures, + ); + expect(actualResult).to.deep.eq(expectedResult); + assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); + }); + + it('stops when filled == `makerAssetFillAmount`', async () => { + const COUNT = 4; + const orders = _.times(COUNT, () => randomOrder()); + const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); + // Skip the last order in our `makerAssetFillAmount` calculation. + const makerAssetFillAmount = _.reduce( + orders.slice(0, COUNT - 1), + (total, o) => o.makerAssetAmount.plus(total), + constants.ZERO_AMOUNT, + ); + const [expectedResult, expectedCalls] = simulator(orders, makerAssetFillAmount, signatures); + // It should stop filling after the penultimate order. + expect(expectedCalls.length).to.eq(COUNT - 1); + const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( + getContractFn(), + orders, + makerAssetFillAmount, + signatures, + ); + expect(actualResult).to.deep.eq(expectedResult); + assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); + }); + + it('stops when filled > `makerAssetFillAmount`', async () => { + const COUNT = 4; + const orders = _.times(COUNT, () => randomOrder()); + const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); + const makerAssetFillAmount = _.reduce( + orders, + (total, o) => o.makerAssetAmount.plus(total), + constants.ZERO_AMOUNT, + ); + // Because `TestWrapperFunctions` always fills `makerAssetAmount` + // setting the first order's `makerAssetAmount` to larger than + // `makerAssetFillAmount` will cause an overfill. + orders[0].makerAssetAmount = makerAssetFillAmount.plus(1); + const [expectedResult, expectedCalls] = simulator(orders, makerAssetFillAmount, signatures); + // It should stop filling after first order. + expect(expectedCalls.length).to.eq(1); + const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( + getContractFn(), + orders, + makerAssetFillAmount, + signatures, + ); + expect(actualResult).to.deep.eq(expectedResult); + assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); + }); + + it('reverts when an overflow occurs when computing `remainingTakerAssetFillAmount`', async () => { + const orders = [randomOrder({ takerAssetAmount: MAX_UINT256 })]; + const signatures = _.times(orders.length, i => createOrderSignature(orders[i])); + const makerAssetFillAmount = new BigNumber(2); + const expectedError = new SafeMathRevertErrors.Uint256BinOpError( + SafeMathRevertErrors.BinOpErrorCodes.MultiplicationOverflow, + orders[0].takerAssetAmount, + makerAssetFillAmount, + ); + const tx = transactionHelper.getResultAndReceiptAsync( + getContractFn(), + orders, + makerAssetFillAmount, + signatures, + ); + return expect(tx).to.revertWith(expectedError); + }); + + it("reverts when an order's `makerAssetAmount` is zero", async () => { + const orders = [randomOrder({ makerAssetAmount: constants.ZERO_AMOUNT })]; + const signatures = _.times(orders.length, i => createOrderSignature(orders[i])); + const makerAssetFillAmount = ONE_ETHER; + const expectedError = new SafeMathRevertErrors.Uint256BinOpError( + SafeMathRevertErrors.BinOpErrorCodes.DivisionByZero, + orders[0].takerAssetAmount.times(makerAssetFillAmount), + orders[0].makerAssetAmount, + ); + const tx = transactionHelper.getResultAndReceiptAsync( + getContractFn(), + orders, + makerAssetFillAmount, + signatures, + ); + return expect(tx).to.revertWith(expectedError); + }); + + it('reverts when an overflow occurs when summing fill results', async () => { + const orders = [ + randomOrder({ + takerAssetAmount: new BigNumber(1), + makerAssetAmount: new BigNumber(1), + }), + randomOrder({ + takerAssetAmount: new BigNumber(1), + makerAssetAmount: MAX_UINT256, + }), + ]; + const signatures = _.times(orders.length, i => createOrderSignature(orders[i])); + const makerAssetFillAmount = new BigNumber(2); + const expectedError = new SafeMathRevertErrors.Uint256BinOpError( + SafeMathRevertErrors.BinOpErrorCodes.AdditionOverflow, + orders[0].makerAssetAmount, + orders[1].makerAssetAmount, + ); + const tx = transactionHelper.getResultAndReceiptAsync( + getContractFn(), + orders, + makerAssetFillAmount, + signatures, + ); + return expect(tx).to.revertWith(expectedError); + }); + + it('returns empty fill results with no orders', async () => { + const [expectedResult, expectedCalls] = simulator([], constants.ZERO_AMOUNT, []); + expect(expectedCalls.length).to.eq(0); + const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( + getContractFn(), + [], + constants.ZERO_AMOUNT, + [], + ); + + expect(actualResult).to.deep.eq(expectedResult); + assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); + }); + } + + function simulateMarketBuyOrdersNoThrow( + orders: Order[], + makerAssetFillAmount: BigNumber, + signatures: string[], + ): [FillResults, ExpectedFillOrderCallArgs[]] { + const fillOrderCalls = []; + let fillResults = _.cloneDeep(EMPTY_FILL_RESULTS); + for (const [order, signature] of _.zip(orders, signatures) as [[Order, string]]) { + const remainingMakerAssetFillAmount = safeSub(makerAssetFillAmount, fillResults.makerAssetFilledAmount); + const remainingTakerAssetFillAmount = getPartialAmountFloor( + order.takerAssetAmount, + order.makerAssetAmount, + remainingMakerAssetFillAmount, + ); + if (order.salt !== ALWAYS_FAILING_SALT) { + fillOrderCalls.push([order, remainingTakerAssetFillAmount, signature]); + } + fillResults = addFillResults(fillResults, getExpectedFillResults(order, signature)); + if (fillResults.makerAssetFilledAmount.gte(makerAssetFillAmount)) { + break; + } + } + return [fillResults, fillOrderCalls as any]; + } + + describe('marketBuyOrdersNoThrow', () => { + defineCommonMarketBuyOrdersTests(() => testContract.marketBuyOrdersNoThrow, simulateMarketBuyOrdersNoThrow); + + it('works when any fills revert', async () => { + const COUNT = 4; + const BAD_ORDERS_COUNT = 2; + const orders = _.times(COUNT, () => randomOrder()); + const badOrders = _.sampleSize(orders, BAD_ORDERS_COUNT); + for (const order of badOrders) { + order.salt = ALWAYS_FAILING_SALT; + } + const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); + const makerAssetFillAmount = _.reduce( + orders, + (total, o) => o.makerAssetAmount.plus(total), + constants.ZERO_AMOUNT, + ); + const [expectedResult, expectedCalls] = simulateMarketBuyOrdersNoThrow( + orders, + makerAssetFillAmount, + signatures, + ); + expect(expectedCalls.length).to.eq(COUNT - BAD_ORDERS_COUNT); + const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( + testContract.marketBuyOrdersNoThrow, + orders, + makerAssetFillAmount, + signatures, + ); + expect(actualResult).to.deep.eq(expectedResult); + assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); + }); + + it('works when all fills revert', async () => { + const COUNT = 4; + const orders = _.times(COUNT, () => randomOrder({ salt: ALWAYS_FAILING_SALT })); + const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); + const makerAssetFillAmount = _.reduce( + orders, + (total, o) => o.makerAssetAmount.plus(total), + constants.ZERO_AMOUNT, + ); + const [expectedResult, expectedCalls] = simulateMarketBuyOrdersNoThrow( + orders, + makerAssetFillAmount, + signatures, + ); + expect(expectedCalls.length).to.eq(0); + const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( + testContract.marketBuyOrdersNoThrow, + orders, + makerAssetFillAmount, + signatures, + ); + expect(actualResult).to.deep.eq(expectedResult); + assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); + }); + }); + + describe('marketBuyOrdersFillOrKill', () => { + defineCommonMarketBuyOrdersTests( + () => testContract.marketBuyOrdersFillOrKill, + simulateMarketBuyOrdersNoThrow, + ); + + it('reverts when filled < `makerAssetFillAmount`', async () => { + const COUNT = 4; + const orders = _.times(COUNT, () => randomOrder()); + const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); + const makerAssetFillAmount = _.reduce( + orders, + (total, o) => o.makerAssetAmount.plus(total), + constants.ZERO_AMOUNT, + ).plus(1); + const expectedError = new ExchangeRevertErrors.IncompleteFillError( + ExchangeRevertErrors.IncompleteFillErrorCode.IncompleteMarketBuyOrders, + makerAssetFillAmount, + makerAssetFillAmount.minus(1), + ); + const tx = transactionHelper.getResultAndReceiptAsync( + testContract.marketBuyOrdersFillOrKill, + orders, + makerAssetFillAmount, + signatures, + ); + return expect(tx).to.revertWith(expectedError); + }); + + it('works when fills fail but can still buy `makerAssetFillAmount`', async () => { + const COUNT = 4; + const BAD_ORDERS_COUNT = 2; + const orders = _.times(COUNT, () => randomOrder()); + const badOrders = _.sampleSize(orders, BAD_ORDERS_COUNT); + for (const order of badOrders) { + order.salt = ALWAYS_FAILING_SALT; + } + const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); + const makerAssetFillAmount = _.reduce( + orders, + (total, o) => o.makerAssetAmount.plus(total), + constants.ZERO_AMOUNT, + ).minus(_.reduce(badOrders, (total, o) => o.makerAssetAmount.plus(total), constants.ZERO_AMOUNT)); + const [expectedResult, expectedCalls] = simulateMarketBuyOrdersNoThrow( + orders, + makerAssetFillAmount, + signatures, + ); + expect(expectedCalls.length).to.eq(COUNT - BAD_ORDERS_COUNT); + const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( + testContract.marketBuyOrdersFillOrKill, + orders, + makerAssetFillAmount, + signatures, + ); + expect(actualResult).to.deep.eq(expectedResult); + assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); + }); + + it('reverts when a failed fill results in buying less than `makerAssetFillAmount`', async () => { + const COUNT = 4; + const BAD_ORDERS_COUNT = 2; + const orders = _.times(COUNT, () => randomOrder()); + const badOrders = _.sampleSize(orders, BAD_ORDERS_COUNT); + for (const order of badOrders) { + order.salt = ALWAYS_FAILING_SALT; + } + const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); + const badOrdersAmount = _.reduce( + badOrders, + (total, o) => o.makerAssetAmount.plus(total), + constants.ZERO_AMOUNT, + ); + const makerAssetFillAmount = _.reduce( + orders, + (total, o) => o.makerAssetAmount.plus(total), + constants.ZERO_AMOUNT, + ) + .minus(badOrdersAmount) + .plus(1); + const expectedError = new ExchangeRevertErrors.IncompleteFillError( + ExchangeRevertErrors.IncompleteFillErrorCode.IncompleteMarketBuyOrders, + makerAssetFillAmount, + makerAssetFillAmount.minus(1), + ); + const tx = transactionHelper.getResultAndReceiptAsync( + testContract.marketBuyOrdersFillOrKill, + orders, + makerAssetFillAmount, + signatures, + ); + return expect(tx).to.revertWith(expectedError); + }); + }); + }); + + describe('batchCancelOrders', () => { + // Asserts that `_cancelOrder()` was called in the same order and with the same + // arguments as given by examining receipt logs. + function assertCancelOrderCallsFromLogs(logs: LogEntry[], calls: Order[]): void { + expect(logs.length).to.eq(calls.length); + for (const i of _.times(calls.length)) { + const log = (logs[i] as any) as LogWithDecodedArgs; + const expectedOrder = calls[i]; + expect(log.event).to.eq('CancelOrderCalled'); + assertSameOrderFromEvent(log.args.order as any, expectedOrder); + } + } + + it('works with no orders', async () => { + const [, receipt] = await transactionHelper.getResultAndReceiptAsync(testContract.batchCancelOrders, []); + assertCancelOrderCallsFromLogs(receipt.logs, []); + }); + + it('works with many orders', async () => { + const COUNT = 8; + const orders = _.times(COUNT, () => randomOrder({ makerAddress: senderAddress })); + const [, receipt] = await transactionHelper.getResultAndReceiptAsync( + testContract.batchCancelOrders, + orders, + ); + assertCancelOrderCallsFromLogs(receipt.logs, orders); + }); + + it('works with duplicate orders', async () => { + const UNIQUE_ORDERS = 2; + const COUNT = 6; + const uniqueOrders = _.times(UNIQUE_ORDERS, () => randomOrder({ makerAddress: senderAddress })); + const orders = _.shuffle(_.flatten(_.times(COUNT / UNIQUE_ORDERS, () => uniqueOrders))); + const [, receipt] = await transactionHelper.getResultAndReceiptAsync( + testContract.batchCancelOrders, + orders, + ); + assertCancelOrderCallsFromLogs(receipt.logs, orders); + }); + + it('reverts if one `_cancelOrder()` reverts', async () => { + const COUNT = 8; + const FAILING_ORDER_INDEX = 4; + const orders = _.times(COUNT, () => randomOrder({ makerAddress: senderAddress })); + const failingOrder = orders[FAILING_ORDER_INDEX]; + failingOrder.salt = ALWAYS_FAILING_SALT; + const expectedError = ALWAYS_FAILING_SALT_REVERT_ERROR; + const tx = transactionHelper.getResultAndReceiptAsync(testContract.batchCancelOrders, orders); + return expect(tx).to.revertWith(expectedError); + }); + }); +}); +// tslint:disable-next-line: max-file-line-count From ddeb984067fa933428fbd63c3e86bd7a53ef1648 Mon Sep 17 00:00:00 2001 From: fabioberger Date: Wed, 13 Nov 2019 13:52:01 +0000 Subject: [PATCH 07/20] Remove duplicate type --- packages/0x.js/src/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/0x.js/src/index.ts b/packages/0x.js/src/index.ts index f550895cca..4ba462c7f2 100644 --- a/packages/0x.js/src/index.ts +++ b/packages/0x.js/src/index.ts @@ -89,7 +89,6 @@ export { SimpleEvmOutput, SimpleEvmBytecodeOutput, EIP712DomainWithDefaultSchema, - SendTransactionOpts, EventCallback, IndexedFilterValues, DecodedLogEvent, From 0f671de6b4023d2d91d533593e600582777241c5 Mon Sep 17 00:00:00 2001 From: fabioberger Date: Wed, 13 Nov 2019 14:07:18 +0000 Subject: [PATCH 08/20] Fix lib_exchange_rich_error_decoder tests --- contracts/exchange/test/lib_exchange_rich_error_decoder.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contracts/exchange/test/lib_exchange_rich_error_decoder.ts b/contracts/exchange/test/lib_exchange_rich_error_decoder.ts index f0c85b5394..c9925804a0 100644 --- a/contracts/exchange/test/lib_exchange_rich_error_decoder.ts +++ b/contracts/exchange/test/lib_exchange_rich_error_decoder.ts @@ -13,7 +13,7 @@ import * as _ from 'lodash'; import { artifacts, TestLibExchangeRichErrorDecoderContract } from '../src'; -blockchainTests.resets('LibExchangeRichErrorDecoder', ({ provider, txDefaults }) => { +blockchainTests.resets.only('LibExchangeRichErrorDecoder', ({ provider, txDefaults }) => { const ASSET_PROXY_ID_LENGTH = 4; const SIGNATURE_LENGTH = 66; const ASSET_DATA_LENGTH = 36; @@ -37,7 +37,7 @@ blockchainTests.resets('LibExchangeRichErrorDecoder', ({ provider, txDefaults }) // Solidity counterparts. const endpointName = `decode${revert.name}`; const callAsync = (_encoded: string) => { - return (decoder as any)[endpointName].callAsync.call((decoder as any)[endpointName], _encoded); + return (decoder as any)[endpointName](_encoded).callAsync.call((decoder as any)[endpointName]); }; describe(`${endpointName}()`, async () => { it('decodes encoded parameters', async () => { From 25367095e2e65687d18d661d641181a28ebf500a Mon Sep 17 00:00:00 2001 From: fabioberger Date: Wed, 13 Nov 2019 16:07:36 +0000 Subject: [PATCH 09/20] Fix remaining test failures in contracts-* packages --- contracts/asset-proxy/test/eth2dai_bridge.ts | 12 ++++++------ contracts/asset-proxy/test/uniswap_bridge.ts | 16 ++++++++-------- .../function_assertion_test.ts | 12 ++++++------ .../exchange_wrapper_test.ts | 14 +++++++------- contracts/staking/test/actors/finalizer_actor.ts | 7 +++---- contracts/staking/test/rewards_test.ts | 2 +- .../test/unit_tests/delegator_reward_test.ts | 2 +- .../unit_tests/mixin_staking_pool_rewards.ts | 4 ++-- 8 files changed, 34 insertions(+), 35 deletions(-) diff --git a/contracts/asset-proxy/test/eth2dai_bridge.ts b/contracts/asset-proxy/test/eth2dai_bridge.ts index 4af06f95a8..4f43696caf 100644 --- a/contracts/asset-proxy/test/eth2dai_bridge.ts +++ b/contracts/asset-proxy/test/eth2dai_bridge.ts @@ -84,14 +84,14 @@ blockchainTests.resets('Eth2DaiBridge unit tests', env => { .awaitTransactionSuccessAsync(); // Create tokens and balances. if (_opts.fromTokenAddress === undefined) { - [_opts.fromTokenAddress] = await transactionHelper.getResultAndReceiptAsync( - testContract.createToken, + [_opts.fromTokenAddress] = await transactionHelper.getResultAndReceiptAsync( + testContract.createToken.bind(testContract), new BigNumber(_opts.fromTokenBalance), ); } if (_opts.toTokenAddress === undefined) { - [_opts.toTokenAddress] = await transactionHelper.getResultAndReceiptAsync( - testContract.createToken, + [_opts.toTokenAddress] = await transactionHelper.getResultAndReceiptAsync( + testContract.createToken.bind(testContract), constants.ZERO_AMOUNT, ); } @@ -104,8 +104,8 @@ blockchainTests.resets('Eth2DaiBridge unit tests', env => { ) .awaitTransactionSuccessAsync(); // Call bridgeTransferFrom(). - const [result, { logs }] = await transactionHelper.getResultAndReceiptAsync( - testContract.bridgeTransferFrom, + const [result, { logs }] = await transactionHelper.getResultAndReceiptAsync( + testContract.bridgeTransferFrom.bind(testContract), // "to" token address _opts.toTokenAddress, // Random from address. diff --git a/contracts/asset-proxy/test/uniswap_bridge.ts b/contracts/asset-proxy/test/uniswap_bridge.ts index ae07d17abe..b7d62d3eee 100644 --- a/contracts/asset-proxy/test/uniswap_bridge.ts +++ b/contracts/asset-proxy/test/uniswap_bridge.ts @@ -89,15 +89,15 @@ blockchainTests.resets('UniswapBridge unit tests', env => { async function withdrawToAsync(opts?: Partial): Promise { const _opts = createWithdrawToOpts(opts); // Create the "from" token and exchange. - [[_opts.fromTokenAddress]] = await transactionHelper.getResultAndReceiptAsync( - testContract.createTokenAndExchange, + [[_opts.fromTokenAddress]] = await transactionHelper.getResultAndReceiptAsync( + testContract.createTokenAndExchange.bind(testContract), _opts.fromTokenAddress, _opts.exchangeRevertReason, { value: new BigNumber(_opts.exchangeFillAmount) }, ); // Create the "to" token and exchange. - [[_opts.toTokenAddress]] = await transactionHelper.getResultAndReceiptAsync( - testContract.createTokenAndExchange, + [[_opts.toTokenAddress]] = await transactionHelper.getResultAndReceiptAsync( + testContract.createTokenAndExchange.bind(testContract), _opts.toTokenAddress, _opts.exchangeRevertReason, { value: new BigNumber(_opts.exchangeFillAmount) }, @@ -113,8 +113,8 @@ blockchainTests.resets('UniswapBridge unit tests', env => { value: new BigNumber(_opts.fromTokenBalance), }); // Call bridgeTransferFrom(). - const [result, receipt] = await transactionHelper.getResultAndReceiptAsync( - testContract.bridgeTransferFrom, + const [result, receipt] = await transactionHelper.getResultAndReceiptAsync( + testContract.bridgeTransferFrom.bind(testContract), // The "to" token address. _opts.toTokenAddress, // The "from" address. @@ -144,8 +144,8 @@ blockchainTests.resets('UniswapBridge unit tests', env => { }); it('just transfers tokens to `to` if the same tokens are in play', async () => { - const [[tokenAddress]] = await transactionHelper.getResultAndReceiptAsync( - testContract.createTokenAndExchange, + const [[tokenAddress]] = await transactionHelper.getResultAndReceiptAsync( + testContract.createTokenAndExchange.bind(testContract), constants.NULL_ADDRESS, '', ); diff --git a/contracts/integrations/test/framework-unit-tests/function_assertion_test.ts b/contracts/integrations/test/framework-unit-tests/function_assertion_test.ts index b9158c16dd..60b18b183d 100644 --- a/contracts/integrations/test/framework-unit-tests/function_assertion_test.ts +++ b/contracts/integrations/test/framework-unit-tests/function_assertion_test.ts @@ -22,7 +22,7 @@ blockchainTests.resets('FunctionAssertion Unit Tests', env => { describe('executeAsync', () => { it('should call the before function with the provided arguments', async () => { let sideEffectTarget = ZERO_AMOUNT; - const assertion = new FunctionAssertion(exampleContract.returnInteger, { + const assertion = new FunctionAssertion(exampleContract.returnInteger.bind(exampleContract), { before: async (_input: BigNumber) => { sideEffectTarget = randomInput; }, @@ -34,7 +34,7 @@ blockchainTests.resets('FunctionAssertion Unit Tests', env => { it('should call the after function with the provided arguments', async () => { let sideEffectTarget = ZERO_AMOUNT; - const assertion = new FunctionAssertion(exampleContract.returnInteger, { + const assertion = new FunctionAssertion(exampleContract.returnInteger.bind(exampleContract), { after: async (_beforeInfo: any, _result: Result, input: BigNumber) => { sideEffectTarget = input; }, @@ -52,7 +52,7 @@ blockchainTests.resets('FunctionAssertion Unit Tests', env => { it('should pass the return value of "before" to "after"', async () => { const randomInput = getRandomInteger(ZERO_AMOUNT, MAX_UINT256); let sideEffectTarget = ZERO_AMOUNT; - const assertion = new FunctionAssertion(exampleContract.returnInteger, { + const assertion = new FunctionAssertion(exampleContract.returnInteger.bind(exampleContract), { before: async (_input: BigNumber) => { return randomInput; }, @@ -66,7 +66,7 @@ blockchainTests.resets('FunctionAssertion Unit Tests', env => { it('should pass the result from the function call to "after"', async () => { let sideEffectTarget = ZERO_AMOUNT; - const assertion = new FunctionAssertion(exampleContract.returnInteger, { + const assertion = new FunctionAssertion(exampleContract.returnInteger.bind(exampleContract), { after: async (_beforeInfo: any, result: Result, _input: BigNumber) => { sideEffectTarget = result.data; }, @@ -78,7 +78,7 @@ blockchainTests.resets('FunctionAssertion Unit Tests', env => { it('should pass the receipt from the function call to "after"', async () => { let sideEffectTarget: TransactionReceiptWithDecodedLogs; - const assertion = new FunctionAssertion(exampleContract.emitEvent, { + const assertion = new FunctionAssertion(exampleContract.emitEvent.bind(exampleContract), { after: async (_beforeInfo: any, result: Result, _input: string) => { if (result.receipt) { sideEffectTarget = result.receipt; @@ -99,7 +99,7 @@ blockchainTests.resets('FunctionAssertion Unit Tests', env => { it('should pass the error to "after" if the function call fails', async () => { let sideEffectTarget: Error; - const assertion = new FunctionAssertion(exampleContract.stringRevert, { + const assertion = new FunctionAssertion(exampleContract.stringRevert.bind(exampleContract), { after: async (_beforeInfo: any, result: Result, _input: string) => { sideEffectTarget = result.data; }, diff --git a/contracts/integrations/test/internal-integration-tests/exchange_wrapper_test.ts b/contracts/integrations/test/internal-integration-tests/exchange_wrapper_test.ts index 0889c28606..bd275400b3 100644 --- a/contracts/integrations/test/internal-integration-tests/exchange_wrapper_test.ts +++ b/contracts/integrations/test/internal-integration-tests/exchange_wrapper_test.ts @@ -315,10 +315,10 @@ blockchainTests.resets('Exchange wrappers', env => { makerAssetAmount: toBaseUnitAmount(new BigNumber(100)), takerAssetAmount: toBaseUnitAmount(new BigNumber(200)), }); - const takerAssetFilledAmount = signedOrder.takerAssetAmount.div(2); + const takerAssetFilledAmount = signedOrder.takerAssetAmount.div(5); const [fillResults, receipt] = await transactionHelper.getResultAndReceiptAsync( - deployment.exchange.fillOrKillOrder, + deployment.exchange.fillOrKillOrder.bind(deployment.exchange), signedOrder, takerAssetFilledAmount, signedOrder.signature, @@ -437,7 +437,7 @@ blockchainTests.resets('Exchange wrappers', env => { } const [fillResults, receipt] = await transactionHelper.getResultAndReceiptAsync( - deployment.exchange.batchFillOrders, + deployment.exchange.batchFillOrders.bind(deployment.exchange), signedOrders, takerAssetFillAmounts, signedOrders.map(signedOrder => signedOrder.signature), @@ -499,7 +499,7 @@ blockchainTests.resets('Exchange wrappers', env => { } const [fillResults, receipt] = await transactionHelper.getResultAndReceiptAsync( - deployment.exchange.batchFillOrKillOrders, + deployment.exchange.batchFillOrKillOrders.bind(deployment.exchange), signedOrders, takerAssetFillAmounts, signedOrders.map(order => order.signature), @@ -595,7 +595,7 @@ blockchainTests.resets('Exchange wrappers', env => { } const [fillResults, receipt] = await transactionHelper.getResultAndReceiptAsync( - deployment.exchange.batchFillOrdersNoThrow, + deployment.exchange.batchFillOrdersNoThrow.bind(deployment.exchange), signedOrdersWithValidity.map(signedOrderWithValidity => signedOrderWithValidity.signedOrder), takerAssetFillAmounts, signedOrdersWithValidity.map( @@ -710,7 +710,7 @@ blockchainTests.resets('Exchange wrappers', env => { } const [fillResults, receipt] = await transactionHelper.getResultAndReceiptAsync( - deployment.exchange.marketSellOrdersNoThrow, + deployment.exchange.marketSellOrdersNoThrow.bind(deployment.exchange), signedOrdersWithValidity.map(orderWithValidity => orderWithValidity.signedOrder), takerAssetFillAmount, signedOrdersWithValidity.map(orderWithValidity => orderWithValidity.signedOrder.signature), @@ -908,7 +908,7 @@ blockchainTests.resets('Exchange wrappers', env => { } const [fillResults, receipt] = await transactionHelper.getResultAndReceiptAsync( - deployment.exchange.marketBuyOrdersNoThrow, + deployment.exchange.marketBuyOrdersNoThrow.bind(deployment.exchange), signedOrdersWithValidity.map(orderWithValidity => orderWithValidity.signedOrder), makerAssetFillAmount, signedOrdersWithValidity.map(orderWithValidity => orderWithValidity.signedOrder.signature), diff --git a/contracts/staking/test/actors/finalizer_actor.ts b/contracts/staking/test/actors/finalizer_actor.ts index 08a95554e0..8944665876 100644 --- a/contracts/staking/test/actors/finalizer_actor.ts +++ b/contracts/staking/test/actors/finalizer_actor.ts @@ -131,9 +131,9 @@ export class FinalizerActor extends BaseActor { for (const delegator of delegators) { let balance = new BigNumber(delegatorBalancesByPoolId[poolId][delegator] || 0); if (delegator === operator) { - balance = balance.plus(await computeRewardBalanceOfOperator(poolId).callAsync()); + balance = balance.plus(await computeRewardBalanceOfOperator.bind(this._stakingApiWrapper.stakingContract)(poolId).callAsync()); } else { - balance = balance.plus(await computeRewardBalanceOfDelegator(poolId, delegator).callAsync()); + balance = balance.plus(await computeRewardBalanceOfDelegator.bind(this._stakingApiWrapper.stakingContract)(poolId, delegator).callAsync()); } delegatorBalancesByPoolId[poolId][delegator] = balance; } @@ -144,13 +144,12 @@ export class FinalizerActor extends BaseActor { private async _getDelegatorStakesByPoolIdAsync( delegatorsByPoolId: DelegatorsByPoolId, ): Promise { - const { getStakeDelegatedToPoolByOwner } = this._stakingApiWrapper.stakingContract; const delegatorBalancesByPoolId: DelegatorBalancesByPoolId = {}; for (const poolId of Object.keys(delegatorsByPoolId)) { const delegators = delegatorsByPoolId[poolId]; delegatorBalancesByPoolId[poolId] = {}; for (const delegator of delegators) { - delegatorBalancesByPoolId[poolId][delegator] = (await getStakeDelegatedToPoolByOwner( + delegatorBalancesByPoolId[poolId][delegator] = (await this._stakingApiWrapper.stakingContract.getStakeDelegatedToPoolByOwner( delegator, poolId, ).callAsync()).currentEpochBalance; diff --git a/contracts/staking/test/rewards_test.ts b/contracts/staking/test/rewards_test.ts index 2974a53782..3c0a0f5e5c 100644 --- a/contracts/staking/test/rewards_test.ts +++ b/contracts/staking/test/rewards_test.ts @@ -163,7 +163,7 @@ blockchainTests.resets('Testing Rewards', env => { // sanity balances - all zero await validateEndBalances({}); }); - it.only('Reward balance should be zero if not delegated, when epoch is greater than 0', async () => { + it('Reward balance should be zero if not delegated, when epoch is greater than 0', async () => { await payProtocolFeeAndFinalize(); // sanity balances - all zero await validateEndBalances({}); diff --git a/contracts/staking/test/unit_tests/delegator_reward_test.ts b/contracts/staking/test/unit_tests/delegator_reward_test.ts index a031ff2e57..2cb22f8bfc 100644 --- a/contracts/staking/test/unit_tests/delegator_reward_test.ts +++ b/contracts/staking/test/unit_tests/delegator_reward_test.ts @@ -152,7 +152,7 @@ blockchainTests.resets('Delegator rewards unit tests', env => { stake: getRandomInteger(1, toBaseUnitAmount(10)), ...opts, }; - const fn = now ? testContract.delegateStakeNow : testContract.delegateStake; + const fn = now ? testContract.delegateStakeNow.bind(testContract) : testContract.delegateStake.bind(testContract); const receipt = await fn(_opts.delegator, poolId, new BigNumber(_opts.stake)).awaitTransactionSuccessAsync(); const delegatorTransfers = getTransfersFromLogs(receipt.logs, _opts.delegator); return { diff --git a/contracts/staking/test/unit_tests/mixin_staking_pool_rewards.ts b/contracts/staking/test/unit_tests/mixin_staking_pool_rewards.ts index 2dc4580a35..e6d7ba80f4 100644 --- a/contracts/staking/test/unit_tests/mixin_staking_pool_rewards.ts +++ b/contracts/staking/test/unit_tests/mixin_staking_pool_rewards.ts @@ -365,8 +365,8 @@ blockchainTests.resets('MixinStakingPoolRewards unit tests', env => { reward: Numberish, membersStake: Numberish, ): Promise<[[BigNumber, BigNumber], LogEntry[]]> { - const [result, receipt] = await transactionHelper.getResultAndReceiptAsync( - testContract.syncPoolRewards, + const [result, receipt] = await transactionHelper.getResultAndReceiptAsync( + testContract.syncPoolRewards.bind(testContract), POOL_ID, new BigNumber(reward), new BigNumber(membersStake), From c41fb4a13861e3670fbdeeb56ef47a9dcb1eef2f Mon Sep 17 00:00:00 2001 From: fabioberger Date: Wed, 13 Nov 2019 16:09:19 +0000 Subject: [PATCH 10/20] Prettier fixes --- .../staking/test/actors/finalizer_actor.ts | 21 +++++++++++++------ .../test/unit_tests/delegator_reward_test.ts | 4 +++- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/contracts/staking/test/actors/finalizer_actor.ts b/contracts/staking/test/actors/finalizer_actor.ts index 8944665876..97c3fd7773 100644 --- a/contracts/staking/test/actors/finalizer_actor.ts +++ b/contracts/staking/test/actors/finalizer_actor.ts @@ -131,9 +131,17 @@ export class FinalizerActor extends BaseActor { for (const delegator of delegators) { let balance = new BigNumber(delegatorBalancesByPoolId[poolId][delegator] || 0); if (delegator === operator) { - balance = balance.plus(await computeRewardBalanceOfOperator.bind(this._stakingApiWrapper.stakingContract)(poolId).callAsync()); + balance = balance.plus( + await computeRewardBalanceOfOperator + .bind(this._stakingApiWrapper.stakingContract)(poolId) + .callAsync(), + ); } else { - balance = balance.plus(await computeRewardBalanceOfDelegator.bind(this._stakingApiWrapper.stakingContract)(poolId, delegator).callAsync()); + balance = balance.plus( + await computeRewardBalanceOfDelegator + .bind(this._stakingApiWrapper.stakingContract)(poolId, delegator) + .callAsync(), + ); } delegatorBalancesByPoolId[poolId][delegator] = balance; } @@ -149,10 +157,11 @@ export class FinalizerActor extends BaseActor { const delegators = delegatorsByPoolId[poolId]; delegatorBalancesByPoolId[poolId] = {}; for (const delegator of delegators) { - delegatorBalancesByPoolId[poolId][delegator] = (await this._stakingApiWrapper.stakingContract.getStakeDelegatedToPoolByOwner( - delegator, - poolId, - ).callAsync()).currentEpochBalance; + delegatorBalancesByPoolId[poolId][ + delegator + ] = (await this._stakingApiWrapper.stakingContract + .getStakeDelegatedToPoolByOwner(delegator, poolId) + .callAsync()).currentEpochBalance; } } return delegatorBalancesByPoolId; diff --git a/contracts/staking/test/unit_tests/delegator_reward_test.ts b/contracts/staking/test/unit_tests/delegator_reward_test.ts index 2cb22f8bfc..ed774636ea 100644 --- a/contracts/staking/test/unit_tests/delegator_reward_test.ts +++ b/contracts/staking/test/unit_tests/delegator_reward_test.ts @@ -152,7 +152,9 @@ blockchainTests.resets('Delegator rewards unit tests', env => { stake: getRandomInteger(1, toBaseUnitAmount(10)), ...opts, }; - const fn = now ? testContract.delegateStakeNow.bind(testContract) : testContract.delegateStake.bind(testContract); + const fn = now + ? testContract.delegateStakeNow.bind(testContract) + : testContract.delegateStake.bind(testContract); const receipt = await fn(_opts.delegator, poolId, new BigNumber(_opts.stake)).awaitTransactionSuccessAsync(); const delegatorTransfers = getTransfersFromLogs(receipt.logs, _opts.delegator); return { From ac78dc6f959083f10c9bafa0bc93ef86bf80a857 Mon Sep 17 00:00:00 2001 From: xianny Date: Wed, 13 Nov 2019 16:24:01 -0500 Subject: [PATCH 11/20] remove transactionHelper --- contracts/asset-proxy/test/eth2dai_bridge.ts | 20 +- contracts/asset-proxy/test/uniswap_bridge.ts | 45 +- .../exchange/test/transactions_unit_tests.ts | 35 +- contracts/exchange/test/wrapper_unit_tests.ts | 483 ++++++------------ .../exchange_wrapper_test.ts | 89 ++-- .../unit_tests/mixin_staking_pool_rewards.ts | 8 +- contracts/test-utils/src/index.ts | 1 - .../test-utils/src/transaction_helper.ts | 21 - 8 files changed, 245 insertions(+), 457 deletions(-) delete mode 100644 contracts/test-utils/src/transaction_helper.ts diff --git a/contracts/asset-proxy/test/eth2dai_bridge.ts b/contracts/asset-proxy/test/eth2dai_bridge.ts index 4f43696caf..3d30584d4f 100644 --- a/contracts/asset-proxy/test/eth2dai_bridge.ts +++ b/contracts/asset-proxy/test/eth2dai_bridge.ts @@ -8,7 +8,6 @@ import { hexRandom, Numberish, randomAddress, - transactionHelper, } from '@0x/contracts-test-utils'; import { AssetProxyId } from '@0x/types'; import { BigNumber, RawRevertError } from '@0x/utils'; @@ -84,16 +83,14 @@ blockchainTests.resets('Eth2DaiBridge unit tests', env => { .awaitTransactionSuccessAsync(); // Create tokens and balances. if (_opts.fromTokenAddress === undefined) { - [_opts.fromTokenAddress] = await transactionHelper.getResultAndReceiptAsync( - testContract.createToken.bind(testContract), - new BigNumber(_opts.fromTokenBalance), - ); + const createTokenFn = testContract.createToken(new BigNumber(_opts.fromTokenBalance)); + _opts.fromTokenAddress = await createTokenFn.callAsync(); + await createTokenFn.awaitTransactionSuccessAsync(); } if (_opts.toTokenAddress === undefined) { - [_opts.toTokenAddress] = await transactionHelper.getResultAndReceiptAsync( - testContract.createToken.bind(testContract), - constants.ZERO_AMOUNT, - ); + const createTokenFn = testContract.createToken(constants.ZERO_AMOUNT); + _opts.toTokenAddress = await createTokenFn.callAsync(); + await createTokenFn.awaitTransactionSuccessAsync(); } // Set the transfer behavior of `toTokenAddress`. await testContract @@ -104,8 +101,7 @@ blockchainTests.resets('Eth2DaiBridge unit tests', env => { ) .awaitTransactionSuccessAsync(); // Call bridgeTransferFrom(). - const [result, { logs }] = await transactionHelper.getResultAndReceiptAsync( - testContract.bridgeTransferFrom.bind(testContract), + const bridgeTransferFromFn = testContract.bridgeTransferFrom( // "to" token address _opts.toTokenAddress, // Random from address. @@ -116,6 +112,8 @@ blockchainTests.resets('Eth2DaiBridge unit tests', env => { // ABI-encode the "from" token address as the bridge data. hexLeftPad(_opts.fromTokenAddress as string), ); + const result = await bridgeTransferFromFn.callAsync(); + const { logs } = await bridgeTransferFromFn.awaitTransactionSuccessAsync(); return { opts: _opts, result, diff --git a/contracts/asset-proxy/test/uniswap_bridge.ts b/contracts/asset-proxy/test/uniswap_bridge.ts index b7d62d3eee..f8932b3e92 100644 --- a/contracts/asset-proxy/test/uniswap_bridge.ts +++ b/contracts/asset-proxy/test/uniswap_bridge.ts @@ -9,7 +9,6 @@ import { hexRandom, Numberish, randomAddress, - transactionHelper, } from '@0x/contracts-test-utils'; import { AssetProxyId } from '@0x/types'; import { BigNumber } from '@0x/utils'; @@ -88,20 +87,23 @@ blockchainTests.resets('UniswapBridge unit tests', env => { async function withdrawToAsync(opts?: Partial): Promise { const _opts = createWithdrawToOpts(opts); + const callData = { value: new BigNumber(_opts.exchangeFillAmount) }; // Create the "from" token and exchange. - [[_opts.fromTokenAddress]] = await transactionHelper.getResultAndReceiptAsync( - testContract.createTokenAndExchange.bind(testContract), + const createFromTokenFn = testContract.createTokenAndExchange( _opts.fromTokenAddress, _opts.exchangeRevertReason, - { value: new BigNumber(_opts.exchangeFillAmount) }, ); + [_opts.fromTokenAddress] = await createFromTokenFn.callAsync(callData); + await createFromTokenFn.awaitTransactionSuccessAsync(callData); + // Create the "to" token and exchange. - [[_opts.toTokenAddress]] = await transactionHelper.getResultAndReceiptAsync( - testContract.createTokenAndExchange.bind(testContract), + const createToTokenFn = testContract.createTokenAndExchange( _opts.toTokenAddress, _opts.exchangeRevertReason, - { value: new BigNumber(_opts.exchangeFillAmount) }, ); + [_opts.toTokenAddress] = await createToTokenFn.callAsync(callData); + await createToTokenFn.awaitTransactionSuccessAsync(callData); + await testContract .setTokenRevertReason(_opts.toTokenAddress, _opts.toTokenRevertReason) .awaitTransactionSuccessAsync(); @@ -113,8 +115,7 @@ blockchainTests.resets('UniswapBridge unit tests', env => { value: new BigNumber(_opts.fromTokenBalance), }); // Call bridgeTransferFrom(). - const [result, receipt] = await transactionHelper.getResultAndReceiptAsync( - testContract.bridgeTransferFrom.bind(testContract), + const bridgeTransferFromFn = testContract.bridgeTransferFrom( // The "to" token address. _opts.toTokenAddress, // The "from" address. @@ -126,6 +127,8 @@ blockchainTests.resets('UniswapBridge unit tests', env => { // ABI-encoded "from" token address. hexLeftPad(_opts.fromTokenAddress), ); + const result = await bridgeTransferFromFn.callAsync(); + const receipt = await bridgeTransferFromFn.awaitTransactionSuccessAsync(); return { opts: _opts, result, @@ -144,11 +147,9 @@ blockchainTests.resets('UniswapBridge unit tests', env => { }); it('just transfers tokens to `to` if the same tokens are in play', async () => { - const [[tokenAddress]] = await transactionHelper.getResultAndReceiptAsync( - testContract.createTokenAndExchange.bind(testContract), - constants.NULL_ADDRESS, - '', - ); + const createTokenFn = await testContract.createTokenAndExchange(constants.NULL_ADDRESS, ''); + const [tokenAddress] = await createTokenFn.callAsync(); + await createTokenFn.awaitTransactionSuccessAsync(); const { opts, result, logs } = await withdrawToAsync({ fromTokenAddress: tokenAddress, toTokenAddress: tokenAddress, @@ -209,7 +210,7 @@ blockchainTests.resets('UniswapBridge unit tests', env => { hexLeftPad(randomAddress()), ) .awaitTransactionSuccessAsync(); - return expect(tx).to.revertWith('NO_UNISWAP_EXCHANGE_FOR_TOKEN'); + return expect(tx).to.eventually.be.rejectedWith('NO_UNISWAP_EXCHANGE_FOR_TOKEN'); }); it('fails if the exchange fails', async () => { @@ -217,7 +218,7 @@ blockchainTests.resets('UniswapBridge unit tests', env => { const tx = withdrawToAsync({ exchangeRevertReason: revertReason, }); - return expect(tx).to.revertWith(revertReason); + return expect(tx).to.eventually.be.rejectedWith(revertReason); }); }); @@ -283,7 +284,7 @@ blockchainTests.resets('UniswapBridge unit tests', env => { hexLeftPad(wethTokenAddress), ) .awaitTransactionSuccessAsync(); - return expect(tx).to.revertWith('NO_UNISWAP_EXCHANGE_FOR_TOKEN'); + return expect(tx).to.eventually.be.rejectedWith('NO_UNISWAP_EXCHANGE_FOR_TOKEN'); }); it('fails if `WETH.deposit()` fails', async () => { @@ -292,7 +293,7 @@ blockchainTests.resets('UniswapBridge unit tests', env => { toTokenAddress: wethTokenAddress, toTokenRevertReason: revertReason, }); - return expect(tx).to.revertWith(revertReason); + return expect(tx).to.eventually.be.rejectedWith(revertReason); }); it('fails if the exchange fails', async () => { @@ -301,7 +302,7 @@ blockchainTests.resets('UniswapBridge unit tests', env => { toTokenAddress: wethTokenAddress, exchangeRevertReason: revertReason, }); - return expect(tx).to.revertWith(revertReason); + return expect(tx).to.eventually.be.rejectedWith(revertReason); }); }); @@ -343,7 +344,7 @@ blockchainTests.resets('UniswapBridge unit tests', env => { hexLeftPad(randomAddress()), ) .awaitTransactionSuccessAsync(); - return expect(tx).to.revertWith('NO_UNISWAP_EXCHANGE_FOR_TOKEN'); + return expect(tx).to.eventually.be.rejectedWith('NO_UNISWAP_EXCHANGE_FOR_TOKEN'); }); it('fails if the `WETH.withdraw()` fails', async () => { @@ -352,7 +353,7 @@ blockchainTests.resets('UniswapBridge unit tests', env => { fromTokenAddress: wethTokenAddress, fromTokenRevertReason: revertReason, }); - return expect(tx).to.revertWith(revertReason); + return expect(tx).to.eventually.be.rejectedWith(revertReason); }); it('fails if the exchange fails', async () => { @@ -361,7 +362,7 @@ blockchainTests.resets('UniswapBridge unit tests', env => { fromTokenAddress: wethTokenAddress, exchangeRevertReason: revertReason, }); - return expect(tx).to.revertWith(revertReason); + return expect(tx).to.eventually.be.rejectedWith(revertReason); }); }); }); diff --git a/contracts/exchange/test/transactions_unit_tests.ts b/contracts/exchange/test/transactions_unit_tests.ts index 1a537d7a26..286c48e794 100644 --- a/contracts/exchange/test/transactions_unit_tests.ts +++ b/contracts/exchange/test/transactions_unit_tests.ts @@ -1,4 +1,4 @@ -import { blockchainTests, constants, describe, expect, hexRandom, transactionHelper } from '@0x/contracts-test-utils'; +import { blockchainTests, constants, describe, expect, hexRandom } from '@0x/contracts-test-utils'; import { ExchangeRevertErrors, transactionHashUtils } from '@0x/order-utils'; import { EIP712DomainWithDefaultSchema, ZeroExTransaction } from '@0x/types'; import { BigNumber, StringRevertError } from '@0x/utils'; @@ -186,12 +186,9 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef const transactionHash = transactionHashUtils.getTransactionHashHex(transaction); const validSignature = randomSignature(); - const [result, receipt] = await transactionHelper.getResultAndReceiptAsync( - transactionsContract.batchExecuteTransactions, - [transaction], - [validSignature], - { from: accounts[0] }, - ); + const contractFn = transactionsContract.batchExecuteTransactions([transaction], [validSignature]); + const result = await contractFn.callAsync({ from: accounts[0] }); + const receipt = await contractFn.awaitTransactionSuccessAsync({ from: accounts[0] }); expect(result.length).to.be.eq(1); const returnData = transactionsContract.getABIDecodedReturnData('executeTransaction', result[0]); @@ -224,13 +221,13 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef const transactionHash1 = transactionHashUtils.getTransactionHashHex(transaction1); const transactionHash2 = transactionHashUtils.getTransactionHashHex(transaction2); - const [result, receipt] = await transactionHelper.getResultAndReceiptAsync( - transactionsContract.batchExecuteTransactions, + const contractFn = transactionsContract.batchExecuteTransactions( [transaction1, transaction2], [randomSignature(), randomSignature()], - { from: accounts[0] }, ); + const result = await contractFn.callAsync({ from: accounts[0] }); + const receipt = await contractFn.awaitTransactionSuccessAsync({ from: accounts[0] }); expect(result.length).to.be.eq(2); expect(transactionsContract.getABIDecodedReturnData('executeTransaction', result[0])).to.equal( DEADBEEF_RETURN_DATA, @@ -507,13 +504,10 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef }); const transactionHash = transactionHashUtils.getTransactionHashHex(transaction); - const [result, receipt] = await transactionHelper.getResultAndReceiptAsync( - transactionsContract.executeTransaction, - transaction, - validSignature, - { from: accounts[0] }, - ); + const contractFn = transactionsContract.executeTransaction(transaction, validSignature); + const result = await contractFn.callAsync({ from: accounts[0] }); + const receipt = await contractFn.awaitTransactionSuccessAsync({ from: accounts[0] }); expect(transactionsContract.getABIDecodedReturnData('executeTransaction', result)).to.equal( DEADBEEF_RETURN_DATA, ); @@ -538,13 +532,10 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef }); const transactionHash = transactionHashUtils.getTransactionHashHex(transaction); - const [result, receipt] = await transactionHelper.getResultAndReceiptAsync( - transactionsContract.executeTransaction, - transaction, - validSignature, - { from: accounts[0] }, - ); + const contractFn = transactionsContract.executeTransaction(transaction, validSignature); + const result = await contractFn.callAsync({ from: accounts[0] }); + const receipt = await contractFn.awaitTransactionSuccessAsync({ from: accounts[0] }); expect(transactionsContract.getABIDecodedReturnData('executeTransaction', result)).to.equal( DEADBEEF_RETURN_DATA, ); diff --git a/contracts/exchange/test/wrapper_unit_tests.ts b/contracts/exchange/test/wrapper_unit_tests.ts index 034bd492f0..e4e9931d63 100644 --- a/contracts/exchange/test/wrapper_unit_tests.ts +++ b/contracts/exchange/test/wrapper_unit_tests.ts @@ -1,13 +1,6 @@ +import { ContractTxFunctionObj } from '@0x/base-contract'; import { ReferenceFunctions as LibReferenceFunctions } from '@0x/contracts-exchange-libs'; -import { - blockchainTests, - constants, - describe, - expect, - hexRandom, - MutatorContractFunction, - transactionHelper, -} from '@0x/contracts-test-utils'; +import { blockchainTests, constants, describe, expect, hexRandom } from '@0x/contracts-test-utils'; import { ReferenceFunctions as UtilReferenceFunctions } from '@0x/contracts-utils'; import { ExchangeRevertErrors, orderHashUtils } from '@0x/order-utils'; import { FillResults, Order } from '@0x/types'; @@ -150,12 +143,9 @@ blockchainTests('Exchange wrapper functions unit tests.', env => { const signature = createOrderSignature(order); const expectedResult = getExpectedFillResults(order, signature); const expectedCalls = [[order, fillAmount, signature]]; - const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( - testContract.fillOrKillOrder, - order, - fillAmount, - signature, - ); + const contractFn = testContract.fillOrKillOrder(order, fillAmount, signature); + const actualResult = await contractFn.callAsync(); + const receipt = await contractFn.awaitTransactionSuccessAsync(); expect(actualResult).to.deep.eq(expectedResult); assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); }); @@ -213,12 +203,9 @@ blockchainTests('Exchange wrapper functions unit tests.', env => { const signature = createOrderSignature(order); const expectedResult = getExpectedFillResults(order, signature); const expectedCalls = [[order, fillAmount, signature]]; - const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( - testContract.fillOrderNoThrow, - order, - fillAmount, - signature, - ); + const contractFn = testContract.fillOrderNoThrow(order, fillAmount, signature); + const actualResult = await contractFn.callAsync(); + const receipt = await contractFn.awaitTransactionSuccessAsync(); expect(actualResult).to.deep.eq(expectedResult); assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); }); @@ -230,12 +217,9 @@ blockchainTests('Exchange wrapper functions unit tests.', env => { }); const signature = createOrderSignature(order); const expectedResult = EMPTY_FILL_RESULTS; - const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( - testContract.fillOrderNoThrow, - order, - fillAmount, - signature, - ); + const contractFn = testContract.fillOrderNoThrow(order, fillAmount, signature); + const actualResult = await contractFn.callAsync(); + const receipt = await contractFn.awaitTransactionSuccessAsync(); expect(actualResult).to.deep.eq(expectedResult); assertFillOrderCallsFromLogs(receipt.logs, []); }); @@ -243,12 +227,9 @@ blockchainTests('Exchange wrapper functions unit tests.', env => { describe('batchFillOrders', () => { it('works with no fills', async () => { - const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( - testContract.batchFillOrders, - [], - [], - [], - ); + const contractFn = testContract.batchFillOrders([], [], []); + const actualResult = await contractFn.callAsync(); + const receipt = await contractFn.awaitTransactionSuccessAsync(); expect(actualResult).to.deep.eq([]); assertFillOrderCallsFromLogs(receipt.logs, []); }); @@ -260,12 +241,9 @@ blockchainTests('Exchange wrapper functions unit tests.', env => { const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); const expectedCalls = _.zip(orders, fillAmounts, signatures); - const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( - testContract.batchFillOrders, - orders, - fillAmounts, - signatures, - ); + const contractFn = testContract.batchFillOrders(orders, fillAmounts, signatures); + const actualResult = await contractFn.callAsync(); + const receipt = await contractFn.awaitTransactionSuccessAsync(); expect(actualResult).to.deep.eq(expectedResult); assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); }); @@ -277,12 +255,9 @@ blockchainTests('Exchange wrapper functions unit tests.', env => { const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); const expectedCalls = _.zip(orders, fillAmounts, signatures); - const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( - testContract.batchFillOrders, - orders, - fillAmounts, - signatures, - ); + const contractFn = testContract.batchFillOrders(orders, fillAmounts, signatures); + const actualResult = await contractFn.callAsync(); + const receipt = await contractFn.awaitTransactionSuccessAsync(); expect(actualResult).to.deep.eq(expectedResult); assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); }); @@ -296,12 +271,9 @@ blockchainTests('Exchange wrapper functions unit tests.', env => { const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); const expectedCalls = _.zip(orders, fillAmounts, signatures); - const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( - testContract.batchFillOrders, - orders, - fillAmounts, - signatures, - ); + const contractFn = testContract.batchFillOrders(orders, fillAmounts, signatures); + const actualResult = await contractFn.callAsync(); + const receipt = await contractFn.awaitTransactionSuccessAsync(); expect(actualResult).to.deep.eq(expectedResult); assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); }); @@ -312,12 +284,7 @@ blockchainTests('Exchange wrapper functions unit tests.', env => { const fillAmounts = _.times(COUNT - 1, i => orders[i].takerAssetAmount); const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); const expectedError = new AnyRevertError(); // Just a generic revert. - const tx = transactionHelper.getResultAndReceiptAsync( - testContract.batchFillOrders, - orders, - fillAmounts, - signatures, - ); + const tx = testContract.batchFillOrders(orders, fillAmounts, signatures).awaitTransactionSuccessAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -327,24 +294,16 @@ blockchainTests('Exchange wrapper functions unit tests.', env => { const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); const signatures = _.times(COUNT - 1, i => createOrderSignature(orders[i])); const expectedError = new AnyRevertError(); // Just a generic revert. - const tx = transactionHelper.getResultAndReceiptAsync( - testContract.batchFillOrders, - orders, - fillAmounts, - signatures, - ); + const tx = testContract.batchFillOrders(orders, fillAmounts, signatures).awaitTransactionSuccessAsync(); return expect(tx).to.revertWith(expectedError); }); }); describe('batchFillOrKillOrders', () => { it('works with no fills', async () => { - const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( - testContract.batchFillOrKillOrders, - [], - [], - [], - ); + const contractFn = testContract.batchFillOrKillOrders([], [], []); + const actualResult = await contractFn.callAsync(); + const receipt = await contractFn.awaitTransactionSuccessAsync(); expect(actualResult).to.deep.eq([]); assertFillOrderCallsFromLogs(receipt.logs, []); }); @@ -356,12 +315,9 @@ blockchainTests('Exchange wrapper functions unit tests.', env => { const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); const expectedCalls = _.zip(orders, fillAmounts, signatures); - const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( - testContract.batchFillOrKillOrders, - orders, - fillAmounts, - signatures, - ); + const contractFn = testContract.batchFillOrKillOrders(orders, fillAmounts, signatures); + const actualResult = await contractFn.callAsync(); + const receipt = await contractFn.awaitTransactionSuccessAsync(); expect(actualResult).to.deep.eq(expectedResult); assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); }); @@ -373,12 +329,9 @@ blockchainTests('Exchange wrapper functions unit tests.', env => { const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); const expectedCalls = _.zip(orders, fillAmounts, signatures); - const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( - testContract.batchFillOrKillOrders, - orders, - fillAmounts, - signatures, - ); + const contractFn = testContract.batchFillOrKillOrders(orders, fillAmounts, signatures); + const actualResult = await contractFn.callAsync(); + const receipt = await contractFn.awaitTransactionSuccessAsync(); expect(actualResult).to.deep.eq(expectedResult); assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); }); @@ -392,12 +345,9 @@ blockchainTests('Exchange wrapper functions unit tests.', env => { const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); const expectedCalls = _.zip(orders, fillAmounts, signatures); - const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( - testContract.batchFillOrKillOrders, - orders, - fillAmounts, - signatures, - ); + const contractFn = testContract.batchFillOrKillOrders(orders, fillAmounts, signatures); + const actualResult = await contractFn.callAsync(); + const receipt = await contractFn.awaitTransactionSuccessAsync(); expect(actualResult).to.deep.eq(expectedResult); assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); }); @@ -418,12 +368,9 @@ blockchainTests('Exchange wrapper functions unit tests.', env => { failingAmount, failingAmount.minus(1), ); - const tx = transactionHelper.getResultAndReceiptAsync( - testContract.batchFillOrKillOrders, - orders, - fillAmounts, - signatures, - ); + const tx = testContract + .batchFillOrKillOrders(orders, fillAmounts, signatures) + .awaitTransactionSuccessAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -443,12 +390,9 @@ blockchainTests('Exchange wrapper functions unit tests.', env => { failingAmount, failingAmount.plus(1), ); - const tx = transactionHelper.getResultAndReceiptAsync( - testContract.batchFillOrKillOrders, - orders, - fillAmounts, - signatures, - ); + const tx = testContract + .batchFillOrKillOrders(orders, fillAmounts, signatures) + .awaitTransactionSuccessAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -458,12 +402,9 @@ blockchainTests('Exchange wrapper functions unit tests.', env => { const fillAmounts = _.times(COUNT - 1, i => orders[i].takerAssetAmount); const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); const expectedError = new AnyRevertError(); // Just a generic revert. - const tx = transactionHelper.getResultAndReceiptAsync( - testContract.batchFillOrKillOrders, - orders, - fillAmounts, - signatures, - ); + const tx = testContract + .batchFillOrKillOrders(orders, fillAmounts, signatures) + .awaitTransactionSuccessAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -473,24 +414,18 @@ blockchainTests('Exchange wrapper functions unit tests.', env => { const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); const signatures = _.times(COUNT - 1, i => createOrderSignature(orders[i])); const expectedError = new AnyRevertError(); // Just a generic revert. - const tx = transactionHelper.getResultAndReceiptAsync( - testContract.batchFillOrKillOrders, - orders, - fillAmounts, - signatures, - ); + const tx = testContract + .batchFillOrKillOrders(orders, fillAmounts, signatures) + .awaitTransactionSuccessAsync(); return expect(tx).to.revertWith(expectedError); }); }); describe('batchFillOrdersNoThrow', () => { it('works with no fills', async () => { - const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( - testContract.batchFillOrdersNoThrow, - [], - [], - [], - ); + const contractFn = testContract.batchFillOrdersNoThrow([], [], []); + const actualResult = await contractFn.callAsync(); + const receipt = await contractFn.awaitTransactionSuccessAsync(); expect(actualResult).to.deep.eq([]); assertFillOrderCallsFromLogs(receipt.logs, []); }); @@ -502,12 +437,9 @@ blockchainTests('Exchange wrapper functions unit tests.', env => { const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); const expectedCalls = _.zip(orders, fillAmounts, signatures); - const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( - testContract.batchFillOrdersNoThrow, - orders, - fillAmounts, - signatures, - ); + const contractFn = testContract.batchFillOrdersNoThrow(orders, fillAmounts, signatures); + const actualResult = await contractFn.callAsync(); + const receipt = await contractFn.awaitTransactionSuccessAsync(); expect(actualResult).to.deep.eq(expectedResult); assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); }); @@ -519,12 +451,9 @@ blockchainTests('Exchange wrapper functions unit tests.', env => { const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); const expectedCalls = _.zip(orders, fillAmounts, signatures); - const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( - testContract.batchFillOrdersNoThrow, - orders, - fillAmounts, - signatures, - ); + const contractFn = testContract.batchFillOrdersNoThrow(orders, fillAmounts, signatures); + const actualResult = await contractFn.callAsync(); + const receipt = await contractFn.awaitTransactionSuccessAsync(); expect(actualResult).to.deep.eq(expectedResult); assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); }); @@ -538,12 +467,9 @@ blockchainTests('Exchange wrapper functions unit tests.', env => { const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); const expectedCalls = _.zip(orders, fillAmounts, signatures); - const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( - testContract.batchFillOrdersNoThrow, - orders, - fillAmounts, - signatures, - ); + const contractFn = testContract.batchFillOrdersNoThrow(orders, fillAmounts, signatures); + const actualResult = await contractFn.callAsync(); + const receipt = await contractFn.awaitTransactionSuccessAsync(); expect(actualResult).to.deep.eq(expectedResult); assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); }); @@ -559,12 +485,9 @@ blockchainTests('Exchange wrapper functions unit tests.', env => { const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i])); const expectedCalls = _.zip(orders, fillAmounts, signatures); expectedCalls.splice(FAILING_ORDER_INDEX, 1); - const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( - testContract.batchFillOrdersNoThrow, - orders, - fillAmounts, - signatures, - ); + const contractFn = testContract.batchFillOrdersNoThrow(orders, fillAmounts, signatures); + const actualResult = await contractFn.callAsync(); + const receipt = await contractFn.awaitTransactionSuccessAsync(); expect(actualResult).to.deep.eq(expectedResult); assertFillOrderCallsFromLogs(receipt.logs, expectedCalls as any); }); @@ -575,12 +498,9 @@ blockchainTests('Exchange wrapper functions unit tests.', env => { const fillAmounts = _.times(COUNT - 1, i => orders[i].takerAssetAmount); const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); const expectedError = new AnyRevertError(); // Just a generic revert. - const tx = transactionHelper.getResultAndReceiptAsync( - testContract.batchFillOrdersNoThrow, - orders, - fillAmounts, - signatures, - ); + const tx = testContract + .batchFillOrdersNoThrow(orders, fillAmounts, signatures) + .awaitTransactionSuccessAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -590,24 +510,21 @@ blockchainTests('Exchange wrapper functions unit tests.', env => { const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount); const signatures = _.times(COUNT - 1, i => createOrderSignature(orders[i])); const expectedError = new AnyRevertError(); // Just a generic revert. - const tx = transactionHelper.getResultAndReceiptAsync( - testContract.batchFillOrdersNoThrow, - orders, - fillAmounts, - signatures, - ); + const tx = testContract + .batchFillOrdersNoThrow(orders, fillAmounts, signatures) + .awaitTransactionSuccessAsync(); return expect(tx).to.revertWith(expectedError); }); }); type ExpectedFillOrderCallArgs = [Order, BigNumber, string]; type MarketSellBuyArgs = [Order[], BigNumber, string[], ...any[]]; - type MarketSellBuyContractFunction = () => MutatorContractFunction; + type MarketSellBuyContractFn = (...args: MarketSellBuyArgs) => ContractTxFunctionObj; type MarketSellBuySimulator = (...args: MarketSellBuyArgs) => [FillResults, ExpectedFillOrderCallArgs[]]; describe('marketSell*', () => { function defineCommonMarketSellOrdersTests( - getContractFn: MarketSellBuyContractFunction, + getContractFn: () => MarketSellBuyContractFn, simulator: MarketSellBuySimulator, ): void { it('works with one order', async () => { @@ -621,12 +538,9 @@ blockchainTests('Exchange wrapper functions unit tests.', env => { ); const [expectedResult, expectedCalls] = simulator(orders, takerAssetFillAmount, signatures); expect(expectedCalls.length).to.eq(COUNT); - const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( - getContractFn(), - orders, - takerAssetFillAmount, - signatures, - ); + const fnWithArgs = getContractFn()(orders, takerAssetFillAmount, signatures); + const actualResult = await fnWithArgs.callAsync(); + const receipt = await fnWithArgs.awaitTransactionSuccessAsync(); expect(actualResult).to.deep.eq(expectedResult); assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); }); @@ -642,12 +556,9 @@ blockchainTests('Exchange wrapper functions unit tests.', env => { ); const [expectedResult, expectedCalls] = simulator(orders, takerAssetFillAmount, signatures); expect(expectedCalls.length).to.eq(COUNT); - const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( - getContractFn(), - orders, - takerAssetFillAmount, - signatures, - ); + const fnWithArgs = getContractFn()(orders, takerAssetFillAmount, signatures); + const actualResult = await fnWithArgs.callAsync(); + const receipt = await fnWithArgs.awaitTransactionSuccessAsync(); expect(actualResult).to.deep.eq(expectedResult); assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); }); @@ -665,12 +576,9 @@ blockchainTests('Exchange wrapper functions unit tests.', env => { ); const [expectedResult, expectedCalls] = simulator(orders, takerAssetFillAmount, signatures); expect(expectedCalls.length).to.eq(COUNT); - const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( - getContractFn(), - orders, - takerAssetFillAmount, - signatures, - ); + const fnWithArgs = getContractFn()(orders, takerAssetFillAmount, signatures); + const actualResult = await fnWithArgs.callAsync(); + const receipt = await fnWithArgs.awaitTransactionSuccessAsync(); expect(actualResult).to.deep.eq(expectedResult); assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); }); @@ -688,12 +596,9 @@ blockchainTests('Exchange wrapper functions unit tests.', env => { const [expectedResult, expectedCalls] = simulator(orders, takerAssetFillAmount, signatures); // It should stop filling after the penultimate order. expect(expectedCalls.length).to.eq(COUNT - 1); - const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( - getContractFn(), - orders, - takerAssetFillAmount, - signatures, - ); + const fnWithArgs = getContractFn()(orders, takerAssetFillAmount, signatures); + const actualResult = await fnWithArgs.callAsync(); + const receipt = await fnWithArgs.awaitTransactionSuccessAsync(); expect(actualResult).to.deep.eq(expectedResult); assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); }); @@ -714,12 +619,9 @@ blockchainTests('Exchange wrapper functions unit tests.', env => { const [expectedResult, expectedCalls] = simulator(orders, takerAssetFillAmount, signatures); // It should stop filling after first order. expect(expectedCalls.length).to.eq(1); - const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( - getContractFn(), - orders, - takerAssetFillAmount, - signatures, - ); + const fnWithArgs = getContractFn()(orders, takerAssetFillAmount, signatures); + const actualResult = await fnWithArgs.callAsync(); + const receipt = await fnWithArgs.awaitTransactionSuccessAsync(); expect(actualResult).to.deep.eq(expectedResult); assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); }); @@ -735,25 +637,16 @@ blockchainTests('Exchange wrapper functions unit tests.', env => { orders[0].takerAssetAmount, orders[1].takerAssetAmount, ); - const tx = transactionHelper.getResultAndReceiptAsync( - getContractFn(), - orders, - takerAssetFillAmount, - signatures, - ); + const tx = getContractFn()(orders, takerAssetFillAmount, signatures).awaitTransactionSuccessAsync(); return expect(tx).to.revertWith(expectedError); }); it('returns empty fill results with no orders', async () => { const [expectedResult, expectedCalls] = simulator([], constants.ZERO_AMOUNT, []); expect(expectedCalls.length).to.eq(0); - const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( - getContractFn(), - [], - constants.ZERO_AMOUNT, - [], - ); - + const fnWithArgs = getContractFn()([], constants.ZERO_AMOUNT, []); + const actualResult = await fnWithArgs.callAsync(); + const receipt = await fnWithArgs.awaitTransactionSuccessAsync(); expect(actualResult).to.deep.eq(expectedResult); assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); }); @@ -802,12 +695,9 @@ blockchainTests('Exchange wrapper functions unit tests.', env => { signatures, ); expect(expectedCalls.length).to.eq(COUNT - BAD_ORDERS_COUNT); - const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( - testContract.marketSellOrdersNoThrow, - orders, - takerAssetFillAmount, - signatures, - ); + const contractFn = testContract.marketSellOrdersNoThrow(orders, takerAssetFillAmount, signatures); + const actualResult = await contractFn.callAsync(); + const receipt = await contractFn.awaitTransactionSuccessAsync(); expect(actualResult).to.deep.eq(expectedResult); assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); }); @@ -827,12 +717,9 @@ blockchainTests('Exchange wrapper functions unit tests.', env => { signatures, ); expect(expectedCalls.length).to.eq(0); - const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( - testContract.marketSellOrdersNoThrow, - orders, - takerAssetFillAmount, - signatures, - ); + const contractFn = testContract.marketSellOrdersNoThrow(orders, takerAssetFillAmount, signatures); + const actualResult = await contractFn.callAsync(); + const receipt = await contractFn.awaitTransactionSuccessAsync(); expect(actualResult).to.deep.eq(expectedResult); assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); }); @@ -855,12 +742,9 @@ blockchainTests('Exchange wrapper functions unit tests.', env => { takerAssetFillAmount, takerAssetFillAmount.minus(1), ); - const tx = transactionHelper.getResultAndReceiptAsync( - testContract.marketSellOrdersFillOrKill, - orders, - takerAssetFillAmount, - signatures, - ); + const tx = testContract + .marketSellOrdersFillOrKill(orders, takerAssetFillAmount, signatures) + .awaitTransactionSuccessAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -884,12 +768,9 @@ blockchainTests('Exchange wrapper functions unit tests.', env => { signatures, ); expect(expectedCalls.length).to.eq(COUNT - BAD_ORDERS_COUNT); - const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( - testContract.marketSellOrdersFillOrKill, - orders, - takerAssetFillAmount, - signatures, - ); + const contractFn = testContract.marketSellOrdersFillOrKill(orders, takerAssetFillAmount, signatures); + const actualResult = await contractFn.callAsync(); + const receipt = await contractFn.awaitTransactionSuccessAsync(); expect(actualResult).to.deep.eq(expectedResult); assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); }); @@ -920,12 +801,9 @@ blockchainTests('Exchange wrapper functions unit tests.', env => { takerAssetFillAmount, takerAssetFillAmount.minus(1), ); - const tx = transactionHelper.getResultAndReceiptAsync( - testContract.marketSellOrdersFillOrKill, - orders, - takerAssetFillAmount, - signatures, - ); + const tx = testContract + .marketSellOrdersFillOrKill(orders, takerAssetFillAmount, signatures) + .awaitTransactionSuccessAsync(); return expect(tx).to.revertWith(expectedError); }); }); @@ -933,7 +811,7 @@ blockchainTests('Exchange wrapper functions unit tests.', env => { describe('marketBuy*', () => { function defineCommonMarketBuyOrdersTests( - getContractFn: MarketSellBuyContractFunction, + getContractFn: () => MarketSellBuyContractFn, simulator: MarketSellBuySimulator, ): void { it('works with one order', async () => { @@ -947,12 +825,10 @@ blockchainTests('Exchange wrapper functions unit tests.', env => { ); const [expectedResult, expectedCalls] = simulator(orders, makerAssetFillAmount, signatures); expect(expectedCalls.length).to.eq(COUNT); - const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( - getContractFn(), - orders, - makerAssetFillAmount, - signatures, - ); + const fnWithArgs = getContractFn()(orders, makerAssetFillAmount, signatures); + const actualResult = await fnWithArgs.callAsync(); + const receipt = await fnWithArgs.awaitTransactionSuccessAsync(); + expect(actualResult).to.deep.eq(expectedResult); assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); }); @@ -968,12 +844,9 @@ blockchainTests('Exchange wrapper functions unit tests.', env => { ); const [expectedResult, expectedCalls] = simulator(orders, makerAssetFillAmount, signatures); expect(expectedCalls.length).to.eq(COUNT); - const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( - getContractFn(), - orders, - makerAssetFillAmount, - signatures, - ); + const fnWithArgs = getContractFn()(orders, makerAssetFillAmount, signatures); + const actualResult = await fnWithArgs.callAsync(); + const receipt = await fnWithArgs.awaitTransactionSuccessAsync(); expect(actualResult).to.deep.eq(expectedResult); assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); }); @@ -991,12 +864,9 @@ blockchainTests('Exchange wrapper functions unit tests.', env => { ); const [expectedResult, expectedCalls] = simulator(orders, makerAssetFillAmount, signatures); expect(expectedCalls.length).to.eq(COUNT); - const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( - getContractFn(), - orders, - makerAssetFillAmount, - signatures, - ); + const fnWithArgs = getContractFn()(orders, makerAssetFillAmount, signatures); + const actualResult = await fnWithArgs.callAsync(); + const receipt = await fnWithArgs.awaitTransactionSuccessAsync(); expect(actualResult).to.deep.eq(expectedResult); assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); }); @@ -1014,12 +884,9 @@ blockchainTests('Exchange wrapper functions unit tests.', env => { const [expectedResult, expectedCalls] = simulator(orders, makerAssetFillAmount, signatures); // It should stop filling after the penultimate order. expect(expectedCalls.length).to.eq(COUNT - 1); - const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( - getContractFn(), - orders, - makerAssetFillAmount, - signatures, - ); + const fnWithArgs = getContractFn()(orders, makerAssetFillAmount, signatures); + const actualResult = await fnWithArgs.callAsync(); + const receipt = await fnWithArgs.awaitTransactionSuccessAsync(); expect(actualResult).to.deep.eq(expectedResult); assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); }); @@ -1040,12 +907,9 @@ blockchainTests('Exchange wrapper functions unit tests.', env => { const [expectedResult, expectedCalls] = simulator(orders, makerAssetFillAmount, signatures); // It should stop filling after first order. expect(expectedCalls.length).to.eq(1); - const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( - getContractFn(), - orders, - makerAssetFillAmount, - signatures, - ); + const fnWithArgs = getContractFn()(orders, makerAssetFillAmount, signatures); + const actualResult = await fnWithArgs.callAsync(); + const receipt = await fnWithArgs.awaitTransactionSuccessAsync(); expect(actualResult).to.deep.eq(expectedResult); assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); }); @@ -1059,12 +923,7 @@ blockchainTests('Exchange wrapper functions unit tests.', env => { orders[0].takerAssetAmount, makerAssetFillAmount, ); - const tx = transactionHelper.getResultAndReceiptAsync( - getContractFn(), - orders, - makerAssetFillAmount, - signatures, - ); + const tx = getContractFn()(orders, makerAssetFillAmount, signatures).awaitTransactionSuccessAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -1077,12 +936,7 @@ blockchainTests('Exchange wrapper functions unit tests.', env => { orders[0].takerAssetAmount.times(makerAssetFillAmount), orders[0].makerAssetAmount, ); - const tx = transactionHelper.getResultAndReceiptAsync( - getContractFn(), - orders, - makerAssetFillAmount, - signatures, - ); + const tx = getContractFn()(orders, makerAssetFillAmount, signatures).awaitTransactionSuccessAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -1104,25 +958,16 @@ blockchainTests('Exchange wrapper functions unit tests.', env => { orders[0].makerAssetAmount, orders[1].makerAssetAmount, ); - const tx = transactionHelper.getResultAndReceiptAsync( - getContractFn(), - orders, - makerAssetFillAmount, - signatures, - ); + const tx = getContractFn()(orders, makerAssetFillAmount, signatures).awaitTransactionSuccessAsync(); return expect(tx).to.revertWith(expectedError); }); it('returns empty fill results with no orders', async () => { const [expectedResult, expectedCalls] = simulator([], constants.ZERO_AMOUNT, []); expect(expectedCalls.length).to.eq(0); - const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( - getContractFn(), - [], - constants.ZERO_AMOUNT, - [], - ); - + const fnWithArgs = getContractFn()([], constants.ZERO_AMOUNT, []); + const actualResult = await fnWithArgs.callAsync(); + const receipt = await fnWithArgs.awaitTransactionSuccessAsync(); expect(actualResult).to.deep.eq(expectedResult); assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); }); @@ -1176,12 +1021,9 @@ blockchainTests('Exchange wrapper functions unit tests.', env => { signatures, ); expect(expectedCalls.length).to.eq(COUNT - BAD_ORDERS_COUNT); - const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( - testContract.marketBuyOrdersNoThrow, - orders, - makerAssetFillAmount, - signatures, - ); + const contractFn = testContract.marketBuyOrdersNoThrow(orders, makerAssetFillAmount, signatures); + const actualResult = await contractFn.callAsync(); + const receipt = await contractFn.awaitTransactionSuccessAsync(); expect(actualResult).to.deep.eq(expectedResult); assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); }); @@ -1201,22 +1043,16 @@ blockchainTests('Exchange wrapper functions unit tests.', env => { signatures, ); expect(expectedCalls.length).to.eq(0); - const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( - testContract.marketBuyOrdersNoThrow, - orders, - makerAssetFillAmount, - signatures, - ); + const contractFn = testContract.marketBuyOrdersNoThrow(orders, makerAssetFillAmount, signatures); + const actualResult = await contractFn.callAsync(); + const receipt = await contractFn.awaitTransactionSuccessAsync(); expect(actualResult).to.deep.eq(expectedResult); assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); }); }); describe('marketBuyOrdersFillOrKill', () => { - defineCommonMarketBuyOrdersTests( - () => testContract.marketBuyOrdersFillOrKill, - simulateMarketBuyOrdersNoThrow, - ); + defineCommonMarketBuyOrdersTests(() => testContract.marketBuyOrdersFillOrKill, simulateMarketBuyOrdersNoThrow); it('reverts when filled < `makerAssetFillAmount`', async () => { const COUNT = 4; @@ -1232,12 +1068,9 @@ blockchainTests('Exchange wrapper functions unit tests.', env => { makerAssetFillAmount, makerAssetFillAmount.minus(1), ); - const tx = transactionHelper.getResultAndReceiptAsync( - testContract.marketBuyOrdersFillOrKill, - orders, - makerAssetFillAmount, - signatures, - ); + const tx = testContract + .marketBuyOrdersFillOrKill(orders, makerAssetFillAmount, signatures) + .awaitTransactionSuccessAsync(); return expect(tx).to.revertWith(expectedError); }); @@ -1261,12 +1094,9 @@ blockchainTests('Exchange wrapper functions unit tests.', env => { signatures, ); expect(expectedCalls.length).to.eq(COUNT - BAD_ORDERS_COUNT); - const [actualResult, receipt] = await transactionHelper.getResultAndReceiptAsync( - testContract.marketBuyOrdersFillOrKill, - orders, - makerAssetFillAmount, - signatures, - ); + const fnWithArgs = testContract.marketBuyOrdersFillOrKill(orders, makerAssetFillAmount, signatures); + const actualResult = await fnWithArgs.callAsync(); + const receipt = await fnWithArgs.awaitTransactionSuccessAsync(); expect(actualResult).to.deep.eq(expectedResult); assertFillOrderCallsFromLogs(receipt.logs, expectedCalls); }); @@ -1297,12 +1127,9 @@ blockchainTests('Exchange wrapper functions unit tests.', env => { makerAssetFillAmount, makerAssetFillAmount.minus(1), ); - const tx = transactionHelper.getResultAndReceiptAsync( - testContract.marketBuyOrdersFillOrKill, - orders, - makerAssetFillAmount, - signatures, - ); + const tx = testContract + .marketBuyOrdersFillOrKill(orders, makerAssetFillAmount, signatures) + .awaitTransactionSuccessAsync(); return expect(tx).to.revertWith(expectedError); }); }); @@ -1322,18 +1149,15 @@ blockchainTests('Exchange wrapper functions unit tests.', env => { } it('works with no orders', async () => { - const [, receipt] = await transactionHelper.getResultAndReceiptAsync(testContract.batchCancelOrders, []); - assertCancelOrderCallsFromLogs(receipt.logs, []); + const { logs } = await testContract.batchCancelOrders([]).awaitTransactionSuccessAsync(); + assertCancelOrderCallsFromLogs(logs, []); }); it('works with many orders', async () => { const COUNT = 8; const orders = _.times(COUNT, () => randomOrder({ makerAddress: senderAddress })); - const [, receipt] = await transactionHelper.getResultAndReceiptAsync( - testContract.batchCancelOrders, - orders, - ); - assertCancelOrderCallsFromLogs(receipt.logs, orders); + const { logs } = await testContract.batchCancelOrders(orders).awaitTransactionSuccessAsync(); + assertCancelOrderCallsFromLogs(logs, orders); }); it('works with duplicate orders', async () => { @@ -1341,11 +1165,8 @@ blockchainTests('Exchange wrapper functions unit tests.', env => { const COUNT = 6; const uniqueOrders = _.times(UNIQUE_ORDERS, () => randomOrder({ makerAddress: senderAddress })); const orders = _.shuffle(_.flatten(_.times(COUNT / UNIQUE_ORDERS, () => uniqueOrders))); - const [, receipt] = await transactionHelper.getResultAndReceiptAsync( - testContract.batchCancelOrders, - orders, - ); - assertCancelOrderCallsFromLogs(receipt.logs, orders); + const { logs } = await testContract.batchCancelOrders(orders).awaitTransactionSuccessAsync(); + assertCancelOrderCallsFromLogs(logs, orders); }); it('reverts if one `_cancelOrder()` reverts', async () => { @@ -1355,7 +1176,7 @@ blockchainTests('Exchange wrapper functions unit tests.', env => { const failingOrder = orders[FAILING_ORDER_INDEX]; failingOrder.salt = ALWAYS_FAILING_SALT; const expectedError = ALWAYS_FAILING_SALT_REVERT_ERROR; - const tx = transactionHelper.getResultAndReceiptAsync(testContract.batchCancelOrders, orders); + const tx = testContract.batchCancelOrders(orders).awaitTransactionSuccessAsync(); return expect(tx).to.revertWith(expectedError); }); }); diff --git a/contracts/integrations/test/internal-integration-tests/exchange_wrapper_test.ts b/contracts/integrations/test/internal-integration-tests/exchange_wrapper_test.ts index bd275400b3..9d9ba0a19f 100644 --- a/contracts/integrations/test/internal-integration-tests/exchange_wrapper_test.ts +++ b/contracts/integrations/test/internal-integration-tests/exchange_wrapper_test.ts @@ -1,15 +1,12 @@ -import { artifacts as assetProxyArtifacts } from '@0x/contracts-asset-proxy'; import { DevUtilsContract } from '@0x/contracts-dev-utils'; import { IERC20TokenEvents, IERC20TokenTransferEventArgs } from '@0x/contracts-erc20'; import { - artifacts as exchangeArtifacts, BlockchainBalanceStore, IExchangeEvents, IExchangeFillEventArgs, LocalBalanceStore, } from '@0x/contracts-exchange'; import { ReferenceFunctions } from '@0x/contracts-exchange-libs'; -import { artifacts as stakingArtifacts } from '@0x/contracts-staking'; import { blockchainTests, constants, @@ -19,7 +16,6 @@ import { Numberish, provider, toBaseUnitAmount, - transactionHelper, verifyEvents, } from '@0x/contracts-test-utils'; import { ExchangeRevertErrors, orderHashUtils } from '@0x/order-utils'; @@ -317,13 +313,14 @@ blockchainTests.resets('Exchange wrappers', env => { }); const takerAssetFilledAmount = signedOrder.takerAssetAmount.div(5); - const [fillResults, receipt] = await transactionHelper.getResultAndReceiptAsync( - deployment.exchange.fillOrKillOrder.bind(deployment.exchange), + const contractFn = deployment.exchange.fillOrKillOrder( signedOrder, takerAssetFilledAmount, signedOrder.signature, - { from: taker.address, gasPrice: DeploymentManager.gasPrice, value }, ); + const callData = { from: taker.address, gasPrice: DeploymentManager.gasPrice, value }; + const fillResults = await contractFn.callAsync(callData); + const receipt = await contractFn.awaitTransactionSuccessAsync(callData); const expectedFillResults = calculateScaledFillResultsWithTaker(signedOrder, takerAssetFilledAmount); @@ -436,20 +433,20 @@ blockchainTests.resets('Exchange wrappers', env => { await simulateFillAsync(signedOrder, expectedFillResults, shouldPayWethFees); } - const [fillResults, receipt] = await transactionHelper.getResultAndReceiptAsync( - deployment.exchange.batchFillOrders.bind(deployment.exchange), + const contractFn = deployment.exchange.batchFillOrders( signedOrders, takerAssetFillAmounts, signedOrders.map(signedOrder => signedOrder.signature), - { - from: taker.address, - gasPrice: DeploymentManager.gasPrice, - value, - }, ); + const callData = { + from: taker.address, + gasPrice: DeploymentManager.gasPrice, + value, + }; + const fillResults = await contractFn.callAsync(callData); + const receipt = await contractFn.awaitTransactionSuccessAsync(callData); expect(totalFillResults).to.be.deep.eq(fillResults); - await assertResultsAsync(receipt, fillTestInfo); } @@ -498,17 +495,18 @@ blockchainTests.resets('Exchange wrappers', env => { await simulateFillAsync(signedOrder, expectedFillResults, shouldPayWethFees); } - const [fillResults, receipt] = await transactionHelper.getResultAndReceiptAsync( - deployment.exchange.batchFillOrKillOrders.bind(deployment.exchange), + const contractFn = deployment.exchange.batchFillOrKillOrders( signedOrders, takerAssetFillAmounts, signedOrders.map(order => order.signature), - { - from: taker.address, - gasPrice: DeploymentManager.gasPrice, - value, - }, ); + const callData = { + from: taker.address, + gasPrice: DeploymentManager.gasPrice, + value, + }; + const fillResults = await contractFn.callAsync(callData); + const receipt = await contractFn.awaitTransactionSuccessAsync(callData); expect(totalFillResults).to.be.deep.eq(fillResults); @@ -594,19 +592,20 @@ blockchainTests.resets('Exchange wrappers', env => { } } - const [fillResults, receipt] = await transactionHelper.getResultAndReceiptAsync( - deployment.exchange.batchFillOrdersNoThrow.bind(deployment.exchange), + const contractFn = deployment.exchange.batchFillOrdersNoThrow( signedOrdersWithValidity.map(signedOrderWithValidity => signedOrderWithValidity.signedOrder), takerAssetFillAmounts, signedOrdersWithValidity.map( signedOrderWithValidity => signedOrderWithValidity.signedOrder.signature, ), - { - from: taker.address, - gasPrice: DeploymentManager.gasPrice, - value, - }, ); + const callData = { + from: taker.address, + gasPrice: DeploymentManager.gasPrice, + value, + }; + const fillResults = await contractFn.callAsync(callData); + const receipt = await contractFn.awaitTransactionSuccessAsync(callData); expect(totalFillResults).to.be.deep.eq(fillResults); @@ -709,18 +708,18 @@ blockchainTests.resets('Exchange wrappers', env => { } } - const [fillResults, receipt] = await transactionHelper.getResultAndReceiptAsync( - deployment.exchange.marketSellOrdersNoThrow.bind(deployment.exchange), + const contractFn = deployment.exchange.marketSellOrdersNoThrow( signedOrdersWithValidity.map(orderWithValidity => orderWithValidity.signedOrder), takerAssetFillAmount, signedOrdersWithValidity.map(orderWithValidity => orderWithValidity.signedOrder.signature), - { - from: taker.address, - gasPrice: DeploymentManager.gasPrice, - value, - }, ); - + const callData = { + from: taker.address, + gasPrice: DeploymentManager.gasPrice, + value, + }; + const fillResults = await contractFn.callAsync(callData); + const receipt = await contractFn.awaitTransactionSuccessAsync(callData); expect(fillResults).to.deep.equal(totalFillResults); await assertResultsAsync(receipt, fillTestInfo); @@ -907,18 +906,18 @@ blockchainTests.resets('Exchange wrappers', env => { } } - const [fillResults, receipt] = await transactionHelper.getResultAndReceiptAsync( - deployment.exchange.marketBuyOrdersNoThrow.bind(deployment.exchange), + const contractFn = deployment.exchange.marketBuyOrdersNoThrow( signedOrdersWithValidity.map(orderWithValidity => orderWithValidity.signedOrder), makerAssetFillAmount, signedOrdersWithValidity.map(orderWithValidity => orderWithValidity.signedOrder.signature), - { - from: taker.address, - gasPrice: DeploymentManager.gasPrice, - value, - }, ); - + const callData = { + from: taker.address, + gasPrice: DeploymentManager.gasPrice, + value, + }; + const fillResults = await contractFn.callAsync(callData); + const receipt = await contractFn.awaitTransactionSuccessAsync(callData); expect(fillResults).to.deep.equal(totalFillResults); await assertResultsAsync(receipt, fillTestInfo); diff --git a/contracts/staking/test/unit_tests/mixin_staking_pool_rewards.ts b/contracts/staking/test/unit_tests/mixin_staking_pool_rewards.ts index e6d7ba80f4..dbe5d8b796 100644 --- a/contracts/staking/test/unit_tests/mixin_staking_pool_rewards.ts +++ b/contracts/staking/test/unit_tests/mixin_staking_pool_rewards.ts @@ -8,7 +8,6 @@ import { hexRandom, Numberish, randomAddress, - transactionHelper, verifyEventsFromLogs, } from '@0x/contracts-test-utils'; import { BigNumber } from '@0x/utils'; @@ -365,13 +364,14 @@ blockchainTests.resets('MixinStakingPoolRewards unit tests', env => { reward: Numberish, membersStake: Numberish, ): Promise<[[BigNumber, BigNumber], LogEntry[]]> { - const [result, receipt] = await transactionHelper.getResultAndReceiptAsync( - testContract.syncPoolRewards.bind(testContract), + const contractFn = testContract.syncPoolRewards( POOL_ID, new BigNumber(reward), new BigNumber(membersStake), ); - return [result, receipt.logs]; + const result = await contractFn.callAsync(); + const { logs } = await contractFn.awaitTransactionSuccessAsync(); + return [result, logs]; } it("transfers operator's portion of the reward to the operator", async () => { diff --git a/contracts/test-utils/src/index.ts b/contracts/test-utils/src/index.ts index ec7c8afc30..eb8873e636 100644 --- a/contracts/test-utils/src/index.ts +++ b/contracts/test-utils/src/index.ts @@ -26,7 +26,6 @@ export { randomAddress } from './address_utils'; export { OrderFactory } from './order_factory'; export { bytes32Values, testCombinatoriallyWithReferenceFunc, uint256Values } from './combinatorial_utils'; export { TransactionFactory } from './transaction_factory'; -export { MutatorContractFunction, transactionHelper } from './transaction_helper'; export { testWithReferenceFuncAsync } from './test_with_reference'; export { hexConcat, diff --git a/contracts/test-utils/src/transaction_helper.ts b/contracts/test-utils/src/transaction_helper.ts deleted file mode 100644 index b76e625588..0000000000 --- a/contracts/test-utils/src/transaction_helper.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { ContractTxFunctionObj } from '@0x/base-contract'; -import { TransactionReceiptWithDecodedLogs } from 'ethereum-types'; - -export type MutatorContractFunction = (...args: any[]) => ContractTxFunctionObj; -/** - * Helper class for performing non-constant contract functions calls. - */ -export const transactionHelper = { - async getResultAndReceiptAsync( - contractFunction: MutatorContractFunction, - ...args: any[] // tslint:disable-line:trailing-comma - ): Promise<[O, TransactionReceiptWithDecodedLogs]> { - // HACK(dorothy-zbornak): We take advantage of the general rule that - // the parameters for `callAsync()` are a subset of the - // parameters for `sendTransactionAsync()`. - const contractFunctionObj = contractFunction(...args); - const result = await contractFunctionObj.callAsync(); - const receipt = await contractFunctionObj.awaitTransactionSuccessAsync(); - return [result, receipt]; - }, -}; From c61ada8a133b8101f00de6162e1c320f3f62566a Mon Sep 17 00:00:00 2001 From: xianny Date: Wed, 13 Nov 2019 16:46:53 -0500 Subject: [PATCH 12/20] lint and update changelogs --- contracts/exchange/test/wrapper_unit_tests.ts | 5 ++++- contracts/staking/test/unit_tests/staking_proxy_test.ts | 2 +- contracts/test-utils/CHANGELOG.json | 6 +++++- packages/0x.js/src/index.ts | 5 ++++- .../src/generated-wrappers/asset_proxy_owner.ts | 4 ++-- .../src/generated-wrappers/coordinator.ts | 4 ++-- .../src/generated-wrappers/coordinator_registry.ts | 4 ++-- .../abi-gen-wrappers/src/generated-wrappers/dev_utils.ts | 4 ++-- .../src/generated-wrappers/dummy_erc20_token.ts | 4 ++-- .../src/generated-wrappers/dummy_erc721_token.ts | 4 ++-- .../src/generated-wrappers/dutch_auction.ts | 4 ++-- .../src/generated-wrappers/erc1155_mintable.ts | 4 ++-- .../src/generated-wrappers/erc1155_proxy.ts | 4 ++-- .../src/generated-wrappers/erc20_proxy.ts | 4 ++-- .../src/generated-wrappers/erc20_token.ts | 4 ++-- .../src/generated-wrappers/erc721_proxy.ts | 4 ++-- .../src/generated-wrappers/erc721_token.ts | 4 ++-- .../src/generated-wrappers/eth_balance_checker.ts | 4 ++-- .../abi-gen-wrappers/src/generated-wrappers/exchange.ts | 4 ++-- .../abi-gen-wrappers/src/generated-wrappers/forwarder.ts | 4 ++-- .../src/generated-wrappers/i_asset_proxy.ts | 4 ++-- .../src/generated-wrappers/i_validator.ts | 4 ++-- .../abi-gen-wrappers/src/generated-wrappers/i_wallet.ts | 4 ++-- .../src/generated-wrappers/multi_asset_proxy.ts | 4 ++-- .../src/generated-wrappers/order_validator.ts | 4 ++-- .../abi-gen-wrappers/src/generated-wrappers/staking.ts | 4 ++-- .../src/generated-wrappers/staking_proxy.ts | 4 ++-- .../src/generated-wrappers/static_call_proxy.ts | 4 ++-- packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts | 4 ++-- .../abi-gen-wrappers/src/generated-wrappers/zrx_token.ts | 4 ++-- packages/abi-gen/templates/TypeScript/contract.handlebars | 4 ++-- .../abi-gen/test-cli/output/typescript/abi_gen_dummy.ts | 4 ++-- packages/abi-gen/test-cli/output/typescript/lib_dummy.ts | 4 ++-- .../abi-gen/test-cli/output/typescript/test_lib_dummy.ts | 4 ++-- packages/base-contract/CHANGELOG.json | 8 ++++++++ packages/contract-wrappers/src/index.ts | 2 +- packages/monorepo-scripts/src/doc_gen_configs.ts | 6 ++++++ packages/monorepo-scripts/src/utils/doc_generate_utils.ts | 6 +++--- packages/types/CHANGELOG.json | 4 ---- 39 files changed, 92 insertions(+), 72 deletions(-) diff --git a/contracts/exchange/test/wrapper_unit_tests.ts b/contracts/exchange/test/wrapper_unit_tests.ts index e4e9931d63..df1f1bb6da 100644 --- a/contracts/exchange/test/wrapper_unit_tests.ts +++ b/contracts/exchange/test/wrapper_unit_tests.ts @@ -1052,7 +1052,10 @@ blockchainTests('Exchange wrapper functions unit tests.', env => { }); describe('marketBuyOrdersFillOrKill', () => { - defineCommonMarketBuyOrdersTests(() => testContract.marketBuyOrdersFillOrKill, simulateMarketBuyOrdersNoThrow); + defineCommonMarketBuyOrdersTests( + () => testContract.marketBuyOrdersFillOrKill, + simulateMarketBuyOrdersNoThrow, + ); it('reverts when filled < `makerAssetFillAmount`', async () => { const COUNT = 4; diff --git a/contracts/staking/test/unit_tests/staking_proxy_test.ts b/contracts/staking/test/unit_tests/staking_proxy_test.ts index d5333286de..7a4988531b 100644 --- a/contracts/staking/test/unit_tests/staking_proxy_test.ts +++ b/contracts/staking/test/unit_tests/staking_proxy_test.ts @@ -169,7 +169,7 @@ blockchainTests.resets('StakingProxy unit tests', env => { const calls = [testContract.echo(testString).getABIEncodedTransactionData()]; const rawResults = await testProxyContract.batchExecute(calls).callAsync(); expect(rawResults.length).to.equal(1); - const returnValues = [testContract.getABIDecodedReturnData('echo', rawResults[0])]; + const returnValues = [testContract.getABIDecodedReturnData<{}>('echo', rawResults[0])]; expect(returnValues[0]).to.equal(testString); }); diff --git a/contracts/test-utils/CHANGELOG.json b/contracts/test-utils/CHANGELOG.json index a3c37665ed..1f0cdec9d5 100644 --- a/contracts/test-utils/CHANGELOG.json +++ b/contracts/test-utils/CHANGELOG.json @@ -1,10 +1,14 @@ [ { - "version": "3.2.0-beta.1", + "version": "4.0.0-beta.0", "changes": [ { "note": "OrderFactory default order expiration time increased from ten minutes to fifteen minutes ", "pr": 2304 + }, + { + "note": "Remove TransactionHelper and MutatorContractFunction", + "pr": 2325 } ] }, diff --git a/packages/0x.js/src/index.ts b/packages/0x.js/src/index.ts index 4ba462c7f2..2cfcf925c7 100644 --- a/packages/0x.js/src/index.ts +++ b/packages/0x.js/src/index.ts @@ -46,13 +46,16 @@ export { ExchangeProtocolFeeCollectorAddressEventArgs, ExchangeProtocolFeeMultiplierEventArgs, ExchangeTransactionExecutionEventArgs, +} from '@0x/abi-gen-wrappers'; + +export { ContractEvent, SendTransactionOpts, AwaitTransactionSuccessOpts, ContractFunctionObj, ContractTxFunctionObj, SubscriptionErrors, -} from '@0x/abi-gen-wrappers'; +} from '@0x/base-contract'; export import Web3ProviderEngine = require('web3-provider-engine'); diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/asset_proxy_owner.ts b/packages/abi-gen-wrappers/src/generated-wrappers/asset_proxy_owner.ts index 95ea9c4cf9..e85a8c4d8e 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/asset_proxy_owner.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/asset_proxy_owner.ts @@ -126,7 +126,7 @@ export class AssetProxyOwnerContract extends BaseContract { * @ignore */ public static deployedBytecode: string | undefined; - private _methodABIIndex: { [name: string]: number } = {}; + private readonly _methodABIIndex: { [name: string]: number } = {}; private readonly _subscriptionManager: SubscriptionManager; public static async deployFrom0xArtifactAsync( artifact: ContractArtifact | SimpleContractArtifact, @@ -977,7 +977,7 @@ export class AssetProxyOwnerContract extends BaseContract { public getFunctionSignature(methodName: string): string { const index = this._methodABIIndex[methodName]; - const methodAbi = AssetProxyOwnerContract.ABI()[index] as MethodAbi; + const methodAbi = AssetProxyOwnerContract.ABI()[index] as MethodAbi; // tslint:disable-line:no-unnecessary-type-assertion const functionSignature = methodAbiToFunctionSignature(methodAbi); return functionSignature; } diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/coordinator.ts b/packages/abi-gen-wrappers/src/generated-wrappers/coordinator.ts index 34342cdc5a..66167d9d99 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/coordinator.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/coordinator.ts @@ -40,7 +40,7 @@ export class CoordinatorContract extends BaseContract { * @ignore */ public static deployedBytecode: string | undefined; - private _methodABIIndex: { [name: string]: number } = {}; + private readonly _methodABIIndex: { [name: string]: number } = {}; public static async deployFrom0xArtifactAsync( artifact: ContractArtifact | SimpleContractArtifact, supportedProvider: SupportedProvider, @@ -419,7 +419,7 @@ export class CoordinatorContract extends BaseContract { public getFunctionSignature(methodName: string): string { const index = this._methodABIIndex[methodName]; - const methodAbi = CoordinatorContract.ABI()[index] as MethodAbi; + const methodAbi = CoordinatorContract.ABI()[index] as MethodAbi; // tslint:disable-line:no-unnecessary-type-assertion const functionSignature = methodAbiToFunctionSignature(methodAbi); return functionSignature; } diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts b/packages/abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts index 77fce885f6..bcb482e3d3 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts @@ -53,7 +53,7 @@ export class CoordinatorRegistryContract extends BaseContract { * @ignore */ public static deployedBytecode: string | undefined; - private _methodABIIndex: { [name: string]: number } = {}; + private readonly _methodABIIndex: { [name: string]: number } = {}; private readonly _subscriptionManager: SubscriptionManager; public static async deployFrom0xArtifactAsync( artifact: ContractArtifact | SimpleContractArtifact, @@ -194,7 +194,7 @@ export class CoordinatorRegistryContract extends BaseContract { public getFunctionSignature(methodName: string): string { const index = this._methodABIIndex[methodName]; - const methodAbi = CoordinatorRegistryContract.ABI()[index] as MethodAbi; + const methodAbi = CoordinatorRegistryContract.ABI()[index] as MethodAbi; // tslint:disable-line:no-unnecessary-type-assertion const functionSignature = methodAbiToFunctionSignature(methodAbi); return functionSignature; } diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts b/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts index fcf60dbf0c..29c87879b8 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts @@ -41,7 +41,7 @@ export class DevUtilsContract extends BaseContract { */ public static deployedBytecode = '0x608060405234801561001057600080fd5b506004361061025c5760003560e01c80639a7e752611610145578063cafd3a07116100bd578063d3d862d11161008c578063e4e6e7da11610071578063e4e6e7da1461063a578063e77286eb1461065b578063ee4f5a941461067d5761025c565b8063d3d862d114610605578063e25cabf7146106185761025c565b8063cafd3a071461059e578063d001c5dc146105bf578063d186037f146105d2578063d3637905146105e55761025c565b8063a6627e9f11610114578063b43cffe1116100f9578063b43cffe114610548578063bbb2dcf61461055b578063bc03f9641461057d5761025c565b8063a6627e9f14610512578063acaedc74146105255761025c565b80639a7e7526146104985780639eadc835146104bb578063a0901e51146104df578063a5cd62ba146104f25761025c565b8063459be5e2116101d85780636f83188e116101a75780637b66ad341161018c5780637b66ad34146104515780637d727512146104725780638f4ce479146104855761025c565b80636f83188e1461040d5780637914b2ec146104305761025c565b8063459be5e21461038a5780634dfdac20146103ab578063590aa875146103cb57806365129042146103eb5761025c565b80632322cf761161022f578063327d305411610214578063327d30541461033257806332aae3ad146103455780633db6dc61146103675761025c565b80632322cf76146102f0578063314853ff146103105761025c565b806302d0aec31461026157806304a5618a1461028b5780630d7b7d76146102ad578063165979e1146102ce575b600080fd5b61027461026f3660046149dd565b61069f565b6040516102829291906152e4565b60405180910390f35b61029e6102993660046149dd565b6106fb565b60405161028293929190615387565b6102c06102bb366004614565565b6107a9565b604051610282929190615292565b6102e16102dc3660046149dd565b6107cb565b604051610282939291906154c2565b6103036102fe366004614565565b610828565b6040516102829190615731565b61032361031e3660046149dd565b610850565b604051610282939291906152b9565b6102c06103403660046149dd565b610897565b6103586103533660046149dd565b6108d9565b60405161028293929190615438565b61037a6103753660046149dd565b61092c565b6040516102829493929190615258565b61039d6103983660046149dd565b610976565b6040516102829291906154ab565b6103be6103b936600461448c565b6109cc565b60405161028291906151f2565b6103de6103d936600461435d565b610a4f565b60405161028291906153e7565b6103fe6103f93660046149dd565b610ad3565b60405161028293929190614fdf565b61042061041b3660046149dd565b610b0d565b6040516102829493929190615535565b61044361043e3660046149dd565b61164e565b604051610282929190615301565b61046461045f3660046149dd565b611686565b604051610282929190614fc5565b610303610480366004614565565b6116be565b6104436104933660046149dd565b611dd3565b6104ab6104a63660046149dd565b611e63565b60405161028294939291906154f1565b6104ce6104c93660046149dd565b611ec4565b604051610282959493929190615324565b6103be6104ed3660046145d4565b611f6f565b61050561050036600461463a565b611fe8565b60405161028291906150f9565b6103de6105203660046145a9565b6120ac565b6105386105333660046149dd565b612133565b6040516102829493929190615055565b6103de6105563660046144da565b61216f565b61056e6105693660046149dd565b6121fc565b604051610282939291906153b2565b61059061058b3660046149dd565b6122a9565b6040516102829291906152a0565b6105b16105ac3660046149dd565b6122e2565b604051610282929190615528565b6103be6105cd36600461448c565b612330565b6103036105e0366004614565565b61239e565b6105f86105f3366004614a94565b6129e1565b60405161028291906154dd565b6103de6106133660046147e2565b612f7e565b61062b6106263660046146be565b612fb6565b60405161028293929190615146565b61064d61064836600461448c565b6130ee565b604051610282929190615233565b61066e610669366004614aec565b613107565b604051610282939291906156d5565b61069061068b3660046149dd565b613341565b60405161028293929190615481565b6000806106b3836106ae61337e565b6133a2565b60006106cc60048551866133fc9092919063ffffffff16565b8060200190516106df9190810190614990565b909350905060ff811660068111156106f357fe5b915050915091565b6000808061070f848263ffffffff61343f16565b92506001600160e01b031983167f02571792000000000000000000000000000000000000000000000000000000001461077d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107749061569e565b60405180910390fd5b61078e84601063ffffffff61347316565b91506107a184602463ffffffff6134a616565b929491935050565b6000806107b684846116be565b91506107c2848461239e565b90509250929050565b60008060006107dc846106ae6134b2565b60006107f560048651876133fc9092919063ffffffff16565b8060200190516108089190810190614d20565b9094509250905060ff8116600281111561081e57fe5b9350509193909250565b600080600061083785856107a9565b9150915061084582826134d6565b925050505b92915050565b6000606080610861846106ae6134ec565b835161087790859060049063ffffffff6133fc16565b80602001905161088a9190810190614930565b9196909550909350915050565b6000806108a6836106ae613510565b82516108bc90849060049063ffffffff6133fc16565b8060200190516108cf91908101906148d2565b9094909350915050565b60008060606108ea846106ae613534565b600061090360048651876133fc9092919063ffffffff16565b8060200190516109169190810190614cd4565b9094509250905060ff8116600181111561081e57fe5b60008060608061093e856106ae613558565b845161095490869060049063ffffffff6133fc16565b806020019051610967919081019061488e565b92989197509550909350915050565b600080610985836106ae61357c565b600061099e60048551866133fc9092919063ffffffff16565b8060200190516109b19190810190614c07565b9250905060ff811660038111156109c457fe5b925050915091565b6060600082519050806040519080825280602002602001820160405280156109fe578160200160208202803883390190505b50915060005b818114610a4757610a2885858381518110610a1b57fe5b602002602001015161239e565b838281518110610a3457fe5b6020908102919091010152600101610a04565b505092915050565b6040516060907ff47261b00000000000000000000000000000000000000000000000000000000090610a85908490602401614fb1565b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff166001600160e01b0319909316929092179091529050919050565b6000806000610ae4846106ae6135a0565b8351610afa90859060049063ffffffff6133fc16565b80602001905161088a91908101906143b2565b60608080806000610b24868263ffffffff61343f16565b90506001600160e01b031981167fdedfc1f1000000000000000000000000000000000000000000000000000000001415610b95576040518060400160405280601181526020017f626174636843616e63656c4f72646572730000000000000000000000000000008152509450611124565b6001600160e01b031981167f9694a402000000000000000000000000000000000000000000000000000000001415610c04576040518060400160405280600f81526020017f626174636846696c6c4f726465727300000000000000000000000000000000008152509450611124565b6001600160e01b031981167f8ea8dfe4000000000000000000000000000000000000000000000000000000001415610c73576040518060400160405280601681526020017f626174636846696c6c4f72646572734e6f5468726f77000000000000000000008152509450611124565b6001600160e01b031981167fbeee2e14000000000000000000000000000000000000000000000000000000001415610ce2576040518060400160405280601581526020017f626174636846696c6c4f724b696c6c4f726465727300000000000000000000008152509450611124565b6001600160e01b031981167f2da62987000000000000000000000000000000000000000000000000000000001415610d51576040518060400160405280600b81526020017f63616e63656c4f726465720000000000000000000000000000000000000000008152509450611124565b6001600160e01b031981167f9b44d556000000000000000000000000000000000000000000000000000000001415610dc0576040518060400160405280600981526020017f66696c6c4f7264657200000000000000000000000000000000000000000000008152509450611124565b6001600160e01b031981167fe14b58c4000000000000000000000000000000000000000000000000000000001415610e2f576040518060400160405280600f81526020017f66696c6c4f724b696c6c4f7264657200000000000000000000000000000000008152509450611124565b6001600160e01b031981167f78d29ac1000000000000000000000000000000000000000000000000000000001415610e9e576040518060400160405280601681526020017f6d61726b65744275794f72646572734e6f5468726f77000000000000000000008152509450611124565b6001600160e01b031981167f369da099000000000000000000000000000000000000000000000000000000001415610f0d576040518060400160405280601781526020017f6d61726b657453656c6c4f72646572734e6f5468726f770000000000000000008152509450611124565b6001600160e01b031981167f8bc8efb3000000000000000000000000000000000000000000000000000000001415610f7c576040518060400160405280601981526020017f6d61726b65744275794f726465727346696c6c4f724b696c6c000000000000008152509450611124565b6001600160e01b031981167fa6c3bf33000000000000000000000000000000000000000000000000000000001415610feb576040518060400160405280601a81526020017f6d61726b657453656c6c4f726465727346696c6c4f724b696c6c0000000000008152509450611124565b6001600160e01b031981167f88ec79fb00000000000000000000000000000000000000000000000000000000141561105a576040518060400160405280600b81526020017f6d617463684f72646572730000000000000000000000000000000000000000008152509450611124565b6001600160e01b031981167f4f9559b10000000000000000000000000000000000000000000000000000000014806110bb57506001600160e01b031981167f2280c91000000000000000000000000000000000000000000000000000000000145b156110f2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161077490615630565b6040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610774906155f9565b6001600160e01b031981167fdedfc1f10000000000000000000000000000000000000000000000000000000014156111c957855161116c90879060049063ffffffff6135c416565b80602001905161117f9190810190614607565b604080516000808252602082019092529195505b50604080516000808252602082019092529194506111c1565b60608152602001906001900390816111ac5790505b509150611646565b6001600160e01b031981167fbeee2e1400000000000000000000000000000000000000000000000000000000148061122a57506001600160e01b031981167f9694a40200000000000000000000000000000000000000000000000000000000145b8061125e57506001600160e01b031981167f8ea8dfe400000000000000000000000000000000000000000000000000000000145b156112785761126c86613644565b91955093509150611646565b6001600160e01b031981167f2da629870000000000000000000000000000000000000000000000000000000014156113605760408051600180825281830190925290816020015b6112c7613c90565b8152602001906001900390816112bf57505086519094506112f290879060049063ffffffff6135c416565b8060200190516113059190810190614a61565b8460008151811061131257fe5b602002602001018190525060006040519080825280602002602001820160405280156111935781602001602082028038833901905050604080516000808252602082019092529194506111c1565b6001600160e01b031981167fe14b58c40000000000000000000000000000000000000000000000000000000014806113c157506001600160e01b031981167f9b44d55600000000000000000000000000000000000000000000000000000000145b156113cf5761126c86613673565b6001600160e01b031981167f78d29ac100000000000000000000000000000000000000000000000000000000148061143057506001600160e01b031981167f369da09900000000000000000000000000000000000000000000000000000000145b8061146457506001600160e01b031981167f8bc8efb300000000000000000000000000000000000000000000000000000000145b8061149857506001600160e01b031981167fa6c3bf3300000000000000000000000000000000000000000000000000000000145b156114a65761126c8661376d565b6001600160e01b031981167f88ec79fb000000000000000000000000000000000000000000000000000000001415611646576114e0613c90565b6114e8613c90565b60608061150260048b518c6135c49092919063ffffffff16565b8060200190516115159190810190614b43565b604080516002808252606082019092529498509296509094509250816020015b61153d613c90565b815260200190600190039081611535579050509750838860008151811061156057fe5b6020026020010181905250828860018151811061157957fe5b602090810291909101015260408051600280825260608201909252908160200160208202803883390190505096508360a00151876000815181106115b957fe5b6020026020010181815250508260a00151876001815181106115d757fe5b60209081029190910101526040805160028082526060820190925290816020015b60608152602001906001900390816115f8579050509550818660008151811061161d57fe5b6020026020010181905250808660018151811061163657fe5b6020026020010181905250505050505b509193509193565b60008061165d836106ae6137e1565b825161167390849060049063ffffffff6133fc16565b8060200190516108cf91908101906149b4565b600080611695836106ae613805565b82516116ab90849060049063ffffffff6133fc16565b8060200190516108cf9190810190614379565b6000806116d1838263ffffffff61343f16565b90506001600160e01b031981167ff47261b000000000000000000000000000000000000000000000000000000000141561184657600061171884601063ffffffff61347316565b6040519091506060907f70a082310000000000000000000000000000000000000000000000000000000090611751908890602401614fb1565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050905060006060836001600160a01b0316836040516117cc9190614f95565b600060405180830381855afa9150503d8060008114611807576040519150601f19603f3d011682016040523d82523d6000602084013e61180c565b606091505b509150915081801561181f575080516020145b61182a57600061183b565b61183b81600063ffffffff6134a616565b955050505050611dcc565b6001600160e01b031981167f025717920000000000000000000000000000000000000000000000000000000014156119e157600080611884856106fb565b6040519194509250606091507f6352211e00000000000000000000000000000000000000000000000000000000906118c0908490602401615731565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050905060006060846001600160a01b03168360405161193b9190614f95565b600060405180830381855afa9150503d8060008114611976576040519150601f19603f3d011682016040523d82523d6000602084013e61197b565b606091505b50915091506000828015611990575081516020145b61199b5760006119ac565b6119ac82600c63ffffffff61347316565b9050896001600160a01b0316816001600160a01b0316146119ce5760006119d1565b60015b60ff169750505050505050611dcc565b6001600160e01b031981167fa7cb5fb7000000000000000000000000000000000000000000000000000000001415611bc4576000606080611a2186611ec4565b5081519296509094509250905060005b818114611bba5783516060907efdd58e00000000000000000000000000000000000000000000000000000000908b90879085908110611a6c57fe5b6020026020010151604051602401611a85929190615089565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050905060006060876001600160a01b031683604051611b009190614f95565b600060405180830381855afa9150503d8060008114611b3b576040519150601f19603f3d011682016040523d82523d6000602084013e611b40565b606091505b50915091506000828015611b55575081516020145b611b60576000611b71565b611b7182600063ffffffff6134a616565b90506000878681518110611b8157fe5b60200260200101518281611b9157fe5b0490508b811080611ba057508b155b15611ba957809b505b505060019093019250611a31915050565b5050505050611dcc565b6001600160e01b031981167fc339d10a000000000000000000000000000000000000000000000000000000001415611d15576040516060907fa85e59e40000000000000000000000000000000000000000000000000000000090611c33908690600090819081906024016153fa565b60408051601f198184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff166001600160e01b03199094169390931790925260045491519092506000916001600160a01b031690611c9a908490614f95565b600060405180830381855afa9150503d8060008114611cd5576040519150601f19603f3d011682016040523d82523d6000602084013e611cda565b606091505b5050905080611cea576000611d0c565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff5b93505050611dcc565b6001600160e01b031981167f94cfcdd7000000000000000000000000000000000000000000000000000000001415611dcc57606080611d53856121fc565b80519194509250905060005b818114611dc7576000611d8589858481518110611d7857fe5b60200260200101516116be565b90506000858381518110611d9557fe5b60200260200101518281611da557fe5b04905087811080611db4575087155b15611dbd578097505b5050600101611d5f565b505050505b5092915050565b600080611de6838263ffffffff61343f16565b91506001600160e01b031982167ff47261b00000000000000000000000000000000000000000000000000000000014611e4b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107749061569e565b611e5c83601063ffffffff61347316565b9050915091565b60008060006060611e76856106ae613829565b6000611e8f60048751886133fc9092919063ffffffff16565b806020019051611ea29190810190614c76565b91965094509250905060ff81166006811115611eba57fe5b9450509193509193565b60008060608080611edb868563ffffffff61343f16565b94506001600160e01b031985167fa7cb5fb70000000000000000000000000000000000000000000000000000000014611f40576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107749061569e565b505050506024828101516044840151606485015160848601519496929591820184019490820184019391010190565b6060808251604051908082528060200260200182016040528015611f9d578160200160208202803883390190505b50905060005b83518114611dcc57838181518110611fb757fe5b60200260200101516001600160a01b031631828281518110611fd557fe5b6020908102919091010152600101611fa3565b60606000845190508060405190808252806020026020018201604052801561201a578160200160208202803883390190505b50915060005b8181146120a25761206b86828151811061203657fe5b602002602001015186838151811061204a57fe5b602002602001015186848151811061205e57fe5b60200260200101516129e1565b83828151811061207757fe5b6020026020010190600481111561208a57fe5b9081600481111561209757fe5b905250600101612020565b50505b9392505050565b6040516060907f0257179200000000000000000000000000000000000000000000000000000000906120e49085908590602401615089565b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff166001600160e01b031990931692909217909152905092915050565b60006060806060612146856106ae61384d565b845161215c90869060049063ffffffff6133fc16565b80602001905161096791908101906143f4565b6040516060907fa7cb5fb700000000000000000000000000000000000000000000000000000000906121ab908790879087908790602401615003565b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff166001600160e01b0319909316929092179091529050949350505050565b6000606080612211848463ffffffff61343f16565b92506001600160e01b031983167f94cfcdd70000000000000000000000000000000000000000000000000000000014612276576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107749061569e565b835161228c90859060049063ffffffff6135c416565b80602001905161229f9190810190614817565b9395909450915050565b600060606122b9836106ae613871565b82516122cf90849060049063ffffffff6133fc16565b8060200190516108cf91908101906148f5565b6000806122f1836106ae613895565b600061230a60048551866133fc9092919063ffffffff16565b80602001905161231d9190810190614c07565b9250905060ff811660018111156109c457fe5b606060008251905080604051908082528060200260200182016040528015612362578160200160208202803883390190505b50915060005b818114610a475761237f85858381518110611d7857fe5b83828151811061238b57fe5b6020908102919091010152600101612368565b6000806123b1838263ffffffff61343f16565b90506001600160e01b031981167f94cfcdd7000000000000000000000000000000000000000000000000000000001415612463576060806123f1856121fc565b80519194509250905060005b81811461245857600061241689858481518110610a1b57fe5b9050600085838151811061242657fe5b6020026020010151828161243657fe5b04905087811080612445575087155b1561244e578097505b50506001016123fd565b5061084a9350505050565b6001600160e01b031981167ff47261b00000000000000000000000000000000000000000000000000000000014156124ee5760006124a884601063ffffffff61347316565b6001546040519192506060917fdd62ed3e00000000000000000000000000000000000000000000000000000000916117519189916001600160a01b031690602401614fc5565b6001600160e01b031981167f025717920000000000000000000000000000000000000000000000000000000014156127de5760008061252c856106fb565b600254604051929550909350606092507fe985e9c50000000000000000000000000000000000000000000000000000000091612578918a916001600160a01b0390911690602401614fc5565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050905060006060846001600160a01b0316836040516125f39190614f95565b600060405180830381855afa9150503d806000811461262e576040519150601f19603f3d011682016040523d82523d6000602084013e612633565b606091505b509150915081158061264757508051602014155b80612663575061265e81600063ffffffff6134a616565b600114155b156127b1576040516060907f081812fc000000000000000000000000000000000000000000000000000000009061269e908790602401615731565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050509050856001600160a01b0316816040516127159190614f95565b600060405180830381855afa9150503d8060008114612750576040519150601f19603f3d011682016040523d82523d6000602084013e612755565b606091505b509093509150828015612769575081516020145b801561279857506002546001600160a01b031661278d83600c63ffffffff61347316565b6001600160a01b0316145b6127a35760006127a6565b60015b60ff16975050611bba565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff96505050505050611dcc565b6001600160e01b031981167fa7cb5fb700000000000000000000000000000000000000000000000000000000141561298657600061281b84611ec4565b5050600354604051929450606093507fe985e9c50000000000000000000000000000000000000000000000000000000092612865925089916001600160a01b031690602401614fc5565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050905060006060836001600160a01b0316836040516128e09190614f95565b600060405180830381855afa9150503d806000811461291b576040519150601f19603f3d011682016040523d82523d6000602084013e612920565b606091505b5091509150818015612933575080516020145b801561294f575061294b81600063ffffffff6134a616565b6001145b61295a57600061183b565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff955050505050611dcc565b6001600160e01b031981167fc339d10a000000000000000000000000000000000000000000000000000000001415611dcc57507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9392505050565b60006129eb613d23565b612a7c8584600560009054906101000a90046001600160a01b03166001600160a01b0316631ce4c78b6040518163ffffffff1660e01b815260040160206040518083038186803b158015612a3e57600080fd5b505afa158015612a52573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250612a769190810190614bef565b3a6138b9565b60408051600480825260a0820190925291925060609190816020015b6060815260200190600190039081612a9857505060408051600480825260a082019092529192506060919060208201608080388339505060408051600480825260a08201909252929350606092915060208201608080388339505060408051600480825260a0820190925292935060609291506020820160808038833901905050905088610160015184600081518110612b2e57fe5b60200260200101819052508783600081518110612b4757fe5b60200260200101906001600160a01b031690816001600160a01b031681525050886000015182600081518110612b7957fe5b60200260200101906001600160a01b031690816001600160a01b0316815250508681600081518110612ba757fe5b60200260200101818152505088610140015184600181518110612bc657fe5b6020026020010181905250886000015183600181518110612be357fe5b60200260200101906001600160a01b031690816001600160a01b0316815250508782600181518110612c1157fe5b60200260200101906001600160a01b031690816001600160a01b031681525050846000015181600181518110612c4357fe5b602002602001018181525050886101a0015184600281518110612c6257fe5b60200260200101819052508783600281518110612c7b57fe5b60200260200101906001600160a01b031690816001600160a01b031681525050886040015182600281518110612cad57fe5b60200260200101906001600160a01b031690816001600160a01b031681525050846060015181600281518110612cdf57fe5b60200260200101818152505088610180015184600381518110612cfe57fe5b6020026020010181905250886000015183600381518110612d1b57fe5b60200260200101906001600160a01b031690816001600160a01b031681525050886040015182600381518110612d4d57fe5b60200260200101906001600160a01b031690816001600160a01b031681525050846040015181600381518110612d7f57fe5b60209081029190910101526040516060907fb04fbddd0000000000000000000000000000000000000000000000000000000090612dc69087908790879087906024016150a2565b60408051601f198184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff166001600160e01b03199094169390931790925260055491519092506060916001600160a01b031690612e2d908490614f95565b6000604051808303816000865af19150503d8060008114612e6a576040519150601f19603f3d011682016040523d82523d6000602084013e612e6f565b606091505b50915060009050612e86828263ffffffff61343f16565b9050612e90613534565b6001600160e01b031982811691161415612ed2576000612eaf836108d9565b5091505060ff81166004811115612ec257fe5b99505050505050505050506120a5565b612eda6134ec565b6001600160e01b031982811691161415612f0d576000612ef983610850565b509091505060ff81166004811115612ec257fe5b815160208301207ff43f26ea5a94b478394a975e856464913dc1a8a1ca70939d974aa7c238aa0ce01415612f4c576004985050505050505050506120a5565b6040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610774906155c2565b6040516060907f94cfcdd700000000000000000000000000000000000000000000000000000000906120e49085908590602401615205565b606080606060008551905080604051908082528060200260200182016040528015612ffb57816020015b612fe8613d52565b815260200190600190039081612fe05790505b50935080604051908082528060200260200182016040528015613028578160200160208202803883390190505b50925080604051908082528060200260200182016040528015613055578160200160208202803883390190505b50915060005b8181146130e55761309287828151811061307157fe5b602002602001015187838151811061308557fe5b6020026020010151613107565b87518890859081106130a057fe5b602002602001018785815181106130b357fe5b602002602001018786815181106130c657fe5b931515602094850291909101909301929092529190525260010161305b565b50509250925092565b6060806130fb8484612330565b91506107c284846109cc565b61310f613d52565b600080546040517f9d3fa4b900000000000000000000000000000000000000000000000000000000815282916001600160a01b031690639d3fa4b9906131599088906004016156f9565b60606040518083038186803b15801561317157600080fd5b505afa158015613185573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506131a99190810190614a10565b85516000546040517fa12dcc6f00000000000000000000000000000000000000000000000000000000815292955090916001600160a01b039091169063a12dcc6f906131fb908990899060040161570c565b60206040518083038186803b15801561321357600080fd5b505afa158015613227573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061324b919081019061486e565b9150600061325e82886101400151610828565b60a088015160c08901516101808a01516101408b01519394509192909160009161328d9163ffffffff61393016565b156132ba576132b3846132ad848d6080015161395590919063ffffffff16565b85613971565b9050613313565b816132ce576132b3848b6080015185613971565b60006132df868c6101800151610828565b905060006132f2868d6080015187613971565b90506000613301838688613971565b905061330d82826134d6565b93505050505b61333361332d89604001518561399b90919063ffffffff16565b826134d6565b965050505050509250925092565b6000806000613352846106ae6139ba565b600061336b60048651876133fc9092919063ffffffff16565b8060200190516108089190810190614c34565b7ffdb6ca8d0000000000000000000000000000000000000000000000000000000090565b60006133af83600061343f565b90506001600160e01b0319808216908316146133f7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161077490615667565b505050565b60608183111561341a5761341a613415600085856139de565b613a4d565b83518211156134335761343361341560018487516139de565b50819003910190815290565b600081600401835110156134605761346061341560038551856004016139de565b5001602001516001600160e01b03191690565b600081601401835110156134945761349461341560048551856014016139de565b5001601401516001600160a01b031690565b60006120a58383613a55565b7f18e4b1410000000000000000000000000000000000000000000000000000000090565b60008183106134e557816120a5565b5090919050565b7f4678472b0000000000000000000000000000000000000000000000000000000090565b7fb6555d6f0000000000000000000000000000000000000000000000000000000090565b7f488219a60000000000000000000000000000000000000000000000000000000090565b7f1b8388f70000000000000000000000000000000000000000000000000000000090565b7fe94a7ed00000000000000000000000000000000000000000000000000000000090565b7f4ad312750000000000000000000000000000000000000000000000000000000090565b6060818311156135dd576135dd613415600085856139de565b83518211156135f6576135f661341560018487516139de565b8282036040519080825280601f01601f191660200182016040528015613623576020820181803883390190505b5090506120a561363282613a7f565b8461363c87613a7f565b018351613a85565b606080606061366060048551866135c49092919063ffffffff16565b80602001905161088a9190810190614715565b60408051600180825281830190925260609182918291816020015b613696613c90565b81526020019060019003908161368e5750506040805160018082528183019092529194506020808301908038833901905050604080516001808252818301909252919350816020015b60608152602001906001900390816136df575050845190915061370c90859060049063ffffffff6135c416565b80602001905161371f9190810190614b9c565b8560008151811061372c57fe5b602002602001018560008151811061374057fe5b602002602001018560008151811061375457fe5b6020908102919091010192909252919052529193909250565b6040805160018082528183019092526060918291829160208083019080388339505085519193506137a99186915060049063ffffffff6135c416565b8060200190516137bc919081019061478f565b845185906000906137c957fe5b60209081029190910101919091529095929450925050565b7f11c7b7200000000000000000000000000000000000000000000000000000000090565b7fa15c0d060000000000000000000000000000000000000000000000000000000090565b7f7e5a23180000000000000000000000000000000000000000000000000000000090565b7f5bd0428d0000000000000000000000000000000000000000000000000000000090565b7f20d11f610000000000000000000000000000000000000000000000000000000090565b7ff59851840000000000000000000000000000000000000000000000000000000090565b6138c1613d23565b6020810184905260a085015160808601516138dd918691613b2a565b815260a085015160c08601516138f4918691613b2a565b604082015260a085015160e086015161390e918691613b2a565b6060820152613923828463ffffffff613b5e16565b6080820152949350505050565b6000815183511480156120a55750508051602091820120825192909101919091201490565b6000828201838110156120a5576120a561341560008686613b8b565b600061399383613987868563ffffffff613b5e16565b9063ffffffff613baa16565b949350505050565b6000828211156139b4576139b461341560028585613b8b565b50900390565b7fe53c76c80000000000000000000000000000000000000000000000000000000090565b6060632800659560e01b8484846040516024016139fd939291906154cf565b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff166001600160e01b03199093169290921790915290509392505050565b805160208201fd5b60008160200183511015613a7657613a7661341560058551856020016139de565b50016020015190565b60200190565b6020811015613aaf576001816020036101000a0380198351168185511680821786525050506133f7565b82821415613abc576133f7565b82821115613af65760208103905080820181840181515b82851015613aee578451865260209586019590940193613ad3565b9052506133f7565b60208103905080820181840183515b81861215613b215782518252601f199283019290910190613b05565b85525050505050565b6000613b37848484613bd4565b15613b4a57613b4a613415858585613c3a565b61399383613987868563ffffffff613b5e16565b600082613b6d5750600061084a565b82820282848281613b7a57fe5b04146120a5576120a5613415600186865b606063e946c1bb60e01b8484846040516024016139fd93929190615460565b600081613bc057613bc061341560038585613b8b565b6000828481613bcb57fe5b04949350505050565b600082613be657613be6613415613c59565b811580613bf1575083155b15613bfe575060006120a5565b60008380613c0857fe5b8584099050613c1d858463ffffffff613b5e16565b613c2f826103e863ffffffff613b5e16565b101595945050505050565b606063339f3de260e01b8484846040516024016139fd9392919061573a565b60408051808201909152600481527fa791837c00000000000000000000000000000000000000000000000000000000602082015290565b604051806101c0016040528060006001600160a01b0316815260200160006001600160a01b0316815260200160006001600160a01b0316815260200160006001600160a01b03168152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001606081526020016060815260200160608152602001606081525090565b6040518060a0016040528060008152602001600081526020016000815260200160008152602001600081525090565b604080516060810182526000808252602082018190529181019190915290565b803561084a81615816565b805161084a81615816565b600082601f830112613d98578081fd5b8135613dab613da682615777565b615750565b818152915060208083019084810181840286018201871015613dcc57600080fd5b60005b84811015611dc7578135613de281615816565b84529282019290820190600101613dcf565b600082601f830112613e04578081fd5b8151613e12613da682615777565b8181529150602080830190840160005b83811015613e4f57613e3a8760208451890101614074565b83526020928301929190910190600101613e22565b5050505092915050565b600082601f830112613e69578081fd5b8135613e77613da682615777565b8181529150602080830190840160005b83811015613e4f57613e9f8760208435890101614026565b83526020928301929190910190600101613e87565b600082601f830112613ec4578081fd5b8151613ed2613da682615777565b8181529150602080830190840160005b83811015613e4f57613efa8760208451890101614209565b83526020928301929190910190600101613ee2565b600082601f830112613f1f578081fd5b8135613f2d613da682615777565b8181529150602080830190840160005b83811015613e4f57613f5587602084358901016140ba565b83526020928301929190910190600101613f3d565b600082601f830112613f7a578081fd5b8151613f88613da682615777565b818152915060208083019084810181840286018201871015613fa957600080fd5b60005b84811015611dc757815184529282019290820190600101613fac565b600082601f830112613fd8578081fd5b8135613fe6613da682615777565b81815291506020808301908481018184028601820187101561400757600080fd5b60005b84811015611dc75781358452928201929082019060010161400a565b600082601f830112614036578081fd5b8135614044613da682615797565b915080825283602082850101111561405b57600080fd5b8060208401602084013760009082016020015292915050565b600082601f830112614084578081fd5b8151614092613da682615797565b91508082528360208285010111156140a957600080fd5b611dcc8160208401602086016157bb565b60006101c08083850312156140cd578182fd5b6140d681615750565b9150506140e38383613d72565b81526140f28360208401613d72565b60208201526141048360408401613d72565b60408201526141168360608401613d72565b60608201526080820135608082015260a082013560a082015260c082013560c082015260e082013560e08201526101008083013581830152506101208083013581830152506101408083013567ffffffffffffffff8082111561417857600080fd5b61418486838701614026565b838501526101609250828501359150808211156141a057600080fd5b6141ac86838701614026565b838501526101809250828501359150808211156141c857600080fd5b6141d486838701614026565b838501526101a09250828501359150808211156141f057600080fd5b506141fd85828601614026565b82840152505092915050565b60006101c080838503121561421c578182fd5b61422581615750565b9150506142328383613d7d565b81526142418360208401613d7d565b60208201526142538360408401613d7d565b60408201526142658360608401613d7d565b60608201526080820151608082015260a082015160a082015260c082015160c082015260e082015160e08201526101008083015181830152506101208083015181830152506101408083015167ffffffffffffffff808211156142c757600080fd5b6142d386838701614074565b838501526101609250828501519150808211156142ef57600080fd5b6142fb86838701614074565b8385015261018092508285015191508082111561431757600080fd5b61432386838701614074565b838501526101a092508285015191508082111561433f57600080fd5b506141fd85828601614074565b805160ff8116811461084a57600080fd5b60006020828403121561436e578081fd5b81356120a581615816565b6000806040838503121561438b578081fd5b825161439681615816565b60208401519092506143a781615816565b809150509250929050565b6000806000606084860312156143c6578081fd5b83516143d181615816565b60208501519093506143e281615816565b80925050604084015190509250925092565b60008060008060808587031215614409578182fd5b845161441481615816565b602086015190945067ffffffffffffffff80821115614431578384fd5b61443d88838901614074565b94506040870151915080821115614452578384fd5b61445e88838901614074565b93506060870151915080821115614473578283fd5b5061448087828801614074565b91505092959194509250565b6000806040838503121561449e578182fd5b82356144a981615816565b9150602083013567ffffffffffffffff8111156144c4578182fd5b6144d085828601613e59565b9150509250929050565b600080600080608085870312156144ef578182fd5b84356144fa81615816565b9350602085013567ffffffffffffffff80821115614516578384fd5b61452288838901613fc8565b94506040870135915080821115614537578384fd5b61454388838901613fc8565b93506060870135915080821115614558578283fd5b5061448087828801614026565b60008060408385031215614577578182fd5b823561458281615816565b9150602083013567ffffffffffffffff81111561459d578182fd5b6144d085828601614026565b600080604083850312156145bb578182fd5b82356145c681615816565b946020939093013593505050565b6000602082840312156145e5578081fd5b813567ffffffffffffffff8111156145fb578182fd5b61399384828501613d88565b600060208284031215614618578081fd5b815167ffffffffffffffff81111561462e578182fd5b61399384828501613eb4565b60008060006060848603121561464e578081fd5b833567ffffffffffffffff80821115614665578283fd5b61467187838801613f0f565b94506020860135915080821115614686578283fd5b61469287838801613d88565b935060408601359150808211156146a7578283fd5b506146b486828701613fc8565b9150509250925092565b600080604083850312156146d0578182fd5b823567ffffffffffffffff808211156146e7578384fd5b6146f386838701613f0f565b93506020850135915080821115614708578283fd5b506144d085828601613e59565b600080600060608486031215614729578081fd5b835167ffffffffffffffff80821115614740578283fd5b61474c87838801613eb4565b94506020860151915080821115614761578283fd5b61476d87838801613f6a565b93506040860151915080821115614782578283fd5b506146b486828701613df4565b6000806000606084860312156147a3578081fd5b835167ffffffffffffffff808211156147ba578283fd5b6147c687838801613eb4565b9450602086015193506040860151915080821115614782578283fd5b600080604083850312156147f4578182fd5b823567ffffffffffffffff8082111561480b578384fd5b6146f386838701613fc8565b60008060408385031215614829578182fd5b825167ffffffffffffffff80821115614840578384fd5b61484c86838701613f6a565b93506020850151915080821115614861578283fd5b506144d085828601613df4565b60006020828403121561487f578081fd5b815180151581146120a5578182fd5b600080600080608085870312156148a3578182fd5b8451935060208501516148b581615816565b604086015190935067ffffffffffffffff80821115614452578384fd5b600080604083850312156148e4578182fd5b505080516020909101519092909150565b60008060408385031215614907578182fd5b82519150602083015167ffffffffffffffff811115614924578182fd5b6144d085828601614074565b600080600060608486031215614944578081fd5b83519250602084015167ffffffffffffffff80821115614962578283fd5b61496e87838801614074565b93506040860151915080821115614983578283fd5b506146b486828701614074565b600080604083850312156149a2578182fd5b8251915060208301516143a78161582b565b600080604083850312156149c6578182fd5b82516001600160e01b031981168114614396578283fd5b6000602082840312156149ee578081fd5b813567ffffffffffffffff811115614a04578182fd5b61399384828501614026565b60006060828403128015614a22578182fd5b8015614a2c578182fd5b50614a376060615750565b8251614a428161582b565b8152602083810151908201526040928301519281019290925250919050565b600060208284031215614a72578081fd5b815167ffffffffffffffff811115614a88578182fd5b61399384828501614209565b600080600060608486031215614aa8578081fd5b833567ffffffffffffffff811115614abe578182fd5b614aca868287016140ba565b9350506020840135614adb81615816565b929592945050506040919091013590565b60008060408385031215614afe578182fd5b823567ffffffffffffffff80821115614b15578384fd5b614b21868387016140ba565b93506020850135915080821115614b36578283fd5b506144d085828601614026565b60008060008060808587031215614b58578182fd5b845167ffffffffffffffff80821115614b6f578384fd5b614b7b88838901614209565b95506020870151915080821115614b90578384fd5b61443d88838901614209565b600080600060608486031215614bb0578081fd5b835167ffffffffffffffff80821115614bc7578283fd5b614bd387838801614209565b9450602086015193506040860151915080821115614983578283fd5b600060208284031215614c00578081fd5b5051919050565b60008060408385031215614c19578182fd5b8251614c248161582b565b6020939093015192949293505050565b600080600060608486031215614c48578081fd5b8351614c538161582b565b602085015160408601519194509250614c6b81615816565b809150509250925092565b60008060008060808587031215614c8b578182fd5b614c95868661434c565b9350602085015192506040850151614cac81615816565b606086015190925067ffffffffffffffff811115614cc8578182fd5b61448087828801614074565b600080600060608486031215614ce8578081fd5b614cf2858561434c565b925060208401519150604084015167ffffffffffffffff811115614d14578182fd5b6146b486828701614074565b600080600060608486031215614d34578081fd5b614d3e858561434c565b925060208401519150604084015190509250925092565b1515815260200190565b6000614d6b8383614e78565b505060600190565b6001600160a01b03169052565b6000815180845260208401935060208301825b82811015614dba5781516001600160a01b0316865260209586019590910190600101614d93565b5093949350505050565b600081518084526020840180819550602083028101915060208501845b84811015614e0f578284038852614df9848351614e4c565b6020988901989094509190910190600101614de1565b50919695505050505050565b6000815180845260208401935060208301825b82811015614dba578151865260209586019590910190600101614e2e565b60008151808452614e648160208601602086016157bb565b601f01601f19169290920160200192915050565b805160ff16825260208082015190830152604090810151910152565b60006101c0614ea4848451614d73565b6020830151614eb66020860182614d73565b506040830151614ec96040860182614d73565b506060830151614edc6060860182614d73565b506080830151608085015260a083015160a085015260c083015160c085015260e083015160e0850152610100808401518186015250610120808401518186015250610140808401518282870152614f3583870182614e4c565b91505061016091508184015185820383870152614f528282614e4c565b925050506101808084015185830382870152614f6e8382614e4c565b9150506101a091508184015185820383870152614f8b8282614e4c565b9695505050505050565b60008251614fa78184602087016157bb565b9190910192915050565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b60006001600160a01b0386168252608060208301526150256080830186614e1b565b82810360408401526150378186614e1b565b83810360608501526150498186614e4c565b98975050505050505050565b60006001600160a01b0386168252608060208301526150776080830186614e4c565b82810360408401526150378186614e4c565b6001600160a01b03929092168252602082015260400190565b6000608082526150b56080830187614dc4565b82810360208401526150c78187614d80565b83810360408501526150d98187614d80565b91505082810360608401526150ee8185614e1b565b979650505050505050565b602080825282518282018190526000918401906040840190835b8181101561513b5783516005811061512757fe5b835260209384019390920191600101615113565b509095945050505050565b6000606082016060835280865161515d8184615731565b9150602088019250835b8181101561518b5761517a838551614d5f565b602094909401939250600101615167565b5050838103602085015261519f8187614e1b565b91505082810360408401528084516151b78184615731565b9150602086019250835b818110156151e5576151d4838551614d55565b6020949094019392506001016151c1565b5090979650505050505050565b6000602082526120a56020830184614e1b565b6000604082526152186040830185614e1b565b828103602084015261522a8185614dc4565b95945050505050565b6000604082526152466040830185614e1b565b828103602084015261522a8185614e1b565b60008582526001600160a01b0385166020830152608060408301526152806080830185614e4c565b82810360608401526150ee8185614e4c565b918252602082015260400190565b6000838252604060208301526139936040830184614e4c565b6000848252606060208301526152d26060830185614e4c565b8281036040840152614f8b8185614e4c565b828152604081016152f48361580c565b8260208301529392505050565b6001600160e01b03199290921682526001600160a01b0316602082015260400190565b60006001600160e01b0319871682526001600160a01b038616602083015260a0604083015261535660a0830186614e1b565b82810360608401526153688186614e1b565b838103608085015261537a8186614e4c565b9998505050505050505050565b6001600160e01b03199390931683526001600160a01b03919091166020830152604082015260600190565b60006001600160e01b031985168252606060208301526153d56060830185614e1b565b8281036040840152614f8b8185614dc4565b6000602082526120a56020830184614e4c565b60006080825261540d6080830187614e4c565b6001600160a01b03958616602084015293909416604082015260ff9190911660609091015292915050565b6000615443856157eb565b8482528360208301526060604083015261522a6060830184614e4c565b6060810161546d856157f8565b938152602081019290925260409091015290565b6060810161548e85615802565b93815260208101929092526001600160a01b031660409091015290565b604081016154b8846157f8565b9281526020015290565b6060810161546d85615802565b606081016008851061546d57fe5b60208101600583106154eb57fe5b91905290565b60006154fc8661580c565b8582528460208301526001600160a01b038416604083015260806060830152614f8b6080830184614e4c565b604081016154b8846157eb565b6000608082526155486080830187614e4c565b602083820381850152818751808452828401915082838202850101838a01865b8381101561559657601f19878403018552615584838351614e94565b94860194925090850190600101615568565b505086810360408801526155aa818a614e1b565b94505050505082810360608401526150ee8185614dc4565b60208082526013908201527f554e4b4e4f574e5f52455455524e5f4441544100000000000000000000000000604082015260600190565b60208082526019908201527f554e4b4e4f574e5f46554e4354494f4e5f53454c4543544f5200000000000000604082015260600190565b6020808252600d908201527f554e494d504c454d454e54454400000000000000000000000000000000000000604082015260600190565b6020808252600c908201527f4241445f53454c4543544f520000000000000000000000000000000000000000604082015260600190565b6020808252600e908201527f57524f4e475f50524f58595f4944000000000000000000000000000000000000604082015260600190565b60a081016156e38286614e78565b8360608301528215156080830152949350505050565b6000602082526120a56020830184614e94565b60006040825261571f6040830185614e94565b828103602084015261522a8185614e4c565b90815260200190565b9283526020830191909152604082015260600190565b60405181810167ffffffffffffffff8111828210171561576f57600080fd5b604052919050565b600067ffffffffffffffff82111561578d578081fd5b5060209081020190565b600067ffffffffffffffff8211156157ad578081fd5b50601f01601f191660200190565b60005b838110156157d65781810151838201526020016157be565b838111156157e5576000848401525b50505050565b600281106157f557fe5b50565b600481106157f557fe5b600381106157f557fe5b600781106157f557fe5b6001600160a01b03811681146157f557600080fd5b60ff811681146157f557600080fdfea365627a7a723158200ea049525ebc74d73f3bf7858c601bd21168267b0dfb4abbdb7787cfd7233a2c6c6578706572696d656e74616cf564736f6c634300050c0040'; - private _methodABIIndex: { [name: string]: number } = {}; + private readonly _methodABIIndex: { [name: string]: number } = {}; public static async deployFrom0xArtifactAsync( artifact: ContractArtifact | SimpleContractArtifact, supportedProvider: SupportedProvider, @@ -1392,7 +1392,7 @@ export class DevUtilsContract extends BaseContract { public getFunctionSignature(methodName: string): string { const index = this._methodABIIndex[methodName]; - const methodAbi = DevUtilsContract.ABI()[index] as MethodAbi; + const methodAbi = DevUtilsContract.ABI()[index] as MethodAbi; // tslint:disable-line:no-unnecessary-type-assertion const functionSignature = methodAbiToFunctionSignature(methodAbi); return functionSignature; } diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts b/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts index 36d219d183..54a21f2095 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts @@ -61,7 +61,7 @@ export class DummyERC20TokenContract extends BaseContract { * @ignore */ public static deployedBytecode: string | undefined; - private _methodABIIndex: { [name: string]: number } = {}; + private readonly _methodABIIndex: { [name: string]: number } = {}; private readonly _subscriptionManager: SubscriptionManager; public static async deployFrom0xArtifactAsync( artifact: ContractArtifact | SimpleContractArtifact, @@ -475,7 +475,7 @@ export class DummyERC20TokenContract extends BaseContract { public getFunctionSignature(methodName: string): string { const index = this._methodABIIndex[methodName]; - const methodAbi = DummyERC20TokenContract.ABI()[index] as MethodAbi; + const methodAbi = DummyERC20TokenContract.ABI()[index] as MethodAbi; // tslint:disable-line:no-unnecessary-type-assertion const functionSignature = methodAbiToFunctionSignature(methodAbi); return functionSignature; } diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts b/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts index 73dee8cb7d..6ff77684f4 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts @@ -71,7 +71,7 @@ export class DummyERC721TokenContract extends BaseContract { * @ignore */ public static deployedBytecode: string | undefined; - private _methodABIIndex: { [name: string]: number } = {}; + private readonly _methodABIIndex: { [name: string]: number } = {}; private readonly _subscriptionManager: SubscriptionManager; public static async deployFrom0xArtifactAsync( artifact: ContractArtifact | SimpleContractArtifact, @@ -527,7 +527,7 @@ export class DummyERC721TokenContract extends BaseContract { public getFunctionSignature(methodName: string): string { const index = this._methodABIIndex[methodName]; - const methodAbi = DummyERC721TokenContract.ABI()[index] as MethodAbi; + const methodAbi = DummyERC721TokenContract.ABI()[index] as MethodAbi; // tslint:disable-line:no-unnecessary-type-assertion const functionSignature = methodAbiToFunctionSignature(methodAbi); return functionSignature; } diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/dutch_auction.ts b/packages/abi-gen-wrappers/src/generated-wrappers/dutch_auction.ts index 44b3af45b4..9d37da2bac 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/dutch_auction.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/dutch_auction.ts @@ -40,7 +40,7 @@ export class DutchAuctionContract extends BaseContract { * @ignore */ public static deployedBytecode: string | undefined; - private _methodABIIndex: { [name: string]: number } = {}; + private readonly _methodABIIndex: { [name: string]: number } = {}; public static async deployFrom0xArtifactAsync( artifact: ContractArtifact | SimpleContractArtifact, supportedProvider: SupportedProvider, @@ -417,7 +417,7 @@ export class DutchAuctionContract extends BaseContract { public getFunctionSignature(methodName: string): string { const index = this._methodABIIndex[methodName]; - const methodAbi = DutchAuctionContract.ABI()[index] as MethodAbi; + const methodAbi = DutchAuctionContract.ABI()[index] as MethodAbi; // tslint:disable-line:no-unnecessary-type-assertion const functionSignature = methodAbiToFunctionSignature(methodAbi); return functionSignature; } diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_mintable.ts b/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_mintable.ts index e0351a29b7..a5e41bca2f 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_mintable.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_mintable.ts @@ -83,7 +83,7 @@ export class ERC1155MintableContract extends BaseContract { */ public static deployedBytecode = '0x608060405234801561001057600080fd5b50600436106101765760003560e01c80639f4b286a116100d8578063e0a5c9491161008c578063f242432a11610066578063f242432a146107bb578063f94190881461085d578063fc67bf1c146108d457610176565b8063e0a5c94914610726578063e44591f014610763578063e985e9c51461078057610176565b8063adebf6f2116100bd578063adebf6f21461067a578063cc10e40114610697578063cd53d08e1461070957610176565b80639f4b286a146105c8578063a22cb4651461063f57610176565b80636352211e1161012f5780637269a327116101145780637269a327146104c557806378b27221146104e25780639cca1c64146105ab57610176565b80636352211e146104625780636f969c2d146104a857610176565b80632eb2c2d6116101605780632eb2c2d6146101e35780634e1273f41461031f5780635e81b9581461043157610176565b8062fdd58e1461017b57806308d7d469146101c6575b600080fd5b6101b46004803603604081101561019157600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81351690602001356108dc565b60408051918252519081900360200190f35b6101b4600480360360208110156101dc57600080fd5b5035610966565b61031d600480360360a08110156101f957600080fd5b73ffffffffffffffffffffffffffffffffffffffff823581169260208101359091169181019060608101604082013564010000000081111561023a57600080fd5b82018360208201111561024c57600080fd5b8035906020019184602083028401116401000000008311171561026e57600080fd5b91939092909160208101903564010000000081111561028c57600080fd5b82018360208201111561029e57600080fd5b803590602001918460208302840111640100000000831117156102c057600080fd5b9193909290916020810190356401000000008111156102de57600080fd5b8201836020820111156102f057600080fd5b8035906020019184600183028401116401000000008311171561031257600080fd5b509092509050610978565b005b6103e16004803603604081101561033557600080fd5b81019060208101813564010000000081111561035057600080fd5b82018360208201111561036257600080fd5b8035906020019184602083028401116401000000008311171561038457600080fd5b9193909290916020810190356401000000008111156103a257600080fd5b8201836020820111156103b457600080fd5b803590602001918460208302840111640100000000831117156103d657600080fd5b509092509050611192565b60408051602080825283518183015283519192839290830191858101910280838360005b8381101561041d578181015183820152602001610405565b505050509050019250505060405180910390f35b61044e6004803603602081101561044757600080fd5b5035611357565b604080519115158252519081900360200190f35b61047f6004803603602081101561047857600080fd5b503561139d565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b6101b4600480360360208110156104be57600080fd5b50356113c5565b61044e600480360360208110156104db57600080fd5b50356113ea565b61031d600480360360608110156104f857600080fd5b8135919081019060408101602082013564010000000081111561051a57600080fd5b82018360208201111561052c57600080fd5b8035906020019184602083028401116401000000008311171561054e57600080fd5b91939092909160208101903564010000000081111561056c57600080fd5b82018360208201111561057e57600080fd5b803590602001918460208302840111640100000000831117156105a057600080fd5b50909250905061142f565b6101b4600480360360208110156105c157600080fd5b5035611760565b61031d600480360360408110156105de57600080fd5b8135919081019060408101602082013564010000000081111561060057600080fd5b82018360208201111561061257600080fd5b8035906020019184600183028401116401000000008311171561063457600080fd5b509092509050611775565b61031d6004803603604081101561065557600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81351690602001351515611875565b61044e6004803603602081101561069057600080fd5b503561190e565b6101b4600480360360408110156106ad57600080fd5b8101906020810181356401000000008111156106c857600080fd5b8201836020820111156106da57600080fd5b803590602001918460018302840111640100000000831117156106fc57600080fd5b9193509150351515611934565b61047f6004803603602081101561071f57600080fd5b5035611a6d565b61072e611a95565b604080517fffffffff000000000000000000000000000000000000000000000000000000009092168252519081900360200190f35b61044e6004803603602081101561077957600080fd5b5035611ab9565b61044e6004803603604081101561079657600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81358116916020013516611ae1565b61031d600480360360a08110156107d157600080fd5b73ffffffffffffffffffffffffffffffffffffffff823581169260208101359091169160408201359160608101359181019060a08101608082013564010000000081111561081e57600080fd5b82018360208201111561083057600080fd5b8035906020019184600183028401116401000000008311171561085257600080fd5b509092509050611b1c565b61031d6004803603604081101561087357600080fd5b8135919081019060408101602082013564010000000081111561089557600080fd5b8201836020820111156108a757600080fd5b803590602001918460208302840111640100000000831117156108c957600080fd5b5090925090506120fb565b61072e61242b565b60006108e782611357565b1561092e5760008281526020819052604090205473ffffffffffffffffffffffffffffffffffffffff848116911614610921576000610924565b60015b60ff169050610960565b50600081815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff861684529091529020545b92915050565b60056020526000908152604090205481565b73ffffffffffffffffffffffffffffffffffffffff87166109fa57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f43414e4e4f545f5452414e534645525f544f5f414444524553535f5a45524f00604482015290519081900360640190fd5b848314610a6857604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f544f4b454e5f414e445f56414c5545535f4c454e4754485f4d49534d41544348604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff8816331480610ac1575073ffffffffffffffffffffffffffffffffffffffff8816600090815260026020908152604080832033845290915290205460ff1615156001145b610b2c57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f494e53554646494349454e545f414c4c4f57414e434500000000000000000000604482015290519081900360640190fd5b60005b85811015610deb576000878783818110610b4557fe5b9050602002013590506000868684818110610b5c57fe5b905060200201359050610b6e82611ab9565b15610cc85780600114610be257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f414d4f554e545f455155414c5f544f5f4f4e455f524551554952454400000000604482015290519081900360640190fd5b60008281526020819052604090205473ffffffffffffffffffffffffffffffffffffffff8c8116911614610c7757604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f4e46545f4e4f545f4f574e45445f42595f46524f4d5f41444452455353000000604482015290519081900360640190fd5b600082815260208190526040902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff8c16179055610de1565b600082815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8f168452909152902054610d02908261244f565b6001600084815260200190815260200160002060008d73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610db06001600084815260200190815260200160002060008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482612473565b600083815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8f1684529091529020555b5050600101610b2f565b508673ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb898989896040518080602001806020018381038352878782818152602001925060200280828437600083820152601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169091018481038352858152602090810191508690860280828437600083820152604051601f9091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169092018290039850909650505050505050a4610f1f8773ffffffffffffffffffffffffffffffffffffffff1661248f565b156111885760008773ffffffffffffffffffffffffffffffffffffffff1663bc197c81338b8a8a8a8a8a8a6040518963ffffffff1660e01b8152600401808973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001806020018060200184810384528a8a82818152602001925060200280828437600083820152601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169091018581038452888152602090810191508990890280828437600083820152601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01690910185810383528681526020019050868680828437600081840152601f19601f8201169050808301925050509b505050505050505050505050602060405180830381600087803b1580156110a857600080fd5b505af11580156110bc573d6000803e3d6000fd5b505050506040513d60208110156110d257600080fd5b505190507fffffffff0000000000000000000000000000000000000000000000000000000081167fbc197c81000000000000000000000000000000000000000000000000000000001461118657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f4241445f52454345495645525f52455455524e5f56414c554500000000000000604482015290519081900360640190fd5b505b5050505050505050565b60608382146111ec576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602481526020018061256a6024913960400191505060405180910390fd5b604080518581526020808702820101909152848015611215578160200160208202803883390190505b50905060005b8481101561134e57600084848381811061123157fe5b90506020020135905061124381611357565b156112b95786868381811061125457fe5b600084815260208181526040909120549102929092013573ffffffffffffffffffffffffffffffffffffffff9081169216919091149050611296576000611299565b60015b60ff168383815181106112a857fe5b602002602001018181525050611345565b6000818152600160205260408120908888858181106112d457fe5b9050602002013573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483838151811061133857fe5b6020026020010181815250505b5060010161121b565b50949350505050565b60007f80000000000000000000000000000000000000000000000000000000000000008083161480156109605750506fffffffffffffffffffffffffffffffff16151590565b60009081526020819052604090205473ffffffffffffffffffffffffffffffffffffffff1690565b7fffffffffffffffffffffffffffffffff000000000000000000000000000000001690565b60007f80000000000000000000000000000000000000000000000000000000000000008083161480156109605750506fffffffffffffffffffffffffffffffff161590565b600085815260046020526040902054859073ffffffffffffffffffffffffffffffffffffffff16331461146157600080fd5b61146a8661190e565b6114bf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602d81526020018061258e602d913960400191505060405180910390fd5b60005b848110156117575760008686838181106114d857fe5b9050602002013573ffffffffffffffffffffffffffffffffffffffff169050600085858481811061150557fe5b60008c815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8916845282529091205491029290920135925061154a91839150612473565b60008a815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff87168085529083528184209490945580518d8152918201859052805133927fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f6292908290030190a46115d68273ffffffffffffffffffffffffffffffffffffffff1661248f565b1561174d57604080517ff23a6e6100000000000000000000000000000000000000000000000000000000815233600482018190526024820152604481018b90526064810183905260a06084820152600060a48201819052915173ffffffffffffffffffffffffffffffffffffffff85169163f23a6e619160e480830192602092919082900301818787803b15801561166d57600080fd5b505af1158015611681573d6000803e3d6000fd5b505050506040513d602081101561169757600080fd5b505190507fffffffff0000000000000000000000000000000000000000000000000000000081167ff23a6e61000000000000000000000000000000000000000000000000000000001461174b57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f4241445f52454345495645525f52455455524e5f56414c554500000000000000604482015290519081900360640190fd5b505b50506001016114c2565b50505050505050565b6fffffffffffffffffffffffffffffffff1690565b600083815260046020908152604080832080547fffffffffffffffffffffffff0000000000000000000000000000000000000000163390811790915581518781529283018490528151849391927fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62928290030190a4801561187057827f6bb7ff708619ba0610cba295a58592e0451dee2622938c8755667688daf3529b838360405180806020018281038252848482818152602001925080828437600083820152604051601f9091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169092018290039550909350505050a25b505050565b33600081815260026020908152604080832073ffffffffffffffffffffffffffffffffffffffff87168085529083529281902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016861515908117909155815190815290519293927f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31929181900390910190a35050565b7f8000000000000000000000000000000000000000000000000000000000000000161590565b600380546001019081905560801b811561196b577f8000000000000000000000000000000000000000000000000000000000000000175b600081815260046020908152604080832080547fffffffffffffffffffffffff0000000000000000000000000000000000000000163390811790915581518581529283018490528151849391927fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62928290030190a48215611a6657807f6bb7ff708619ba0610cba295a58592e0451dee2622938c8755667688daf3529b858560405180806020018281038252848482818152602001925080828437600083820152604051601f9091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169092018290039550909350505050a25b9392505050565b60046020526000908152604090205473ffffffffffffffffffffffffffffffffffffffff1681565b7ff23a6e610000000000000000000000000000000000000000000000000000000081565b7f80000000000000000000000000000000000000000000000000000000000000009081161490565b73ffffffffffffffffffffffffffffffffffffffff918216600090815260026020908152604080832093909416825291909152205460ff1690565b73ffffffffffffffffffffffffffffffffffffffff8516611b9e57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f43414e4e4f545f5452414e534645525f544f5f414444524553535f5a45524f00604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff8616331480611bf7575073ffffffffffffffffffffffffffffffffffffffff8616600090815260026020908152604080832033845290915290205460ff1615156001145b611c6257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f494e53554646494349454e545f414c4c4f57414e434500000000000000000000604482015290519081900360640190fd5b611c6b84611ab9565b15611dc55782600114611cdf57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f414d4f554e545f455155414c5f544f5f4f4e455f524551554952454400000000604482015290519081900360640190fd5b60008481526020819052604090205473ffffffffffffffffffffffffffffffffffffffff878116911614611d7457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f4e46545f4e4f545f4f574e45445f42595f46524f4d5f41444452455353000000604482015290519081900360640190fd5b600084815260208190526040902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff8716179055611e74565b600084815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8a168452909152902054611dff908461244f565b600085815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8b81168552925280832093909355871681522054611e439084612473565b600085815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8a1684529091529020555b8473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f628787604051808381526020018281526020019250505060405180910390a4611f178573ffffffffffffffffffffffffffffffffffffffff1661248f565b156120f35760008573ffffffffffffffffffffffffffffffffffffffff1663f23a6e613389888888886040518763ffffffff1660e01b8152600401808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001858152602001848152602001806020018281038252848482818152602001925080828437600081840152601f19601f820116905080830192505050975050505050505050602060405180830381600087803b15801561201557600080fd5b505af1158015612029573d6000803e3d6000fd5b505050506040513d602081101561203f57600080fd5b505190507fffffffff0000000000000000000000000000000000000000000000000000000081167ff23a6e61000000000000000000000000000000000000000000000000000000001461175757604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f4241445f52454345495645525f52455455524e5f56414c554500000000000000604482015290519081900360640190fd5b505050505050565b600083815260046020526040902054839073ffffffffffffffffffffffffffffffffffffffff16331461212d57600080fd5b61213684611ab9565b61218b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602d81526020018061253d602d913960400191505060405180910390fd5b600084815260056020526040812054600101905b838110156123f75760008585838181106121b557fe5b8486018a176000818152602081815260408083208054958302979097013573ffffffffffffffffffffffffffffffffffffffff167fffffffffffffffffffffffff00000000000000000000000000000000000000009095168517909655855183815260019181019190915285519396509194869450909233927fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f6292908290030190a46122768273ffffffffffffffffffffffffffffffffffffffff1661248f565b156123ed57604080517ff23a6e6100000000000000000000000000000000000000000000000000000000815233600482018190526024820152604481018390526001606482015260a06084820152600060a48201819052915173ffffffffffffffffffffffffffffffffffffffff85169163f23a6e619160e480830192602092919082900301818787803b15801561230d57600080fd5b505af1158015612321573d6000803e3d6000fd5b505050506040513d602081101561233757600080fd5b505190507fffffffff0000000000000000000000000000000000000000000000000000000081167ff23a6e6100000000000000000000000000000000000000000000000000000000146123eb57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f4241445f52454345495645525f52455455524e5f56414c554500000000000000604482015290519081900360640190fd5b505b505060010161219f565b50600085815260056020526040902054612412908490612473565b6000958652600560205260409095209490945550505050565b7fbc197c810000000000000000000000000000000000000000000000000000000081565b60008282111561246d5761246d61246860028585612495565b612534565b50900390565b600082820183811015611a6657611a6661246860008686612495565b3b151590565b606063e946c1bb60e01b848484604051602401808460038111156124b557fe5b60ff1681526020018381526020018281526020019350505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505090509392505050565b805160208201fdfe54524945445f544f5f4d494e545f4e4f4e5f46554e4749424c455f464f525f46554e4749424c455f544f4b454e4f574e4552535f414e445f4944535f4d5553545f484156455f53414d455f4c454e47544854524945445f544f5f4d494e545f46554e4749424c455f464f525f4e4f4e5f46554e4749424c455f544f4b454ea265627a7a723158205af7d187cbffb255b374d24e5838a04f6b3a3245622025907396b2a61f9d93da64736f6c634300050c0032'; - private _methodABIIndex: { [name: string]: number } = {}; + private readonly _methodABIIndex: { [name: string]: number } = {}; private readonly _subscriptionManager: SubscriptionManager; public static async deployFrom0xArtifactAsync( artifact: ContractArtifact | SimpleContractArtifact, @@ -694,7 +694,7 @@ export class ERC1155MintableContract extends BaseContract { public getFunctionSignature(methodName: string): string { const index = this._methodABIIndex[methodName]; - const methodAbi = ERC1155MintableContract.ABI()[index] as MethodAbi; + const methodAbi = ERC1155MintableContract.ABI()[index] as MethodAbi; // tslint:disable-line:no-unnecessary-type-assertion const functionSignature = methodAbiToFunctionSignature(methodAbi); return functionSignature; } diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts b/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts index da2cb41209..340ad339ff 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts @@ -62,7 +62,7 @@ export class ERC1155ProxyContract extends BaseContract { */ public static deployedBytecode = '0x608060405234801561001057600080fd5b50600436106100be5760003560e01c8063a85e59e411610076578063b91816111161005b578063b918161114610285578063d39de6e9146102cc578063f2fde38b14610324576100be565b8063a85e59e4146101b2578063ae25532e14610248576100be565b806370712939116100a7578063707129391461013e5780638da5cb5b146101715780639ad2674414610179576100be565b806342f1181e146100c3578063494503d4146100f8575b600080fd5b6100f6600480360360208110156100d957600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610357565b005b6101156004803603602081101561010e57600080fd5b5035610543565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b6100f66004803603602081101561015457600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610577565b61011561086a565b6100f66004803603604081101561018f57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135169060200135610886565b6100f6600480360360808110156101c857600080fd5b8101906020810181356401000000008111156101e357600080fd5b8201836020820111156101f557600080fd5b8035906020019184600183028401116401000000008311171561021757600080fd5b919350915073ffffffffffffffffffffffffffffffffffffffff813581169160208101359091169060400135610c37565b610250611138565b604080517fffffffff000000000000000000000000000000000000000000000000000000009092168252519081900360200190f35b6102b86004803603602081101561029b57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16611159565b604080519115158252519081900360200190f35b6102d461116e565b60408051602080825283518183015283519192839290830191858101910280838360005b838110156103105781810151838201526020016102f8565b505050509050019250505060405180910390f35b6100f66004803603602081101561033a57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166111dd565b60005473ffffffffffffffffffffffffffffffffffffffff1633146103dd57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f4f4e4c595f434f4e54524143545f4f574e455200000000000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff811660009081526001602052604090205460ff161561047257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f5441524745545f414c52454144595f415554484f52495a454400000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff8116600081815260016020819052604080832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00168317905560028054928301815583527f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace90910180547fffffffffffffffffffffffff00000000000000000000000000000000000000001684179055513392917f3147867c59d17e8fa9d522465651d44aae0a9e38f902f3475b97e58072f0ed4c91a350565b6002818154811061055057fe5b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff16905081565b60005473ffffffffffffffffffffffffffffffffffffffff1633146105fd57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f4f4e4c595f434f4e54524143545f4f574e455200000000000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff811660009081526001602052604090205460ff1661069157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f5441524745545f4e4f545f415554484f52495a45440000000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff8116600090815260016020526040812080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690555b600254811015610823578173ffffffffffffffffffffffffffffffffffffffff166002828154811061070b57fe5b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff16141561081b57600280547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff810190811061076357fe5b6000918252602090912001546002805473ffffffffffffffffffffffffffffffffffffffff909216918390811061079657fe5b600091825260209091200180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055600280547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01906108159082611407565b50610823565b6001016106dd565b50604051339073ffffffffffffffffffffffffffffffffffffffff8316907f1f32c1b084e2de0713b8fb16bd46bb9df710a3dbeae2f3ca93af46e016dcc6b090600090a350565b60005473ffffffffffffffffffffffffffffffffffffffff1681565b60005473ffffffffffffffffffffffffffffffffffffffff16331461090c57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f4f4e4c595f434f4e54524143545f4f574e455200000000000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff821660009081526001602052604090205460ff166109a057604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f5441524745545f4e4f545f415554484f52495a45440000000000000000000000604482015290519081900360640190fd5b6002548110610a1057604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f494e4445585f4f55545f4f465f424f554e445300000000000000000000000000604482015290519081900360640190fd5b8173ffffffffffffffffffffffffffffffffffffffff1660028281548110610a3457fe5b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff1614610ac257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f415554484f52495a45445f414444524553535f4d49534d415443480000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff8216600090815260016020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169055600280547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8101908110610b3d57fe5b6000918252602090912001546002805473ffffffffffffffffffffffffffffffffffffffff9092169183908110610b7057fe5b600091825260209091200180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055600280547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190610bef9082611407565b50604051339073ffffffffffffffffffffffffffffffffffffffff8416907f1f32c1b084e2de0713b8fb16bd46bb9df710a3dbeae2f3ca93af46e016dcc6b090600090a35050565b3360009081526001602052604090205460ff16610cb557604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f53454e4445525f4e4f545f415554484f52495a45440000000000000000000000604482015290519081900360640190fd5b60006060806060610d0b60048a8a90508b8b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525092949392505063ffffffff6112c3169050565b8060200190516080811015610d1f57600080fd5b815160208301805160405192949293830192919084640100000000821115610d4657600080fd5b908301906020820185811115610d5b57600080fd5b8251866020820283011164010000000082111715610d7857600080fd5b82525081516020918201928201910280838360005b83811015610da5578181015183820152602001610d8d565b5050505090500160405260200180516040519392919084640100000000821115610dce57600080fd5b908301906020820185811115610de357600080fd5b8251866020820283011164010000000082111715610e0057600080fd5b82525081516020918201928201910280838360005b83811015610e2d578181015183820152602001610e15565b5050505090500160405260200180516040519392919084640100000000821115610e5657600080fd5b908301906020820185811115610e6b57600080fd5b8251640100000000811182820188101715610e8557600080fd5b82525081516020918201929091019080838360005b83811015610eb2578181015183820152602001610e9a565b50505050905090810190601f168015610edf5780820380516001836020036101000a031916815260200191505b506040525050509350935093509350600082519050606081604051908082528060200260200182016040528015610f20578160200160208202803883390190505b50905060005b828114610f6957610f4a858281518110610f3c57fe5b602002602001015189611306565b828281518110610f5657fe5b6020908102919091010152600101610f26565b508573ffffffffffffffffffffffffffffffffffffffff16632eb2c2d68a8a8885886040518663ffffffff1660e01b8152600401808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001806020018060200180602001848103845287818151815260200191508051906020019060200280838360005b8381101561104657818101518382015260200161102e565b50505050905001848103835286818151815260200191508051906020019060200280838360005b8381101561108557818101518382015260200161106d565b50505050905001848103825285818151815260200191508051906020019080838360005b838110156110c15781810151838201526020016110a9565b50505050905090810190601f1680156110ee5780820380516001836020036101000a031916815260200191505b5098505050505050505050600060405180830381600087803b15801561111357600080fd5b505af1158015611127573d6000803e3d6000fd5b505050505050505050505050505050565b6000604051808061144f603091396030019050604051809103902090505b90565b60016020526000908152604090205460ff1681565b606060028054806020026020016040519081016040528092919081815260200182805480156111d357602002820191906000526020600020905b815473ffffffffffffffffffffffffffffffffffffffff1681526001909101906020018083116111a8575b5050505050905090565b60005473ffffffffffffffffffffffffffffffffffffffff16331461126357604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f4f4e4c595f434f4e54524143545f4f574e455200000000000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff8116156112c057600080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83161790555b50565b6060818311156112e1576112e16112dc60008585611340565b6113df565b83518211156112fa576112fa6112dc6001848751611340565b50819003910190815290565b6000826113155750600061133a565b8282028284828161132257fe5b0414611337576113376112dc600186866113e7565b90505b92915050565b6060632800659560e01b8484846040516024018084600781111561136057fe5b60ff1681526020018381526020018281526020019350505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505090509392505050565b805160208201fd5b606063e946c1bb60e01b8484846040516024018084600381111561136057fe5b81548183558181111561142b5760008381526020902061142b918101908301611430565b505050565b61115691905b8082111561144a5760008155600101611436565b509056fe4552433131353541737365747328616464726573732c75696e743235365b5d2c75696e743235365b5d2c627974657329a265627a7a72315820be5e6597d38133fd52aac17250498790f106d5d4d0e4ab30d0e854a2db1e2ffe64736f6c634300050c0032'; - private _methodABIIndex: { [name: string]: number } = {}; + private readonly _methodABIIndex: { [name: string]: number } = {}; private readonly _subscriptionManager: SubscriptionManager; public static async deployFrom0xArtifactAsync( artifact: ContractArtifact | SimpleContractArtifact, @@ -341,7 +341,7 @@ export class ERC1155ProxyContract extends BaseContract { public getFunctionSignature(methodName: string): string { const index = this._methodABIIndex[methodName]; - const methodAbi = ERC1155ProxyContract.ABI()[index] as MethodAbi; + const methodAbi = ERC1155ProxyContract.ABI()[index] as MethodAbi; // tslint:disable-line:no-unnecessary-type-assertion const functionSignature = methodAbiToFunctionSignature(methodAbi); return functionSignature; } diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts b/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts index 525e7b1101..87e40b7ed3 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts @@ -62,7 +62,7 @@ export class ERC20ProxyContract extends BaseContract { */ public static deployedBytecode = '0x608060405234801561001057600080fd5b50600436106100a35760003560e01c80639ad2674411610076578063b91816111161005b578063b918161114610374578063d39de6e9146103bb578063f2fde38b14610413576100a3565b80639ad26744146102fe578063ae25532e14610337576100a3565b806342f1181e14610248578063494503d41461027d57806370712939146102c35780638da5cb5b146102f6575b7fffffffff00000000000000000000000000000000000000000000000000000000600035167fa85e59e40000000000000000000000000000000000000000000000000000000081141561024257604080513381526001602082015290812054610177577f08c379a0000000000000000000000000000000000000000000000000000000006000527c20000000000000000000000000000000000000000000000000000000006020527c1553454e4445525f4e4f545f415554484f52495a454400000000000000604052600060605260646000fd5b50602860043501357f23b872dd0000000000000000000000000000000000000000000000000000000060005260606024600437602060006064600080855af1600080511160203d14163d15178116905080156101cf57005b50507f08c379a0000000000000000000000000000000000000000000000000000000006000527c20000000000000000000000000000000000000000000000000000000006020527c0f5452414e534645525f4641494c454400000000000000000000000000604052600060605260646000fd5b50600080fd5b61027b6004803603602081101561025e57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610446565b005b61029a6004803603602081101561029357600080fd5b5035610632565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b61027b600480360360208110156102d957600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610666565b61029a610959565b61027b6004803603604081101561031457600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135169060200135610975565b61033f610d26565b604080517fffffffff000000000000000000000000000000000000000000000000000000009092168252519081900360200190f35b6103a76004803603602081101561038a57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610d5c565b604080519115158252519081900360200190f35b6103c3610d71565b60408051602080825283518183015283519192839290830191858101910280838360005b838110156103ff5781810151838201526020016103e7565b505050509050019250505060405180910390f35b61027b6004803603602081101561042957600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610de0565b60005473ffffffffffffffffffffffffffffffffffffffff1633146104cc57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f4f4e4c595f434f4e54524143545f4f574e455200000000000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff811660009081526001602052604090205460ff161561056157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f5441524745545f414c52454144595f415554484f52495a454400000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff8116600081815260016020819052604080832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00168317905560028054928301815583527f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace90910180547fffffffffffffffffffffffff00000000000000000000000000000000000000001684179055513392917f3147867c59d17e8fa9d522465651d44aae0a9e38f902f3475b97e58072f0ed4c91a350565b6002818154811061063f57fe5b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff16905081565b60005473ffffffffffffffffffffffffffffffffffffffff1633146106ec57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f4f4e4c595f434f4e54524143545f4f574e455200000000000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff811660009081526001602052604090205460ff1661078057604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f5441524745545f4e4f545f415554484f52495a45440000000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff8116600090815260016020526040812080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690555b600254811015610912578173ffffffffffffffffffffffffffffffffffffffff16600282815481106107fa57fe5b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff16141561090a57600280547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff810190811061085257fe5b6000918252602090912001546002805473ffffffffffffffffffffffffffffffffffffffff909216918390811061088557fe5b600091825260209091200180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055600280547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01906109049082610ec6565b50610912565b6001016107cc565b50604051339073ffffffffffffffffffffffffffffffffffffffff8316907f1f32c1b084e2de0713b8fb16bd46bb9df710a3dbeae2f3ca93af46e016dcc6b090600090a350565b60005473ffffffffffffffffffffffffffffffffffffffff1681565b60005473ffffffffffffffffffffffffffffffffffffffff1633146109fb57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f4f4e4c595f434f4e54524143545f4f574e455200000000000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff821660009081526001602052604090205460ff16610a8f57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f5441524745545f4e4f545f415554484f52495a45440000000000000000000000604482015290519081900360640190fd5b6002548110610aff57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f494e4445585f4f55545f4f465f424f554e445300000000000000000000000000604482015290519081900360640190fd5b8173ffffffffffffffffffffffffffffffffffffffff1660028281548110610b2357fe5b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff1614610bb157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f415554484f52495a45445f414444524553535f4d49534d415443480000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff8216600090815260016020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169055600280547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8101908110610c2c57fe5b6000918252602090912001546002805473ffffffffffffffffffffffffffffffffffffffff9092169183908110610c5f57fe5b600091825260209091200180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055600280547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190610cde9082610ec6565b50604051339073ffffffffffffffffffffffffffffffffffffffff8416907f1f32c1b084e2de0713b8fb16bd46bb9df710a3dbeae2f3ca93af46e016dcc6b090600090a35050565b604080517f4552433230546f6b656e28616464726573732900000000000000000000000000815290519081900360130190205b90565b60016020526000908152604090205460ff1681565b60606002805480602002602001604051908101604052809291908181526020018280548015610dd657602002820191906000526020600020905b815473ffffffffffffffffffffffffffffffffffffffff168152600190910190602001808311610dab575b5050505050905090565b60005473ffffffffffffffffffffffffffffffffffffffff163314610e6657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f4f4e4c595f434f4e54524143545f4f574e455200000000000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff811615610ec357600080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83161790555b50565b815481835581811115610eea57600083815260209020610eea918101908301610eef565b505050565b610d5991905b80821115610f095760008155600101610ef5565b509056fea265627a7a72315820cb3312567959522bd12ea03b9812cab2bace85fe5f172b3ae8014b3eacc85fa864736f6c634300050b0032'; - private _methodABIIndex: { [name: string]: number } = {}; + private readonly _methodABIIndex: { [name: string]: number } = {}; private readonly _subscriptionManager: SubscriptionManager; public static async deployFrom0xArtifactAsync( artifact: ContractArtifact | SimpleContractArtifact, @@ -322,7 +322,7 @@ export class ERC20ProxyContract extends BaseContract { public getFunctionSignature(methodName: string): string { const index = this._methodABIIndex[methodName]; - const methodAbi = ERC20ProxyContract.ABI()[index] as MethodAbi; + const methodAbi = ERC20ProxyContract.ABI()[index] as MethodAbi; // tslint:disable-line:no-unnecessary-type-assertion const functionSignature = methodAbiToFunctionSignature(methodAbi); return functionSignature; } diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts b/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts index c024421db0..c1d3579e53 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts @@ -61,7 +61,7 @@ export class ERC20TokenContract extends BaseContract { * @ignore */ public static deployedBytecode: string | undefined; - private _methodABIIndex: { [name: string]: number } = {}; + private readonly _methodABIIndex: { [name: string]: number } = {}; private readonly _subscriptionManager: SubscriptionManager; public static async deployFrom0xArtifactAsync( artifact: ContractArtifact | SimpleContractArtifact, @@ -313,7 +313,7 @@ export class ERC20TokenContract extends BaseContract { public getFunctionSignature(methodName: string): string { const index = this._methodABIIndex[methodName]; - const methodAbi = ERC20TokenContract.ABI()[index] as MethodAbi; + const methodAbi = ERC20TokenContract.ABI()[index] as MethodAbi; // tslint:disable-line:no-unnecessary-type-assertion const functionSignature = methodAbiToFunctionSignature(methodAbi); return functionSignature; } diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts b/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts index be6b27774b..c348b19b1e 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts @@ -62,7 +62,7 @@ export class ERC721ProxyContract extends BaseContract { */ public static deployedBytecode = '0x608060405234801561001057600080fd5b50600436106100a35760003560e01c80639ad2674411610076578063b91816111161005b578063b9181611146103ea578063d39de6e914610431578063f2fde38b14610489576100a3565b80639ad2674414610374578063ae25532e146103ad576100a3565b806342f1181e146102be578063494503d4146102f357806370712939146103395780638da5cb5b1461036c575b7fffffffff00000000000000000000000000000000000000000000000000000000600035167fa85e59e4000000000000000000000000000000000000000000000000000000008114156102b857604080513381526001602082015290812054610177577f08c379a0000000000000000000000000000000000000000000000000000000006000527c20000000000000000000000000000000000000000000000000000000006020527c1553454e4445525f4e4f545f415554484f52495a454400000000000000604052600060605260646000fd5b50600160643503156101f4577f08c379a0000000000000000000000000000000000000000000000000000000006000527c20000000000000000000000000000000000000000000000000000000006020527c0e494e56414c49445f414d4f554e540000000000000000000000000000604052600060605260646000fd5b7f23b872dd000000000000000000000000000000000000000000000000000000006000526040602460043760043560206048820160443760288101356000806064600080855af1915050801561024657005b507f08c379a0000000000000000000000000000000000000000000000000000000006000527c20000000000000000000000000000000000000000000000000000000006020527c0f5452414e534645525f4641494c454400000000000000000000000000604052600060605260646000fd5b50600080fd5b6102f1600480360360208110156102d457600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166104bc565b005b6103106004803603602081101561030957600080fd5b50356106a8565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b6102f16004803603602081101561034f57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166106dc565b6103106109cf565b6102f16004803603604081101561038a57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81351690602001356109eb565b6103b5610d9c565b604080517fffffffff000000000000000000000000000000000000000000000000000000009092168252519081900360200190f35b61041d6004803603602081101561040057600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610dd2565b604080519115158252519081900360200190f35b610439610de7565b60408051602080825283518183015283519192839290830191858101910280838360005b8381101561047557818101518382015260200161045d565b505050509050019250505060405180910390f35b6102f16004803603602081101561049f57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610e56565b60005473ffffffffffffffffffffffffffffffffffffffff16331461054257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f4f4e4c595f434f4e54524143545f4f574e455200000000000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff811660009081526001602052604090205460ff16156105d757604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f5441524745545f414c52454144595f415554484f52495a454400000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff8116600081815260016020819052604080832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00168317905560028054928301815583527f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace90910180547fffffffffffffffffffffffff00000000000000000000000000000000000000001684179055513392917f3147867c59d17e8fa9d522465651d44aae0a9e38f902f3475b97e58072f0ed4c91a350565b600281815481106106b557fe5b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff16905081565b60005473ffffffffffffffffffffffffffffffffffffffff16331461076257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f4f4e4c595f434f4e54524143545f4f574e455200000000000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff811660009081526001602052604090205460ff166107f657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f5441524745545f4e4f545f415554484f52495a45440000000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff8116600090815260016020526040812080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690555b600254811015610988578173ffffffffffffffffffffffffffffffffffffffff166002828154811061087057fe5b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff16141561098057600280547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81019081106108c857fe5b6000918252602090912001546002805473ffffffffffffffffffffffffffffffffffffffff90921691839081106108fb57fe5b600091825260209091200180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055600280547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff019061097a9082610f3c565b50610988565b600101610842565b50604051339073ffffffffffffffffffffffffffffffffffffffff8316907f1f32c1b084e2de0713b8fb16bd46bb9df710a3dbeae2f3ca93af46e016dcc6b090600090a350565b60005473ffffffffffffffffffffffffffffffffffffffff1681565b60005473ffffffffffffffffffffffffffffffffffffffff163314610a7157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f4f4e4c595f434f4e54524143545f4f574e455200000000000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff821660009081526001602052604090205460ff16610b0557604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f5441524745545f4e4f545f415554484f52495a45440000000000000000000000604482015290519081900360640190fd5b6002548110610b7557604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f494e4445585f4f55545f4f465f424f554e445300000000000000000000000000604482015290519081900360640190fd5b8173ffffffffffffffffffffffffffffffffffffffff1660028281548110610b9957fe5b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff1614610c2757604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f415554484f52495a45445f414444524553535f4d49534d415443480000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff8216600090815260016020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169055600280547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8101908110610ca257fe5b6000918252602090912001546002805473ffffffffffffffffffffffffffffffffffffffff9092169183908110610cd557fe5b600091825260209091200180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055600280547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190610d549082610f3c565b50604051339073ffffffffffffffffffffffffffffffffffffffff8416907f1f32c1b084e2de0713b8fb16bd46bb9df710a3dbeae2f3ca93af46e016dcc6b090600090a35050565b604080517f455243373231546f6b656e28616464726573732c75696e7432353629000000008152905190819003601c0190205b90565b60016020526000908152604090205460ff1681565b60606002805480602002602001604051908101604052809291908181526020018280548015610e4c57602002820191906000526020600020905b815473ffffffffffffffffffffffffffffffffffffffff168152600190910190602001808311610e21575b5050505050905090565b60005473ffffffffffffffffffffffffffffffffffffffff163314610edc57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f4f4e4c595f434f4e54524143545f4f574e455200000000000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff811615610f3957600080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83161790555b50565b815481835581811115610f6057600083815260209020610f60918101908301610f65565b505050565b610dcf91905b80821115610f7f5760008155600101610f6b565b509056fea265627a7a723158201e53a891f6df3931041b820f71387e9eecd97f7ea0d346c54fab37668bd022ec64736f6c634300050b0032'; - private _methodABIIndex: { [name: string]: number } = {}; + private readonly _methodABIIndex: { [name: string]: number } = {}; private readonly _subscriptionManager: SubscriptionManager; public static async deployFrom0xArtifactAsync( artifact: ContractArtifact | SimpleContractArtifact, @@ -322,7 +322,7 @@ export class ERC721ProxyContract extends BaseContract { public getFunctionSignature(methodName: string): string { const index = this._methodABIIndex[methodName]; - const methodAbi = ERC721ProxyContract.ABI()[index] as MethodAbi; + const methodAbi = ERC721ProxyContract.ABI()[index] as MethodAbi; // tslint:disable-line:no-unnecessary-type-assertion const functionSignature = methodAbiToFunctionSignature(methodAbi); return functionSignature; } diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts b/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts index 391b590a1b..7892de27fb 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts @@ -71,7 +71,7 @@ export class ERC721TokenContract extends BaseContract { * @ignore */ public static deployedBytecode: string | undefined; - private _methodABIIndex: { [name: string]: number } = {}; + private readonly _methodABIIndex: { [name: string]: number } = {}; private readonly _subscriptionManager: SubscriptionManager; public static async deployFrom0xArtifactAsync( artifact: ContractArtifact | SimpleContractArtifact, @@ -403,7 +403,7 @@ export class ERC721TokenContract extends BaseContract { public getFunctionSignature(methodName: string): string { const index = this._methodABIIndex[methodName]; - const methodAbi = ERC721TokenContract.ABI()[index] as MethodAbi; + const methodAbi = ERC721TokenContract.ABI()[index] as MethodAbi; // tslint:disable-line:no-unnecessary-type-assertion const functionSignature = methodAbiToFunctionSignature(methodAbi); return functionSignature; } diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/eth_balance_checker.ts b/packages/abi-gen-wrappers/src/generated-wrappers/eth_balance_checker.ts index 3d015e1604..7af7d98d53 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/eth_balance_checker.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/eth_balance_checker.ts @@ -40,7 +40,7 @@ export class EthBalanceCheckerContract extends BaseContract { * @ignore */ public static deployedBytecode: string | undefined; - private _methodABIIndex: { [name: string]: number } = {}; + private readonly _methodABIIndex: { [name: string]: number } = {}; public static async deployFrom0xArtifactAsync( artifact: ContractArtifact | SimpleContractArtifact, supportedProvider: SupportedProvider, @@ -135,7 +135,7 @@ export class EthBalanceCheckerContract extends BaseContract { public getFunctionSignature(methodName: string): string { const index = this._methodABIIndex[methodName]; - const methodAbi = EthBalanceCheckerContract.ABI()[index] as MethodAbi; + const methodAbi = EthBalanceCheckerContract.ABI()[index] as MethodAbi; // tslint:disable-line:no-unnecessary-type-assertion const functionSignature = methodAbiToFunctionSignature(methodAbi); return functionSignature; } diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts b/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts index fc4dd289cf..d56ee22154 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts @@ -120,7 +120,7 @@ export class ExchangeContract extends BaseContract { * @ignore */ public static deployedBytecode: string | undefined; - private _methodABIIndex: { [name: string]: number } = {}; + private readonly _methodABIIndex: { [name: string]: number } = {}; private readonly _subscriptionManager: SubscriptionManager; public static async deployFrom0xArtifactAsync( artifact: ContractArtifact | SimpleContractArtifact, @@ -3078,7 +3078,7 @@ export class ExchangeContract extends BaseContract { public getFunctionSignature(methodName: string): string { const index = this._methodABIIndex[methodName]; - const methodAbi = ExchangeContract.ABI()[index] as MethodAbi; + const methodAbi = ExchangeContract.ABI()[index] as MethodAbi; // tslint:disable-line:no-unnecessary-type-assertion const functionSignature = methodAbiToFunctionSignature(methodAbi); return functionSignature; } diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts b/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts index ba3fa9e2e0..9de6c3f8f2 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts @@ -40,7 +40,7 @@ export class ForwarderContract extends BaseContract { * @ignore */ public static deployedBytecode: string | undefined; - private _methodABIIndex: { [name: string]: number } = {}; + private readonly _methodABIIndex: { [name: string]: number } = {}; public static async deployFrom0xArtifactAsync( artifact: ContractArtifact | SimpleContractArtifact, supportedProvider: SupportedProvider, @@ -413,7 +413,7 @@ export class ForwarderContract extends BaseContract { public getFunctionSignature(methodName: string): string { const index = this._methodABIIndex[methodName]; - const methodAbi = ForwarderContract.ABI()[index] as MethodAbi; + const methodAbi = ForwarderContract.ABI()[index] as MethodAbi; // tslint:disable-line:no-unnecessary-type-assertion const functionSignature = methodAbiToFunctionSignature(methodAbi); return functionSignature; } diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/i_asset_proxy.ts b/packages/abi-gen-wrappers/src/generated-wrappers/i_asset_proxy.ts index 57ec1480df..da7037eda3 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/i_asset_proxy.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/i_asset_proxy.ts @@ -40,7 +40,7 @@ export class IAssetProxyContract extends BaseContract { * @ignore */ public static deployedBytecode: string | undefined; - private _methodABIIndex: { [name: string]: number } = {}; + private readonly _methodABIIndex: { [name: string]: number } = {}; public static async deployFrom0xArtifactAsync( artifact: ContractArtifact | SimpleContractArtifact, supportedProvider: SupportedProvider, @@ -156,7 +156,7 @@ export class IAssetProxyContract extends BaseContract { public getFunctionSignature(methodName: string): string { const index = this._methodABIIndex[methodName]; - const methodAbi = IAssetProxyContract.ABI()[index] as MethodAbi; + const methodAbi = IAssetProxyContract.ABI()[index] as MethodAbi; // tslint:disable-line:no-unnecessary-type-assertion const functionSignature = methodAbiToFunctionSignature(methodAbi); return functionSignature; } diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/i_validator.ts b/packages/abi-gen-wrappers/src/generated-wrappers/i_validator.ts index b0120f9670..b629383e3b 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/i_validator.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/i_validator.ts @@ -40,7 +40,7 @@ export class IValidatorContract extends BaseContract { * @ignore */ public static deployedBytecode: string | undefined; - private _methodABIIndex: { [name: string]: number } = {}; + private readonly _methodABIIndex: { [name: string]: number } = {}; public static async deployFrom0xArtifactAsync( artifact: ContractArtifact | SimpleContractArtifact, supportedProvider: SupportedProvider, @@ -143,7 +143,7 @@ export class IValidatorContract extends BaseContract { public getFunctionSignature(methodName: string): string { const index = this._methodABIIndex[methodName]; - const methodAbi = IValidatorContract.ABI()[index] as MethodAbi; + const methodAbi = IValidatorContract.ABI()[index] as MethodAbi; // tslint:disable-line:no-unnecessary-type-assertion const functionSignature = methodAbiToFunctionSignature(methodAbi); return functionSignature; } diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/i_wallet.ts b/packages/abi-gen-wrappers/src/generated-wrappers/i_wallet.ts index 2c58f37459..c2515d963c 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/i_wallet.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/i_wallet.ts @@ -40,7 +40,7 @@ export class IWalletContract extends BaseContract { * @ignore */ public static deployedBytecode: string | undefined; - private _methodABIIndex: { [name: string]: number } = {}; + private readonly _methodABIIndex: { [name: string]: number } = {}; public static async deployFrom0xArtifactAsync( artifact: ContractArtifact | SimpleContractArtifact, supportedProvider: SupportedProvider, @@ -139,7 +139,7 @@ export class IWalletContract extends BaseContract { public getFunctionSignature(methodName: string): string { const index = this._methodABIIndex[methodName]; - const methodAbi = IWalletContract.ABI()[index] as MethodAbi; + const methodAbi = IWalletContract.ABI()[index] as MethodAbi; // tslint:disable-line:no-unnecessary-type-assertion const functionSignature = methodAbiToFunctionSignature(methodAbi); return functionSignature; } diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/multi_asset_proxy.ts b/packages/abi-gen-wrappers/src/generated-wrappers/multi_asset_proxy.ts index 45dc76173e..7c6189ff1b 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/multi_asset_proxy.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/multi_asset_proxy.ts @@ -69,7 +69,7 @@ export class MultiAssetProxyContract extends BaseContract { */ public static deployedBytecode = '0x608060405234801561001057600080fd5b50600436106100d45760003560e01c80639ad2674411610081578063c585bb931161005b578063c585bb9314610789578063d39de6e9146107bc578063f2fde38b14610814576100d4565b80639ad26744146106cc578063ae25532e14610705578063b918161114610742576100d4565b806360704108116100b2578063607041081461065257806370712939146106915780638da5cb5b146106c4576100d4565b80633fd3c9971461059857806342f1181e14610600578063494503d414610635575b7fffffffff00000000000000000000000000000000000000000000000000000000600035167fa85e59e400000000000000000000000000000000000000000000000000000000811415610592573360005260026020526040600020546101a5577f08c379a0000000000000000000000000000000000000000000000000000000006000527c20000000000000000000000000000000000000000000000000000000006020527c1553454e4445525f4e4f545f415554484f52495a454400000000000000604052600060605260646000fd5b600480350180356020600482030660448210171561022e577f08c379a0000000000000000000000000000000000000000000000000000000006000527c20000000000000000000000000000000000000000000000000000000006020527c19494e56414c49445f41535345545f444154415f4c454e475448000000604052600060605260646000fd5b602081018201368111156102ad577f08c379a0000000000000000000000000000000000000000000000000000000006000527c20000000000000000000000000000000000000000000000000000000006020527c16494e56414c49445f41535345545f444154415f454e44000000000000604052600060605260646000fd5b5050602481013560448201356044820183016020810335925060448201840160208103358085031561034a577f08c379a0000000000000000000000000000000000000000000000000000000006000527c20000000000000000000000000000000000000000000000000000000006020527c0f4c454e4754485f4d49534d4154434800000000000000000000000000604052600060605260646000fd5b5060646000803760806004526000936064359060200285805b82811015610587578086013584810281868204148615176103ef577f08c379a0000000000000000000000000000000000000000000000000000000006000527c20000000000000000000000000000000000000000000000000000000006020527c1055494e543235365f4f564552464c4f57000000000000000000000000604052600060605260646000fd5b60649081528287013589018b01604481019250018135600481101561049e577f08c379a0000000000000000000000000000000000000000000000000000000006000527c20000000000000000000000000000000000000000000000000000000006020527c1e4c454e4754485f475245415445525f5448414e5f335f5245515549526040527f454400000000000000000000000000000000000000000000000000000000000060605260646000fd5b7fffffffff000000000000000000000000000000000000000000000000000000008235168b8103156104df57809b508b608452600160a45260406084205495505b5084610556577f08c379a0000000000000000000000000000000000000000000000000000000006000527c20000000000000000000000000000000000000000000000000000000006020527c1a41535345545f50524f58595f444f45535f4e4f545f45584953540000604052600060605260646000fd5b60208101836084376000808260a401600080895af1925050508061057e573d6000803e3d6000fd5b50602001610363565b505050505050505050005b50600080fd5b6105d7600480360360208110156105ae57600080fd5b50357fffffffff0000000000000000000000000000000000000000000000000000000016610847565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b6106336004803603602081101561061657600080fd5b503573ffffffffffffffffffffffffffffffffffffffff1661086f565b005b6105d76004803603602081101561064b57600080fd5b5035610a5b565b6105d76004803603602081101561066857600080fd5b50357fffffffff0000000000000000000000000000000000000000000000000000000016610a8f565b610633600480360360208110156106a757600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610ad9565b6105d7610dcc565b610633600480360360408110156106e257600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135169060200135610de8565b61070d611199565b604080517fffffffff000000000000000000000000000000000000000000000000000000009092168252519081900360200190f35b6107756004803603602081101561075857600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166111cf565b604080519115158252519081900360200190f35b6106336004803603602081101561079f57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166111e4565b6107c4611446565b60408051602080825283518183015283519192839290830191858101910280838360005b838110156108005781810151838201526020016107e8565b505050509050019250505060405180910390f35b6106336004803603602081101561082a57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166114b5565b60016020526000908152604090205473ffffffffffffffffffffffffffffffffffffffff1681565b60005473ffffffffffffffffffffffffffffffffffffffff1633146108f557604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f4f4e4c595f434f4e54524143545f4f574e455200000000000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff811660009081526002602052604090205460ff161561098a57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f5441524745545f414c52454144595f415554484f52495a454400000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff811660008181526002602052604080822080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600190811790915560038054918201815583527fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b0180547fffffffffffffffffffffffff00000000000000000000000000000000000000001684179055513392917f3147867c59d17e8fa9d522465651d44aae0a9e38f902f3475b97e58072f0ed4c91a350565b60038181548110610a6857fe5b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff16905081565b7fffffffff000000000000000000000000000000000000000000000000000000001660009081526001602052604090205473ffffffffffffffffffffffffffffffffffffffff1690565b60005473ffffffffffffffffffffffffffffffffffffffff163314610b5f57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f4f4e4c595f434f4e54524143545f4f574e455200000000000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff811660009081526002602052604090205460ff16610bf357604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f5441524745545f4e4f545f415554484f52495a45440000000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff8116600090815260026020526040812080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690555b600354811015610d85578173ffffffffffffffffffffffffffffffffffffffff1660038281548110610c6d57fe5b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff161415610d7d57600380547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8101908110610cc557fe5b6000918252602090912001546003805473ffffffffffffffffffffffffffffffffffffffff9092169183908110610cf857fe5b600091825260209091200180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055600380547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190610d77908261159b565b50610d85565b600101610c3f565b50604051339073ffffffffffffffffffffffffffffffffffffffff8316907f1f32c1b084e2de0713b8fb16bd46bb9df710a3dbeae2f3ca93af46e016dcc6b090600090a350565b60005473ffffffffffffffffffffffffffffffffffffffff1681565b60005473ffffffffffffffffffffffffffffffffffffffff163314610e6e57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f4f4e4c595f434f4e54524143545f4f574e455200000000000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff821660009081526002602052604090205460ff16610f0257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f5441524745545f4e4f545f415554484f52495a45440000000000000000000000604482015290519081900360640190fd5b6003548110610f7257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f494e4445585f4f55545f4f465f424f554e445300000000000000000000000000604482015290519081900360640190fd5b8173ffffffffffffffffffffffffffffffffffffffff1660038281548110610f9657fe5b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff161461102457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f415554484f52495a45445f414444524553535f4d49534d415443480000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff8216600090815260026020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169055600380547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff810190811061109f57fe5b6000918252602090912001546003805473ffffffffffffffffffffffffffffffffffffffff90921691839081106110d257fe5b600091825260209091200180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055600380547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190611151908261159b565b50604051339073ffffffffffffffffffffffffffffffffffffffff8416907f1f32c1b084e2de0713b8fb16bd46bb9df710a3dbeae2f3ca93af46e016dcc6b090600090a35050565b604080517f4d756c746941737365742875696e743235365b5d2c62797465735b5d290000008152905190819003601d0190205b90565b60026020526000908152604090205460ff1681565b60005473ffffffffffffffffffffffffffffffffffffffff16331461126a57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f4f4e4c595f434f4e54524143545f4f574e455200000000000000000000000000604482015290519081900360640190fd5b60008173ffffffffffffffffffffffffffffffffffffffff1663ae25532e6040518163ffffffff1660e01b815260040160206040518083038186803b1580156112b257600080fd5b505afa1580156112c6573d6000803e3d6000fd5b505050506040513d60208110156112dc57600080fd5b50517fffffffff00000000000000000000000000000000000000000000000000000000811660009081526001602052604090205490915073ffffffffffffffffffffffffffffffffffffffff16801561139657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f41535345545f50524f58595f414c52454144595f455849535453000000000000604482015290519081900360640190fd5b7fffffffff00000000000000000000000000000000000000000000000000000000821660008181526001602090815260409182902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff881690811790915582519384529083015280517fd2c6b762299c609bdb96520b58a49bfb80186934d4f71a86a367571a15c031949281900390910190a1505050565b606060038054806020026020016040519081016040528092919081815260200182805480156114ab57602002820191906000526020600020905b815473ffffffffffffffffffffffffffffffffffffffff168152600190910190602001808311611480575b5050505050905090565b60005473ffffffffffffffffffffffffffffffffffffffff16331461153b57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f4f4e4c595f434f4e54524143545f4f574e455200000000000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff81161561159857600080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83161790555b50565b8154818355818111156115bf576000838152602090206115bf9181019083016115c4565b505050565b6111cc91905b808211156115de57600081556001016115ca565b509056fea265627a7a72315820ff218c9e47c47135d1028b03281d63826ba3569217fc501ee67c0661fa98fc5164736f6c634300050b0032'; - private _methodABIIndex: { [name: string]: number } = {}; + private readonly _methodABIIndex: { [name: string]: number } = {}; private readonly _subscriptionManager: SubscriptionManager; public static async deployFrom0xArtifactAsync( artifact: ContractArtifact | SimpleContractArtifact, @@ -399,7 +399,7 @@ export class MultiAssetProxyContract extends BaseContract { public getFunctionSignature(methodName: string): string { const index = this._methodABIIndex[methodName]; - const methodAbi = MultiAssetProxyContract.ABI()[index] as MethodAbi; + const methodAbi = MultiAssetProxyContract.ABI()[index] as MethodAbi; // tslint:disable-line:no-unnecessary-type-assertion const functionSignature = methodAbiToFunctionSignature(methodAbi); return functionSignature; } diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/order_validator.ts b/packages/abi-gen-wrappers/src/generated-wrappers/order_validator.ts index acd8ba4ec1..0629a8c2e6 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/order_validator.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/order_validator.ts @@ -40,7 +40,7 @@ export class OrderValidatorContract extends BaseContract { * @ignore */ public static deployedBytecode: string | undefined; - private _methodABIIndex: { [name: string]: number } = {}; + private readonly _methodABIIndex: { [name: string]: number } = {}; public static async deployFrom0xArtifactAsync( artifact: ContractArtifact | SimpleContractArtifact, supportedProvider: SupportedProvider, @@ -689,7 +689,7 @@ export class OrderValidatorContract extends BaseContract { public getFunctionSignature(methodName: string): string { const index = this._methodABIIndex[methodName]; - const methodAbi = OrderValidatorContract.ABI()[index] as MethodAbi; + const methodAbi = OrderValidatorContract.ABI()[index] as MethodAbi; // tslint:disable-line:no-unnecessary-type-assertion const functionSignature = methodAbiToFunctionSignature(methodAbi); return functionSignature; } diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/staking.ts b/packages/abi-gen-wrappers/src/generated-wrappers/staking.ts index 978bdc798e..f2dee82f92 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/staking.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/staking.ts @@ -172,7 +172,7 @@ export class StakingContract extends BaseContract { * @ignore */ public static deployedBytecode: string | undefined; - private _methodABIIndex: { [name: string]: number } = {}; + private readonly _methodABIIndex: { [name: string]: number } = {}; private readonly _subscriptionManager: SubscriptionManager; public static async deployFrom0xArtifactAsync( artifact: ContractArtifact | SimpleContractArtifact, @@ -1614,7 +1614,7 @@ export class StakingContract extends BaseContract { public getFunctionSignature(methodName: string): string { const index = this._methodABIIndex[methodName]; - const methodAbi = StakingContract.ABI()[index] as MethodAbi; + const methodAbi = StakingContract.ABI()[index] as MethodAbi; // tslint:disable-line:no-unnecessary-type-assertion const functionSignature = methodAbiToFunctionSignature(methodAbi); return functionSignature; } diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/staking_proxy.ts b/packages/abi-gen-wrappers/src/generated-wrappers/staking_proxy.ts index e2317306dc..f30c275c1f 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/staking_proxy.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/staking_proxy.ts @@ -78,7 +78,7 @@ export class StakingProxyContract extends BaseContract { * @ignore */ public static deployedBytecode: string | undefined; - private _methodABIIndex: { [name: string]: number } = {}; + private readonly _methodABIIndex: { [name: string]: number } = {}; private readonly _subscriptionManager: SubscriptionManager; public static async deployFrom0xArtifactAsync( artifact: ContractArtifact | SimpleContractArtifact, @@ -701,7 +701,7 @@ export class StakingProxyContract extends BaseContract { public getFunctionSignature(methodName: string): string { const index = this._methodABIIndex[methodName]; - const methodAbi = StakingProxyContract.ABI()[index] as MethodAbi; + const methodAbi = StakingProxyContract.ABI()[index] as MethodAbi; // tslint:disable-line:no-unnecessary-type-assertion const functionSignature = methodAbiToFunctionSignature(methodAbi); return functionSignature; } diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/static_call_proxy.ts b/packages/abi-gen-wrappers/src/generated-wrappers/static_call_proxy.ts index 834bf73d2f..c4ce57c1b2 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/static_call_proxy.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/static_call_proxy.ts @@ -41,7 +41,7 @@ export class StaticCallProxyContract extends BaseContract { */ public static deployedBytecode = '0x608060405234801561001057600080fd5b50600436106100365760003560e01c8063a85e59e41461003b578063ae25532e146100d3575b600080fd5b6100d16004803603608081101561005157600080fd5b81019060208101813564010000000081111561006c57600080fd5b82018360208201111561007e57600080fd5b803590602001918460018302840111640100000000831117156100a057600080fd5b919350915073ffffffffffffffffffffffffffffffffffffffff813581169160208101359091169060400135610110565b005b6100db6103a5565b604080517fffffffff000000000000000000000000000000000000000000000000000000009092168252519081900360200190f35b6000606060006101656004898990508a8a8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525092949392505063ffffffff6103c5169050565b806020019051606081101561017957600080fd5b8151602083018051604051929492938301929190846401000000008211156101a057600080fd5b9083019060208201858111156101b557600080fd5b82516401000000008111828201881017156101cf57600080fd5b82525081516020918201929091019080838360005b838110156101fc5781810151838201526020016101e4565b50505050905090810190601f1680156102295780820380516001836020036101000a031916815260200191505b5060405260200180519060200190929190505050925092509250600060608473ffffffffffffffffffffffffffffffffffffffff16846040518082805190602001908083835b602083106102ac57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161026f565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855afa9150503d806000811461030c576040519150601f19603f3d011682016040523d82523d6000602084013e610311565b606091505b50915091508161032357805160208201fd5b8051602082012083811461039857604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f554e45585045435445445f5354415449435f43414c4c5f524553554c54000000604482015290519081900360640190fd5b5050505050505050505050565b600060405180806104b06021913960210190506040518091039020905090565b6060818311156103e3576103e36103de60008585610408565b6104a7565b83518211156103fc576103fc6103de6001848751610408565b50819003910190815290565b6060632800659560e01b8484846040516024018084600781111561042857fe5b60ff1681526020018381526020018281526020019350505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505090509392505050565b805160208201fdfe53746174696343616c6c28616464726573732c62797465732c6279746573333229a265627a7a72315820c55cf13cfcaaf322238d786911313ce7d45854692241ae9b56709bdbfed4f54c64736f6c634300050b0032'; - private _methodABIIndex: { [name: string]: number } = {}; + private readonly _methodABIIndex: { [name: string]: number } = {}; public static async deployFrom0xArtifactAsync( artifact: ContractArtifact | SimpleContractArtifact, supportedProvider: SupportedProvider, @@ -157,7 +157,7 @@ export class StaticCallProxyContract extends BaseContract { public getFunctionSignature(methodName: string): string { const index = this._methodABIIndex[methodName]; - const methodAbi = StaticCallProxyContract.ABI()[index] as MethodAbi; + const methodAbi = StaticCallProxyContract.ABI()[index] as MethodAbi; // tslint:disable-line:no-unnecessary-type-assertion const functionSignature = methodAbiToFunctionSignature(methodAbi); return functionSignature; } diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts b/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts index 30f9c6a7f0..a8f5b15c5f 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts @@ -77,7 +77,7 @@ export class WETH9Contract extends BaseContract { * @ignore */ public static deployedBytecode: string | undefined; - private _methodABIIndex: { [name: string]: number } = {}; + private readonly _methodABIIndex: { [name: string]: number } = {}; private readonly _subscriptionManager: SubscriptionManager; public static async deployFrom0xArtifactAsync( artifact: ContractArtifact | SimpleContractArtifact, @@ -437,7 +437,7 @@ export class WETH9Contract extends BaseContract { public getFunctionSignature(methodName: string): string { const index = this._methodABIIndex[methodName]; - const methodAbi = WETH9Contract.ABI()[index] as MethodAbi; + const methodAbi = WETH9Contract.ABI()[index] as MethodAbi; // tslint:disable-line:no-unnecessary-type-assertion const functionSignature = methodAbiToFunctionSignature(methodAbi); return functionSignature; } diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts b/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts index 2aa19aea36..cc95cd3151 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts @@ -61,7 +61,7 @@ export class ZRXTokenContract extends BaseContract { * @ignore */ public static deployedBytecode: string | undefined; - private _methodABIIndex: { [name: string]: number } = {}; + private readonly _methodABIIndex: { [name: string]: number } = {}; private readonly _subscriptionManager: SubscriptionManager; public static async deployFrom0xArtifactAsync( artifact: ContractArtifact | SimpleContractArtifact, @@ -352,7 +352,7 @@ export class ZRXTokenContract extends BaseContract { public getFunctionSignature(methodName: string): string { const index = this._methodABIIndex[methodName]; - const methodAbi = ZRXTokenContract.ABI()[index] as MethodAbi; + const methodAbi = ZRXTokenContract.ABI()[index] as MethodAbi; // tslint:disable-line:no-unnecessary-type-assertion const functionSignature = methodAbiToFunctionSignature(methodAbi); return functionSignature; } diff --git a/packages/abi-gen/templates/TypeScript/contract.handlebars b/packages/abi-gen/templates/TypeScript/contract.handlebars index 606a3e0732..8a06e04f6d 100644 --- a/packages/abi-gen/templates/TypeScript/contract.handlebars +++ b/packages/abi-gen/templates/TypeScript/contract.handlebars @@ -65,7 +65,7 @@ export class {{contractName}}Contract extends BaseContract { {{else~}} public static deployedBytecode = '{{this.deployedBytecode}}'; {{/ifEquals~}} - private _methodABIIndex: { [name:string]: number } = {}; + private readonly _methodABIIndex: { [name:string]: number } = {}; {{#if events~}} private readonly _subscriptionManager: SubscriptionManager<{{contractName}}EventArgs, {{contractName}}Events>; {{/if~}} @@ -167,7 +167,7 @@ export class {{contractName}}Contract extends BaseContract { public getFunctionSignature(methodName: string): string { const index = this._methodABIIndex[methodName]; - const methodAbi = {{contractName}}Contract.ABI()[index] as MethodAbi; + const methodAbi = {{contractName}}Contract.ABI()[index] as MethodAbi; // tslint:disable-line:no-unnecessary-type-assertion const functionSignature = methodAbiToFunctionSignature(methodAbi); return functionSignature; } diff --git a/packages/abi-gen/test-cli/output/typescript/abi_gen_dummy.ts b/packages/abi-gen/test-cli/output/typescript/abi_gen_dummy.ts index cd0c70c3d1..b1ec054a4b 100644 --- a/packages/abi-gen/test-cli/output/typescript/abi_gen_dummy.ts +++ b/packages/abi-gen/test-cli/output/typescript/abi_gen_dummy.ts @@ -60,7 +60,7 @@ export class AbiGenDummyContract extends BaseContract { */ public static deployedBytecode = '0x608060405234801561001057600080fd5b50600436106101d95760003560e01c806376f15d5b11610104578063bb607362116100a2578063d88be12f11610071578063d88be12f1461039b578063ee8b86fb146103a3578063f408fb3114610279578063fa315f9d146103b6576101d9565b8063bb60736214610353578063bdab168814610369578063cd3c0b971461037e578063d6d7618c14610386576101d9565b80638ee52b4e116100de5780638ee52b4e146103225780639a3b618514610335578063a3c2f6b61461033d578063ae2dae1714610345576101d9565b806376f15d5b146102f25780637833bec0146102fa5780637a791e6e1461031a576101d9565b80634303a5421161017c57806359c28add1161014b57806359c28add146102b45780635ba3c7c0146102c957806363d69c88146102d1578063647341eb146102e4576101d9565b80634303a542146102875780634582eab21461028f57806345fdbdb714610297578063586f84b21461029f576101d9565b80632e1a7d4d116101b85780632e1a7d4d146102245780633687617d1461023757806336b32396146102595780633e9ef66a14610279576101d9565b806209e437146101de5780630527c28f146101e85780631310e444146101fb575b600080fd5b6101e66103c4565b005b6101e66101f6366004610c7f565b610401565b61020e610209366004610d87565b610404565b60405161021b91906113e8565b60405180910390f35b6101e6610232366004610d87565b61040b565b61024a610245366004610efc565b61045c565b60405161021b93929190611151565b61026c610267366004610d0b565b6104fc565b60405161021b9190611094565b6101e66101f6366004610d4c565b61020e6105de565b6101e66105e5565b6101e661064a565b6102a761067c565b60405161021b9190611373565b6102bc610684565b60405161021b919061137e565b6101e661068c565b61026c6102df366004610c2e565b6106f1565b6101e66101f6366004610ec9565b61020e6106fa565b61030d610308366004610d9f565b610708565b60405161021b9190611287565b6101e66107c5565b61020e610330366004610d87565b6107ca565b6101e66107d0565b61020e6107db565b6101e66101f6366004610e39565b61035b6107e0565b60405161021b9291906113f1565b610371610819565b60405161021b91906110b5565b6101e661081e565b61038e610855565b60405161021b91906113d5565b61020e6109ae565b6101e66103b1366004610d87565b6101f6565b6101e66101f6366004610d87565b6040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103f690611250565b60405180910390fd5b565b50565b506107c790565b3373ffffffffffffffffffffffffffffffffffffffff167f7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b658260405161045191906113e8565b60405180910390a250565b505060408051808201825260048082527f1234567800000000000000000000000000000000000000000000000000000000602080840191909152835180850185528281527f87654321000000000000000000000000000000000000000000000000000000008183015284518086019095529184527f616d657400000000000000000000000000000000000000000000000000000000908401529093909250565b600060606040518060400160405280601c81526020017f19457468657265756d205369676e6564204d6573736167653a0a33320000000081525090506000818760405160200161054d929190611072565b604051602081830303815290604052805190602001209050600181878787604051600081526020016040526040516105889493929190611133565b6020604051602081039080840390855afa1580156105aa573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015198975050505050505050565b6107c75b90565b604080518082018252601481527f5245564552545f574954485f434f4e5354414e54000000000000000000000000602082015290517f08c379a00000000000000000000000000000000000000000000000000000000081526103f69190600401611193565b6040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103f690611219565b6105e26109b4565b6105e26109cc565b604080518082018252601581527f524551554952455f574954485f434f4e5354414e540000000000000000000000602082015290517f08c379a00000000000000000000000000000000000000000000000000000000081526103f69190600401611193565b50929392505050565b600080546001019081905590565b6107106109ec565b50604080516080810182529182528051808201825260048082527f123456780000000000000000000000000000000000000000000000000000000060208381019190915280850192909252825180840184528181527f87654321000000000000000000000000000000000000000000000000000000008184015284840152825180840190935282527f616d65740000000000000000000000000000000000000000000000000000000090820152606082015290565b6103ff565b60010190565b600080546001019055565b600190565b60408051808201909152600581527f68656c6c6f0000000000000000000000000000000000000000000000000000006020820152600191565b606090565b7f61a6029a4c7ddee5824d171331eecbd015d26a271310a223718b837facb5b77160405161084b906111ad565b60405180910390a1565b61085d610a1a565b6040805160028082526060828101909352816020015b60608152602001906001900390816108735790505090506040518060400160405280600581526020017f3078313233000000000000000000000000000000000000000000000000000000815250816000815181106108cd57fe5b60200260200101819052506040518060400160405280600581526020017f30783332310000000000000000000000000000000000000000000000000000008152508160018151811061091b57fe5b6020908102919091018101919091526040805160c0810182526005608082018181527f307831323300000000000000000000000000000000000000000000000000000060a0840152825281840152808201939093528051808201909152600381527f6162630000000000000000000000000000000000000000000000000000000000918101919091526060820152905090565b6104d290565b60405180602001604052806109c7610a48565b905290565b60405180604001604052806109df610a1a565b8152602001606081525090565b60405180608001604052806109ff610a5b565b81526020016060815260200160608152602001606081525090565b604051806080016040528060608152602001600063ffffffff16815260200160608152602001606081525090565b6040518060200160405280600081525090565b60405180606001604052806000815260200160608152602001606081525090565b600082601f830112610a8c578081fd5b8135610a9f610a9a82611431565b61140a565b8181529150602080830190840160005b83811015610adc57610ac78760208435890101610ae6565b83526020928301929190910190600101610aaf565b5050505092915050565b600082601f830112610af6578081fd5b813567ffffffffffffffff811115610b0c578182fd5b610b3d60207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8401160161140a565b9150808252836020828501011115610b5457600080fd5b8060208401602084013760009082016020015292915050565b600060808284031215610b7e578081fd5b610b88608061140a565b9050813567ffffffffffffffff80821115610ba257600080fd5b610bae85838601610ae6565b8352610bbd8560208601610c14565b60208401526040840135915080821115610bd657600080fd5b610be285838601610a7c565b60408401526060840135915080821115610bfb57600080fd5b50610c0884828501610ae6565b60608301525092915050565b803563ffffffff81168114610c2857600080fd5b92915050565b600080600080600060a08688031215610c45578081fd5b8535610c5081611481565b945060208601359350604086013592506060860135610c6e81611481565b949793965091946080013592915050565b60006020808385031215610c91578182fd5b823567ffffffffffffffff811115610ca7578283fd5b80840185601f820112610cb8578384fd5b80359150610cc8610a9a83611431565b82815283810190828501865b85811015610cfd57610ceb8a888435880101610ae6565b84529286019290860190600101610cd4565b509098975050505050505050565b60008060008060808587031215610d20578384fd5b84359350602085013560ff81168114610d37578384fd5b93969395505050506040820135916060013590565b600060208284031215610d5d578081fd5b813567ffffffffffffffff811115610d73578182fd5b610d7f84828501610ae6565b949350505050565b600060208284031215610d98578081fd5b5035919050565b600060208284031215610db0578081fd5b813567ffffffffffffffff80821115610dc7578283fd5b81840160608187031215610dd9578384fd5b610de3606061140a565b925080358352602081013582811115610dfa578485fd5b610e0687828401610ae6565b602085015250604081013582811115610e1d578485fd5b610e2987828401610ae6565b6040850152509195945050505050565b600060208284031215610e4a578081fd5b813567ffffffffffffffff80821115610e61578283fd5b81840160408187031215610e73578384fd5b610e7d604061140a565b9250803582811115610e8d578485fd5b610e9987828401610b6d565b845250602081013582811115610ead578485fd5b610eb987828401610ae6565b6020850152509195945050505050565b600060208284031215610eda578081fd5b813567ffffffffffffffff811115610ef0578182fd5b610d7f84828501610b6d565b600080600060608486031215610f10578081fd5b83359250602084013567ffffffffffffffff80821115610f2e578283fd5b610f3a87838801610ae6565b93506040860135915080821115610f4f578283fd5b50610f5c86828701610ae6565b9150509250925092565b60008151808452610f7e816020860160208601611451565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b6000815160808452610fc56080850182610f66565b6020915063ffffffff828501511682860152604084015185820360408701528181518084528484019150848582028501018584018794505b8285101561104b577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0868303018452611037828251610f66565b600195909501949387019391508601610ffd565b506060880151955088810360608a01526110658187610f66565b9998505050505050505050565b60008351611084818460208801611451565b9190910191825250602001919050565b73ffffffffffffffffffffffffffffffffffffffff91909116815260200190565b6000602080830181845280855180835260408601915060408482028701019250838701855b82811015611126577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc0888603018452611114858351610fb0565b945092850192908501906001016110da565b5092979650505050505050565b93845260ff9290921660208401526040830152606082015260800190565b6000606082526111646060830186610f66565b82810360208401526111768186610f66565b83810360408501526111888186610f66565b979650505050505050565b6000602082526111a66020830184610f66565b9392505050565b60408082526004908201527f123456780000000000000000000000000000000000000000000000000000000060608201526080602082018190526005908201527f6c6f72656d00000000000000000000000000000000000000000000000000000060a082015260c00190565b6020808252600d908201527f53494d504c455f52455645525400000000000000000000000000000000000000604082015260600190565b6020808252600e908201527f53494d504c455f52455155495245000000000000000000000000000000000000604082015260600190565b600060208252825160806020840152805160a08401526020810151606060c08501526112b7610100850182610f66565b604083015191507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff608582030160e08601526112f28183610f66565b9250505060208401517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0808584030160408601526113308383610f66565b604087015193508186820301606087015261134b8185610f66565b92505060608601519250808583030160808601525061136a8183610f66565b95945050505050565b905151815260200190565b60006020825282516040602084015261139a6060840182610fb0565b602085015191507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe084820301604085015261136a8183610f66565b6000602082526111a66020830184610fb0565b90815260200190565b600083825260406020830152610d7f6040830184610f66565b60405181810167ffffffffffffffff8111828210171561142957600080fd5b604052919050565b600067ffffffffffffffff821115611447578081fd5b5060209081020190565b60005b8381101561146c578181015183820152602001611454565b8381111561147b576000848401525b50505050565b73ffffffffffffffffffffffffffffffffffffffff8116811461040157600080fdfea365627a7a723158204f5b227587475ada330d11bfb46020f41172555bd06234eaaad1a7d10a4c2a396c6578706572696d656e74616cf564736f6c634300050c0040'; - private _methodABIIndex: { [name: string]: number } = {}; + private readonly _methodABIIndex: { [name: string]: number } = {}; private readonly _subscriptionManager: SubscriptionManager; public static async deployFrom0xArtifactAsync( artifact: ContractArtifact | SimpleContractArtifact, @@ -804,7 +804,7 @@ export class AbiGenDummyContract extends BaseContract { public getFunctionSignature(methodName: string): string { const index = this._methodABIIndex[methodName]; - const methodAbi = AbiGenDummyContract.ABI()[index] as MethodAbi; + const methodAbi = AbiGenDummyContract.ABI()[index] as MethodAbi; // tslint:disable-line:no-unnecessary-type-assertion const functionSignature = methodAbiToFunctionSignature(methodAbi); return functionSignature; } diff --git a/packages/abi-gen/test-cli/output/typescript/lib_dummy.ts b/packages/abi-gen/test-cli/output/typescript/lib_dummy.ts index ae506e5de1..f36975f234 100644 --- a/packages/abi-gen/test-cli/output/typescript/lib_dummy.ts +++ b/packages/abi-gen/test-cli/output/typescript/lib_dummy.ts @@ -40,7 +40,7 @@ export class LibDummyContract extends BaseContract { * @ignore */ public static deployedBytecode: string | undefined; - private _methodABIIndex: { [name: string]: number } = {}; + private readonly _methodABIIndex: { [name: string]: number } = {}; public static async deployFrom0xArtifactAsync( artifact: ContractArtifact | SimpleContractArtifact, supportedProvider: SupportedProvider, @@ -115,7 +115,7 @@ export class LibDummyContract extends BaseContract { public getFunctionSignature(methodName: string): string { const index = this._methodABIIndex[methodName]; - const methodAbi = LibDummyContract.ABI()[index] as MethodAbi; + const methodAbi = LibDummyContract.ABI()[index] as MethodAbi; // tslint:disable-line:no-unnecessary-type-assertion const functionSignature = methodAbiToFunctionSignature(methodAbi); return functionSignature; } diff --git a/packages/abi-gen/test-cli/output/typescript/test_lib_dummy.ts b/packages/abi-gen/test-cli/output/typescript/test_lib_dummy.ts index a2a53a7b6b..fb3801014c 100644 --- a/packages/abi-gen/test-cli/output/typescript/test_lib_dummy.ts +++ b/packages/abi-gen/test-cli/output/typescript/test_lib_dummy.ts @@ -41,7 +41,7 @@ export class TestLibDummyContract extends BaseContract { */ public static deployedBytecode = '0x6080604052348015600f57600080fd5b506004361060325760003560e01c806322935e921460375780632b82fdf0146063575b600080fd5b605160048036036020811015604b57600080fd5b5035607d565b60408051918252519081900360200190f35b605160048036036020811015607757600080fd5b5035608c565b60006086826095565b92915050565b6000608682609c565b6104d20190565b6001019056fea265627a7a72315820863e53f0da474a1275d583d88852313fe053941e79bddd5279abd812b31e020c64736f6c634300050c0032'; - private _methodABIIndex: { [name: string]: number } = {}; + private readonly _methodABIIndex: { [name: string]: number } = {}; public static async deployFrom0xArtifactAsync( artifact: ContractArtifact | SimpleContractArtifact, supportedProvider: SupportedProvider, @@ -155,7 +155,7 @@ export class TestLibDummyContract extends BaseContract { public getFunctionSignature(methodName: string): string { const index = this._methodABIIndex[methodName]; - const methodAbi = TestLibDummyContract.ABI()[index] as MethodAbi; + const methodAbi = TestLibDummyContract.ABI()[index] as MethodAbi; // tslint:disable-line:no-unnecessary-type-assertion const functionSignature = methodAbiToFunctionSignature(methodAbi); return functionSignature; } diff --git a/packages/base-contract/CHANGELOG.json b/packages/base-contract/CHANGELOG.json index c691b66589..9cae42a3ab 100644 --- a/packages/base-contract/CHANGELOG.json +++ b/packages/base-contract/CHANGELOG.json @@ -9,6 +9,14 @@ { "note": "Remove duplicate types `IndexedFilterValues`, `DecodedLogEvent`, `EventCallback`", "pr": 2243 + }, + { + "note": "Added ContractFunctionObj type and supporting types", + "pr": 2325 + }, + { + "note": "Added AwaitTransactionSuccessOpts and SendTransactionOpts", + "pr": 2325 } ] }, diff --git a/packages/contract-wrappers/src/index.ts b/packages/contract-wrappers/src/index.ts index 743d3b46e2..f02e1a31a2 100644 --- a/packages/contract-wrappers/src/index.ts +++ b/packages/contract-wrappers/src/index.ts @@ -161,4 +161,4 @@ export { } from '@0x/types'; export { AbiDecoder, DecodedCalldata } from '@0x/utils'; -export { AwaitTransactionSuccessOpts, SendTransactionOpts } from '@0x/base-contract'; +export { AwaitTransactionSuccessOpts, SendTransactionOpts, ContractFunctionObj, ContractTxFunctionObj } from '@0x/base-contract'; diff --git a/packages/monorepo-scripts/src/doc_gen_configs.ts b/packages/monorepo-scripts/src/doc_gen_configs.ts index 02cdc94c95..1238610e11 100644 --- a/packages/monorepo-scripts/src/doc_gen_configs.ts +++ b/packages/monorepo-scripts/src/doc_gen_configs.ts @@ -34,6 +34,7 @@ export const docGenConfigs: DocGenConfigs = { 'Web3WrapperErrors', 'AssetBuyerError', 'ContractError', + 'SubscriptionErrors', 'TypedDataError', 'SwapQuoterError', 'SwapQuoteGetOutputOpts', @@ -45,6 +46,11 @@ export const docGenConfigs: DocGenConfigs = { 'IndexedFilterValues', 'OrderInfo', 'TransactionOpts', + 'ContractEvent', + 'SendTransactionOpts', + 'AwaitTransactionOpts', + 'ContractFunctionObj', + 'ContractTxFunctionObj', 'EventCallback ', ], // Some libraries only export types. In those cases, we cannot check if the exported types are part of the diff --git a/packages/monorepo-scripts/src/utils/doc_generate_utils.ts b/packages/monorepo-scripts/src/utils/doc_generate_utils.ts index 121a2fc8ac..fc040e5739 100644 --- a/packages/monorepo-scripts/src/utils/doc_generate_utils.ts +++ b/packages/monorepo-scripts/src/utils/doc_generate_utils.ts @@ -427,9 +427,9 @@ export class DocGenerateUtils { throw new Error( `GENERATE_DOCS: WARNING - ${ this._packageName - } is exporting one of ${innerExportItems} which is - itself exported from an external package. To fix this, export the external dependency directly, - not indirectly through ${innerExportPath}.`, + } is exporting one of ${innerExportItems} from a package which is itself exporting from another\ + internal package ${innerExportPath}. To fix this, export the dependency directly from ${innerExportPath}\ + instead of the intermediate package.`, ); } else { const absoluteSrcPath = path.join(pathIfExists, 'src', `${innerExportPath}.ts`); diff --git a/packages/types/CHANGELOG.json b/packages/types/CHANGELOG.json index 7cba5c2e0f..398df453b5 100644 --- a/packages/types/CHANGELOG.json +++ b/packages/types/CHANGELOG.json @@ -2,10 +2,6 @@ { "version": "3.0.0-beta.0", "changes": [ - { - "note": "Add `SendTransactionOpts` and `AwaitTransactionSuccessOpts` types for contract wrappers", - "pr": 2243 - }, { "note": "All references to network ID have been removed, and references to chain ID have been introduced instead", "pr": 2313 From dd9b5d0730ab17f4ed0b814daeb6984d80b32b24 Mon Sep 17 00:00:00 2001 From: fabioberger Date: Thu, 14 Nov 2019 10:01:47 +0000 Subject: [PATCH 13/20] Fix prettier --- .../function_assertion_test.ts | 50 ++++++++++++------- 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/contracts/integrations/test/framework-unit-tests/function_assertion_test.ts b/contracts/integrations/test/framework-unit-tests/function_assertion_test.ts index d21469c973..34de637869 100644 --- a/contracts/integrations/test/framework-unit-tests/function_assertion_test.ts +++ b/contracts/integrations/test/framework-unit-tests/function_assertion_test.ts @@ -24,11 +24,14 @@ blockchainTests.resets('FunctionAssertion Unit Tests', env => { describe('executeAsync', () => { it('should call the before function with the provided arguments', async () => { let sideEffectTarget = ZERO_AMOUNT; - const assertion = new FunctionAssertion(exampleContract.returnInteger.bind(exampleContract), { - before: async (_input: BigNumber) => { - sideEffectTarget = randomInput; + const assertion = new FunctionAssertion( + exampleContract.returnInteger.bind(exampleContract), + { + before: async (_input: BigNumber) => { + sideEffectTarget = randomInput; + }, }, - }); + ); const randomInput = getRandomInteger(ZERO_AMOUNT, MAX_UINT256); await assertion.executeAsync(randomInput); expect(sideEffectTarget).bignumber.to.be.eq(randomInput); @@ -36,11 +39,14 @@ blockchainTests.resets('FunctionAssertion Unit Tests', env => { it('should call the after function with the provided arguments', async () => { let sideEffectTarget = ZERO_AMOUNT; - const assertion = new FunctionAssertion(exampleContract.returnInteger.bind(exampleContract), { - after: async (_beforeInfo: any, _result: FunctionResult, input: BigNumber) => { - sideEffectTarget = input; + const assertion = new FunctionAssertion( + exampleContract.returnInteger.bind(exampleContract), + { + after: async (_beforeInfo: any, _result: FunctionResult, input: BigNumber) => { + sideEffectTarget = input; + }, }, - }); + ); const randomInput = getRandomInteger(ZERO_AMOUNT, MAX_UINT256); await assertion.executeAsync(randomInput); expect(sideEffectTarget).bignumber.to.be.eq(randomInput); @@ -54,25 +60,31 @@ blockchainTests.resets('FunctionAssertion Unit Tests', env => { it('should pass the return value of "before" to "after"', async () => { const randomInput = getRandomInteger(ZERO_AMOUNT, MAX_UINT256); let sideEffectTarget = ZERO_AMOUNT; - const assertion = new FunctionAssertion(exampleContract.returnInteger.bind(exampleContract), { - before: async (_input: BigNumber) => { - return randomInput; - }, - after: async (beforeInfo: any, _result: FunctionResult, _input: BigNumber) => { - sideEffectTarget = beforeInfo; + const assertion = new FunctionAssertion( + exampleContract.returnInteger.bind(exampleContract), + { + before: async (_input: BigNumber) => { + return randomInput; + }, + after: async (beforeInfo: any, _result: FunctionResult, _input: BigNumber) => { + sideEffectTarget = beforeInfo; + }, }, - }); + ); await assertion.executeAsync(randomInput); expect(sideEffectTarget).bignumber.to.be.eq(randomInput); }); it('should pass the result from the function call to "after"', async () => { let sideEffectTarget = ZERO_AMOUNT; - const assertion = new FunctionAssertion(exampleContract.returnInteger.bind(exampleContract), { - after: async (_beforeInfo: any, result: FunctionResult, _input: BigNumber) => { - sideEffectTarget = result.data; + const assertion = new FunctionAssertion( + exampleContract.returnInteger.bind(exampleContract), + { + after: async (_beforeInfo: any, result: FunctionResult, _input: BigNumber) => { + sideEffectTarget = result.data; + }, }, - }); + ); const randomInput = getRandomInteger(ZERO_AMOUNT, MAX_UINT256); await assertion.executeAsync(randomInput); expect(sideEffectTarget).bignumber.to.be.eq(randomInput); From df116be4655095ecb7ffc7d36f2e5c976ad294b5 Mon Sep 17 00:00:00 2001 From: fabioberger Date: Thu, 14 Nov 2019 14:16:46 +0000 Subject: [PATCH 14/20] Revert changes to reference docs --- packages/0x.js/docs/reference.mdx | 13078 +++++++--- packages/asset-buyer/docs/reference.mdx | 707 +- packages/asset-swapper/docs/reference.mdx | 660 +- packages/connect/docs/reference.mdx | 349 +- packages/contract-wrappers/docs/reference.mdx | 21194 ++++++++++++---- packages/ethereum-types/docs/reference.mdx | 1031 +- packages/json-schemas/docs/reference.mdx | 8 +- packages/migrations/docs/reference.mdx | 266 +- packages/order-utils/docs/reference.mdx | 2152 +- packages/sol-compiler/docs/reference.mdx | 313 +- packages/sol-coverage/docs/reference.mdx | 460 +- packages/sol-profiler/docs/reference.mdx | 456 +- packages/sol-trace/docs/reference.mdx | 408 +- packages/subproviders/docs/reference.mdx | 630 +- packages/web3-wrapper/docs/reference.mdx | 1216 +- 15 files changed, 30418 insertions(+), 12510 deletions(-) diff --git a/packages/0x.js/docs/reference.mdx b/packages/0x.js/docs/reference.mdx index 39dbd2c72d..b4b9045d4f 100644 --- a/packages/0x.js/docs/reference.mdx +++ b/packages/0x.js/docs/reference.mdx @@ -1,60 +1,15 @@ -# Interface: JSONRPCRequestPayloadWithMethod - - -## Properties - -### id - -• **id**: *number* - - - -Defined in ethereum-types/lib/index.d.ts:267 - -___ - -### jsonrpc - -• **jsonrpc**: *string* - - - -Defined in ethereum-types/lib/index.d.ts:268 - -___ - -### method - -• **method**: *string* - -*Overrides void* - -*Defined in [subproviders/src/types.ts:136](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/types.ts#L136)* - -___ - -### params - -• **params**: *any[]* - - - -Defined in ethereum-types/lib/index.d.ts:265 - -
- -# Class: ERC20TokenContract +# Class: DevUtilsContract ## Constructors -\+ **new ERC20TokenContract**(`address`: string, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults?`: `Partial`, `logDecodeDependencies?`: undefined | object, `deployedBytecode`: string | undefined): *[ERC20TokenContract](#class-erc20tokencontract)* +\+ **new DevUtilsContract**(`address`: string, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults?`: `Partial`, `logDecodeDependencies?`: undefined | object, `deployedBytecode`: string | undefined): *[DevUtilsContract](#class-devutilscontract)* *Overrides void* -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:951](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L951)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:4076](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L4076)* **Parameters:** @@ -64,9 +19,9 @@ Name | Type | Default | `supportedProvider` | [SupportedProvider](#supportedprovider) | - | `txDefaults?` | `Partial` | - | `logDecodeDependencies?` | undefined \| object | - | -`deployedBytecode` | string \| undefined | ERC20TokenContract.deployedBytecode | +`deployedBytecode` | string \| undefined | DevUtilsContract.deployedBytecode | -**Returns:** *[ERC20TokenContract](#class-erc20tokencontract)* +**Returns:** *[DevUtilsContract](#class-devutilscontract)* ## Properties @@ -76,7 +31,7 @@ Name | Type | Default | -Defined in base-contract/lib/src/index.d.ts:32 +Defined in base-contract/lib/src/index.d.ts:31 ___ @@ -86,7 +41,7 @@ ___ -Defined in base-contract/lib/src/index.d.ts:28 +Defined in base-contract/lib/src/index.d.ts:27 ___ @@ -96,7 +51,7 @@ ___ -Defined in base-contract/lib/src/index.d.ts:29 +Defined in base-contract/lib/src/index.d.ts:28 ___ @@ -106,7 +61,7 @@ Args -Defined in base-contract/lib/src/index.d.ts:31 +Defined in base-contract/lib/src/index.d.ts:30 ___ @@ -116,2209 +71,2302 @@ ___ -Defined in base-contract/lib/src/index.d.ts:30 +Defined in base-contract/lib/src/index.d.ts:29 ## Methods -### allowance - -▸ **allowance**(`_owner`: string, `_spender`: string): *`ContractFunctionObj`* +### `Static` ABI -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:828](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L828)* +▸ **ABI**(): *[ContractAbi](#contractabi)* -**Parameters:** +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2719](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2719)* -Name | Type | ------- | ------ | -`_owner` | string | -`_spender` | string | +**Returns:** *[ContractAbi](#contractabi)* -**Returns:** *`ContractFunctionObj`* +The contract ABI ___ -### approve - -▸ **approve**(`_spender`: string, `_value`: `BigNumber`): *`ContractTxFunctionObj`* +### `Static` deployAsync -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:347](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L347)* +▸ **deployAsync**(`bytecode`: string, `abi`: [ContractAbi](#contractabi), `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object, `_exchange`: string): *`Promise`* -`msg.sender` approves `_spender` to spend `_value` tokens +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2672](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2672)* **Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`_spender` | string | The address of the account able to transfer the tokens | -`_value` | `BigNumber` | The amount of wei to be approved for transfer | - -**Returns:** *`ContractTxFunctionObj`* +Name | Type | +------ | ------ | +`bytecode` | string | +`abi` | [ContractAbi](#contractabi) | +`supportedProvider` | [SupportedProvider](#supportedprovider) | +`txDefaults` | `Partial` | +`logDecodeDependencies` | object | +`_exchange` | string | -Always true if the call has enough gas to complete execution +**Returns:** *`Promise`* ___ -### balanceOf - -▸ **balanceOf**(`_owner`: string): *`ContractFunctionObj`* +### `Static` deployFrom0xArtifactAsync -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:653](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L653)* +▸ **deployFrom0xArtifactAsync**(`artifact`: `ContractArtifact` | `SimpleContractArtifact`, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object, `_exchange`: string): *`Promise`* -Query the balance of owner +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2639](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2639)* **Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`_owner` | string | The address from which the balance will be retrieved | - -**Returns:** *`ContractFunctionObj`* +Name | Type | +------ | ------ | +`artifact` | `ContractArtifact` \| `SimpleContractArtifact` | +`supportedProvider` | [SupportedProvider](#supportedprovider) | +`txDefaults` | `Partial` | +`logDecodeDependencies` | object | +`_exchange` | string | -Balance of owner +**Returns:** *`Promise`* ___ -### getABIDecodedReturnData +### `Static` strictArgumentEncodingCheck -▸ **getABIDecodedReturnData**<**T**>(`methodName`: string, `callData`: string): *`T`* +▸ **strictArgumentEncodingCheck**(`inputAbi`: `DataItem`[], `args`: any[]): *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:327](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L327)* -**Type parameters:** -▪ **T** +Defined in base-contract/lib/src/index.d.ts:41 **Parameters:** Name | Type | ------ | ------ | -`methodName` | string | -`callData` | string | +`inputAbi` | `DataItem`[] | +`args` | any[] | -**Returns:** *`T`* +**Returns:** *string* -___ +## Object literals -### getABIDecodedTransactionData +### decodeAssetProxyDispatchError -▸ **getABIDecodedTransactionData**<**T**>(`methodName`: string, `callData`: string): *`T`* +#### ▪ **decodeAssetProxyDispatchError**: *object* -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:320](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L320)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:45](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L45)* -**Type parameters:** +Decompose an ABI-encoded AssetProxyDispatchError. + +#### callAsync + +▸ **callAsync**(`encoded`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise<[number, string, string]>`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:53](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L53)* -▪ **T** +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | ------- | ------ | -`methodName` | string | -`callData` | string | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`encoded` | string | - | ABI-encoded revert error. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -**Returns:** *`T`* +**Returns:** *`Promise<[number, string, string]>`* + +errorCode The error code.orderHash Hash of the order being dispatched.assetData Asset data of the order being dispatched. ___ -### getFunctionSignature +### decodeAssetProxyExistsError -▸ **getFunctionSignature**(`methodName`: string): *string* +#### ▪ **decodeAssetProxyExistsError**: *object* -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:314](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L314)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:90](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L90)* -**Parameters:** +Decompose an ABI-encoded AssetProxyExistsError. -Name | Type | ------- | ------ | -`methodName` | string | +#### callAsync -**Returns:** *string* +▸ **callAsync**(`encoded`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise<[string, string]>`* -___ +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:98](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L98)* -### getLogsAsync +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. -▸ **getLogsAsync**<**ArgsType**>(`eventName`: [ERC20TokenEvents](#enumeration-erc20tokenevents), `blockRange`: `BlockRange`, `indexFilterValues`: `IndexedFilterValues`): *`Promise>>`* +**Parameters:** -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:935](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L935)* +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`encoded` | string | - | ABI-encoded revert error. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -Gets historical logs without creating a subscription +**Returns:** *`Promise<[string, string]>`* -**Type parameters:** +assetProxyId Id of asset proxy.assetProxyAddress The address of the asset proxy. -▪ **ArgsType**: *[ERC20TokenEventArgs](#erc20tokeneventargs)* +___ -**Parameters:** +### decodeAssetProxyId -Name | Type | Description | ------- | ------ | ------ | -`eventName` | [ERC20TokenEvents](#enumeration-erc20tokenevents) | The ERC20Token contract event you would like to subscribe to. | -`blockRange` | `BlockRange` | Block range to get logs from. | -`indexFilterValues` | `IndexedFilterValues` | An object where the keys are indexed args returned by the event and the value is the value you are interested in. E.g `{_from: aUserAddressHex}` | +#### ▪ **decodeAssetProxyId**: *object* -**Returns:** *`Promise>>`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:135](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L135)* -Array of logs that match the parameters +Decode AssetProxy identifier -___ +#### callAsync -### getSelector +▸ **callAsync**(`assetData`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -▸ **getSelector**(`methodName`: string): *string* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:144](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L144)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:334](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L334)* +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | ------- | ------ | -`methodName` | string | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`assetData` | string | - | AssetProxy-compliant asset data describing an ERC-20, ERC- 721, ERC1155, or MultiAsset asset. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -**Returns:** *string* +**Returns:** *`Promise`* + +The AssetProxy identifier ___ -### subscribe +### decodeAssetProxyTransferError -▸ **subscribe**<**ArgsType**>(`eventName`: [ERC20TokenEvents](#enumeration-erc20tokenevents), `indexFilterValues`: `IndexedFilterValues`, `callback`: [EventCallback](#eventcallback)‹*`ArgsType`*›, `isVerbose`: boolean, `blockPollingIntervalMs?`: undefined | number): *string* +#### ▪ **decodeAssetProxyTransferError**: *object* -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:893](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L893)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:181](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L181)* -Subscribe to an event type emitted by the ERC20Token contract. +Decompose an ABI-encoded AssetProxyTransferError. -**Type parameters:** +#### callAsync -▪ **ArgsType**: *[ERC20TokenEventArgs](#erc20tokeneventargs)* +▸ **callAsync**(`encoded`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise<[string, string, string]>`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:189](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L189)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** Name | Type | Default | Description | ------ | ------ | ------ | ------ | -`eventName` | [ERC20TokenEvents](#enumeration-erc20tokenevents) | - | The ERC20Token contract event you would like to subscribe to. | -`indexFilterValues` | `IndexedFilterValues` | - | An object where the keys are indexed args returned by the event and the value is the value you are interested in. E.g `{maker: aUserAddressHex}` | -`callback` | [EventCallback](#eventcallback)‹*`ArgsType`*› | - | Callback that gets called when a log is added/removed | -`isVerbose` | boolean | false | Enable verbose subscription warnings (e.g recoverable network issues encountered) | -`blockPollingIntervalMs?` | undefined \| number | - | - | +`encoded` | string | - | ABI-encoded revert error. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -**Returns:** *string* +**Returns:** *`Promise<[string, string, string]>`* -Subscription token used later to unsubscribe +orderHash Hash of the order being dispatched.assetData Asset data of the order being dispatched.errorData ABI-encoded revert data from the asset proxy. ___ -### totalSupply +### decodeEIP1271SignatureError -▸ **totalSupply**(): *`ContractFunctionObj`* +#### ▪ **decodeEIP1271SignatureError**: *object* -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:470](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L470)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:226](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L226)* -Query total supply of token +Decompose an ABI-encoded SignatureValidatorError. -**Returns:** *`ContractFunctionObj`* +#### callAsync -Total supply of token +▸ **callAsync**(`encoded`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise<[string, string, string, string]>`* -___ +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:234](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L234)* -### transfer +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. -▸ **transfer**(`_to`: string, `_value`: `BigNumber`): *`ContractTxFunctionObj`* +**Parameters:** -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:709](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L709)* +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`encoded` | string | - | ABI-encoded revert error. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -send `value` token to `to` from `msg.sender` +**Returns:** *`Promise<[string, string, string, string]>`* -**Parameters:** +signerAddress The expected signer of the hash.signature The full signature bytes.errorData The revert data thrown by the validator contract. -Name | Type | Description | ------- | ------ | ------ | -`_to` | string | The address of the recipient | -`_value` | `BigNumber` | The amount of token to be transferred | +___ -**Returns:** *`ContractTxFunctionObj`* +### decodeERC1155AssetData -True if transfer was successful +#### ▪ **decodeERC1155AssetData**: *object* -___ +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:271](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L271)* -### transferFrom +Decode ERC-1155 asset data from the format described in the AssetProxy contract specification. -▸ **transferFrom**(`_from`: string, `_to`: string, `_value`: `BigNumber`): *`ContractTxFunctionObj`* +#### callAsync -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:524](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L524)* +▸ **callAsync**(`assetData`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise<[string, string, BigNumber[], BigNumber[], string]>`* -send `value` token to `to` from `from` on the condition it is approved by `from` +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:280](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L280)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`_from` | string | The address of the sender | -`_to` | string | The address of the recipient | -`_value` | `BigNumber` | The amount of token to be transferred | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`assetData` | string | - | AssetProxy-compliant asset data describing an ERC-1155 set of assets. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -**Returns:** *`ContractTxFunctionObj`* +**Returns:** *`Promise<[string, string, BigNumber[], BigNumber[], string]>`* -True if transfer was successful +The ERC-1155 AssetProxy identifier, the address of the ERC-1155 contract hosting the assets, an array of the identifiers of the assets to be traded, an array of asset amounts to be traded, and callback data. Each element of the arrays corresponds to the same-indexed element of the other array. Return values specified as `memory` are returned as pointers to locations within the memory of the input parameter `assetData`. ___ -### unsubscribe - -▸ **unsubscribe**(`subscriptionToken`: string): *void* +### decodeERC20AssetData -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:918](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L918)* +#### ▪ **decodeERC20AssetData**: *object* -Cancel a subscription +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:319](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L319)* -**Parameters:** +Decode ERC-20 asset data from the format described in the AssetProxy contract specification. -Name | Type | Description | ------- | ------ | ------ | -`subscriptionToken` | string | Subscription token returned by `subscribe()` | +#### callAsync -**Returns:** *void* +▸ **callAsync**(`assetData`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise<[string, string]>`* -___ +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:327](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L327)* -### unsubscribeAll +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. -▸ **unsubscribeAll**(): *void* +**Parameters:** -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:924](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L924)* +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`assetData` | string | - | AssetProxy-compliant asset data describing an ERC-20 asset. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -Cancels all existing subscriptions +**Returns:** *`Promise<[string, string]>`* -**Returns:** *void* +The AssetProxy identifier, and the address of the ERC-20 contract hosting this asset. ___ -### `Static` ABI - -▸ **ABI**(): *[ContractAbi](#contractabi)* +### decodeERC721AssetData -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:133](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L133)* +#### ▪ **decodeERC721AssetData**: *object* -**Returns:** *[ContractAbi](#contractabi)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:364](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L364)* -The contract ABI +Decode ERC-721 asset data from the format described in the AssetProxy contract specification. -___ +#### callAsync -### `Static` deployAsync +▸ **callAsync**(`assetData`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise<[string, string, BigNumber]>`* -▸ **deployAsync**(`bytecode`: string, `abi`: [ContractAbi](#contractabi), `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object): *`Promise`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:373](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L373)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:91](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L91)* +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | ------- | ------ | -`bytecode` | string | -`abi` | [ContractAbi](#contractabi) | -`supportedProvider` | [SupportedProvider](#supportedprovider) | -`txDefaults` | `Partial` | -`logDecodeDependencies` | object | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`assetData` | string | - | AssetProxy-compliant asset data describing an ERC-721 asset. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -**Returns:** *`Promise`* +**Returns:** *`Promise<[string, string, BigNumber]>`* + +The ERC-721 AssetProxy identifier, the address of the ERC-721 contract hosting this asset, and the identifier of the specific asset to be traded. ___ -### `Static` deployFrom0xArtifactAsync - -▸ **deployFrom0xArtifactAsync**(`artifact`: `ContractArtifact` | `SimpleContractArtifact`, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object): *`Promise`* +### decodeExchangeInvalidContextError -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:66](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L66)* +#### ▪ **decodeExchangeInvalidContextError**: *object* -**Parameters:** +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:410](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L410)* -Name | Type | ------- | ------ | -`artifact` | `ContractArtifact` \| `SimpleContractArtifact` | -`supportedProvider` | [SupportedProvider](#supportedprovider) | -`txDefaults` | `Partial` | -`logDecodeDependencies` | object | +Decompose an ABI-encoded OrderStatusError. -**Returns:** *`Promise`* +#### callAsync -___ +▸ **callAsync**(`encoded`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise<[number, string, string]>`* -### `Static` strictArgumentEncodingCheck +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:418](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L418)* -▸ **strictArgumentEncodingCheck**(`inputAbi`: `DataItem`[], `args`: any[]): *string* +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. +**Parameters:** +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`encoded` | string | - | ABI-encoded revert error. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -Defined in base-contract/lib/src/index.d.ts:42 +**Returns:** *`Promise<[number, string, string]>`* -**Parameters:** +errorCode Error code that corresponds to invalid maker, taker, or sender.orderHash The order hash.contextAddress The maker, taker, or sender address -Name | Type | ------- | ------ | -`inputAbi` | `DataItem`[] | -`args` | any[] | +___ -**Returns:** *string* +### decodeFillError -
+#### ▪ **decodeFillError**: *object* -# Class: ERC721TokenContract +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:455](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L455)* +Decompose an ABI-encoded FillError. -## Constructors +#### callAsync +▸ **callAsync**(`encoded`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise<[number, string]>`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:463](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L463)* -\+ **new ERC721TokenContract**(`address`: string, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults?`: `Partial`, `logDecodeDependencies?`: undefined | object, `deployedBytecode`: string | undefined): *[ERC721TokenContract](#class-erc721tokencontract)* +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. -*Overrides void* +**Parameters:** -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:1376](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L1376)* +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`encoded` | string | - | ABI-encoded revert error. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -**Parameters:** +**Returns:** *`Promise<[number, string]>`* -Name | Type | Default | ------- | ------ | ------ | -`address` | string | - | -`supportedProvider` | [SupportedProvider](#supportedprovider) | - | -`txDefaults?` | `Partial` | - | -`logDecodeDependencies?` | undefined \| object | - | -`deployedBytecode` | string \| undefined | ERC721TokenContract.deployedBytecode | +errorCode The error code.orderHash The order hash. -**Returns:** *[ERC721TokenContract](#class-erc721tokencontract)* +___ -## Properties +### decodeIncompleteFillError -### `Optional` _deployedBytecodeIfExists +#### ▪ **decodeIncompleteFillError**: *object* -• **_deployedBytecodeIfExists**? : *`Buffer`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:500](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L500)* +Decompose an ABI-encoded IncompleteFillError. +#### callAsync -Defined in base-contract/lib/src/index.d.ts:32 +▸ **callAsync**(`encoded`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise<[number, BigNumber, BigNumber]>`* -___ +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:508](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L508)* -### abi +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. -• **abi**: *[ContractAbi](#contractabi)* +**Parameters:** +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`encoded` | string | - | ABI-encoded revert error. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | +**Returns:** *`Promise<[number, BigNumber, BigNumber]>`* -Defined in base-contract/lib/src/index.d.ts:28 +orderHash Hash of the order being filled. ___ -### address - -• **address**: *string* +### decodeMultiAssetData +#### ▪ **decodeMultiAssetData**: *object* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:545](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L545)* -Defined in base-contract/lib/src/index.d.ts:29 +Decode multi-asset data from the format described in the AssetProxy contract specification. -___ +#### callAsync -Args +▸ **callAsync**(`assetData`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise<[string, BigNumber[], string[]]>`* -• **constructorArgs**: *any[]* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:553](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L553)* +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. +**Parameters:** -Defined in base-contract/lib/src/index.d.ts:31 +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`assetData` | string | - | AssetProxy-compliant data describing a multi-asset basket. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -___ +**Returns:** *`Promise<[string, BigNumber[], string[]]>`* -### contractName +The Multi-Asset AssetProxy identifier, an array of the amounts of the assets to be traded, and an array of the AssetProxy-compliant data describing each asset to be traded. Each element of the arrays corresponds to the same-indexed element of the other array. -• **contractName**: *string* +___ +### decodeNegativeSpreadError +#### ▪ **decodeNegativeSpreadError**: *object* -Defined in base-contract/lib/src/index.d.ts:30 +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:590](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L590)* -## Methods +Decompose an ABI-encoded NegativeSpreadError. -### approve +#### callAsync -▸ **approve**(`_approved`: string, `_tokenId`: `BigNumber`): *`ContractTxFunctionObj`* +▸ **callAsync**(`encoded`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise<[string, string]>`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:438](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L438)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:598](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L598)* -The zero address indicates there is no approved address. -Throws unless `msg.sender` is the current NFT owner, or an authorized -operator of the current owner. +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`_approved` | string | The new approved NFT controller | -`_tokenId` | `BigNumber` | The NFT to approve | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`encoded` | string | - | ABI-encoded revert error. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise<[string, string]>`* -**Returns:** *`ContractTxFunctionObj`* +leftOrderHash Hash of the left order being matched.rightOrderHash Hash of the right order being matched. ___ -### balanceOf +### decodeOrderEpochError -▸ **balanceOf**(`_owner`: string): *`ContractFunctionObj`* +#### ▪ **decodeOrderEpochError**: *object* -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:563](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L563)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:635](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L635)* -NFTs assigned to the zero address are considered invalid, and this -function throws for queries about the zero address. +Decompose an ABI-encoded OrderEpochError. + +#### callAsync + +▸ **callAsync**(`encoded`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise<[string, string, BigNumber]>`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:643](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L643)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`_owner` | string | An address for whom to query the balance | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`encoded` | string | - | ABI-encoded revert error. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -**Returns:** *`ContractFunctionObj`* +**Returns:** *`Promise<[string, string, BigNumber]>`* -The number of NFTs owned by `_owner`, possibly zero +makerAddress The order maker.orderSenderAddress The order sender.currentEpoch The current epoch for the maker. ___ -### getABIDecodedReturnData - -▸ **getABIDecodedReturnData**<**T**>(`methodName`: string, `callData`: string): *`T`* +### decodeOrderStatusError -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:417](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L417)* +#### ▪ **decodeOrderStatusError**: *object* -**Type parameters:** +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:680](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L680)* -▪ **T** +Decompose an ABI-encoded OrderStatusError. -**Parameters:** +#### callAsync -Name | Type | ------- | ------ | -`methodName` | string | -`callData` | string | +▸ **callAsync**(`encoded`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise<[string, number]>`* -**Returns:** *`T`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:688](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L688)* -___ +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. -### getABIDecodedTransactionData +**Parameters:** -▸ **getABIDecodedTransactionData**<**T**>(`methodName`: string, `callData`: string): *`T`* +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`encoded` | string | - | ABI-encoded revert error. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:410](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L410)* +**Returns:** *`Promise<[string, number]>`* -**Type parameters:** +orderHash The order hash.orderStatus The order status. -▪ **T** +___ -**Parameters:** +### decodeSignatureError -Name | Type | ------- | ------ | -`methodName` | string | -`callData` | string | +#### ▪ **decodeSignatureError**: *object* -**Returns:** *`T`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:725](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L725)* -___ +Decompose an ABI-encoded SignatureError. -### getApproved +#### callAsync -▸ **getApproved**(`_tokenId`: `BigNumber`): *`ContractFunctionObj`* +▸ **callAsync**(`encoded`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise<[number, string, string, string]>`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:618](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L618)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:733](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L733)* -Throws if `_tokenId` is not a valid NFT. +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`_tokenId` | `BigNumber` | The NFT to find the approved address for | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`encoded` | string | - | ABI-encoded revert error. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -**Returns:** *`ContractFunctionObj`* +**Returns:** *`Promise<[number, string, string, string]>`* -The approved address for this NFT, or the zero address if there is none +errorCode The error code.signerAddress The expected signer of the hash.signature The full signature. ___ -### getFunctionSignature +### decodeSignatureValidatorNotApprovedError -▸ **getFunctionSignature**(`methodName`: string): *string* +#### ▪ **decodeSignatureValidatorNotApprovedError**: *object* -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:404](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L404)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:770](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L770)* -**Parameters:** +Decompose an ABI-encoded SignatureValidatorNotApprovedError. -Name | Type | ------- | ------ | -`methodName` | string | +#### callAsync -**Returns:** *string* +▸ **callAsync**(`encoded`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise<[string, string]>`* -___ +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:778](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L778)* -### getLogsAsync +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. -▸ **getLogsAsync**<**ArgsType**>(`eventName`: [ERC721TokenEvents](#enumeration-erc721tokenevents), `blockRange`: `BlockRange`, `indexFilterValues`: `IndexedFilterValues`): *`Promise>>`* +**Parameters:** -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:1360](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L1360)* +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`encoded` | string | - | ABI-encoded revert error. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -Gets historical logs without creating a subscription +**Returns:** *`Promise<[string, string]>`* -**Type parameters:** +signerAddress The expected signer of the hash.validatorAddress The expected validator. -▪ **ArgsType**: *[ERC721TokenEventArgs](#erc721tokeneventargs)* +___ -**Parameters:** +### decodeSignatureWalletError -Name | Type | Description | ------- | ------ | ------ | -`eventName` | [ERC721TokenEvents](#enumeration-erc721tokenevents) | The ERC721Token contract event you would like to subscribe to. | -`blockRange` | `BlockRange` | Block range to get logs from. | -`indexFilterValues` | `IndexedFilterValues` | An object where the keys are indexed args returned by the event and the value is the value you are interested in. E.g `{_from: aUserAddressHex}` | +#### ▪ **decodeSignatureWalletError**: *object* -**Returns:** *`Promise>>`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:817](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L817)* -Array of logs that match the parameters +Decompose an ABI-encoded SignatureWalletError. -___ +#### callAsync -### getSelector +▸ **callAsync**(`encoded`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise<[string, string, string, string]>`* -▸ **getSelector**(`methodName`: string): *string* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:825](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L825)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:424](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L424)* +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | ------- | ------ | -`methodName` | string | - -**Returns:** *string* - -___ +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`encoded` | string | - | ABI-encoded revert error. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -### isApprovedForAll +**Returns:** *`Promise<[string, string, string, string]>`* -▸ **isApprovedForAll**(`_owner`: string, `_operator`: string): *`ContractFunctionObj`* +errorCode The error code.signerAddress The expected signer of the hash.signature The full signature bytes.errorData The revert data thrown by the validator contract. -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:666](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L666)* +___ -**Parameters:** +### decodeStaticCallAssetData -Name | Type | ------- | ------ | -`_owner` | string | -`_operator` | string | +#### ▪ **decodeStaticCallAssetData**: *object* -**Returns:** *`ContractFunctionObj`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:862](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L862)* -___ +Decode StaticCall asset data from the format described in the AssetProxy contract specification. -### ownerOf +#### callAsync -▸ **ownerOf**(`_tokenId`: `BigNumber`): *`ContractFunctionObj`* +▸ **callAsync**(`assetData`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise<[string, string, string, string]>`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:727](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L727)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:871](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L871)* -NFTs assigned to zero address are considered invalid, and queries -about them do throw. +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`_tokenId` | `BigNumber` | The identifier for an NFT | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`assetData` | string | - | AssetProxy-compliant asset data describing a StaticCall asset | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -**Returns:** *`ContractFunctionObj`* +**Returns:** *`Promise<[string, string, string, string]>`* -The address of the owner of the NFT +The StaticCall AssetProxy identifier, the target address of the StaticCAll, the data to be passed to the target address, and the expected Keccak-256 hash of the static call return data. ___ -### safeTransferFrom1 +### decodeTransactionError -▸ **safeTransferFrom1**(`_from`: string, `_to`: string, `_tokenId`: `BigNumber`): *`ContractTxFunctionObj`* +#### ▪ **decodeTransactionError**: *object* -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:782](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L782)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:908](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L908)* -This works identically to the other function with an extra data parameter, -except this function just sets data to "". +Decompose an ABI-encoded TransactionError. -**Parameters:** +#### callAsync -Name | Type | Description | ------- | ------ | ------ | -`_from` | string | The current owner of the NFT | -`_to` | string | The new owner | -`_tokenId` | `BigNumber` | The NFT to transfer | +▸ **callAsync**(`encoded`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise<[number, string]>`* -**Returns:** *`ContractTxFunctionObj`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:916](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L916)* -___ +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. -### safeTransferFrom2 +**Parameters:** -▸ **safeTransferFrom2**(`_from`: string, `_to`: string, `_tokenId`: `BigNumber`, `_data`: string): *`ContractTxFunctionObj`* +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`encoded` | string | - | ABI-encoded revert error. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:918](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L918)* +**Returns:** *`Promise<[number, string]>`* -Throws unless `msg.sender` is the current owner, an authorized -operator, or the approved address for this NFT. Throws if `_from` is -not the current owner. Throws if `_to` is the zero address. Throws if -`_tokenId` is not a valid NFT. When transfer is complete, this function -checks if `_to` is a smart contract (code size > 0). If so, it calls -`onERC721Received` on `_to` and throws if the return value is not -`bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`. +errorCode The error code.transactionHash Hash of the transaction. -**Parameters:** +___ -Name | Type | Description | ------- | ------ | ------ | -`_from` | string | The current owner of the NFT | -`_to` | string | The new owner | -`_tokenId` | `BigNumber` | The NFT to transfer | -`_data` | string | Additional data with no specified format, sent in call to `_to` | +### decodeTransactionExecutionError -**Returns:** *`ContractTxFunctionObj`* +#### ▪ **decodeTransactionExecutionError**: *object* -___ +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:953](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L953)* -### setApprovalForAll +Decompose an ABI-encoded TransactionExecutionError. -▸ **setApprovalForAll**(`_operator`: string, `_approved`: boolean): *`ContractTxFunctionObj`* +#### callAsync -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:1056](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L1056)* +▸ **callAsync**(`encoded`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise<[string, string]>`* -Emits the ApprovalForAll event. The contract MUST allow -multiple operators per owner. +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:961](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L961)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`_operator` | string | Address to add to the set of authorized operators | -`_approved` | boolean | True if the operator is approved, false to revoke approval | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`encoded` | string | - | ABI-encoded revert error. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -**Returns:** *`ContractTxFunctionObj`* +**Returns:** *`Promise<[string, string]>`* + +transactionHash Hash of the transaction.errorData Error thrown by exeucteTransaction(). ___ -### subscribe +### decodeZeroExTransactionData -▸ **subscribe**<**ArgsType**>(`eventName`: [ERC721TokenEvents](#enumeration-erc721tokenevents), `indexFilterValues`: `IndexedFilterValues`, `callback`: [EventCallback](#eventcallback)‹*`ArgsType`*›, `isVerbose`: boolean, `blockPollingIntervalMs?`: undefined | number): *string* +#### ▪ **decodeZeroExTransactionData**: *object* -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:1318](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L1318)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:998](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L998)* -Subscribe to an event type emitted by the ERC721Token contract. +Decodes the call data for an Exchange contract method call. -**Type parameters:** +#### callAsync -▪ **ArgsType**: *[ERC721TokenEventArgs](#erc721tokeneventargs)* +▸ **callAsync**(`transactionData`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise<[string, Array, BigNumber[], string[]]>`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1007](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1007)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** Name | Type | Default | Description | ------ | ------ | ------ | ------ | -`eventName` | [ERC721TokenEvents](#enumeration-erc721tokenevents) | - | The ERC721Token contract event you would like to subscribe to. | -`indexFilterValues` | `IndexedFilterValues` | - | An object where the keys are indexed args returned by the event and the value is the value you are interested in. E.g `{maker: aUserAddressHex}` | -`callback` | [EventCallback](#eventcallback)‹*`ArgsType`*› | - | Callback that gets called when a log is added/removed | -`isVerbose` | boolean | false | Enable verbose subscription warnings (e.g recoverable network issues encountered) | -`blockPollingIntervalMs?` | undefined \| number | - | - | +`transactionData` | string | - | ABI-encoded calldata for an Exchange contract method call. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -**Returns:** *string* +**Returns:** *`Promise<[string, Array, BigNumber[], string[]]>`* -Subscription token used later to unsubscribe +The name of the function called, and the parameters it was given. For single-order fills and cancels, the arrays will have just one element. ___ -### transferFrom +### encodeERC1155AssetData -▸ **transferFrom**(`_from`: string, `_to`: string, `_tokenId`: `BigNumber`): *`ContractTxFunctionObj`* +#### ▪ **encodeERC1155AssetData**: *object* -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:1184](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L1184)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1088](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1088)* -Throws unless `msg.sender` is the current owner, an authorized -operator, or the approved address for this NFT. Throws if `_from` is -not the current owner. Throws if `_to` is the zero address. Throws if -`_tokenId` is not a valid NFT. +Encode ERC-1155 asset data into the format described in the AssetProxy contract specification. -**Parameters:** +#### callAsync -Name | Type | Description | ------- | ------ | ------ | -`_from` | string | The current owner of the NFT | -`_to` | string | The new owner | -`_tokenId` | `BigNumber` | The NFT to transfer | +▸ **callAsync**(`tokenAddress`: string, `tokenIds`: `BigNumber`[], `tokenValues`: `BigNumber`[], `callbackData`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -**Returns:** *`ContractTxFunctionObj`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1101](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1101)* -___ +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. -### unsubscribe +**Parameters:** -▸ **unsubscribe**(`subscriptionToken`: string): *void* +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`tokenAddress` | string | - | The address of the ERC-1155 contract hosting the asset(s) to be traded. | +`tokenIds` | `BigNumber`[] | - | The identifiers of the specific assets to be traded. | +`tokenValues` | `BigNumber`[] | - | The amounts of each asset to be traded. | +`callbackData` | string | - | Data to be passed to receiving contracts when a transfer is performed. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:1343](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L1343)* +**Returns:** *`Promise`* -Cancel a subscription +AssetProxy-compliant asset data describing the set of assets. -**Parameters:** +___ -Name | Type | Description | ------- | ------ | ------ | -`subscriptionToken` | string | Subscription token returned by `subscribe()` | +### encodeERC20AssetData -**Returns:** *void* +#### ▪ **encodeERC20AssetData**: *object* -___ +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1147](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1147)* -### unsubscribeAll +Encode ERC-20 asset data into the format described in the AssetProxy contract specification. -▸ **unsubscribeAll**(): *void* +#### callAsync -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:1349](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L1349)* +▸ **callAsync**(`tokenAddress`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -Cancels all existing subscriptions +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1156](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1156)* -**Returns:** *void* +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. -___ +**Parameters:** -### `Static` ABI +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`tokenAddress` | string | - | The address of the ERC-20 contract hosting the asset to be traded. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -▸ **ABI**(): *[ContractAbi](#contractabi)* +**Returns:** *`Promise`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:143](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L143)* +AssetProxy-compliant data describing the asset. -**Returns:** *[ContractAbi](#contractabi)* +___ -The contract ABI +### encodeERC721AssetData -___ +#### ▪ **encodeERC721AssetData**: *object* -### `Static` deployAsync +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1195](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1195)* -▸ **deployAsync**(`bytecode`: string, `abi`: [ContractAbi](#contractabi), `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object): *`Promise`* +Encode ERC-721 asset data into the format described in the AssetProxy specification. -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:101](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L101)* +#### callAsync -**Parameters:** +▸ **callAsync**(`tokenAddress`: string, `tokenId`: `BigNumber`, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -Name | Type | ------- | ------ | -`bytecode` | string | -`abi` | [ContractAbi](#contractabi) | -`supportedProvider` | [SupportedProvider](#supportedprovider) | -`txDefaults` | `Partial` | -`logDecodeDependencies` | object | +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1205](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1205)* -**Returns:** *`Promise`* +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. -___ +**Parameters:** -### `Static` deployFrom0xArtifactAsync +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`tokenAddress` | string | - | The address of the ERC-721 contract hosting the asset to be traded. | +`tokenId` | `BigNumber` | - | The identifier of the specific asset to be traded. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -▸ **deployFrom0xArtifactAsync**(`artifact`: `ContractArtifact` | `SimpleContractArtifact`, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object): *`Promise`* +**Returns:** *`Promise`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:76](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L76)* +AssetProxy-compliant asset data describing the asset. -**Parameters:** +___ -Name | Type | ------- | ------ | -`artifact` | `ContractArtifact` \| `SimpleContractArtifact` | -`supportedProvider` | [SupportedProvider](#supportedprovider) | -`txDefaults` | `Partial` | -`logDecodeDependencies` | object | +### encodeMultiAssetData -**Returns:** *`Promise`* +#### ▪ **encodeMultiAssetData**: *object* -___ +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1247](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1247)* -### `Static` strictArgumentEncodingCheck +Encode data for multiple assets, per the AssetProxy contract specification. -▸ **strictArgumentEncodingCheck**(`inputAbi`: `DataItem`[], `args`: any[]): *string* +#### callAsync +▸ **callAsync**(`amounts`: `BigNumber`[], `nestedAssetData`: string[], `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1257](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1257)* -Defined in base-contract/lib/src/index.d.ts:42 +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | ------- | ------ | -`inputAbi` | `DataItem`[] | -`args` | any[] | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`amounts` | `BigNumber`[] | - | The amounts of each asset to be traded. | +`nestedAssetData` | string[] | - | AssetProxy-compliant data describing each asset to be traded. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -**Returns:** *string* +**Returns:** *`Promise`* -
+AssetProxy-compliant data describing the set of assets. -# Class: ExchangeContract +___ +### encodeStaticCallAssetData -## Constructors +#### ▪ **encodeStaticCallAssetData**: *object* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1299](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1299)* +Encode StaticCall asset data into the format described in the AssetProxy contract specification. -\+ **new ExchangeContract**(`address`: string, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults?`: `Partial`, `logDecodeDependencies?`: undefined | object, `deployedBytecode`: string | undefined): *[ExchangeContract](#class-exchangecontract)* +#### callAsync -*Overrides void* +▸ **callAsync**(`staticCallTargetAddress`: string, `staticCallData`: string, `expectedReturnDataHash`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1311](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1311)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:8066](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L8066)* +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | Default | ------- | ------ | ------ | -`address` | string | - | -`supportedProvider` | [SupportedProvider](#supportedprovider) | - | -`txDefaults?` | `Partial` | - | -`logDecodeDependencies?` | undefined \| object | - | -`deployedBytecode` | string \| undefined | ExchangeContract.deployedBytecode | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`staticCallTargetAddress` | string | - | Target address of StaticCall. | +`staticCallData` | string | - | Data that will be passed to staticCallTargetAddress in the StaticCall. | +`expectedReturnDataHash` | string | - | Expected Keccak-256 hash of the StaticCall return data. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -**Returns:** *[ExchangeContract](#class-exchangecontract)* +**Returns:** *`Promise`* -## Properties +AssetProxy-compliant asset data describing the set of assets. -### `Optional` _deployedBytecodeIfExists +___ -• **_deployedBytecodeIfExists**? : *`Buffer`* +### getAssetProxyAllowance + +#### ▪ **getAssetProxyAllowance**: *object* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1356](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1356)* +Returns the number of asset(s) (described by assetData) that the corresponding AssetProxy contract is authorized to spend. When the asset data contains multiple assets (eg for Multi-Asset), the return value indicates how many complete "baskets" of those assets may be spent by all of the corresponding AssetProxy contracts. -Defined in base-contract/lib/src/index.d.ts:32 +#### callAsync -___ +▸ **callAsync**(`ownerAddress`: string, `assetData`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -### abi +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1366](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1366)* -• **abi**: *[ContractAbi](#contractabi)* +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. +**Parameters:** +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`ownerAddress` | string | - | Owner of the assets specified by assetData. | +`assetData` | string | - | Details of asset, encoded per the AssetProxy contract specification. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -Defined in base-contract/lib/src/index.d.ts:28 +**Returns:** *`Promise`* + +Number of assets (or asset baskets) that the corresponding AssetProxy is authorized to spend. ___ -### address +### getBalance -• **address**: *string* +#### ▪ **getBalance**: *object* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1416](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1416)* +Returns the owner's balance of the assets(s) specified in assetData. When the asset data contains multiple assets (eg in ERC1155 or Multi-Asset), the return value indicates how many complete "baskets" of those assets are owned by owner. -Defined in base-contract/lib/src/index.d.ts:29 +#### callAsync -___ +▸ **callAsync**(`ownerAddress`: string, `assetData`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -Args +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1426](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1426)* -• **constructorArgs**: *any[]* +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`ownerAddress` | string | - | Owner of the assets specified by assetData. | +`assetData` | string | - | Details of asset, encoded per the AssetProxy contract specification. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | +**Returns:** *`Promise`* -Defined in base-contract/lib/src/index.d.ts:31 +Number of assets (or asset baskets) held by owner. ___ -### contractName +### getBalanceAndAssetProxyAllowance -• **contractName**: *string* +#### ▪ **getBalanceAndAssetProxyAllowance**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1476](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1476)* +Calls getBalance() and getAllowance() for assetData. +#### callAsync -Defined in base-contract/lib/src/index.d.ts:30 +▸ **callAsync**(`ownerAddress`: string, `assetData`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise<[BigNumber, BigNumber]>`* -## Methods +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1486](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1486)* -### EIP1271_MAGIC_VALUE +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. -▸ **EIP1271_MAGIC_VALUE**(): *`ContractFunctionObj`* +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`ownerAddress` | string | - | Owner of the assets specified by assetData. | +`assetData` | string | - | Details of asset, encoded per the AssetProxy contract specification. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3106](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3106)* +**Returns:** *`Promise<[BigNumber, BigNumber]>`* -**Returns:** *`ContractFunctionObj`* +Number of assets (or asset baskets) held by owner, and number of assets (or asset baskets) that the corresponding AssetProxy is authorized to spend. ___ -### EIP712_EXCHANGE_DOMAIN_HASH +### getBatchAssetProxyAllowances -▸ **EIP712_EXCHANGE_DOMAIN_HASH**(): *`ContractFunctionObj`* +#### ▪ **getBatchAssetProxyAllowances**: *object* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3153](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3153)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1536](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1536)* -**Returns:** *`ContractFunctionObj`* +Calls getAssetProxyAllowance() for each element of assetData. -___ +#### callAsync -### allowedValidators +▸ **callAsync**(`ownerAddress`: string, `assetData`: string[], `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -▸ **allowedValidators**(`index_0`: string, `index_1`: string): *`ContractFunctionObj`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1546](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1546)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3200](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3200)* +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | ------- | ------ | -`index_0` | string | -`index_1` | string | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`ownerAddress` | string | - | Owner of the assets specified by assetData. | +`assetData` | string[] | - | Array of asset details, each encoded per the AssetProxy contract specification. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -**Returns:** *`ContractFunctionObj`* +**Returns:** *`Promise`* + +An array of asset allowances from getAllowance(), with each element corresponding to the same-indexed element in the assetData input. ___ -### batchCancelOrders +### getBatchBalances -▸ **batchCancelOrders**(`orders`: `Array`): *`ContractTxFunctionObj`* +#### ▪ **getBatchBalances**: *object* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3259](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3259)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1596](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1596)* -Executes multiple calls of cancelOrder. +Calls getBalance() for each element of assetData. -**Parameters:** +#### callAsync -Name | Type | Description | ------- | ------ | ------ | -`orders` | `Array` | Array of order specifications. | +▸ **callAsync**(`ownerAddress`: string, `assetData`: string[], `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -**Returns:** *`ContractTxFunctionObj`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1606](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1606)* -___ +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. -### batchExecuteTransactions +**Parameters:** -▸ **batchExecuteTransactions**(`transactions`: `Array`, `signatures`: string[]): *`ContractTxFunctionObj`* +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`ownerAddress` | string | - | Owner of the assets specified by assetData. | +`assetData` | string[] | - | Array of asset details, each encoded per the AssetProxy contract specification. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3403](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3403)* +**Returns:** *`Promise`* -Executes a batch of Exchange method calls in the context of signer(s). +Array of asset balances from getBalance(), with each element corresponding to the same-indexed element in the assetData input. -**Parameters:** +___ -Name | Type | Description | ------- | ------ | ------ | -`transactions` | `Array` | Array of 0x transaction structures. | -`signatures` | string[] | Array of proofs that transactions have been signed by signer(s). | +### getBatchBalancesAndAssetProxyAllowances -**Returns:** *`ContractTxFunctionObj`* +#### ▪ **getBatchBalancesAndAssetProxyAllowances**: *object* -Array containing ABI encoded return data for each of the underlying Exchange function calls. +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1656](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1656)* -___ +Calls getBatchBalances() and getBatchAllowances() for each element of assetData. -### batchFillOrKillOrders +#### callAsync -▸ **batchFillOrKillOrders**(`orders`: `Array`, `takerAssetFillAmounts`: `BigNumber`[], `signatures`: string[]): *`ContractTxFunctionObj>`* +▸ **callAsync**(`ownerAddress`: string, `assetData`: string[], `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise<[BigNumber[], BigNumber[]]>`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3541](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3541)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1666](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1666)* -Executes multiple calls of fillOrKillOrder. +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`orders` | `Array` | Array of order specifications. | -`takerAssetFillAmounts` | `BigNumber`[] | Array of desired amounts of takerAsset to sell in orders. | -`signatures` | string[] | Proofs that orders have been created by makers. | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`ownerAddress` | string | - | Owner of the assets specified by assetData. | +`assetData` | string[] | - | Array of asset details, each encoded per the AssetProxy contract specification. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -**Returns:** *`ContractTxFunctionObj>`* +**Returns:** *`Promise<[BigNumber[], BigNumber[]]>`* -Array of amounts filled and fees paid by makers and taker. +An array of asset balances from getBalance(), and an array of asset allowances from getAllowance(), with each element corresponding to the same-indexed element in the assetData input. ___ -### batchFillOrders - -▸ **batchFillOrders**(`orders`: `Array`, `takerAssetFillAmounts`: `BigNumber`[], `signatures`: string[]): *`ContractTxFunctionObj>`* +### getEthBalances -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3717](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3717)* +#### ▪ **getEthBalances**: *object* -Executes multiple calls of fillOrder. +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1716](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1716)* -**Parameters:** +Batch fetches ETH balances -Name | Type | Description | ------- | ------ | ------ | -`orders` | `Array` | Array of order specifications. | -`takerAssetFillAmounts` | `BigNumber`[] | Array of desired amounts of takerAsset to sell in orders. | -`signatures` | string[] | Proofs that orders have been created by makers. | +#### callAsync -**Returns:** *`ContractTxFunctionObj>`* +▸ **callAsync**(`addresses`: string[], `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -Array of amounts filled and fees paid by makers and taker. +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1724](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1724)* -___ +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. -### batchFillOrdersNoThrow +**Parameters:** -▸ **batchFillOrdersNoThrow**(`orders`: `Array`, `takerAssetFillAmounts`: `BigNumber`[], `signatures`: string[]): *`ContractTxFunctionObj>`* +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`addresses` | string[] | - | Array of addresses. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3893](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3893)* +**Returns:** *`Promise`* -Executes multiple calls of fillOrder. If any fill reverts, the error is caught and ignored. +Array of ETH balances. -**Parameters:** +___ -Name | Type | Description | ------- | ------ | ------ | -`orders` | `Array` | Array of order specifications. | -`takerAssetFillAmounts` | `BigNumber`[] | Array of desired amounts of takerAsset to sell in orders. | -`signatures` | string[] | Proofs that orders have been created by makers. | +### getOrderRelevantState -**Returns:** *`ContractTxFunctionObj>`* +#### ▪ **getOrderRelevantState**: *object* -Array of amounts filled and fees paid by makers and taker. +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1769](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1769)* -___ +Fetches all order-relevant information needed to validate if the supplied order is fillable. -### batchMatchOrders +#### callAsync -▸ **batchMatchOrders**(`leftOrders`: `Array`, `rightOrders`: `Array`, `leftSignatures`: string[], `rightSignatures`: string[]): *`ContractTxFunctionObj`* +▸ **callAsync**(`order`: object, `signature`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise<[object, BigNumber, boolean]>`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4073](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4073)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1780](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1780)* -Match complementary orders that have a profitable spread. -Each order is filled at their respective price point, and -the matcher receives a profit denominated in the left maker asset. +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`leftOrders` | `Array` | Set of orders with the same maker / taker asset. | -`rightOrders` | `Array` | Set of orders to match against `leftOrders` | -`leftSignatures` | string[] | Proof that left orders were created by the left makers. | -`rightSignatures` | string[] | Proof that right orders were created by the right makers. | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`order` | object | - | The order structure. | +`signature` | string | - | Signature provided by maker that proves the order's authenticity. `0x01` can always be provided if the signature does not need to be validated. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -**Returns:** *`ContractTxFunctionObj`* +**Returns:** *`Promise<[object, BigNumber, boolean]>`* -batchMatchedFillResults Amounts filled and profit generated. +The orderInfo (hash, status, and `takerAssetAmount` already filled for the given order), fillableTakerAssetAmount (amount of the order's `takerAssetAmount` that is fillable given all on-chain state), and isValidSignature (validity of the provided signature). NOTE: If the `takerAssetData` encodes data for multiple assets, `fillableTakerAssetAmount` will represent a "scaled" amount, meaning it must be multiplied by all the individual asset amounts within the `takerAssetData` to get the final amount of each asset that can be filled. ___ -### batchMatchOrdersWithMaximalFill +### getOrderRelevantStates -▸ **batchMatchOrdersWithMaximalFill**(`leftOrders`: `Array`, `rightOrders`: `Array`, `leftSignatures`: string[], `rightSignatures`: string[]): *`ContractTxFunctionObj`* +#### ▪ **getOrderRelevantStates**: *object* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4298](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4298)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1850](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1850)* -Match complementary orders that have a profitable spread. -Each order is maximally filled at their respective price point, and -the matcher receives a profit denominated in either the left maker asset, -right maker asset, or a combination of both. +Fetches all order-relevant information needed to validate if the supplied orders are fillable. -**Parameters:** +#### callAsync -Name | Type | Description | ------- | ------ | ------ | -`leftOrders` | `Array` | Set of orders with the same maker / taker asset. | -`rightOrders` | `Array` | Set of orders to match against `leftOrders` | -`leftSignatures` | string[] | Proof that left orders were created by the left makers. | -`rightSignatures` | string[] | Proof that right orders were created by the right makers. | +▸ **callAsync**(`orders`: `Array`, `signatures`: string[], `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise<[Array, BigNumber[], boolean[]]>`* -**Returns:** *`ContractTxFunctionObj`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1861](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1861)* -batchMatchedFillResults Amounts filled and profit generated. +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. -___ +**Parameters:** -### cancelOrder - -▸ **cancelOrder**(`order`: object): *`ContractTxFunctionObj`* - -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4514](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4514)* - -After calling, the order can not be filled anymore. - -**Parameters:** +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`orders` | `Array` | - | Array of order structures. | +`signatures` | string[] | - | Array of signatures provided by makers that prove the authenticity of the orders. `0x01` can always be provided if a signature does not need to be validated. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -Name | Type | Description | ------- | ------ | ------ | -`order` | object | Order struct containing order specifications. | +**Returns:** *`Promise<[Array, BigNumber[], boolean[]]>`* -**Returns:** *`ContractTxFunctionObj`* +The ordersInfo (array of the hash, status, and `takerAssetAmount` already filled for each order), fillableTakerAssetAmounts (array of amounts for each order's `takerAssetAmount` that is fillable given all on-chain state), and isValidSignature (array containing the validity of each provided signature). NOTE: If the `takerAssetData` encodes data for multiple assets, each element of `fillableTakerAssetAmounts` will represent a "scaled" amount, meaning it must be multiplied by all the individual asset amounts within the `takerAssetData` to get the final amount of each asset that can be filled. ___ -### cancelOrdersUpTo +### getSimulatedOrderTransferResults -▸ **cancelOrdersUpTo**(`targetOrderEpoch`: `BigNumber`): *`ContractTxFunctionObj`* +#### ▪ **getSimulatedOrderTransferResults**: *object* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4654](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4654)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1940](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1940)* -Cancels all orders created by makerAddress with a salt less than or equal to the targetOrderEpoch -and senderAddress equal to msg.sender (or null address if msg.sender == makerAddress). +Simulates all of the transfers within an order and returns the index of the first failed transfer. -**Parameters:** +#### awaitTransactionSuccessAsync -Name | Type | Description | ------- | ------ | ------ | -`targetOrderEpoch` | `BigNumber` | Orders created with a salt less or equal to this value will be cancelled. | +▸ **awaitTransactionSuccessAsync**(`order`: object, `takerAddress`: string, `takerAssetFillAmount`: `BigNumber`, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* -**Returns:** *`ContractTxFunctionObj`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2015](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2015)* -___ +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. -### cancelled +**Parameters:** -▸ **cancelled**(`index_0`: string): *`ContractFunctionObj`* +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`order` | object | - | The order to simulate transfers for. | +`takerAddress` | string | - | The address of the taker that will fill the order. | +`takerAssetFillAmount` | `BigNumber` | - | The amount of takerAsset that the taker wished to fill. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4762](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4762)* +**Returns:** *`PromiseWithTransactionHash`* -**Parameters:** +A promise that resolves when the transaction is successful -Name | Type | ------- | ------ | -`index_0` | string | +#### callAsync -**Returns:** *`ContractFunctionObj`* +▸ **callAsync**(`order`: object, `takerAddress`: string, `takerAssetFillAmount`: `BigNumber`, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -___ +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2121](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2121)* -### currentContextAddress +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. -▸ **currentContextAddress**(): *`ContractFunctionObj`* +**Parameters:** -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4810](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4810)* +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`order` | object | - | The order to simulate transfers for. | +`takerAddress` | string | - | The address of the taker that will fill the order. | +`takerAssetFillAmount` | `BigNumber` | - | The amount of takerAsset that the taker wished to fill. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -**Returns:** *`ContractFunctionObj`* +**Returns:** *`Promise`* -___ +The index of the first failed transfer (or 4 if all transfers are successful). -### executeTransaction +#### estimateGasAsync -▸ **executeTransaction**(`transaction`: object, `signature`: string): *`ContractTxFunctionObj`* +▸ **estimateGasAsync**(`order`: object, `takerAddress`: string, `takerAssetFillAmount`: `BigNumber`, `txData?`: `Partial` | undefined): *`Promise`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4863](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4863)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2068](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2068)* -Executes an Exchange method call in the context of signer. +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. **Parameters:** Name | Type | Description | ------ | ------ | ------ | -`transaction` | object | 0x transaction structure. | -`signature` | string | Proof that transaction has been signed by signer. | - -**Returns:** *`ContractTxFunctionObj`* +`order` | object | The order to simulate transfers for. | +`takerAddress` | string | The address of the taker that will fill the order. | +`takerAssetFillAmount` | `BigNumber` | The amount of takerAsset that the taker wished to fill. | +`txData?` | `Partial` \| undefined | Additional data for transaction | -ABI encoded return data of the underlying Exchange function call. +**Returns:** *`Promise`* -___ +The hash of the transaction -### fillOrKillOrder +#### getABIEncodedTransactionData -▸ **fillOrKillOrder**(`order`: object, `takerAssetFillAmount`: `BigNumber`, `signature`: string): *`ContractTxFunctionObj`* +▸ **getABIEncodedTransactionData**(`order`: object, `takerAddress`: string, `takerAssetFillAmount`: `BigNumber`): *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4999](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4999)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2195](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2195)* -Fills the input order. Reverts if exact takerAssetFillAmount not filled. +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). **Parameters:** Name | Type | Description | ------ | ------ | ------ | -`order` | object | Order struct containing order specifications. | -`takerAssetFillAmount` | `BigNumber` | Desired amount of takerAsset to sell. | -`signature` | string | Proof that order has been created by maker. | +`order` | object | The order to simulate transfers for. | +`takerAddress` | string | The address of the taker that will fill the order. | +`takerAssetFillAmount` | `BigNumber` | The amount of takerAsset that the taker wished to fill. | -**Returns:** *`ContractTxFunctionObj`* +**Returns:** *string* -___ +The ABI encoded transaction data as a string -### fillOrder +#### getSelector -▸ **fillOrder**(`order`: object, `takerAssetFillAmount`: `BigNumber`, `signature`: string): *`ContractTxFunctionObj`* +▸ **getSelector**(): *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:5168](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L5168)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2227](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2227)* -Fills the input order. +Returns the 4 byte function selector as a hex string. -**Parameters:** +**Returns:** *string* -Name | Type | Description | ------- | ------ | ------ | -`order` | object | Order struct containing order specifications. | -`takerAssetFillAmount` | `BigNumber` | Desired amount of takerAsset to sell. | -`signature` | string | Proof that order has been created by maker. | +#### sendTransactionAsync -**Returns:** *`ContractTxFunctionObj`* +▸ **sendTransactionAsync**(`order`: object, `takerAddress`: string, `takerAssetFillAmount`: `BigNumber`, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* -Amounts filled and fees paid by maker and taker. +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1951](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1951)* -___ +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. -### filled +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`order` | object | - | The order to simulate transfers for. | +`takerAddress` | string | - | The address of the taker that will fill the order. | +`takerAssetFillAmount` | `BigNumber` | - | The amount of takerAsset that the taker wished to fill. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | -▸ **filled**(`index_0`: string): *`ContractFunctionObj`* +**Returns:** *`Promise`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:5330](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L5330)* +The hash of the transaction -**Parameters:** +___ -Name | Type | ------- | ------ | -`index_0` | string | +### getSimulatedOrdersTransferResults -**Returns:** *`ContractFunctionObj`* +#### ▪ **getSimulatedOrdersTransferResults**: *object* -___ +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2238](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2238)* -### getABIDecodedReturnData +Simulates all of the transfers for each given order and returns the indices of each first failed transfer. -▸ **getABIDecodedReturnData**<**T**>(`methodName`: string, `callData`: string): *`T`* +#### awaitTransactionSuccessAsync -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3092](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3092)* +▸ **awaitTransactionSuccessAsync**(`orders`: `Array`, `takerAddresses`: string[], `takerAssetFillAmounts`: `BigNumber`[], `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* -**Type parameters:** +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2316](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2316)* -▪ **T** +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. **Parameters:** -Name | Type | ------- | ------ | -`methodName` | string | -`callData` | string | - -**Returns:** *`T`* +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`orders` | `Array` | - | Array of orders to individually simulate transfers for. | +`takerAddresses` | string[] | - | Array of addresses of takers that will fill each order. | +`takerAssetFillAmounts` | `BigNumber`[] | - | Array of amounts of takerAsset that will be filled for each order. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | -___ +**Returns:** *`PromiseWithTransactionHash`* -### getABIDecodedTransactionData +A promise that resolves when the transaction is successful -▸ **getABIDecodedTransactionData**<**T**>(`methodName`: string, `callData`: string): *`T`* +#### callAsync -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3085](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3085)* +▸ **callAsync**(`orders`: `Array`, `takerAddresses`: string[], `takerAssetFillAmounts`: `BigNumber`[], `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -**Type parameters:** +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2426](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2426)* -▪ **T** +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | ------- | ------ | -`methodName` | string | -`callData` | string | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`orders` | `Array` | - | Array of orders to individually simulate transfers for. | +`takerAddresses` | string[] | - | Array of addresses of takers that will fill each order. | +`takerAssetFillAmounts` | `BigNumber`[] | - | Array of amounts of takerAsset that will be filled for each order. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -**Returns:** *`T`* +**Returns:** *`Promise`* -___ +The indices of the first failed transfer (or 4 if all transfers are successful) for each order. -### getAssetProxy +#### estimateGasAsync -▸ **getAssetProxy**(`assetProxyId`: string): *`ContractFunctionObj`* +▸ **estimateGasAsync**(`orders`: `Array`, `takerAddresses`: string[], `takerAssetFillAmounts`: `BigNumber`[], `txData?`: `Partial` | undefined): *`Promise`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:5383](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L5383)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2371](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2371)* -Gets an asset proxy. +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. **Parameters:** Name | Type | Description | ------ | ------ | ------ | -`assetProxyId` | string | Id of the asset proxy. | +`orders` | `Array` | Array of orders to individually simulate transfers for. | +`takerAddresses` | string[] | Array of addresses of takers that will fill each order. | +`takerAssetFillAmounts` | `BigNumber`[] | Array of amounts of takerAsset that will be filled for each order. | +`txData?` | `Partial` \| undefined | Additional data for transaction | -**Returns:** *`ContractFunctionObj`* +**Returns:** *`Promise`* -The asset proxy registered to assetProxyId. Returns 0x0 if no proxy is registered. +The hash of the transaction -___ +#### getABIEncodedTransactionData -### getFunctionSignature +▸ **getABIEncodedTransactionData**(`orders`: `Array`, `takerAddresses`: string[], `takerAssetFillAmounts`: `BigNumber`[]): *string* -▸ **getFunctionSignature**(`methodName`: string): *string* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2502](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2502)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3079](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3079)* +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). **Parameters:** -Name | Type | ------- | ------ | -`methodName` | string | +Name | Type | Description | +------ | ------ | ------ | +`orders` | `Array` | Array of orders to individually simulate transfers for. | +`takerAddresses` | string[] | Array of addresses of takers that will fill each order. | +`takerAssetFillAmounts` | `BigNumber`[] | Array of amounts of takerAsset that will be filled for each order. | **Returns:** *string* -___ +The ABI encoded transaction data as a string -### getLogsAsync +#### getSelector -▸ **getLogsAsync**<**ArgsType**>(`eventName`: [ExchangeEvents](#enumeration-exchangeevents), `blockRange`: `BlockRange`, `indexFilterValues`: `IndexedFilterValues`): *`Promise>>`* +▸ **getSelector**(): *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:8050](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L8050)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2535](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2535)* -Gets historical logs without creating a subscription +Returns the 4 byte function selector as a hex string. -**Type parameters:** +**Returns:** *string* -▪ **ArgsType**: *[ExchangeEventArgs](#exchangeeventargs)* +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`orders`: `Array`, `takerAddresses`: string[], `takerAssetFillAmounts`: `BigNumber`[], `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2250](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2250)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. **Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`eventName` | [ExchangeEvents](#enumeration-exchangeevents) | The Exchange contract event you would like to subscribe to. | -`blockRange` | `BlockRange` | Block range to get logs from. | -`indexFilterValues` | `IndexedFilterValues` | An object where the keys are indexed args returned by the event and the value is the value you are interested in. E.g `{_from: aUserAddressHex}` | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`orders` | `Array` | - | Array of orders to individually simulate transfers for. | +`takerAddresses` | string[] | - | Array of addresses of takers that will fill each order. | +`takerAssetFillAmounts` | `BigNumber`[] | - | Array of amounts of takerAsset that will be filled for each order. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | -**Returns:** *`Promise>>`* +**Returns:** *`Promise`* -Array of logs that match the parameters +The hash of the transaction ___ -### getOrderInfo +### getTransferableAssetAmount -▸ **getOrderInfo**(`order`: object): *`ContractFunctionObj`* +#### ▪ **getTransferableAssetAmount**: *object* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:5436](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L5436)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2546](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2546)* -Gets information about an order: status, hash, and amount filled. +Gets the amount of an asset transferable by the owner. -**Parameters:** +#### callAsync -Name | Type | Description | ------- | ------ | ------ | -`order` | object | Order to gather information on. | +▸ **callAsync**(`ownerAddress`: string, `assetData`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -**Returns:** *`ContractFunctionObj`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2556](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2556)* -OrderInfo Information about the order and its state. See LibOrder.OrderInfo for a complete description. +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. -___ +**Parameters:** -### getSelector +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`ownerAddress` | string | - | Address of the owner of the asset. | +`assetData` | string | - | Description of tokens, per the AssetProxy contract specification. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -▸ **getSelector**(`methodName`: string): *string* +**Returns:** *`Promise`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3099](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3099)* +The amount of the asset tranferable by the owner. NOTE: If the `assetData` encodes data for multiple assets, the `transferableAssetAmount` will represent the amount of times the entire `assetData` can be transferred. To calculate the total individual transferable amounts, this scaled `transferableAmount` must be multiplied by the individual asset amounts located within the `assetData`. -**Parameters:** +___ -Name | Type | ------- | ------ | -`methodName` | string | +### revertIfInvalidAssetData -**Returns:** *string* +#### ▪ **revertIfInvalidAssetData**: *object* -___ +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2603](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2603)* -### isValidHashSignature +#### callAsync -▸ **isValidHashSignature**(`hash`: string, `signerAddress`: string, `signature`: string): *`ContractFunctionObj`* +▸ **callAsync**(`assetData`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:5520](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L5520)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2609](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2609)* -Verifies that a hash has been signed by the given signer. +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | Description | +Name | Type | Default | ------ | ------ | ------ | -`hash` | string | Any 32-byte hash. | -`signerAddress` | string | Address that should have signed the given hash. | -`signature` | string | Proof that the hash has been signed by signer. | +`assetData` | string | - | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | -**Returns:** *`ContractFunctionObj`* - -isValid `true` if the signature is valid for the given hash and signer. +**Returns:** *`Promise`* -___ +
-### isValidOrderSignature +# Class: ERC20TokenContract -▸ **isValidOrderSignature**(`order`: object, `signature`: string): *`ContractFunctionObj`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:5583](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L5583)* +## Constructors -Verifies that a signature for an order is valid. -**Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`order` | object | The order. | -`signature` | string | Proof that the order has been signed by signer. | +\+ **new ERC20TokenContract**(`address`: string, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults?`: `Partial`, `logDecodeDependencies?`: undefined | object, `deployedBytecode`: string | undefined): *[ERC20TokenContract](#class-erc20tokencontract)* -**Returns:** *`ContractFunctionObj`* +*Overrides void* -isValid `true` if the signature is valid for the given order and signer. +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:1113](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L1113)* -___ +**Parameters:** -### isValidTransactionSignature +Name | Type | Default | +------ | ------ | ------ | +`address` | string | - | +`supportedProvider` | [SupportedProvider](#supportedprovider) | - | +`txDefaults?` | `Partial` | - | +`logDecodeDependencies?` | undefined \| object | - | +`deployedBytecode` | string \| undefined | ERC20TokenContract.deployedBytecode | -▸ **isValidTransactionSignature**(`transaction`: object, `signature`: string): *`ContractFunctionObj`* +**Returns:** *[ERC20TokenContract](#class-erc20tokencontract)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:5664](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L5664)* +## Properties -Verifies that a signature for a transaction is valid. +#### `Optional` _deployedBytecodeIfExists -**Parameters:** +• **_deployedBytecodeIfExists**? : *`Buffer`* -Name | Type | Description | ------- | ------ | ------ | -`transaction` | object | The transaction. | -`signature` | string | Proof that the order has been signed by signer. | -**Returns:** *`ContractFunctionObj`* -isValid `true` if the signature is valid for the given transaction and signer. +Defined in base-contract/lib/src/index.d.ts:31 ___ -### marketBuyOrdersFillOrKill +### abi -▸ **marketBuyOrdersFillOrKill**(`orders`: `Array`, `makerAssetFillAmount`: `BigNumber`, `signatures`: string[]): *`ContractTxFunctionObj`* +• **abi**: *[ContractAbi](#contractabi)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:5738](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L5738)* -Calls marketBuyOrdersNoThrow then reverts if < makerAssetFillAmount has been bought. -NOTE: This function does not enforce that the makerAsset is the same for each order. -**Parameters:** +Defined in base-contract/lib/src/index.d.ts:27 -Name | Type | Description | ------- | ------ | ------ | -`orders` | `Array` | Array of order specifications. | -`makerAssetFillAmount` | `BigNumber` | Minimum amount of makerAsset to buy. | -`signatures` | string[] | Proofs that orders have been signed by makers. | +___ -**Returns:** *`ContractTxFunctionObj`* +### address -Amounts filled and fees paid by makers and taker. +• **address**: *string* -___ -### marketBuyOrdersNoThrow -▸ **marketBuyOrdersNoThrow**(`orders`: `Array`, `makerAssetFillAmount`: `BigNumber`, `signatures`: string[]): *`ContractTxFunctionObj`* +Defined in base-contract/lib/src/index.d.ts:28 -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:5909](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L5909)* +___ -Executes multiple calls of fillOrder until total amount of makerAsset is bought by taker. -If any fill reverts, the error is caught and ignored. -NOTE: This function does not enforce that the makerAsset is the same for each order. +Args -**Parameters:** +• **constructorArgs**: *any[]* -Name | Type | Description | ------- | ------ | ------ | -`orders` | `Array` | Array of order specifications. | -`makerAssetFillAmount` | `BigNumber` | Desired amount of makerAsset to buy. | -`signatures` | string[] | Proofs that orders have been signed by makers. | -**Returns:** *`ContractTxFunctionObj`* -Amounts filled and fees paid by makers and taker. +Defined in base-contract/lib/src/index.d.ts:30 ___ -### marketSellOrdersFillOrKill - -▸ **marketSellOrdersFillOrKill**(`orders`: `Array`, `takerAssetFillAmount`: `BigNumber`, `signatures`: string[]): *`ContractTxFunctionObj`* +### contractName -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6079](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6079)* +• **contractName**: *string* -Calls marketSellOrdersNoThrow then reverts if < takerAssetFillAmount has been sold. -NOTE: This function does not enforce that the takerAsset is the same for each order. -**Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`orders` | `Array` | Array of order specifications. | -`takerAssetFillAmount` | `BigNumber` | Minimum amount of takerAsset to sell. | -`signatures` | string[] | Proofs that orders have been signed by makers. | +Defined in base-contract/lib/src/index.d.ts:29 -**Returns:** *`ContractTxFunctionObj`* +## Methods -Amounts filled and fees paid by makers and taker. +### getLogsAsync -___ +▸ **getLogsAsync**<**ArgsType**>(`eventName`: [ERC20TokenEvents](#enumeration-erc20tokenevents), `blockRange`: `BlockRange`, `indexFilterValues`: `IndexedFilterValues`): *`Promise>>`* -### marketSellOrdersNoThrow +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:1097](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L1097)* -▸ **marketSellOrdersNoThrow**(`orders`: `Array`, `takerAssetFillAmount`: `BigNumber`, `signatures`: string[]): *`ContractTxFunctionObj`* +Gets historical logs without creating a subscription -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6250](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6250)* +**Type parameters:** -Executes multiple calls of fillOrder until total amount of takerAsset is sold by taker. -If any fill reverts, the error is caught and ignored. -NOTE: This function does not enforce that the takerAsset is the same for each order. +▪ **ArgsType**: *[ERC20TokenEventArgs](#erc20tokeneventargs)* **Parameters:** Name | Type | Description | ------ | ------ | ------ | -`orders` | `Array` | Array of order specifications. | -`takerAssetFillAmount` | `BigNumber` | Desired amount of takerAsset to sell. | -`signatures` | string[] | Proofs that orders have been signed by makers. | +`eventName` | [ERC20TokenEvents](#enumeration-erc20tokenevents) | The ERC20Token contract event you would like to subscribe to. | +`blockRange` | `BlockRange` | Block range to get logs from. | +`indexFilterValues` | `IndexedFilterValues` | An object where the keys are indexed args returned by the event and the value is the value you are interested in. E.g `{_from: aUserAddressHex}` | -**Returns:** *`ContractTxFunctionObj`* +**Returns:** *`Promise>>`* -Amounts filled and fees paid by makers and taker. +Array of logs that match the parameters ___ -### matchOrders +### subscribe -▸ **matchOrders**(`leftOrder`: object, `rightOrder`: object, `leftSignature`: string, `rightSignature`: string): *`ContractTxFunctionObj`* +▸ **subscribe**<**ArgsType**>(`eventName`: [ERC20TokenEvents](#enumeration-erc20tokenevents), `indexFilterValues`: `IndexedFilterValues`, `callback`: [EventCallback](#eventcallback)‹*`ArgsType`*›, `isVerbose`: boolean, `blockPollingIntervalMs?`: undefined | number): *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6423](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6423)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:1055](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L1055)* -Match two complementary orders that have a profitable spread. -Each order is filled at their respective price point. However, the calculations are -carried out as though the orders are both being filled at the right order's price point. -The profit made by the left order goes to the taker (who matched the two orders). +Subscribe to an event type emitted by the ERC20Token contract. + +**Type parameters:** + +▪ **ArgsType**: *[ERC20TokenEventArgs](#erc20tokeneventargs)* **Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`leftOrder` | object | First order to match. | -`rightOrder` | object | Second order to match. | -`leftSignature` | string | Proof that order was created by the left maker. | -`rightSignature` | string | Proof that order was created by the right maker. | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`eventName` | [ERC20TokenEvents](#enumeration-erc20tokenevents) | - | The ERC20Token contract event you would like to subscribe to. | +`indexFilterValues` | `IndexedFilterValues` | - | An object where the keys are indexed args returned by the event and the value is the value you are interested in. E.g `{maker: aUserAddressHex}` | +`callback` | [EventCallback](#eventcallback)‹*`ArgsType`*› | - | Callback that gets called when a log is added/removed | +`isVerbose` | boolean | false | Enable verbose subscription warnings (e.g recoverable network issues encountered) | +`blockPollingIntervalMs?` | undefined \| number | - | - | -**Returns:** *`ContractTxFunctionObj`* +**Returns:** *string* -matchedFillResults Amounts filled and fees paid by maker and taker of matched orders. +Subscription token used later to unsubscribe ___ -### matchOrdersWithMaximalFill +### unsubscribe -▸ **matchOrdersWithMaximalFill**(`leftOrder`: object, `rightOrder`: object, `leftSignature`: string, `rightSignature`: string): *`ContractTxFunctionObj`* +▸ **unsubscribe**(`subscriptionToken`: string): *void* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6645](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6645)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:1080](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L1080)* -Match two complementary orders that have a profitable spread. -Each order is maximally filled at their respective price point, and -the matcher receives a profit denominated in either the left maker asset, -right maker asset, or a combination of both. +Cancel a subscription **Parameters:** Name | Type | Description | ------ | ------ | ------ | -`leftOrder` | object | First order to match. | -`rightOrder` | object | Second order to match. | -`leftSignature` | string | Proof that order was created by the left maker. | -`rightSignature` | string | Proof that order was created by the right maker. | - -**Returns:** *`ContractTxFunctionObj`* +`subscriptionToken` | string | Subscription token returned by `subscribe()` | -matchedFillResults Amounts filled by maker and taker of matched orders. +**Returns:** *void* ___ -### orderEpoch - -▸ **orderEpoch**(`index_0`: string, `index_1`: string): *`ContractFunctionObj`* +### unsubscribeAll -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6856](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6856)* +▸ **unsubscribeAll**(): *void* -**Parameters:** +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:1086](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L1086)* -Name | Type | ------- | ------ | -`index_0` | string | -`index_1` | string | +Cancels all existing subscriptions -**Returns:** *`ContractFunctionObj`* +**Returns:** *void* ___ -### owner +### `Static` ABI + +▸ **ABI**(): *[ContractAbi](#contractabi)* -▸ **owner**(): *`ContractFunctionObj`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:866](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L866)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6911](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6911)* +**Returns:** *[ContractAbi](#contractabi)* -**Returns:** *`ContractFunctionObj`* +The contract ABI ___ -### preSign - -▸ **preSign**(`hash`: string): *`ContractTxFunctionObj`* +### `Static` deployAsync -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6963](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6963)* +▸ **deployAsync**(`bytecode`: string, `abi`: [ContractAbi](#contractabi), `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object): *`Promise`* -Approves a hash on-chain. -After presigning a hash, the preSign signature type will become valid for that hash and signer. +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:824](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L824)* **Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`hash` | string | Any 32-byte hash. | +Name | Type | +------ | ------ | +`bytecode` | string | +`abi` | [ContractAbi](#contractabi) | +`supportedProvider` | [SupportedProvider](#supportedprovider) | +`txDefaults` | `Partial` | +`logDecodeDependencies` | object | -**Returns:** *`ContractTxFunctionObj`* +**Returns:** *`Promise`* ___ -### preSigned +### `Static` deployFrom0xArtifactAsync -▸ **preSigned**(`index_0`: string, `index_1`: string): *`ContractFunctionObj`* +▸ **deployFrom0xArtifactAsync**(`artifact`: `ContractArtifact` | `SimpleContractArtifact`, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object): *`Promise`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7069](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7069)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:799](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L799)* **Parameters:** Name | Type | ------ | ------ | -`index_0` | string | -`index_1` | string | +`artifact` | `ContractArtifact` \| `SimpleContractArtifact` | +`supportedProvider` | [SupportedProvider](#supportedprovider) | +`txDefaults` | `Partial` | +`logDecodeDependencies` | object | -**Returns:** *`ContractFunctionObj`* +**Returns:** *`Promise`* ___ -### protocolFeeCollector +### `Static` strictArgumentEncodingCheck -▸ **protocolFeeCollector**(): *`ContractFunctionObj`* +▸ **strictArgumentEncodingCheck**(`inputAbi`: `DataItem`[], `args`: any[]): *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7124](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7124)* -**Returns:** *`ContractFunctionObj`* -___ +Defined in base-contract/lib/src/index.d.ts:41 -### protocolFeeMultiplier +**Parameters:** -▸ **protocolFeeMultiplier**(): *`ContractFunctionObj`* +Name | Type | +------ | ------ | +`inputAbi` | `DataItem`[] | +`args` | any[] | -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7171](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7171)* +**Returns:** *string* -**Returns:** *`ContractFunctionObj`* +## Object literals -___ +### allowance -### registerAssetProxy +#### ▪ **allowance**: *object* -▸ **registerAssetProxy**(`assetProxy`: string): *`ContractTxFunctionObj`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:742](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L742)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7223](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7223)* +#### callAsync -Registers an asset proxy to its asset proxy id. -Once an asset proxy is registered, it cannot be unregistered. +▸ **callAsync**(`_owner`: string, `_spender`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:751](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L751)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`assetProxy` | string | Address of new asset proxy to register. | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_owner` | string | - | The address of the account owning tokens | +`_spender` | string | - | The address of the account able to transfer the tokens | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* -**Returns:** *`ContractTxFunctionObj`* +Amount of remaining tokens allowed to spent ___ -### setProtocolFeeCollectorAddress +### approve -▸ **setProtocolFeeCollectorAddress**(`updatedProtocolFeeCollector`: string): *`ContractTxFunctionObj`* +#### ▪ **approve**: *object* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7342](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7342)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:64](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L64)* -Allows the owner to update the protocolFeeCollector address. +`msg.sender` approves `_spender` to spend `_value` tokens + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`_spender`: string, `_value`: `BigNumber`, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:114](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L114)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. **Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`updatedProtocolFeeCollector` | string | The updated protocolFeeCollector contract address. | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_spender` | string | - | The address of the account able to transfer the tokens | +`_value` | `BigNumber` | - | The amount of wei to be approved for transfer | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | -**Returns:** *`ContractTxFunctionObj`* +**Returns:** *`PromiseWithTransactionHash`* -___ +A promise that resolves when the transaction is successful -### setProtocolFeeMultiplier +#### callAsync -▸ **setProtocolFeeMultiplier**(`updatedProtocolFeeMultiplier`: `BigNumber`): *`ContractTxFunctionObj`* +▸ **callAsync**(`_spender`: string, `_value`: `BigNumber`, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7461](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7461)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:178](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L178)* -Allows the owner to update the protocol fee multiplier. +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`updatedProtocolFeeMultiplier` | `BigNumber` | The updated protocol fee multiplier. | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_spender` | string | - | The address of the account able to transfer the tokens | +`_value` | `BigNumber` | - | The amount of wei to be approved for transfer | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -**Returns:** *`ContractTxFunctionObj`* +**Returns:** *`Promise`* -___ +Always true if the call has enough gas to complete execution -### setSignatureValidatorApproval +#### estimateGasAsync -▸ **setSignatureValidatorApproval**(`validatorAddress`: string, `approval`: boolean): *`ContractTxFunctionObj`* +▸ **estimateGasAsync**(`_spender`: string, `_value`: `BigNumber`, `txData?`: `Partial` | undefined): *`Promise`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7581](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7581)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:143](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L143)* -Approves/unnapproves a Validator contract to verify signatures on signer's behalf -using the `Validator` signature type. +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. **Parameters:** Name | Type | Description | ------ | ------ | ------ | -`validatorAddress` | string | Address of Validator contract. | -`approval` | boolean | Approval or disapproval of Validator contract. | +`_spender` | string | The address of the account able to transfer the tokens | +`_value` | `BigNumber` | The amount of wei to be approved for transfer | +`txData?` | `Partial` \| undefined | Additional data for transaction | -**Returns:** *`ContractTxFunctionObj`* +**Returns:** *`Promise`* -___ +The hash of the transaction -### simulateDispatchTransferFromCalls +#### getABIEncodedTransactionData -▸ **simulateDispatchTransferFromCalls**(`assetData`: string[], `fromAddresses`: string[], `toAddresses`: string[], `amounts`: `BigNumber`[]): *`ContractTxFunctionObj`* +▸ **getABIEncodedTransactionData**(`_spender`: string, `_value`: `BigNumber`): *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7712](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7712)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:232](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L232)* -This function may be used to simulate any amount of transfers As they would occur through the Exchange contract. Note that this function will always revert, even if all transfers are successful. However, it may be used with eth_call or with a try/catch pattern in order to simulate the results of the transfers. +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). **Parameters:** Name | Type | Description | ------ | ------ | ------ | -`assetData` | string[] | Array of asset details, each encoded per the AssetProxy contract specification. | -`fromAddresses` | string[] | Array containing the `from` addresses that correspond with each transfer. | -`toAddresses` | string[] | Array containing the `to` addresses that correspond with each transfer. | -`amounts` | `BigNumber`[] | Array containing the amounts that correspond to each transfer. | +`_spender` | string | The address of the account able to transfer the tokens | +`_value` | `BigNumber` | The amount of wei to be approved for transfer | -**Returns:** *`ContractTxFunctionObj`* +**Returns:** *string* -This function does not return a value. However, it will always revert with `Error("TRANSFERS_SUCCESSFUL")` if all of the transfers were successful. +The ABI encoded transaction data as a string -___ +#### getSelector -### subscribe +▸ **getSelector**(): *string* -▸ **subscribe**<**ArgsType**>(`eventName`: [ExchangeEvents](#enumeration-exchangeevents), `indexFilterValues`: `IndexedFilterValues`, `callback`: [EventCallback](#eventcallback)‹*`ArgsType`*›, `isVerbose`: boolean, `blockPollingIntervalMs?`: undefined | number): *string* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:245](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L245)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:8008](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L8008)* +Returns the 4 byte function selector as a hex string. -Subscribe to an event type emitted by the Exchange contract. +**Returns:** *string* -**Type parameters:** +#### sendTransactionAsync -▪ **ArgsType**: *[ExchangeEventArgs](#exchangeeventargs)* +▸ **sendTransactionAsync**(`_spender`: string, `_value`: `BigNumber`, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:73](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L73)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. **Parameters:** Name | Type | Default | Description | ------ | ------ | ------ | ------ | -`eventName` | [ExchangeEvents](#enumeration-exchangeevents) | - | The Exchange contract event you would like to subscribe to. | -`indexFilterValues` | `IndexedFilterValues` | - | An object where the keys are indexed args returned by the event and the value is the value you are interested in. E.g `{maker: aUserAddressHex}` | -`callback` | [EventCallback](#eventcallback)‹*`ArgsType`*› | - | Callback that gets called when a log is added/removed | -`isVerbose` | boolean | false | Enable verbose subscription warnings (e.g recoverable network issues encountered) | -`blockPollingIntervalMs?` | undefined \| number | - | - | +`_spender` | string | - | The address of the account able to transfer the tokens | +`_value` | `BigNumber` | - | The amount of wei to be approved for transfer | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | -**Returns:** *string* +**Returns:** *`Promise`* -Subscription token used later to unsubscribe +The hash of the transaction ___ -### transactionsExecuted - -▸ **transactionsExecuted**(`index_0`: string): *`ContractFunctionObj`* - -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7840](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7840)* +### balanceOf -**Parameters:** +#### ▪ **balanceOf**: *object* -Name | Type | ------- | ------ | -`index_0` | string | +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:515](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L515)* -**Returns:** *`ContractFunctionObj`* +Query the balance of owner -___ +#### callAsync -### transferOwnership +▸ **callAsync**(`_owner`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -▸ **transferOwnership**(`newOwner`: string): *`ContractTxFunctionObj`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:523](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L523)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7890](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7890)* +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | ------- | ------ | -`newOwner` | string | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_owner` | string | - | The address from which the balance will be retrieved | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -**Returns:** *`ContractTxFunctionObj`* +**Returns:** *`Promise`* -___ +Balance of owner -### unsubscribe +___ -▸ **unsubscribe**(`subscriptionToken`: string): *void* +### totalSupply -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:8033](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L8033)* +#### ▪ **totalSupply**: *object* -Cancel a subscription +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:254](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L254)* -**Parameters:** +Query total supply of token -Name | Type | Description | ------- | ------ | ------ | -`subscriptionToken` | string | Subscription token returned by `subscribe()` | +#### callAsync -**Returns:** *void* +▸ **callAsync**(`callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -___ +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:261](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L261)* -### unsubscribeAll +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. -▸ **unsubscribeAll**(): *void* +**Parameters:** -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:8039](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L8039)* +Name | Type | Default | +------ | ------ | ------ | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | -Cancels all existing subscriptions +**Returns:** *`Promise`* -**Returns:** *void* +Total supply of token ___ -### `Static` ABI - -▸ **ABI**(): *[ContractAbi](#contractabi)* +### transfer -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:198](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L198)* +#### ▪ **transfer**: *object* -**Returns:** *[ContractAbi](#contractabi)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:568](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L568)* -The contract ABI +send `value` token to `to` from `msg.sender` -___ +#### awaitTransactionSuccessAsync -### `Static` deployAsync +▸ **awaitTransactionSuccessAsync**(`_to`: string, `_value`: `BigNumber`, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* -▸ **deployAsync**(`bytecode`: string, `abi`: [ContractAbi](#contractabi), `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object, `chainId`: `BigNumber`): *`Promise`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:615](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L615)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:151](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L151)* +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. **Parameters:** -Name | Type | ------- | ------ | -`bytecode` | string | -`abi` | [ContractAbi](#contractabi) | -`supportedProvider` | [SupportedProvider](#supportedprovider) | -`txDefaults` | `Partial` | -`logDecodeDependencies` | object | -`chainId` | `BigNumber` | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_to` | string | - | The address of the recipient | +`_value` | `BigNumber` | - | The amount of token to be transferred | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | -**Returns:** *`Promise`* +**Returns:** *`PromiseWithTransactionHash`* -___ +A promise that resolves when the transaction is successful -### `Static` deployFrom0xArtifactAsync +#### callAsync -▸ **deployFrom0xArtifactAsync**(`artifact`: `ContractArtifact` | `SimpleContractArtifact`, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object, `chainId`: `BigNumber`): *`Promise`* +▸ **callAsync**(`_to`: string, `_value`: `BigNumber`, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:125](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L125)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:672](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L672)* -**Parameters:** +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. -Name | Type | ------- | ------ | -`artifact` | `ContractArtifact` \| `SimpleContractArtifact` | -`supportedProvider` | [SupportedProvider](#supportedprovider) | -`txDefaults` | `Partial` | -`logDecodeDependencies` | object | -`chainId` | `BigNumber` | +**Parameters:** -**Returns:** *`Promise`* +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_to` | string | - | The address of the recipient | +`_value` | `BigNumber` | - | The amount of token to be transferred | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -___ +**Returns:** *`Promise`* -### `Static` strictArgumentEncodingCheck +True if transfer was successful -▸ **strictArgumentEncodingCheck**(`inputAbi`: `DataItem`[], `args`: any[]): *string* +#### estimateGasAsync +▸ **estimateGasAsync**(`_to`: string, `_value`: `BigNumber`, `txData?`: `Partial` | undefined): *`Promise`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:644](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L644)* -Defined in base-contract/lib/src/index.d.ts:42 +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. **Parameters:** -Name | Type | ------- | ------ | -`inputAbi` | `DataItem`[] | -`args` | any[] | +Name | Type | Description | +------ | ------ | ------ | +`_to` | string | The address of the recipient | +`_value` | `BigNumber` | The amount of token to be transferred | +`txData?` | `Partial` \| undefined | Additional data for transaction | -**Returns:** *string* +**Returns:** *`Promise`* -
+The hash of the transaction -# Class: IValidatorContract +#### getABIEncodedTransactionData +▸ **getABIEncodedTransactionData**(`_to`: string, `_value`: `BigNumber`): *string* -## Constructors +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:723](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L723)* - - -\+ **new IValidatorContract**(`address`: string, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults?`: `Partial`, `logDecodeDependencies?`: undefined | object, `deployedBytecode`: string | undefined): *[IValidatorContract](#class-ivalidatorcontract)* - -*Overrides void* - -*Defined in [abi-gen-wrappers/src/generated-wrappers/i_validator.ts:234](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/i_validator.ts#L234)* +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). **Parameters:** -Name | Type | Default | +Name | Type | Description | ------ | ------ | ------ | -`address` | string | - | -`supportedProvider` | [SupportedProvider](#supportedprovider) | - | -`txDefaults?` | `Partial` | - | -`logDecodeDependencies?` | undefined \| object | - | -`deployedBytecode` | string \| undefined | IValidatorContract.deployedBytecode | - -**Returns:** *[IValidatorContract](#class-ivalidatorcontract)* - -## Properties - -### `Optional` _deployedBytecodeIfExists - -• **_deployedBytecodeIfExists**? : *`Buffer`* - - - -Defined in base-contract/lib/src/index.d.ts:32 - -___ - -### abi - -• **abi**: *[ContractAbi](#contractabi)* +`_to` | string | The address of the recipient | +`_value` | `BigNumber` | The amount of token to be transferred | +**Returns:** *string* +The ABI encoded transaction data as a string -Defined in base-contract/lib/src/index.d.ts:28 +#### getSelector -___ +▸ **getSelector**(): *string* -### address +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:736](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L736)* -• **address**: *string* +Returns the 4 byte function selector as a hex string. +**Returns:** *string* +#### sendTransactionAsync -Defined in base-contract/lib/src/index.d.ts:29 +▸ **sendTransactionAsync**(`_to`: string, `_value`: `BigNumber`, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* -___ +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:577](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L577)* -Args +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. -• **constructorArgs**: *any[]* +**Parameters:** +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_to` | string | - | The address of the recipient | +`_value` | `BigNumber` | - | The amount of token to be transferred | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | +**Returns:** *`Promise`* -Defined in base-contract/lib/src/index.d.ts:31 +The hash of the transaction ___ -### contractName - -• **contractName**: *string* - - +### transferFrom -Defined in base-contract/lib/src/index.d.ts:30 +#### ▪ **transferFrom**: *object* -## Methods +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:301](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L301)* -### getABIDecodedReturnData +send `value` token to `to` from `from` on the condition it is approved by `from` -▸ **getABIDecodedReturnData**<**T**>(`methodName`: string, `callData`: string): *`T`* +#### awaitTransactionSuccessAsync -*Defined in [abi-gen-wrappers/src/generated-wrappers/i_validator.ts:157](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/i_validator.ts#L157)* +▸ **awaitTransactionSuccessAsync**(`_from`: string, `_to`: string, `_value`: `BigNumber`, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* -**Type parameters:** +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:356](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L356)* -▪ **T** +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. **Parameters:** -Name | Type | ------- | ------ | -`methodName` | string | -`callData` | string | - -**Returns:** *`T`* +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_from` | string | - | The address of the sender | +`_to` | string | - | The address of the recipient | +`_value` | `BigNumber` | - | The amount of token to be transferred | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | -___ +**Returns:** *`PromiseWithTransactionHash`* -### getABIDecodedTransactionData +A promise that resolves when the transaction is successful -▸ **getABIDecodedTransactionData**<**T**>(`methodName`: string, `callData`: string): *`T`* +#### callAsync -*Defined in [abi-gen-wrappers/src/generated-wrappers/i_validator.ts:150](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/i_validator.ts#L150)* +▸ **callAsync**(`_from`: string, `_to`: string, `_value`: `BigNumber`, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -**Type parameters:** +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:433](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L433)* -▪ **T** +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | ------- | ------ | -`methodName` | string | -`callData` | string | - -**Returns:** *`T`* - -___ - -### getFunctionSignature - -▸ **getFunctionSignature**(`methodName`: string): *string* - -*Defined in [abi-gen-wrappers/src/generated-wrappers/i_validator.ts:144](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/i_validator.ts#L144)* - -**Parameters:** +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_from` | string | - | The address of the sender | +`_to` | string | - | The address of the recipient | +`_value` | `BigNumber` | - | The amount of token to be transferred | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -Name | Type | ------- | ------ | -`methodName` | string | +**Returns:** *`Promise`* -**Returns:** *string* +True if transfer was successful -___ +#### estimateGasAsync -### getSelector +▸ **estimateGasAsync**(`_from`: string, `_to`: string, `_value`: `BigNumber`, `txData?`: `Partial` | undefined): *`Promise`* -▸ **getSelector**(`methodName`: string): *string* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:394](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L394)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/i_validator.ts:164](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/i_validator.ts#L164)* +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. **Parameters:** -Name | Type | ------- | ------ | -`methodName` | string | +Name | Type | Description | +------ | ------ | ------ | +`_from` | string | The address of the sender | +`_to` | string | The address of the recipient | +`_value` | `BigNumber` | The amount of token to be transferred | +`txData?` | `Partial` \| undefined | Additional data for transaction | -**Returns:** *string* +**Returns:** *`Promise`* -___ +The hash of the transaction -### isValidSignature +#### getABIEncodedTransactionData -▸ **isValidSignature**(`hash`: string, `signerAddress`: string, `signature`: string): *`ContractFunctionObj`* +▸ **getABIEncodedTransactionData**(`_from`: string, `_to`: string, `_value`: `BigNumber`): *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/i_validator.ts:178](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/i_validator.ts#L178)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:491](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L491)* -Verifies that a signature is valid. +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). **Parameters:** Name | Type | Description | ------ | ------ | ------ | -`hash` | string | Message hash that is signed. | -`signerAddress` | string | Address that should have signed the given hash. | -`signature` | string | Proof of signing. | - -**Returns:** *`ContractFunctionObj`* - -Magic bytes4 value if the signature is valid. Magic value is bytes4(keccak256("isValidValidatorSignature(address,bytes32,address,bytes)")) - -___ - -### `Static` ABI - -▸ **ABI**(): *[ContractAbi](#contractabi)* - -*Defined in [abi-gen-wrappers/src/generated-wrappers/i_validator.ts:111](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/i_validator.ts#L111)* - -**Returns:** *[ContractAbi](#contractabi)* - -The contract ABI +`_from` | string | The address of the sender | +`_to` | string | The address of the recipient | +`_value` | `BigNumber` | The amount of token to be transferred | -___ +**Returns:** *string* -### `Static` deployAsync +The ABI encoded transaction data as a string -▸ **deployAsync**(`bytecode`: string, `abi`: [ContractAbi](#contractabi), `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object): *`Promise`* +#### getSelector -*Defined in [abi-gen-wrappers/src/generated-wrappers/i_validator.ts:69](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/i_validator.ts#L69)* +▸ **getSelector**(): *string* -**Parameters:** +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:506](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L506)* -Name | Type | ------- | ------ | -`bytecode` | string | -`abi` | [ContractAbi](#contractabi) | -`supportedProvider` | [SupportedProvider](#supportedprovider) | -`txDefaults` | `Partial` | -`logDecodeDependencies` | object | +Returns the 4 byte function selector as a hex string. -**Returns:** *`Promise`* +**Returns:** *string* -___ +#### sendTransactionAsync -### `Static` deployFrom0xArtifactAsync +▸ **sendTransactionAsync**(`_from`: string, `_to`: string, `_value`: `BigNumber`, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* -▸ **deployFrom0xArtifactAsync**(`artifact`: `ContractArtifact` | `SimpleContractArtifact`, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object): *`Promise`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:311](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L311)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/i_validator.ts:44](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/i_validator.ts#L44)* +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. **Parameters:** -Name | Type | ------- | ------ | -`artifact` | `ContractArtifact` \| `SimpleContractArtifact` | -`supportedProvider` | [SupportedProvider](#supportedprovider) | -`txDefaults` | `Partial` | -`logDecodeDependencies` | object | - -**Returns:** *`Promise`* - -___ - -### `Static` strictArgumentEncodingCheck - -▸ **strictArgumentEncodingCheck**(`inputAbi`: `DataItem`[], `args`: any[]): *string* - - - -Defined in base-contract/lib/src/index.d.ts:42 - -**Parameters:** +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_from` | string | - | The address of the sender | +`_to` | string | - | The address of the recipient | +`_value` | `BigNumber` | - | The amount of token to be transferred | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | -Name | Type | ------- | ------ | -`inputAbi` | `DataItem`[] | -`args` | any[] | +**Returns:** *`Promise`* -**Returns:** *string* +The hash of the transaction
-# Class: IWalletContract +# Class: ERC721TokenContract ## Constructors -\+ **new IWalletContract**(`address`: string, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults?`: `Partial`, `logDecodeDependencies?`: undefined | object, `deployedBytecode`: string | undefined): *[IWalletContract](#class-iwalletcontract)* +\+ **new ERC721TokenContract**(`address`: string, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults?`: `Partial`, `logDecodeDependencies?`: undefined | object, `deployedBytecode`: string | undefined): *[ERC721TokenContract](#class-erc721tokencontract)* *Overrides void* -*Defined in [abi-gen-wrappers/src/generated-wrappers/i_wallet.ts:224](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/i_wallet.ts#L224)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:1735](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L1735)* **Parameters:** @@ -2328,19 +2376,19 @@ Name | Type | Default | `supportedProvider` | [SupportedProvider](#supportedprovider) | - | `txDefaults?` | `Partial` | - | `logDecodeDependencies?` | undefined \| object | - | -`deployedBytecode` | string \| undefined | IWalletContract.deployedBytecode | +`deployedBytecode` | string \| undefined | ERC721TokenContract.deployedBytecode | -**Returns:** *[IWalletContract](#class-iwalletcontract)* +**Returns:** *[ERC721TokenContract](#class-erc721tokencontract)* ## Properties -### `Optional` _deployedBytecodeIfExists +#### `Optional` _deployedBytecodeIfExists • **_deployedBytecodeIfExists**? : *`Buffer`* -Defined in base-contract/lib/src/index.d.ts:32 +Defined in base-contract/lib/src/index.d.ts:31 ___ @@ -2350,7 +2398,7 @@ ___ -Defined in base-contract/lib/src/index.d.ts:28 +Defined in base-contract/lib/src/index.d.ts:27 ___ @@ -2360,7 +2408,7 @@ ___ -Defined in base-contract/lib/src/index.d.ts:29 +Defined in base-contract/lib/src/index.d.ts:28 ___ @@ -2370,7 +2418,7 @@ Args -Defined in base-contract/lib/src/index.d.ts:31 +Defined in base-contract/lib/src/index.d.ts:30 ___ @@ -2380,102 +2428,91 @@ ___ -Defined in base-contract/lib/src/index.d.ts:30 +Defined in base-contract/lib/src/index.d.ts:29 ## Methods -### getABIDecodedReturnData +### getLogsAsync + +▸ **getLogsAsync**<**ArgsType**>(`eventName`: [ERC721TokenEvents](#enumeration-erc721tokenevents), `blockRange`: `BlockRange`, `indexFilterValues`: `IndexedFilterValues`): *`Promise>>`* -▸ **getABIDecodedReturnData**<**T**>(`methodName`: string, `callData`: string): *`T`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:1719](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L1719)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/i_wallet.ts:153](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/i_wallet.ts#L153)* +Gets historical logs without creating a subscription **Type parameters:** -▪ **T** +▪ **ArgsType**: *[ERC721TokenEventArgs](#erc721tokeneventargs)* **Parameters:** -Name | Type | ------- | ------ | -`methodName` | string | -`callData` | string | - -**Returns:** *`T`* - -___ - -### getABIDecodedTransactionData - -▸ **getABIDecodedTransactionData**<**T**>(`methodName`: string, `callData`: string): *`T`* - -*Defined in [abi-gen-wrappers/src/generated-wrappers/i_wallet.ts:146](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/i_wallet.ts#L146)* +Name | Type | Description | +------ | ------ | ------ | +`eventName` | [ERC721TokenEvents](#enumeration-erc721tokenevents) | The ERC721Token contract event you would like to subscribe to. | +`blockRange` | `BlockRange` | Block range to get logs from. | +`indexFilterValues` | `IndexedFilterValues` | An object where the keys are indexed args returned by the event and the value is the value you are interested in. E.g `{_from: aUserAddressHex}` | -**Type parameters:** +**Returns:** *`Promise>>`* -▪ **T** +Array of logs that match the parameters -**Parameters:** +___ -Name | Type | ------- | ------ | -`methodName` | string | -`callData` | string | +### subscribe -**Returns:** *`T`* +▸ **subscribe**<**ArgsType**>(`eventName`: [ERC721TokenEvents](#enumeration-erc721tokenevents), `indexFilterValues`: `IndexedFilterValues`, `callback`: [EventCallback](#eventcallback)‹*`ArgsType`*›, `isVerbose`: boolean, `blockPollingIntervalMs?`: undefined | number): *string* -___ +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:1677](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L1677)* -### getFunctionSignature +Subscribe to an event type emitted by the ERC721Token contract. -▸ **getFunctionSignature**(`methodName`: string): *string* +**Type parameters:** -*Defined in [abi-gen-wrappers/src/generated-wrappers/i_wallet.ts:140](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/i_wallet.ts#L140)* +▪ **ArgsType**: *[ERC721TokenEventArgs](#erc721tokeneventargs)* **Parameters:** -Name | Type | ------- | ------ | -`methodName` | string | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`eventName` | [ERC721TokenEvents](#enumeration-erc721tokenevents) | - | The ERC721Token contract event you would like to subscribe to. | +`indexFilterValues` | `IndexedFilterValues` | - | An object where the keys are indexed args returned by the event and the value is the value you are interested in. E.g `{maker: aUserAddressHex}` | +`callback` | [EventCallback](#eventcallback)‹*`ArgsType`*› | - | Callback that gets called when a log is added/removed | +`isVerbose` | boolean | false | Enable verbose subscription warnings (e.g recoverable network issues encountered) | +`blockPollingIntervalMs?` | undefined \| number | - | - | **Returns:** *string* +Subscription token used later to unsubscribe + ___ -### getSelector +### unsubscribe + +▸ **unsubscribe**(`subscriptionToken`: string): *void* -▸ **getSelector**(`methodName`: string): *string* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:1702](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L1702)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/i_wallet.ts:160](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/i_wallet.ts#L160)* +Cancel a subscription **Parameters:** -Name | Type | ------- | ------ | -`methodName` | string | +Name | Type | Description | +------ | ------ | ------ | +`subscriptionToken` | string | Subscription token returned by `subscribe()` | -**Returns:** *string* +**Returns:** *void* ___ -### isValidSignature - -▸ **isValidSignature**(`hash`: string, `signature`: string): *`ContractFunctionObj`* - -*Defined in [abi-gen-wrappers/src/generated-wrappers/i_wallet.ts:173](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/i_wallet.ts#L173)* - -Validates a hash with the `Wallet` signature type. +### unsubscribeAll -**Parameters:** +▸ **unsubscribeAll**(): *void* -Name | Type | Description | ------- | ------ | ------ | -`hash` | string | Message hash that is signed. | -`signature` | string | Proof of signing. | +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:1708](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L1708)* -**Returns:** *`ContractFunctionObj`* +Cancels all existing subscriptions -magicValue `bytes4(0xb0671381)` if the signature check succeeds. +**Returns:** *void* ___ @@ -2483,7 +2520,7 @@ ___ ▸ **ABI**(): *[ContractAbi](#contractabi)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/i_wallet.ts:111](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/i_wallet.ts#L111)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:1408](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L1408)* **Returns:** *[ContractAbi](#contractabi)* @@ -2493,9 +2530,9 @@ ___ ### `Static` deployAsync -▸ **deployAsync**(`bytecode`: string, `abi`: [ContractAbi](#contractabi), `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object): *`Promise`* +▸ **deployAsync**(`bytecode`: string, `abi`: [ContractAbi](#contractabi), `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object): *`Promise`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/i_wallet.ts:69](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/i_wallet.ts#L69)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:1366](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L1366)* **Parameters:** @@ -2507,15 +2544,15 @@ Name | Type | `txDefaults` | `Partial` | `logDecodeDependencies` | object | -**Returns:** *`Promise`* +**Returns:** *`Promise`* ___ ### `Static` deployFrom0xArtifactAsync -▸ **deployFrom0xArtifactAsync**(`artifact`: `ContractArtifact` | `SimpleContractArtifact`, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object): *`Promise`* +▸ **deployFrom0xArtifactAsync**(`artifact`: `ContractArtifact` | `SimpleContractArtifact`, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object): *`Promise`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/i_wallet.ts:44](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/i_wallet.ts#L44)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:1341](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L1341)* **Parameters:** @@ -2526,7 +2563,7 @@ Name | Type | `txDefaults` | `Partial` | `logDecodeDependencies` | object | -**Returns:** *`Promise`* +**Returns:** *`Promise`* ___ @@ -2536,7 +2573,7 @@ ___ -Defined in base-contract/lib/src/index.d.ts:42 +Defined in base-contract/lib/src/index.d.ts:41 **Parameters:** @@ -2547,3051 +2584,8513 @@ Name | Type | **Returns:** *string* -
+## Object literals -# Class: WETH9Contract +### approve +#### ▪ **approve**: *object* -## Constructors +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:76](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L76)* +The zero address indicates there is no approved address. +Throws unless `msg.sender` is the current NFT owner, or an authorized +operator of the current owner. +#### awaitTransactionSuccessAsync -\+ **new WETH9Contract**(`address`: string, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults?`: `Partial`, `logDecodeDependencies?`: undefined | object, `deployedBytecode`: string | undefined): *[WETH9Contract](#class-weth9contract)* +▸ **awaitTransactionSuccessAsync**(`_approved`: string, `_tokenId`: `BigNumber`, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* -*Overrides void* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:126](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L126)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:1381](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L1381)* +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. **Parameters:** -Name | Type | Default | ------- | ------ | ------ | -`address` | string | - | -`supportedProvider` | [SupportedProvider](#supportedprovider) | - | -`txDefaults?` | `Partial` | - | -`logDecodeDependencies?` | undefined \| object | - | -`deployedBytecode` | string \| undefined | WETH9Contract.deployedBytecode | - -**Returns:** *[WETH9Contract](#class-weth9contract)* +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_approved` | string | - | The new approved NFT controller | +`_tokenId` | `BigNumber` | - | The NFT to approve | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | -## Properties +**Returns:** *`PromiseWithTransactionHash`* -### `Optional` _deployedBytecodeIfExists +A promise that resolves when the transaction is successful -• **_deployedBytecodeIfExists**? : *`Buffer`* +#### callAsync +▸ **callAsync**(`_approved`: string, `_tokenId`: `BigNumber`, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:189](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L189)* -Defined in base-contract/lib/src/index.d.ts:32 +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. -___ +**Parameters:** -### abi +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_approved` | string | - | The new approved NFT controller | +`_tokenId` | `BigNumber` | - | The NFT to approve | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -• **abi**: *[ContractAbi](#contractabi)* +**Returns:** *`Promise`* +#### estimateGasAsync +▸ **estimateGasAsync**(`_approved`: string, `_tokenId`: `BigNumber`, `txData?`: `Partial` | undefined): *`Promise`* -Defined in base-contract/lib/src/index.d.ts:28 +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:155](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L155)* -___ +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. -### address +**Parameters:** -• **address**: *string* +Name | Type | Description | +------ | ------ | ------ | +`_approved` | string | The new approved NFT controller | +`_tokenId` | `BigNumber` | The NFT to approve | +`txData?` | `Partial` \| undefined | Additional data for transaction | +**Returns:** *`Promise`* +The hash of the transaction -Defined in base-contract/lib/src/index.d.ts:29 +#### getABIEncodedTransactionData -___ +▸ **getABIEncodedTransactionData**(`_approved`: string, `_tokenId`: `BigNumber`): *string* -Args +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:243](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L243)* -• **constructorArgs**: *any[]* +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). +**Parameters:** +Name | Type | Description | +------ | ------ | ------ | +`_approved` | string | The new approved NFT controller | +`_tokenId` | `BigNumber` | The NFT to approve | -Defined in base-contract/lib/src/index.d.ts:31 +**Returns:** *string* -___ +The ABI encoded transaction data as a string -### contractName +#### getSelector -• **contractName**: *string* +▸ **getSelector**(): *string* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:256](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L256)* +Returns the 4 byte function selector as a hex string. -Defined in base-contract/lib/src/index.d.ts:30 +**Returns:** *string* -## Methods +#### sendTransactionAsync -### allowance +▸ **sendTransactionAsync**(`_approved`: string, `_tokenId`: `BigNumber`, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* -▸ **allowance**(`index_0`: string, `index_1`: string): *`ContractFunctionObj`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:85](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L85)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:1258](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L1258)* +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. **Parameters:** -Name | Type | ------- | ------ | -`index_0` | string | -`index_1` | string | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_approved` | string | - | The new approved NFT controller | +`_tokenId` | `BigNumber` | - | The NFT to approve | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | -**Returns:** *`ContractFunctionObj`* +**Returns:** *`Promise`* + +The hash of the transaction ___ -### approve +### balanceOf -▸ **approve**(`guy`: string, `wad`: `BigNumber`): *`ContractTxFunctionObj`* +#### ▪ **balanceOf**: *object* -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:512](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L512)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:266](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L266)* + +NFTs assigned to the zero address are considered invalid, and this +function throws for queries about the zero address. + +#### callAsync + +▸ **callAsync**(`_owner`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:274](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L274)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | ------- | ------ | -`guy` | string | -`wad` | `BigNumber` | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_owner` | string | - | An address for whom to query the balance | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* -**Returns:** *`ContractTxFunctionObj`* +The number of NFTs owned by `_owner`, possibly zero ___ -### balanceOf +### getApproved + +#### ▪ **getApproved**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:319](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L319)* + +Throws if `_tokenId` is not a valid NFT. + +#### callAsync -▸ **balanceOf**(`index_0`: string): *`ContractFunctionObj`* +▸ **callAsync**(`_tokenId`: `BigNumber`, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:946](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L946)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:327](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L327)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | ------- | ------ | -`index_0` | string | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_tokenId` | `BigNumber` | - | The NFT to find the approved address for | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* -**Returns:** *`ContractFunctionObj`* +The approved address for this NFT, or the zero address if there is none ___ -### decimals +### isApprovedForAll -▸ **decimals**(): *`ContractFunctionObj`* +#### ▪ **isApprovedForAll**: *object* -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:899](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L899)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:369](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L369)* -**Returns:** *`ContractFunctionObj`* +#### callAsync -___ +▸ **callAsync**(`_owner`: string, `_operator`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -### deposit +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:378](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L378)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** -▸ **deposit**(): *`ContractTxFunctionObj`* +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_owner` | string | - | The address that owns the NFTs | +`_operator` | string | - | The address that acts on behalf of the owner | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:1153](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L1153)* +**Returns:** *`Promise`* -**Returns:** *`ContractTxFunctionObj`* +True if `_operator` is an approved operator for `_owner`, false otherwise ___ -### getABIDecodedReturnData +### ownerOf -▸ **getABIDecodedReturnData**<**T**>(`methodName`: string, `callData`: string): *`T`* +#### ▪ **ownerOf**: *object* -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:451](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L451)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:429](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L429)* -**Type parameters:** +NFTs assigned to zero address are considered invalid, and queries +about them do throw. -▪ **T** +#### callAsync + +▸ **callAsync**(`_tokenId`: `BigNumber`, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:437](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L437)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | ------- | ------ | -`methodName` | string | -`callData` | string | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_tokenId` | `BigNumber` | - | The identifier for an NFT | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* -**Returns:** *`T`* +The address of the owner of the NFT ___ -### getABIDecodedTransactionData +### safeTransferFrom1 -▸ **getABIDecodedTransactionData**<**T**>(`methodName`: string, `callData`: string): *`T`* +#### ▪ **safeTransferFrom1**: *object* -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:444](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L444)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:483](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L483)* -**Type parameters:** +This works identically to the other function with an extra data parameter, +except this function just sets data to "". -▪ **T** +#### awaitTransactionSuccessAsync -**Parameters:** +▸ **awaitTransactionSuccessAsync**(`_from`: string, `_to`: string, `_tokenId`: `BigNumber`, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* -Name | Type | ------- | ------ | -`methodName` | string | -`callData` | string | +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:538](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L538)* -**Returns:** *`T`* +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. -___ +**Parameters:** -### getFunctionSignature +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_from` | string | - | The current owner of the NFT | +`_to` | string | - | The new owner | +`_tokenId` | `BigNumber` | - | The NFT to transfer | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | -▸ **getFunctionSignature**(`methodName`: string): *string* +**Returns:** *`PromiseWithTransactionHash`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:438](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L438)* +A promise that resolves when the transaction is successful -**Parameters:** +#### callAsync -Name | Type | ------- | ------ | -`methodName` | string | +▸ **callAsync**(`_from`: string, `_to`: string, `_tokenId`: `BigNumber`, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -**Returns:** *string* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:614](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L614)* -___ +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. -### getLogsAsync +**Parameters:** -▸ **getLogsAsync**<**ArgsType**>(`eventName`: [WETH9Events](#enumeration-weth9events), `blockRange`: `BlockRange`, `indexFilterValues`: `IndexedFilterValues`): *`Promise>>`* +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_from` | string | - | The current owner of the NFT | +`_to` | string | - | The new owner | +`_tokenId` | `BigNumber` | - | The NFT to transfer | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:1365](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L1365)* +**Returns:** *`Promise`* -Gets historical logs without creating a subscription +#### estimateGasAsync -**Type parameters:** +▸ **estimateGasAsync**(`_from`: string, `_to`: string, `_tokenId`: `BigNumber`, `txData?`: `Partial` | undefined): *`Promise`* -▪ **ArgsType**: *[WETH9EventArgs](#weth9eventargs)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:576](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L576)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. **Parameters:** Name | Type | Description | ------ | ------ | ------ | -`eventName` | [WETH9Events](#enumeration-weth9events) | The WETH9 contract event you would like to subscribe to. | -`blockRange` | `BlockRange` | Block range to get logs from. | -`indexFilterValues` | `IndexedFilterValues` | An object where the keys are indexed args returned by the event and the value is the value you are interested in. E.g `{_from: aUserAddressHex}` | +`_from` | string | The current owner of the NFT | +`_to` | string | The new owner | +`_tokenId` | `BigNumber` | The NFT to transfer | +`txData?` | `Partial` \| undefined | Additional data for transaction | -**Returns:** *`Promise>>`* +**Returns:** *`Promise`* -Array of logs that match the parameters +The hash of the transaction -___ +#### getABIEncodedTransactionData -### getSelector +▸ **getABIEncodedTransactionData**(`_from`: string, `_to`: string, `_tokenId`: `BigNumber`): *string* -▸ **getSelector**(`methodName`: string): *string* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:672](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L672)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:458](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L458)* +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). **Parameters:** -Name | Type | ------- | ------ | -`methodName` | string | +Name | Type | Description | +------ | ------ | ------ | +`_from` | string | The current owner of the NFT | +`_to` | string | The new owner | +`_tokenId` | `BigNumber` | The NFT to transfer | **Returns:** *string* -___ - -### name - -▸ **name**(): *`ContractFunctionObj`* +The ABI encoded transaction data as a string -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:465](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L465)* +#### getSelector -**Returns:** *`ContractFunctionObj`* +▸ **getSelector**(): *string* -___ +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:687](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L687)* -### subscribe +Returns the 4 byte function selector as a hex string. -▸ **subscribe**<**ArgsType**>(`eventName`: [WETH9Events](#enumeration-weth9events), `indexFilterValues`: `IndexedFilterValues`, `callback`: [EventCallback](#eventcallback)‹*`ArgsType`*›, `isVerbose`: boolean, `blockPollingIntervalMs?`: undefined | number): *string* +**Returns:** *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:1323](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L1323)* +#### sendTransactionAsync -Subscribe to an event type emitted by the WETH9 contract. +▸ **sendTransactionAsync**(`_from`: string, `_to`: string, `_tokenId`: `BigNumber`, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* -**Type parameters:** +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:493](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L493)* -▪ **ArgsType**: *[WETH9EventArgs](#weth9eventargs)* +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. **Parameters:** Name | Type | Default | Description | ------ | ------ | ------ | ------ | -`eventName` | [WETH9Events](#enumeration-weth9events) | - | The WETH9 contract event you would like to subscribe to. | -`indexFilterValues` | `IndexedFilterValues` | - | An object where the keys are indexed args returned by the event and the value is the value you are interested in. E.g `{maker: aUserAddressHex}` | -`callback` | [EventCallback](#eventcallback)‹*`ArgsType`*› | - | Callback that gets called when a log is added/removed | -`isVerbose` | boolean | false | Enable verbose subscription warnings (e.g recoverable network issues encountered) | -`blockPollingIntervalMs?` | undefined \| number | - | - | +`_from` | string | - | The current owner of the NFT | +`_to` | string | - | The new owner | +`_tokenId` | `BigNumber` | - | The NFT to transfer | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | -**Returns:** *string* +**Returns:** *`Promise`* -Subscription token used later to unsubscribe +The hash of the transaction ___ -### symbol +### safeTransferFrom2 + +#### ▪ **safeTransferFrom2**: *object* -▸ **symbol**(): *`ContractFunctionObj`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:702](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L702)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:996](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L996)* +Throws unless `msg.sender` is the current owner, an authorized +operator, or the approved address for this NFT. Throws if `_from` is +not the current owner. Throws if `_to` is the zero address. Throws if +`_tokenId` is not a valid NFT. When transfer is complete, this function +checks if `_to` is a smart contract (code size > 0). If so, it calls +`onERC721Received` on `_to` and throws if the return value is not +`bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`. -**Returns:** *`ContractFunctionObj`* +#### awaitTransactionSuccessAsync -___ +▸ **awaitTransactionSuccessAsync**(`_from`: string, `_to`: string, `_tokenId`: `BigNumber`, `_data`: string, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* -### totalSupply +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:762](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L762)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. -▸ **totalSupply**(): *`ContractFunctionObj`* +**Parameters:** -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:622](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L622)* +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_from` | string | - | The current owner of the NFT | +`_to` | string | - | The new owner | +`_tokenId` | `BigNumber` | - | The NFT to transfer | +`_data` | string | - | Additional data with no specified format, sent in call to `_to` | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | -**Returns:** *`ContractFunctionObj`* +**Returns:** *`PromiseWithTransactionHash`* -___ +A promise that resolves when the transaction is successful -### transfer +#### callAsync -▸ **transfer**(`dst`: string, `wad`: `BigNumber`): *`ContractTxFunctionObj`* +▸ **callAsync**(`_from`: string, `_to`: string, `_tokenId`: `BigNumber`, `_data`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:1043](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L1043)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:846](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L846)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | ------- | ------ | -`dst` | string | -`wad` | `BigNumber` | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_from` | string | - | The current owner of the NFT | +`_to` | string | - | The new owner | +`_tokenId` | `BigNumber` | - | The NFT to transfer | +`_data` | string | - | Additional data with no specified format, sent in call to `_to` | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -**Returns:** *`ContractTxFunctionObj`* +**Returns:** *`Promise`* -___ +#### estimateGasAsync -### transferFrom +▸ **estimateGasAsync**(`_from`: string, `_to`: string, `_tokenId`: `BigNumber`, `_data`: string, `txData?`: `Partial` | undefined): *`Promise`* -▸ **transferFrom**(`src`: string, `dst`: string, `wad`: `BigNumber`): *`ContractTxFunctionObj`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:804](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L804)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:669](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L669)* +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. **Parameters:** -Name | Type | ------- | ------ | -`src` | string | -`dst` | string | -`wad` | `BigNumber` | +Name | Type | Description | +------ | ------ | ------ | +`_from` | string | The current owner of the NFT | +`_to` | string | The new owner | +`_tokenId` | `BigNumber` | The NFT to transfer | +`_data` | string | Additional data with no specified format, sent in call to `_to` | +`txData?` | `Partial` \| undefined | Additional data for transaction | -**Returns:** *`ContractTxFunctionObj`* +**Returns:** *`Promise`* -___ +The hash of the transaction -### unsubscribe +#### getABIEncodedTransactionData -▸ **unsubscribe**(`subscriptionToken`: string): *void* +▸ **getABIEncodedTransactionData**(`_from`: string, `_to`: string, `_tokenId`: `BigNumber`, `_data`: string): *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:1348](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L1348)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:908](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L908)* -Cancel a subscription +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). **Parameters:** Name | Type | Description | ------ | ------ | ------ | -`subscriptionToken` | string | Subscription token returned by `subscribe()` | +`_from` | string | The current owner of the NFT | +`_to` | string | The new owner | +`_tokenId` | `BigNumber` | The NFT to transfer | +`_data` | string | Additional data with no specified format, sent in call to `_to` | -**Returns:** *void* +**Returns:** *string* -___ +The ABI encoded transaction data as a string -### unsubscribeAll +#### getSelector -▸ **unsubscribeAll**(): *void* +▸ **getSelector**(): *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:1354](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L1354)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:923](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L923)* -Cancels all existing subscriptions +Returns the 4 byte function selector as a hex string. -**Returns:** *void* +**Returns:** *string* -___ +#### sendTransactionAsync -### withdraw +▸ **sendTransactionAsync**(`_from`: string, `_to`: string, `_tokenId`: `BigNumber`, `_data`: string, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* -▸ **withdraw**(`wad`: `BigNumber`): *`ContractTxFunctionObj`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:713](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L713)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:793](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L793)* +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. **Parameters:** -Name | Type | ------- | ------ | -`wad` | `BigNumber` | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_from` | string | - | The current owner of the NFT | +`_to` | string | - | The new owner | +`_tokenId` | `BigNumber` | - | The NFT to transfer | +`_data` | string | - | Additional data with no specified format, sent in call to `_to` | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | -**Returns:** *`ContractTxFunctionObj`* +**Returns:** *`Promise`* -___ +The hash of the transaction -### `Static` ABI +___ -▸ **ABI**(): *[ContractAbi](#contractabi)* +### setApprovalForAll -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:149](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L149)* +#### ▪ **setApprovalForAll**: *object* -**Returns:** *[ContractAbi](#contractabi)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:933](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L933)* -The contract ABI +Emits the ApprovalForAll event. The contract MUST allow +multiple operators per owner. -___ +#### awaitTransactionSuccessAsync -### `Static` deployAsync +▸ **awaitTransactionSuccessAsync**(`_operator`: string, `_approved`: boolean, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* -▸ **deployAsync**(`bytecode`: string, `abi`: [ContractAbi](#contractabi), `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object): *`Promise`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:983](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L983)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:107](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L107)* +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. **Parameters:** -Name | Type | ------- | ------ | -`bytecode` | string | -`abi` | [ContractAbi](#contractabi) | -`supportedProvider` | [SupportedProvider](#supportedprovider) | -`txDefaults` | `Partial` | -`logDecodeDependencies` | object | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_operator` | string | - | Address to add to the set of authorized operators | +`_approved` | boolean | - | True if the operator is approved, false to revoke approval | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | -**Returns:** *`Promise`* +**Returns:** *`PromiseWithTransactionHash`* -___ +A promise that resolves when the transaction is successful -### `Static` deployFrom0xArtifactAsync +#### callAsync -▸ **deployFrom0xArtifactAsync**(`artifact`: `ContractArtifact` | `SimpleContractArtifact`, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object): *`Promise`* +▸ **callAsync**(`_operator`: string, `_approved`: boolean, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:1051](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L1051)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:82](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L82)* +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | ------- | ------ | -`artifact` | `ContractArtifact` \| `SimpleContractArtifact` | -`supportedProvider` | [SupportedProvider](#supportedprovider) | -`txDefaults` | `Partial` | -`logDecodeDependencies` | object | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_operator` | string | - | Address to add to the set of authorized operators | +`_approved` | boolean | - | True if the operator is approved, false to revoke approval | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -**Returns:** *`Promise`* +**Returns:** *`Promise`* -___ +#### estimateGasAsync -### `Static` strictArgumentEncodingCheck +▸ **estimateGasAsync**(`_operator`: string, `_approved`: boolean, `txData?`: `Partial` | undefined): *`Promise`* -▸ **strictArgumentEncodingCheck**(`inputAbi`: `DataItem`[], `args`: any[]): *string* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:1017](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L1017)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`_operator` | string | Address to add to the set of authorized operators | +`_approved` | boolean | True if the operator is approved, false to revoke approval | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData +▸ **getABIEncodedTransactionData**(`_operator`: string, `_approved`: boolean): *string* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:1105](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L1105)* -Defined in base-contract/lib/src/index.d.ts:42 +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). **Parameters:** -Name | Type | ------- | ------ | -`inputAbi` | `DataItem`[] | -`args` | any[] | +Name | Type | Description | +------ | ------ | ------ | +`_operator` | string | Address to add to the set of authorized operators | +`_approved` | boolean | True if the operator is approved, false to revoke approval | **Returns:** *string* -
+The ABI encoded transaction data as a string -# Class: MetamaskSubprovider +#### getSelector -This class implements the [web3-provider-engine](https://github.com/MetaMask/provider-engine) -subprovider interface and the provider sendAsync interface. -It handles inconsistencies with Metamask implementations of various JSON RPC methods. -It forwards JSON RPC requests involving the domain of a signer (getAccounts, -sendTransaction, signMessage etc...) to the provider instance supplied at instantiation. All other requests -are passed onwards for subsequent subproviders to handle. +▸ **getSelector**(): *string* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:1118](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L1118)* -## Constructors +Returns the 4 byte function selector as a hex string. +**Returns:** *string* +#### sendTransactionAsync -\+ **new MetamaskSubprovider**(`supportedProvider`: [SupportedProvider](#supportedprovider)): *[MetamaskSubprovider](#class-metamasksubprovider)* +▸ **sendTransactionAsync**(`_operator`: string, `_approved`: boolean, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* -*Defined in [subproviders/src/subproviders/metamask_subprovider.ts:19](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/metamask_subprovider.ts#L19)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:942](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L942)* -Instantiates a new MetamaskSubprovider +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. **Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`supportedProvider` | [SupportedProvider](#supportedprovider) | Web3 provider that should handle all user account related requests | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_operator` | string | - | Address to add to the set of authorized operators | +`_approved` | boolean | - | True if the operator is approved, false to revoke approval | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | -**Returns:** *[MetamaskSubprovider](#class-metamasksubprovider)* +**Returns:** *`Promise`* -## Methods +The hash of the transaction -### emitPayloadAsync +___ -▸ **emitPayloadAsync**(`payload`: `Partial`): *`Promise`* +### transferFrom + +#### ▪ **transferFrom**: *object* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:1130](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L1130)* +Throws unless `msg.sender` is the current owner, an authorized +operator, or the approved address for this NFT. Throws if `_from` is +not the current owner. Throws if `_to` is the zero address. Throws if +`_tokenId` is not a valid NFT. -*Defined in [subproviders/src/subproviders/subprovider.ts:55](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/subprovider.ts#L55)* +#### awaitTransactionSuccessAsync -Emits a JSON RPC payload that will then be handled by the ProviderEngine instance -this subprovider is a part of. The payload will cascade down the subprovider middleware -stack until finding the responsible entity for handling the request. +▸ **awaitTransactionSuccessAsync**(`_from`: string, `_to`: string, `_tokenId`: `BigNumber`, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* -**Parameters:** +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:1185](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L1185)* -Name | Type | Description | ------- | ------ | ------ | -`payload` | `Partial` | JSON RPC payload | +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. -**Returns:** *`Promise`* +**Parameters:** -JSON RPC response payload +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_from` | string | - | The current owner of the NFT | +`_to` | string | - | The new owner | +`_tokenId` | `BigNumber` | - | The NFT to transfer | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | -___ +**Returns:** *`PromiseWithTransactionHash`* -### handleRequest +A promise that resolves when the transaction is successful -▸ **handleRequest**(`payload`: `JSONRPCRequestPayload`, `next`: [Callback](#callback), `end`: [ErrorCallback](#errorcallback)): *`Promise`* +#### callAsync -*Overrides void* +▸ **callAsync**(`_from`: string, `_to`: string, `_tokenId`: `BigNumber`, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -*Defined in [subproviders/src/subproviders/metamask_subprovider.ts:39](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/metamask_subprovider.ts#L39)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:1261](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L1261)* -This method conforms to the web3-provider-engine interface. -It is called internally by the ProviderEngine when it is this subproviders -turn to handle a JSON RPC request. +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`payload` | `JSONRPCRequestPayload` | JSON RPC payload | -`next` | [Callback](#callback) | Callback to call if this subprovider decides not to handle the request | -`end` | [ErrorCallback](#errorcallback) | Callback to call if subprovider handled the request and wants to pass back the request. | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_from` | string | - | The current owner of the NFT | +`_to` | string | - | The new owner | +`_tokenId` | `BigNumber` | - | The NFT to transfer | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | **Returns:** *`Promise`* -___ - -### sendAsync +#### estimateGasAsync -▸ **sendAsync**(`payload`: `JSONRPCRequestPayload`, `callback`: [ErrorCallback](#errorcallback)): *void* +▸ **estimateGasAsync**(`_from`: string, `_to`: string, `_tokenId`: `BigNumber`, `txData?`: `Partial` | undefined): *`Promise`* -*Defined in [subproviders/src/subproviders/metamask_subprovider.ts:117](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/metamask_subprovider.ts#L117)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:1223](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L1223)* -This method conforms to the provider sendAsync interface. -Allowing the MetamaskSubprovider to be used as a generic provider (outside of Web3ProviderEngine) with the -addition of wrapping the inconsistent Metamask behaviour +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. **Parameters:** Name | Type | Description | ------ | ------ | ------ | -`payload` | `JSONRPCRequestPayload` | JSON RPC payload | -`callback` | [ErrorCallback](#errorcallback) | - | - -**Returns:** *void* - -The contents nested under the result key of the response body - -___ +`_from` | string | The current owner of the NFT | +`_to` | string | The new owner | +`_tokenId` | `BigNumber` | The NFT to transfer | +`txData?` | `Partial` \| undefined | Additional data for transaction | -### setEngine +**Returns:** *`Promise`* -▸ **setEngine**(`engine`: `Web3ProviderEngine`): *void* +The hash of the transaction +#### getABIEncodedTransactionData +▸ **getABIEncodedTransactionData**(`_from`: string, `_to`: string, `_tokenId`: `BigNumber`): *string* -*Defined in [subproviders/src/subproviders/subprovider.ts:68](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/subprovider.ts#L68)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:1319](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L1319)* -Set's the subprovider's engine to the ProviderEngine it is added to. -This is only called within the ProviderEngine source code, do not call -directly. +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). **Parameters:** Name | Type | Description | ------ | ------ | ------ | -`engine` | `Web3ProviderEngine` | The ProviderEngine this subprovider is added to | +`_from` | string | The current owner of the NFT | +`_to` | string | The new owner | +`_tokenId` | `BigNumber` | The NFT to transfer | -**Returns:** *void* +**Returns:** *string* -
+The ABI encoded transaction data as a string -# Class: RPCSubprovider +#### getSelector -This class implements the [web3-provider-engine](https://github.com/MetaMask/provider-engine) subprovider interface. -It forwards on JSON RPC requests to the supplied `rpcUrl` endpoint +▸ **getSelector**(): *string* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:1334](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L1334)* -## Constructors +Returns the 4 byte function selector as a hex string. +**Returns:** *string* +#### sendTransactionAsync -\+ **new RPCSubprovider**(`rpcUrl`: string, `requestTimeoutMs`: number): *[RPCSubprovider](#class-rpcsubprovider)* +▸ **sendTransactionAsync**(`_from`: string, `_to`: string, `_tokenId`: `BigNumber`, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* -*Defined in [subproviders/src/subproviders/rpc_subprovider.ts:17](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/rpc_subprovider.ts#L17)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:1140](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L1140)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. **Parameters:** Name | Type | Default | Description | ------ | ------ | ------ | ------ | -`rpcUrl` | string | - | URL to the backing Ethereum node to which JSON RPC requests should be sent | -`requestTimeoutMs` | number | 20000 | Amount of miliseconds to wait before timing out the JSON RPC request | - -**Returns:** *[RPCSubprovider](#class-rpcsubprovider)* - -## Methods - -### emitPayloadAsync - -▸ **emitPayloadAsync**(`payload`: `Partial`): *`Promise`* - +`_from` | string | - | The current owner of the NFT | +`_to` | string | - | The new owner | +`_tokenId` | `BigNumber` | - | The NFT to transfer | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | +**Returns:** *`Promise`* -*Defined in [subproviders/src/subproviders/subprovider.ts:55](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/subprovider.ts#L55)* - -Emits a JSON RPC payload that will then be handled by the ProviderEngine instance -this subprovider is a part of. The payload will cascade down the subprovider middleware -stack until finding the responsible entity for handling the request. +The hash of the transaction -**Parameters:** +
-Name | Type | Description | ------- | ------ | ------ | -`payload` | `Partial` | JSON RPC payload | +# Class: ExchangeContract -**Returns:** *`Promise`* -JSON RPC response payload +## Constructors -___ -### handleRequest -▸ **handleRequest**(`payload`: `JSONRPCRequestPayload`, `_next`: [Callback](#callback), `end`: [ErrorCallback](#errorcallback)): *`Promise`* +\+ **new ExchangeContract**(`address`: string, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults?`: `Partial`, `logDecodeDependencies?`: undefined | object, `deployedBytecode`: string | undefined): *[ExchangeContract](#class-exchangecontract)* *Overrides void* -*Defined in [subproviders/src/subproviders/rpc_subprovider.ts:38](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/rpc_subprovider.ts#L38)* - -This method conforms to the web3-provider-engine interface. -It is called internally by the ProviderEngine when it is this subproviders -turn to handle a JSON RPC request. +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:10951](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L10951)* **Parameters:** -Name | Type | Description | +Name | Type | Default | ------ | ------ | ------ | -`payload` | `JSONRPCRequestPayload` | JSON RPC payload | -`_next` | [Callback](#callback) | Callback to call if this subprovider decides not to handle the request | -`end` | [ErrorCallback](#errorcallback) | Callback to call if subprovider handled the request and wants to pass back the request. | +`address` | string | - | +`supportedProvider` | [SupportedProvider](#supportedprovider) | - | +`txDefaults?` | `Partial` | - | +`logDecodeDependencies?` | undefined \| object | - | +`deployedBytecode` | string \| undefined | ExchangeContract.deployedBytecode | -**Returns:** *`Promise`* +**Returns:** *[ExchangeContract](#class-exchangecontract)* -___ +## Properties -### setEngine +#### `Optional` _deployedBytecodeIfExists -▸ **setEngine**(`engine`: `Web3ProviderEngine`): *void* +• **_deployedBytecodeIfExists**? : *`Buffer`* -*Defined in [subproviders/src/subproviders/subprovider.ts:68](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/subprovider.ts#L68)* +Defined in base-contract/lib/src/index.d.ts:31 -Set's the subprovider's engine to the ProviderEngine it is added to. -This is only called within the ProviderEngine source code, do not call -directly. +___ -**Parameters:** +### abi -Name | Type | Description | ------- | ------ | ------ | -`engine` | `Web3ProviderEngine` | The ProviderEngine this subprovider is added to | +• **abi**: *[ContractAbi](#contractabi)* -**Returns:** *void* -
-# Enumeration: ERC20TokenEvents +Defined in base-contract/lib/src/index.d.ts:27 +___ -## Enumeration members +### address + +• **address**: *string* -### Approval -• **Approval**: = "Approval" -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:41](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L41)* +Defined in base-contract/lib/src/index.d.ts:28 ___ -### Transfer +Args -• **Transfer**: = "Transfer" +• **constructorArgs**: *any[]* -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:40](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L40)* -
-# Enumeration: ERC721TokenEvents +Defined in base-contract/lib/src/index.d.ts:30 +___ -## Enumeration members +### contractName -### Approval +• **contractName**: *string* -• **Approval**: = "Approval" -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:43](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L43)* -___ +Defined in base-contract/lib/src/index.d.ts:29 -### ApprovalForAll +## Methods -• **ApprovalForAll**: = "ApprovalForAll" +### getLogsAsync -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:44](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L44)* +▸ **getLogsAsync**<**ArgsType**>(`eventName`: [ExchangeEvents](#enumeration-exchangeevents), `blockRange`: `BlockRange`, `indexFilterValues`: `IndexedFilterValues`): *`Promise>>`* -___ +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:10935](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L10935)* -### Transfer +Gets historical logs without creating a subscription -• **Transfer**: = "Transfer" +**Type parameters:** -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:45](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L45)* +▪ **ArgsType**: *[ExchangeEventArgs](#exchangeeventargs)* -
+**Parameters:** -# Enumeration: ExchangeEvents +Name | Type | Description | +------ | ------ | ------ | +`eventName` | [ExchangeEvents](#enumeration-exchangeevents) | The Exchange contract event you would like to subscribe to. | +`blockRange` | `BlockRange` | Block range to get logs from. | +`indexFilterValues` | `IndexedFilterValues` | An object where the keys are indexed args returned by the event and the value is the value you are interested in. E.g `{_from: aUserAddressHex}` | +**Returns:** *`Promise>>`* -## Enumeration members +Array of logs that match the parameters -### AssetProxyRegistered +___ -• **AssetProxyRegistered**: = "AssetProxyRegistered" +### subscribe -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:48](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L48)* +▸ **subscribe**<**ArgsType**>(`eventName`: [ExchangeEvents](#enumeration-exchangeevents), `indexFilterValues`: `IndexedFilterValues`, `callback`: [EventCallback](#eventcallback)‹*`ArgsType`*›, `isVerbose`: boolean, `blockPollingIntervalMs?`: undefined | number): *string* -___ +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:10893](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L10893)* -### Cancel +Subscribe to an event type emitted by the Exchange contract. -• **Cancel**: = "Cancel" +**Type parameters:** -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:49](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L49)* +▪ **ArgsType**: *[ExchangeEventArgs](#exchangeeventargs)* -___ +**Parameters:** -### CancelUpTo +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`eventName` | [ExchangeEvents](#enumeration-exchangeevents) | - | The Exchange contract event you would like to subscribe to. | +`indexFilterValues` | `IndexedFilterValues` | - | An object where the keys are indexed args returned by the event and the value is the value you are interested in. E.g `{maker: aUserAddressHex}` | +`callback` | [EventCallback](#eventcallback)‹*`ArgsType`*› | - | Callback that gets called when a log is added/removed | +`isVerbose` | boolean | false | Enable verbose subscription warnings (e.g recoverable network issues encountered) | +`blockPollingIntervalMs?` | undefined \| number | - | - | -• **CancelUpTo**: = "CancelUpTo" +**Returns:** *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:50](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L50)* +Subscription token used later to unsubscribe ___ -### Fill +### unsubscribe -• **Fill**: = "Fill" +▸ **unsubscribe**(`subscriptionToken`: string): *void* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:51](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L51)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:10918](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L10918)* -___ +Cancel a subscription -### ProtocolFeeCollectorAddress +**Parameters:** -• **ProtocolFeeCollectorAddress**: = "ProtocolFeeCollectorAddress" +Name | Type | Description | +------ | ------ | ------ | +`subscriptionToken` | string | Subscription token returned by `subscribe()` | -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:52](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L52)* +**Returns:** *void* ___ -### ProtocolFeeMultiplier +### unsubscribeAll -• **ProtocolFeeMultiplier**: = "ProtocolFeeMultiplier" +▸ **unsubscribeAll**(): *void* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:53](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L53)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:10924](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L10924)* -___ +Cancels all existing subscriptions -### SignatureValidatorApproval +**Returns:** *void* -• **SignatureValidatorApproval**: = "SignatureValidatorApproval" +___ -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:54](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L54)* +### `Static` ABI -___ +▸ **ABI**(): *[ContractAbi](#contractabi)* -### TransactionExecution +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:8004](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L8004)* -• **TransactionExecution**: = "TransactionExecution" +**Returns:** *[ContractAbi](#contractabi)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:55](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L55)* +The contract ABI -
+___ -# Enumeration: WETH9Events +### `Static` deployAsync +▸ **deployAsync**(`bytecode`: string, `abi`: [ContractAbi](#contractabi), `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object, `chainId`: `BigNumber`): *`Promise`* -## Enumeration members +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7957](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7957)* -### Approval +**Parameters:** -• **Approval**: = "Approval" +Name | Type | +------ | ------ | +`bytecode` | string | +`abi` | [ContractAbi](#contractabi) | +`supportedProvider` | [SupportedProvider](#supportedprovider) | +`txDefaults` | `Partial` | +`logDecodeDependencies` | object | +`chainId` | `BigNumber` | -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:44](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L44)* +**Returns:** *`Promise`* ___ -### Deposit - -• **Deposit**: = "Deposit" +### `Static` deployFrom0xArtifactAsync -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:46](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L46)* +▸ **deployFrom0xArtifactAsync**(`artifact`: `ContractArtifact` | `SimpleContractArtifact`, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object, `chainId`: `BigNumber`): *`Promise`* -___ +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7931](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7931)* -### Transfer +**Parameters:** -• **Transfer**: = "Transfer" +Name | Type | +------ | ------ | +`artifact` | `ContractArtifact` \| `SimpleContractArtifact` | +`supportedProvider` | [SupportedProvider](#supportedprovider) | +`txDefaults` | `Partial` | +`logDecodeDependencies` | object | +`chainId` | `BigNumber` | -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:45](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L45)* +**Returns:** *`Promise`* ___ -### Withdrawal +### `Static` strictArgumentEncodingCheck -• **Withdrawal**: = "Withdrawal" +▸ **strictArgumentEncodingCheck**(`inputAbi`: `DataItem`[], `args`: any[]): *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:47](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L47)* -
-# Enumeration: SubscriptionErrors +Defined in base-contract/lib/src/index.d.ts:41 +**Parameters:** -## Enumeration members +Name | Type | +------ | ------ | +`inputAbi` | `DataItem`[] | +`args` | any[] | -### SubscriptionAlreadyPresent +**Returns:** *string* -• **SubscriptionAlreadyPresent**: = "SUBSCRIPTION_ALREADY_PRESENT" +## Object literals -*Defined in [base-contract/src/types.ts:21](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/base-contract/src/types.ts#L21)* +### EIP1271_MAGIC_VALUE -___ +#### ▪ **EIP1271_MAGIC_VALUE**: *object* -### SubscriptionNotFound +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:120](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L120)* -• **SubscriptionNotFound**: = "SUBSCRIPTION_NOT_FOUND" +#### callAsync -*Defined in [base-contract/src/types.ts:20](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/base-contract/src/types.ts#L20)* +▸ **callAsync**(`callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -
+*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:126](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L126)* -# Enumeration: ChainId +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. +**Parameters:** -## Enumeration members +Name | Type | Default | +------ | ------ | ------ | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | -### Ganache +**Returns:** *`Promise`* -• **Ganache**: = 1337 +___ -*Defined in [contract-addresses/src/index.ts:34](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L34)* +### EIP712_EXCHANGE_DOMAIN_HASH -___ +#### ▪ **EIP712_EXCHANGE_DOMAIN_HASH**: *object* -### Kovan +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:163](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L163)* -• **Kovan**: = 42 +#### callAsync -*Defined in [contract-addresses/src/index.ts:33](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L33)* +▸ **callAsync**(`callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -___ +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:169](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L169)* -### Mainnet +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. -• **Mainnet**: = 1 +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | -*Defined in [contract-addresses/src/index.ts:30](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L30)* +**Returns:** *`Promise`* ___ -### Rinkeby +### allowedValidators -• **Rinkeby**: = 4 +#### ▪ **allowedValidators**: *object* -*Defined in [contract-addresses/src/index.ts:32](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L32)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:206](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L206)* -___ +#### callAsync -### Ropsten +▸ **callAsync**(`index_0`: string, `index_1`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -• **Ropsten**: = 3 +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:212](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L212)* -*Defined in [contract-addresses/src/index.ts:31](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L31)* +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. -
+**Parameters:** +Name | Type | Default | +------ | ------ | ------ | +`index_0` | string | - | +`index_1` | string | - | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | +**Returns:** *`Promise`* -# Enumeration: BlockParamLiteral +___ +### batchCancelOrders -## Enumeration members +#### ▪ **batchCancelOrders**: *object* -### Earliest +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:262](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L262)* -• **Earliest**: = "earliest" +Executes multiple calls of cancelOrder. -*Defined in [ethereum-types/src/index.ts:478](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L478)* +#### awaitTransactionSuccessAsync -___ +▸ **awaitTransactionSuccessAsync**(`orders`: `Array`, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* -### Latest +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:323](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L323)* -• **Latest**: = "latest" +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. -*Defined in [ethereum-types/src/index.ts:479](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L479)* +**Parameters:** -___ +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`orders` | `Array` | - | Array of order specifications. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | -### Pending +**Returns:** *`PromiseWithTransactionHash`* -• **Pending**: = "pending" +A promise that resolves when the transaction is successful -*Defined in [ethereum-types/src/index.ts:480](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L480)* +#### callAsync -
+▸ **callAsync**(`orders`: `Array`, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:410](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L410)* +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. +**Parameters:** +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`orders` | `Array` | - | Array of order specifications. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | +**Returns:** *`Promise`* +#### estimateGasAsync +▸ **estimateGasAsync**(`orders`: `Array`, `txData?`: `Partial` | undefined): *`Promise`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:364](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L364)* +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. +**Parameters:** -# Enumeration: AssetProxyId +Name | Type | Description | +------ | ------ | ------ | +`orders` | `Array` | Array of order specifications. | +`txData?` | `Partial` \| undefined | Additional data for transaction | +**Returns:** *`Promise`* -## Enumeration members +The hash of the transaction -### ERC1155 +#### getABIEncodedTransactionData -• **ERC1155**: = "0xa7cb5fb7" +▸ **getABIEncodedTransactionData**(`orders`: `Array`): *string* -*Defined in [types/src/index.ts:166](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L166)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:478](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L478)* -___ +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). -### ERC20 +**Parameters:** -• **ERC20**: = "0xf47261b0" +Name | Type | Description | +------ | ------ | ------ | +`orders` | `Array` | Array of order specifications. | -*Defined in [types/src/index.ts:163](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L163)* +**Returns:** *string* -___ +The ABI encoded transaction data as a string -### ERC20Bridge +#### getSelector -• **ERC20Bridge**: = "0xdc1600f3" +▸ **getSelector**(): *string* -*Defined in [types/src/index.ts:168](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L168)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:507](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L507)* -___ +Returns the 4 byte function selector as a hex string. -### ERC721 +**Returns:** *string* -• **ERC721**: = "0x02571792" +#### sendTransactionAsync -*Defined in [types/src/index.ts:164](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L164)* +▸ **sendTransactionAsync**(`orders`: `Array`, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* -___ +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:270](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L270)* -### MultiAsset +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. -• **MultiAsset**: = "0x94cfcdd7" +**Parameters:** -*Defined in [types/src/index.ts:165](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L165)* +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`orders` | `Array` | - | Array of order specifications. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | -___ +**Returns:** *`Promise`* -### StaticCall +The hash of the transaction -• **StaticCall**: = "0xc339d10a" +___ -*Defined in [types/src/index.ts:167](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L167)* +### batchExecuteTransactions -
+#### ▪ **batchExecuteTransactions**: *object* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:518](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L518)* +Executes a batch of Exchange method calls in the context of signer(s). +#### awaitTransactionSuccessAsync +▸ **awaitTransactionSuccessAsync**(`transactions`: `Array`, `signatures`: string[], `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:576](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L576)* +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. +**Parameters:** +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`transactions` | `Array` | - | Array of 0x transaction structures. | +`signatures` | string[] | - | Array of proofs that transactions have been signed by signer(s). | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | +**Returns:** *`PromiseWithTransactionHash`* +A promise that resolves when the transaction is successful +#### callAsync +▸ **callAsync**(`transactions`: `Array`, `signatures`: string[], `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -# Enumeration: SignatureType +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:659](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L659)* +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. -## Enumeration members +**Parameters:** -### EIP1271Wallet +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`transactions` | `Array` | - | Array of 0x transaction structures. | +`signatures` | string[] | - | Array of proofs that transactions have been signed by signer(s). | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -• **EIP1271Wallet**: +**Returns:** *`Promise`* -*Defined in [types/src/index.ts:158](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L158)* +Array containing ABI encoded return data for each of the underlying Exchange function calls. -___ +#### estimateGasAsync -### EIP712 +▸ **estimateGasAsync**(`transactions`: `Array`, `signatures`: string[], `txData?`: `Partial` | undefined): *`Promise`* -• **EIP712**: +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:617](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L617)* -*Defined in [types/src/index.ts:153](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L153)* +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. -___ +**Parameters:** -### EthSign +Name | Type | Description | +------ | ------ | ------ | +`transactions` | `Array` | Array of 0x transaction structures. | +`signatures` | string[] | Array of proofs that transactions have been signed by signer(s). | +`txData?` | `Partial` \| undefined | Additional data for transaction | -• **EthSign**: +**Returns:** *`Promise`* -*Defined in [types/src/index.ts:154](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L154)* +The hash of the transaction -___ +#### getABIEncodedTransactionData -### Illegal +▸ **getABIEncodedTransactionData**(`transactions`: `Array`, `signatures`: string[]): *string* -• **Illegal**: +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:722](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L722)* -*Defined in [types/src/index.ts:151](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L151)* +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). -___ +**Parameters:** -### Invalid +Name | Type | Description | +------ | ------ | ------ | +`transactions` | `Array` | Array of 0x transaction structures. | +`signatures` | string[] | Array of proofs that transactions have been signed by signer(s). | -• **Invalid**: +**Returns:** *string* -*Defined in [types/src/index.ts:152](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L152)* +The ABI encoded transaction data as a string -___ +#### getSelector -### NSignatureTypes +▸ **getSelector**(): *string* -• **NSignatureTypes**: +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:744](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L744)* -*Defined in [types/src/index.ts:159](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L159)* +Returns the 4 byte function selector as a hex string. -___ +**Returns:** *string* -### PreSigned +#### sendTransactionAsync -• **PreSigned**: +▸ **sendTransactionAsync**(`transactions`: `Array`, `signatures`: string[], `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* -*Defined in [types/src/index.ts:157](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L157)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:528](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L528)* -___ +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. -### Validator +**Parameters:** -• **Validator**: +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`transactions` | `Array` | - | Array of 0x transaction structures. | +`signatures` | string[] | - | Array of proofs that transactions have been signed by signer(s). | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* -*Defined in [types/src/index.ts:156](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L156)* +The hash of the transaction ___ -### Wallet +### batchFillOrKillOrders -• **Wallet**: +#### ▪ **batchFillOrKillOrders**: *object* -*Defined in [types/src/index.ts:155](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L155)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:755](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L755)* -
+Executes multiple calls of fillOrKillOrder. +#### awaitTransactionSuccessAsync +▸ **awaitTransactionSuccessAsync**(`orders`: `Array`, `takerAssetFillAmounts`: `BigNumber`[], `signatures`: string[], `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:831](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L831)* +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. +**Parameters:** +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`orders` | `Array` | - | Array of order specifications. | +`takerAssetFillAmounts` | `BigNumber`[] | - | Array of desired amounts of takerAsset to sell in orders. | +`signatures` | string[] | - | Proofs that orders have been created by makers. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | +**Returns:** *`PromiseWithTransactionHash`* +A promise that resolves when the transaction is successful +#### callAsync +▸ **callAsync**(`orders`: `Array`, `takerAssetFillAmounts`: `BigNumber`[], `signatures`: string[], `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise>`* -
+*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:939](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L939)* -# Interface: ERC20TokenApprovalEventArgs +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. +**Parameters:** -## Index +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`orders` | `Array` | - | Array of order specifications. | +`takerAssetFillAmounts` | `BigNumber`[] | - | Array of desired amounts of takerAsset to sell in orders. | +`signatures` | string[] | - | Proofs that orders have been created by makers. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -### Properties +**Returns:** *`Promise>`* -* [_owner](#_owner) -* [_spender](#_spender) -* [_value](#_value) +Array of amounts filled and fees paid by makers and taker. -## Properties +#### estimateGasAsync -### _owner +▸ **estimateGasAsync**(`orders`: `Array`, `takerAssetFillAmounts`: `BigNumber`[], `signatures`: string[], `txData?`: `Partial` | undefined): *`Promise`* -• **_owner**: *string* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:885](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L885)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:51](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L51)* +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. -___ - -### _spender +**Parameters:** -• **_spender**: *string* +Name | Type | Description | +------ | ------ | ------ | +`orders` | `Array` | Array of order specifications. | +`takerAssetFillAmounts` | `BigNumber`[] | Array of desired amounts of takerAsset to sell in orders. | +`signatures` | string[] | Proofs that orders have been created by makers. | +`txData?` | `Partial` \| undefined | Additional data for transaction | -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:52](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L52)* +**Returns:** *`Promise`* -___ +The hash of the transaction -### _value +#### getABIEncodedTransactionData -• **_value**: *`BigNumber`* +▸ **getABIEncodedTransactionData**(`orders`: `Array`, `takerAssetFillAmounts`: `BigNumber`[], `signatures`: string[]): *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:53](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L53)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:1030](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L1030)* -
+Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). -# Interface: ERC20TokenTransferEventArgs +**Parameters:** +Name | Type | Description | +------ | ------ | ------ | +`orders` | `Array` | Array of order specifications. | +`takerAssetFillAmounts` | `BigNumber`[] | Array of desired amounts of takerAsset to sell in orders. | +`signatures` | string[] | Proofs that orders have been created by makers. | -## Index +**Returns:** *string* -### Properties +The ABI encoded transaction data as a string -* [_from](#_from) -* [_to](#_to) -* [_value](#_value) +#### getSelector -## Properties +▸ **getSelector**(): *string* -### _from +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:1063](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L1063)* -• **_from**: *string* +Returns the 4 byte function selector as a hex string. -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:45](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L45)* +**Returns:** *string* -___ +#### sendTransactionAsync -### _to +▸ **sendTransactionAsync**(`orders`: `Array`, `takerAssetFillAmounts`: `BigNumber`[], `signatures`: string[], `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* -• **_to**: *string* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:766](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L766)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:46](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L46)* +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. -___ +**Parameters:** -### _value +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`orders` | `Array` | - | Array of order specifications. | +`takerAssetFillAmounts` | `BigNumber`[] | - | Array of desired amounts of takerAsset to sell in orders. | +`signatures` | string[] | - | Proofs that orders have been created by makers. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | -• **_value**: *`BigNumber`* +**Returns:** *`Promise`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:47](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L47)* +The hash of the transaction -
+___ -# Interface: ERC721TokenApprovalEventArgs +### batchFillOrders +#### ▪ **batchFillOrders**: *object* -## Index +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:1074](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L1074)* -### Properties +Executes multiple calls of fillOrder. -* [_approved](#_approved) -* [_owner](#_owner) -* [_tokenId](#_tokenid) +#### awaitTransactionSuccessAsync -## Properties +▸ **awaitTransactionSuccessAsync**(`orders`: `Array`, `takerAssetFillAmounts`: `BigNumber`[], `signatures`: string[], `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* -### _approved +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:1145](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L1145)* -• **_approved**: *string* +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:50](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L50)* +**Parameters:** -___ +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`orders` | `Array` | - | Array of order specifications. | +`takerAssetFillAmounts` | `BigNumber`[] | - | Array of desired amounts of takerAsset to sell in orders. | +`signatures` | string[] | - | Proofs that orders have been created by makers. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | -### _owner +**Returns:** *`PromiseWithTransactionHash`* -• **_owner**: *string* +A promise that resolves when the transaction is successful -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:49](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L49)* +#### callAsync -___ +▸ **callAsync**(`orders`: `Array`, `takerAssetFillAmounts`: `BigNumber`[], `signatures`: string[], `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise>`* -### _tokenId +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:1253](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L1253)* -• **_tokenId**: *`BigNumber`* +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:51](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L51)* +**Parameters:** -
+Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`orders` | `Array` | - | Array of order specifications. | +`takerAssetFillAmounts` | `BigNumber`[] | - | Array of desired amounts of takerAsset to sell in orders. | +`signatures` | string[] | - | Proofs that orders have been created by makers. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -# Interface: ERC721TokenApprovalForAllEventArgs +**Returns:** *`Promise>`* +Array of amounts filled and fees paid by makers and taker. -## Index +#### estimateGasAsync -### Properties +▸ **estimateGasAsync**(`orders`: `Array`, `takerAssetFillAmounts`: `BigNumber`[], `signatures`: string[], `txData?`: `Partial` | undefined): *`Promise`* -* [_approved](#_approved) -* [_operator](#_operator) -* [_owner](#_owner) +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:1199](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L1199)* -## Properties +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. -### _approved +**Parameters:** -• **_approved**: *boolean* +Name | Type | Description | +------ | ------ | ------ | +`orders` | `Array` | Array of order specifications. | +`takerAssetFillAmounts` | `BigNumber`[] | Array of desired amounts of takerAsset to sell in orders. | +`signatures` | string[] | Proofs that orders have been created by makers. | +`txData?` | `Partial` \| undefined | Additional data for transaction | -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:57](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L57)* +**Returns:** *`Promise`* -___ +The hash of the transaction -### _operator +#### getABIEncodedTransactionData -• **_operator**: *string* +▸ **getABIEncodedTransactionData**(`orders`: `Array`, `takerAssetFillAmounts`: `BigNumber`[], `signatures`: string[]): *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:56](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L56)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:1344](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L1344)* -___ +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). -### _owner +**Parameters:** -• **_owner**: *string* +Name | Type | Description | +------ | ------ | ------ | +`orders` | `Array` | Array of order specifications. | +`takerAssetFillAmounts` | `BigNumber`[] | Array of desired amounts of takerAsset to sell in orders. | +`signatures` | string[] | Proofs that orders have been created by makers. | -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:55](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L55)* +**Returns:** *string* -
+The ABI encoded transaction data as a string -# Interface: ERC721TokenTransferEventArgs +#### getSelector +▸ **getSelector**(): *string* -## Index +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:1377](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L1377)* -### Properties +Returns the 4 byte function selector as a hex string. -* [_from](#_from) -* [_to](#_to) -* [_tokenId](#_tokenid) +**Returns:** *string* -## Properties +#### sendTransactionAsync -### _from +▸ **sendTransactionAsync**(`orders`: `Array`, `takerAssetFillAmounts`: `BigNumber`[], `signatures`: string[], `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* -• **_from**: *string* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:1085](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L1085)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:61](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L61)* +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. -___ +**Parameters:** -### _to +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`orders` | `Array` | - | Array of order specifications. | +`takerAssetFillAmounts` | `BigNumber`[] | - | Array of desired amounts of takerAsset to sell in orders. | +`signatures` | string[] | - | Proofs that orders have been created by makers. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | -• **_to**: *string* +**Returns:** *`Promise`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:62](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L62)* +The hash of the transaction ___ -### _tokenId - -• **_tokenId**: *`BigNumber`* +### batchFillOrdersNoThrow -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:63](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L63)* +#### ▪ **batchFillOrdersNoThrow**: *object* -
+*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:1388](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L1388)* -# Interface: ExchangeAssetProxyRegisteredEventArgs +Executes multiple calls of fillOrder. If any fill reverts, the error is caught and ignored. +#### awaitTransactionSuccessAsync -## Index +▸ **awaitTransactionSuccessAsync**(`orders`: `Array`, `takerAssetFillAmounts`: `BigNumber`[], `signatures`: string[], `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* -### Properties +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:1464](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L1464)* -* [assetProxy](#assetproxy) -* [id](#id) +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. -## Properties +**Parameters:** -### assetProxy +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`orders` | `Array` | - | Array of order specifications. | +`takerAssetFillAmounts` | `BigNumber`[] | - | Array of desired amounts of takerAsset to sell in orders. | +`signatures` | string[] | - | Proofs that orders have been created by makers. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | -• **assetProxy**: *string* +**Returns:** *`PromiseWithTransactionHash`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:60](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L60)* +A promise that resolves when the transaction is successful -___ +#### callAsync -### id +▸ **callAsync**(`orders`: `Array`, `takerAssetFillAmounts`: `BigNumber`[], `signatures`: string[], `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise>`* -• **id**: *string* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:1572](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L1572)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:59](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L59)* +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. -
+**Parameters:** -# Interface: ExchangeCancelEventArgs +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`orders` | `Array` | - | Array of order specifications. | +`takerAssetFillAmounts` | `BigNumber`[] | - | Array of desired amounts of takerAsset to sell in orders. | +`signatures` | string[] | - | Proofs that orders have been created by makers. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | +**Returns:** *`Promise>`* -## Index +Array of amounts filled and fees paid by makers and taker. -### Properties +#### estimateGasAsync -* [feeRecipientAddress](#feerecipientaddress) -* [makerAddress](#makeraddress) -* [makerAssetData](#makerassetdata) -* [orderHash](#orderhash) -* [senderAddress](#senderaddress) -* [takerAssetData](#takerassetdata) +▸ **estimateGasAsync**(`orders`: `Array`, `takerAssetFillAmounts`: `BigNumber`[], `signatures`: string[], `txData?`: `Partial` | undefined): *`Promise`* -## Properties +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:1518](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L1518)* -### feeRecipientAddress +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. -• **feeRecipientAddress**: *string* +**Parameters:** -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:65](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L65)* +Name | Type | Description | +------ | ------ | ------ | +`orders` | `Array` | Array of order specifications. | +`takerAssetFillAmounts` | `BigNumber`[] | Array of desired amounts of takerAsset to sell in orders. | +`signatures` | string[] | Proofs that orders have been created by makers. | +`txData?` | `Partial` \| undefined | Additional data for transaction | -___ +**Returns:** *`Promise`* -### makerAddress +The hash of the transaction -• **makerAddress**: *string* +#### getABIEncodedTransactionData -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:64](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L64)* +▸ **getABIEncodedTransactionData**(`orders`: `Array`, `takerAssetFillAmounts`: `BigNumber`[], `signatures`: string[]): *string* -___ +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:1663](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L1663)* -### makerAssetData +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). -• **makerAssetData**: *string* +**Parameters:** -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:66](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L66)* +Name | Type | Description | +------ | ------ | ------ | +`orders` | `Array` | Array of order specifications. | +`takerAssetFillAmounts` | `BigNumber`[] | Array of desired amounts of takerAsset to sell in orders. | +`signatures` | string[] | Proofs that orders have been created by makers. | -___ +**Returns:** *string* -### orderHash +The ABI encoded transaction data as a string -• **orderHash**: *string* +#### getSelector -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:69](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L69)* +▸ **getSelector**(): *string* -___ +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:1696](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L1696)* -### senderAddress +Returns the 4 byte function selector as a hex string. -• **senderAddress**: *string* +**Returns:** *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:68](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L68)* +#### sendTransactionAsync -___ +▸ **sendTransactionAsync**(`orders`: `Array`, `takerAssetFillAmounts`: `BigNumber`[], `signatures`: string[], `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* -### takerAssetData +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:1399](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L1399)* -• **takerAssetData**: *string* +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:67](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L67)* +**Parameters:** -
+Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`orders` | `Array` | - | Array of order specifications. | +`takerAssetFillAmounts` | `BigNumber`[] | - | Array of desired amounts of takerAsset to sell in orders. | +`signatures` | string[] | - | Proofs that orders have been created by makers. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | -# Interface: ExchangeCancelUpToEventArgs +**Returns:** *`Promise`* +The hash of the transaction -## Index +___ -### Properties +### batchMatchOrders -* [makerAddress](#makeraddress) -* [orderEpoch](#orderepoch) -* [orderSenderAddress](#ordersenderaddress) +#### ▪ **batchMatchOrders**: *object* -## Properties +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:1709](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L1709)* -### makerAddress +Match complementary orders that have a profitable spread. +Each order is filled at their respective price point, and +the matcher receives a profit denominated in the left maker asset. -• **makerAddress**: *string* +#### awaitTransactionSuccessAsync -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:73](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L73)* +▸ **awaitTransactionSuccessAsync**(`leftOrders`: `Array`, `rightOrders`: `Array`, `leftSignatures`: string[], `rightSignatures`: string[], `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* -___ +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:1807](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L1807)* -### orderEpoch +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. -• **orderEpoch**: *`BigNumber`* +**Parameters:** -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:75](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L75)* +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`leftOrders` | `Array` | - | Set of orders with the same maker / taker asset. | +`rightOrders` | `Array` | - | Set of orders to match against `leftOrders` | +`leftSignatures` | string[] | - | Proof that left orders were created by the left makers. | +`rightSignatures` | string[] | - | Proof that right orders were created by the right makers. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | -___ +**Returns:** *`PromiseWithTransactionHash`* -### orderSenderAddress +A promise that resolves when the transaction is successful -• **orderSenderAddress**: *string* +#### callAsync -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:74](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L74)* +▸ **callAsync**(`leftOrders`: `Array`, `rightOrders`: `Array`, `leftSignatures`: string[], `rightSignatures`: string[], `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -
+*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:1954](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L1954)* -# Interface: ExchangeFillEventArgs +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. +**Parameters:** -## Index +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`leftOrders` | `Array` | - | Set of orders with the same maker / taker asset. | +`rightOrders` | `Array` | - | Set of orders to match against `leftOrders` | +`leftSignatures` | string[] | - | Proof that left orders were created by the left makers. | +`rightSignatures` | string[] | - | Proof that right orders were created by the right makers. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -### Properties +**Returns:** *`Promise`* -* [feeRecipientAddress](#feerecipientaddress) -* [makerAddress](#makeraddress) -* [makerAssetData](#makerassetdata) -* [makerAssetFilledAmount](#makerassetfilledamount) -* [makerFeeAssetData](#makerfeeassetdata) -* [makerFeePaid](#makerfeepaid) -* [orderHash](#orderhash) -* [protocolFeePaid](#protocolfeepaid) -* [senderAddress](#senderaddress) -* [takerAddress](#takeraddress) -* [takerAssetData](#takerassetdata) -* [takerAssetFilledAmount](#takerassetfilledamount) -* [takerFeeAssetData](#takerfeeassetdata) -* [takerFeePaid](#takerfeepaid) +batchMatchedFillResults Amounts filled and profit generated. -## Properties +#### estimateGasAsync -### feeRecipientAddress +▸ **estimateGasAsync**(`leftOrders`: `Array`, `rightOrders`: `Array`, `leftSignatures`: string[], `rightSignatures`: string[], `txData?`: `Partial` | undefined): *`Promise`* -• **feeRecipientAddress**: *string* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:1881](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L1881)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:80](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L80)* +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. -___ +**Parameters:** -### makerAddress +Name | Type | Description | +------ | ------ | ------ | +`leftOrders` | `Array` | Set of orders with the same maker / taker asset. | +`rightOrders` | `Array` | Set of orders to match against `leftOrders` | +`leftSignatures` | string[] | Proof that left orders were created by the left makers. | +`rightSignatures` | string[] | Proof that right orders were created by the right makers. | +`txData?` | `Partial` \| undefined | Additional data for transaction | -• **makerAddress**: *string* +**Returns:** *`Promise`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:79](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L79)* +The hash of the transaction -___ +#### getABIEncodedTransactionData -### makerAssetData +▸ **getABIEncodedTransactionData**(`leftOrders`: `Array`, `rightOrders`: `Array`, `leftSignatures`: string[], `rightSignatures`: string[]): *string* -• **makerAssetData**: *string* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:2082](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L2082)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:81](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L81)* +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). -___ +**Parameters:** -### makerAssetFilledAmount +Name | Type | Description | +------ | ------ | ------ | +`leftOrders` | `Array` | Set of orders with the same maker / taker asset. | +`rightOrders` | `Array` | Set of orders to match against `leftOrders` | +`leftSignatures` | string[] | Proof that left orders were created by the left makers. | +`rightSignatures` | string[] | Proof that right orders were created by the right makers. | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:2132](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L2132)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`leftOrders`: `Array`, `rightOrders`: `Array`, `leftSignatures`: string[], `rightSignatures`: string[], `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:1722](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L1722)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`leftOrders` | `Array` | - | Set of orders with the same maker / taker asset. | +`rightOrders` | `Array` | - | Set of orders to match against `leftOrders` | +`leftSignatures` | string[] | - | Proof that left orders were created by the left makers. | +`rightSignatures` | string[] | - | Proof that right orders were created by the right makers. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### batchMatchOrdersWithMaximalFill + +#### ▪ **batchMatchOrdersWithMaximalFill**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:2146](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L2146)* + +Match complementary orders that have a profitable spread. +Each order is maximally filled at their respective price point, and +the matcher receives a profit denominated in either the left maker asset, +right maker asset, or a combination of both. + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`leftOrders`: `Array`, `rightOrders`: `Array`, `leftSignatures`: string[], `rightSignatures`: string[], `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:2244](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L2244)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`leftOrders` | `Array` | - | Set of orders with the same maker / taker asset. | +`rightOrders` | `Array` | - | Set of orders to match against `leftOrders` | +`leftSignatures` | string[] | - | Proof that left orders were created by the left makers. | +`rightSignatures` | string[] | - | Proof that right orders were created by the right makers. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`leftOrders`: `Array`, `rightOrders`: `Array`, `leftSignatures`: string[], `rightSignatures`: string[], `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:2391](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L2391)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`leftOrders` | `Array` | - | Set of orders with the same maker / taker asset. | +`rightOrders` | `Array` | - | Set of orders to match against `leftOrders` | +`leftSignatures` | string[] | - | Proof that left orders were created by the left makers. | +`rightSignatures` | string[] | - | Proof that right orders were created by the right makers. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +batchMatchedFillResults Amounts filled and profit generated. + +#### estimateGasAsync + +▸ **estimateGasAsync**(`leftOrders`: `Array`, `rightOrders`: `Array`, `leftSignatures`: string[], `rightSignatures`: string[], `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:2318](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L2318)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`leftOrders` | `Array` | Set of orders with the same maker / taker asset. | +`rightOrders` | `Array` | Set of orders to match against `leftOrders` | +`leftSignatures` | string[] | Proof that left orders were created by the left makers. | +`rightSignatures` | string[] | Proof that right orders were created by the right makers. | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`leftOrders`: `Array`, `rightOrders`: `Array`, `leftSignatures`: string[], `rightSignatures`: string[]): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:2519](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L2519)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`leftOrders` | `Array` | Set of orders with the same maker / taker asset. | +`rightOrders` | `Array` | Set of orders to match against `leftOrders` | +`leftSignatures` | string[] | Proof that left orders were created by the left makers. | +`rightSignatures` | string[] | Proof that right orders were created by the right makers. | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:2569](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L2569)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`leftOrders`: `Array`, `rightOrders`: `Array`, `leftSignatures`: string[], `rightSignatures`: string[], `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:2159](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L2159)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`leftOrders` | `Array` | - | Set of orders with the same maker / taker asset. | +`rightOrders` | `Array` | - | Set of orders to match against `leftOrders` | +`leftSignatures` | string[] | - | Proof that left orders were created by the left makers. | +`rightSignatures` | string[] | - | Proof that right orders were created by the right makers. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### cancelOrder + +#### ▪ **cancelOrder**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:2580](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L2580)* + +After calling, the order can not be filled anymore. + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`order`: object, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:2640](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L2640)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`order` | object | - | Order struct containing order specifications. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`order`: object, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:2725](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L2725)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`order` | object | - | Order struct containing order specifications. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +#### estimateGasAsync + +▸ **estimateGasAsync**(`order`: object, `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:2680](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L2680)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`order` | object | Order struct containing order specifications. | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`order`: object): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:2792](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L2792)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`order` | object | Order struct containing order specifications. | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:2818](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L2818)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`order`: object, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:2588](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L2588)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`order` | object | - | Order struct containing order specifications. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### cancelOrdersUpTo + +#### ▪ **cancelOrdersUpTo**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:2830](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L2830)* + +Cancels all orders created by makerAddress with a salt less than or equal to the targetOrderEpoch +and senderAddress equal to msg.sender (or null address if msg.sender == makerAddress). + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`targetOrderEpoch`: `BigNumber`, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:2875](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L2875)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`targetOrderEpoch` | `BigNumber` | - | Orders created with a salt less or equal to this value will be cancelled. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`targetOrderEpoch`: `BigNumber`, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:2928](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L2928)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`targetOrderEpoch` | `BigNumber` | - | Orders created with a salt less or equal to this value will be cancelled. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +#### estimateGasAsync + +▸ **estimateGasAsync**(`targetOrderEpoch`: `BigNumber`, `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:2902](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L2902)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`targetOrderEpoch` | `BigNumber` | Orders created with a salt less or equal to this value will be cancelled. | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`targetOrderEpoch`: `BigNumber`): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:2977](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L2977)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`targetOrderEpoch` | `BigNumber` | Orders created with a salt less or equal to this value will be cancelled. | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:2988](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L2988)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`targetOrderEpoch`: `BigNumber`, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:2839](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L2839)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`targetOrderEpoch` | `BigNumber` | - | Orders created with a salt less or equal to this value will be cancelled. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### cancelled + +#### ▪ **cancelled**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:2994](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L2994)* + +#### callAsync + +▸ **callAsync**(`index_0`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3000](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3000)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`index_0` | string | - | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +___ + +### currentContextAddress + +#### ▪ **currentContextAddress**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3042](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3042)* + +#### callAsync + +▸ **callAsync**(`callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3048](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3048)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +___ + +### executeTransaction + +#### ▪ **executeTransaction**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3088](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3088)* + +Executes an Exchange method call in the context of signer. + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`transaction`: object, `signature`: string, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3143](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3143)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`transaction` | object | - | 0x transaction structure. | +`signature` | string | - | Proof that transaction has been signed by signer. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`transaction`: object, `signature`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3217](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3217)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`transaction` | object | - | 0x transaction structure. | +`signature` | string | - | Proof that transaction has been signed by signer. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +ABI encoded return data of the underlying Exchange function call. + +#### estimateGasAsync + +▸ **estimateGasAsync**(`transaction`: object, `signature`: string, `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3177](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3177)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`transaction` | object | 0x transaction structure. | +`signature` | string | Proof that transaction has been signed by signer. | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`transaction`: object, `signature`: string): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3278](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3278)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`transaction` | object | 0x transaction structure. | +`signature` | string | Proof that transaction has been signed by signer. | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3299](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3299)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`transaction`: object, `signature`: string, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3097](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3097)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`transaction` | object | - | 0x transaction structure. | +`signature` | string | - | Proof that transaction has been signed by signer. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### fillOrKillOrder + +#### ▪ **fillOrKillOrder**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3310](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3310)* + +Fills the input order. Reverts if exact takerAssetFillAmount not filled. + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`order`: object, `takerAssetFillAmount`: `BigNumber`, `signature`: string, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3378](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3378)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`order` | object | - | Order struct containing order specifications. | +`takerAssetFillAmount` | `BigNumber` | - | Desired amount of takerAsset to sell. | +`signature` | string | - | Proof that order has been created by maker. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`order`: object, `takerAssetFillAmount`: `BigNumber`, `signature`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3481](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3481)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`order` | object | - | Order struct containing order specifications. | +`takerAssetFillAmount` | `BigNumber` | - | Desired amount of takerAsset to sell. | +`signature` | string | - | Proof that order has been created by maker. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +#### estimateGasAsync + +▸ **estimateGasAsync**(`order`: object, `takerAssetFillAmount`: `BigNumber`, `signature`: string, `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3430](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3430)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`order` | object | Order struct containing order specifications. | +`takerAssetFillAmount` | `BigNumber` | Desired amount of takerAsset to sell. | +`signature` | string | Proof that order has been created by maker. | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`order`: object, `takerAssetFillAmount`: `BigNumber`, `signature`: string): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3566](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3566)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`order` | object | Order struct containing order specifications. | +`takerAssetFillAmount` | `BigNumber` | Desired amount of takerAsset to sell. | +`signature` | string | Proof that order has been created by maker. | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3598](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3598)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`order`: object, `takerAssetFillAmount`: `BigNumber`, `signature`: string, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3320](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3320)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`order` | object | - | Order struct containing order specifications. | +`takerAssetFillAmount` | `BigNumber` | - | Desired amount of takerAsset to sell. | +`signature` | string | - | Proof that order has been created by maker. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### fillOrder + +#### ▪ **fillOrder**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3609](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3609)* + +Fills the input order. + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`order`: object, `takerAssetFillAmount`: `BigNumber`, `signature`: string, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3677](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3677)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`order` | object | - | Order struct containing order specifications. | +`takerAssetFillAmount` | `BigNumber` | - | Desired amount of takerAsset to sell. | +`signature` | string | - | Proof that order has been created by maker. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`order`: object, `takerAssetFillAmount`: `BigNumber`, `signature`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3781](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3781)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`order` | object | - | Order struct containing order specifications. | +`takerAssetFillAmount` | `BigNumber` | - | Desired amount of takerAsset to sell. | +`signature` | string | - | Proof that order has been created by maker. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +Amounts filled and fees paid by maker and taker. + +#### estimateGasAsync + +▸ **estimateGasAsync**(`order`: object, `takerAssetFillAmount`: `BigNumber`, `signature`: string, `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3729](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3729)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`order` | object | Order struct containing order specifications. | +`takerAssetFillAmount` | `BigNumber` | Desired amount of takerAsset to sell. | +`signature` | string | Proof that order has been created by maker. | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`order`: object, `takerAssetFillAmount`: `BigNumber`, `signature`: string): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3866](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3866)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`order` | object | Order struct containing order specifications. | +`takerAssetFillAmount` | `BigNumber` | Desired amount of takerAsset to sell. | +`signature` | string | Proof that order has been created by maker. | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3898](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3898)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`order`: object, `takerAssetFillAmount`: `BigNumber`, `signature`: string, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3619](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3619)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`order` | object | - | Order struct containing order specifications. | +`takerAssetFillAmount` | `BigNumber` | - | Desired amount of takerAsset to sell. | +`signature` | string | - | Proof that order has been created by maker. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### filled + +#### ▪ **filled**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3906](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3906)* + +#### callAsync + +▸ **callAsync**(`index_0`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3912](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3912)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`index_0` | string | - | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +___ + +### getAssetProxy + +#### ▪ **getAssetProxy**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3957](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3957)* + +Gets an asset proxy. + +#### callAsync + +▸ **callAsync**(`assetProxyId`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3965](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3965)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`assetProxyId` | string | - | Id of the asset proxy. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +The asset proxy registered to assetProxyId. Returns 0x0 if no proxy is registered. + +___ + +### getOrderInfo + +#### ▪ **getOrderInfo**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4010](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4010)* + +Gets information about an order: status, hash, and amount filled. + +#### callAsync + +▸ **callAsync**(`order`: object, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4018](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4018)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`order` | object | - | Order to gather information on. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +OrderInfo Information about the order and its state. See LibOrder.OrderInfo for a complete description. + +___ + +### isValidHashSignature + +#### ▪ **isValidHashSignature**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4086](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4086)* + +Verifies that a hash has been signed by the given signer. + +#### callAsync + +▸ **callAsync**(`hash`: string, `signerAddress`: string, `signature`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4096](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4096)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`hash` | string | - | Any 32-byte hash. | +`signerAddress` | string | - | Address that should have signed the given hash. | +`signature` | string | - | Proof that the hash has been signed by signer. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +isValid `true` if the signature is valid for the given hash and signer. + +___ + +### isValidOrderSignature + +#### ▪ **isValidOrderSignature**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4149](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4149)* + +Verifies that a signature for an order is valid. + +#### callAsync + +▸ **callAsync**(`order`: object, `signature`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4158](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4158)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`order` | object | - | The order. | +`signature` | string | - | Proof that the order has been signed by signer. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +isValid `true` if the signature is valid for the given order and signer. + +___ + +### isValidTransactionSignature + +#### ▪ **isValidTransactionSignature**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4224](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4224)* + +Verifies that a signature for a transaction is valid. + +#### callAsync + +▸ **callAsync**(`transaction`: object, `signature`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4233](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4233)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`transaction` | object | - | The transaction. | +`signature` | string | - | Proof that the order has been signed by signer. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +isValid `true` if the signature is valid for the given transaction and signer. + +___ + +### marketBuyOrdersFillOrKill + +#### ▪ **marketBuyOrdersFillOrKill**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4291](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4291)* + +Calls marketBuyOrdersNoThrow then reverts if < makerAssetFillAmount has been bought. +NOTE: This function does not enforce that the makerAsset is the same for each order. + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`orders`: `Array`, `makerAssetFillAmount`: `BigNumber`, `signatures`: string[], `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4365](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4365)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`orders` | `Array` | - | Array of order specifications. | +`makerAssetFillAmount` | `BigNumber` | - | Minimum amount of makerAsset to buy. | +`signatures` | string[] | - | Proofs that orders have been signed by makers. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`orders`: `Array`, `makerAssetFillAmount`: `BigNumber`, `signatures`: string[], `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4471](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4471)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`orders` | `Array` | - | Array of order specifications. | +`makerAssetFillAmount` | `BigNumber` | - | Minimum amount of makerAsset to buy. | +`signatures` | string[] | - | Proofs that orders have been signed by makers. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +Amounts filled and fees paid by makers and taker. + +#### estimateGasAsync + +▸ **estimateGasAsync**(`orders`: `Array`, `makerAssetFillAmount`: `BigNumber`, `signatures`: string[], `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4418](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4418)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`orders` | `Array` | Array of order specifications. | +`makerAssetFillAmount` | `BigNumber` | Minimum amount of makerAsset to buy. | +`signatures` | string[] | Proofs that orders have been signed by makers. | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`orders`: `Array`, `makerAssetFillAmount`: `BigNumber`, `signatures`: string[]): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4557](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4557)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`orders` | `Array` | Array of order specifications. | +`makerAssetFillAmount` | `BigNumber` | Minimum amount of makerAsset to buy. | +`signatures` | string[] | Proofs that orders have been signed by makers. | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4590](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4590)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`orders`: `Array`, `makerAssetFillAmount`: `BigNumber`, `signatures`: string[], `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4301](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4301)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`orders` | `Array` | - | Array of order specifications. | +`makerAssetFillAmount` | `BigNumber` | - | Minimum amount of makerAsset to buy. | +`signatures` | string[] | - | Proofs that orders have been signed by makers. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### marketBuyOrdersNoThrow + +#### ▪ **marketBuyOrdersNoThrow**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4603](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4603)* + +Executes multiple calls of fillOrder until total amount of makerAsset is bought by taker. +If any fill reverts, the error is caught and ignored. +NOTE: This function does not enforce that the makerAsset is the same for each order. + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`orders`: `Array`, `makerAssetFillAmount`: `BigNumber`, `signatures`: string[], `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4677](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4677)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`orders` | `Array` | - | Array of order specifications. | +`makerAssetFillAmount` | `BigNumber` | - | Desired amount of makerAsset to buy. | +`signatures` | string[] | - | Proofs that orders have been signed by makers. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`orders`: `Array`, `makerAssetFillAmount`: `BigNumber`, `signatures`: string[], `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4783](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4783)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`orders` | `Array` | - | Array of order specifications. | +`makerAssetFillAmount` | `BigNumber` | - | Desired amount of makerAsset to buy. | +`signatures` | string[] | - | Proofs that orders have been signed by makers. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +Amounts filled and fees paid by makers and taker. + +#### estimateGasAsync + +▸ **estimateGasAsync**(`orders`: `Array`, `makerAssetFillAmount`: `BigNumber`, `signatures`: string[], `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4730](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4730)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`orders` | `Array` | Array of order specifications. | +`makerAssetFillAmount` | `BigNumber` | Desired amount of makerAsset to buy. | +`signatures` | string[] | Proofs that orders have been signed by makers. | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`orders`: `Array`, `makerAssetFillAmount`: `BigNumber`, `signatures`: string[]): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4869](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4869)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`orders` | `Array` | Array of order specifications. | +`makerAssetFillAmount` | `BigNumber` | Desired amount of makerAsset to buy. | +`signatures` | string[] | Proofs that orders have been signed by makers. | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4902](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4902)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`orders`: `Array`, `makerAssetFillAmount`: `BigNumber`, `signatures`: string[], `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4613](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4613)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`orders` | `Array` | - | Array of order specifications. | +`makerAssetFillAmount` | `BigNumber` | - | Desired amount of makerAsset to buy. | +`signatures` | string[] | - | Proofs that orders have been signed by makers. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### marketSellOrdersFillOrKill + +#### ▪ **marketSellOrdersFillOrKill**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4914](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4914)* + +Calls marketSellOrdersNoThrow then reverts if < takerAssetFillAmount has been sold. +NOTE: This function does not enforce that the takerAsset is the same for each order. + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`orders`: `Array`, `takerAssetFillAmount`: `BigNumber`, `signatures`: string[], `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4988](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4988)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`orders` | `Array` | - | Array of order specifications. | +`takerAssetFillAmount` | `BigNumber` | - | Minimum amount of takerAsset to sell. | +`signatures` | string[] | - | Proofs that orders have been signed by makers. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`orders`: `Array`, `takerAssetFillAmount`: `BigNumber`, `signatures`: string[], `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:5094](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L5094)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`orders` | `Array` | - | Array of order specifications. | +`takerAssetFillAmount` | `BigNumber` | - | Minimum amount of takerAsset to sell. | +`signatures` | string[] | - | Proofs that orders have been signed by makers. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +Amounts filled and fees paid by makers and taker. + +#### estimateGasAsync + +▸ **estimateGasAsync**(`orders`: `Array`, `takerAssetFillAmount`: `BigNumber`, `signatures`: string[], `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:5041](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L5041)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`orders` | `Array` | Array of order specifications. | +`takerAssetFillAmount` | `BigNumber` | Minimum amount of takerAsset to sell. | +`signatures` | string[] | Proofs that orders have been signed by makers. | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`orders`: `Array`, `takerAssetFillAmount`: `BigNumber`, `signatures`: string[]): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:5180](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L5180)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`orders` | `Array` | Array of order specifications. | +`takerAssetFillAmount` | `BigNumber` | Minimum amount of takerAsset to sell. | +`signatures` | string[] | Proofs that orders have been signed by makers. | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:5213](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L5213)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`orders`: `Array`, `takerAssetFillAmount`: `BigNumber`, `signatures`: string[], `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4924](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4924)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`orders` | `Array` | - | Array of order specifications. | +`takerAssetFillAmount` | `BigNumber` | - | Minimum amount of takerAsset to sell. | +`signatures` | string[] | - | Proofs that orders have been signed by makers. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### marketSellOrdersNoThrow + +#### ▪ **marketSellOrdersNoThrow**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:5226](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L5226)* + +Executes multiple calls of fillOrder until total amount of takerAsset is sold by taker. +If any fill reverts, the error is caught and ignored. +NOTE: This function does not enforce that the takerAsset is the same for each order. + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`orders`: `Array`, `takerAssetFillAmount`: `BigNumber`, `signatures`: string[], `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:5300](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L5300)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`orders` | `Array` | - | Array of order specifications. | +`takerAssetFillAmount` | `BigNumber` | - | Desired amount of takerAsset to sell. | +`signatures` | string[] | - | Proofs that orders have been signed by makers. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`orders`: `Array`, `takerAssetFillAmount`: `BigNumber`, `signatures`: string[], `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:5406](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L5406)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`orders` | `Array` | - | Array of order specifications. | +`takerAssetFillAmount` | `BigNumber` | - | Desired amount of takerAsset to sell. | +`signatures` | string[] | - | Proofs that orders have been signed by makers. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +Amounts filled and fees paid by makers and taker. + +#### estimateGasAsync + +▸ **estimateGasAsync**(`orders`: `Array`, `takerAssetFillAmount`: `BigNumber`, `signatures`: string[], `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:5353](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L5353)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`orders` | `Array` | Array of order specifications. | +`takerAssetFillAmount` | `BigNumber` | Desired amount of takerAsset to sell. | +`signatures` | string[] | Proofs that orders have been signed by makers. | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`orders`: `Array`, `takerAssetFillAmount`: `BigNumber`, `signatures`: string[]): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:5492](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L5492)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`orders` | `Array` | Array of order specifications. | +`takerAssetFillAmount` | `BigNumber` | Desired amount of takerAsset to sell. | +`signatures` | string[] | Proofs that orders have been signed by makers. | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:5525](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L5525)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`orders`: `Array`, `takerAssetFillAmount`: `BigNumber`, `signatures`: string[], `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:5236](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L5236)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`orders` | `Array` | - | Array of order specifications. | +`takerAssetFillAmount` | `BigNumber` | - | Desired amount of takerAsset to sell. | +`signatures` | string[] | - | Proofs that orders have been signed by makers. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### matchOrders + +#### ▪ **matchOrders**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:5539](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L5539)* + +Match two complementary orders that have a profitable spread. +Each order is filled at their respective price point. However, the calculations are +carried out as though the orders are both being filled at the right order's price point. +The profit made by the left order goes to the taker (who matched the two orders). + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`leftOrder`: object, `rightOrder`: object, `leftSignature`: string, `rightSignature`: string, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:5631](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L5631)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`leftOrder` | object | - | First order to match. | +`rightOrder` | object | - | Second order to match. | +`leftSignature` | string | - | Proof that order was created by the left maker. | +`rightSignature` | string | - | Proof that order was created by the right maker. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`leftOrder`: object, `rightOrder`: object, `leftSignature`: string, `rightSignature`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:5770](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L5770)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`leftOrder` | object | - | First order to match. | +`rightOrder` | object | - | Second order to match. | +`leftSignature` | string | - | Proof that order was created by the left maker. | +`rightSignature` | string | - | Proof that order was created by the right maker. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +matchedFillResults Amounts filled and fees paid by maker and taker of matched orders. + +#### estimateGasAsync + +▸ **estimateGasAsync**(`leftOrder`: object, `rightOrder`: object, `leftSignature`: string, `rightSignature`: string, `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:5701](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L5701)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`leftOrder` | object | First order to match. | +`rightOrder` | object | Second order to match. | +`leftSignature` | string | Proof that order was created by the left maker. | +`rightSignature` | string | Proof that order was created by the right maker. | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`leftOrder`: object, `rightOrder`: object, `leftSignature`: string, `rightSignature`: string): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:5894](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L5894)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`leftOrder` | object | First order to match. | +`rightOrder` | object | Second order to match. | +`leftSignature` | string | Proof that order was created by the left maker. | +`rightSignature` | string | Proof that order was created by the right maker. | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:5942](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L5942)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`leftOrder`: object, `rightOrder`: object, `leftSignature`: string, `rightSignature`: string, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:5550](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L5550)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`leftOrder` | object | - | First order to match. | +`rightOrder` | object | - | Second order to match. | +`leftSignature` | string | - | Proof that order was created by the left maker. | +`rightSignature` | string | - | Proof that order was created by the right maker. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### matchOrdersWithMaximalFill + +#### ▪ **matchOrdersWithMaximalFill**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:5956](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L5956)* + +Match two complementary orders that have a profitable spread. +Each order is maximally filled at their respective price point, and +the matcher receives a profit denominated in either the left maker asset, +right maker asset, or a combination of both. + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`leftOrder`: object, `rightOrder`: object, `leftSignature`: string, `rightSignature`: string, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6048](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6048)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`leftOrder` | object | - | First order to match. | +`rightOrder` | object | - | Second order to match. | +`leftSignature` | string | - | Proof that order was created by the left maker. | +`rightSignature` | string | - | Proof that order was created by the right maker. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`leftOrder`: object, `rightOrder`: object, `leftSignature`: string, `rightSignature`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6187](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6187)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`leftOrder` | object | - | First order to match. | +`rightOrder` | object | - | Second order to match. | +`leftSignature` | string | - | Proof that order was created by the left maker. | +`rightSignature` | string | - | Proof that order was created by the right maker. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +matchedFillResults Amounts filled by maker and taker of matched orders. + +#### estimateGasAsync + +▸ **estimateGasAsync**(`leftOrder`: object, `rightOrder`: object, `leftSignature`: string, `rightSignature`: string, `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6118](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6118)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`leftOrder` | object | First order to match. | +`rightOrder` | object | Second order to match. | +`leftSignature` | string | Proof that order was created by the left maker. | +`rightSignature` | string | Proof that order was created by the right maker. | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`leftOrder`: object, `rightOrder`: object, `leftSignature`: string, `rightSignature`: string): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6311](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6311)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`leftOrder` | object | First order to match. | +`rightOrder` | object | Second order to match. | +`leftSignature` | string | Proof that order was created by the left maker. | +`rightSignature` | string | Proof that order was created by the right maker. | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6359](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6359)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`leftOrder`: object, `rightOrder`: object, `leftSignature`: string, `rightSignature`: string, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:5967](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L5967)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`leftOrder` | object | - | First order to match. | +`rightOrder` | object | - | Second order to match. | +`leftSignature` | string | - | Proof that order was created by the left maker. | +`rightSignature` | string | - | Proof that order was created by the right maker. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### orderEpoch + +#### ▪ **orderEpoch**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6367](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6367)* + +#### callAsync + +▸ **callAsync**(`index_0`: string, `index_1`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6373](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6373)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`index_0` | string | - | +`index_1` | string | - | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +___ + +### owner + +#### ▪ **owner**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6420](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6420)* + +#### callAsync + +▸ **callAsync**(`callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6426](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6426)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +___ + +### preSign + +#### ▪ **preSign**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6467](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6467)* + +Approves a hash on-chain. +After presigning a hash, the preSign signature type will become valid for that hash and signer. + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`hash`: string, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6510](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6510)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`hash` | string | - | Any 32-byte hash. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`hash`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6561](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6561)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`hash` | string | - | Any 32-byte hash. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +#### estimateGasAsync + +▸ **estimateGasAsync**(`hash`: string, `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6536](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6536)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`hash` | string | Any 32-byte hash. | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`hash`: string): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6605](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6605)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`hash` | string | Any 32-byte hash. | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6614](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6614)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`hash`: string, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6475](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6475)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`hash` | string | - | Any 32-byte hash. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### preSigned + +#### ▪ **preSigned**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6620](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6620)* + +#### callAsync + +▸ **callAsync**(`index_0`: string, `index_1`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6626](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6626)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`index_0` | string | - | +`index_1` | string | - | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +___ + +### protocolFeeCollector + +#### ▪ **protocolFeeCollector**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6673](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6673)* + +#### callAsync + +▸ **callAsync**(`callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6679](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6679)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +___ + +### protocolFeeMultiplier + +#### ▪ **protocolFeeMultiplier**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6716](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6716)* + +#### callAsync + +▸ **callAsync**(`callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6722](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6722)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +___ + +### registerAssetProxy + +#### ▪ **registerAssetProxy**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6763](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6763)* + +Registers an asset proxy to its asset proxy id. +Once an asset proxy is registered, it cannot be unregistered. + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`assetProxy`: string, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6806](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6806)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`assetProxy` | string | - | Address of new asset proxy to register. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`assetProxy`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6857](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6857)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`assetProxy` | string | - | Address of new asset proxy to register. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +#### estimateGasAsync + +▸ **estimateGasAsync**(`assetProxy`: string, `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6832](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6832)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`assetProxy` | string | Address of new asset proxy to register. | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`assetProxy`: string): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6905](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6905)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`assetProxy` | string | Address of new asset proxy to register. | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6916](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6916)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`assetProxy`: string, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6771](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6771)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`assetProxy` | string | - | Address of new asset proxy to register. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### setProtocolFeeCollectorAddress + +#### ▪ **setProtocolFeeCollectorAddress**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6925](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6925)* + +Allows the owner to update the protocolFeeCollector address. + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`updatedProtocolFeeCollector`: string, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6972](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6972)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`updatedProtocolFeeCollector` | string | - | The updated protocolFeeCollector contract address. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`updatedProtocolFeeCollector`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7034](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7034)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`updatedProtocolFeeCollector` | string | - | The updated protocolFeeCollector contract address. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +#### estimateGasAsync + +▸ **estimateGasAsync**(`updatedProtocolFeeCollector`: string, `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7003](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7003)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`updatedProtocolFeeCollector` | string | The updated protocolFeeCollector contract address. | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`updatedProtocolFeeCollector`: string): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7085](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7085)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`updatedProtocolFeeCollector` | string | The updated protocolFeeCollector contract address. | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7096](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7096)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`updatedProtocolFeeCollector`: string, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6934](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6934)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`updatedProtocolFeeCollector` | string | - | The updated protocolFeeCollector contract address. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### setProtocolFeeMultiplier + +#### ▪ **setProtocolFeeMultiplier**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7105](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7105)* + +Allows the owner to update the protocol fee multiplier. + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`updatedProtocolFeeMultiplier`: `BigNumber`, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7150](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7150)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`updatedProtocolFeeMultiplier` | `BigNumber` | - | The updated protocol fee multiplier. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`updatedProtocolFeeMultiplier`: `BigNumber`, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7210](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7210)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`updatedProtocolFeeMultiplier` | `BigNumber` | - | The updated protocol fee multiplier. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +#### estimateGasAsync + +▸ **estimateGasAsync**(`updatedProtocolFeeMultiplier`: `BigNumber`, `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7180](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7180)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`updatedProtocolFeeMultiplier` | `BigNumber` | The updated protocol fee multiplier. | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`updatedProtocolFeeMultiplier`: `BigNumber`): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7260](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7260)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`updatedProtocolFeeMultiplier` | `BigNumber` | The updated protocol fee multiplier. | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7271](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7271)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`updatedProtocolFeeMultiplier`: `BigNumber`, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7113](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7113)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`updatedProtocolFeeMultiplier` | `BigNumber` | - | The updated protocol fee multiplier. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### setSignatureValidatorApproval + +#### ▪ **setSignatureValidatorApproval**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7281](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7281)* + +Approves/unnapproves a Validator contract to verify signatures on signer's behalf +using the `Validator` signature type. + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`validatorAddress`: string, `approval`: boolean, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7331](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7331)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`validatorAddress` | string | - | Address of Validator contract. | +`approval` | boolean | - | Approval or disapproval of Validator contract. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`validatorAddress`: string, `approval`: boolean, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7399](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7399)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`validatorAddress` | string | - | Address of Validator contract. | +`approval` | boolean | - | Approval or disapproval of Validator contract. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +#### estimateGasAsync + +▸ **estimateGasAsync**(`validatorAddress`: string, `approval`: boolean, `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7365](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7365)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`validatorAddress` | string | Address of Validator contract. | +`approval` | boolean | Approval or disapproval of Validator contract. | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`validatorAddress`: string, `approval`: boolean): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7453](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7453)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`validatorAddress` | string | Address of Validator contract. | +`approval` | boolean | Approval or disapproval of Validator contract. | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7466](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7466)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`validatorAddress`: string, `approval`: boolean, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7290](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7290)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`validatorAddress` | string | - | Address of Validator contract. | +`approval` | boolean | - | Approval or disapproval of Validator contract. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### simulateDispatchTransferFromCalls + +#### ▪ **simulateDispatchTransferFromCalls**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7475](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7475)* + +This function may be used to simulate any amount of transfers As they would occur through the Exchange contract. Note that this function will always revert, even if all transfers are successful. However, it may be used with eth_call or with a try/catch pattern in order to simulate the results of the transfers. + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`assetData`: string[], `fromAddresses`: string[], `toAddresses`: string[], `amounts`: `BigNumber`[], `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7547](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7547)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`assetData` | string[] | - | Array of asset details, each encoded per the AssetProxy contract specification. | +`fromAddresses` | string[] | - | Array containing the `from` addresses that correspond with each transfer. | +`toAddresses` | string[] | - | Array containing the `to` addresses that correspond with each transfer. | +`amounts` | `BigNumber`[] | - | Array containing the amounts that correspond to each transfer. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`assetData`: string[], `fromAddresses`: string[], `toAddresses`: string[], `amounts`: `BigNumber`[], `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7638](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7638)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`assetData` | string[] | - | Array of asset details, each encoded per the AssetProxy contract specification. | +`fromAddresses` | string[] | - | Array containing the `from` addresses that correspond with each transfer. | +`toAddresses` | string[] | - | Array containing the `to` addresses that correspond with each transfer. | +`amounts` | `BigNumber`[] | - | Array containing the amounts that correspond to each transfer. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +This function does not return a value. However, it will always revert with `Error("TRANSFERS_SUCCESSFUL")` if all of the transfers were successful. + +#### estimateGasAsync + +▸ **estimateGasAsync**(`assetData`: string[], `fromAddresses`: string[], `toAddresses`: string[], `amounts`: `BigNumber`[], `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7593](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7593)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`assetData` | string[] | Array of asset details, each encoded per the AssetProxy contract specification. | +`fromAddresses` | string[] | Array containing the `from` addresses that correspond with each transfer. | +`toAddresses` | string[] | Array containing the `to` addresses that correspond with each transfer. | +`amounts` | `BigNumber`[] | Array containing the amounts that correspond to each transfer. | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`assetData`: string[], `fromAddresses`: string[], `toAddresses`: string[], `amounts`: `BigNumber`[]): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7704](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7704)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`assetData` | string[] | Array of asset details, each encoded per the AssetProxy contract specification. | +`fromAddresses` | string[] | Array containing the `from` addresses that correspond with each transfer. | +`toAddresses` | string[] | Array containing the `to` addresses that correspond with each transfer. | +`amounts` | `BigNumber`[] | Array containing the amounts that correspond to each transfer. | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7724](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7724)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`assetData`: string[], `fromAddresses`: string[], `toAddresses`: string[], `amounts`: `BigNumber`[], `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7490](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7490)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`assetData` | string[] | - | Array of asset details, each encoded per the AssetProxy contract specification. | +`fromAddresses` | string[] | - | Array containing the `from` addresses that correspond with each transfer. | +`toAddresses` | string[] | - | Array containing the `to` addresses that correspond with each transfer. | +`amounts` | `BigNumber`[] | - | Array containing the amounts that correspond to each transfer. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### transactionsExecuted + +#### ▪ **transactionsExecuted**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7732](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7732)* + +#### callAsync + +▸ **callAsync**(`index_0`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7738](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7738)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`index_0` | string | - | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +___ + +### transferOwnership + +#### ▪ **transferOwnership**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7780](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7780)* + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`newOwner`: string, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7821](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7821)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`newOwner` | string | - | - | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`newOwner`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7870](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7870)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`newOwner` | string | - | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +#### estimateGasAsync + +▸ **estimateGasAsync**(`newOwner`: string, `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7846](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7846)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`newOwner` | string | - | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`newOwner`: string): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7913](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7913)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | +------ | ------ | +`newOwner` | string | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7924](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7924)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`newOwner`: string, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7787](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7787)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`newOwner` | string | - | - | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +
+ +# Class: IValidatorContract + + +## Constructors + + + +\+ **new IValidatorContract**(`address`: string, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults?`: `Partial`, `logDecodeDependencies?`: undefined | object, `deployedBytecode`: string | undefined): *[IValidatorContract](#class-ivalidatorcontract)* + +*Overrides void* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/i_validator.ts:202](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/i_validator.ts#L202)* + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`address` | string | - | +`supportedProvider` | [SupportedProvider](#supportedprovider) | - | +`txDefaults?` | `Partial` | - | +`logDecodeDependencies?` | undefined \| object | - | +`deployedBytecode` | string \| undefined | IValidatorContract.deployedBytecode | + +**Returns:** *[IValidatorContract](#class-ivalidatorcontract)* + +## Properties + +#### `Optional` _deployedBytecodeIfExists + +• **_deployedBytecodeIfExists**? : *`Buffer`* + + + +Defined in base-contract/lib/src/index.d.ts:31 + +___ + +### abi + +• **abi**: *[ContractAbi](#contractabi)* + + + +Defined in base-contract/lib/src/index.d.ts:27 + +___ + +### address + +• **address**: *string* + + + +Defined in base-contract/lib/src/index.d.ts:28 + +___ + +Args + +• **constructorArgs**: *any[]* + + + +Defined in base-contract/lib/src/index.d.ts:30 + +___ + +### contractName + +• **contractName**: *string* + + + +Defined in base-contract/lib/src/index.d.ts:29 + +## Methods + +### `Static` ABI + +▸ **ABI**(): *[ContractAbi](#contractabi)* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/i_validator.ts:171](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/i_validator.ts#L171)* + +**Returns:** *[ContractAbi](#contractabi)* + +The contract ABI + +___ + +### `Static` deployAsync + +▸ **deployAsync**(`bytecode`: string, `abi`: [ContractAbi](#contractabi), `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/i_validator.ts:129](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/i_validator.ts#L129)* + +**Parameters:** + +Name | Type | +------ | ------ | +`bytecode` | string | +`abi` | [ContractAbi](#contractabi) | +`supportedProvider` | [SupportedProvider](#supportedprovider) | +`txDefaults` | `Partial` | +`logDecodeDependencies` | object | + +**Returns:** *`Promise`* + +___ + +### `Static` deployFrom0xArtifactAsync + +▸ **deployFrom0xArtifactAsync**(`artifact`: `ContractArtifact` | `SimpleContractArtifact`, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/i_validator.ts:104](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/i_validator.ts#L104)* + +**Parameters:** + +Name | Type | +------ | ------ | +`artifact` | `ContractArtifact` \| `SimpleContractArtifact` | +`supportedProvider` | [SupportedProvider](#supportedprovider) | +`txDefaults` | `Partial` | +`logDecodeDependencies` | object | + +**Returns:** *`Promise`* + +___ + +### `Static` strictArgumentEncodingCheck + +▸ **strictArgumentEncodingCheck**(`inputAbi`: `DataItem`[], `args`: any[]): *string* + + + +Defined in base-contract/lib/src/index.d.ts:41 + +**Parameters:** + +Name | Type | +------ | ------ | +`inputAbi` | `DataItem`[] | +`args` | any[] | + +**Returns:** *string* + +## Object literals + +### isValidSignature + +#### ▪ **isValidSignature**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/i_validator.ts:44](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/i_validator.ts#L44)* + +Verifies that a signature is valid. + +#### callAsync + +▸ **callAsync**(`hash`: string, `signerAddress`: string, `signature`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/i_validator.ts:54](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/i_validator.ts#L54)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`hash` | string | - | Message hash that is signed. | +`signerAddress` | string | - | Address that should have signed the given hash. | +`signature` | string | - | Proof of signing. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +Magic bytes4 value if the signature is valid. Magic value is bytes4(keccak256("isValidValidatorSignature(address,bytes32,address,bytes)")) + +
+ +# Class: IWalletContract + + +## Constructors + + + +\+ **new IWalletContract**(`address`: string, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults?`: `Partial`, `logDecodeDependencies?`: undefined | object, `deployedBytecode`: string | undefined): *[IWalletContract](#class-iwalletcontract)* + +*Overrides void* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/i_wallet.ts:191](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/i_wallet.ts#L191)* + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`address` | string | - | +`supportedProvider` | [SupportedProvider](#supportedprovider) | - | +`txDefaults?` | `Partial` | - | +`logDecodeDependencies?` | undefined \| object | - | +`deployedBytecode` | string \| undefined | IWalletContract.deployedBytecode | + +**Returns:** *[IWalletContract](#class-iwalletcontract)* + +## Properties + +#### `Optional` _deployedBytecodeIfExists + +• **_deployedBytecodeIfExists**? : *`Buffer`* + + + +Defined in base-contract/lib/src/index.d.ts:31 + +___ + +### abi + +• **abi**: *[ContractAbi](#contractabi)* + + + +Defined in base-contract/lib/src/index.d.ts:27 + +___ + +### address + +• **address**: *string* + + + +Defined in base-contract/lib/src/index.d.ts:28 + +___ + +Args + +• **constructorArgs**: *any[]* + + + +Defined in base-contract/lib/src/index.d.ts:30 + +___ + +### contractName + +• **contractName**: *string* + + + +Defined in base-contract/lib/src/index.d.ts:29 + +## Methods + +### `Static` ABI + +▸ **ABI**(): *[ContractAbi](#contractabi)* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/i_wallet.ts:164](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/i_wallet.ts#L164)* + +**Returns:** *[ContractAbi](#contractabi)* + +The contract ABI + +___ + +### `Static` deployAsync + +▸ **deployAsync**(`bytecode`: string, `abi`: [ContractAbi](#contractabi), `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/i_wallet.ts:122](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/i_wallet.ts#L122)* + +**Parameters:** + +Name | Type | +------ | ------ | +`bytecode` | string | +`abi` | [ContractAbi](#contractabi) | +`supportedProvider` | [SupportedProvider](#supportedprovider) | +`txDefaults` | `Partial` | +`logDecodeDependencies` | object | + +**Returns:** *`Promise`* + +___ + +### `Static` deployFrom0xArtifactAsync + +▸ **deployFrom0xArtifactAsync**(`artifact`: `ContractArtifact` | `SimpleContractArtifact`, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/i_wallet.ts:97](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/i_wallet.ts#L97)* + +**Parameters:** + +Name | Type | +------ | ------ | +`artifact` | `ContractArtifact` \| `SimpleContractArtifact` | +`supportedProvider` | [SupportedProvider](#supportedprovider) | +`txDefaults` | `Partial` | +`logDecodeDependencies` | object | + +**Returns:** *`Promise`* + +___ + +### `Static` strictArgumentEncodingCheck + +▸ **strictArgumentEncodingCheck**(`inputAbi`: `DataItem`[], `args`: any[]): *string* + + + +Defined in base-contract/lib/src/index.d.ts:41 + +**Parameters:** + +Name | Type | +------ | ------ | +`inputAbi` | `DataItem`[] | +`args` | any[] | + +**Returns:** *string* + +## Object literals + +### isValidSignature + +#### ▪ **isValidSignature**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/i_wallet.ts:44](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/i_wallet.ts#L44)* + +Validates a hash with the `Wallet` signature type. + +#### callAsync + +▸ **callAsync**(`hash`: string, `signature`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/i_wallet.ts:53](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/i_wallet.ts#L53)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`hash` | string | - | Message hash that is signed. | +`signature` | string | - | Proof of signing. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +magicValue `bytes4(0xb0671381)` if the signature check succeeds. + +
+ +# Class: WETH9Contract + + +## Constructors + + + +\+ **new WETH9Contract**(`address`: string, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults?`: `Partial`, `logDecodeDependencies?`: undefined | object, `deployedBytecode`: string | undefined): *[WETH9Contract](#class-weth9contract)* + +*Overrides void* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:1583](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L1583)* + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`address` | string | - | +`supportedProvider` | [SupportedProvider](#supportedprovider) | - | +`txDefaults?` | `Partial` | - | +`logDecodeDependencies?` | undefined \| object | - | +`deployedBytecode` | string \| undefined | WETH9Contract.deployedBytecode | + +**Returns:** *[WETH9Contract](#class-weth9contract)* + +## Properties + +#### `Optional` _deployedBytecodeIfExists + +• **_deployedBytecodeIfExists**? : *`Buffer`* + + + +Defined in base-contract/lib/src/index.d.ts:31 + +___ + +### abi + +• **abi**: *[ContractAbi](#contractabi)* + + + +Defined in base-contract/lib/src/index.d.ts:27 + +___ + +### address + +• **address**: *string* + + + +Defined in base-contract/lib/src/index.d.ts:28 + +___ + +Args + +• **constructorArgs**: *any[]* + + + +Defined in base-contract/lib/src/index.d.ts:30 + +___ + +### contractName + +• **contractName**: *string* + + + +Defined in base-contract/lib/src/index.d.ts:29 + +## Methods + +### getLogsAsync + +▸ **getLogsAsync**<**ArgsType**>(`eventName`: [WETH9Events](#enumeration-weth9events), `blockRange`: `BlockRange`, `indexFilterValues`: `IndexedFilterValues`): *`Promise>>`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:1567](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L1567)* + +Gets historical logs without creating a subscription + +**Type parameters:** + +▪ **ArgsType**: *[WETH9EventArgs](#weth9eventargs)* + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`eventName` | [WETH9Events](#enumeration-weth9events) | The WETH9 contract event you would like to subscribe to. | +`blockRange` | `BlockRange` | Block range to get logs from. | +`indexFilterValues` | `IndexedFilterValues` | An object where the keys are indexed args returned by the event and the value is the value you are interested in. E.g `{_from: aUserAddressHex}` | + +**Returns:** *`Promise>>`* + +Array of logs that match the parameters + +___ + +### subscribe + +▸ **subscribe**<**ArgsType**>(`eventName`: [WETH9Events](#enumeration-weth9events), `indexFilterValues`: `IndexedFilterValues`, `callback`: [EventCallback](#eventcallback)‹*`ArgsType`*›, `isVerbose`: boolean, `blockPollingIntervalMs?`: undefined | number): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:1525](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L1525)* + +Subscribe to an event type emitted by the WETH9 contract. + +**Type parameters:** + +▪ **ArgsType**: *[WETH9EventArgs](#weth9eventargs)* + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`eventName` | [WETH9Events](#enumeration-weth9events) | - | The WETH9 contract event you would like to subscribe to. | +`indexFilterValues` | `IndexedFilterValues` | - | An object where the keys are indexed args returned by the event and the value is the value you are interested in. E.g `{maker: aUserAddressHex}` | +`callback` | [EventCallback](#eventcallback)‹*`ArgsType`*› | - | Callback that gets called when a log is added/removed | +`isVerbose` | boolean | false | Enable verbose subscription warnings (e.g recoverable network issues encountered) | +`blockPollingIntervalMs?` | undefined \| number | - | - | + +**Returns:** *string* + +Subscription token used later to unsubscribe + +___ + +### unsubscribe + +▸ **unsubscribe**(`subscriptionToken`: string): *void* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:1550](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L1550)* + +Cancel a subscription + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`subscriptionToken` | string | Subscription token returned by `subscribe()` | + +**Returns:** *void* + +___ + +### unsubscribeAll + +▸ **unsubscribeAll**(): *void* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:1556](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L1556)* + +Cancels all existing subscriptions + +**Returns:** *void* + +___ + +### `Static` ABI + +▸ **ABI**(): *[ContractAbi](#contractabi)* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:1228](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L1228)* + +**Returns:** *[ContractAbi](#contractabi)* + +The contract ABI + +___ + +### `Static` deployAsync + +▸ **deployAsync**(`bytecode`: string, `abi`: [ContractAbi](#contractabi), `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:1186](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L1186)* + +**Parameters:** + +Name | Type | +------ | ------ | +`bytecode` | string | +`abi` | [ContractAbi](#contractabi) | +`supportedProvider` | [SupportedProvider](#supportedprovider) | +`txDefaults` | `Partial` | +`logDecodeDependencies` | object | + +**Returns:** *`Promise`* + +___ + +### `Static` deployFrom0xArtifactAsync + +▸ **deployFrom0xArtifactAsync**(`artifact`: `ContractArtifact` | `SimpleContractArtifact`, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:1161](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L1161)* + +**Parameters:** + +Name | Type | +------ | ------ | +`artifact` | `ContractArtifact` \| `SimpleContractArtifact` | +`supportedProvider` | [SupportedProvider](#supportedprovider) | +`txDefaults` | `Partial` | +`logDecodeDependencies` | object | + +**Returns:** *`Promise`* + +___ + +### `Static` strictArgumentEncodingCheck + +▸ **strictArgumentEncodingCheck**(`inputAbi`: `DataItem`[], `args`: any[]): *string* + + + +Defined in base-contract/lib/src/index.d.ts:41 + +**Parameters:** + +Name | Type | +------ | ------ | +`inputAbi` | `DataItem`[] | +`args` | any[] | + +**Returns:** *string* + +## Object literals + +### allowance + +#### ▪ **allowance**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:1107](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L1107)* + +#### callAsync + +▸ **callAsync**(`index_0`: string, `index_1`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:1113](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L1113)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`index_0` | string | - | +`index_1` | string | - | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +___ + +### approve + +#### ▪ **approve**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:120](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L120)* + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`guy`: string, `wad`: `BigNumber`, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:163](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L163)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`guy` | string | - | - | +`wad` | `BigNumber` | - | - | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`guy`: string, `wad`: `BigNumber`, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:215](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L215)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`guy` | string | - | +`wad` | `BigNumber` | - | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +#### estimateGasAsync + +▸ **estimateGasAsync**(`guy`: string, `wad`: `BigNumber`, `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:190](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L190)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`guy` | string | - | +`wad` | `BigNumber` | - | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`guy`: string, `wad`: `BigNumber`): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:264](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L264)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | +------ | ------ | +`guy` | string | +`wad` | `BigNumber` | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:277](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L277)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`guy`: string, `wad`: `BigNumber`, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:127](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L127)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`guy` | string | - | - | +`wad` | `BigNumber` | - | - | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### balanceOf + +#### ▪ **balanceOf**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:712](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L712)* + +#### callAsync + +▸ **callAsync**(`index_0`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:718](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L718)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`index_0` | string | - | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +___ + +### decimals + +#### ▪ **decimals**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:669](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L669)* + +#### callAsync + +▸ **callAsync**(`callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:675](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L675)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +___ + +### deposit + +#### ▪ **deposit**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:966](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L966)* + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:1005](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L1005)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:1051](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L1051)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +#### estimateGasAsync + +▸ **estimateGasAsync**(`txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:1028](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L1028)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:1093](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L1093)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:1101](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L1101)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:973](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L973)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### name + +#### ▪ **name**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:77](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L77)* + +#### callAsync + +▸ **callAsync**(`callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:83](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L83)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +___ + +### symbol + +#### ▪ **symbol**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:760](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L760)* + +#### callAsync + +▸ **callAsync**(`callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:766](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L766)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +___ + +### totalSupply + +#### ▪ **totalSupply**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:283](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L283)* + +#### callAsync + +▸ **callAsync**(`callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:289](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L289)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +___ + +### transfer + +#### ▪ **transfer**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:803](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L803)* + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`dst`: string, `wad`: `BigNumber`, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:846](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L846)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`dst` | string | - | - | +`wad` | `BigNumber` | - | - | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`dst`: string, `wad`: `BigNumber`, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:898](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L898)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`dst` | string | - | +`wad` | `BigNumber` | - | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +#### estimateGasAsync + +▸ **estimateGasAsync**(`dst`: string, `wad`: `BigNumber`, `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:873](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L873)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`dst` | string | - | +`wad` | `BigNumber` | - | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`dst`: string, `wad`: `BigNumber`): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:947](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L947)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | +------ | ------ | +`dst` | string | +`wad` | `BigNumber` | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:960](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L960)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`dst`: string, `wad`: `BigNumber`, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:810](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L810)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`dst` | string | - | - | +`wad` | `BigNumber` | - | - | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### transferFrom + +#### ▪ **transferFrom**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:326](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L326)* + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`src`: string, `dst`: string, `wad`: `BigNumber`, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:375](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L375)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`src` | string | - | - | +`dst` | string | - | - | +`wad` | `BigNumber` | - | - | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`src`: string, `dst`: string, `wad`: `BigNumber`, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:445](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L445)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`src` | string | - | +`dst` | string | - | +`wad` | `BigNumber` | - | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +#### estimateGasAsync + +▸ **estimateGasAsync**(`src`: string, `dst`: string, `wad`: `BigNumber`, `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:410](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L410)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`src` | string | - | +`dst` | string | - | +`wad` | `BigNumber` | - | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`src`: string, `dst`: string, `wad`: `BigNumber`): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:500](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L500)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | +------ | ------ | +`src` | string | +`dst` | string | +`wad` | `BigNumber` | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:515](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L515)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`src`: string, `dst`: string, `wad`: `BigNumber`, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:333](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L333)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`src` | string | - | - | +`dst` | string | - | - | +`wad` | `BigNumber` | - | - | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### withdraw + +#### ▪ **withdraw**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:521](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L521)* + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`wad`: `BigNumber`, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:562](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L562)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`wad` | `BigNumber` | - | - | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`wad`: `BigNumber`, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:611](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L611)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`wad` | `BigNumber` | - | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +#### estimateGasAsync + +▸ **estimateGasAsync**(`wad`: `BigNumber`, `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:587](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L587)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`wad` | `BigNumber` | - | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`wad`: `BigNumber`): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:654](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L654)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | +------ | ------ | +`wad` | `BigNumber` | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:663](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L663)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`wad`: `BigNumber`, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:528](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L528)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`wad` | `BigNumber` | - | - | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +
+ +# Class: ZRXTokenContract + + +## Constructors + + + +\+ **new ZRXTokenContract**(`address`: string, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults?`: `Partial`, `logDecodeDependencies?`: undefined | object, `deployedBytecode`: string | undefined): *[ZRXTokenContract](#class-zrxtokencontract)* + +*Overrides void* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:1241](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L1241)* + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`address` | string | - | +`supportedProvider` | [SupportedProvider](#supportedprovider) | - | +`txDefaults?` | `Partial` | - | +`logDecodeDependencies?` | undefined \| object | - | +`deployedBytecode` | string \| undefined | ZRXTokenContract.deployedBytecode | + +**Returns:** *[ZRXTokenContract](#class-zrxtokencontract)* + +## Properties + +#### `Optional` _deployedBytecodeIfExists + +• **_deployedBytecodeIfExists**? : *`Buffer`* + + + +Defined in base-contract/lib/src/index.d.ts:31 + +___ + +### abi + +• **abi**: *[ContractAbi](#contractabi)* + + + +Defined in base-contract/lib/src/index.d.ts:27 + +___ + +### address + +• **address**: *string* + + + +Defined in base-contract/lib/src/index.d.ts:28 + +___ + +Args + +• **constructorArgs**: *any[]* + + + +Defined in base-contract/lib/src/index.d.ts:30 + +___ + +### contractName + +• **contractName**: *string* + + + +Defined in base-contract/lib/src/index.d.ts:29 + +## Methods + +### getLogsAsync + +▸ **getLogsAsync**<**ArgsType**>(`eventName`: [ZRXTokenEvents](#enumeration-zrxtokenevents), `blockRange`: `BlockRange`, `indexFilterValues`: `IndexedFilterValues`): *`Promise>>`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:1225](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L1225)* + +Gets historical logs without creating a subscription + +**Type parameters:** + +▪ **ArgsType**: *[ZRXTokenEventArgs](#zrxtokeneventargs)* + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`eventName` | [ZRXTokenEvents](#enumeration-zrxtokenevents) | The ZRXToken contract event you would like to subscribe to. | +`blockRange` | `BlockRange` | Block range to get logs from. | +`indexFilterValues` | `IndexedFilterValues` | An object where the keys are indexed args returned by the event and the value is the value you are interested in. E.g `{_from: aUserAddressHex}` | + +**Returns:** *`Promise>>`* + +Array of logs that match the parameters + +___ + +### subscribe + +▸ **subscribe**<**ArgsType**>(`eventName`: [ZRXTokenEvents](#enumeration-zrxtokenevents), `indexFilterValues`: `IndexedFilterValues`, `callback`: [EventCallback](#eventcallback)‹*`ArgsType`*›, `isVerbose`: boolean, `blockPollingIntervalMs?`: undefined | number): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:1183](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L1183)* + +Subscribe to an event type emitted by the ZRXToken contract. + +**Type parameters:** + +▪ **ArgsType**: *[ZRXTokenEventArgs](#zrxtokeneventargs)* + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`eventName` | [ZRXTokenEvents](#enumeration-zrxtokenevents) | - | The ZRXToken contract event you would like to subscribe to. | +`indexFilterValues` | `IndexedFilterValues` | - | An object where the keys are indexed args returned by the event and the value is the value you are interested in. E.g `{maker: aUserAddressHex}` | +`callback` | [EventCallback](#eventcallback)‹*`ArgsType`*› | - | Callback that gets called when a log is added/removed | +`isVerbose` | boolean | false | Enable verbose subscription warnings (e.g recoverable network issues encountered) | +`blockPollingIntervalMs?` | undefined \| number | - | - | + +**Returns:** *string* + +Subscription token used later to unsubscribe + +___ + +### unsubscribe + +▸ **unsubscribe**(`subscriptionToken`: string): *void* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:1208](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L1208)* + +Cancel a subscription + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`subscriptionToken` | string | Subscription token returned by `subscribe()` | + +**Returns:** *void* + +___ + +### unsubscribeAll + +▸ **unsubscribeAll**(): *void* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:1214](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L1214)* + +Cancels all existing subscriptions + +**Returns:** *void* + +___ + +### `Static` ABI + +▸ **ABI**(): *[ContractAbi](#contractabi)* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:955](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L955)* + +**Returns:** *[ContractAbi](#contractabi)* + +The contract ABI + +___ + +### `Static` deployAsync + +▸ **deployAsync**(`bytecode`: string, `abi`: [ContractAbi](#contractabi), `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:913](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L913)* + +**Parameters:** + +Name | Type | +------ | ------ | +`bytecode` | string | +`abi` | [ContractAbi](#contractabi) | +`supportedProvider` | [SupportedProvider](#supportedprovider) | +`txDefaults` | `Partial` | +`logDecodeDependencies` | object | + +**Returns:** *`Promise`* + +___ + +### `Static` deployFrom0xArtifactAsync + +▸ **deployFrom0xArtifactAsync**(`artifact`: `ContractArtifact` | `SimpleContractArtifact`, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:888](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L888)* + +**Parameters:** + +Name | Type | +------ | ------ | +`artifact` | `ContractArtifact` \| `SimpleContractArtifact` | +`supportedProvider` | [SupportedProvider](#supportedprovider) | +`txDefaults` | `Partial` | +`logDecodeDependencies` | object | + +**Returns:** *`Promise`* + +___ + +### `Static` strictArgumentEncodingCheck + +▸ **strictArgumentEncodingCheck**(`inputAbi`: `DataItem`[], `args`: any[]): *string* + + + +Defined in base-contract/lib/src/index.d.ts:41 + +**Parameters:** + +Name | Type | +------ | ------ | +`inputAbi` | `DataItem`[] | +`args` | any[] | + +**Returns:** *string* + +## Object literals + +### allowance + +#### ▪ **allowance**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:834](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L834)* + +#### callAsync + +▸ **callAsync**(`_owner`: string, `_spender`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:840](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L840)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`_owner` | string | - | +`_spender` | string | - | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +___ + +### approve + +#### ▪ **approve**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:104](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L104)* + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`_spender`: string, `_value`: `BigNumber`, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:150](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L150)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_spender` | string | - | - | +`_value` | `BigNumber` | - | - | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`_spender`: string, `_value`: `BigNumber`, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:209](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L209)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`_spender` | string | - | +`_value` | `BigNumber` | - | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +#### estimateGasAsync + +▸ **estimateGasAsync**(`_spender`: string, `_value`: `BigNumber`, `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:177](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L177)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`_spender` | string | - | +`_value` | `BigNumber` | - | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`_spender`: string, `_value`: `BigNumber`): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:261](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L261)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | +------ | ------ | +`_spender` | string | +`_value` | `BigNumber` | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:274](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L274)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`_spender`: string, `_value`: `BigNumber`, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:111](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L111)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_spender` | string | - | - | +`_value` | `BigNumber` | - | - | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### balanceOf + +#### ▪ **balanceOf**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:580](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L580)* + +#### callAsync + +▸ **callAsync**(`_owner`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:586](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L586)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`_owner` | string | - | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +___ + +### decimals + +#### ▪ **decimals**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:537](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L537)* + +#### callAsync + +▸ **callAsync**(`callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:543](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L543)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +___ + +### name + +#### ▪ **name**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:61](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L61)* + +#### callAsync + +▸ **callAsync**(`callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:67](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L67)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +___ + +### symbol + +#### ▪ **symbol**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:628](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L628)* + +#### callAsync + +▸ **callAsync**(`callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:634](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L634)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +___ + +### totalSupply + +#### ▪ **totalSupply**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:280](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L280)* + +#### callAsync + +▸ **callAsync**(`callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:286](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L286)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +___ + +### transfer + +#### ▪ **transfer**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:671](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L671)* + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`_to`: string, `_value`: `BigNumber`, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:714](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L714)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_to` | string | - | - | +`_value` | `BigNumber` | - | - | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`_to`: string, `_value`: `BigNumber`, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:766](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L766)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`_to` | string | - | +`_value` | `BigNumber` | - | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +#### estimateGasAsync + +▸ **estimateGasAsync**(`_to`: string, `_value`: `BigNumber`, `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:741](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L741)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`_to` | string | - | +`_value` | `BigNumber` | - | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`_to`: string, `_value`: `BigNumber`): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:815](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L815)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | +------ | ------ | +`_to` | string | +`_value` | `BigNumber` | + +**Returns:** *string* + +The ABI encoded transaction data as a string -• **makerAssetFilledAmount**: *`BigNumber`* +#### getSelector -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:88](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L88)* +▸ **getSelector**(): *string* -___ +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:828](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L828)* -### makerFeeAssetData +Returns the 4 byte function selector as a hex string. -• **makerFeeAssetData**: *string* +**Returns:** *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:83](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L83)* +#### sendTransactionAsync -___ +▸ **sendTransactionAsync**(`_to`: string, `_value`: `BigNumber`, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* -### makerFeePaid +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:678](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L678)* -• **makerFeePaid**: *`BigNumber`* +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:90](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L90)* +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_to` | string | - | - | +`_value` | `BigNumber` | - | - | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction ___ -### orderHash +### transferFrom -• **orderHash**: *string* +#### ▪ **transferFrom**: *object* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:85](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L85)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:326](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L326)* -___ +ERC20 transferFrom, modified such that an allowance of MAX_UINT represents an unlimited allowance. -### protocolFeePaid +#### awaitTransactionSuccessAsync -• **protocolFeePaid**: *`BigNumber`* +▸ **awaitTransactionSuccessAsync**(`_from`: string, `_to`: string, `_value`: `BigNumber`, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:92](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L92)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:381](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L381)* -___ +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. -### senderAddress +**Parameters:** -• **senderAddress**: *string* +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_from` | string | - | Address to transfer from. | +`_to` | string | - | Address to transfer to. | +`_value` | `BigNumber` | - | Amount to transfer. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:87](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L87)* +**Returns:** *`PromiseWithTransactionHash`* -___ +A promise that resolves when the transaction is successful -### takerAddress +#### callAsync -• **takerAddress**: *string* +▸ **callAsync**(`_from`: string, `_to`: string, `_value`: `BigNumber`, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:86](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L86)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:458](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L458)* -___ +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. -### takerAssetData +**Parameters:** -• **takerAssetData**: *string* +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_from` | string | - | Address to transfer from. | +`_to` | string | - | Address to transfer to. | +`_value` | `BigNumber` | - | Amount to transfer. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:82](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L82)* +**Returns:** *`Promise`* -___ +Success of transfer. -### takerAssetFilledAmount +#### estimateGasAsync -• **takerAssetFilledAmount**: *`BigNumber`* +▸ **estimateGasAsync**(`_from`: string, `_to`: string, `_value`: `BigNumber`, `txData?`: `Partial` | undefined): *`Promise`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:89](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L89)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:419](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L419)* -___ +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. -### takerFeeAssetData +**Parameters:** -• **takerFeeAssetData**: *string* +Name | Type | Description | +------ | ------ | ------ | +`_from` | string | Address to transfer from. | +`_to` | string | Address to transfer to. | +`_value` | `BigNumber` | Amount to transfer. | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:84](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L84)* +The hash of the transaction -___ +#### getABIEncodedTransactionData -### takerFeePaid +▸ **getABIEncodedTransactionData**(`_from`: string, `_to`: string, `_value`: `BigNumber`): *string* -• **takerFeePaid**: *`BigNumber`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:516](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L516)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`_from` | string | Address to transfer from. | +`_to` | string | Address to transfer to. | +`_value` | `BigNumber` | Amount to transfer. | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:531](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L531)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:91](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L91)* +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`_from`: string, `_to`: string, `_value`: `BigNumber`, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:336](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L336)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_from` | string | - | Address to transfer from. | +`_to` | string | - | Address to transfer to. | +`_value` | `BigNumber` | - | Amount to transfer. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction
-# Interface: ExchangeProtocolFeeCollectorAddressEventArgs +# Class: MetamaskSubprovider +This class implements the [web3-provider-engine](https://github.com/MetaMask/provider-engine) +subprovider interface and the provider sendAsync interface. +It handles inconsistencies with Metamask implementations of various JSON RPC methods. +It forwards JSON RPC requests involving the domain of a signer (getAccounts, +sendTransaction, signMessage etc...) to the provider instance supplied at instantiation. All other requests +are passed onwards for subsequent subproviders to handle. -## Index -### Properties +## Constructors -* [oldProtocolFeeCollector](#oldprotocolfeecollector) -* [updatedProtocolFeeCollector](#updatedprotocolfeecollector) -## Properties -### oldProtocolFeeCollector +\+ **new MetamaskSubprovider**(`supportedProvider`: [SupportedProvider](#supportedprovider)): *[MetamaskSubprovider](#class-metamasksubprovider)* + +*Defined in [subproviders/src/subproviders/metamask_subprovider.ts:19](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/metamask_subprovider.ts#L19)* + +Instantiates a new MetamaskSubprovider + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`supportedProvider` | [SupportedProvider](#supportedprovider) | Web3 provider that should handle all user account related requests | + +**Returns:** *[MetamaskSubprovider](#class-metamasksubprovider)* + +## Methods + +#### emitPayloadAsync + +▸ **emitPayloadAsync**(`payload`: `Partial`): *`Promise`* + -• **oldProtocolFeeCollector**: *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:96](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L96)* +*Defined in [subproviders/src/subproviders/subprovider.ts:55](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/subprovider.ts#L55)* + +Emits a JSON RPC payload that will then be handled by the ProviderEngine instance +this subprovider is a part of. The payload will cascade down the subprovider middleware +stack until finding the responsible entity for handling the request. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`payload` | `Partial` | JSON RPC payload | + +**Returns:** *`Promise`* + +JSON RPC response payload ___ -### updatedProtocolFeeCollector +### handleRequest -• **updatedProtocolFeeCollector**: *string* +▸ **handleRequest**(`payload`: `JSONRPCRequestPayload`, `next`: [Callback](#callback), `end`: [ErrorCallback](#errorcallback)): *`Promise`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:97](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L97)* +*Overrides void* -
+*Defined in [subproviders/src/subproviders/metamask_subprovider.ts:39](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/metamask_subprovider.ts#L39)* -# Interface: ExchangeProtocolFeeMultiplierEventArgs +This method conforms to the web3-provider-engine interface. +It is called internally by the ProviderEngine when it is this subproviders +turn to handle a JSON RPC request. +**Parameters:** -## Index +Name | Type | Description | +------ | ------ | ------ | +`payload` | `JSONRPCRequestPayload` | JSON RPC payload | +`next` | [Callback](#callback) | Callback to call if this subprovider decides not to handle the request | +`end` | [ErrorCallback](#errorcallback) | Callback to call if subprovider handled the request and wants to pass back the request. | -### Properties +**Returns:** *`Promise`* -* [oldProtocolFeeMultiplier](#oldprotocolfeemultiplier) -* [updatedProtocolFeeMultiplier](#updatedprotocolfeemultiplier) +___ -## Properties +### sendAsync -### oldProtocolFeeMultiplier +▸ **sendAsync**(`payload`: `JSONRPCRequestPayload`, `callback`: [ErrorCallback](#errorcallback)): *void* -• **oldProtocolFeeMultiplier**: *`BigNumber`* +*Defined in [subproviders/src/subproviders/metamask_subprovider.ts:117](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/metamask_subprovider.ts#L117)* + +This method conforms to the provider sendAsync interface. +Allowing the MetamaskSubprovider to be used as a generic provider (outside of Web3ProviderEngine) with the +addition of wrapping the inconsistent Metamask behaviour + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`payload` | `JSONRPCRequestPayload` | JSON RPC payload | +`callback` | [ErrorCallback](#errorcallback) | - | -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:101](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L101)* +**Returns:** *void* + +The contents nested under the result key of the response body ___ -### updatedProtocolFeeMultiplier +### setEngine -• **updatedProtocolFeeMultiplier**: *`BigNumber`* +▸ **setEngine**(`engine`: `Web3ProviderEngine`): *void* + + + +*Defined in [subproviders/src/subproviders/subprovider.ts:68](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/subprovider.ts#L68)* + +Set's the subprovider's engine to the ProviderEngine it is added to. +This is only called within the ProviderEngine source code, do not call +directly. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`engine` | `Web3ProviderEngine` | The ProviderEngine this subprovider is added to | -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:102](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L102)* +**Returns:** *void*
-# Interface: ExchangeSignatureValidatorApprovalEventArgs +# Class: RPCSubprovider +This class implements the [web3-provider-engine](https://github.com/MetaMask/provider-engine) subprovider interface. +It forwards on JSON RPC requests to the supplied `rpcUrl` endpoint -## Index -### Properties +## Constructors -* [isApproved](#isapproved) -* [signerAddress](#signeraddress) -* [validatorAddress](#validatoraddress) -## Properties -### isApproved +\+ **new RPCSubprovider**(`rpcUrl`: string, `requestTimeoutMs`: number): *[RPCSubprovider](#class-rpcsubprovider)* -• **isApproved**: *boolean* +*Defined in [subproviders/src/subproviders/rpc_subprovider.ts:17](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/rpc_subprovider.ts#L17)* + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`rpcUrl` | string | - | URL to the backing Ethereum node to which JSON RPC requests should be sent | +`requestTimeoutMs` | number | 20000 | Amount of miliseconds to wait before timing out the JSON RPC request | + +**Returns:** *[RPCSubprovider](#class-rpcsubprovider)* + +## Methods + +### emitPayloadAsync + +▸ **emitPayloadAsync**(`payload`: `Partial`): *`Promise`* + + + +*Defined in [subproviders/src/subproviders/subprovider.ts:55](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/subprovider.ts#L55)* + +Emits a JSON RPC payload that will then be handled by the ProviderEngine instance +this subprovider is a part of. The payload will cascade down the subprovider middleware +stack until finding the responsible entity for handling the request. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`payload` | `Partial` | JSON RPC payload | + +**Returns:** *`Promise`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:108](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L108)* +JSON RPC response payload ___ -### signerAddress +### handleRequest -• **signerAddress**: *string* +▸ **handleRequest**(`payload`: `JSONRPCRequestPayload`, `_next`: [Callback](#callback), `end`: [ErrorCallback](#errorcallback)): *`Promise`* + +*Overrides void* + +*Defined in [subproviders/src/subproviders/rpc_subprovider.ts:38](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/rpc_subprovider.ts#L38)* + +This method conforms to the web3-provider-engine interface. +It is called internally by the ProviderEngine when it is this subproviders +turn to handle a JSON RPC request. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`payload` | `JSONRPCRequestPayload` | JSON RPC payload | +`_next` | [Callback](#callback) | Callback to call if this subprovider decides not to handle the request | +`end` | [ErrorCallback](#errorcallback) | Callback to call if subprovider handled the request and wants to pass back the request. | + +**Returns:** *`Promise`* + +___ + +### setEngine + +▸ **setEngine**(`engine`: `Web3ProviderEngine`): *void* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:106](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L106)* -___ -### validatorAddress +*Defined in [subproviders/src/subproviders/subprovider.ts:68](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/subprovider.ts#L68)* -• **validatorAddress**: *string* +Set's the subprovider's engine to the ProviderEngine it is added to. +This is only called within the ProviderEngine source code, do not call +directly. -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:107](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L107)* +**Parameters:** -
+Name | Type | Description | +------ | ------ | ------ | +`engine` | `Web3ProviderEngine` | The ProviderEngine this subprovider is added to | -# Interface: ExchangeTransactionExecutionEventArgs +**Returns:** *void* +
-## Index +# Enumeration: ERC20TokenEvents -### Properties -* [transactionHash](#transactionhash) +## Enumeration members -## Properties +### Approval -### transactionHash +• **Approval**: = "Approval" -• **transactionHash**: *string* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:38](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L38)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:112](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L112)* +___ -
+### Transfer -# Interface: WETH9ApprovalEventArgs +• **Transfer**: = "Transfer" +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:37](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L37)* -## Index +
-### Properties +# Enumeration: ERC721TokenEvents -* [_owner](#_owner) -* [_spender](#_spender) -* [_value](#_value) -## Properties +## Enumeration members -### _owner +### Approval -• **_owner**: *string* +• **Approval**: = "Approval" -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:51](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L51)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:40](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L40)* ___ -### _spender +### ApprovalForAll -• **_spender**: *string* +• **ApprovalForAll**: = "ApprovalForAll" -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:52](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L52)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:41](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L41)* ___ -### _value +### Transfer -• **_value**: *`BigNumber`* +• **Transfer**: = "Transfer" -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:53](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L53)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:42](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L42)*
-# Interface: WETH9DepositEventArgs +# Enumeration: ExchangeEvents -## Index +## Enumeration members -### Properties +### AssetProxyRegistered -* [_owner](#_owner) -* [_value](#_value) +• **AssetProxyRegistered**: = "AssetProxyRegistered" -## Properties +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:45](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L45)* -### _owner +___ -• **_owner**: *string* +### Cancel + +• **Cancel**: = "Cancel" -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:63](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L63)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:46](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L46)* ___ -### _value +### CancelUpTo -• **_value**: *`BigNumber`* +• **CancelUpTo**: = "CancelUpTo" -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:64](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L64)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:47](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L47)* -
+___ -# Interface: WETH9TransferEventArgs +### Fill +• **Fill**: = "Fill" -## Index +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:48](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L48)* -### Properties +___ -* [_from](#_from) -* [_to](#_to) -* [_value](#_value) +### ProtocolFeeCollectorAddress -## Properties +• **ProtocolFeeCollectorAddress**: = "ProtocolFeeCollectorAddress" -### _from +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:49](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L49)* -• **_from**: *string* +___ -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:57](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L57)* +### ProtocolFeeMultiplier + +• **ProtocolFeeMultiplier**: = "ProtocolFeeMultiplier" + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:50](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L50)* ___ -### _to +### SignatureValidatorApproval -• **_to**: *string* +• **SignatureValidatorApproval**: = "SignatureValidatorApproval" -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:58](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L58)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:51](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L51)* ___ -### _value +### TransactionExecution -• **_value**: *`BigNumber`* +• **TransactionExecution**: = "TransactionExecution" -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:59](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L59)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:52](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L52)*
-# Interface: WETH9WithdrawalEventArgs - +# Enumeration: WETH9Events -## Index -### Properties +## Enumeration members -* [_owner](#_owner) -* [_value](#_value) +### Approval -## Properties +• **Approval**: = "Approval" -### _owner +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:41](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L41)* -• **_owner**: *string* +___ -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:68](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L68)* +### Deposit -___ +• **Deposit**: = "Deposit" -### _value +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:43](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L43)* -• **_value**: *`BigNumber`* +___ -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:69](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L69)* +### Transfer -
+• **Transfer**: = "Transfer" -# Interface: AwaitTransactionSuccessOpts +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:42](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L42)* -Used with `awaitTransactionSuccessAsync` -* pollingIntervalMs: Determine polling intervals in milliseconds -* timeoutMs: Determines timeout in milliseconds +___ +### Withdrawal -## Properties +• **Withdrawal**: = "Withdrawal" -### `Optional` pollingIntervalMs +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:44](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L44)* -• **pollingIntervalMs**? : *undefined | number* +
-*Defined in [base-contract/src/types.ts:39](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/base-contract/src/types.ts#L39)* +# Enumeration: ZRXTokenEvents -___ -### `Optional` shouldValidate +## Enumeration members -• **shouldValidate**? : *undefined | false | true* +### Approval -*Inherited from [SendTransactionOpts](#interface-sendtransactionopts).[shouldValidate](#optional-shouldvalidate)* +• **Approval**: = "Approval" -*Defined in [base-contract/src/types.ts:30](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/base-contract/src/types.ts#L30)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:38](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L38)* ___ -### `Optional` timeoutMs +### Transfer -• **timeoutMs**? : *undefined | number* +• **Transfer**: = "Transfer" -*Defined in [base-contract/src/types.ts:40](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/base-contract/src/types.ts#L40)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:37](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L37)*
-# Interface: ContractEvent <**ContractEventArgs**> - -## Type parameters - -▪ **ContractEventArgs** +# Enumeration: ChainId -## Properties +## Enumeration members -### address +### Ganache -• **address**: *string* +• **Ganache**: = 1337 -*Defined in [base-contract/src/types.ts:13](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/base-contract/src/types.ts#L13)* +*Defined in [contract-addresses/src/index.ts:34](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L34)* ___ -### args +### Kovan -• **args**: *`ContractEventArgs`* +• **Kovan**: = 42 -*Defined in [base-contract/src/types.ts:16](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/base-contract/src/types.ts#L16)* +*Defined in [contract-addresses/src/index.ts:33](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L33)* ___ -### blockHash +### Mainnet -• **blockHash**: *string* +• **Mainnet**: = 1 -*Defined in [base-contract/src/types.ts:11](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/base-contract/src/types.ts#L11)* +*Defined in [contract-addresses/src/index.ts:30](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L30)* ___ -### blockNumber +### Rinkeby -• **blockNumber**: *number* +• **Rinkeby**: = 4 -*Defined in [base-contract/src/types.ts:12](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/base-contract/src/types.ts#L12)* +*Defined in [contract-addresses/src/index.ts:32](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L32)* ___ -### event +### Ropsten -• **event**: *string* +• **Ropsten**: = 3 -*Defined in [base-contract/src/types.ts:15](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/base-contract/src/types.ts#L15)* +*Defined in [contract-addresses/src/index.ts:31](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L31)* -___ +
-### logIndex -• **logIndex**: *number* -*Defined in [base-contract/src/types.ts:8](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/base-contract/src/types.ts#L8)* +# Enumeration: BlockParamLiteral -___ -### transactionHash +## Enumeration members -• **transactionHash**: *string* +### Earliest + +• **Earliest**: = "earliest" -*Defined in [base-contract/src/types.ts:10](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/base-contract/src/types.ts#L10)* +*Defined in [ethereum-types/src/index.ts:478](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L478)* ___ -### transactionIndex +### Latest -• **transactionIndex**: *number* +• **Latest**: = "latest" -*Defined in [base-contract/src/types.ts:9](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/base-contract/src/types.ts#L9)* +*Defined in [ethereum-types/src/index.ts:479](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L479)* ___ -### type +### Pending -• **type**: *string* +• **Pending**: = "pending" -*Defined in [base-contract/src/types.ts:14](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/base-contract/src/types.ts#L14)* +*Defined in [ethereum-types/src/index.ts:480](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L480)*
-# Interface: ContractFunctionObj <**T**> -## Type parameters -▪ **T** -## Methods -### callAsync -▸ **callAsync**(`callData?`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -*Defined in [base-contract/src/types.ts:44](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/base-contract/src/types.ts#L44)* -**Parameters:** -Name | Type | ------- | ------ | -`callData?` | `Partial` | -`defaultBlock?` | [BlockParam](#blockparam) | -**Returns:** *`Promise`* +# Enumeration: AssetProxyId -___ -### getABIEncodedTransactionData +## Enumeration members -▸ **getABIEncodedTransactionData**(): *string* +### ERC1155 -*Defined in [base-contract/src/types.ts:45](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/base-contract/src/types.ts#L45)* +• **ERC1155**: = "0xa7cb5fb7" -**Returns:** *string* +*Defined in [types/src/index.ts:166](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L166)* -
+___ -# Interface: ContractTxFunctionObj <**T**> +### ERC20 -## Type parameters +• **ERC20**: = "0xf47261b0" -▪ **T** +*Defined in [types/src/index.ts:163](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L163)* +___ -## Methods +### ERC20Bridge -### awaitTransactionSuccessAsync +• **ERC20Bridge**: = "0xdc1600f3" -▸ **awaitTransactionSuccessAsync**(`txData?`: `Partial`, `opts?`: [AwaitTransactionSuccessOpts](#class-awaittransactionsuccessopts)): *`PromiseWithTransactionHash`* +*Defined in [types/src/index.ts:168](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L168)* -*Defined in [base-contract/src/types.ts:50](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/base-contract/src/types.ts#L50)* +___ -**Parameters:** +### ERC721 -Name | Type | ------- | ------ | -`txData?` | `Partial` | -`opts?` | [AwaitTransactionSuccessOpts](#class-awaittransactionsuccessopts) | +• **ERC721**: = "0x02571792" -**Returns:** *`PromiseWithTransactionHash`* +*Defined in [types/src/index.ts:164](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L164)* ___ -### callAsync - -▸ **callAsync**(`callData?`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* - -*Inherited from [ContractFunctionObj](#interface-contractfunctionobj).[callAsync](#callasync)* +### MultiAsset -*Defined in [base-contract/src/types.ts:44](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/base-contract/src/types.ts#L44)* +• **MultiAsset**: = "0x94cfcdd7" -**Parameters:** +*Defined in [types/src/index.ts:165](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L165)* -Name | Type | ------- | ------ | -`callData?` | `Partial` | -`defaultBlock?` | [BlockParam](#blockparam) | +___ -**Returns:** *`Promise`* +### StaticCall -___ +• **StaticCall**: = "0xc339d10a" -### estimateGasAsync +*Defined in [types/src/index.ts:167](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L167)* -▸ **estimateGasAsync**(`txData?`: `Partial`): *`Promise`* +
-*Defined in [base-contract/src/types.ts:54](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/base-contract/src/types.ts#L54)* -**Parameters:** -Name | Type | ------- | ------ | -`txData?` | `Partial` | -**Returns:** *`Promise`* -___ -### getABIEncodedTransactionData -▸ **getABIEncodedTransactionData**(): *string* -*Inherited from [ContractFunctionObj](#interface-contractfunctionobj).[getABIEncodedTransactionData](#getabiencodedtransactiondata)* -*Defined in [base-contract/src/types.ts:45](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/base-contract/src/types.ts#L45)* -**Returns:** *string* -___ -### sendTransactionAsync -▸ **sendTransactionAsync**(`txData?`: `Partial`, `opts?`: [SendTransactionOpts](#class-sendtransactionopts)): *`Promise`* +# Enumeration: SignatureType -*Defined in [base-contract/src/types.ts:49](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/base-contract/src/types.ts#L49)* -**Parameters:** +## Enumeration members -Name | Type | ------- | ------ | -`txData?` | `Partial` | -`opts?` | [SendTransactionOpts](#class-sendtransactionopts) | +### EIP1271Wallet -**Returns:** *`Promise`* +• **EIP1271Wallet**: -
+*Defined in [types/src/index.ts:158](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L158)* +___ +### EIP712 -# Interface: ContractAddresses +• **EIP712**: +*Defined in [types/src/index.ts:153](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L153)* -## Properties +___ -### assetProxyOwner +### EthSign -• **assetProxyOwner**: *string* +• **EthSign**: -*Defined in [contract-addresses/src/index.ts:12](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L12)* +*Defined in [types/src/index.ts:154](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L154)* ___ -### coordinator +### Illegal -• **coordinator**: *string* +• **Illegal**: -*Defined in [contract-addresses/src/index.ts:18](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L18)* +*Defined in [types/src/index.ts:151](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L151)* ___ -### coordinatorRegistry +### Invalid -• **coordinatorRegistry**: *string* +• **Invalid**: -*Defined in [contract-addresses/src/index.ts:17](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L17)* +*Defined in [types/src/index.ts:152](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L152)* ___ -### devUtils +### NSignatureTypes -• **devUtils**: *string* +• **NSignatureTypes**: -*Defined in [contract-addresses/src/index.ts:22](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L22)* +*Defined in [types/src/index.ts:159](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L159)* ___ -### dutchAuction +### PreSigned -• **dutchAuction**: *string* +• **PreSigned**: -*Defined in [contract-addresses/src/index.ts:16](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L16)* +*Defined in [types/src/index.ts:157](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L157)* ___ -### erc1155Proxy +### Validator -• **erc1155Proxy**: *string* +• **Validator**: -*Defined in [contract-addresses/src/index.ts:21](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L21)* +*Defined in [types/src/index.ts:156](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L156)* ___ -### erc20BridgeProxy +### Wallet -• **erc20BridgeProxy**: *string* +• **Wallet**: -*Defined in [contract-addresses/src/index.ts:26](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L26)* +*Defined in [types/src/index.ts:155](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L155)* -___ +
-### erc20Proxy -• **erc20Proxy**: *string* -*Defined in [contract-addresses/src/index.ts:6](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L6)* -___ -### erc721Proxy -• **erc721Proxy**: *string* -*Defined in [contract-addresses/src/index.ts:7](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L7)* -___ -### etherToken +# Interface: ERC20TokenApprovalEventArgs -• **etherToken**: *string* -*Defined in [contract-addresses/src/index.ts:9](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L9)* +## Index -___ +### Properties -### exchange +* [_owner](#_owner) +* [_spender](#_spender) +* [_value](#_value) -• **exchange**: *string* +## Properties + +### _owner + +• **_owner**: *string* -*Defined in [contract-addresses/src/index.ts:11](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L11)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:48](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L48)* ___ -### exchangeV2 +### _spender -• **exchangeV2**: *string* +• **_spender**: *string* -*Defined in [contract-addresses/src/index.ts:10](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L10)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:49](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L49)* ___ -### forwarder +### _value -• **forwarder**: *string* +• **_value**: *`BigNumber`* -*Defined in [contract-addresses/src/index.ts:14](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L14)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:50](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L50)* -___ +
-### multiAssetProxy +# Interface: ERC20TokenTransferEventArgs -• **multiAssetProxy**: *string* -*Defined in [contract-addresses/src/index.ts:19](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L19)* +## Index -___ +### Properties -### orderValidator +* [_from](#_from) +* [_to](#_to) +* [_value](#_value) -• **orderValidator**: *string* +## Properties + +### _from + +• **_from**: *string* -*Defined in [contract-addresses/src/index.ts:15](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L15)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:42](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L42)* ___ -### staking +### _to -• **staking**: *string* +• **_to**: *string* -*Defined in [contract-addresses/src/index.ts:24](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L24)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:43](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L43)* ___ -### stakingProxy +### _value -• **stakingProxy**: *string* +• **_value**: *`BigNumber`* -*Defined in [contract-addresses/src/index.ts:25](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L25)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:44](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L44)* -___ +
-### staticCallProxy +# Interface: ERC721TokenApprovalEventArgs -• **staticCallProxy**: *string* -*Defined in [contract-addresses/src/index.ts:20](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L20)* +## Index -___ +### Properties -### zeroExGovernor +* [_approved](#_approved) +* [_owner](#_owner) +* [_tokenId](#_tokenid) -• **zeroExGovernor**: *string* +## Properties + +### _approved + +• **_approved**: *string* -*Defined in [contract-addresses/src/index.ts:13](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L13)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:47](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L47)* ___ -### zrxToken +### _owner -• **zrxToken**: *string* +• **_owner**: *string* -*Defined in [contract-addresses/src/index.ts:8](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L8)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:46](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L46)* ___ -### zrxVault +### _tokenId -• **zrxVault**: *string* +• **_tokenId**: *`BigNumber`* -*Defined in [contract-addresses/src/index.ts:23](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L23)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:48](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L48)*
+# Interface: ERC721TokenApprovalForAllEventArgs -# Interface: BlockRange - +## Index -## Properties +### Properties -### fromBlock +* [_approved](#_approved) +* [_operator](#_operator) +* [_owner](#_owner) -• **fromBlock**: *[BlockParam](#blockparam)* +## Properties -*Defined in [ethereum-types/src/index.ts:742](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L742)* +### _approved -___ +• **_approved**: *boolean* -### toBlock +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:54](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L54)* -• **toBlock**: *[BlockParam](#blockparam)* +___ -*Defined in [ethereum-types/src/index.ts:743](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L743)* +### _operator -
+• **_operator**: *string* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:53](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L53)* +___ +### _owner +• **_owner**: *string* -# Interface: CallData +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:52](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L52)* +
-## Properties +# Interface: ERC721TokenTransferEventArgs -### `Optional` data -• **data**? : *undefined | string* +## Index -*Inherited from [CallTxDataBase](#interface-calltxdatabase).[data](#optional-data)* +### Properties -*Defined in [ethereum-types/src/index.ts:393](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L393)* +* [_from](#_from) +* [_to](#_to) +* [_tokenId](#_tokenid) -___ +## Properties -### `Optional` from +### _from -• **from**? : *undefined | string* +• **_from**: *string* -*Defined in [ethereum-types/src/index.ts:402](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L402)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:58](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L58)* ___ -### `Optional` gas - -• **gas**? : *number | string | `BigNumber`* +### _to -*Inherited from [CallTxDataBase](#interface-calltxdatabase).[gas](#optional-gas)* +• **_to**: *string* -*Defined in [ethereum-types/src/index.ts:391](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L391)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:59](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L59)* ___ -### `Optional` gasPrice - -• **gasPrice**? : *number | string | `BigNumber`* +### _tokenId -*Inherited from [CallTxDataBase](#interface-calltxdatabase).[gasPrice](#optional-gasprice)* +• **_tokenId**: *`BigNumber`* -*Defined in [ethereum-types/src/index.ts:392](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L392)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:60](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L60)* -___ +
-### `Optional` nonce +# Interface: ExchangeAssetProxyRegisteredEventArgs -• **nonce**? : *undefined | number* -*Inherited from [CallTxDataBase](#interface-calltxdatabase).[nonce](#optional-nonce)* +## Index -*Defined in [ethereum-types/src/index.ts:394](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L394)* +### Properties -___ +* [assetProxy](#assetproxy) +* [id](#id) -### `Optional` to +## Properties -• **to**? : *undefined | string* +### assetProxy -*Inherited from [CallTxDataBase](#interface-calltxdatabase).[to](#optional-to)* +• **assetProxy**: *string* -*Defined in [ethereum-types/src/index.ts:389](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L389)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:57](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L57)* ___ -### `Optional` value - -• **value**? : *number | string | `BigNumber`* +### id -*Inherited from [CallTxDataBase](#interface-calltxdatabase).[value](#optional-value)* +• **id**: *string* -*Defined in [ethereum-types/src/index.ts:390](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L390)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:56](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L56)*
+# Interface: ExchangeCancelEventArgs +## Index +### Properties -# Interface: CompilerOpts - +* [feeRecipientAddress](#feerecipientaddress) +* [makerAddress](#makeraddress) +* [makerAssetData](#makerassetdata) +* [orderHash](#orderhash) +* [senderAddress](#senderaddress) +* [takerAssetData](#takerassetdata) -## Properties +## Properties -### name +### feeRecipientAddress -• **name**: *"solc"* +• **feeRecipientAddress**: *string* -*Defined in [ethereum-types/src/index.ts:655](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L655)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:62](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L62)* ___ -### settings +### makerAddress -• **settings**: *[CompilerSettings](#class-compilersettings)* +• **makerAddress**: *string* -*Defined in [ethereum-types/src/index.ts:657](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L657)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:61](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L61)* ___ -### version +### makerAssetData -• **version**: *string* +• **makerAssetData**: *string* -*Defined in [ethereum-types/src/index.ts:656](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L656)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:63](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L63)* -
+___ -# Interface: CompilerSettings +### orderHash +• **orderHash**: *string* -## Properties +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:66](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L66)* -### `Optional` evmVersion +___ -• **evmVersion**? : *"homestead" | "tangerineWhistle" | "spuriousDragon" | "byzantium" | "constantinople"* +### senderAddress + +• **senderAddress**: *string* -*Defined in [ethereum-types/src/index.ts:689](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L689)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:65](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L65)* ___ -### `Optional` libraries +### takerAssetData -• **libraries**? : *undefined | object* +• **takerAssetData**: *string* -*Defined in [ethereum-types/src/index.ts:691](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L691)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:64](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L64)* -___ +
-### `Optional` metadata +# Interface: ExchangeCancelUpToEventArgs -• **metadata**? : *[CompilerSettingsMetadata](#class-compilersettingsmetadata)* -*Defined in [ethereum-types/src/index.ts:690](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L690)* +## Index -___ +### Properties -### `Optional` optimizer +* [makerAddress](#makeraddress) +* [orderEpoch](#orderepoch) +* [orderSenderAddress](#ordersenderaddress) -• **optimizer**? : *[OptimizerSettings](#class-optimizersettings)* +## Properties + +### makerAddress + +• **makerAddress**: *string* -*Defined in [ethereum-types/src/index.ts:688](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L688)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:70](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L70)* ___ -### outputSelection +### orderEpoch -• **outputSelection**: *object* +• **orderEpoch**: *`BigNumber`* -*Defined in [ethereum-types/src/index.ts:696](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L696)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:72](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L72)* -#### Type declaration: +___ -● \[▪ **fileName**: *string*\]: object +### orderSenderAddress -● \[▪ **contractName**: *string*\]: [OutputField](#outputfield)[] +• **orderSenderAddress**: *string* -___ +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:71](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L71)* -### `Optional` remappings +
+ +# Interface: ExchangeFillEventArgs -• **remappings**? : *string[]* -*Defined in [ethereum-types/src/index.ts:687](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L687)* +## Index -
+### Properties -# Interface: CompilerSettingsMetadata +* [feeRecipientAddress](#feerecipientaddress) +* [makerAddress](#makeraddress) +* [makerAssetData](#makerassetdata) +* [makerAssetFilledAmount](#makerassetfilledamount) +* [makerFeeAssetData](#makerfeeassetdata) +* [makerFeePaid](#makerfeepaid) +* [orderHash](#orderhash) +* [protocolFeePaid](#protocolfeepaid) +* [senderAddress](#senderaddress) +* [takerAddress](#takeraddress) +* [takerAssetData](#takerassetdata) +* [takerAssetFilledAmount](#takerassetfilledamount) +* [takerFeeAssetData](#takerfeeassetdata) +* [takerFeePaid](#takerfeepaid) +## Properties -## Properties +### feeRecipientAddress -### useLiteralContent +• **feeRecipientAddress**: *string* -• **useLiteralContent**: *true* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:77](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L77)* -*Defined in [ethereum-types/src/index.ts:704](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L704)* +___ -
+### makerAddress -# Interface: ConstructorAbi +• **makerAddress**: *string* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:76](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L76)* -## Properties +___ -### inputs +### makerAssetData -• **inputs**: *[DataItem](#class-dataitem)[]* +• **makerAssetData**: *string* -*Defined in [ethereum-types/src/index.ts:103](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L103)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:78](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L78)* ___ -### payable +### makerAssetFilledAmount -• **payable**: *boolean* +• **makerAssetFilledAmount**: *`BigNumber`* -*Defined in [ethereum-types/src/index.ts:104](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L104)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:85](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L85)* ___ -### stateMutability +### makerFeeAssetData -• **stateMutability**: *[ConstructorStateMutability](#constructorstatemutability)* +• **makerFeeAssetData**: *string* -*Defined in [ethereum-types/src/index.ts:105](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L105)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:80](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L80)* ___ -### type +### makerFeePaid -• **type**: *string* +• **makerFeePaid**: *`BigNumber`* -*Defined in [ethereum-types/src/index.ts:102](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L102)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:87](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L87)* -
+___ -# Interface: ContractArtifact +### orderHash -This type defines the schema of the artifact.json file generated by Sol-compiler -schemaVersion: The version of the artifact schema -contractName: The contract name it represents -chains: Chain specific information by chain (address, id, constructor args, etc...) -compilerOutput: The Solidity compiler output generated from the specified compiler input -description (http://solidity.readthedocs.io/en/v0.4.24/using-the-compiler.html#compiler-input-and-output-json-description) -compiler: The compiler settings used -sourceCodes: The source code of the contract and all it's dependencies -sources: A mapping from source filePath to sourceMap id -sourceTreeHashHex: A unique hash generated from the contract source and that of it's dependencies. -If any of the sources change, the hash would change notifying us that a re-compilation is necessary +• **orderHash**: *string* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:82](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L82)* -## Properties +___ -### chains +### protocolFeePaid -• **chains**: *[ContractChains](#class-contractchains)* +• **protocolFeePaid**: *`BigNumber`* -*Defined in [ethereum-types/src/index.ts:676](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L676)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:89](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L89)* ___ -### compiler - -• **compiler**: *[CompilerOpts](#class-compileropts)* +### senderAddress -*Inherited from [ContractVersionData](#interface-contractversiondata).[compiler](#compiler)* +• **senderAddress**: *string* -*Defined in [ethereum-types/src/index.ts:641](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L641)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:84](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L84)* ___ -### compilerOutput - -• **compilerOutput**: *[StandardContractOutput](#class-standardcontractoutput)* +### takerAddress -*Inherited from [ContractVersionData](#interface-contractversiondata).[compilerOutput](#compileroutput)* +• **takerAddress**: *string* -*Defined in [ethereum-types/src/index.ts:651](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L651)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:83](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L83)* ___ -### contractName +### takerAssetData -• **contractName**: *string* +• **takerAssetData**: *string* -*Defined in [ethereum-types/src/index.ts:675](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L675)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:79](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L79)* ___ -### schemaVersion +### takerAssetFilledAmount -• **schemaVersion**: *string* +• **takerAssetFilledAmount**: *`BigNumber`* -*Defined in [ethereum-types/src/index.ts:674](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L674)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:86](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L86)* ___ -### sourceCodes +### takerFeeAssetData -• **sourceCodes**: *object* +• **takerFeeAssetData**: *string* -*Inherited from [ContractVersionData](#interface-contractversiondata).[sourceCodes](#sourcecodes)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:81](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L81)* -*Defined in [ethereum-types/src/index.ts:647](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L647)* +___ -#### Type declaration: +### takerFeePaid -● \[▪ **sourceName**: *string*\]: string +• **takerFeePaid**: *`BigNumber`* -___ +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:88](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L88)* -### sourceTreeHashHex +
-• **sourceTreeHashHex**: *string* +# Interface: ExchangeProtocolFeeCollectorAddressEventArgs -*Inherited from [ContractVersionData](#interface-contractversiondata).[sourceTreeHashHex](#sourcetreehashhex)* -*Defined in [ethereum-types/src/index.ts:650](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L650)* +## Index -___ +### Properties -### sources +* [oldProtocolFeeCollector](#oldprotocolfeecollector) +* [updatedProtocolFeeCollector](#updatedprotocolfeecollector) -• **sources**: *object* +## Properties -*Inherited from [ContractVersionData](#interface-contractversiondata).[sources](#sources)* +### oldProtocolFeeCollector -*Defined in [ethereum-types/src/index.ts:642](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L642)* +• **oldProtocolFeeCollector**: *string* -#### Type declaration: +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:93](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L93)* -● \[▪ **sourceName**: *string*\]: object +___ -
+### updatedProtocolFeeCollector -# Interface: ContractChainData +• **updatedProtocolFeeCollector**: *string* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:94](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L94)* -## Properties +
-### address +# Interface: ExchangeProtocolFeeMultiplierEventArgs -• **address**: *string* -*Defined in [ethereum-types/src/index.ts:554](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L554)* +## Index -___ +### Properties -Args +* [oldProtocolFeeMultiplier](#oldprotocolfeemultiplier) +* [updatedProtocolFeeMultiplier](#updatedprotocolfeemultiplier) -• **constructorArgs**: *string* +## Properties -*Defined in [ethereum-types/src/index.ts:558](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L558)* +### oldProtocolFeeMultiplier -___ +• **oldProtocolFeeMultiplier**: *`BigNumber`* -### links +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:98](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L98)* -• **links**: *object* +___ -*Defined in [ethereum-types/src/index.ts:555](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L555)* +### updatedProtocolFeeMultiplier -#### Type declaration: +• **updatedProtocolFeeMultiplier**: *`BigNumber`* -● \[▪ **linkName**: *string*\]: string +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:99](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L99)*
-# Interface: ContractChains - +# Interface: ExchangeSignatureValidatorApprovalEventArgs -## Hierarchy -* **ContractVersionData** +## Index - * [ContractArtifact](#class-contractartifact) +### Properties +* [isApproved](#isapproved) +* [signerAddress](#signeraddress) +* [validatorAddress](#validatoraddress) -## Properties +## Properties -### compiler +### isApproved -• **compiler**: *[CompilerOpts](#class-compileropts)* +• **isApproved**: *boolean* -*Defined in [ethereum-types/src/index.ts:641](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L641)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:105](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L105)* ___ -### compilerOutput +### signerAddress -• **compilerOutput**: *[StandardContractOutput](#class-standardcontractoutput)* +• **signerAddress**: *string* -*Defined in [ethereum-types/src/index.ts:651](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L651)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:103](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L103)* ___ -### sourceCodes - -• **sourceCodes**: *object* - -*Defined in [ethereum-types/src/index.ts:647](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L647)* +### validatorAddress -#### Type declaration: +• **validatorAddress**: *string* -● \[▪ **sourceName**: *string*\]: string +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:104](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L104)* -___ +
-### sourceTreeHashHex +# Interface: ExchangeTransactionExecutionEventArgs -• **sourceTreeHashHex**: *string* -*Defined in [ethereum-types/src/index.ts:650](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L650)* +## Index -___ +### Properties -### sources +* [transactionHash](#transactionhash) -• **sources**: *object* +## Properties -*Defined in [ethereum-types/src/index.ts:642](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L642)* +### transactionHash -#### Type declaration: +• **transactionHash**: *string* -● \[▪ **sourceName**: *string*\]: object +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:109](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L109)*
-# Interface: DataItem - +# Interface: WETH9ApprovalEventArgs -## Properties -### `Optional` components +## Index -• **components**? : *[DataItem](#class-dataitem)[]* +### Properties -*Defined in [ethereum-types/src/index.ts:137](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L137)* +* [_owner](#_owner) +* [_spender](#_spender) +* [_value](#_value) -___ +## Properties -### name +### _owner -• **name**: *string* +• **_owner**: *string* -*Defined in [ethereum-types/src/index.ts:135](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L135)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:48](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L48)* ___ -### type - -• **type**: *string* +### _spender -*Defined in [ethereum-types/src/index.ts:136](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L136)* +• **_spender**: *string* -
+*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:49](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L49)* -# Interface: DecodedLogArgs +___ +### _value -## Type parameters +• **_value**: *`BigNumber`* -▪ **A** +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:50](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L50)* +
-## Properties +# Interface: WETH9DepositEventArgs -### address -• **address**: *string* +## Index -*Inherited from [LogEntry](#interface-logentry).[address](#address)* +### Properties -*Defined in [ethereum-types/src/index.ts:434](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L434)* +* [_owner](#_owner) +* [_value](#_value) -___ +## Properties -### args +### _owner -• **args**: *`A`* +• **_owner**: *string* -*Defined in [ethereum-types/src/index.ts:417](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L417)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:60](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L60)* ___ -### blockHash - -• **blockHash**: *string | null* +### _value -*Inherited from [LogEntry](#interface-logentry).[blockHash](#blockhash)* +• **_value**: *`BigNumber`* -*Defined in [ethereum-types/src/index.ts:432](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L432)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:61](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L61)* -___ +
-### blockNumber +# Interface: WETH9TransferEventArgs -• **blockNumber**: *number | null* -*Inherited from [LogEntry](#interface-logentry).[blockNumber](#blocknumber)* +## Index -*Defined in [ethereum-types/src/index.ts:433](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L433)* +### Properties -___ +* [_from](#_from) +* [_to](#_to) +* [_value](#_value) -### data +## Properties -• **data**: *string* +### _from -*Inherited from [LogEntry](#interface-logentry).[data](#data)* +• **_from**: *string* -*Defined in [ethereum-types/src/index.ts:435](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L435)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:54](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L54)* ___ -### event +### _to -• **event**: *string* +• **_to**: *string* -*Defined in [ethereum-types/src/index.ts:416](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L416)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:55](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L55)* ___ -### logIndex - -• **logIndex**: *number | null* +### _value -*Inherited from [LogEntry](#interface-logentry).[logIndex](#logindex)* +• **_value**: *`BigNumber`* -*Defined in [ethereum-types/src/index.ts:429](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L429)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:56](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L56)* -___ +
-### topics +# Interface: WETH9WithdrawalEventArgs -• **topics**: *string[]* -*Inherited from [LogEntry](#interface-logentry).[topics](#topics)* +## Index -*Defined in [ethereum-types/src/index.ts:436](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L436)* +### Properties -___ +* [_owner](#_owner) +* [_value](#_value) -### transactionHash +## Properties -• **transactionHash**: *string* +### _owner -*Inherited from [LogEntry](#interface-logentry).[transactionHash](#transactionhash)* +• **_owner**: *string* -*Defined in [ethereum-types/src/index.ts:431](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L431)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:65](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L65)* ___ -### transactionIndex - -• **transactionIndex**: *number | null* +### _value -*Inherited from [LogEntry](#interface-logentry).[transactionIndex](#transactionindex)* +• **_value**: *`BigNumber`* -*Defined in [ethereum-types/src/index.ts:430](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L430)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:66](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L66)*
+# Interface: ZRXTokenApprovalEventArgs -# Interface: DevdocOutput - +## Index -## Properties +### Properties -### `Optional` author +* [_owner](#_owner) +* [_spender](#_spender) +* [_value](#_value) -• **author**? : *undefined | string* +## Properties -*Defined in [ethereum-types/src/index.ts:628](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L628)* +### _owner -___ +• **_owner**: *string* -### methods +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:48](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L48)* -• **methods**: *object* +___ -*Defined in [ethereum-types/src/index.ts:629](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L629)* +### _spender -#### Type declaration: +• **_spender**: *string* -● \[▪ **signature**: *string*\]: object +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:49](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L49)* ___ -### `Optional` title +### _value -• **title**? : *undefined | string* +• **_value**: *`BigNumber`* -*Defined in [ethereum-types/src/index.ts:627](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L627)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:50](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L50)*
-# Interface: EIP1193Provider - - -## Properties - -### isEIP1193 - -• **isEIP1193**: *boolean* +# Interface: ZRXTokenTransferEventArgs -*Defined in [ethereum-types/src/index.ts:73](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L73)* -## Methods +## Index -### on +### Properties -▸ **on**(`event`: [EIP1193Event](#eip1193event), `listener`: function): *this* +* [_from](#_from) +* [_to](#_to) +* [_value](#_value) -*Defined in [ethereum-types/src/index.ts:75](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L75)* +## Properties -**Parameters:** +### _from -▪ **event**: *[EIP1193Event](#eip1193event)* +• **_from**: *string* -▪ **listener**: *function* +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:42](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L42)* -▸ (`result`: any): *void* +___ -**Parameters:** +### _to -Name | Type | ------- | ------ | -`result` | any | +• **_to**: *string* -**Returns:** *this* +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:43](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L43)* ___ -### send - -▸ **send**(`method`: string, `params?`: any[]): *`Promise`* - -*Defined in [ethereum-types/src/index.ts:74](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L74)* - -**Parameters:** +### _value -Name | Type | ------- | ------ | -`method` | string | -`params?` | any[] | +• **_value**: *`BigNumber`* -**Returns:** *`Promise`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:44](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L44)*
+# Interface: ContractAddresses +## Properties +### assetProxyOwner -# Interface: EvmBytecodeOutput +• **assetProxyOwner**: *string* +*Defined in [contract-addresses/src/index.ts:12](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L12)* -## Properties +___ -### object +### coordinator -• **object**: *string* +• **coordinator**: *string* -*Defined in [ethereum-types/src/index.ts:622](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L622)* +*Defined in [contract-addresses/src/index.ts:18](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L18)* ___ -### sourceMap +### coordinatorRegistry -• **sourceMap**: *string* +• **coordinatorRegistry**: *string* -*Defined in [ethereum-types/src/index.ts:623](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L623)* +*Defined in [contract-addresses/src/index.ts:17](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L17)* -
+___ -# Interface: EvmOutput +### devUtils +• **devUtils**: *string* -## Properties +*Defined in [contract-addresses/src/index.ts:22](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L22)* -### bytecode +___ -• **bytecode**: *[EvmBytecodeOutput](#class-evmbytecodeoutput)* +### dutchAuction -*Defined in [ethereum-types/src/index.ts:617](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L617)* +• **dutchAuction**: *string* + +*Defined in [contract-addresses/src/index.ts:16](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L16)* ___ -### deployedBytecode +### erc1155Proxy -• **deployedBytecode**: *[EvmBytecodeOutput](#class-evmbytecodeoutput)* +• **erc1155Proxy**: *string* -*Defined in [ethereum-types/src/index.ts:618](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L618)* +*Defined in [contract-addresses/src/index.ts:21](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L21)* -
+___ -# Interface: FallbackAbi +### erc20BridgeProxy +• **erc20BridgeProxy**: *string* -## Properties +*Defined in [contract-addresses/src/index.ts:26](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L26)* -### payable +___ -• **payable**: *boolean* +### erc20Proxy -*Defined in [ethereum-types/src/index.ts:112](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L112)* +• **erc20Proxy**: *string* -___ +*Defined in [contract-addresses/src/index.ts:6](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L6)* -### type +___ -• **type**: *string* +### erc721Proxy -*Defined in [ethereum-types/src/index.ts:111](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L111)* +• **erc721Proxy**: *string* -
+*Defined in [contract-addresses/src/index.ts:7](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L7)* +___ +### etherToken -# Interface: GanacheProvider +• **etherToken**: *string* +*Defined in [contract-addresses/src/index.ts:9](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L9)* -## Methods +___ -### sendAsync +### exchange -▸ **sendAsync**(`payload`: [JSONRPCRequestPayload](_ethereum_types_src_index_.jsonrpcrequestpayload.md), `callback`: [JSONRPCErrorCallback](#jsonrpcerrorcallback)): *void* +• **exchange**: *string* -*Defined in [ethereum-types/src/index.ts:14](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L14)* +*Defined in [contract-addresses/src/index.ts:11](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L11)* -**Parameters:** +___ -Name | Type | ------- | ------ | -`payload` | [JSONRPCRequestPayload](#class-jsonrpcrequestpayload) | -`callback` | [JSONRPCErrorCallback](#jsonrpcerrorcallback) | +### exchangeV2 -**Returns:** *void* +• **exchangeV2**: *string* -
+*Defined in [contract-addresses/src/index.ts:10](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L10)* +___ +### forwarder -# Interface: JSONRPCRequestPayload +• **forwarder**: *string* +*Defined in [contract-addresses/src/index.ts:14](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L14)* -## Properties +___ -### id +### multiAssetProxy -• **id**: *number* +• **multiAssetProxy**: *string* -*Defined in [ethereum-types/src/index.ts:330](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L330)* +*Defined in [contract-addresses/src/index.ts:19](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L19)* ___ -### jsonrpc +### orderValidator -• **jsonrpc**: *string* +• **orderValidator**: *string* -*Defined in [ethereum-types/src/index.ts:331](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L331)* +*Defined in [contract-addresses/src/index.ts:15](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L15)* ___ -### method +### staking -• **method**: *string* +• **staking**: *string* -*Defined in [ethereum-types/src/index.ts:329](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L329)* +*Defined in [contract-addresses/src/index.ts:24](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L24)* ___ -### params - -• **params**: *any[]* +### stakingProxy -*Defined in [ethereum-types/src/index.ts:328](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L328)* +• **stakingProxy**: *string* -
+*Defined in [contract-addresses/src/index.ts:25](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L25)* -# Interface: JSONRPCResponseError +___ +### staticCallProxy -## Properties +• **staticCallProxy**: *string* -### code +*Defined in [contract-addresses/src/index.ts:20](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L20)* -• **code**: *number* +___ -*Defined in [ethereum-types/src/index.ts:336](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L336)* +### zeroExGovernor -___ +• **zeroExGovernor**: *string* -### message +*Defined in [contract-addresses/src/index.ts:13](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L13)* -• **message**: *string* +___ -*Defined in [ethereum-types/src/index.ts:335](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L335)* +### zrxToken -
+• **zrxToken**: *string* -# Interface: JSONRPCResponsePayload +*Defined in [contract-addresses/src/index.ts:8](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L8)* +___ -## Properties +### zrxVault -### `Optional` error +• **zrxVault**: *string* -• **error**? : *[JSONRPCResponseError](#class-jsonrpcresponseerror)* +*Defined in [contract-addresses/src/index.ts:23](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L23)* -*Defined in [ethereum-types/src/index.ts:343](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L343)* +
-___ -### id -• **id**: *number* +# Interface: BlockRange -*Defined in [ethereum-types/src/index.ts:341](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L341)* -___ +## Properties -### jsonrpc +### fromBlock -• **jsonrpc**: *string* +• **fromBlock**: *[BlockParam](#blockparam)* -*Defined in [ethereum-types/src/index.ts:342](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L342)* +*Defined in [ethereum-types/src/index.ts:740](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L740)* ___ -### result +### toBlock -• **result**: *any* +• **toBlock**: *[BlockParam](#blockparam)* -*Defined in [ethereum-types/src/index.ts:340](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L340)* +*Defined in [ethereum-types/src/index.ts:741](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L741)*
@@ -5599,1670 +11098,1519 @@ ___ -# Interface: LogWithDecodedArgs <**ArgsType**> +# Interface: CallData -## Type parameters -▪ **ArgsType**: *[DecodedLogArgs](#class-decodedlogargs)* +## Properties +### `Optional` data -## Properties +• **data**? : *undefined | string* -### address +*Inherited from [CallTxDataBase](#interface-calltxdatabase).[data](#optional-data)* -• **address**: *string* +*Defined in [ethereum-types/src/index.ts:393](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L393)* -*Inherited from [LogEntry](#interface-logentry).[address](#address)* +___ + +### `Optional` from + +• **from**? : *undefined | string* -*Defined in [ethereum-types/src/index.ts:434](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L434)* +*Defined in [ethereum-types/src/index.ts:402](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L402)* ___ -### args +### `Optional` gas -• **args**: *`ArgsType`* +• **gas**? : *number | string | `BigNumber`* -*Inherited from [DecodedLogEntry](#interface-decodedlogentry).[args](#args)* +*Inherited from [CallTxDataBase](#interface-calltxdatabase).[gas](#optional-gas)* -*Defined in [ethereum-types/src/index.ts:417](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L417)* +*Defined in [ethereum-types/src/index.ts:391](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L391)* ___ -### blockHash +### `Optional` gasPrice -• **blockHash**: *string | null* +• **gasPrice**? : *number | string | `BigNumber`* -*Inherited from [LogEntry](#interface-logentry).[blockHash](#blockhash)* +*Inherited from [CallTxDataBase](#interface-calltxdatabase).[gasPrice](#optional-gasprice)* -*Defined in [ethereum-types/src/index.ts:432](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L432)* +*Defined in [ethereum-types/src/index.ts:392](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L392)* ___ -### blockNumber +### `Optional` nonce -• **blockNumber**: *number | null* +• **nonce**? : *undefined | number* -*Inherited from [LogEntry](#interface-logentry).[blockNumber](#blocknumber)* +*Inherited from [CallTxDataBase](#interface-calltxdatabase).[nonce](#optional-nonce)* -*Defined in [ethereum-types/src/index.ts:433](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L433)* +*Defined in [ethereum-types/src/index.ts:394](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L394)* ___ -### data +### `Optional` to -• **data**: *string* +• **to**? : *undefined | string* -*Inherited from [LogEntry](#interface-logentry).[data](#data)* +*Inherited from [CallTxDataBase](#interface-calltxdatabase).[to](#optional-to)* -*Defined in [ethereum-types/src/index.ts:435](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L435)* +*Defined in [ethereum-types/src/index.ts:389](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L389)* ___ -### event +### `Optional` value -• **event**: *string* +• **value**? : *number | string | `BigNumber`* -*Inherited from [DecodedLogEntry](#interface-decodedlogentry).[event](#event)* +*Inherited from [CallTxDataBase](#interface-calltxdatabase).[value](#optional-value)* -*Defined in [ethereum-types/src/index.ts:416](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L416)* +*Defined in [ethereum-types/src/index.ts:390](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L390)* -___ +
-### logIndex -• **logIndex**: *number | null* -*Inherited from [LogEntry](#interface-logentry).[logIndex](#logindex)* -*Defined in [ethereum-types/src/index.ts:429](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L429)* -___ +# Interface: CompilerOpts -### topics -• **topics**: *string[]* +## Properties -*Inherited from [LogEntry](#interface-logentry).[topics](#topics)* +### name -*Defined in [ethereum-types/src/index.ts:436](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L436)* +• **name**: *"solc"* -___ +*Defined in [ethereum-types/src/index.ts:655](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L655)* -### transactionHash +___ -• **transactionHash**: *string* +### settings -*Inherited from [LogEntry](#interface-logentry).[transactionHash](#transactionhash)* +• **settings**: *[CompilerSettings](#class-compilersettings)* -*Defined in [ethereum-types/src/index.ts:431](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L431)* +*Defined in [ethereum-types/src/index.ts:657](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L657)* ___ -### transactionIndex - -• **transactionIndex**: *number | null* +### version -*Inherited from [LogEntry](#interface-logentry).[transactionIndex](#transactionindex)* +• **version**: *string* -*Defined in [ethereum-types/src/index.ts:430](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L430)* +*Defined in [ethereum-types/src/index.ts:656](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L656)*
-# Interface: MethodAbi +# Interface: CompilerSettings ## Properties -### constant +### `Optional` evmVersion -• **constant**: *boolean* +• **evmVersion**? : *"homestead" | "tangerineWhistle" | "spuriousDragon" | "byzantium" | "constantinople"* -*Defined in [ethereum-types/src/index.ts:94](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L94)* +*Defined in [ethereum-types/src/index.ts:689](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L689)* ___ -### inputs +### `Optional` libraries -• **inputs**: *[DataItem](#class-dataitem)[]* +• **libraries**? : *undefined | object* -*Defined in [ethereum-types/src/index.ts:92](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L92)* +*Defined in [ethereum-types/src/index.ts:691](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L691)* ___ -### name +### `Optional` metadata -• **name**: *string* +• **metadata**? : *[CompilerSettingsMetadata](#class-compilersettingsmetadata)* -*Defined in [ethereum-types/src/index.ts:91](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L91)* +*Defined in [ethereum-types/src/index.ts:690](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L690)* ___ -### outputs +### `Optional` optimizer -• **outputs**: *[DataItem](#class-dataitem)[]* +• **optimizer**? : *[OptimizerSettings](#class-optimizersettings)* -*Defined in [ethereum-types/src/index.ts:93](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L93)* +*Defined in [ethereum-types/src/index.ts:688](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L688)* ___ -### payable - -• **payable**: *boolean* +### outputSelection -*Defined in [ethereum-types/src/index.ts:96](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L96)* +• **outputSelection**: *object* -___ +*Defined in [ethereum-types/src/index.ts:696](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L696)* -### stateMutability +#### Type declaration: -• **stateMutability**: *[StateMutability](#statemutability)* +● \[▪ **fileName**: *string*\]: object -*Defined in [ethereum-types/src/index.ts:95](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L95)* +● \[▪ **contractName**: *string*\]: [OutputField](#outputfield)[] ___ -### type +### `Optional` remappings -• **type**: *string* +• **remappings**? : *string[]* -*Defined in [ethereum-types/src/index.ts:90](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L90)* +*Defined in [ethereum-types/src/index.ts:687](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L687)*
-# Interface: OptimizerSettings +# Interface: CompilerSettingsMetadata ## Properties -### enabled - -• **enabled**: *boolean* - -*Defined in [ethereum-types/src/index.ts:708](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L708)* - -___ - -### `Optional` runs +### useLiteralContent -• **runs**? : *undefined | number* +• **useLiteralContent**: *true* -*Defined in [ethereum-types/src/index.ts:709](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L709)* +*Defined in [ethereum-types/src/index.ts:704](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L704)*
+# Interface: ConstructorAbi +## Properties +### inputs -# Interface: RevertErrorAbi +• **inputs**: *[DataItem](#class-dataitem)[]* +*Defined in [ethereum-types/src/index.ts:103](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L103)* -## Properties +___ -### `Optional` arguments +### payable -• **arguments**? : *[DataItem](#class-dataitem)[]* +• **payable**: *boolean* -*Defined in [ethereum-types/src/index.ts:122](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L122)* +*Defined in [ethereum-types/src/index.ts:104](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L104)* ___ -### name +### stateMutability -• **name**: *string* +• **stateMutability**: *[ConstructorStateMutability](#constructorstatemutability)* -*Defined in [ethereum-types/src/index.ts:121](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L121)* +*Defined in [ethereum-types/src/index.ts:105](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L105)* ___ ### type -• **type**: *"error"* +• **type**: *string* -*Defined in [ethereum-types/src/index.ts:120](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L120)* +*Defined in [ethereum-types/src/index.ts:102](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L102)*
+# Interface: ContractArtifact + +This type defines the schema of the artifact.json file generated by Sol-compiler +schemaVersion: The version of the artifact schema +contractName: The contract name it represents +chains: Chain specific information by chain (address, id, constructor args, etc...) +compilerOutput: The Solidity compiler output generated from the specified compiler input +description (http://solidity.readthedocs.io/en/v0.4.24/using-the-compiler.html#compiler-input-and-output-json-description) +compiler: The compiler settings used +sourceCodes: The source code of the contract and all it's dependencies +sources: A mapping from source filePath to sourceMap id +sourceTreeHashHex: A unique hash generated from the contract source and that of it's dependencies. +If any of the sources change, the hash would change notifying us that a re-compilation is necessary + +## Properties +### chains +• **chains**: *[ContractChains](#class-contractchains)* +*Defined in [ethereum-types/src/index.ts:676](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L676)* +___ -# Interface: StandardContractOutput +### compiler +• **compiler**: *[CompilerOpts](#class-compileropts)* -## Properties +*Inherited from [ContractVersionData](#interface-contractversiondata).[compiler](#compiler)* -### abi +*Defined in [ethereum-types/src/index.ts:641](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L641)* -• **abi**: *[ContractAbi](#contractabi)* +___ + +### compilerOutput + +• **compilerOutput**: *[StandardContractOutput](#class-standardcontractoutput)* + +*Inherited from [ContractVersionData](#interface-contractversiondata).[compilerOutput](#compileroutput)* -*Defined in [ethereum-types/src/index.ts:564](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L564)* +*Defined in [ethereum-types/src/index.ts:651](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L651)* ___ -### `Optional` devdoc +### contractName -• **devdoc**? : *[DevdocOutput](#class-devdocoutput)* +• **contractName**: *string* -*Defined in [ethereum-types/src/index.ts:566](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L566)* +*Defined in [ethereum-types/src/index.ts:675](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L675)* ___ -### evm +### schemaVersion -• **evm**: *[EvmOutput](#class-evmoutput)* +• **schemaVersion**: *string* -*Defined in [ethereum-types/src/index.ts:565](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L565)* +*Defined in [ethereum-types/src/index.ts:674](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L674)* -
+___ +### sourceCodes +• **sourceCodes**: *object* +*Inherited from [ContractVersionData](#interface-contractversiondata).[sourceCodes](#sourcecodes)* +*Defined in [ethereum-types/src/index.ts:647](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L647)* +#### Type declaration: +● \[▪ **sourceName**: *string*\]: string +___ +### sourceTreeHashHex +• **sourceTreeHashHex**: *string* +*Inherited from [ContractVersionData](#interface-contractversiondata).[sourceTreeHashHex](#sourcetreehashhex)* +*Defined in [ethereum-types/src/index.ts:650](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L650)* +___ +### sources +• **sources**: *object* -# Interface: TupleDataItem +*Inherited from [ContractVersionData](#interface-contractversiondata).[sources](#sources)* +*Defined in [ethereum-types/src/index.ts:642](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L642)* -## Properties +#### Type declaration: -### components +● \[▪ **sourceName**: *string*\]: object -• **components**: *[DataItem](#class-dataitem)[]* +
-*Overrides [DataItem](_ethereum_types_src_index_.dataitem.md).[components](#optional-components)* +# Interface: ContractChainData -*Defined in [ethereum-types/src/index.ts:141](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L141)* -___ +## Properties -### name +### address -• **name**: *string* +• **address**: *string* -*Inherited from [DataItem](#interface-dataitem).[name](#name)* +*Defined in [ethereum-types/src/index.ts:554](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L554)* + +___ -*Defined in [ethereum-types/src/index.ts:135](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L135)* +Args + +• **constructorArgs**: *string* + +*Defined in [ethereum-types/src/index.ts:558](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L558)* ___ -### type +### links -• **type**: *string* +• **links**: *object* -*Inherited from [DataItem](#interface-dataitem).[type](#type)* +*Defined in [ethereum-types/src/index.ts:555](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L555)* + +#### Type declaration: -*Defined in [ethereum-types/src/index.ts:136](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L136)* +● \[▪ **linkName**: *string*\]: string
-# Interface: TxData +# Interface: ContractChains -## Properties +## Hierarchy -### `Optional` data +* **ContractVersionData** -• **data**? : *undefined | string* + * [ContractArtifact](#class-contractartifact) -*Inherited from [CallTxDataBase](#interface-calltxdatabase).[data](#optional-data)* -*Defined in [ethereum-types/src/index.ts:393](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L393)* +## Properties + +### compiler + +• **compiler**: *[CompilerOpts](#class-compileropts)* + +*Defined in [ethereum-types/src/index.ts:641](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L641)* ___ -### from +### compilerOutput -• **from**: *string* +• **compilerOutput**: *[StandardContractOutput](#class-standardcontractoutput)* -*Defined in [ethereum-types/src/index.ts:398](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L398)* +*Defined in [ethereum-types/src/index.ts:651](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L651)* ___ -### `Optional` gas +### sourceCodes -• **gas**? : *number | string | `BigNumber`* +• **sourceCodes**: *object* -*Inherited from [CallTxDataBase](#interface-calltxdatabase).[gas](#optional-gas)* +*Defined in [ethereum-types/src/index.ts:647](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L647)* -*Defined in [ethereum-types/src/index.ts:391](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L391)* +#### Type declaration: -___ +● \[▪ **sourceName**: *string*\]: string -### `Optional` gasPrice +___ -• **gasPrice**? : *number | string | `BigNumber`* +### sourceTreeHashHex -*Inherited from [CallTxDataBase](#interface-calltxdatabase).[gasPrice](#optional-gasprice)* +• **sourceTreeHashHex**: *string* -*Defined in [ethereum-types/src/index.ts:392](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L392)* +*Defined in [ethereum-types/src/index.ts:650](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L650)* ___ -### `Optional` nonce +### sources -• **nonce**? : *undefined | number* +• **sources**: *object* -*Inherited from [CallTxDataBase](#interface-calltxdatabase).[nonce](#optional-nonce)* +*Defined in [ethereum-types/src/index.ts:642](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L642)* -*Defined in [ethereum-types/src/index.ts:394](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L394)* +#### Type declaration: -___ +● \[▪ **sourceName**: *string*\]: object -### `Optional` to +
-• **to**? : *undefined | string* +# Interface: DataItem -*Inherited from [CallTxDataBase](#interface-calltxdatabase).[to](#optional-to)* -*Defined in [ethereum-types/src/index.ts:389](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L389)* +## Properties + +### `Optional` components + +• **components**? : *[DataItem](#class-dataitem)[]* + +*Defined in [ethereum-types/src/index.ts:137](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L137)* ___ -### `Optional` value +### name -• **value**? : *number | string | `BigNumber`* +• **name**: *string* -*Inherited from [CallTxDataBase](#interface-calltxdatabase).[value](#optional-value)* +*Defined in [ethereum-types/src/index.ts:135](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L135)* -*Defined in [ethereum-types/src/index.ts:390](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L390)* +___ -
+### type -# Interface: TxDataPayable +• **type**: *string* +*Defined in [ethereum-types/src/index.ts:136](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L136)* -## Properties +
-### `Optional` data +# Interface: DecodedLogArgs -• **data**? : *undefined | string* -*Inherited from [CallTxDataBase](#interface-calltxdatabase).[data](#optional-data)* +## Type parameters -*Defined in [ethereum-types/src/index.ts:393](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L393)* +▪ **A** -___ -### from +## Properties -• **from**: *string* +### address -*Inherited from [TxData](#interface-txdata).[from](#from)* +• **address**: *string* -*Defined in [ethereum-types/src/index.ts:398](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L398)* +*Inherited from [LogEntry](#interface-logentry).[address](#address)* -___ +*Defined in [ethereum-types/src/index.ts:434](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L434)* -### `Optional` gas +___ -• **gas**? : *number | string | `BigNumber`* +### args -*Inherited from [CallTxDataBase](#interface-calltxdatabase).[gas](#optional-gas)* +• **args**: *`A`* -*Defined in [ethereum-types/src/index.ts:391](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L391)* +*Defined in [ethereum-types/src/index.ts:417](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L417)* ___ -### `Optional` gasPrice +### blockHash -• **gasPrice**? : *number | string | `BigNumber`* +• **blockHash**: *string | null* -*Inherited from [CallTxDataBase](#interface-calltxdatabase).[gasPrice](#optional-gasprice)* +*Inherited from [LogEntry](#interface-logentry).[blockHash](#blockhash)* -*Defined in [ethereum-types/src/index.ts:392](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L392)* +*Defined in [ethereum-types/src/index.ts:432](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L432)* ___ -### `Optional` nonce +### blockNumber -• **nonce**? : *undefined | number* +• **blockNumber**: *number | null* -*Inherited from [CallTxDataBase](#interface-calltxdatabase).[nonce](#optional-nonce)* +*Inherited from [LogEntry](#interface-logentry).[blockNumber](#blocknumber)* -*Defined in [ethereum-types/src/index.ts:394](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L394)* +*Defined in [ethereum-types/src/index.ts:433](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L433)* ___ -### `Optional` to +### data -• **to**? : *undefined | string* +• **data**: *string* -*Inherited from [CallTxDataBase](#interface-calltxdatabase).[to](#optional-to)* +*Inherited from [LogEntry](#interface-logentry).[data](#data)* -*Defined in [ethereum-types/src/index.ts:389](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L389)* +*Defined in [ethereum-types/src/index.ts:435](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L435)* ___ -### `Optional` value - -• **value**? : *`BigNumber`* - -*Overrides [CallTxDataBase](_ethereum_types_src_index_.calltxdatabase.md).[value](#optional-value)* +### event -*Defined in [ethereum-types/src/index.ts:442](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L442)* +• **event**: *string* -
+*Defined in [ethereum-types/src/index.ts:416](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L416)* -# Interface: Web3JsV1Provider +___ -Web3.js version 1 provider interface -This provider interface was implemented in the pre-1.0Beta releases for Web3.js. -This interface allowed sending synchonous requests, support for which was later dropped. +### logIndex +• **logIndex**: *number | null* -## Methods +*Inherited from [LogEntry](#interface-logentry).[logIndex](#logindex)* -### send +*Defined in [ethereum-types/src/index.ts:429](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L429)* -▸ **send**(`payload`: [JSONRPCRequestPayload](_ethereum_types_src_index_.jsonrpcrequestpayload.md)): *[JSONRPCResponsePayload](#class-jsonrpcresponsepayload)* +___ -*Defined in [ethereum-types/src/index.ts:45](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L45)* +### topics -**Parameters:** +• **topics**: *string[]* -Name | Type | ------- | ------ | -`payload` | [JSONRPCRequestPayload](#class-jsonrpcrequestpayload) | +*Inherited from [LogEntry](#interface-logentry).[topics](#topics)* -**Returns:** *[JSONRPCResponsePayload](#class-jsonrpcresponsepayload)* +*Defined in [ethereum-types/src/index.ts:436](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L436)* ___ -### sendAsync +### transactionHash -▸ **sendAsync**(`payload`: [JSONRPCRequestPayload](_ethereum_types_src_index_.jsonrpcrequestpayload.md), `callback`: [JSONRPCErrorCallback](#jsonrpcerrorcallback)): *void* +• **transactionHash**: *string* -*Defined in [ethereum-types/src/index.ts:44](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L44)* +*Inherited from [LogEntry](#interface-logentry).[transactionHash](#transactionhash)* -**Parameters:** +*Defined in [ethereum-types/src/index.ts:431](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L431)* -Name | Type | ------- | ------ | -`payload` | [JSONRPCRequestPayload](#class-jsonrpcrequestpayload) | -`callback` | [JSONRPCErrorCallback](#jsonrpcerrorcallback) | +___ -**Returns:** *void* +### transactionIndex -
+• **transactionIndex**: *number | null* -# Interface: Web3JsV2Provider +*Inherited from [LogEntry](#interface-logentry).[transactionIndex](#transactionindex)* -Web3.js version 2 provider interface -This provider interface was used in a couple of Web3.js 1.0 beta releases -before the first attempts to conform to EIP1193 +*Defined in [ethereum-types/src/index.ts:430](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L430)* +
-## Methods -### send -▸ **send**(`payload`: [JSONRPCRequestPayload](_ethereum_types_src_index_.jsonrpcrequestpayload.md), `callback`: [JSONRPCErrorCallback](#jsonrpcerrorcallback)): *void* +# Interface: DevdocOutput -*Defined in [ethereum-types/src/index.ts:54](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L54)* -**Parameters:** +## Properties -Name | Type | ------- | ------ | -`payload` | [JSONRPCRequestPayload](#class-jsonrpcrequestpayload) | -`callback` | [JSONRPCErrorCallback](#jsonrpcerrorcallback) | +### `Optional` author -**Returns:** *void* +• **author**? : *undefined | string* -
+*Defined in [ethereum-types/src/index.ts:628](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L628)* -# Interface: Web3JsV3Provider +___ -Web3.js version 3 provider interface -This provider interface was implemented with the hopes for conforming to the EIP1193 spec, -however it does not conform entirely. +### methods +• **methods**: *object* -## Methods +*Defined in [ethereum-types/src/index.ts:629](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L629)* -### send +#### Type declaration: -▸ **send**(`method`: string, `params?`: any[]): *`Promise`* +● \[▪ **signature**: *string*\]: object -*Defined in [ethereum-types/src/index.ts:63](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L63)* +___ -**Parameters:** +### `Optional` title -Name | Type | ------- | ------ | -`method` | string | -`params?` | any[] | +• **title**? : *undefined | string* -**Returns:** *`Promise`* +*Defined in [ethereum-types/src/index.ts:627](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L627)*
-# Interface: ZeroExProvider - -The interface for the provider used internally by 0x libraries -Any property we use from any SupportedProvider should we explicitly -add here +# Interface: EIP1193Provider ## Properties -### `Optional` isMetaMask - -• **isMetaMask**? : *undefined | false | true* - -*Defined in [ethereum-types/src/index.ts:31](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L31)* +### isEIP1193 -___ +• **isEIP1193**: *boolean* -### `Optional` isParity +*Defined in [ethereum-types/src/index.ts:73](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L73)* -• **isParity**? : *undefined | false | true* +## Methods -*Defined in [ethereum-types/src/index.ts:32](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L32)* +### on -___ +▸ **on**(`event`: [EIP1193Event](#eip1193event), `listener`: function): *this* -### `Optional` isZeroExProvider +*Defined in [ethereum-types/src/index.ts:75](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L75)* -• **isZeroExProvider**? : *undefined | false | true* +**Parameters:** -*Defined in [ethereum-types/src/index.ts:30](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L30)* +▪ **event**: *[EIP1193Event](#eip1193event)* -## Methods +▪ **listener**: *function* -### `Optional` enable +▸ (`result`: any): *void* -▸ **enable**(): *`Promise`* +**Parameters:** -*Defined in [ethereum-types/src/index.ts:34](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L34)* +Name | Type | +------ | ------ | +`result` | any | -**Returns:** *`Promise`* +**Returns:** *this* ___ -### sendAsync +### send -▸ **sendAsync**(`payload`: [JSONRPCRequestPayload](_ethereum_types_src_index_.jsonrpcrequestpayload.md), `callback`: [JSONRPCErrorCallback](#jsonrpcerrorcallback)): *void* +▸ **send**(`method`: string, `params?`: any[]): *`Promise`* -*Defined in [ethereum-types/src/index.ts:35](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L35)* +*Defined in [ethereum-types/src/index.ts:74](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L74)* **Parameters:** Name | Type | ------ | ------ | -`payload` | [JSONRPCRequestPayload](#class-jsonrpcrequestpayload) | -`callback` | [JSONRPCErrorCallback](#jsonrpcerrorcallback) | +`method` | string | +`params?` | any[] | -**Returns:** *void* +**Returns:** *`Promise`* -___ +
-### `Optional` stop -▸ **stop**(): *void* -*Defined in [ethereum-types/src/index.ts:33](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L33)* -**Returns:** *void* -
+# Interface: EvmBytecodeOutput +## Properties +### object +• **object**: *string* +*Defined in [ethereum-types/src/index.ts:622](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L622)* +___ -# Class: DevUtilsContract +### sourceMap +• **sourceMap**: *string* -## Constructors +*Defined in [ethereum-types/src/index.ts:623](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L623)* +
+# Interface: EvmOutput -\+ **new DevUtilsContract**(`address`: string, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults?`: `Partial`, `logDecodeDependencies?`: undefined | object, `deployedBytecode`: string | undefined): *[DevUtilsContract](#class-devutilscontract)* -*Overrides void* +## Properties -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:3929](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L3929)* +### bytecode -**Parameters:** +• **bytecode**: *[EvmBytecodeOutput](#class-evmbytecodeoutput)* -Name | Type | Default | ------- | ------ | ------ | -`address` | string | - | -`supportedProvider` | [SupportedProvider](#supportedprovider) | - | -`txDefaults?` | `Partial` | - | -`logDecodeDependencies?` | undefined \| object | - | -`deployedBytecode` | string \| undefined | DevUtilsContract.deployedBytecode | +*Defined in [ethereum-types/src/index.ts:617](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L617)* -**Returns:** *[DevUtilsContract](#class-devutilscontract)* +___ -## Properties +### deployedBytecode -### `Optional` _deployedBytecodeIfExists +• **deployedBytecode**: *[EvmBytecodeOutput](#class-evmbytecodeoutput)* -• **_deployedBytecodeIfExists**? : *`Buffer`* +*Defined in [ethereum-types/src/index.ts:618](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L618)* +
+# Interface: FallbackAbi -Defined in base-contract/lib/src/index.d.ts:32 -___ +## Properties -### abi +### payable -• **abi**: *[ContractAbi](#contractabi)* +• **payable**: *boolean* +*Defined in [ethereum-types/src/index.ts:112](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L112)* +___ -Defined in base-contract/lib/src/index.d.ts:28 +### type -___ +• **type**: *string* -### address +*Defined in [ethereum-types/src/index.ts:111](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L111)* -• **address**: *string* +
-Defined in base-contract/lib/src/index.d.ts:29 +# Interface: GanacheProvider -___ -Args +## Methods -• **constructorArgs**: *any[]* +### sendAsync +▸ **sendAsync**(`payload`: [JSONRPCRequestPayload](_ethereum_types_src_index_.jsonrpcrequestpayload.md), `callback`: [JSONRPCErrorCallback](#jsonrpcerrorcallback)): *void* +*Defined in [ethereum-types/src/index.ts:14](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L14)* -Defined in base-contract/lib/src/index.d.ts:31 +**Parameters:** -___ +Name | Type | +------ | ------ | +`payload` | [JSONRPCRequestPayload](#class-jsonrpcrequestpayload) | +`callback` | [JSONRPCErrorCallback](#jsonrpcerrorcallback) | -### contractName +**Returns:** *void* -• **contractName**: *string* +
-Defined in base-contract/lib/src/index.d.ts:30 +# Interface: JSONRPCRequestPayload -## Methods -### decodeAssetProxyDispatchError +## Properties -▸ **decodeAssetProxyDispatchError**(`encoded`: string): *`ContractFunctionObj<[number, string, string]>`* +### id -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1516](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1516)* +• **id**: *number* -Decompose an ABI-encoded AssetProxyDispatchError. +*Defined in [ethereum-types/src/index.ts:330](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L330)* -**Parameters:** +___ -Name | Type | Description | ------- | ------ | ------ | -`encoded` | string | ABI-encoded revert error. | +### jsonrpc -**Returns:** *`ContractFunctionObj<[number, string, string]>`* +• **jsonrpc**: *string* -errorCode The error code.orderHash Hash of the order being dispatched.assetData Asset data of the order being dispatched. +*Defined in [ethereum-types/src/index.ts:331](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L331)* ___ -### decodeAssetProxyExistsError - -▸ **decodeAssetProxyExistsError**(`encoded`: string): *`ContractFunctionObj<[string, string]>`* +### method -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1564](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1564)* +• **method**: *string* -Decompose an ABI-encoded AssetProxyExistsError. +*Defined in [ethereum-types/src/index.ts:329](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L329)* -**Parameters:** +___ -Name | Type | Description | ------- | ------ | ------ | -`encoded` | string | ABI-encoded revert error. | +### params -**Returns:** *`ContractFunctionObj<[string, string]>`* +• **params**: *any[]* -assetProxyId Id of asset proxy.assetProxyAddress The address of the asset proxy. +*Defined in [ethereum-types/src/index.ts:328](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L328)* -___ +
-### decodeAssetProxyId +# Interface: JSONRPCResponseError -▸ **decodeAssetProxyId**(`assetData`: string): *`ContractFunctionObj`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1610](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1610)* +## Properties -Decode AssetProxy identifier +### code -**Parameters:** +• **code**: *number* -Name | Type | Description | ------- | ------ | ------ | -`assetData` | string | AssetProxy-compliant asset data describing an ERC-20, ERC- 721, ERC1155, or MultiAsset asset. | +*Defined in [ethereum-types/src/index.ts:336](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L336)* -**Returns:** *`ContractFunctionObj`* +___ -The AssetProxy identifier +### message -___ +• **message**: *string* -### decodeAssetProxyTransferError +*Defined in [ethereum-types/src/index.ts:335](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L335)* -▸ **decodeAssetProxyTransferError**(`encoded`: string): *`ContractFunctionObj<[string, string, string]>`* +
-*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1653](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1653)* +# Interface: JSONRPCResponsePayload -Decompose an ABI-encoded AssetProxyTransferError. -**Parameters:** +## Properties -Name | Type | Description | ------- | ------ | ------ | -`encoded` | string | ABI-encoded revert error. | +### `Optional` error -**Returns:** *`ContractFunctionObj<[string, string, string]>`* +• **error**? : *[JSONRPCResponseError](#class-jsonrpcresponseerror)* -orderHash Hash of the order being dispatched.assetData Asset data of the order being dispatched.errorData ABI-encoded revert data from the asset proxy. +*Defined in [ethereum-types/src/index.ts:343](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L343)* ___ -### decodeEIP1271SignatureError - -▸ **decodeEIP1271SignatureError**(`encoded`: string): *`ContractFunctionObj<[string, string, string, string]>`* +### id -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1701](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1701)* +• **id**: *number* -Decompose an ABI-encoded SignatureValidatorError. +*Defined in [ethereum-types/src/index.ts:341](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L341)* -**Parameters:** +___ -Name | Type | Description | ------- | ------ | ------ | -`encoded` | string | ABI-encoded revert error. | +### jsonrpc -**Returns:** *`ContractFunctionObj<[string, string, string, string]>`* +• **jsonrpc**: *string* -signerAddress The expected signer of the hash.signature The full signature bytes.errorData The revert data thrown by the validator contract. +*Defined in [ethereum-types/src/index.ts:342](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L342)* ___ -### decodeERC1155AssetData +### result -▸ **decodeERC1155AssetData**(`assetData`: string): *`ContractFunctionObj<[string, string, BigNumber[], BigNumber[], string]>`* +• **result**: *any* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1750](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1750)* +*Defined in [ethereum-types/src/index.ts:340](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L340)* -Decode ERC-1155 asset data from the format described in the AssetProxy contract specification. +
-**Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`assetData` | string | AssetProxy-compliant asset data describing an ERC-1155 set of assets. | -**Returns:** *`ContractFunctionObj<[string, string, BigNumber[], BigNumber[], string]>`* -The ERC-1155 AssetProxy identifier, the address of the ERC-1155 contract hosting the assets, an array of the identifiers of the assets to be traded, an array of asset amounts to be traded, and callback data. Each element of the arrays corresponds to the same-indexed element of the other array. Return values specified as `memory` are returned as pointers to locations within the memory of the input parameter `assetData`. -___ +# Interface: LogWithDecodedArgs <**ArgsType**> -### decodeERC20AssetData +## Type parameters -▸ **decodeERC20AssetData**(`assetData`: string): *`ContractFunctionObj<[string, string]>`* +▪ **ArgsType**: *[DecodedLogArgs](#class-decodedlogargs)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1802](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1802)* -Decode ERC-20 asset data from the format described in the AssetProxy contract specification. +## Properties -**Parameters:** +### address -Name | Type | Description | ------- | ------ | ------ | -`assetData` | string | AssetProxy-compliant asset data describing an ERC-20 asset. | +• **address**: *string* -**Returns:** *`ContractFunctionObj<[string, string]>`* +*Inherited from [LogEntry](#interface-logentry).[address](#address)* -The AssetProxy identifier, and the address of the ERC-20 contract hosting this asset. +*Defined in [ethereum-types/src/index.ts:434](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L434)* ___ -### decodeERC721AssetData +### args -▸ **decodeERC721AssetData**(`assetData`: string): *`ContractFunctionObj<[string, string, BigNumber]>`* +• **args**: *`ArgsType`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1848](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1848)* +*Inherited from [DecodedLogEntry](#interface-decodedlogentry).[args](#args)* -Decode ERC-721 asset data from the format described in the AssetProxy contract specification. +*Defined in [ethereum-types/src/index.ts:417](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L417)* -**Parameters:** +___ -Name | Type | Description | ------- | ------ | ------ | -`assetData` | string | AssetProxy-compliant asset data describing an ERC-721 asset. | +### blockHash -**Returns:** *`ContractFunctionObj<[string, string, BigNumber]>`* +• **blockHash**: *string | null* -The ERC-721 AssetProxy identifier, the address of the ERC-721 contract hosting this asset, and the identifier of the specific asset to be traded. +*Inherited from [LogEntry](#interface-logentry).[blockHash](#blockhash)* + +*Defined in [ethereum-types/src/index.ts:432](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L432)* ___ -### decodeExchangeInvalidContextError +### blockNumber -▸ **decodeExchangeInvalidContextError**(`encoded`: string): *`ContractFunctionObj<[number, string, string]>`* +• **blockNumber**: *number | null* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1896](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1896)* +*Inherited from [LogEntry](#interface-logentry).[blockNumber](#blocknumber)* -Decompose an ABI-encoded OrderStatusError. +*Defined in [ethereum-types/src/index.ts:433](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L433)* -**Parameters:** +___ -Name | Type | Description | ------- | ------ | ------ | -`encoded` | string | ABI-encoded revert error. | +### data -**Returns:** *`ContractFunctionObj<[number, string, string]>`* +• **data**: *string* -errorCode Error code that corresponds to invalid maker, taker, or sender.orderHash The order hash.contextAddress The maker, taker, or sender address +*Inherited from [LogEntry](#interface-logentry).[data](#data)* + +*Defined in [ethereum-types/src/index.ts:435](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L435)* ___ -### decodeFillError +### event -▸ **decodeFillError**(`encoded`: string): *`ContractFunctionObj<[number, string]>`* +• **event**: *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1945](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1945)* +*Inherited from [DecodedLogEntry](#interface-decodedlogentry).[event](#event)* -Decompose an ABI-encoded FillError. +*Defined in [ethereum-types/src/index.ts:416](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L416)* -**Parameters:** +___ -Name | Type | Description | ------- | ------ | ------ | -`encoded` | string | ABI-encoded revert error. | +### logIndex -**Returns:** *`ContractFunctionObj<[number, string]>`* +• **logIndex**: *number | null* -errorCode The error code.orderHash The order hash. +*Inherited from [LogEntry](#interface-logentry).[logIndex](#logindex)* -___ +*Defined in [ethereum-types/src/index.ts:429](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L429)* -### decodeIncompleteFillError +___ -▸ **decodeIncompleteFillError**(`encoded`: string): *`ContractFunctionObj<[number, BigNumber, BigNumber]>`* +### topics -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1988](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1988)* +• **topics**: *string[]* -Decompose an ABI-encoded IncompleteFillError. +*Inherited from [LogEntry](#interface-logentry).[topics](#topics)* -**Parameters:** +*Defined in [ethereum-types/src/index.ts:436](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L436)* -Name | Type | Description | ------- | ------ | ------ | -`encoded` | string | ABI-encoded revert error. | +___ -**Returns:** *`ContractFunctionObj<[number, BigNumber, BigNumber]>`* +### transactionHash -orderHash Hash of the order being filled. +• **transactionHash**: *string* -___ +*Inherited from [LogEntry](#interface-logentry).[transactionHash](#transactionhash)* -### decodeMultiAssetData +*Defined in [ethereum-types/src/index.ts:431](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L431)* -▸ **decodeMultiAssetData**(`assetData`: string): *`ContractFunctionObj<[string, BigNumber[], string[]]>`* +___ -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2036](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2036)* +### transactionIndex -Decode multi-asset data from the format described in the AssetProxy contract specification. +• **transactionIndex**: *number | null* -**Parameters:** +*Inherited from [LogEntry](#interface-logentry).[transactionIndex](#transactionindex)* -Name | Type | Description | ------- | ------ | ------ | -`assetData` | string | AssetProxy-compliant data describing a multi-asset basket. | +*Defined in [ethereum-types/src/index.ts:430](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L430)* -**Returns:** *`ContractFunctionObj<[string, BigNumber[], string[]]>`* +
-The Multi-Asset AssetProxy identifier, an array of the amounts of the assets to be traded, and an array of the AssetProxy-compliant data describing each asset to be traded. Each element of the arrays corresponds to the same-indexed element of the other array. +# Interface: MethodAbi -___ -### decodeNegativeSpreadError +## Properties -▸ **decodeNegativeSpreadError**(`encoded`: string): *`ContractFunctionObj<[string, string]>`* +### constant -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2084](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2084)* +• **constant**: *boolean* -Decompose an ABI-encoded NegativeSpreadError. +*Defined in [ethereum-types/src/index.ts:94](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L94)* -**Parameters:** +___ -Name | Type | Description | ------- | ------ | ------ | -`encoded` | string | ABI-encoded revert error. | +### inputs -**Returns:** *`ContractFunctionObj<[string, string]>`* +• **inputs**: *[DataItem](#class-dataitem)[]* -leftOrderHash Hash of the left order being matched.rightOrderHash Hash of the right order being matched. +*Defined in [ethereum-types/src/index.ts:92](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L92)* ___ -### decodeOrderEpochError - -▸ **decodeOrderEpochError**(`encoded`: string): *`ContractFunctionObj<[string, string, BigNumber]>`* +### name -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2129](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2129)* +• **name**: *string* -Decompose an ABI-encoded OrderEpochError. +*Defined in [ethereum-types/src/index.ts:91](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L91)* -**Parameters:** +___ -Name | Type | Description | ------- | ------ | ------ | -`encoded` | string | ABI-encoded revert error. | +### outputs -**Returns:** *`ContractFunctionObj<[string, string, BigNumber]>`* +• **outputs**: *[DataItem](#class-dataitem)[]* -makerAddress The order maker.orderSenderAddress The order sender.currentEpoch The current epoch for the maker. +*Defined in [ethereum-types/src/index.ts:93](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L93)* ___ -### decodeOrderStatusError - -▸ **decodeOrderStatusError**(`encoded`: string): *`ContractFunctionObj<[string, number]>`* +### payable -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2177](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2177)* +• **payable**: *boolean* -Decompose an ABI-encoded OrderStatusError. +*Defined in [ethereum-types/src/index.ts:96](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L96)* -**Parameters:** +___ -Name | Type | Description | ------- | ------ | ------ | -`encoded` | string | ABI-encoded revert error. | +### stateMutability -**Returns:** *`ContractFunctionObj<[string, number]>`* +• **stateMutability**: *[StateMutability](#statemutability)* -orderHash The order hash.orderStatus The order status. +*Defined in [ethereum-types/src/index.ts:95](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L95)* ___ -### decodeSignatureError - -▸ **decodeSignatureError**(`encoded`: string): *`ContractFunctionObj<[number, string, string, string]>`* +### type -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2222](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2222)* +• **type**: *string* -Decompose an ABI-encoded SignatureError. +*Defined in [ethereum-types/src/index.ts:90](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L90)* -**Parameters:** +
-Name | Type | Description | ------- | ------ | ------ | -`encoded` | string | ABI-encoded revert error. | +# Interface: OptimizerSettings -**Returns:** *`ContractFunctionObj<[number, string, string, string]>`* -errorCode The error code.signerAddress The expected signer of the hash.signature The full signature. +## Properties -___ +### enabled -### decodeSignatureValidatorNotApprovedError +• **enabled**: *boolean* -▸ **decodeSignatureValidatorNotApprovedError**(`encoded`: string): *`ContractFunctionObj<[string, string]>`* +*Defined in [ethereum-types/src/index.ts:708](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L708)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2268](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2268)* +___ -Decompose an ABI-encoded SignatureValidatorNotApprovedError. +### `Optional` runs -**Parameters:** +• **runs**? : *undefined | number* -Name | Type | Description | ------- | ------ | ------ | -`encoded` | string | ABI-encoded revert error. | +*Defined in [ethereum-types/src/index.ts:709](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L709)* -**Returns:** *`ContractFunctionObj<[string, string]>`* +
-signerAddress The expected signer of the hash.validatorAddress The expected validator. -___ -### decodeSignatureWalletError -▸ **decodeSignatureWalletError**(`encoded`: string): *`ContractFunctionObj<[string, string, string, string]>`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2316](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2316)* +# Interface: RevertErrorAbi -Decompose an ABI-encoded SignatureWalletError. -**Parameters:** +## Properties -Name | Type | Description | ------- | ------ | ------ | -`encoded` | string | ABI-encoded revert error. | +### `Optional` arguments -**Returns:** *`ContractFunctionObj<[string, string, string, string]>`* +• **arguments**? : *[DataItem](#class-dataitem)[]* -errorCode The error code.signerAddress The expected signer of the hash.signature The full signature bytes.errorData The revert data thrown by the validator contract. +*Defined in [ethereum-types/src/index.ts:122](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L122)* ___ -### decodeStaticCallAssetData - -▸ **decodeStaticCallAssetData**(`assetData`: string): *`ContractFunctionObj<[string, string, string, string]>`* - -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2365](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2365)* +### name -Decode StaticCall asset data from the format described in the AssetProxy contract specification. +• **name**: *string* -**Parameters:** +*Defined in [ethereum-types/src/index.ts:121](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L121)* -Name | Type | Description | ------- | ------ | ------ | -`assetData` | string | AssetProxy-compliant asset data describing a StaticCall asset | +___ -**Returns:** *`ContractFunctionObj<[string, string, string, string]>`* +### type -The StaticCall AssetProxy identifier, the target address of the StaticCAll, the data to be passed to the target address, and the expected Keccak-256 hash of the static call return data. +• **type**: *"error"* -___ +*Defined in [ethereum-types/src/index.ts:120](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L120)* -### decodeTransactionError +
-▸ **decodeTransactionError**(`encoded`: string): *`ContractFunctionObj<[number, string]>`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2413](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2413)* -Decompose an ABI-encoded TransactionError. -**Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`encoded` | string | ABI-encoded revert error. | -**Returns:** *`ContractFunctionObj<[number, string]>`* -errorCode The error code.transactionHash Hash of the transaction. +# Interface: StandardContractOutput -___ -### decodeTransactionExecutionError +## Properties -▸ **decodeTransactionExecutionError**(`encoded`: string): *`ContractFunctionObj<[string, string]>`* +### abi -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2458](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2458)* +• **abi**: *[ContractAbi](#contractabi)* -Decompose an ABI-encoded TransactionExecutionError. +*Defined in [ethereum-types/src/index.ts:564](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L564)* -**Parameters:** +___ -Name | Type | Description | ------- | ------ | ------ | -`encoded` | string | ABI-encoded revert error. | +### `Optional` devdoc -**Returns:** *`ContractFunctionObj<[string, string]>`* +• **devdoc**? : *[DevdocOutput](#class-devdocoutput)* -transactionHash Hash of the transaction.errorData Error thrown by exeucteTransaction(). +*Defined in [ethereum-types/src/index.ts:566](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L566)* ___ -### decodeZeroExTransactionData - -▸ **decodeZeroExTransactionData**(`transactionData`: string): *`ContractFunctionObj<[string, Array, BigNumber[], string[]]>`* +### evm -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2505](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2505)* +• **evm**: *[EvmOutput](#class-evmoutput)* -Decodes the call data for an Exchange contract method call. +*Defined in [ethereum-types/src/index.ts:565](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L565)* -**Parameters:** +
-Name | Type | Description | ------- | ------ | ------ | -`transactionData` | string | ABI-encoded calldata for an Exchange contract method call. | -**Returns:** *`ContractFunctionObj<[string, Array, BigNumber[], string[]]>`* -The name of the function called, and the parameters it was given. For single-order fills and cancels, the arrays will have just one element. -___ -### encodeERC1155AssetData -▸ **encodeERC1155AssetData**(`tokenAddress`: string, `tokenIds`: `BigNumber`[], `tokenValues`: `BigNumber`[], `callbackData`: string): *`ContractFunctionObj`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2628](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2628)* -Encode ERC-1155 asset data into the format described in the AssetProxy contract specification. -**Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`tokenAddress` | string | The address of the ERC-1155 contract hosting the asset(s) to be traded. | -`tokenIds` | `BigNumber`[] | The identifiers of the specific assets to be traded. | -`tokenValues` | `BigNumber`[] | The amounts of each asset to be traded. | -`callbackData` | string | Data to be passed to receiving contracts when a transfer is performed. | -**Returns:** *`ContractFunctionObj`* -AssetProxy-compliant asset data describing the set of assets. -___ -### encodeERC20AssetData -▸ **encodeERC20AssetData**(`tokenAddress`: string): *`ContractFunctionObj`* +# Interface: TupleDataItem -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2686](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2686)* -Encode ERC-20 asset data into the format described in the AssetProxy contract specification. +## Properties -**Parameters:** +### components -Name | Type | Description | ------- | ------ | ------ | -`tokenAddress` | string | The address of the ERC-20 contract hosting the asset to be traded. | +• **components**: *[DataItem](#class-dataitem)[]* -**Returns:** *`ContractFunctionObj`* +*Overrides [DataItem](_ethereum_types_src_index_.dataitem.md).[components](#optional-components)* -AssetProxy-compliant data describing the asset. +*Defined in [ethereum-types/src/index.ts:141](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L141)* ___ -### encodeERC721AssetData +### name -▸ **encodeERC721AssetData**(`tokenAddress`: string, `tokenId`: `BigNumber`): *`ContractFunctionObj`* +• **name**: *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2735](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2735)* +*Inherited from [DataItem](#interface-dataitem).[name](#name)* -Encode ERC-721 asset data into the format described in the AssetProxy specification. +*Defined in [ethereum-types/src/index.ts:135](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L135)* -**Parameters:** +___ -Name | Type | Description | ------- | ------ | ------ | -`tokenAddress` | string | The address of the ERC-721 contract hosting the asset to be traded. | -`tokenId` | `BigNumber` | The identifier of the specific asset to be traded. | +### type -**Returns:** *`ContractFunctionObj`* +• **type**: *string* -AssetProxy-compliant asset data describing the asset. +*Inherited from [DataItem](#interface-dataitem).[type](#type)* -___ +*Defined in [ethereum-types/src/index.ts:136](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L136)* -### encodeMultiAssetData +
-▸ **encodeMultiAssetData**(`amounts`: `BigNumber`[], `nestedAssetData`: string[]): *`ContractFunctionObj`* +# Interface: TxData -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2787](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2787)* -Encode data for multiple assets, per the AssetProxy contract specification. +## Properties -**Parameters:** +### `Optional` data -Name | Type | Description | ------- | ------ | ------ | -`amounts` | `BigNumber`[] | The amounts of each asset to be traded. | -`nestedAssetData` | string[] | AssetProxy-compliant data describing each asset to be traded. | +• **data**? : *undefined | string* -**Returns:** *`ContractFunctionObj`* +*Inherited from [CallTxDataBase](#interface-calltxdatabase).[data](#optional-data)* -AssetProxy-compliant data describing the set of assets. +*Defined in [ethereum-types/src/index.ts:393](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L393)* ___ -### encodeStaticCallAssetData +### from -▸ **encodeStaticCallAssetData**(`staticCallTargetAddress`: string, `staticCallData`: string, `expectedReturnDataHash`: string): *`ContractFunctionObj`* +• **from**: *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2841](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2841)* +*Defined in [ethereum-types/src/index.ts:398](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L398)* -Encode StaticCall asset data into the format described in the AssetProxy contract specification. +___ -**Parameters:** +### `Optional` gas -Name | Type | Description | ------- | ------ | ------ | -`staticCallTargetAddress` | string | Target address of StaticCall. | -`staticCallData` | string | Data that will be passed to staticCallTargetAddress in the StaticCall. | -`expectedReturnDataHash` | string | Expected Keccak-256 hash of the StaticCall return data. | +• **gas**? : *number | string | `BigNumber`* -**Returns:** *`ContractFunctionObj`* +*Inherited from [CallTxDataBase](#interface-calltxdatabase).[gas](#optional-gas)* -AssetProxy-compliant asset data describing the set of assets. +*Defined in [ethereum-types/src/index.ts:391](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L391)* ___ -### getABIDecodedReturnData +### `Optional` gasPrice -▸ **getABIDecodedReturnData**<**T**>(`methodName`: string, `callData`: string): *`T`* +• **gasPrice**? : *number | string | `BigNumber`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1497](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1497)* +*Inherited from [CallTxDataBase](#interface-calltxdatabase).[gasPrice](#optional-gasprice)* -**Type parameters:** +*Defined in [ethereum-types/src/index.ts:392](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L392)* -▪ **T** +___ -**Parameters:** +### `Optional` nonce -Name | Type | ------- | ------ | -`methodName` | string | -`callData` | string | +• **nonce**? : *undefined | number* + +*Inherited from [CallTxDataBase](#interface-calltxdatabase).[nonce](#optional-nonce)* -**Returns:** *`T`* +*Defined in [ethereum-types/src/index.ts:394](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L394)* ___ -### getABIDecodedTransactionData +### `Optional` to -▸ **getABIDecodedTransactionData**<**T**>(`methodName`: string, `callData`: string): *`T`* +• **to**? : *undefined | string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1490](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1490)* +*Inherited from [CallTxDataBase](#interface-calltxdatabase).[to](#optional-to)* -**Type parameters:** +*Defined in [ethereum-types/src/index.ts:389](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L389)* -▪ **T** +___ -**Parameters:** +### `Optional` value -Name | Type | ------- | ------ | -`methodName` | string | -`callData` | string | +• **value**? : *number | string | `BigNumber`* -**Returns:** *`T`* +*Inherited from [CallTxDataBase](#interface-calltxdatabase).[value](#optional-value)* -___ +*Defined in [ethereum-types/src/index.ts:390](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L390)* -### getAssetProxyAllowance +
-▸ **getAssetProxyAllowance**(`ownerAddress`: string, `assetData`: string): *`ContractFunctionObj`* +# Interface: TxDataPayable -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2899](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2899)* -Returns the number of asset(s) (described by assetData) that the corresponding AssetProxy contract is authorized to spend. When the asset data contains multiple assets (eg for Multi-Asset), the return value indicates how many complete "baskets" of those assets may be spent by all of the corresponding AssetProxy contracts. +## Properties -**Parameters:** +### `Optional` data -Name | Type | Description | ------- | ------ | ------ | -`ownerAddress` | string | Owner of the assets specified by assetData. | -`assetData` | string | Details of asset, encoded per the AssetProxy contract specification. | +• **data**? : *undefined | string* -**Returns:** *`ContractFunctionObj`* +*Inherited from [CallTxDataBase](#interface-calltxdatabase).[data](#optional-data)* -Number of assets (or asset baskets) that the corresponding AssetProxy is authorized to spend. +*Defined in [ethereum-types/src/index.ts:393](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L393)* ___ -### getBalance +### from + +• **from**: *string* -▸ **getBalance**(`ownerAddress`: string, `assetData`: string): *`ContractFunctionObj`* +*Inherited from [TxData](#interface-txdata).[from](#from)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2961](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2961)* +*Defined in [ethereum-types/src/index.ts:398](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L398)* -Returns the owner's balance of the assets(s) specified in assetData. When the asset data contains multiple assets (eg in ERC1155 or Multi-Asset), the return value indicates how many complete "baskets" of those assets are owned by owner. +___ -**Parameters:** +### `Optional` gas -Name | Type | Description | ------- | ------ | ------ | -`ownerAddress` | string | Owner of the assets specified by assetData. | -`assetData` | string | Details of asset, encoded per the AssetProxy contract specification. | +• **gas**? : *number | string | `BigNumber`* -**Returns:** *`ContractFunctionObj`* +*Inherited from [CallTxDataBase](#interface-calltxdatabase).[gas](#optional-gas)* -Number of assets (or asset baskets) held by owner. +*Defined in [ethereum-types/src/index.ts:391](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L391)* ___ -### getBalanceAndAssetProxyAllowance +### `Optional` gasPrice -▸ **getBalanceAndAssetProxyAllowance**(`ownerAddress`: string, `assetData`: string): *`ContractFunctionObj<[BigNumber, BigNumber]>`* +• **gasPrice**? : *number | string | `BigNumber`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:3023](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L3023)* +*Inherited from [CallTxDataBase](#interface-calltxdatabase).[gasPrice](#optional-gasprice)* -Calls getBalance() and getAllowance() for assetData. +*Defined in [ethereum-types/src/index.ts:392](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L392)* -**Parameters:** +___ -Name | Type | Description | ------- | ------ | ------ | -`ownerAddress` | string | Owner of the assets specified by assetData. | -`assetData` | string | Details of asset, encoded per the AssetProxy contract specification. | +### `Optional` nonce -**Returns:** *`ContractFunctionObj<[BigNumber, BigNumber]>`* +• **nonce**? : *undefined | number* -Number of assets (or asset baskets) held by owner, and number of assets (or asset baskets) that the corresponding AssetProxy is authorized to spend. +*Inherited from [CallTxDataBase](#interface-calltxdatabase).[nonce](#optional-nonce)* + +*Defined in [ethereum-types/src/index.ts:394](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L394)* ___ -### getBatchAssetProxyAllowances +### `Optional` to -▸ **getBatchAssetProxyAllowances**(`ownerAddress`: string, `assetData`: string[]): *`ContractFunctionObj`* +• **to**? : *undefined | string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:3091](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L3091)* +*Inherited from [CallTxDataBase](#interface-calltxdatabase).[to](#optional-to)* -Calls getAssetProxyAllowance() for each element of assetData. +*Defined in [ethereum-types/src/index.ts:389](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L389)* -**Parameters:** +___ -Name | Type | Description | ------- | ------ | ------ | -`ownerAddress` | string | Owner of the assets specified by assetData. | -`assetData` | string[] | Array of asset details, each encoded per the AssetProxy contract specification. | +### `Optional` value -**Returns:** *`ContractFunctionObj`* +• **value**? : *`BigNumber`* -An array of asset allowances from getAllowance(), with each element corresponding to the same-indexed element in the assetData input. +*Overrides [CallTxDataBase](_ethereum_types_src_index_.calltxdatabase.md).[value](#optional-value)* -___ +*Defined in [ethereum-types/src/index.ts:442](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L442)* -### getBatchBalances +
-▸ **getBatchBalances**(`ownerAddress`: string, `assetData`: string[]): *`ContractFunctionObj`* +# Interface: Web3JsV1Provider -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:3153](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L3153)* +Web3.js version 1 provider interface +This provider interface was implemented in the pre-1.0Beta releases for Web3.js. +This interface allowed sending synchonous requests, support for which was later dropped. -Calls getBalance() for each element of assetData. -**Parameters:** +## Methods -Name | Type | Description | ------- | ------ | ------ | -`ownerAddress` | string | Owner of the assets specified by assetData. | -`assetData` | string[] | Array of asset details, each encoded per the AssetProxy contract specification. | +### send -**Returns:** *`ContractFunctionObj`* +▸ **send**(`payload`: [JSONRPCRequestPayload](_ethereum_types_src_index_.jsonrpcrequestpayload.md)): *[JSONRPCResponsePayload](#class-jsonrpcresponsepayload)* -Array of asset balances from getBalance(), with each element corresponding to the same-indexed element in the assetData input. +*Defined in [ethereum-types/src/index.ts:45](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L45)* -___ +**Parameters:** -### getBatchBalancesAndAssetProxyAllowances +Name | Type | +------ | ------ | +`payload` | [JSONRPCRequestPayload](#class-jsonrpcrequestpayload) | -▸ **getBatchBalancesAndAssetProxyAllowances**(`ownerAddress`: string, `assetData`: string[]): *`ContractFunctionObj<[BigNumber[], BigNumber[]]>`* +**Returns:** *[JSONRPCResponsePayload](#class-jsonrpcresponsepayload)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:3215](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L3215)* +___ -Calls getBatchBalances() and getBatchAllowances() for each element of assetData. +### sendAsync + +▸ **sendAsync**(`payload`: [JSONRPCRequestPayload](_ethereum_types_src_index_.jsonrpcrequestpayload.md), `callback`: [JSONRPCErrorCallback](#jsonrpcerrorcallback)): *void* + +*Defined in [ethereum-types/src/index.ts:44](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L44)* **Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`ownerAddress` | string | Owner of the assets specified by assetData. | -`assetData` | string[] | Array of asset details, each encoded per the AssetProxy contract specification. | +Name | Type | +------ | ------ | +`payload` | [JSONRPCRequestPayload](#class-jsonrpcrequestpayload) | +`callback` | [JSONRPCErrorCallback](#jsonrpcerrorcallback) | -**Returns:** *`ContractFunctionObj<[BigNumber[], BigNumber[]]>`* +**Returns:** *void* -An array of asset balances from getBalance(), and an array of asset allowances from getAllowance(), with each element corresponding to the same-indexed element in the assetData input. +
-___ +# Interface: Web3JsV2Provider + +Web3.js version 2 provider interface +This provider interface was used in a couple of Web3.js 1.0 beta releases +before the first attempts to conform to EIP1193 -### getEthBalances -▸ **getEthBalances**(`addresses`: string[]): *`ContractFunctionObj`* +## Methods -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:3281](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L3281)* +### send -Batch fetches ETH balances +▸ **send**(`payload`: [JSONRPCRequestPayload](_ethereum_types_src_index_.jsonrpcrequestpayload.md), `callback`: [JSONRPCErrorCallback](#jsonrpcerrorcallback)): *void* + +*Defined in [ethereum-types/src/index.ts:54](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L54)* **Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`addresses` | string[] | Array of addresses. | +Name | Type | +------ | ------ | +`payload` | [JSONRPCRequestPayload](#class-jsonrpcrequestpayload) | +`callback` | [JSONRPCErrorCallback](#jsonrpcerrorcallback) | + +**Returns:** *void* -**Returns:** *`ContractFunctionObj`* +
-Array of ETH balances. +# Interface: Web3JsV3Provider -___ +Web3.js version 3 provider interface +This provider interface was implemented with the hopes for conforming to the EIP1193 spec, +however it does not conform entirely. -### getFunctionSignature -▸ **getFunctionSignature**(`methodName`: string): *string* +## Methods + +### send + +▸ **send**(`method`: string, `params?`: any[]): *`Promise`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1484](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1484)* +*Defined in [ethereum-types/src/index.ts:63](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L63)* **Parameters:** Name | Type | ------ | ------ | -`methodName` | string | +`method` | string | +`params?` | any[] | -**Returns:** *string* +**Returns:** *`Promise`* -___ +
-### getOrderRelevantState +# Interface: ZeroExProvider -▸ **getOrderRelevantState**(`order`: object, `signature`: string): *`ContractFunctionObj<[object, BigNumber, boolean]>`* +The interface for the provider used internally by 0x libraries +Any property we use from any SupportedProvider should we explicitly +add here -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:3337](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L3337)* -Fetches all order-relevant information needed to validate if the supplied order is fillable. +## Properties -**Parameters:** +### `Optional` isMetaMask -Name | Type | Description | ------- | ------ | ------ | -`order` | object | The order structure. | -`signature` | string | Signature provided by maker that proves the order's authenticity. `0x01` can always be provided if the signature does not need to be validated. | +• **isMetaMask**? : *undefined | false | true* -**Returns:** *`ContractFunctionObj<[object, BigNumber, boolean]>`* +*Defined in [ethereum-types/src/index.ts:31](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L31)* -The orderInfo (hash, status, and `takerAssetAmount` already filled for the given order), fillableTakerAssetAmount (amount of the order's `takerAssetAmount` that is fillable given all on-chain state), and isValidSignature (validity of the provided signature). NOTE: If the `takerAssetData` encodes data for multiple assets, `fillableTakerAssetAmount` will represent a "scaled" amount, meaning it must be multiplied by all the individual asset amounts within the `takerAssetData` to get the final amount of each asset that can be filled. +___ + +### `Optional` isParity + +• **isParity**? : *undefined | false | true* + +*Defined in [ethereum-types/src/index.ts:32](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L32)* ___ -### getOrderRelevantStates +### `Optional` isZeroExProvider -▸ **getOrderRelevantStates**(`orders`: `Array`, `signatures`: string[]): *`ContractFunctionObj<[Array, BigNumber[], boolean[]]>`* +• **isZeroExProvider**? : *undefined | false | true* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:3433](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L3433)* +*Defined in [ethereum-types/src/index.ts:30](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L30)* -Fetches all order-relevant information needed to validate if the supplied orders are fillable. +## Methods -**Parameters:** +### `Optional` enable -Name | Type | Description | ------- | ------ | ------ | -`orders` | `Array` | Array of order structures. | -`signatures` | string[] | Array of signatures provided by makers that prove the authenticity of the orders. `0x01` can always be provided if a signature does not need to be validated. | +▸ **enable**(): *`Promise`* -**Returns:** *`ContractFunctionObj<[Array, BigNumber[], boolean[]]>`* +*Defined in [ethereum-types/src/index.ts:34](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L34)* -The ordersInfo (array of the hash, status, and `takerAssetAmount` already filled for each order), fillableTakerAssetAmounts (array of amounts for each order's `takerAssetAmount` that is fillable given all on-chain state), and isValidSignature (array containing the validity of each provided signature). NOTE: If the `takerAssetData` encodes data for multiple assets, each element of `fillableTakerAssetAmounts` will represent a "scaled" amount, meaning it must be multiplied by all the individual asset amounts within the `takerAssetData` to get the final amount of each asset that can be filled. +**Returns:** *`Promise`* ___ -### getSelector +### sendAsync -▸ **getSelector**(`methodName`: string): *string* +▸ **sendAsync**(`payload`: [JSONRPCRequestPayload](_ethereum_types_src_index_.jsonrpcrequestpayload.md), `callback`: [JSONRPCErrorCallback](#jsonrpcerrorcallback)): *void* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1504](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1504)* +*Defined in [ethereum-types/src/index.ts:35](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L35)* **Parameters:** Name | Type | ------ | ------ | -`methodName` | string | +`payload` | [JSONRPCRequestPayload](#class-jsonrpcrequestpayload) | +`callback` | [JSONRPCErrorCallback](#jsonrpcerrorcallback) | -**Returns:** *string* +**Returns:** *void* ___ -### getSimulatedOrderTransferResults - -▸ **getSimulatedOrderTransferResults**(`order`: object, `takerAddress`: string, `takerAssetFillAmount`: `BigNumber`): *`ContractTxFunctionObj`* +### `Optional` stop -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:3537](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L3537)* +▸ **stop**(): *void* -Simulates all of the transfers within an order and returns the index of the first failed transfer. +*Defined in [ethereum-types/src/index.ts:33](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L33)* -**Parameters:** +**Returns:** *void* -Name | Type | Description | ------- | ------ | ------ | -`order` | object | The order to simulate transfers for. | -`takerAddress` | string | The address of the taker that will fill the order. | -`takerAssetFillAmount` | `BigNumber` | The amount of takerAsset that the taker wished to fill. | +
-**Returns:** *`ContractTxFunctionObj`* -The index of the first failed transfer (or 4 if all transfers are successful). -___ -### getSimulatedOrdersTransferResults -▸ **getSimulatedOrdersTransferResults**(`orders`: `Array`, `takerAddresses`: string[], `takerAssetFillAmounts`: `BigNumber`[]): *`ContractTxFunctionObj`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:3687](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L3687)* -Simulates all of the transfers for each given order and returns the indices of each first failed transfer. +# Interface: JSONRPCRequestPayloadWithMethod -**Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`orders` | `Array` | Array of orders to individually simulate transfers for. | -`takerAddresses` | string[] | Array of addresses of takers that will fill each order. | -`takerAssetFillAmounts` | `BigNumber`[] | Array of amounts of takerAsset that will be filled for each order. | +## Properties -**Returns:** *`ContractTxFunctionObj`* +### id -The indices of the first failed transfer (or 4 if all transfers are successful) for each order. +• **id**: *number* -___ -### getTransferableAssetAmount -▸ **getTransferableAssetAmount**(`ownerAddress`: string, `assetData`: string): *`ContractFunctionObj`* +Defined in ethereum-types/lib/index.d.ts:267 -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:3835](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L3835)* +___ -Gets the amount of an asset transferable by the owner. +### jsonrpc -**Parameters:** +• **jsonrpc**: *string* -Name | Type | Description | ------- | ------ | ------ | -`ownerAddress` | string | Address of the owner of the asset. | -`assetData` | string | Description of tokens, per the AssetProxy contract specification. | -**Returns:** *`ContractFunctionObj`* -The amount of the asset tranferable by the owner. NOTE: If the `assetData` encodes data for multiple assets, the `transferableAssetAmount` will represent the amount of times the entire `assetData` can be transferred. To calculate the total individual transferable amounts, this scaled `transferableAmount` must be multiplied by the individual asset amounts located within the `assetData`. +Defined in ethereum-types/lib/index.d.ts:268 ___ -### revertIfInvalidAssetData - -▸ **revertIfInvalidAssetData**(`assetData`: string): *`ContractFunctionObj`* - -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:3890](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L3890)* +### method -**Parameters:** +• **method**: *string* -Name | Type | ------- | ------ | -`assetData` | string | +*Overrides void* -**Returns:** *`ContractFunctionObj`* +*Defined in [subproviders/src/types.ts:136](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/types.ts#L136)* ___ -### `Static` ABI - -▸ **ABI**(): *[ContractAbi](#contractabi)* - -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:125](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L125)* - -**Returns:** *[ContractAbi](#contractabi)* +### params -The contract ABI +• **params**: *any[]* -___ -### `Static` deployAsync -▸ **deployAsync**(`bytecode`: string, `abi`: [ContractAbi](#contractabi), `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object, `_exchange`: string): *`Promise`* +Defined in ethereum-types/lib/index.d.ts:265 -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:78](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L78)* +
-**Parameters:** -Name | Type | ------- | ------ | -`bytecode` | string | -`abi` | [ContractAbi](#contractabi) | -`supportedProvider` | [SupportedProvider](#supportedprovider) | -`txDefaults` | `Partial` | -`logDecodeDependencies` | object | -`_exchange` | string | -**Returns:** *`Promise`* -___ -### `Static` deployFrom0xArtifactAsync -▸ **deployFrom0xArtifactAsync**(`artifact`: `ContractArtifact` | `SimpleContractArtifact`, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object, `_exchange`: string): *`Promise`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:45](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L45)* -**Parameters:** -Name | Type | ------- | ------ | -`artifact` | `ContractArtifact` \| `SimpleContractArtifact` | -`supportedProvider` | [SupportedProvider](#supportedprovider) | -`txDefaults` | `Partial` | -`logDecodeDependencies` | object | -`_exchange` | string | -**Returns:** *`Promise`* -___ -### `Static` strictArgumentEncodingCheck -▸ **strictArgumentEncodingCheck**(`inputAbi`: `DataItem`[], `args`: any[]): *string* -Defined in base-contract/lib/src/index.d.ts:42 -**Parameters:** -Name | Type | ------- | ------ | -`inputAbi` | `DataItem`[] | -`args` | any[] | -**Returns:** *string* -
@@ -7284,25 +12632,46 @@ Name | Type | +# Interface: AwaitTransactionSuccessOpts +Used with `awaitTransactionSuccessAsync` +* pollingIntervalMs: Determine polling intervals in milliseconds +* timeoutMs: Determines timeout in milliseconds +## Properties +### `Optional` pollingIntervalMs +• **pollingIntervalMs**? : *undefined | number* +*Overrides [SendTransactionOpts](_types_src_index_.sendtransactionopts.md).[pollingIntervalMs](#optional-pollingintervalms)* +*Defined in [types/src/index.ts:877](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L877)* +___ +### `Optional` shouldValidate +• **shouldValidate**? : *undefined | false | true* +*Inherited from [SendTransactionOpts](#interface-sendtransactionopts).[shouldValidate](#optional-shouldvalidate)* +*Overrides [SendTransactionOpts](_types_src_index_.sendtransactionopts.md).[shouldValidate](#optional-shouldvalidate)* +*Defined in [types/src/index.ts:680](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L680)* +___ +### `Optional` timeoutMs +• **timeoutMs**? : *undefined | number* +*Overrides [SendTransactionOpts](_types_src_index_.sendtransactionopts.md).[timeoutMs](#optional-timeoutms)* +*Defined in [types/src/index.ts:878](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L878)* +
@@ -7327,7 +12696,7 @@ Name | Type | • **isRemoved**: *boolean* -*Defined in [types/src/index.ts:844](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L844)* +*Defined in [types/src/index.ts:844](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L844)* ___ @@ -7335,7 +12704,7 @@ ___ • **log**: *`LogWithDecodedArgs`* -*Defined in [types/src/index.ts:845](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L845)* +*Defined in [types/src/index.ts:845](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L845)*
@@ -7350,7 +12719,7 @@ ___ • **assetData**: *[AssetData](#assetdata)* -*Defined in [types/src/index.ts:219](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L219)* +*Defined in [types/src/index.ts:219](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L219)* ___ @@ -7358,7 +12727,7 @@ ___ • **beginAmount**: *`BigNumber`* -*Defined in [types/src/index.ts:221](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L221)* +*Defined in [types/src/index.ts:221](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L221)* ___ @@ -7366,7 +12735,7 @@ ___ • **beginTimeSeconds**: *`BigNumber`* -*Defined in [types/src/index.ts:220](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L220)* +*Defined in [types/src/index.ts:220](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L220)*
@@ -7383,7 +12752,7 @@ Elliptic Curve signature • **r**: *string* -*Defined in [types/src/index.ts:62](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L62)* +*Defined in [types/src/index.ts:62](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L62)* ___ @@ -7391,7 +12760,7 @@ ___ • **s**: *string* -*Defined in [types/src/index.ts:63](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L63)* +*Defined in [types/src/index.ts:63](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L63)* ___ @@ -7399,7 +12768,7 @@ ___ • **v**: *number* -*Defined in [types/src/index.ts:61](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L61)* +*Defined in [types/src/index.ts:61](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L61)*
@@ -7412,7 +12781,7 @@ ___ • **chainId**: *number* -*Defined in [types/src/index.ts:793](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L793)* +*Defined in [types/src/index.ts:793](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L793)* ___ @@ -7420,7 +12789,7 @@ ___ • **name**? : *undefined | string* -*Defined in [types/src/index.ts:791](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L791)* +*Defined in [types/src/index.ts:791](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L791)* ___ @@ -7428,7 +12797,7 @@ ___ • **verifyingContract**: *string* -*Defined in [types/src/index.ts:794](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L794)* +*Defined in [types/src/index.ts:794](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L794)* ___ @@ -7436,7 +12805,7 @@ ___ • **version**? : *undefined | string* -*Defined in [types/src/index.ts:792](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L792)* +*Defined in [types/src/index.ts:792](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L792)*
@@ -7455,7 +12824,7 @@ ___ • **assetProxyId**: *string* -*Defined in [types/src/index.ts:183](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L183)* +*Defined in [types/src/index.ts:183](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L183)* ___ @@ -7463,7 +12832,7 @@ ___ • **callbackData**: *string* -*Defined in [types/src/index.ts:187](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L187)* +*Defined in [types/src/index.ts:187](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L187)* ___ @@ -7471,7 +12840,7 @@ ___ • **tokenAddress**: *string* -*Defined in [types/src/index.ts:184](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L184)* +*Defined in [types/src/index.ts:184](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L184)* ___ @@ -7479,7 +12848,7 @@ ___ • **tokenIds**: *`BigNumber`[]* -*Defined in [types/src/index.ts:185](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L185)* +*Defined in [types/src/index.ts:185](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L185)* ___ @@ -7487,7 +12856,7 @@ ___ • **tokenValues**: *`BigNumber`[]* -*Defined in [types/src/index.ts:186](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L186)* +*Defined in [types/src/index.ts:186](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L186)*
@@ -7502,7 +12871,7 @@ ___ • **assetProxyId**: *string* -*Defined in [types/src/index.ts:172](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L172)* +*Defined in [types/src/index.ts:172](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L172)* ___ @@ -7510,7 +12879,7 @@ ___ • **tokenAddress**: *string* -*Defined in [types/src/index.ts:173](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L173)* +*Defined in [types/src/index.ts:173](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L173)*
@@ -7523,7 +12892,7 @@ ___ • **assetProxyId**: *string* -*Defined in [types/src/index.ts:177](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L177)* +*Defined in [types/src/index.ts:177](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L177)* ___ @@ -7531,7 +12900,7 @@ ___ • **tokenAddress**: *string* -*Defined in [types/src/index.ts:178](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L178)* +*Defined in [types/src/index.ts:178](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L178)* ___ @@ -7539,7 +12908,7 @@ ___ • **tokenId**: *`BigNumber`* -*Defined in [types/src/index.ts:179](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L179)* +*Defined in [types/src/index.ts:179](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L179)*
@@ -7567,7 +12936,7 @@ ___ • **keyName**: *string* -*Defined in [types/src/index.ts:691](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L691)* +*Defined in [types/src/index.ts:691](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L691)* ___ @@ -7575,7 +12944,7 @@ ___ • **keyType**: *[Type](#class-type)* -*Defined in [types/src/index.ts:692](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L692)* +*Defined in [types/src/index.ts:692](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L692)* ___ @@ -7583,7 +12952,7 @@ ___ • **valueName**: *string* -*Defined in [types/src/index.ts:693](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L693)* +*Defined in [types/src/index.ts:693](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L693)*
@@ -7600,7 +12969,7 @@ ___ • **amounts**: *`BigNumber`[]* -*Defined in [types/src/index.ts:208](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L208)* +*Defined in [types/src/index.ts:208](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L208)* ___ @@ -7608,7 +12977,7 @@ ___ • **assetProxyId**: *string* -*Defined in [types/src/index.ts:207](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L207)* +*Defined in [types/src/index.ts:207](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L207)* ___ @@ -7616,7 +12985,7 @@ ___ • **nestedAssetData**: *string[]* -*Defined in [types/src/index.ts:209](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L209)* +*Defined in [types/src/index.ts:209](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L209)*
@@ -7629,7 +12998,7 @@ ___ • **amounts**: *`BigNumber`[]* -*Defined in [types/src/index.ts:214](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L214)* +*Defined in [types/src/index.ts:214](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L214)* ___ @@ -7637,7 +13006,7 @@ ___ • **assetProxyId**: *string* -*Defined in [types/src/index.ts:213](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L213)* +*Defined in [types/src/index.ts:213](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L213)* ___ @@ -7645,7 +13014,7 @@ ___ • **nestedAssetData**: *[SingleAssetData](#singleassetdata)[]* -*Defined in [types/src/index.ts:215](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L215)* +*Defined in [types/src/index.ts:215](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L215)*
@@ -7685,7 +13054,44 @@ ___ +# Interface: SendTransactionOpts + +* shouldValidate: Flag indicating whether the library should make attempts to validate a transaction before +broadcasting it. For example, order has a valid signature, maker has sufficient funds, etc. Default=true. +* pollingIntervalMs: Used with `awaitTransactionSuccessAsync` to determine polling interval in milliseconds +* timeoutMs: Used with `awaitTransactionSuccessAsync` to determine timeout in milliseconds +Used with `sendTransactionAsync` +* shouldValidate: Flag indicating whether the library should make attempts to validate a transaction before +broadcasting it. For example, order has a valid signature, maker has sufficient funds, etc. Default=true. + + +## Properties + +### `Optional` pollingIntervalMs + +• **pollingIntervalMs**? : *undefined | number* + +*Defined in [types/src/index.ts:681](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L681)* + +___ + +### `Optional` shouldValidate + +• **shouldValidate**? : *undefined | false | true* + +*Defined in [types/src/index.ts:680](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L680)* + +*Defined in [types/src/index.ts:868](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L868)* + +___ + +### `Optional` timeoutMs + +• **timeoutMs**? : *undefined | number* + +*Defined in [types/src/index.ts:682](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L682)* +
# Interface: SignedOrder @@ -7698,7 +13104,7 @@ ___ *Inherited from [Order](#interface-order).[chainId](#chainid)* -*Defined in [types/src/index.ts:14](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L14)* +*Defined in [types/src/index.ts:14](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L14)* ___ @@ -7708,7 +13114,7 @@ ___ *Inherited from [Order](#interface-order).[exchangeAddress](#exchangeaddress)* -*Defined in [types/src/index.ts:15](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L15)* +*Defined in [types/src/index.ts:15](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L15)* ___ @@ -7718,7 +13124,7 @@ ___ *Inherited from [Order](#interface-order).[expirationTimeSeconds](#expirationtimeseconds)* -*Defined in [types/src/index.ts:24](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L24)* +*Defined in [types/src/index.ts:24](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L24)* ___ @@ -7728,7 +13134,7 @@ ___ *Inherited from [Order](#interface-order).[feeRecipientAddress](#feerecipientaddress)* -*Defined in [types/src/index.ts:18](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L18)* +*Defined in [types/src/index.ts:18](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L18)* ___ @@ -7738,7 +13144,7 @@ ___ *Inherited from [Order](#interface-order).[makerAddress](#makeraddress)* -*Defined in [types/src/index.ts:16](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L16)* +*Defined in [types/src/index.ts:16](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L16)* ___ @@ -7748,7 +13154,7 @@ ___ *Inherited from [Order](#interface-order).[makerAssetAmount](#makerassetamount)* -*Defined in [types/src/index.ts:20](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L20)* +*Defined in [types/src/index.ts:20](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L20)* ___ @@ -7758,7 +13164,7 @@ ___ *Inherited from [Order](#interface-order).[makerAssetData](#makerassetdata)* -*Defined in [types/src/index.ts:26](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L26)* +*Defined in [types/src/index.ts:26](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L26)* ___ @@ -7768,7 +13174,7 @@ ___ *Inherited from [Order](#interface-order).[makerFee](#makerfee)* -*Defined in [types/src/index.ts:22](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L22)* +*Defined in [types/src/index.ts:22](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L22)* ___ @@ -7778,7 +13184,7 @@ ___ *Inherited from [Order](#interface-order).[makerFeeAssetData](#makerfeeassetdata)* -*Defined in [types/src/index.ts:28](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L28)* +*Defined in [types/src/index.ts:28](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L28)* ___ @@ -7788,7 +13194,7 @@ ___ *Inherited from [Order](#interface-order).[salt](#salt)* -*Defined in [types/src/index.ts:25](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L25)* +*Defined in [types/src/index.ts:25](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L25)* ___ @@ -7798,7 +13204,7 @@ ___ *Inherited from [Order](#interface-order).[senderAddress](#senderaddress)* -*Defined in [types/src/index.ts:19](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L19)* +*Defined in [types/src/index.ts:19](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L19)* ___ @@ -7806,7 +13212,7 @@ ___ • **signature**: *string* -*Defined in [types/src/index.ts:33](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L33)* +*Defined in [types/src/index.ts:33](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L33)* ___ @@ -7816,7 +13222,7 @@ ___ *Inherited from [Order](#interface-order).[takerAddress](#takeraddress)* -*Defined in [types/src/index.ts:17](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L17)* +*Defined in [types/src/index.ts:17](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L17)* ___ @@ -7826,7 +13232,7 @@ ___ *Inherited from [Order](#interface-order).[takerAssetAmount](#takerassetamount)* -*Defined in [types/src/index.ts:21](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L21)* +*Defined in [types/src/index.ts:21](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L21)* ___ @@ -7836,7 +13242,7 @@ ___ *Inherited from [Order](#interface-order).[takerAssetData](#takerassetdata)* -*Defined in [types/src/index.ts:27](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L27)* +*Defined in [types/src/index.ts:27](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L27)* ___ @@ -7846,7 +13252,7 @@ ___ *Inherited from [Order](#interface-order).[takerFee](#takerfee)* -*Defined in [types/src/index.ts:23](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L23)* +*Defined in [types/src/index.ts:23](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L23)* ___ @@ -7856,7 +13262,7 @@ ___ *Inherited from [Order](#interface-order).[takerFeeAssetData](#takerfeeassetdata)* -*Defined in [types/src/index.ts:29](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L29)* +*Defined in [types/src/index.ts:29](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L29)*
@@ -7871,7 +13277,7 @@ ___ *Inherited from [ZeroExTransaction](#interface-zeroextransaction).[data](#data)* -*Defined in [types/src/index.ts:49](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L49)* +*Defined in [types/src/index.ts:49](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L49)* ___ @@ -7881,7 +13287,7 @@ ___ *Inherited from [ZeroExTransaction](#interface-zeroextransaction).[domain](#domain)* -*Defined in [types/src/index.ts:50](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L50)* +*Defined in [types/src/index.ts:50](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L50)* ___ @@ -7891,7 +13297,7 @@ ___ *Inherited from [ZeroExTransaction](#interface-zeroextransaction).[expirationTimeSeconds](#expirationtimeseconds)* -*Defined in [types/src/index.ts:46](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L46)* +*Defined in [types/src/index.ts:46](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L46)* ___ @@ -7901,7 +13307,7 @@ ___ *Inherited from [ZeroExTransaction](#interface-zeroextransaction).[gasPrice](#gasprice)* -*Defined in [types/src/index.ts:47](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L47)* +*Defined in [types/src/index.ts:47](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L47)* ___ @@ -7911,7 +13317,7 @@ ___ *Inherited from [ZeroExTransaction](#interface-zeroextransaction).[salt](#salt)* -*Defined in [types/src/index.ts:45](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L45)* +*Defined in [types/src/index.ts:45](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L45)* ___ @@ -7919,7 +13325,7 @@ ___ • **signature**: *string* -*Defined in [types/src/index.ts:54](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L54)* +*Defined in [types/src/index.ts:54](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L54)* ___ @@ -7929,7 +13335,7 @@ ___ *Inherited from [ZeroExTransaction](#interface-zeroextransaction).[signerAddress](#signeraddress)* -*Defined in [types/src/index.ts:48](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L48)* +*Defined in [types/src/index.ts:48](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L48)*
@@ -7942,7 +13348,7 @@ ___ • **chains**: *`ContractChains`* -*Defined in [types/src/index.ts:861](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L861)* +*Defined in [types/src/index.ts:885](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L885)* ___ @@ -7950,7 +13356,7 @@ ___ • **compilerOutput**: *[SimpleStandardContractOutput](#class-simplestandardcontractoutput)* -*Defined in [types/src/index.ts:860](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L860)* +*Defined in [types/src/index.ts:884](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L884)* ___ @@ -7958,7 +13364,7 @@ ___ • **contractName**: *string* -*Defined in [types/src/index.ts:859](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L859)* +*Defined in [types/src/index.ts:883](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L883)* ___ @@ -7966,7 +13372,7 @@ ___ • **schemaVersion**: *string* -*Defined in [types/src/index.ts:858](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L858)* +*Defined in [types/src/index.ts:882](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L882)*
@@ -7979,7 +13385,7 @@ ___ • **object**: *string* -*Defined in [types/src/index.ts:875](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L875)* +*Defined in [types/src/index.ts:899](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L899)*
@@ -7992,7 +13398,7 @@ ___ • **bytecode**: *[SimpleEvmBytecodeOutput](#class-simpleevmbytecodeoutput)* -*Defined in [types/src/index.ts:871](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L871)* +*Defined in [types/src/index.ts:895](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L895)*
@@ -8005,7 +13411,7 @@ ___ • **abi**: *[ContractAbi](#contractabi)* -*Defined in [types/src/index.ts:865](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L865)* +*Defined in [types/src/index.ts:889](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L889)* ___ @@ -8013,7 +13419,7 @@ ___ • **devdoc**? : *[DevdocOutput](#class-devdocoutput)* -*Defined in [types/src/index.ts:867](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L867)* +*Defined in [types/src/index.ts:891](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L891)* ___ @@ -8021,7 +13427,7 @@ ___ • **evm**: *[SimpleEvmOutput](#class-simpleevmoutput)* -*Defined in [types/src/index.ts:866](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L866)* +*Defined in [types/src/index.ts:890](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L890)*
@@ -8038,7 +13444,7 @@ ___ • **assetProxyId**: *string* -*Defined in [types/src/index.ts:191](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L191)* +*Defined in [types/src/index.ts:191](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L191)* ___ @@ -8046,7 +13452,7 @@ ___ • **callResultHash**: *string* -*Defined in [types/src/index.ts:194](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L194)* +*Defined in [types/src/index.ts:194](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L194)* ___ @@ -8054,7 +13460,7 @@ ___ • **callTarget**: *string* -*Defined in [types/src/index.ts:192](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L192)* +*Defined in [types/src/index.ts:192](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L192)* ___ @@ -8062,7 +13468,7 @@ ___ • **staticCallData**: *string* -*Defined in [types/src/index.ts:193](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L193)* +*Defined in [types/src/index.ts:193](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L193)*
@@ -8103,7 +13509,7 @@ Validator signature components • **signature**: *string* -*Defined in [types/src/index.ts:71](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L71)* +*Defined in [types/src/index.ts:71](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L71)* ___ @@ -8111,7 +13517,7 @@ ___ • **validatorAddress**: *string* -*Defined in [types/src/index.ts:70](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L70)* +*Defined in [types/src/index.ts:70](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L70)*
@@ -8126,7 +13532,7 @@ ZeroExTransaction for use with 0x Exchange executeTransaction • **data**: *string* -*Defined in [types/src/index.ts:49](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L49)* +*Defined in [types/src/index.ts:49](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L49)* ___ @@ -8134,7 +13540,7 @@ ___ • **domain**: *[EIP712DomainWithDefaultSchema](#class-eip712domainwithdefaultschema)* -*Defined in [types/src/index.ts:50](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L50)* +*Defined in [types/src/index.ts:50](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L50)* ___ @@ -8142,7 +13548,7 @@ ___ • **expirationTimeSeconds**: *`BigNumber`* -*Defined in [types/src/index.ts:46](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L46)* +*Defined in [types/src/index.ts:46](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L46)* ___ @@ -8150,7 +13556,7 @@ ___ • **gasPrice**: *`BigNumber`* -*Defined in [types/src/index.ts:47](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L47)* +*Defined in [types/src/index.ts:47](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L47)* ___ @@ -8158,7 +13564,7 @@ ___ • **salt**: *`BigNumber`* -*Defined in [types/src/index.ts:45](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L45)* +*Defined in [types/src/index.ts:45](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L45)* ___ @@ -8166,63 +13572,7 @@ ___ • **signerAddress**: *string* -*Defined in [types/src/index.ts:48](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L48)* - -
- - - - -## Type aliases - - - -### AssetData - -Ƭ **AssetData**: *[SingleAssetData](_types_src_index_.md#singleassetdata) | [MultiAssetData](#interface-multiassetdata) | [MultiAssetDataWithRecursiveDecoding](#interface-multiassetdatawithrecursivedecoding)* - -*Defined in [types/src/index.ts:224](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L224)* - -___ - - - - - - - -### EventCallback - -Ƭ **EventCallback**: *function* - -*Defined in [types/src/index.ts:848](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L848)* - -#### Type declaration: - -▸ (`err`: null | `Error`, `log?`: [DecodedLogEvent](#interface-decodedlogevent)‹*`ArgsType`*›): *void* - -**Parameters:** - -Name | Type | ------- | ------ | -`err` | null \| `Error` | -`log?` | [DecodedLogEvent](#interface-decodedlogevent)‹*`ArgsType`*› | - -___ - - - - - - - - - -### SingleAssetData - -Ƭ **SingleAssetData**: *[ERC20AssetData](#interface-erc20assetdata) | [ERC721AssetData](#interface-erc721assetdata) | [ERC1155AssetData](#interface-erc1155assetdata) | [StaticCallAssetData](#interface-staticcallassetdata)* - -*Defined in [types/src/index.ts:204](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L204)* +*Defined in [types/src/index.ts:48](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L48)*
@@ -8239,7 +13589,7 @@ ___ Ƭ **ERC20TokenEventArgs**: *[ERC20TokenTransferEventArgs](#interface-erc20tokentransfereventargs) | [ERC20TokenApprovalEventArgs](#interface-erc20tokenapprovaleventargs)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:37](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L37)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:34](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L34)*
@@ -8252,7 +13602,7 @@ ___ Ƭ **ERC721TokenEventArgs**: *[ERC721TokenApprovalEventArgs](#interface-erc721tokenapprovaleventargs) | [ERC721TokenApprovalForAllEventArgs](#interface-erc721tokenapprovalforalleventargs) | [ERC721TokenTransferEventArgs](#interface-erc721tokentransfereventargs)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:37](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L37)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:34](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L34)*
@@ -8265,7 +13615,7 @@ ___ Ƭ **ExchangeEventArgs**: *[ExchangeAssetProxyRegisteredEventArgs](#interface-exchangeassetproxyregisteredeventargs) | [ExchangeCancelEventArgs](#interface-exchangecanceleventargs) | [ExchangeCancelUpToEventArgs](#interface-exchangecanceluptoeventargs) | [ExchangeFillEventArgs](#interface-exchangefilleventargs) | [ExchangeProtocolFeeCollectorAddressEventArgs](#interface-exchangeprotocolfeecollectoraddresseventargs) | [ExchangeProtocolFeeMultiplierEventArgs](#interface-exchangeprotocolfeemultipliereventargs) | [ExchangeSignatureValidatorApprovalEventArgs](#interface-exchangesignaturevalidatorapprovaleventargs) | [ExchangeTransactionExecutionEventArgs](#interface-exchangetransactionexecutioneventargs)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:37](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L37)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:34](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L34)*
@@ -8286,7 +13636,7 @@ ___ Ƭ **WETH9EventArgs**: *[WETH9ApprovalEventArgs](#interface-weth9approvaleventargs) | [WETH9TransferEventArgs](#interface-weth9transfereventargs) | [WETH9DepositEventArgs](#interface-weth9depositeventargs) | [WETH9WithdrawalEventArgs](#interface-weth9withdrawaleventargs)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:37](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L37)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:34](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L34)*
@@ -8295,7 +13645,13 @@ ___ ## Type aliases +### ZRXTokenEventArgs +Ƭ **ZRXTokenEventArgs**: *[ZRXTokenTransferEventArgs](#interface-zrxtokentransfereventargs) | [ZRXTokenApprovalEventArgs](#interface-zrxtokenapprovaleventargs)* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:34](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L34)* + +
@@ -8306,7 +13662,7 @@ ___ ▸ **getContractAddressesForChainOrThrow**(`chainId`: [ChainId](#enumeration-chainid)): *[ContractAddresses](#interface-contractaddresses)* -*Defined in [contract-addresses/src/index.ts:45](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L45)* +*Defined in [contract-addresses/src/index.ts:45](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L45)* Used to get addresses of contracts that have been deployed to either the Ethereum mainnet or a supported testnet. Throws if there are no known @@ -8334,7 +13690,7 @@ given chainId. Ƭ **AbiDefinition**: *[FunctionAbi](_ethereum_types_src_index_.md#functionabi) | [EventAbi](#interface-eventabi) | [RevertErrorAbi](#interface-reverterrorabi)* -*Defined in [ethereum-types/src/index.ts:80](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L80)* +*Defined in [ethereum-types/src/index.ts:80](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L80)* ___ @@ -8342,7 +13698,7 @@ ___ Ƭ **BlockParam**: *[BlockParamLiteral](#enumeration-blockparamliteral) | number* -*Defined in [ethereum-types/src/index.ts:483](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L483)* +*Defined in [ethereum-types/src/index.ts:483](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L483)* ___ @@ -8350,7 +13706,7 @@ ___ Ƭ **ConstructorStateMutability**: *"nonpayable" | "payable"* -*Defined in [ethereum-types/src/index.ts:84](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L84)* +*Defined in [ethereum-types/src/index.ts:84](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L84)* ___ @@ -8358,7 +13714,7 @@ ___ Ƭ **ContractAbi**: *[AbiDefinition](#abidefinition)[]* -*Defined in [ethereum-types/src/index.ts:78](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L78)* +*Defined in [ethereum-types/src/index.ts:78](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L78)* ___ @@ -8366,7 +13722,7 @@ ___ Ƭ **ContractEventArg**: *any* -*Defined in [ethereum-types/src/index.ts:468](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L468)* +*Defined in [ethereum-types/src/index.ts:468](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L468)* ___ @@ -8376,7 +13732,7 @@ ___ Ƭ **EIP1193Event**: *"accountsChanged" | "networkChanged" | "close" | "connect" | "notification"* -*Defined in [ethereum-types/src/index.ts:70](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L70)* +*Defined in [ethereum-types/src/index.ts:70](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L70)* Interface for providers that conform to EIP 1193 Source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1193.md @@ -8391,7 +13747,7 @@ ___ Ƭ **FunctionAbi**: *[MethodAbi](#interface-methodabi) | [ConstructorAbi](#interface-constructorabi) | [FallbackAbi](#interface-fallbackabi)* -*Defined in [ethereum-types/src/index.ts:82](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L82)* +*Defined in [ethereum-types/src/index.ts:82](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L82)* ___ @@ -8399,7 +13755,7 @@ ___ Ƭ **JSONRPCErrorCallback**: *function* -*Defined in [ethereum-types/src/index.ts:3](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L3)* +*Defined in [ethereum-types/src/index.ts:3](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L3)* #### Type declaration: @@ -8420,7 +13776,7 @@ ___ Ƭ **OutputField**: *"*" | "ast" | "legacyAST" | "abi" | "devdoc" | "userdoc" | "metadata" | "ir" | "evm.assembly" | "evm.legacyAssembly" | "evm.bytecode.object" | "evm.bytecode.opcodes" | "evm.bytecode.sourceMap" | "evm.bytecode.linkReferences" | "evm.deployedBytecode.object" | "evm.deployedBytecode.opcodes" | "evm.deployedBytecode.sourceMap" | "evm.deployedBytecode.linkReferences" | "evm.methodIdentifiers" | "evm.gasEstimates" | "ewasm.wast" | "ewasm.wasm"* -*Defined in [ethereum-types/src/index.ts:525](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L525)* +*Defined in [ethereum-types/src/index.ts:525](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L525)* ___ @@ -8428,7 +13784,7 @@ ___ Ƭ **ParamDescription**: *string* -*Defined in [ethereum-types/src/index.ts:561](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L561)* +*Defined in [ethereum-types/src/index.ts:561](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L561)* ___ @@ -8438,7 +13794,7 @@ ___ Ƭ **StateMutability**: *"pure" | "view" | [ConstructorStateMutability](#constructorstatemutability)* -*Defined in [ethereum-types/src/index.ts:85](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L85)* +*Defined in [ethereum-types/src/index.ts:85](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L85)* ___ @@ -8446,7 +13802,7 @@ ___ Ƭ **SupportedProvider**: *[Web3JsProvider](_ethereum_types_src_index_.md#web3jsprovider) | [GanacheProvider](#interface-ganacheprovider) | [EIP1193Provider](#interface-eip1193provider) | [ZeroExProvider](#interface-zeroexprovider)* -*Defined in [ethereum-types/src/index.ts:9](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L9)* +*Defined in [ethereum-types/src/index.ts:9](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L9)* Do not create your own provider. Use an existing provider from a Web3 or ProviderEngine library Read more about Providers in the guides section of the 0x docs. @@ -8461,7 +13817,7 @@ ___ Ƭ **Web3JsProvider**: *[Web3JsV1Provider](#interface-web3jsv1provider) | [Web3JsV2Provider](#interface-web3jsv2provider) | [Web3JsV3Provider](#interface-web3jsv3provider)* -*Defined in [ethereum-types/src/index.ts:11](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L11)* +*Defined in [ethereum-types/src/index.ts:11](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L11)*
@@ -8474,13 +13830,13 @@ ___ #### ▪ **assetDataUtils**: *object* -*Defined in [order-utils/src/asset_data_utils.ts:23](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/asset_data_utils.ts#L23)* +*Defined in [order-utils/src/asset_data_utils.ts:23](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/asset_data_utils.ts#L23)* #### assertIsERC1155AssetData ▸ **assertIsERC1155AssetData**(`assetData`: string): *void* -*Defined in [order-utils/src/asset_data_utils.ts:397](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/asset_data_utils.ts#L397)* +*Defined in [order-utils/src/asset_data_utils.ts:397](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/asset_data_utils.ts#L397)* Throws if the assetData is not ERC1155. @@ -8496,7 +13852,7 @@ Name | Type | Description | ▸ **assertIsERC20AssetData**(`assetData`: string): *void* -*Defined in [order-utils/src/asset_data_utils.ts:353](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/asset_data_utils.ts#L353)* +*Defined in [order-utils/src/asset_data_utils.ts:353](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/asset_data_utils.ts#L353)* Throws if the length or assetProxyId are invalid for the ERC20Proxy. @@ -8512,7 +13868,7 @@ Name | Type | Description | ▸ **assertIsERC721AssetData**(`assetData`: string): *void* -*Defined in [order-utils/src/asset_data_utils.ts:375](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/asset_data_utils.ts#L375)* +*Defined in [order-utils/src/asset_data_utils.ts:375](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/asset_data_utils.ts#L375)* Throws if the length or assetProxyId are invalid for the ERC721Proxy. @@ -8528,7 +13884,7 @@ Name | Type | Description | ▸ **assertIsMultiAssetData**(`assetData`: string): *void* -*Defined in [order-utils/src/asset_data_utils.ts:419](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/asset_data_utils.ts#L419)* +*Defined in [order-utils/src/asset_data_utils.ts:419](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/asset_data_utils.ts#L419)* Throws if the length or assetProxyId are invalid for the MultiAssetProxy. @@ -8544,7 +13900,7 @@ Name | Type | Description | ▸ **assertIsStaticCallAssetData**(`assetData`: string): *void* -*Defined in [order-utils/src/asset_data_utils.ts:441](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/asset_data_utils.ts#L441)* +*Defined in [order-utils/src/asset_data_utils.ts:441](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/asset_data_utils.ts#L441)* Throws if the assetData is not StaticCallData. @@ -8560,7 +13916,7 @@ Name | Type | Description | ▸ **assertWordAlignedAssetData**(`assetData`: string): *void* -*Defined in [order-utils/src/asset_data_utils.ts:463](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/asset_data_utils.ts#L463)* +*Defined in [order-utils/src/asset_data_utils.ts:463](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/asset_data_utils.ts#L463)* Throws if the assetData is not padded to 32 bytes. @@ -8576,7 +13932,7 @@ Name | Type | Description | ▸ **decodeAssetDataOrThrow**(`assetData`: string): *[SingleAssetData](#singleassetdata) | `MultiAssetData`* -*Defined in [order-utils/src/asset_data_utils.ts:502](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/asset_data_utils.ts#L502)* +*Defined in [order-utils/src/asset_data_utils.ts:502](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/asset_data_utils.ts#L502)* Decode any assetData into its corresponding assetData object @@ -8594,7 +13950,7 @@ Either a ERC20, ERC721, ERC1155, or MultiAsset assetData object ▸ **decodeAssetProxyId**(`assetData`: string): *`AssetProxyId`* -*Defined in [order-utils/src/asset_data_utils.ts:294](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/asset_data_utils.ts#L294)* +*Defined in [order-utils/src/asset_data_utils.ts:294](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/asset_data_utils.ts#L294)* Decode and return the assetProxyId from the assetData @@ -8612,7 +13968,7 @@ The assetProxyId ▸ **decodeDutchAuctionData**(`dutchAuctionData`: string): *`DutchAuctionData`* -*Defined in [order-utils/src/asset_data_utils.ts:263](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/asset_data_utils.ts#L263)* +*Defined in [order-utils/src/asset_data_utils.ts:263](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/asset_data_utils.ts#L263)* Dutch auction details are encoded with the asset data for a 0x order. This function decodes a hex encoded assetData string, containing information both about the asset being traded and the @@ -8632,7 +13988,7 @@ An object containing the auction asset, auction begin time and auction begin amo ▸ **decodeERC1155AssetData**(`assetData`: string): *`ERC1155AssetData`* -*Defined in [order-utils/src/asset_data_utils.ts:107](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/asset_data_utils.ts#L107)* +*Defined in [order-utils/src/asset_data_utils.ts:107](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/asset_data_utils.ts#L107)* Decodes an ERC1155 assetData hex string into its corresponding ERC1155 components. @@ -8650,7 +14006,7 @@ An object containing the decoded tokenAddress, tokenIds, tokenValues, callbackDa ▸ **decodeERC20AssetData**(`assetData`: string): *`ERC20AssetData`* -*Defined in [order-utils/src/asset_data_utils.ts:41](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/asset_data_utils.ts#L41)* +*Defined in [order-utils/src/asset_data_utils.ts:41](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/asset_data_utils.ts#L41)* Decodes an ERC20 assetData hex string into its corresponding ERC20 tokenAddress & assetProxyId @@ -8668,7 +14024,7 @@ An object containing the decoded tokenAddress & assetProxyId ▸ **decodeERC721AssetData**(`assetData`: string): *`ERC721AssetData`* -*Defined in [order-utils/src/asset_data_utils.ts:70](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/asset_data_utils.ts#L70)* +*Defined in [order-utils/src/asset_data_utils.ts:70](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/asset_data_utils.ts#L70)* Decodes an ERC721 assetData hex string into its corresponding ERC721 tokenAddress, tokenId & assetProxyId @@ -8686,7 +14042,7 @@ An object containing the decoded tokenAddress, tokenId & assetProxyId ▸ **decodeMultiAssetData**(`assetData`: string): *`MultiAssetData`* -*Defined in [order-utils/src/asset_data_utils.ts:149](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/asset_data_utils.ts#L149)* +*Defined in [order-utils/src/asset_data_utils.ts:149](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/asset_data_utils.ts#L149)* Decodes a MultiAsset assetData hex string into its corresponding amounts and nestedAssetData @@ -8704,7 +14060,7 @@ An object containing the decoded amounts and nestedAssetData ▸ **decodeMultiAssetDataRecursively**(`assetData`: string): *`MultiAssetDataWithRecursiveDecoding`* -*Defined in [order-utils/src/asset_data_utils.ts:175](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/asset_data_utils.ts#L175)* +*Defined in [order-utils/src/asset_data_utils.ts:175](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/asset_data_utils.ts#L175)* Decodes a MultiAsset assetData hex string into its corresponding amounts and decoded nestedAssetData elements (all nested elements are flattened) @@ -8722,7 +14078,7 @@ An object containing the decoded amounts and nestedAssetData ▸ **decodeStaticCallAssetData**(`assetData`: string): *`StaticCallAssetData`* -*Defined in [order-utils/src/asset_data_utils.ts:225](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/asset_data_utils.ts#L225)* +*Defined in [order-utils/src/asset_data_utils.ts:225](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/asset_data_utils.ts#L225)* Decoded StaticCall assetData into its corresponding callTarget, staticCallData, and expected callResultHash @@ -8740,7 +14096,7 @@ An object containing the decoded callTarget, staticCallData, and expected callRe ▸ **encodeDutchAuctionAssetData**(`assetData`: string, `beginTimeSeconds`: `BigNumber`, `beginAmount`: `BigNumber`): *string* -*Defined in [order-utils/src/asset_data_utils.ts:245](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/asset_data_utils.ts#L245)* +*Defined in [order-utils/src/asset_data_utils.ts:245](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/asset_data_utils.ts#L245)* Dutch auction details are encoded with the asset data for a 0x order. This function produces a hex encoded assetData string, containing information both about the asset being traded and the @@ -8762,7 +14118,7 @@ The hex encoded assetData string. ▸ **encodeERC1155AssetData**(`tokenAddress`: string, `tokenIds`: `BigNumber`[], `tokenValues`: `BigNumber`[], `callbackData`: string): *string* -*Defined in [order-utils/src/asset_data_utils.ts:91](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/asset_data_utils.ts#L91)* +*Defined in [order-utils/src/asset_data_utils.ts:91](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/asset_data_utils.ts#L91)* Encodes a set of ERC1155 assets into an assetData string, usable in the makerAssetData or takerAssetData fields of a 0x order. @@ -8784,7 +14140,7 @@ The hex encoded assetData string ▸ **encodeERC20AssetData**(`tokenAddress`: string): *string* -*Defined in [order-utils/src/asset_data_utils.ts:30](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/asset_data_utils.ts#L30)* +*Defined in [order-utils/src/asset_data_utils.ts:30](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/asset_data_utils.ts#L30)* Encodes an ERC20 token address into a hex encoded assetData string, usable in the makerAssetData or takerAssetData fields in a 0x order. @@ -8803,7 +14159,7 @@ The hex encoded assetData string ▸ **encodeERC721AssetData**(`tokenAddress`: string, `tokenId`: `BigNumber`): *string* -*Defined in [order-utils/src/asset_data_utils.ts:59](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/asset_data_utils.ts#L59)* +*Defined in [order-utils/src/asset_data_utils.ts:59](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/asset_data_utils.ts#L59)* Encodes an ERC721 token address into a hex encoded assetData string, usable in the makerAssetData or takerAssetData fields in a 0x order. @@ -8823,7 +14179,7 @@ The hex encoded assetData string ▸ **encodeMultiAssetData**(`amounts`: `BigNumber`[], `nestedAssetData`: string[]): *string* -*Defined in [order-utils/src/asset_data_utils.ts:130](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/asset_data_utils.ts#L130)* +*Defined in [order-utils/src/asset_data_utils.ts:130](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/asset_data_utils.ts#L130)* Encodes assetData for multiple AssetProxies into a single hex encoded assetData string, usable in the makerAssetData or takerAssetData fields in a 0x order. @@ -8843,7 +14199,7 @@ The hex encoded assetData string ▸ **encodeStaticCallAssetData**(`callTarget`: string, `staticCallData`: string, `callResultHash`: string): *string* -*Defined in [order-utils/src/asset_data_utils.ts:214](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/asset_data_utils.ts#L214)* +*Defined in [order-utils/src/asset_data_utils.ts:214](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/asset_data_utils.ts#L214)* Encodes StaticCallProxy data into an assetData hex string @@ -8863,7 +14219,7 @@ The hex encoded assetData string ▸ **isERC1155AssetData**(`decodedAssetData`: [SingleAssetData](#singleassetdata) | `MultiAssetData`): *boolean* -*Defined in [order-utils/src/asset_data_utils.ts:332](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/asset_data_utils.ts#L332)* +*Defined in [order-utils/src/asset_data_utils.ts:332](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/asset_data_utils.ts#L332)* Checks if the decoded asset data is valid ERC1155 data @@ -8879,7 +14235,7 @@ Name | Type | Description | ▸ **isERC20AssetData**(`decodedAssetData`: [SingleAssetData](#singleassetdata) | `MultiAssetData`): *boolean* -*Defined in [order-utils/src/asset_data_utils.ts:318](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/asset_data_utils.ts#L318)* +*Defined in [order-utils/src/asset_data_utils.ts:318](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/asset_data_utils.ts#L318)* Checks if the decoded asset data is valid ERC20 data @@ -8895,7 +14251,7 @@ Name | Type | Description | ▸ **isERC721AssetData**(`decodedAssetData`: [SingleAssetData](#singleassetdata) | `MultiAssetData`): *boolean* -*Defined in [order-utils/src/asset_data_utils.ts:325](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/asset_data_utils.ts#L325)* +*Defined in [order-utils/src/asset_data_utils.ts:325](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/asset_data_utils.ts#L325)* Checks if the decoded asset data is valid ERC721 data @@ -8911,7 +14267,7 @@ Name | Type | Description | ▸ **isMultiAssetData**(`decodedAssetData`: [SingleAssetData](#singleassetdata) | `MultiAssetData`): *boolean* -*Defined in [order-utils/src/asset_data_utils.ts:339](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/asset_data_utils.ts#L339)* +*Defined in [order-utils/src/asset_data_utils.ts:339](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/asset_data_utils.ts#L339)* Checks if the decoded asset data is valid MultiAsset data @@ -8927,7 +14283,7 @@ Name | Type | Description | ▸ **isStaticCallAssetData**(`decodedAssetData`: [SingleAssetData](#singleassetdata) | `MultiAssetData`): *boolean* -*Defined in [order-utils/src/asset_data_utils.ts:346](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/asset_data_utils.ts#L346)* +*Defined in [order-utils/src/asset_data_utils.ts:346](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/asset_data_utils.ts#L346)* Checks if the decoded asset data is valid StaticCall data @@ -8943,7 +14299,7 @@ Name | Type | Description | ▸ **validateAssetDataOrThrow**(`assetData`: string): *void* -*Defined in [order-utils/src/asset_data_utils.ts:475](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/asset_data_utils.ts#L475)* +*Defined in [order-utils/src/asset_data_utils.ts:475](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/asset_data_utils.ts#L475)* Throws if the length or assetProxyId are invalid for the corresponding AssetProxy. @@ -8966,13 +14322,13 @@ Name | Type | Description | #### ▪ **orderHashUtils**: *object* -*Defined in [order-utils/src/order_hash.ts:12](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/order_hash.ts#L12)* +*Defined in [order-utils/src/order_hash.ts:12](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/order_hash.ts#L12)* #### getOrderHashBuffer ▸ **getOrderHashBuffer**(`order`: `SignedOrder` | `Order`): *`Buffer`* -*Defined in [order-utils/src/order_hash.ts:55](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/order_hash.ts#L55)* +*Defined in [order-utils/src/order_hash.ts:55](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/order_hash.ts#L55)* Computes the orderHash for a supplied order @@ -8990,7 +14346,7 @@ A Buffer containing the resulting orderHash from hashing the supplied order ▸ **getOrderHashHex**(`order`: `SignedOrder` | `Order`): *string* -*Defined in [order-utils/src/order_hash.ts:33](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/order_hash.ts#L33)* +*Defined in [order-utils/src/order_hash.ts:33](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/order_hash.ts#L33)* Computes the orderHash for a supplied order. @@ -9008,7 +14364,7 @@ Hex encoded string orderHash from hashing the supplied order. ▸ **isValidOrderHash**(`orderHash`: string): *boolean* -*Defined in [order-utils/src/order_hash.ts:20](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/order_hash.ts#L20)* +*Defined in [order-utils/src/order_hash.ts:20](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/order_hash.ts#L20)* Checks if the supplied hex encoded order hash is valid. Note: Valid means it has the expected format, not that an order with the orderHash exists. @@ -9035,7 +14391,7 @@ Whether the supplied orderHash has the expected format. ▸ **generatePseudoRandomSalt**(): *`BigNumber`* -*Defined in [order-utils/src/salt.ts:9](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/salt.ts#L9)* +*Defined in [order-utils/src/salt.ts:9](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/salt.ts#L9)* Generates a pseudo-random 256-bit salt. The salt can be included in a 0x order, ensuring that the order generates a unique orderHash @@ -9056,13 +14412,13 @@ A pseudo-random 256-bit number that can be used as a salt. #### ▪ **signatureUtils**: *object* -*Defined in [order-utils/src/signature_utils.ts:27](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/signature_utils.ts#L27)* +*Defined in [order-utils/src/signature_utils.ts:27](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/signature_utils.ts#L27)* #### addSignedMessagePrefix ▸ **addSignedMessagePrefix**(`message`: string): *string* -*Defined in [order-utils/src/signature_utils.ts:497](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/signature_utils.ts#L497)* +*Defined in [order-utils/src/signature_utils.ts:500](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/signature_utils.ts#L500)* Adds the relevant prefix to the message being signed. @@ -9080,7 +14436,7 @@ Prefixed message ▸ **convertECSignatureToSignatureHex**(`ecSignature`: `ECSignature`): *string* -*Defined in [order-utils/src/signature_utils.ts:471](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/signature_utils.ts#L471)* +*Defined in [order-utils/src/signature_utils.ts:474](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/signature_utils.ts#L474)* Combines ECSignature with V,R,S and the EthSign signature type for use in 0x protocol @@ -9098,7 +14454,7 @@ Hex encoded string of signature (v,r,s) with Signature Type ▸ **convertToSignatureWithType**(`signature`: string, `signatureType`: `SignatureType`): *string* -*Defined in [order-utils/src/signature_utils.ts:487](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/signature_utils.ts#L487)* +*Defined in [order-utils/src/signature_utils.ts:490](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/signature_utils.ts#L490)* Combines the signature proof and the Signature Type. @@ -9117,7 +14473,7 @@ Hex encoded string of signature proof with Signature Type ▸ **ecSignHashAsync**(`supportedProvider`: [SupportedProvider](#supportedprovider), `msgHash`: string, `signerAddress`: string): *`Promise`* -*Defined in [order-utils/src/signature_utils.ts:414](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/signature_utils.ts#L414)* +*Defined in [order-utils/src/signature_utils.ts:417](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/signature_utils.ts#L417)* Signs a hash using `eth_sign` and returns its elliptic curve signature and signature type. @@ -9137,7 +14493,7 @@ A hex encoded string containing the Elliptic curve signature generated by signin ▸ **ecSignOrderAsync**(`supportedProvider`: [SupportedProvider](#supportedprovider), `order`: `Order`, `signerAddress`: string): *`Promise`* -*Defined in [order-utils/src/signature_utils.ts:249](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/signature_utils.ts#L249)* +*Defined in [order-utils/src/signature_utils.ts:252](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/signature_utils.ts#L252)* Signs an order and returns a SignedOrder. First `eth_signTypedData` is requested then a fallback to `eth_sign` if not available on the supplied provider. @@ -9158,7 +14514,7 @@ A SignedOrder containing the order and Elliptic curve signature with Signature T ▸ **ecSignTransactionAsync**(`supportedProvider`: [SupportedProvider](#supportedprovider), `transaction`: `ZeroExTransaction`, `signerAddress`: string): *`Promise`* -*Defined in [order-utils/src/signature_utils.ts:328](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/signature_utils.ts#L328)* +*Defined in [order-utils/src/signature_utils.ts:331](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/signature_utils.ts#L331)* Signs a transaction and returns a SignedZeroExTransaction. First `eth_signTypedData` is requested then a fallback to `eth_sign` if not available on the supplied provider. @@ -9179,7 +14535,7 @@ A SignedTransaction containing the order and Elliptic curve signature with Signa ▸ **ecSignTypedDataOrderAsync**(`supportedProvider`: [SupportedProvider](#supportedprovider), `order`: `Order`, `signerAddress`: string): *`Promise`* -*Defined in [order-utils/src/signature_utils.ts:284](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/signature_utils.ts#L284)* +*Defined in [order-utils/src/signature_utils.ts:287](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/signature_utils.ts#L287)* Signs an order using `eth_signTypedData` and returns a SignedOrder. @@ -9199,7 +14555,7 @@ A SignedOrder containing the order and Elliptic curve signature with Signature T ▸ **ecSignTypedDataTransactionAsync**(`supportedProvider`: [SupportedProvider](#supportedprovider), `transaction`: `ZeroExTransaction`, `signerAddress`: string): *`Promise`* -*Defined in [order-utils/src/signature_utils.ts:371](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/signature_utils.ts#L371)* +*Defined in [order-utils/src/signature_utils.ts:374](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/signature_utils.ts#L374)* Signs a ZeroExTransaction using `eth_signTypedData` and returns a SignedZeroExTransaction. @@ -9219,7 +14575,7 @@ A SignedZeroExTransaction containing the ZeroExTransaction and Elliptic curve si ▸ **isValidECSignature**(`data`: string, `signature`: `ECSignature`, `signerAddress`: string): *boolean* -*Defined in [order-utils/src/signature_utils.ts:219](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/signature_utils.ts#L219)* +*Defined in [order-utils/src/signature_utils.ts:222](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/signature_utils.ts#L222)* Checks if the supplied elliptic curve signature corresponds to signing `data` with the private key corresponding to `signerAddress` @@ -9240,7 +14596,7 @@ Whether the ECSignature is valid. ▸ **isValidPresignedSignatureAsync**(`supportedProvider`: [SupportedProvider](#supportedprovider), `data`: string, `signerAddress`: string, `exchangeAddress?`: undefined | string): *`Promise`* -*Defined in [order-utils/src/signature_utils.ts:107](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/signature_utils.ts#L107)* +*Defined in [order-utils/src/signature_utils.ts:107](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/signature_utils.ts#L107)* Verifies that the provided presigned signature is valid according to the 0x Protocol smart contracts @@ -9261,7 +14617,7 @@ Whether the data was preSigned by the supplied signerAddress ▸ **isValidSignatureAsync**(`supportedProvider`: [SupportedProvider](#supportedprovider), `data`: string, `signature`: string, `signerAddress`: string, `exchangeAddress?`: undefined | string): *`Promise`* -*Defined in [order-utils/src/signature_utils.ts:38](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/signature_utils.ts#L38)* +*Defined in [order-utils/src/signature_utils.ts:38](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/signature_utils.ts#L38)* Verifies that the provided signature is valid according to the 0x Protocol smart contracts @@ -9283,7 +14639,7 @@ Whether the signature is valid for the supplied signerAddress and data. ▸ **isValidValidatorSignatureAsync**(`supportedProvider`: [SupportedProvider](#supportedprovider), `data`: string, `signature`: string, `signerAddress`: string, `exchangeAddress?`: undefined | string): *`Promise`* -*Defined in [order-utils/src/signature_utils.ts:168](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/signature_utils.ts#L168)* +*Defined in [order-utils/src/signature_utils.ts:168](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/signature_utils.ts#L168)* Verifies that the provided validator signature is valid according to the 0x Protocol smart contracts @@ -9305,7 +14661,7 @@ Whether the data was preSigned by the supplied signerAddress. ▸ **isValidWalletSignatureAsync**(`supportedProvider`: [SupportedProvider](#supportedprovider), `data`: string, `signature`: string, `signerAddress`: string): *`Promise`* -*Defined in [order-utils/src/signature_utils.ts:139](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/signature_utils.ts#L139)* +*Defined in [order-utils/src/signature_utils.ts:139](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/signature_utils.ts#L139)* Verifies that the provided wallet signature is valid according to the 0x Protocol smart contracts @@ -9326,7 +14682,7 @@ Whether the data was preSigned by the supplied signerAddress. ▸ **parseECSignature**(`signature`: string): *`ECSignature`* -*Defined in [order-utils/src/signature_utils.ts:509](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/signature_utils.ts#L509)* +*Defined in [order-utils/src/signature_utils.ts:512](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/signature_utils.ts#L512)* Parse a 0x protocol hex-encoded signature string into its ECSignature components @@ -9344,7 +14700,7 @@ An ECSignature object with r,s,v parameters ▸ **parseValidatorSignature**(`signature`: string): *`ValidatorSignature`* -*Defined in [order-utils/src/signature_utils.ts:526](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/signature_utils.ts#L526)* +*Defined in [order-utils/src/signature_utils.ts:529](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/signature_utils.ts#L529)* Parse a hex-encoded Validator signature into validator address and signature components @@ -9369,13 +14725,13 @@ A ValidatorSignature with validatorAddress and signature parameters #### ▪ **transactionHashUtils**: *object* -*Defined in [order-utils/src/transaction_hash.ts:9](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/transaction_hash.ts#L9)* +*Defined in [order-utils/src/transaction_hash.ts:9](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/transaction_hash.ts#L9)* #### getTransactionHashBuffer ▸ **getTransactionHashBuffer**(`transaction`: `ZeroExTransaction` | `SignedZeroExTransaction`): *`Buffer`* -*Defined in [order-utils/src/transaction_hash.ts:41](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/transaction_hash.ts#L41)* +*Defined in [order-utils/src/transaction_hash.ts:41](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/transaction_hash.ts#L41)* Computes the transactionHash for a supplied 0x transaction. @@ -9393,7 +14749,7 @@ A Buffer containing the resulting transactionHash from hashing the supplied 0x t ▸ **getTransactionHashHex**(`transaction`: `ZeroExTransaction` | `SignedZeroExTransaction`): *string* -*Defined in [order-utils/src/transaction_hash.ts:30](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/transaction_hash.ts#L30)* +*Defined in [order-utils/src/transaction_hash.ts:30](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/transaction_hash.ts#L30)* Computes the transactionHash for a supplied 0x transaction. @@ -9411,7 +14767,7 @@ Hex encoded string transactionHash from hashing the supplied order. ▸ **isValidTransactionHash**(`transactionHash`: string): *boolean* -*Defined in [order-utils/src/transaction_hash.ts:17](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/transaction_hash.ts#L17)* +*Defined in [order-utils/src/transaction_hash.ts:17](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/transaction_hash.ts#L17)* Checks if the supplied hex encoded 0x transaction hash is valid. Note: Valid means it has the expected format, not that a transaction with the transactionHash exists. @@ -9446,7 +14802,7 @@ Whether the supplied transactionHash has the expected format. Ƭ **Callback**: *function* -*Defined in [subproviders/src/types.ts:131](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/types.ts#L131)* +*Defined in [subproviders/src/types.ts:131](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/types.ts#L131)* ##### Type declaration: @@ -9460,7 +14816,7 @@ ___ Ƭ **ErrorCallback**: *function* -*Defined in [subproviders/src/types.ts:130](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/types.ts#L130)* +*Defined in [subproviders/src/types.ts:130](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/types.ts#L130)* #### Type declaration: @@ -9481,3 +14837,63 @@ ___ + + + +## Type aliases + + + +### AssetData + +Ƭ **AssetData**: *[SingleAssetData](_types_src_index_.md#singleassetdata) | [MultiAssetData](#interface-multiassetdata) | [MultiAssetDataWithRecursiveDecoding](#interface-multiassetdatawithrecursivedecoding)* + +*Defined in [types/src/index.ts:224](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L224)* + +___ + + + + + + + +### EventCallback + +Ƭ **EventCallback**: *function* + +*Defined in [types/src/index.ts:848](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L848)* + +#### Type declaration: + +▸ (`err`: null | `Error`, `log?`: [DecodedLogEvent](#interface-decodedlogevent)‹*`ArgsType`*›): *void* + +**Parameters:** + +Name | Type | +------ | ------ | +`err` | null \| `Error` | +`log?` | [DecodedLogEvent](#interface-decodedlogevent)‹*`ArgsType`*› | + +___ + + + + + + + + + +### SingleAssetData + +Ƭ **SingleAssetData**: *[ERC20AssetData](#interface-erc20assetdata) | [ERC721AssetData](#interface-erc721assetdata) | [ERC1155AssetData](#interface-erc1155assetdata) | [StaticCallAssetData](#interface-staticcallassetdata)* + +*Defined in [types/src/index.ts:204](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L204)* + +
+ + + +
+ diff --git a/packages/asset-buyer/docs/reference.mdx b/packages/asset-buyer/docs/reference.mdx index 2f142b1ca1..744897f1db 100644 --- a/packages/asset-buyer/docs/reference.mdx +++ b/packages/asset-buyer/docs/reference.mdx @@ -1,4 +1,235 @@ +# Class: AssetBuyer + + +## Constructors + + + +\+ **new AssetBuyer**(`supportedProvider`: [SupportedProvider](#supportedprovider), `orderProvider`: [OrderProvider](#interface-orderprovider), `options`: `Partial`): *[AssetBuyer](#class-assetbuyer)* + +*Defined in [asset-buyer/src/asset_buyer.ts:83](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-buyer/src/asset_buyer.ts#L83)* + +Instantiates a new AssetBuyer instance + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`supportedProvider` | [SupportedProvider](#supportedprovider) | - | The Provider instance you would like to use for interacting with the Ethereum network. | +`orderProvider` | [OrderProvider](#interface-orderprovider) | - | An object that conforms to OrderProvider, see type for definition. | +`options` | `Partial` | {} | Initialization options for the AssetBuyer. See type definition for details. | + +**Returns:** *[AssetBuyer](#class-assetbuyer)* + +An instance of AssetBuyer + +## Properties + +### chainId + +• **chainId**: *number* + +*Defined in [asset-buyer/src/asset_buyer.ts:38](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-buyer/src/asset_buyer.ts#L38)* + +___ + +### expiryBufferSeconds + +• **expiryBufferSeconds**: *number* + +*Defined in [asset-buyer/src/asset_buyer.ts:40](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-buyer/src/asset_buyer.ts#L40)* + +___ + +### orderProvider + +• **orderProvider**: *[OrderProvider](#interface-orderprovider)* + +*Defined in [asset-buyer/src/asset_buyer.ts:37](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-buyer/src/asset_buyer.ts#L37)* + +___ + +### orderRefreshIntervalMs + +• **orderRefreshIntervalMs**: *number* + +*Defined in [asset-buyer/src/asset_buyer.ts:39](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-buyer/src/asset_buyer.ts#L39)* + +___ + +### provider + +• **provider**: *`ZeroExProvider`* + +*Defined in [asset-buyer/src/asset_buyer.ts:36](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-buyer/src/asset_buyer.ts#L36)* + +## Methods + +### executeBuyQuoteAsync + +▸ **executeBuyQuoteAsync**(`buyQuote`: [BuyQuote](#interface-buyquote), `options`: `Partial`): *`Promise`* + +*Defined in [asset-buyer/src/asset_buyer.ts:226](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-buyer/src/asset_buyer.ts#L226)* + +Given a BuyQuote and desired rate, attempt to execute the buy. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`buyQuote` | [BuyQuote](#interface-buyquote) | - | An object that conforms to BuyQuote. See type definition for more information. | +`options` | `Partial` | {} | Options for the execution of the BuyQuote. See type definition for more information. | + +**Returns:** *`Promise`* + +A promise of the txHash. + +___ + +### getAvailableAssetDatasAsync + +▸ **getAvailableAssetDatasAsync**(): *`Promise`* + +*Defined in [asset-buyer/src/asset_buyer.ts:300](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-buyer/src/asset_buyer.ts#L300)* + +Get the asset data of all assets that are purchaseable with ether token (wETH) in the order provider passed in at init. +**Returns:** *`Promise`* + +An array of asset data strings that can be purchased using wETH. + +___ + +### getBuyQuoteAsync + +▸ **getBuyQuoteAsync**(`assetData`: string, `assetBuyAmount`: `BigNumber`, `options`: `Partial`): *`Promise`* + +*Defined in [asset-buyer/src/asset_buyer.ts:125](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-buyer/src/asset_buyer.ts#L125)* + +Get a `BuyQuote` containing all information relevant to fulfilling a buy given a desired assetData. +You can then pass the `BuyQuote` to `executeBuyQuoteAsync` to execute the buy. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`assetData` | string | - | The assetData of the desired asset to buy (for more info: https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md). | +`assetBuyAmount` | `BigNumber` | - | The amount of asset to buy. | +`options` | `Partial` | {} | Options for the request. See type definition for more information. | + +**Returns:** *`Promise`* + +An object that conforms to BuyQuote that satisfies the request. See type definition for more information. + +___ + +### getBuyQuoteForERC20TokenAddressAsync + +▸ **getBuyQuoteForERC20TokenAddressAsync**(`tokenAddress`: string, `assetBuyAmount`: `BigNumber`, `options`: `Partial`): *`Promise`* + +*Defined in [asset-buyer/src/asset_buyer.ts:173](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-buyer/src/asset_buyer.ts#L173)* + +Get a `BuyQuote` containing all information relevant to fulfilling a buy given a desired ERC20 token address. +You can then pass the `BuyQuote` to `executeBuyQuoteAsync` to execute the buy. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`tokenAddress` | string | - | The ERC20 token address. | +`assetBuyAmount` | `BigNumber` | - | The amount of asset to buy. | +`options` | `Partial` | {} | Options for the request. See type definition for more information. | + +**Returns:** *`Promise`* + +An object that conforms to BuyQuote that satisfies the request. See type definition for more information. + +___ + +### getLiquidityForAssetDataAsync + +▸ **getLiquidityForAssetDataAsync**(`assetData`: string, `options`: `Partial`): *`Promise`* + +*Defined in [asset-buyer/src/asset_buyer.ts:192](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-buyer/src/asset_buyer.ts#L192)* + +Returns information about available liquidity for an asset +Does not factor in slippage or fees + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`assetData` | string | - | The assetData of the desired asset to buy (for more info: https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md). | +`options` | `Partial` | {} | Options for the request. See type definition for more information. | + +**Returns:** *`Promise`* + +An object that conforms to LiquidityForAssetData that satisfies the request. See type definition for more information. + +___ + +### getOrdersAndFillableAmountsAsync + +▸ **getOrdersAndFillableAmountsAsync**(`assetData`: string, `shouldForceOrderRefresh`: boolean): *`Promise`* + +*Defined in [asset-buyer/src/asset_buyer.ts:309](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-buyer/src/asset_buyer.ts#L309)* + +Grab orders from the map, if there is a miss or it is time to refresh, fetch and process the orders + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`assetData` | string | The assetData of the desired asset to buy (for more info: https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md). | +`shouldForceOrderRefresh` | boolean | If set to true, new orders and state will be fetched instead of waiting for the next orderRefreshIntervalMs. | + +**Returns:** *`Promise`* + +___ + +### `Static` getAssetBuyerForProvidedOrders + +▸ **getAssetBuyerForProvidedOrders**(`supportedProvider`: [SupportedProvider](#supportedprovider), `orders`: `SignedOrder`[], `options`: `Partial`): *[AssetBuyer](#class-assetbuyer)* + +*Defined in [asset-buyer/src/asset_buyer.ts:53](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-buyer/src/asset_buyer.ts#L53)* + +Instantiates a new AssetBuyer instance given existing liquidity in the form of orders and feeOrders. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`supportedProvider` | [SupportedProvider](#supportedprovider) | - | The Provider instance you would like to use for interacting with the Ethereum network. | +`orders` | `SignedOrder`[] | - | A non-empty array of objects that conform to SignedOrder. All orders must have the same makerAssetData and takerAssetData (WETH). | +`options` | `Partial` | {} | Initialization options for the AssetBuyer. See type definition for details. | + +**Returns:** *[AssetBuyer](#class-assetbuyer)* + +An instance of AssetBuyer + +___ + +### `Static` getAssetBuyerForStandardRelayerAPIUrl + +▸ **getAssetBuyerForStandardRelayerAPIUrl**(`supportedProvider`: [SupportedProvider](#supportedprovider), `sraApiUrl`: string, `options`: `Partial`): *[AssetBuyer](#class-assetbuyer)* + +*Defined in [asset-buyer/src/asset_buyer.ts:72](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-buyer/src/asset_buyer.ts#L72)* + +Instantiates a new AssetBuyer instance given a [Standard Relayer API](https://github.com/0xProject/standard-relayer-api) endpoint + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`supportedProvider` | [SupportedProvider](#supportedprovider) | - | The Provider instance you would like to use for interacting with the Ethereum network. | +`sraApiUrl` | string | - | The standard relayer API base HTTP url you would like to source orders from. | +`options` | `Partial` | {} | Initialization options for the AssetBuyer. See type definition for details. | + +**Returns:** *[AssetBuyer](#class-assetbuyer)* + +An instance of AssetBuyer + +
# Class: InsufficientAssetLiquidityError @@ -11,7 +242,7 @@ Error class representing insufficient asset liquidity \+ **new InsufficientAssetLiquidityError**(`amountAvailableToFill`: `BigNumber`): *[InsufficientAssetLiquidityError](#class-insufficientassetliquidityerror)* -*Defined in [asset-buyer/src/errors.ts:12](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-buyer/src/errors.ts#L12)* +*Defined in [asset-buyer/src/errors.ts:12](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-buyer/src/errors.ts#L12)* **Parameters:** @@ -27,7 +258,7 @@ Name | Type | Description | • **amountAvailableToFill**: *`BigNumber`* -*Defined in [asset-buyer/src/errors.ts:12](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-buyer/src/errors.ts#L12)* +*Defined in [asset-buyer/src/errors.ts:12](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-buyer/src/errors.ts#L12)* The amount availabe to fill (in base units) factoring in slippage. @@ -87,7 +318,7 @@ ___ \+ **new BasicOrderProvider**(`orders`: `SignedOrder`[]): *[BasicOrderProvider](#class-basicorderprovider)* -*Defined in [asset-buyer/src/order_providers/basic_order_provider.ts:9](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-buyer/src/order_providers/basic_order_provider.ts#L9)* +*Defined in [asset-buyer/src/order_providers/basic_order_provider.ts:9](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-buyer/src/order_providers/basic_order_provider.ts#L9)* Instantiates a new BasicOrderProvider instance @@ -107,7 +338,7 @@ An instance of BasicOrderProvider • **orders**: *`SignedOrder`[]* -*Defined in [asset-buyer/src/order_providers/basic_order_provider.ts:9](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-buyer/src/order_providers/basic_order_provider.ts#L9)* +*Defined in [asset-buyer/src/order_providers/basic_order_provider.ts:9](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-buyer/src/order_providers/basic_order_provider.ts#L9)* ## Methods @@ -115,7 +346,7 @@ An instance of BasicOrderProvider ▸ **getAvailableMakerAssetDatasAsync**(`takerAssetData`: string): *`Promise`* -*Defined in [asset-buyer/src/order_providers/basic_order_provider.ts:37](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-buyer/src/order_providers/basic_order_provider.ts#L37)* +*Defined in [asset-buyer/src/order_providers/basic_order_provider.ts:37](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-buyer/src/order_providers/basic_order_provider.ts#L37)* Given a taker asset data string, return all availabled paired maker asset data strings. @@ -135,7 +366,7 @@ ___ ▸ **getOrdersAsync**(`orderProviderRequest`: [OrderProviderRequest](#interface-orderproviderrequest)): *`Promise`* -*Defined in [asset-buyer/src/order_providers/basic_order_provider.ts:24](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-buyer/src/order_providers/basic_order_provider.ts#L24)* +*Defined in [asset-buyer/src/order_providers/basic_order_provider.ts:24](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-buyer/src/order_providers/basic_order_provider.ts#L24)* Given an object that conforms to OrderFetcherRequest, return the corresponding OrderProviderResponse that satisfies the request. @@ -163,9 +394,9 @@ An instance of OrderProviderResponse. See type for more information. -\+ **new StandardRelayerAPIOrderProvider**(`apiUrl`: string): *[StandardRelayerAPIOrderProvider](#class-standardrelayerapiorderprovider)* +\+ **new StandardRelayerAPIOrderProvider**(`apiUrl`: string, `chainId`: number): *[StandardRelayerAPIOrderProvider](#class-standardrelayerapiorderprovider)* -*Defined in [asset-buyer/src/order_providers/standard_relayer_api_order_provider.ts:47](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-buyer/src/order_providers/standard_relayer_api_order_provider.ts#L47)* +*Defined in [asset-buyer/src/order_providers/standard_relayer_api_order_provider.ts:48](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-buyer/src/order_providers/standard_relayer_api_order_provider.ts#L48)* Instantiates a new StandardRelayerAPIOrderProvider instance @@ -174,6 +405,7 @@ Instantiates a new StandardRelayerAPIOrderProvider instance Name | Type | Description | ------ | ------ | ------ | `apiUrl` | string | The standard relayer API base HTTP url you would like to source orders from. | +`chainId` | number | The ethereum chain id. | **Returns:** *[StandardRelayerAPIOrderProvider](#class-standardrelayerapiorderprovider)* @@ -185,7 +417,15 @@ An instance of StandardRelayerAPIOrderProvider • **apiUrl**: *string* -*Defined in [asset-buyer/src/order_providers/standard_relayer_api_order_provider.ts:17](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-buyer/src/order_providers/standard_relayer_api_order_provider.ts#L17)* +*Defined in [asset-buyer/src/order_providers/standard_relayer_api_order_provider.ts:17](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-buyer/src/order_providers/standard_relayer_api_order_provider.ts#L17)* + +___ + +### chainId + +• **chainId**: *number* + +*Defined in [asset-buyer/src/order_providers/standard_relayer_api_order_provider.ts:18](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-buyer/src/order_providers/standard_relayer_api_order_provider.ts#L18)* ## Methods @@ -193,7 +433,7 @@ An instance of StandardRelayerAPIOrderProvider ▸ **getAvailableMakerAssetDatasAsync**(`takerAssetData`: string): *`Promise`* -*Defined in [asset-buyer/src/order_providers/standard_relayer_api_order_provider.ts:86](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-buyer/src/order_providers/standard_relayer_api_order_provider.ts#L86)* +*Defined in [asset-buyer/src/order_providers/standard_relayer_api_order_provider.ts:91](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-buyer/src/order_providers/standard_relayer_api_order_provider.ts#L91)* Given a taker asset data string, return all availabled paired maker asset data strings. @@ -213,7 +453,7 @@ ___ ▸ **getOrdersAsync**(`orderProviderRequest`: [OrderProviderRequest](#interface-orderproviderrequest)): *`Promise`* -*Defined in [asset-buyer/src/order_providers/standard_relayer_api_order_provider.ts:63](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-buyer/src/order_providers/standard_relayer_api_order_provider.ts#L63)* +*Defined in [asset-buyer/src/order_providers/standard_relayer_api_order_provider.ts:67](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-buyer/src/order_providers/standard_relayer_api_order_provider.ts#L67)* Given an object that conforms to OrderProviderRequest, return the corresponding OrderProviderResponse that satisfies the request. @@ -240,7 +480,7 @@ Possible error messages thrown by an AssetBuyer instance or associated static me • **AssetUnavailable**: = "ASSET_UNAVAILABLE" -*Defined in [asset-buyer/src/types.ts:122](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-buyer/src/types.ts#L122)* +*Defined in [asset-buyer/src/types.ts:122](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-buyer/src/types.ts#L122)* ___ @@ -248,7 +488,7 @@ ___ • **InsufficientAssetLiquidity**: = "INSUFFICIENT_ASSET_LIQUIDITY" -*Defined in [asset-buyer/src/types.ts:118](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-buyer/src/types.ts#L118)* +*Defined in [asset-buyer/src/types.ts:118](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-buyer/src/types.ts#L118)* ___ @@ -256,7 +496,7 @@ ___ • **InsufficientZrxLiquidity**: = "INSUFFICIENT_ZRX_LIQUIDITY" -*Defined in [asset-buyer/src/types.ts:119](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-buyer/src/types.ts#L119)* +*Defined in [asset-buyer/src/types.ts:119](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-buyer/src/types.ts#L119)* ___ @@ -264,7 +504,7 @@ ___ • **InvalidOrderProviderResponse**: = "INVALID_ORDER_PROVIDER_RESPONSE" -*Defined in [asset-buyer/src/types.ts:121](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-buyer/src/types.ts#L121)* +*Defined in [asset-buyer/src/types.ts:121](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-buyer/src/types.ts#L121)* ___ @@ -272,7 +512,7 @@ ___ • **NoAddressAvailable**: = "NO_ADDRESS_AVAILABLE" -*Defined in [asset-buyer/src/types.ts:120](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-buyer/src/types.ts#L120)* +*Defined in [asset-buyer/src/types.ts:120](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-buyer/src/types.ts#L120)* ___ @@ -280,7 +520,7 @@ ___ • **NoEtherTokenContractFound**: = "NO_ETHER_TOKEN_CONTRACT_FOUND" -*Defined in [asset-buyer/src/types.ts:115](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-buyer/src/types.ts#L115)* +*Defined in [asset-buyer/src/types.ts:115](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-buyer/src/types.ts#L115)* ___ @@ -288,7 +528,7 @@ ___ • **NoZrxTokenContractFound**: = "NO_ZRX_TOKEN_CONTRACT_FOUND" -*Defined in [asset-buyer/src/types.ts:116](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-buyer/src/types.ts#L116)* +*Defined in [asset-buyer/src/types.ts:116](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-buyer/src/types.ts#L116)* ___ @@ -296,7 +536,7 @@ ___ • **SignatureRequestDenied**: = "SIGNATURE_REQUEST_DENIED" -*Defined in [asset-buyer/src/types.ts:123](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-buyer/src/types.ts#L123)* +*Defined in [asset-buyer/src/types.ts:123](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-buyer/src/types.ts#L123)* ___ @@ -304,7 +544,7 @@ ___ • **StandardRelayerApiError**: = "STANDARD_RELAYER_API_ERROR" -*Defined in [asset-buyer/src/types.ts:117](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-buyer/src/types.ts#L117)* +*Defined in [asset-buyer/src/types.ts:117](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-buyer/src/types.ts#L117)* ___ @@ -312,7 +552,7 @@ ___ • **TransactionValueTooLow**: = "TRANSACTION_VALUE_TOO_LOW" -*Defined in [asset-buyer/src/types.ts:124](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-buyer/src/types.ts#L124)* +*Defined in [asset-buyer/src/types.ts:124](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-buyer/src/types.ts#L124)*
@@ -347,10 +587,6 @@ ___ - - - -
@@ -371,7 +607,7 @@ worstCaseQuoteInfo: Info about the worst case price for the asset. • **assetBuyAmount**: *`BigNumber`* -*Defined in [asset-buyer/src/types.ts:48](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-buyer/src/types.ts#L48)* +*Defined in [asset-buyer/src/types.ts:48](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-buyer/src/types.ts#L48)* ___ @@ -379,7 +615,7 @@ ___ • **assetData**: *string* -*Defined in [asset-buyer/src/types.ts:47](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-buyer/src/types.ts#L47)* +*Defined in [asset-buyer/src/types.ts:47](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-buyer/src/types.ts#L47)* ___ @@ -387,7 +623,7 @@ ___ • **bestCaseQuoteInfo**: *[BuyQuoteInfo](#class-buyquoteinfo)* -*Defined in [asset-buyer/src/types.ts:52](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-buyer/src/types.ts#L52)* +*Defined in [asset-buyer/src/types.ts:52](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-buyer/src/types.ts#L52)* ___ @@ -395,7 +631,7 @@ ___ • **feeOrders**: *`SignedOrder`[]* -*Defined in [asset-buyer/src/types.ts:50](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-buyer/src/types.ts#L50)* +*Defined in [asset-buyer/src/types.ts:50](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-buyer/src/types.ts#L50)* ___ @@ -403,7 +639,7 @@ ___ • **feePercentage**? : *undefined | number* -*Defined in [asset-buyer/src/types.ts:51](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-buyer/src/types.ts#L51)* +*Defined in [asset-buyer/src/types.ts:51](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-buyer/src/types.ts#L51)* ___ @@ -411,7 +647,7 @@ ___ • **orders**: *`SignedOrder`[]* -*Defined in [asset-buyer/src/types.ts:49](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-buyer/src/types.ts#L49)* +*Defined in [asset-buyer/src/types.ts:49](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-buyer/src/types.ts#L49)* ___ @@ -419,7 +655,7 @@ ___ • **worstCaseQuoteInfo**: *[BuyQuoteInfo](#class-buyquoteinfo)* -*Defined in [asset-buyer/src/types.ts:53](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-buyer/src/types.ts#L53)* +*Defined in [asset-buyer/src/types.ts:53](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-buyer/src/types.ts#L53)*
@@ -438,7 +674,7 @@ feeRecipient: The address where affiliate fees are sent. Defaults to null addres • **ethAmount**? : *`BigNumber`* -*Defined in [asset-buyer/src/types.ts:93](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-buyer/src/types.ts#L93)* +*Defined in [asset-buyer/src/types.ts:93](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-buyer/src/types.ts#L93)* ___ @@ -446,7 +682,7 @@ ___ • **feeRecipient**: *string* -*Defined in [asset-buyer/src/types.ts:97](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-buyer/src/types.ts#L97)* +*Defined in [asset-buyer/src/types.ts:97](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-buyer/src/types.ts#L97)* ___ @@ -454,7 +690,7 @@ ___ • **gasLimit**? : *undefined | number* -*Defined in [asset-buyer/src/types.ts:95](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-buyer/src/types.ts#L95)* +*Defined in [asset-buyer/src/types.ts:95](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-buyer/src/types.ts#L95)* ___ @@ -462,7 +698,7 @@ ___ • **gasPrice**? : *`BigNumber`* -*Defined in [asset-buyer/src/types.ts:96](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-buyer/src/types.ts#L96)* +*Defined in [asset-buyer/src/types.ts:96](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-buyer/src/types.ts#L96)* ___ @@ -470,7 +706,7 @@ ___ • **takerAddress**? : *undefined | string* -*Defined in [asset-buyer/src/types.ts:94](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-buyer/src/types.ts#L94)* +*Defined in [asset-buyer/src/types.ts:94](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-buyer/src/types.ts#L94)*
@@ -487,7 +723,7 @@ totalEthAmount: The total amount of eth required to complete the buy (filling or • **assetEthAmount**: *`BigNumber`* -*Defined in [asset-buyer/src/types.ts:62](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-buyer/src/types.ts#L62)* +*Defined in [asset-buyer/src/types.ts:62](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-buyer/src/types.ts#L62)* ___ @@ -495,7 +731,7 @@ ___ • **feeEthAmount**: *`BigNumber`* -*Defined in [asset-buyer/src/types.ts:63](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-buyer/src/types.ts#L63)* +*Defined in [asset-buyer/src/types.ts:63](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-buyer/src/types.ts#L63)* ___ @@ -503,7 +739,7 @@ ___ • **totalEthAmount**: *`BigNumber`* -*Defined in [asset-buyer/src/types.ts:64](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-buyer/src/types.ts#L64)* +*Defined in [asset-buyer/src/types.ts:64](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-buyer/src/types.ts#L64)*
@@ -520,7 +756,7 @@ slippagePercentage: The percentage buffer to add to account for slippage. Affect • **feePercentage**: *number* -*Defined in [asset-buyer/src/types.ts:73](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-buyer/src/types.ts#L73)* +*Defined in [asset-buyer/src/types.ts:73](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-buyer/src/types.ts#L73)* ___ @@ -528,7 +764,7 @@ ___ • **shouldForceOrderRefresh**: *boolean* -*Defined in [asset-buyer/src/types.ts:74](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-buyer/src/types.ts#L74)* +*Defined in [asset-buyer/src/types.ts:74](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-buyer/src/types.ts#L74)* ___ @@ -536,7 +772,7 @@ ___ • **slippagePercentage**: *number* -*Defined in [asset-buyer/src/types.ts:75](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-buyer/src/types.ts#L75)* +*Defined in [asset-buyer/src/types.ts:75](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-buyer/src/types.ts#L75)*
@@ -551,7 +787,7 @@ Represents available liquidity for a given assetData • **ethValueAvailableInWei**: *`BigNumber`* -*Defined in [asset-buyer/src/types.ts:141](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-buyer/src/types.ts#L141)* +*Defined in [asset-buyer/src/types.ts:141](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-buyer/src/types.ts#L141)* ___ @@ -559,7 +795,7 @@ ___ • **tokensAvailableInBaseUnits**: *`BigNumber`* -*Defined in [asset-buyer/src/types.ts:140](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-buyer/src/types.ts#L140)* +*Defined in [asset-buyer/src/types.ts:140](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-buyer/src/types.ts#L140)*
@@ -673,7 +909,7 @@ ___ • **remainingFillableMakerAssetAmount**? : *`BigNumber`* -*Defined in [asset-buyer/src/types.ts:26](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-buyer/src/types.ts#L26)* +*Defined in [asset-buyer/src/types.ts:26](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-buyer/src/types.ts#L26)* ___ @@ -802,7 +1038,7 @@ Defined in types/lib/index.d.ts:19 • **isEIP1193**: *boolean* -*Defined in [ethereum-types/src/index.ts:73](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L73)* +*Defined in [ethereum-types/src/index.ts:73](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L73)* ## Methods @@ -810,7 +1046,7 @@ Defined in types/lib/index.d.ts:19 ▸ **on**(`event`: [EIP1193Event](#eip1193event), `listener`: function): *this* -*Defined in [ethereum-types/src/index.ts:75](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L75)* +*Defined in [ethereum-types/src/index.ts:75](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L75)* **Parameters:** @@ -834,7 +1070,7 @@ ___ ▸ **send**(`method`: string, `params?`: any[]): *`Promise`* -*Defined in [ethereum-types/src/index.ts:74](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L74)* +*Defined in [ethereum-types/src/index.ts:74](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L74)* **Parameters:** @@ -868,7 +1104,7 @@ Name | Type | ▸ **sendAsync**(`payload`: [JSONRPCRequestPayload](_ethereum_types_src_index_.jsonrpcrequestpayload.md), `callback`: [JSONRPCErrorCallback](#jsonrpcerrorcallback)): *void* -*Defined in [ethereum-types/src/index.ts:14](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L14)* +*Defined in [ethereum-types/src/index.ts:14](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L14)* **Parameters:** @@ -892,7 +1128,7 @@ Name | Type | • **id**: *number* -*Defined in [ethereum-types/src/index.ts:330](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L330)* +*Defined in [ethereum-types/src/index.ts:330](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L330)* ___ @@ -900,7 +1136,7 @@ ___ • **jsonrpc**: *string* -*Defined in [ethereum-types/src/index.ts:331](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L331)* +*Defined in [ethereum-types/src/index.ts:331](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L331)* ___ @@ -908,7 +1144,7 @@ ___ • **method**: *string* -*Defined in [ethereum-types/src/index.ts:329](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L329)* +*Defined in [ethereum-types/src/index.ts:329](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L329)* ___ @@ -916,7 +1152,7 @@ ___ • **params**: *any[]* -*Defined in [ethereum-types/src/index.ts:328](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L328)* +*Defined in [ethereum-types/src/index.ts:328](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L328)*
@@ -929,7 +1165,7 @@ ___ • **code**: *number* -*Defined in [ethereum-types/src/index.ts:336](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L336)* +*Defined in [ethereum-types/src/index.ts:336](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L336)* ___ @@ -937,7 +1173,7 @@ ___ • **message**: *string* -*Defined in [ethereum-types/src/index.ts:335](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L335)* +*Defined in [ethereum-types/src/index.ts:335](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L335)*
@@ -950,7 +1186,7 @@ ___ • **error**? : *[JSONRPCResponseError](#class-jsonrpcresponseerror)* -*Defined in [ethereum-types/src/index.ts:343](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L343)* +*Defined in [ethereum-types/src/index.ts:343](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L343)* ___ @@ -958,7 +1194,7 @@ ___ • **id**: *number* -*Defined in [ethereum-types/src/index.ts:341](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L341)* +*Defined in [ethereum-types/src/index.ts:341](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L341)* ___ @@ -966,7 +1202,7 @@ ___ • **jsonrpc**: *string* -*Defined in [ethereum-types/src/index.ts:342](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L342)* +*Defined in [ethereum-types/src/index.ts:342](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L342)* ___ @@ -974,7 +1210,7 @@ ___ • **result**: *any* -*Defined in [ethereum-types/src/index.ts:340](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L340)* +*Defined in [ethereum-types/src/index.ts:340](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L340)*
@@ -1035,7 +1271,7 @@ This interface allowed sending synchonous requests, support for which was later ▸ **send**(`payload`: [JSONRPCRequestPayload](_ethereum_types_src_index_.jsonrpcrequestpayload.md)): *[JSONRPCResponsePayload](#class-jsonrpcresponsepayload)* -*Defined in [ethereum-types/src/index.ts:45](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L45)* +*Defined in [ethereum-types/src/index.ts:45](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L45)* **Parameters:** @@ -1051,7 +1287,7 @@ ___ ▸ **sendAsync**(`payload`: [JSONRPCRequestPayload](_ethereum_types_src_index_.jsonrpcrequestpayload.md), `callback`: [JSONRPCErrorCallback](#jsonrpcerrorcallback)): *void* -*Defined in [ethereum-types/src/index.ts:44](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L44)* +*Defined in [ethereum-types/src/index.ts:44](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L44)* **Parameters:** @@ -1077,7 +1313,7 @@ before the first attempts to conform to EIP1193 ▸ **send**(`payload`: [JSONRPCRequestPayload](_ethereum_types_src_index_.jsonrpcrequestpayload.md), `callback`: [JSONRPCErrorCallback](#jsonrpcerrorcallback)): *void* -*Defined in [ethereum-types/src/index.ts:54](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L54)* +*Defined in [ethereum-types/src/index.ts:54](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L54)* **Parameters:** @@ -1103,7 +1339,7 @@ however it does not conform entirely. ▸ **send**(`method`: string, `params?`: any[]): *`Promise`* -*Defined in [ethereum-types/src/index.ts:63](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L63)* +*Defined in [ethereum-types/src/index.ts:63](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L63)* **Parameters:** @@ -1129,7 +1365,7 @@ add here • **isMetaMask**? : *undefined | false | true* -*Defined in [ethereum-types/src/index.ts:31](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L31)* +*Defined in [ethereum-types/src/index.ts:31](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L31)* ___ @@ -1137,7 +1373,7 @@ ___ • **isParity**? : *undefined | false | true* -*Defined in [ethereum-types/src/index.ts:32](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L32)* +*Defined in [ethereum-types/src/index.ts:32](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L32)* ___ @@ -1145,7 +1381,7 @@ ___ • **isZeroExProvider**? : *undefined | false | true* -*Defined in [ethereum-types/src/index.ts:30](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L30)* +*Defined in [ethereum-types/src/index.ts:30](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L30)* ## Methods @@ -1153,7 +1389,7 @@ ___ ▸ **enable**(): *`Promise`* -*Defined in [ethereum-types/src/index.ts:34](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L34)* +*Defined in [ethereum-types/src/index.ts:34](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L34)* **Returns:** *`Promise`* @@ -1163,7 +1399,7 @@ ___ ▸ **sendAsync**(`payload`: [JSONRPCRequestPayload](_ethereum_types_src_index_.jsonrpcrequestpayload.md), `callback`: [JSONRPCErrorCallback](#jsonrpcerrorcallback)): *void* -*Defined in [ethereum-types/src/index.ts:35](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L35)* +*Defined in [ethereum-types/src/index.ts:35](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L35)* **Parameters:** @@ -1180,246 +1416,17 @@ ___ ▸ **stop**(): *void* -*Defined in [ethereum-types/src/index.ts:33](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L33)* +*Defined in [ethereum-types/src/index.ts:33](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L33)* **Returns:** *void*
-# Class: AssetBuyer -## Constructors -\+ **new AssetBuyer**(`supportedProvider`: [SupportedProvider](#supportedprovider), `orderProvider`: [OrderProvider](#interface-orderprovider), `options`: `Partial`): *[AssetBuyer](#class-assetbuyer)* - -*Defined in [asset-buyer/src/asset_buyer.ts:83](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-buyer/src/asset_buyer.ts#L83)* - -Instantiates a new AssetBuyer instance - -**Parameters:** - -Name | Type | Default | Description | ------- | ------ | ------ | ------ | -`supportedProvider` | [SupportedProvider](#supportedprovider) | - | The Provider instance you would like to use for interacting with the Ethereum network. | -`orderProvider` | [OrderProvider](#interface-orderprovider) | - | An object that conforms to OrderProvider, see type for definition. | -`options` | `Partial` | {} | Initialization options for the AssetBuyer. See type definition for details. | - -**Returns:** *[AssetBuyer](#class-assetbuyer)* - -An instance of AssetBuyer - -## Properties - -### chainId - -• **chainId**: *number* - -*Defined in [asset-buyer/src/asset_buyer.ts:38](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-buyer/src/asset_buyer.ts#L38)* - -___ - -### expiryBufferSeconds - -• **expiryBufferSeconds**: *number* - -*Defined in [asset-buyer/src/asset_buyer.ts:40](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-buyer/src/asset_buyer.ts#L40)* - -___ - -### orderProvider - -• **orderProvider**: *[OrderProvider](#interface-orderprovider)* - -*Defined in [asset-buyer/src/asset_buyer.ts:37](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-buyer/src/asset_buyer.ts#L37)* - -___ - -### orderRefreshIntervalMs - -• **orderRefreshIntervalMs**: *number* - -*Defined in [asset-buyer/src/asset_buyer.ts:39](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-buyer/src/asset_buyer.ts#L39)* - -___ - -### provider - -• **provider**: *`ZeroExProvider`* - -*Defined in [asset-buyer/src/asset_buyer.ts:36](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-buyer/src/asset_buyer.ts#L36)* - -## Methods - -### executeBuyQuoteAsync - -▸ **executeBuyQuoteAsync**(`buyQuote`: [BuyQuote](#interface-buyquote), `options`: `Partial`): *`Promise`* - -*Defined in [asset-buyer/src/asset_buyer.ts:226](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-buyer/src/asset_buyer.ts#L226)* - -Given a BuyQuote and desired rate, attempt to execute the buy. - -**Parameters:** - -Name | Type | Default | Description | ------- | ------ | ------ | ------ | -`buyQuote` | [BuyQuote](#interface-buyquote) | - | An object that conforms to BuyQuote. See type definition for more information. | -`options` | `Partial` | {} | Options for the execution of the BuyQuote. See type definition for more information. | - -**Returns:** *`Promise`* - -A promise of the txHash. - -___ - -### getAvailableAssetDatasAsync - -▸ **getAvailableAssetDatasAsync**(): *`Promise`* - -*Defined in [asset-buyer/src/asset_buyer.ts:301](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-buyer/src/asset_buyer.ts#L301)* - -Get the asset data of all assets that are purchaseable with ether token (wETH) in the order provider passed in at init. - -**Returns:** *`Promise`* - -An array of asset data strings that can be purchased using wETH. - -___ - -### getBuyQuoteAsync - -▸ **getBuyQuoteAsync**(`assetData`: string, `assetBuyAmount`: `BigNumber`, `options`: `Partial`): *`Promise`* - -*Defined in [asset-buyer/src/asset_buyer.ts:125](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-buyer/src/asset_buyer.ts#L125)* - -Get a `BuyQuote` containing all information relevant to fulfilling a buy given a desired assetData. -You can then pass the `BuyQuote` to `executeBuyQuoteAsync` to execute the buy. - -**Parameters:** - -Name | Type | Default | Description | ------- | ------ | ------ | ------ | -`assetData` | string | - | The assetData of the desired asset to buy (for more info: https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md). | -`assetBuyAmount` | `BigNumber` | - | The amount of asset to buy. | -`options` | `Partial` | {} | Options for the request. See type definition for more information. | - -**Returns:** *`Promise`* - -An object that conforms to BuyQuote that satisfies the request. See type definition for more information. - -___ - -### getBuyQuoteForERC20TokenAddressAsync - -▸ **getBuyQuoteForERC20TokenAddressAsync**(`tokenAddress`: string, `assetBuyAmount`: `BigNumber`, `options`: `Partial`): *`Promise`* - -*Defined in [asset-buyer/src/asset_buyer.ts:173](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-buyer/src/asset_buyer.ts#L173)* - -Get a `BuyQuote` containing all information relevant to fulfilling a buy given a desired ERC20 token address. -You can then pass the `BuyQuote` to `executeBuyQuoteAsync` to execute the buy. - -**Parameters:** - -Name | Type | Default | Description | ------- | ------ | ------ | ------ | -`tokenAddress` | string | - | The ERC20 token address. | -`assetBuyAmount` | `BigNumber` | - | The amount of asset to buy. | -`options` | `Partial` | {} | Options for the request. See type definition for more information. | - -**Returns:** *`Promise`* - -An object that conforms to BuyQuote that satisfies the request. See type definition for more information. - -___ - -### getLiquidityForAssetDataAsync - -▸ **getLiquidityForAssetDataAsync**(`assetData`: string, `options`: `Partial`): *`Promise`* - -*Defined in [asset-buyer/src/asset_buyer.ts:192](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-buyer/src/asset_buyer.ts#L192)* - -Returns information about available liquidity for an asset -Does not factor in slippage or fees - -**Parameters:** - -Name | Type | Default | Description | ------- | ------ | ------ | ------ | -`assetData` | string | - | The assetData of the desired asset to buy (for more info: https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md). | -`options` | `Partial` | {} | Options for the request. See type definition for more information. | - -**Returns:** *`Promise`* - -An object that conforms to LiquidityForAssetData that satisfies the request. See type definition for more information. - -___ - -### getOrdersAndFillableAmountsAsync - -▸ **getOrdersAndFillableAmountsAsync**(`assetData`: string, `shouldForceOrderRefresh`: boolean): *`Promise`* - -*Defined in [asset-buyer/src/asset_buyer.ts:310](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-buyer/src/asset_buyer.ts#L310)* - -Grab orders from the map, if there is a miss or it is time to refresh, fetch and process the orders - -**Parameters:** - -Name | Type | Description | ------- | ------ | ------ | -`assetData` | string | The assetData of the desired asset to buy (for more info: https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md). | -`shouldForceOrderRefresh` | boolean | If set to true, new orders and state will be fetched instead of waiting for the next orderRefreshIntervalMs. | - -**Returns:** *`Promise`* - -___ - -### `Static` getAssetBuyerForProvidedOrders - -▸ **getAssetBuyerForProvidedOrders**(`supportedProvider`: [SupportedProvider](#supportedprovider), `orders`: `SignedOrder`[], `options`: `Partial`): *[AssetBuyer](#class-assetbuyer)* - -*Defined in [asset-buyer/src/asset_buyer.ts:53](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-buyer/src/asset_buyer.ts#L53)* - -Instantiates a new AssetBuyer instance given existing liquidity in the form of orders and feeOrders. - -**Parameters:** - -Name | Type | Default | Description | ------- | ------ | ------ | ------ | -`supportedProvider` | [SupportedProvider](#supportedprovider) | - | The Provider instance you would like to use for interacting with the Ethereum network. | -`orders` | `SignedOrder`[] | - | A non-empty array of objects that conform to SignedOrder. All orders must have the same makerAssetData and takerAssetData (WETH). | -`options` | `Partial` | {} | Initialization options for the AssetBuyer. See type definition for details. | - -**Returns:** *[AssetBuyer](#class-assetbuyer)* - -An instance of AssetBuyer - -___ - -### `Static` getAssetBuyerForStandardRelayerAPIUrl - -▸ **getAssetBuyerForStandardRelayerAPIUrl**(`supportedProvider`: [SupportedProvider](#supportedprovider), `sraApiUrl`: string, `options`: `Partial`): *[AssetBuyer](#class-assetbuyer)* - -*Defined in [asset-buyer/src/asset_buyer.ts:72](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-buyer/src/asset_buyer.ts#L72)* - -Instantiates a new AssetBuyer instance given a [Standard Relayer API](https://github.com/0xProject/standard-relayer-api) endpoint - -**Parameters:** - -Name | Type | Default | Description | ------- | ------ | ------ | ------ | -`supportedProvider` | [SupportedProvider](#supportedprovider) | - | The Provider instance you would like to use for interacting with the Ethereum network. | -`sraApiUrl` | string | - | The standard relayer API base HTTP url you would like to source orders from. | -`options` | `Partial` | {} | Initialization options for the AssetBuyer. See type definition for details. | - -**Returns:** *[AssetBuyer](#class-assetbuyer)* - -An instance of AssetBuyer - -
- - @@ -1532,7 +1539,7 @@ An instance of AssetBuyer *Inherited from [Order](#interface-order).[chainId](#chainid)* -*Defined in [types/src/index.ts:14](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L14)* +*Defined in [types/src/index.ts:14](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L14)* ___ @@ -1542,7 +1549,7 @@ ___ *Inherited from [Order](#interface-order).[exchangeAddress](#exchangeaddress)* -*Defined in [types/src/index.ts:15](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L15)* +*Defined in [types/src/index.ts:15](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L15)* ___ @@ -1552,7 +1559,7 @@ ___ *Inherited from [Order](#interface-order).[expirationTimeSeconds](#expirationtimeseconds)* -*Defined in [types/src/index.ts:24](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L24)* +*Defined in [types/src/index.ts:24](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L24)* ___ @@ -1562,7 +1569,7 @@ ___ *Inherited from [Order](#interface-order).[feeRecipientAddress](#feerecipientaddress)* -*Defined in [types/src/index.ts:18](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L18)* +*Defined in [types/src/index.ts:18](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L18)* ___ @@ -1572,7 +1579,7 @@ ___ *Inherited from [Order](#interface-order).[makerAddress](#makeraddress)* -*Defined in [types/src/index.ts:16](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L16)* +*Defined in [types/src/index.ts:16](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L16)* ___ @@ -1582,7 +1589,7 @@ ___ *Inherited from [Order](#interface-order).[makerAssetAmount](#makerassetamount)* -*Defined in [types/src/index.ts:20](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L20)* +*Defined in [types/src/index.ts:20](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L20)* ___ @@ -1592,7 +1599,7 @@ ___ *Inherited from [Order](#interface-order).[makerAssetData](#makerassetdata)* -*Defined in [types/src/index.ts:26](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L26)* +*Defined in [types/src/index.ts:26](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L26)* ___ @@ -1602,7 +1609,7 @@ ___ *Inherited from [Order](#interface-order).[makerFee](#makerfee)* -*Defined in [types/src/index.ts:22](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L22)* +*Defined in [types/src/index.ts:22](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L22)* ___ @@ -1612,7 +1619,7 @@ ___ *Inherited from [Order](#interface-order).[makerFeeAssetData](#makerfeeassetdata)* -*Defined in [types/src/index.ts:28](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L28)* +*Defined in [types/src/index.ts:28](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L28)* ___ @@ -1622,7 +1629,7 @@ ___ *Inherited from [Order](#interface-order).[salt](#salt)* -*Defined in [types/src/index.ts:25](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L25)* +*Defined in [types/src/index.ts:25](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L25)* ___ @@ -1632,7 +1639,7 @@ ___ *Inherited from [Order](#interface-order).[senderAddress](#senderaddress)* -*Defined in [types/src/index.ts:19](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L19)* +*Defined in [types/src/index.ts:19](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L19)* ___ @@ -1640,7 +1647,7 @@ ___ • **signature**: *string* -*Defined in [types/src/index.ts:33](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L33)* +*Defined in [types/src/index.ts:33](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L33)* ___ @@ -1650,7 +1657,7 @@ ___ *Inherited from [Order](#interface-order).[takerAddress](#takeraddress)* -*Defined in [types/src/index.ts:17](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L17)* +*Defined in [types/src/index.ts:17](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L17)* ___ @@ -1660,7 +1667,7 @@ ___ *Inherited from [Order](#interface-order).[takerAssetAmount](#takerassetamount)* -*Defined in [types/src/index.ts:21](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L21)* +*Defined in [types/src/index.ts:21](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L21)* ___ @@ -1670,7 +1677,7 @@ ___ *Inherited from [Order](#interface-order).[takerAssetData](#takerassetdata)* -*Defined in [types/src/index.ts:27](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L27)* +*Defined in [types/src/index.ts:27](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L27)* ___ @@ -1680,7 +1687,7 @@ ___ *Inherited from [Order](#interface-order).[takerFee](#takerfee)* -*Defined in [types/src/index.ts:23](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L23)* +*Defined in [types/src/index.ts:23](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L23)* ___ @@ -1690,7 +1697,7 @@ ___ *Inherited from [Order](#interface-order).[takerFeeAssetData](#takerfeeassetdata)* -*Defined in [types/src/index.ts:29](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L29)* +*Defined in [types/src/index.ts:29](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L29)*
@@ -1722,33 +1729,6 @@ ___ - - - - - - - - - - - - - - - - - - - - - -## Type aliases - - - - - @@ -1792,7 +1772,7 @@ ___ Ƭ **LiquidityRequestOpts**: *`Pick`* -*Defined in [asset-buyer/src/types.ts:83](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-buyer/src/types.ts#L83)* +*Defined in [asset-buyer/src/types.ts:83](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-buyer/src/types.ts#L83)*
@@ -1817,7 +1797,7 @@ ___ Ƭ **EIP1193Event**: *"accountsChanged" | "networkChanged" | "close" | "connect" | "notification"* -*Defined in [ethereum-types/src/index.ts:70](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L70)* +*Defined in [ethereum-types/src/index.ts:70](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L70)* Interface for providers that conform to EIP 1193 Source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1193.md @@ -1834,7 +1814,7 @@ ___ Ƭ **JSONRPCErrorCallback**: *function* -*Defined in [ethereum-types/src/index.ts:3](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L3)* +*Defined in [ethereum-types/src/index.ts:3](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L3)* #### Type declaration: @@ -1863,7 +1843,7 @@ ___ Ƭ **SupportedProvider**: *[Web3JsProvider](_ethereum_types_src_index_.md#web3jsprovider) | [GanacheProvider](#interface-ganacheprovider) | [EIP1193Provider](#interface-eip1193provider) | [ZeroExProvider](#interface-zeroexprovider)* -*Defined in [ethereum-types/src/index.ts:9](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L9)* +*Defined in [ethereum-types/src/index.ts:9](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L9)* Do not create your own provider. Use an existing provider from a Web3 or ProviderEngine library Read more about Providers in the guides section of the 0x docs. @@ -1878,7 +1858,38 @@ ___ Ƭ **Web3JsProvider**: *[Web3JsV1Provider](#interface-web3jsv1provider) | [Web3JsV2Provider](#interface-web3jsv2provider) | [Web3JsV3Provider](#interface-web3jsv3provider)* -*Defined in [ethereum-types/src/index.ts:11](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L11)* +*Defined in [ethereum-types/src/index.ts:11](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L11)* + +
+ + + + +## Type aliases + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/packages/asset-swapper/docs/reference.mdx b/packages/asset-swapper/docs/reference.mdx index 21632fe4db..0eb345e2fa 100644 --- a/packages/asset-swapper/docs/reference.mdx +++ b/packages/asset-swapper/docs/reference.mdx @@ -1,15 +1,43 @@ -# Interface: TupleDataItem +# Class: InsufficientAssetLiquidityError +Error class representing insufficient asset liquidity -## Properties -### components +## Constructors + + + +\+ **new InsufficientAssetLiquidityError**(`amountAvailableToFill`: `BigNumber`): *[InsufficientAssetLiquidityError](#class-insufficientassetliquidityerror)* + +*Defined in [asset-swapper/src/errors.ts:12](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/errors.ts#L12)* + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`amountAvailableToFill` | `BigNumber` | The amount availabe to fill (in base units) factoring in slippage | + +**Returns:** *[InsufficientAssetLiquidityError](#class-insufficientassetliquidityerror)* + +## Properties + +### amountAvailableToFill + +• **amountAvailableToFill**: *`BigNumber`* + +*Defined in [asset-swapper/src/errors.ts:12](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/errors.ts#L12)* + +The amount availabe to fill (in base units) factoring in slippage. + +___ + +### message + +• **message**: *string* + -• **components**: *[DataItem](#class-dataitem)[]* -*Overrides [DataItem](_ethereum_types_src_index_.dataitem.md).[components](#optional-components)* -*Defined in [ethereum-types/src/index.ts:141](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L141)* ___ @@ -17,19 +45,29 @@ ___ • **name**: *string* -*Inherited from [DataItem](#interface-dataitem).[name](#name)* -*Defined in [ethereum-types/src/index.ts:135](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L135)* + + ___ -### type +### `Optional` stack -• **type**: *string* +• **stack**? : *undefined | string* + + + +*Overrides void* + + + +___ + +### `Static` Error + +▪ **Error**: *`ErrorConstructor`* -*Inherited from [DataItem](#interface-dataitem).[type](#type)* -*Defined in [ethereum-types/src/index.ts:136](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L136)*
@@ -47,7 +85,7 @@ ___ \+ **new SwapQuoteConsumer**(`supportedProvider`: [SupportedProvider](#supportedprovider), `options`: `Partial`): *[SwapQuoteConsumer](#class-swapquoteconsumer)* -*Defined in [asset-swapper/src/quote_consumers/swap_quote_consumer.ts:31](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/quote_consumers/swap_quote_consumer.ts#L31)* +*Defined in [asset-swapper/src/quote_consumers/swap_quote_consumer.ts:31](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/quote_consumers/swap_quote_consumer.ts#L31)* **Parameters:** @@ -64,7 +102,7 @@ Name | Type | Default | • **chainId**: *number* -*Defined in [asset-swapper/src/quote_consumers/swap_quote_consumer.ts:27](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/quote_consumers/swap_quote_consumer.ts#L27)* +*Defined in [asset-swapper/src/quote_consumers/swap_quote_consumer.ts:27](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/quote_consumers/swap_quote_consumer.ts#L27)* ___ @@ -72,7 +110,7 @@ ___ • **provider**: *`ZeroExProvider`* -*Defined in [asset-swapper/src/quote_consumers/swap_quote_consumer.ts:26](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/quote_consumers/swap_quote_consumer.ts#L26)* +*Defined in [asset-swapper/src/quote_consumers/swap_quote_consumer.ts:26](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/quote_consumers/swap_quote_consumer.ts#L26)* ## Methods @@ -82,7 +120,7 @@ ___ *Implementation of [SwapQuoteConsumerBase](#interface-swapquoteconsumerbase)* -*Defined in [asset-swapper/src/quote_consumers/swap_quote_consumer.ts:81](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/quote_consumers/swap_quote_consumer.ts#L81)* +*Defined in [asset-swapper/src/quote_consumers/swap_quote_consumer.ts:81](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/quote_consumers/swap_quote_consumer.ts#L81)* Given a SwapQuote and desired rate (in takerAsset), attempt to execute the swap. @@ -103,7 +141,7 @@ ___ *Implementation of [SwapQuoteConsumerBase](#interface-swapquoteconsumerbase)* -*Defined in [asset-swapper/src/quote_consumers/swap_quote_consumer.ts:53](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/quote_consumers/swap_quote_consumer.ts#L53)* +*Defined in [asset-swapper/src/quote_consumers/swap_quote_consumer.ts:53](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/quote_consumers/swap_quote_consumer.ts#L53)* Given a SwapQuote, returns 'CalldataInfo' for a 0x exchange call. See type definition of CalldataInfo for more information. @@ -122,7 +160,7 @@ ___ ▸ **getOptimalExtensionContractTypeAsync**(`quote`: [SwapQuote](#swapquote), `opts`: `Partial`): *`Promise`* -*Defined in [asset-swapper/src/quote_consumers/swap_quote_consumer.ts:90](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/quote_consumers/swap_quote_consumer.ts#L90)* +*Defined in [asset-swapper/src/quote_consumers/swap_quote_consumer.ts:90](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/quote_consumers/swap_quote_consumer.ts#L90)* **Parameters:** @@ -141,7 +179,7 @@ ___ *Implementation of [SwapQuoteConsumerBase](#interface-swapquoteconsumerbase)* -*Defined in [asset-swapper/src/quote_consumers/swap_quote_consumer.ts:67](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/quote_consumers/swap_quote_consumer.ts#L67)* +*Defined in [asset-swapper/src/quote_consumers/swap_quote_consumer.ts:67](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/quote_consumers/swap_quote_consumer.ts#L67)* Given a SwapQuote, returns 'SmartContractParamsInfo' for a 0x exchange call. See type definition of SmartContractParamsInfo for more information. @@ -165,7 +203,7 @@ Name | Type | Default | Description | \+ **new SwapQuoter**(`supportedProvider`: [SupportedProvider](#supportedprovider), `orderbook`: `Orderbook`, `options`: `Partial`): *[SwapQuoter](#class-swapquoter)* -*Defined in [asset-swapper/src/swap_quoter.ts:124](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/swap_quoter.ts#L124)* +*Defined in [asset-swapper/src/swap_quoter.ts:126](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/swap_quoter.ts#L126)* Instantiates a new SwapQuoter instance @@ -187,7 +225,7 @@ An instance of SwapQuoter • **expiryBufferMs**: *number* -*Defined in [asset-swapper/src/swap_quoter.ts:30](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/swap_quoter.ts#L30)* +*Defined in [asset-swapper/src/swap_quoter.ts:30](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/swap_quoter.ts#L30)* ___ @@ -195,7 +233,7 @@ ___ • **orderbook**: *`Orderbook`* -*Defined in [asset-swapper/src/swap_quoter.ts:29](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/swap_quoter.ts#L29)* +*Defined in [asset-swapper/src/swap_quoter.ts:29](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/swap_quoter.ts#L29)* ___ @@ -203,7 +241,7 @@ ___ • **provider**: *`ZeroExProvider`* -*Defined in [asset-swapper/src/swap_quoter.ts:28](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/swap_quoter.ts#L28)* +*Defined in [asset-swapper/src/swap_quoter.ts:28](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/swap_quoter.ts#L28)* ## Methods @@ -211,7 +249,7 @@ ___ ▸ **destroyAsync**(): *`Promise`* -*Defined in [asset-swapper/src/swap_quoter.ts:396](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/swap_quoter.ts#L396)* +*Defined in [asset-swapper/src/swap_quoter.ts:391](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/swap_quoter.ts#L391)* Destroys any subscriptions or connections. @@ -223,7 +261,7 @@ ___ ▸ **getAvailableMakerAssetDatasAsync**(`takerAssetData`: string): *`Promise`* -*Defined in [asset-swapper/src/swap_quoter.ts:315](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/swap_quoter.ts#L315)* +*Defined in [asset-swapper/src/swap_quoter.ts:309](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/swap_quoter.ts#L309)* Get the asset data of all assets that are purchaseable with takerAssetData in the order provider passed in at init. @@ -243,7 +281,7 @@ ___ ▸ **getAvailableTakerAssetDatasAsync**(`makerAssetData`: string): *`Promise`* -*Defined in [asset-swapper/src/swap_quoter.ts:300](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/swap_quoter.ts#L300)* +*Defined in [asset-swapper/src/swap_quoter.ts:294](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/swap_quoter.ts#L294)* Get the asset data of all assets that can be used to purchase makerAssetData in the order provider passed in at init. @@ -263,7 +301,7 @@ ___ ▸ **getLiquidityForMakerTakerAssetDataPairAsync**(`makerAssetData`: string, `takerAssetData`: string): *`Promise`* -*Defined in [asset-swapper/src/swap_quoter.ts:274](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/swap_quoter.ts#L274)* +*Defined in [asset-swapper/src/swap_quoter.ts:268](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/swap_quoter.ts#L268)* Returns information about available liquidity for an asset Does not factor in slippage or fees @@ -285,7 +323,7 @@ ___ ▸ **getMarketBuySwapQuoteAsync**(`makerTokenAddress`: string, `takerTokenAddress`: string, `makerAssetBuyAmount`: `BigNumber`, `options`: `Partial`): *`Promise`* -*Defined in [asset-swapper/src/swap_quoter.ts:208](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/swap_quoter.ts#L208)* +*Defined in [asset-swapper/src/swap_quoter.ts:210](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/swap_quoter.ts#L210)* Get a `SwapQuote` containing all information relevant to fulfilling a swap between a desired ERC20 token address and ERC20 owned by a provided address. You can then pass the `SwapQuote` to a `SwapQuoteConsumer` to execute a buy, or process SwapQuote for on-chain consumption. @@ -309,7 +347,7 @@ ___ ▸ **getMarketBuySwapQuoteForAssetDataAsync**(`makerAssetData`: string, `takerAssetData`: string, `makerAssetBuyAmount`: `BigNumber`, `options`: `Partial`): *`Promise`* -*Defined in [asset-swapper/src/swap_quoter.ts:183](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/swap_quoter.ts#L183)* +*Defined in [asset-swapper/src/swap_quoter.ts:185](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/swap_quoter.ts#L185)* Get a `SwapQuote` containing all information relevant to fulfilling a swap between a desired ERC20 token address and ERC20 owned by a provided address. You can then pass the `SwapQuote` to a `SwapQuoteConsumer` to execute a buy, or process SwapQuote for on-chain consumption. @@ -333,7 +371,7 @@ ___ ▸ **getMarketSellSwapQuoteAsync**(`makerTokenAddress`: string, `takerTokenAddress`: string, `takerAssetSellAmount`: `BigNumber`, `options`: `Partial`): *`Promise`* -*Defined in [asset-swapper/src/swap_quoter.ts:242](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/swap_quoter.ts#L242)* +*Defined in [asset-swapper/src/swap_quoter.ts:240](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/swap_quoter.ts#L240)* Get a `SwapQuote` containing all information relevant to fulfilling a swap between a desired ERC20 token address and ERC20 owned by a provided address. You can then pass the `SwapQuote` to a `SwapQuoteConsumer` to execute a buy, or process SwapQuote for on-chain consumption. @@ -357,7 +395,7 @@ ___ ▸ **getMarketSellSwapQuoteForAssetDataAsync**(`makerAssetData`: string, `takerAssetData`: string, `takerAssetSellAmount`: `BigNumber`, `options`: `Partial`): *`Promise`* -*Defined in [asset-swapper/src/swap_quoter.ts:157](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/swap_quoter.ts#L157)* +*Defined in [asset-swapper/src/swap_quoter.ts:159](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/swap_quoter.ts#L159)* Get a `SwapQuote` containing all information relevant to fulfilling a swap between a desired ERC20 token address and ERC20 owned by a provided address. You can then pass the `SwapQuote` to a `SwapQuoteConsumer` to execute a buy, or process SwapQuote for on-chain consumption. @@ -381,7 +419,7 @@ ___ ▸ **getOrdersAndFillableAmountsAsync**(`makerAssetData`: string, `takerAssetData`: string): *`Promise`* -*Defined in [asset-swapper/src/swap_quoter.ts:347](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/swap_quoter.ts#L347)* +*Defined in [asset-swapper/src/swap_quoter.ts:341](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/swap_quoter.ts#L341)* Grab orders from the map, if there is a miss or it is time to refresh, fetch and process the orders @@ -400,7 +438,7 @@ ___ ▸ **isTakerAddressAllowanceEnoughForBestAndWorstQuoteInfoAsync**(`swapQuote`: [SwapQuote](#swapquote), `takerAddress`: string): *`Promise<[boolean, boolean]>`* -*Defined in [asset-swapper/src/swap_quoter.ts:378](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/swap_quoter.ts#L378)* +*Defined in [asset-swapper/src/swap_quoter.ts:372](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/swap_quoter.ts#L372)* Util function to check if takerAddress's allowance is enough for 0x exchange contracts to conduct the swap specified by the swapQuote. @@ -419,7 +457,7 @@ ___ ▸ **isTakerMakerAssetDataPairAvailableAsync**(`makerAssetData`: string, `takerAssetData`: string): *`Promise`* -*Defined in [asset-swapper/src/swap_quoter.ts:330](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/swap_quoter.ts#L330)* +*Defined in [asset-swapper/src/swap_quoter.ts:324](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/swap_quoter.ts#L324)* Validates the taker + maker asset pair is available from the order provider provided to `SwapQuote`. @@ -440,7 +478,7 @@ ___ ▸ **getSwapQuoterForMeshEndpoint**(`supportedProvider`: [SupportedProvider](#supportedprovider), `meshEndpoint`: string, `options`: `Partial`): *[SwapQuoter](#class-swapquoter)* -*Defined in [asset-swapper/src/swap_quoter.ts:111](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/swap_quoter.ts#L111)* +*Defined in [asset-swapper/src/swap_quoter.ts:113](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/swap_quoter.ts#L113)* Instantiates a new SwapQuoter instance given a 0x Mesh endpoint. This pulls all available liquidity stored in Mesh @@ -462,7 +500,7 @@ ___ ▸ **getSwapQuoterForProvidedOrders**(`supportedProvider`: [SupportedProvider](#supportedprovider), `orders`: `SignedOrder`[], `options`: `Partial`): *[SwapQuoter](#class-swapquoter)* -*Defined in [asset-swapper/src/swap_quoter.ts:41](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/swap_quoter.ts#L41)* +*Defined in [asset-swapper/src/swap_quoter.ts:41](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/swap_quoter.ts#L41)* Instantiates a new SwapQuoter instance given existing liquidity in the form of orders and feeOrders. @@ -484,7 +522,7 @@ ___ ▸ **getSwapQuoterForStandardRelayerAPIUrl**(`supportedProvider`: [SupportedProvider](#supportedprovider), `sraApiUrl`: string, `options`: `Partial`): *[SwapQuoter](#class-swapquoter)* -*Defined in [asset-swapper/src/swap_quoter.ts:61](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/swap_quoter.ts#L61)* +*Defined in [asset-swapper/src/swap_quoter.ts:61](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/swap_quoter.ts#L61)* Instantiates a new SwapQuoter instance given a [Standard Relayer API](https://github.com/0xProject/standard-relayer-api) endpoint @@ -506,7 +544,7 @@ ___ ▸ **getSwapQuoterForStandardRelayerAPIWebsocket**(`supportedProvider`: [SupportedProvider](#supportedprovider), `sraApiUrl`: string, `sraWebsocketAPIUrl`: string, `options`: `Partial`): *[SwapQuoter](#class-swapquoter)* -*Defined in [asset-swapper/src/swap_quoter.ts:87](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/swap_quoter.ts#L87)* +*Defined in [asset-swapper/src/swap_quoter.ts:88](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/swap_quoter.ts#L88)* Instantiates a new SwapQuoter instance given a [Standard Relayer API](https://github.com/0xProject/standard-relayer-api) endpoint and a websocket endpoint. This is more effecient than `getSwapQuoterForStandardRelayerAPIUrl` when requesting multiple quotes. @@ -535,7 +573,7 @@ An instance of SwapQuoter \+ **new BaseOrderProvider**(`orderStore`: [OrderStore](_orderbook_src_order_store_.orderstore.md)): *[BaseOrderProvider](#class-baseorderprovider)* -*Defined in [orderbook/src/order_provider/base_order_provider.ts:12](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/orderbook/src/order_provider/base_order_provider.ts#L12)* +*Defined in [orderbook/src/order_provider/base_order_provider.ts:12](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/orderbook/src/order_provider/base_order_provider.ts#L12)* **Parameters:** @@ -551,7 +589,7 @@ Name | Type | • **_orderStore**: *[OrderStore](#class-orderstore)* -*Defined in [orderbook/src/order_provider/base_order_provider.ts:12](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/orderbook/src/order_provider/base_order_provider.ts#L12)* +*Defined in [orderbook/src/order_provider/base_order_provider.ts:12](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/orderbook/src/order_provider/base_order_provider.ts#L12)* ## Methods @@ -559,7 +597,7 @@ Name | Type | ▸ **addOrdersAsync**(`orders`: `SignedOrder`[]): *`Promise`* -*Defined in [orderbook/src/order_provider/base_order_provider.ts:27](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/orderbook/src/order_provider/base_order_provider.ts#L27)* +*Defined in [orderbook/src/order_provider/base_order_provider.ts:27](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/orderbook/src/order_provider/base_order_provider.ts#L27)* **Parameters:** @@ -575,7 +613,7 @@ ___ ▸ **createSubscriptionForAssetPairAsync**(`makerAssetData`: string, `takerAssetData`: string): *`Promise`* -*Defined in [orderbook/src/order_provider/base_order_provider.ts:18](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/orderbook/src/order_provider/base_order_provider.ts#L18)* +*Defined in [orderbook/src/order_provider/base_order_provider.ts:18](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/orderbook/src/order_provider/base_order_provider.ts#L18)* **Parameters:** @@ -592,7 +630,7 @@ ___ ▸ **destroyAsync**(): *`Promise`* -*Defined in [orderbook/src/order_provider/base_order_provider.ts:25](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/orderbook/src/order_provider/base_order_provider.ts#L25)* +*Defined in [orderbook/src/order_provider/base_order_provider.ts:25](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/orderbook/src/order_provider/base_order_provider.ts#L25)* **Returns:** *`Promise`* @@ -602,7 +640,7 @@ ___ ▸ **getAvailableAssetDatasAsync**(): *`Promise`* -*Defined in [orderbook/src/order_provider/base_order_provider.ts:23](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/orderbook/src/order_provider/base_order_provider.ts#L23)* +*Defined in [orderbook/src/order_provider/base_order_provider.ts:23](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/orderbook/src/order_provider/base_order_provider.ts#L23)* **Returns:** *`Promise`* @@ -617,7 +655,7 @@ ___ \+ **new OrderSet**(`orders`: `APIOrder`[]): *[OrderSet](#class-orderset)* -*Defined in [orderbook/src/order_set.ts:6](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/orderbook/src/order_set.ts#L6)* +*Defined in [orderbook/src/order_set.ts:6](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/orderbook/src/order_set.ts#L6)* **Parameters:** @@ -633,7 +671,7 @@ Name | Type | Default | ▸ **add**(`item`: `APIOrder`): *void* -*Defined in [orderbook/src/order_set.ts:19](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/orderbook/src/order_set.ts#L19)* +*Defined in [orderbook/src/order_set.ts:19](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/orderbook/src/order_set.ts#L19)* **Parameters:** @@ -649,7 +687,7 @@ ___ ▸ **addMany**(`items`: `APIOrder`[]): *void* -*Defined in [orderbook/src/order_set.ts:25](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/orderbook/src/order_set.ts#L25)* +*Defined in [orderbook/src/order_set.ts:25](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/orderbook/src/order_set.ts#L25)* **Parameters:** @@ -665,7 +703,7 @@ ___ ▸ **delete**(`item`: `APIOrder`): *boolean* -*Defined in [orderbook/src/order_set.ts:57](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/orderbook/src/order_set.ts#L57)* +*Defined in [orderbook/src/order_set.ts:57](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/orderbook/src/order_set.ts#L57)* **Parameters:** @@ -681,7 +719,7 @@ ___ ▸ **deleteMany**(`items`: `APIOrder`[]): *void* -*Defined in [orderbook/src/order_set.ts:61](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/orderbook/src/order_set.ts#L61)* +*Defined in [orderbook/src/order_set.ts:61](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/orderbook/src/order_set.ts#L61)* **Parameters:** @@ -697,7 +735,7 @@ ___ ▸ **diff**(`other`: [OrderSet](#class-orderset)): *object* -*Defined in [orderbook/src/order_set.ts:35](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/orderbook/src/order_set.ts#L35)* +*Defined in [orderbook/src/order_set.ts:35](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/orderbook/src/order_set.ts#L35)* **Parameters:** @@ -713,7 +751,7 @@ ___ ▸ **has**(`order`: `APIOrder`): *boolean* -*Defined in [orderbook/src/order_set.ts:31](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/orderbook/src/order_set.ts#L31)* +*Defined in [orderbook/src/order_set.ts:31](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/orderbook/src/order_set.ts#L31)* **Parameters:** @@ -729,7 +767,7 @@ ___ ▸ **size**(): *number* -*Defined in [orderbook/src/order_set.ts:15](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/orderbook/src/order_set.ts#L15)* +*Defined in [orderbook/src/order_set.ts:15](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/orderbook/src/order_set.ts#L15)* **Returns:** *number* @@ -739,7 +777,7 @@ ___ ▸ **values**(): *`IterableIterator`* -*Defined in [orderbook/src/order_set.ts:53](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/orderbook/src/order_set.ts#L53)* +*Defined in [orderbook/src/order_set.ts:53](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/orderbook/src/order_set.ts#L53)* **Returns:** *`IterableIterator`* @@ -754,7 +792,7 @@ ___ ▸ **getOrderSetForAssetPair**(`assetPairKey`: string): *[OrderSet](#class-orderset)* -*Defined in [orderbook/src/order_store.ts:19](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/orderbook/src/order_store.ts#L19)* +*Defined in [orderbook/src/order_store.ts:19](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/orderbook/src/order_store.ts#L19)* **Parameters:** @@ -770,7 +808,7 @@ ___ ▸ **getOrderSetForAssets**(`makerAssetData`: string, `takerAssetData`: string): *[OrderSet](#class-orderset)* -*Defined in [orderbook/src/order_store.ts:15](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/orderbook/src/order_store.ts#L15)* +*Defined in [orderbook/src/order_store.ts:15](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/orderbook/src/order_store.ts#L15)* **Parameters:** @@ -787,7 +825,7 @@ ___ ▸ **has**(`assetPairKey`: string): *boolean* -*Defined in [orderbook/src/order_store.ts:34](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/orderbook/src/order_store.ts#L34)* +*Defined in [orderbook/src/order_store.ts:34](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/orderbook/src/order_store.ts#L34)* **Parameters:** @@ -803,7 +841,7 @@ ___ ▸ **keys**(): *`IterableIterator`* -*Defined in [orderbook/src/order_store.ts:40](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/orderbook/src/order_store.ts#L40)* +*Defined in [orderbook/src/order_store.ts:40](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/orderbook/src/order_store.ts#L40)* **Returns:** *`IterableIterator`* @@ -813,7 +851,7 @@ ___ ▸ **update**(`addedRemoved`: [AddedRemovedOrders](#interface-addedremovedorders)): *void* -*Defined in [orderbook/src/order_store.ts:28](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/orderbook/src/order_store.ts#L28)* +*Defined in [orderbook/src/order_store.ts:28](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/orderbook/src/order_store.ts#L28)* **Parameters:** @@ -829,7 +867,7 @@ ___ ▸ **values**(`assetPairKey`: string): *`APIOrder`[]* -*Defined in [orderbook/src/order_store.ts:37](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/orderbook/src/order_store.ts#L37)* +*Defined in [orderbook/src/order_store.ts:37](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/orderbook/src/order_store.ts#L37)* **Parameters:** @@ -845,7 +883,7 @@ ___ ▸ **assetPairKeyToAssets**(`assetPairKey`: string): *string[]* -*Defined in [orderbook/src/order_store.ts:12](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/orderbook/src/order_store.ts#L12)* +*Defined in [orderbook/src/order_store.ts:12](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/orderbook/src/order_store.ts#L12)* **Parameters:** @@ -861,7 +899,7 @@ ___ ▸ **getKeyForAssetPair**(`makerAssetData`: string, `takerAssetData`: string): *string* -*Defined in [orderbook/src/order_store.ts:9](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/orderbook/src/order_store.ts#L9)* +*Defined in [orderbook/src/order_store.ts:9](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/orderbook/src/order_store.ts#L9)* **Parameters:** @@ -883,7 +921,7 @@ Name | Type | \+ **new Orderbook**(`orderProvider`: [BaseOrderProvider](_orderbook_src_order_provider_base_order_provider_.baseorderprovider.md), `orderStore`: [OrderStore](_orderbook_src_order_store_.orderstore.md)): *[Orderbook](#class-orderbook)* -*Defined in [orderbook/src/orderbook.ts:55](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/orderbook/src/orderbook.ts#L55)* +*Defined in [orderbook/src/orderbook.ts:55](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/orderbook/src/orderbook.ts#L55)* Creates an Orderbook with the order provider. All order updates are stored in the `OrderStore`. @@ -903,7 +941,7 @@ Name | Type | Description | ▸ **addOrdersAsync**(`orders`: `SignedOrder`[]): *`Promise`* -*Defined in [orderbook/src/orderbook.ts:98](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/orderbook/src/orderbook.ts#L98)* +*Defined in [orderbook/src/orderbook.ts:98](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/orderbook/src/orderbook.ts#L98)* Adds the orders to the Order Provider. All accepted orders will be returned and rejected orders will be returned with an message indicating a reason for its rejection @@ -922,7 +960,7 @@ ___ ▸ **destroyAsync**(): *`Promise`* -*Defined in [orderbook/src/orderbook.ts:104](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/orderbook/src/orderbook.ts#L104)* +*Defined in [orderbook/src/orderbook.ts:104](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/orderbook/src/orderbook.ts#L104)* Destroys any subscriptions or connections. @@ -934,7 +972,7 @@ ___ ▸ **getAvailableAssetDatasAsync**(): *`Promise`* -*Defined in [orderbook/src/orderbook.ts:90](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/orderbook/src/orderbook.ts#L90)* +*Defined in [orderbook/src/orderbook.ts:90](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/orderbook/src/orderbook.ts#L90)* Returns all of the Available Asset Pairs for the provided Order Provider. @@ -946,7 +984,7 @@ ___ ▸ **getOrdersAsync**(`makerAssetData`: string, `takerAssetData`: string): *`Promise`* -*Defined in [orderbook/src/orderbook.ts:75](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/orderbook/src/orderbook.ts#L75)* +*Defined in [orderbook/src/orderbook.ts:75](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/orderbook/src/orderbook.ts#L75)* Returns all orders where the order.makerAssetData == makerAssetData and order.takerAssetData == takerAssetData. This pair is then subscribed to @@ -969,7 +1007,7 @@ ___ ▸ **getOrderbookForMeshProvider**(`opts`: [MeshOrderProviderOpts](#interface-meshorderprovideropts)): *[Orderbook](#class-orderbook)* -*Defined in [orderbook/src/orderbook.ts:52](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/orderbook/src/orderbook.ts#L52)* +*Defined in [orderbook/src/orderbook.ts:52](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/orderbook/src/orderbook.ts#L52)* Creates an Orderbook with a Mesh Order Provider. This Provider fetches ALL orders and subscribes to updates on ALL orders. @@ -988,7 +1026,7 @@ ___ ▸ **getOrderbookForPollingProvider**(`opts`: [SRAPollingOrderProviderOpts](#interface-srapollingorderprovideropts)): *[Orderbook](#class-orderbook)* -*Defined in [orderbook/src/orderbook.ts:43](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/orderbook/src/orderbook.ts#L43)* +*Defined in [orderbook/src/orderbook.ts:43](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/orderbook/src/orderbook.ts#L43)* Creates an Orderbook with SRA Polling Provider. This Provider simply polls every interval. @@ -1006,7 +1044,7 @@ ___ ▸ **getOrderbookForProvidedOrders**(`orders`: `SignedOrder`[]): *[Orderbook](#class-orderbook)* -*Defined in [orderbook/src/orderbook.ts:26](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/orderbook/src/orderbook.ts#L26)* +*Defined in [orderbook/src/orderbook.ts:26](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/orderbook/src/orderbook.ts#L26)* Creates an Orderbook with the provided orders. This provider simply stores the orders and allows querying. No validation or subscriptions occur. @@ -1025,7 +1063,7 @@ ___ ▸ **getOrderbookForWebsocketProvider**(`opts`: [SRAWebsocketOrderProviderOpts](#interface-srawebsocketorderprovideropts)): *[Orderbook](#class-orderbook)* -*Defined in [orderbook/src/orderbook.ts:35](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/orderbook/src/orderbook.ts#L35)* +*Defined in [orderbook/src/orderbook.ts:35](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/orderbook/src/orderbook.ts#L35)* Creates an Orderbook with the SRA Websocket Provider. This Provider fetches orders via the SRA http endpoint and then subscribes to the asset pair for future updates. @@ -1051,7 +1089,7 @@ Represents the varying smart contracts that can consume a valid swap quote • **Forwarder**: = "FORWARDER" -*Defined in [asset-swapper/src/types.ts:88](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L88)* +*Defined in [asset-swapper/src/types.ts:90](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L90)* ___ @@ -1059,7 +1097,7 @@ ___ • **None**: = "NONE" -*Defined in [asset-swapper/src/types.ts:89](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L89)* +*Defined in [asset-swapper/src/types.ts:91](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L91)*
@@ -1076,7 +1114,7 @@ Possible error messages thrown by an SwapQuoter instance or associated static me • **AssetUnavailable**: = "ASSET_UNAVAILABLE" -*Defined in [asset-swapper/src/types.ts:303](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L303)* +*Defined in [asset-swapper/src/types.ts:305](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L305)* ___ @@ -1084,7 +1122,7 @@ ___ • **FeeAssetUnavailable**: = "FEE_ASSET_UNAVAILABLE" -*Defined in [asset-swapper/src/types.ts:304](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L304)* +*Defined in [asset-swapper/src/types.ts:306](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L306)* ___ @@ -1092,7 +1130,7 @@ ___ • **InsufficientAssetLiquidity**: = "INSUFFICIENT_ASSET_LIQUIDITY" -*Defined in [asset-swapper/src/types.ts:300](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L300)* +*Defined in [asset-swapper/src/types.ts:302](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L302)* ___ @@ -1100,7 +1138,7 @@ ___ • **InsufficientZrxLiquidity**: = "INSUFFICIENT_ZRX_LIQUIDITY" -*Defined in [asset-swapper/src/types.ts:301](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L301)* +*Defined in [asset-swapper/src/types.ts:303](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L303)* ___ @@ -1108,7 +1146,7 @@ ___ • **InvalidOrderProviderResponse**: = "INVALID_ORDER_PROVIDER_RESPONSE" -*Defined in [asset-swapper/src/types.ts:302](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L302)* +*Defined in [asset-swapper/src/types.ts:304](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L304)* ___ @@ -1116,7 +1154,7 @@ ___ • **NoEtherTokenContractFound**: = "NO_ETHER_TOKEN_CONTRACT_FOUND" -*Defined in [asset-swapper/src/types.ts:297](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L297)* +*Defined in [asset-swapper/src/types.ts:299](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L299)* ___ @@ -1124,7 +1162,7 @@ ___ • **NoZrxTokenContractFound**: = "NO_ZRX_TOKEN_CONTRACT_FOUND" -*Defined in [asset-swapper/src/types.ts:298](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L298)* +*Defined in [asset-swapper/src/types.ts:300](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L300)* ___ @@ -1132,7 +1170,7 @@ ___ • **StandardRelayerApiError**: = "STANDARD_RELAYER_API_ERROR" -*Defined in [asset-swapper/src/types.ts:299](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L299)* +*Defined in [asset-swapper/src/types.ts:301](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L301)*
@@ -1167,10 +1205,6 @@ ___ - - - -
# Interface: CalldataInfo @@ -1187,7 +1221,7 @@ ethAmount: If provided, the eth amount in wei to send with the smart contract ca • **calldataHexString**: *string* -*Defined in [asset-swapper/src/types.ts:37](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L37)* +*Defined in [asset-swapper/src/types.ts:39](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L39)* ___ @@ -1195,7 +1229,7 @@ ___ • **ethAmount**? : *`BigNumber`* -*Defined in [asset-swapper/src/types.ts:40](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L40)* +*Defined in [asset-swapper/src/types.ts:42](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L42)* ___ @@ -1203,7 +1237,7 @@ ___ • **methodAbi**: *`MethodAbi`* -*Defined in [asset-swapper/src/types.ts:38](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L38)* +*Defined in [asset-swapper/src/types.ts:40](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L40)* ___ @@ -1211,7 +1245,7 @@ ___ • **toAddress**: *string* -*Defined in [asset-swapper/src/types.ts:39](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L39)* +*Defined in [asset-swapper/src/types.ts:41](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L41)*
@@ -1236,7 +1270,7 @@ ___ *Inherited from [ForwarderSwapQuoteGetOutputOpts](#interface-forwarderswapquotegetoutputopts).[ethAmount](#optional-ethamount)* -*Defined in [asset-swapper/src/types.ts:179](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L179)* +*Defined in [asset-swapper/src/types.ts:181](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L181)* ___ @@ -1246,7 +1280,7 @@ ___ *Inherited from [ForwarderSwapQuoteGetOutputOpts](#interface-forwarderswapquotegetoutputopts).[feePercentage](#feepercentage)* -*Defined in [asset-swapper/src/types.ts:177](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L177)* +*Defined in [asset-swapper/src/types.ts:179](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L179)* ___ @@ -1256,7 +1290,7 @@ ___ *Inherited from [ForwarderSwapQuoteGetOutputOpts](#interface-forwarderswapquotegetoutputopts).[feeRecipient](#feerecipient)* -*Defined in [asset-swapper/src/types.ts:178](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L178)* +*Defined in [asset-swapper/src/types.ts:180](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L180)* ___ @@ -1266,7 +1300,7 @@ ___ *Inherited from [SwapQuoteExecutionOptsBase](#interface-swapquoteexecutionoptsbase).[gasLimit](#optional-gaslimit)* -*Defined in [asset-swapper/src/types.ts:167](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L167)* +*Defined in [asset-swapper/src/types.ts:169](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L169)* ___ @@ -1276,7 +1310,7 @@ ___ *Inherited from [SwapQuoteExecutionOptsBase](#interface-swapquoteexecutionoptsbase).[gasPrice](#optional-gasprice)* -*Defined in [asset-swapper/src/types.ts:168](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L168)* +*Defined in [asset-swapper/src/types.ts:170](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L170)* ___ @@ -1286,7 +1320,7 @@ ___ *Inherited from [SwapQuoteExecutionOptsBase](#interface-swapquoteexecutionoptsbase).[takerAddress](#optional-takeraddress)* -*Defined in [asset-swapper/src/types.ts:166](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L166)* +*Defined in [asset-swapper/src/types.ts:168](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L168)*
@@ -1303,7 +1337,7 @@ ethAmount: The amount of eth (in Wei) sent to the forwarder contract. • **ethAmount**? : *`BigNumber`* -*Defined in [asset-swapper/src/types.ts:179](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L179)* +*Defined in [asset-swapper/src/types.ts:181](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L181)* ___ @@ -1311,7 +1345,7 @@ ___ • **feePercentage**: *number* -*Defined in [asset-swapper/src/types.ts:177](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L177)* +*Defined in [asset-swapper/src/types.ts:179](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L179)* ___ @@ -1319,7 +1353,7 @@ ___ • **feeRecipient**: *string* -*Defined in [asset-swapper/src/types.ts:178](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L178)* +*Defined in [asset-swapper/src/types.ts:180](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L180)*
@@ -1332,7 +1366,7 @@ ___ • **ethAmount**? : *`BigNumber`* -*Defined in [asset-swapper/src/types.ts:186](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L186)* +*Defined in [asset-swapper/src/types.ts:188](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L188)* ___ @@ -1340,7 +1374,7 @@ ___ • **takerAddress**? : *undefined | string* -*Defined in [asset-swapper/src/types.ts:185](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L185)* +*Defined in [asset-swapper/src/types.ts:187](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L187)*
@@ -1355,7 +1389,7 @@ Represents available liquidity for a given assetData • **makerTokensAvailableInBaseUnits**: *`BigNumber`* -*Defined in [asset-swapper/src/types.ts:320](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L320)* +*Defined in [asset-swapper/src/types.ts:322](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L322)* ___ @@ -1363,7 +1397,7 @@ ___ • **takerTokensAvailableInBaseUnits**: *`BigNumber`* -*Defined in [asset-swapper/src/types.ts:321](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L321)* +*Defined in [asset-swapper/src/types.ts:323](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L323)*
@@ -1381,7 +1415,7 @@ type: Specified MarketOperation the SwapQuote is provided for *Inherited from [SwapQuoteBase](#interface-swapquotebase).[bestCaseQuoteInfo](#bestcasequoteinfo)* -*Defined in [asset-swapper/src/types.ts:217](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L217)* +*Defined in [asset-swapper/src/types.ts:219](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L219)* ___ @@ -1391,7 +1425,7 @@ ___ *Inherited from [SwapQuoteBase](#interface-swapquotebase).[feeOrders](#feeorders)* -*Defined in [asset-swapper/src/types.ts:216](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L216)* +*Defined in [asset-swapper/src/types.ts:218](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L218)* ___ @@ -1401,7 +1435,7 @@ ___ *Inherited from [SwapQuoteBase](#interface-swapquotebase).[makerAssetData](#makerassetdata)* -*Defined in [asset-swapper/src/types.ts:214](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L214)* +*Defined in [asset-swapper/src/types.ts:216](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L216)* ___ @@ -1409,7 +1443,7 @@ ___ • **makerAssetFillAmount**: *`BigNumber`* -*Defined in [asset-swapper/src/types.ts:235](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L235)* +*Defined in [asset-swapper/src/types.ts:237](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L237)* ___ @@ -1419,7 +1453,7 @@ ___ *Inherited from [SwapQuoteBase](#interface-swapquotebase).[orders](#orders)* -*Defined in [asset-swapper/src/types.ts:215](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L215)* +*Defined in [asset-swapper/src/types.ts:217](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L217)* ___ @@ -1429,7 +1463,7 @@ ___ *Inherited from [SwapQuoteBase](#interface-swapquotebase).[takerAssetData](#takerassetdata)* -*Defined in [asset-swapper/src/types.ts:213](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L213)* +*Defined in [asset-swapper/src/types.ts:215](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L215)* ___ @@ -1437,7 +1471,7 @@ ___ • **type**: *`Buy`* -*Defined in [asset-swapper/src/types.ts:236](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L236)* +*Defined in [asset-swapper/src/types.ts:238](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L238)* ___ @@ -1447,7 +1481,7 @@ ___ *Inherited from [SwapQuoteBase](#interface-swapquotebase).[worstCaseQuoteInfo](#worstcasequoteinfo)* -*Defined in [asset-swapper/src/types.ts:218](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L218)* +*Defined in [asset-swapper/src/types.ts:220](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L220)*
@@ -1462,7 +1496,7 @@ ___ *Inherited from [SwapQuoteBase](#interface-swapquotebase).[bestCaseQuoteInfo](#bestcasequoteinfo)* -*Defined in [asset-swapper/src/types.ts:217](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L217)* +*Defined in [asset-swapper/src/types.ts:219](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L219)* ___ @@ -1472,7 +1506,7 @@ ___ *Inherited from [SwapQuoteBase](#interface-swapquotebase).[feeOrders](#feeorders)* -*Defined in [asset-swapper/src/types.ts:216](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L216)* +*Defined in [asset-swapper/src/types.ts:218](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L218)* ___ @@ -1482,7 +1516,7 @@ ___ *Inherited from [SwapQuoteWithAffiliateFeeBase](#interface-swapquotewithaffiliatefeebase).[feePercentage](#feepercentage)* -*Defined in [asset-swapper/src/types.ts:240](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L240)* +*Defined in [asset-swapper/src/types.ts:242](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L242)* ___ @@ -1492,7 +1526,7 @@ ___ *Inherited from [SwapQuoteBase](#interface-swapquotebase).[makerAssetData](#makerassetdata)* -*Defined in [asset-swapper/src/types.ts:214](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L214)* +*Defined in [asset-swapper/src/types.ts:216](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L216)* ___ @@ -1502,7 +1536,7 @@ ___ *Inherited from [MarketBuySwapQuote](#interface-marketbuyswapquote).[makerAssetFillAmount](#makerassetfillamount)* -*Defined in [asset-swapper/src/types.ts:235](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L235)* +*Defined in [asset-swapper/src/types.ts:237](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L237)* ___ @@ -1512,7 +1546,7 @@ ___ *Inherited from [SwapQuoteBase](#interface-swapquotebase).[orders](#orders)* -*Defined in [asset-swapper/src/types.ts:215](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L215)* +*Defined in [asset-swapper/src/types.ts:217](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L217)* ___ @@ -1522,7 +1556,7 @@ ___ *Inherited from [SwapQuoteBase](#interface-swapquotebase).[takerAssetData](#takerassetdata)* -*Defined in [asset-swapper/src/types.ts:213](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L213)* +*Defined in [asset-swapper/src/types.ts:215](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L215)* ___ @@ -1532,7 +1566,7 @@ ___ *Inherited from [MarketBuySwapQuote](#interface-marketbuyswapquote).[type](#type)* -*Defined in [asset-swapper/src/types.ts:236](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L236)* +*Defined in [asset-swapper/src/types.ts:238](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L238)* ___ @@ -1542,7 +1576,7 @@ ___ *Inherited from [SwapQuoteBase](#interface-swapquotebase).[worstCaseQuoteInfo](#worstcasequoteinfo)* -*Defined in [asset-swapper/src/types.ts:218](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L218)* +*Defined in [asset-swapper/src/types.ts:220](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L220)*
@@ -1560,7 +1594,7 @@ type: Specified MarketOperation the SwapQuote is provided for *Inherited from [SwapQuoteBase](#interface-swapquotebase).[bestCaseQuoteInfo](#bestcasequoteinfo)* -*Defined in [asset-swapper/src/types.ts:217](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L217)* +*Defined in [asset-swapper/src/types.ts:219](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L219)* ___ @@ -1570,7 +1604,7 @@ ___ *Inherited from [SwapQuoteBase](#interface-swapquotebase).[feeOrders](#feeorders)* -*Defined in [asset-swapper/src/types.ts:216](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L216)* +*Defined in [asset-swapper/src/types.ts:218](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L218)* ___ @@ -1580,7 +1614,7 @@ ___ *Inherited from [SwapQuoteBase](#interface-swapquotebase).[makerAssetData](#makerassetdata)* -*Defined in [asset-swapper/src/types.ts:214](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L214)* +*Defined in [asset-swapper/src/types.ts:216](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L216)* ___ @@ -1590,7 +1624,7 @@ ___ *Inherited from [SwapQuoteBase](#interface-swapquotebase).[orders](#orders)* -*Defined in [asset-swapper/src/types.ts:215](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L215)* +*Defined in [asset-swapper/src/types.ts:217](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L217)* ___ @@ -1600,7 +1634,7 @@ ___ *Inherited from [SwapQuoteBase](#interface-swapquotebase).[takerAssetData](#takerassetdata)* -*Defined in [asset-swapper/src/types.ts:213](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L213)* +*Defined in [asset-swapper/src/types.ts:215](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L215)* ___ @@ -1608,7 +1642,7 @@ ___ • **takerAssetFillAmount**: *`BigNumber`* -*Defined in [asset-swapper/src/types.ts:226](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L226)* +*Defined in [asset-swapper/src/types.ts:228](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L228)* ___ @@ -1616,7 +1650,7 @@ ___ • **type**: *`Sell`* -*Defined in [asset-swapper/src/types.ts:227](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L227)* +*Defined in [asset-swapper/src/types.ts:229](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L229)* ___ @@ -1626,7 +1660,7 @@ ___ *Inherited from [SwapQuoteBase](#interface-swapquotebase).[worstCaseQuoteInfo](#worstcasequoteinfo)* -*Defined in [asset-swapper/src/types.ts:218](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L218)* +*Defined in [asset-swapper/src/types.ts:220](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L220)*
@@ -1641,7 +1675,7 @@ ___ *Inherited from [SwapQuoteBase](#interface-swapquotebase).[bestCaseQuoteInfo](#bestcasequoteinfo)* -*Defined in [asset-swapper/src/types.ts:217](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L217)* +*Defined in [asset-swapper/src/types.ts:219](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L219)* ___ @@ -1651,7 +1685,7 @@ ___ *Inherited from [SwapQuoteBase](#interface-swapquotebase).[feeOrders](#feeorders)* -*Defined in [asset-swapper/src/types.ts:216](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L216)* +*Defined in [asset-swapper/src/types.ts:218](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L218)* ___ @@ -1661,7 +1695,7 @@ ___ *Inherited from [SwapQuoteWithAffiliateFeeBase](#interface-swapquotewithaffiliatefeebase).[feePercentage](#feepercentage)* -*Defined in [asset-swapper/src/types.ts:240](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L240)* +*Defined in [asset-swapper/src/types.ts:242](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L242)* ___ @@ -1671,7 +1705,7 @@ ___ *Inherited from [SwapQuoteBase](#interface-swapquotebase).[makerAssetData](#makerassetdata)* -*Defined in [asset-swapper/src/types.ts:214](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L214)* +*Defined in [asset-swapper/src/types.ts:216](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L216)* ___ @@ -1681,7 +1715,7 @@ ___ *Inherited from [SwapQuoteBase](#interface-swapquotebase).[orders](#orders)* -*Defined in [asset-swapper/src/types.ts:215](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L215)* +*Defined in [asset-swapper/src/types.ts:217](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L217)* ___ @@ -1691,7 +1725,7 @@ ___ *Inherited from [SwapQuoteBase](#interface-swapquotebase).[takerAssetData](#takerassetdata)* -*Defined in [asset-swapper/src/types.ts:213](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L213)* +*Defined in [asset-swapper/src/types.ts:215](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L215)* ___ @@ -1701,7 +1735,7 @@ ___ *Inherited from [MarketSellSwapQuote](#interface-marketsellswapquote).[takerAssetFillAmount](#takerassetfillamount)* -*Defined in [asset-swapper/src/types.ts:226](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L226)* +*Defined in [asset-swapper/src/types.ts:228](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L228)* ___ @@ -1711,7 +1745,7 @@ ___ *Inherited from [MarketSellSwapQuote](#interface-marketsellswapquote).[type](#type)* -*Defined in [asset-swapper/src/types.ts:227](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L227)* +*Defined in [asset-swapper/src/types.ts:229](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L229)* ___ @@ -1721,7 +1755,7 @@ ___ *Inherited from [SwapQuoteBase](#interface-swapquotebase).[worstCaseQuoteInfo](#worstcasequoteinfo)* -*Defined in [asset-swapper/src/types.ts:218](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L218)* +*Defined in [asset-swapper/src/types.ts:220](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L220)*
@@ -1754,7 +1788,7 @@ methodAbi: The ABI of the smart contract method to call with params. • **ethAmount**? : *`BigNumber`* -*Defined in [asset-swapper/src/types.ts:53](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L53)* +*Defined in [asset-swapper/src/types.ts:55](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L55)* ___ @@ -1762,7 +1796,7 @@ ___ • **methodAbi**: *`MethodAbi`* -*Defined in [asset-swapper/src/types.ts:54](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L54)* +*Defined in [asset-swapper/src/types.ts:56](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L56)* ___ @@ -1770,7 +1804,7 @@ ___ • **params**: *`T`* -*Defined in [asset-swapper/src/types.ts:51](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L51)* +*Defined in [asset-swapper/src/types.ts:53](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L53)* ___ @@ -1778,7 +1812,7 @@ ___ • **toAddress**: *string* -*Defined in [asset-swapper/src/types.ts:52](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L52)* +*Defined in [asset-swapper/src/types.ts:54](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L54)*
@@ -1807,7 +1841,7 @@ executeSwapQuoteOrThrowAsync: Executes a web3 transaction to swap for tokens wit ▸ **executeSwapQuoteOrThrowAsync**(`quote`: [SwapQuote](#swapquote), `opts`: `Partial`): *`Promise`* -*Defined in [asset-swapper/src/types.ts:145](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L145)* +*Defined in [asset-swapper/src/types.ts:147](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L147)* **Parameters:** @@ -1824,7 +1858,7 @@ ___ ▸ **getCalldataOrThrowAsync**(`quote`: [SwapQuote](#swapquote), `opts`: `Partial`): *`Promise`* -*Defined in [asset-swapper/src/types.ts:140](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L140)* +*Defined in [asset-swapper/src/types.ts:142](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L142)* **Parameters:** @@ -1841,7 +1875,7 @@ ___ ▸ **getSmartContractParamsOrThrowAsync**(`quote`: [SwapQuote](#swapquote), `opts`: `Partial`): *`Promise>`* -*Defined in [asset-swapper/src/types.ts:141](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L141)* +*Defined in [asset-swapper/src/types.ts:143](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L143)* **Parameters:** @@ -1865,7 +1899,7 @@ chainId: The chainId that the desired orders should be for. • **chainId**: *number* -*Defined in [asset-swapper/src/types.ts:152](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L152)* +*Defined in [asset-swapper/src/types.ts:154](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L154)*
@@ -1884,7 +1918,7 @@ Represents the options for executing a swap quote with SwapQuoteConsumer *Overrides [ForwarderSwapQuoteGetOutputOpts](_asset_swapper_src_types_.forwarderswapquotegetoutputopts.md).[ethAmount](#optional-ethamount)* -*Defined in [asset-swapper/src/types.ts:179](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L179)* +*Defined in [asset-swapper/src/types.ts:181](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L181)* ___ @@ -1896,7 +1930,7 @@ ___ *Overrides [ForwarderSwapQuoteGetOutputOpts](_asset_swapper_src_types_.forwarderswapquotegetoutputopts.md).[feePercentage](#feepercentage)* -*Defined in [asset-swapper/src/types.ts:177](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L177)* +*Defined in [asset-swapper/src/types.ts:179](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L179)* ___ @@ -1908,7 +1942,7 @@ ___ *Overrides [ForwarderSwapQuoteGetOutputOpts](_asset_swapper_src_types_.forwarderswapquotegetoutputopts.md).[feeRecipient](#feerecipient)* -*Defined in [asset-swapper/src/types.ts:178](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L178)* +*Defined in [asset-swapper/src/types.ts:180](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L180)* ___ @@ -1918,7 +1952,7 @@ ___ *Inherited from [SwapQuoteExecutionOptsBase](#interface-swapquoteexecutionoptsbase).[gasLimit](#optional-gaslimit)* -*Defined in [asset-swapper/src/types.ts:167](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L167)* +*Defined in [asset-swapper/src/types.ts:169](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L169)* ___ @@ -1928,7 +1962,7 @@ ___ *Inherited from [SwapQuoteExecutionOptsBase](#interface-swapquoteexecutionoptsbase).[gasPrice](#optional-gasprice)* -*Defined in [asset-swapper/src/types.ts:168](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L168)* +*Defined in [asset-swapper/src/types.ts:170](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L170)* ___ @@ -1938,7 +1972,7 @@ ___ *Inherited from [SwapQuoteExecutionOptsBase](#interface-swapquoteexecutionoptsbase).[takerAddress](#optional-takeraddress)* -*Defined in [asset-swapper/src/types.ts:166](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L166)* +*Defined in [asset-swapper/src/types.ts:168](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L168)* ___ @@ -1948,7 +1982,7 @@ ___ *Inherited from [SwapQuoteGetOutputOpts](#interface-swapquotegetoutputopts).[useExtensionContract](#useextensioncontract)* -*Defined in [asset-swapper/src/types.ts:194](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L194)* +*Defined in [asset-swapper/src/types.ts:196](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L196)*
@@ -1965,7 +1999,7 @@ gasPrice: Gas price in Wei to use for a transaction • **gasLimit**? : *undefined | number* -*Defined in [asset-swapper/src/types.ts:167](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L167)* +*Defined in [asset-swapper/src/types.ts:169](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L169)* ___ @@ -1973,7 +2007,7 @@ ___ • **gasPrice**? : *`BigNumber`* -*Defined in [asset-swapper/src/types.ts:168](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L168)* +*Defined in [asset-swapper/src/types.ts:170](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L170)* ___ @@ -1981,7 +2015,7 @@ ___ • **takerAddress**? : *undefined | string* -*Defined in [asset-swapper/src/types.ts:166](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L166)* +*Defined in [asset-swapper/src/types.ts:168](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L168)*
@@ -1999,7 +2033,7 @@ useConsumerType: If provided, defaults the SwapQuoteConsumer to create output co *Inherited from [ForwarderSwapQuoteGetOutputOpts](#interface-forwarderswapquotegetoutputopts).[ethAmount](#optional-ethamount)* -*Defined in [asset-swapper/src/types.ts:179](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L179)* +*Defined in [asset-swapper/src/types.ts:181](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L181)* ___ @@ -2009,7 +2043,7 @@ ___ *Inherited from [ForwarderSwapQuoteGetOutputOpts](#interface-forwarderswapquotegetoutputopts).[feePercentage](#feepercentage)* -*Defined in [asset-swapper/src/types.ts:177](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L177)* +*Defined in [asset-swapper/src/types.ts:179](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L179)* ___ @@ -2019,7 +2053,7 @@ ___ *Inherited from [ForwarderSwapQuoteGetOutputOpts](#interface-forwarderswapquotegetoutputopts).[feeRecipient](#feerecipient)* -*Defined in [asset-swapper/src/types.ts:178](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L178)* +*Defined in [asset-swapper/src/types.ts:180](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L180)* ___ @@ -2027,7 +2061,7 @@ ___ • **useExtensionContract**: *[ExtensionContractType](#enumeration-extensioncontracttype)* -*Defined in [asset-swapper/src/types.ts:194](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L194)* +*Defined in [asset-swapper/src/types.ts:196](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L196)*
@@ -2047,7 +2081,7 @@ Represents the options provided to a generic SwapQuoteConsumer • **feeTakerTokenAmount**: *`BigNumber`* -*Defined in [asset-swapper/src/types.ts:256](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L256)* +*Defined in [asset-swapper/src/types.ts:258](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L258)* ___ @@ -2055,7 +2089,7 @@ ___ • **makerTokenAmount**: *`BigNumber`* -*Defined in [asset-swapper/src/types.ts:259](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L259)* +*Defined in [asset-swapper/src/types.ts:261](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L261)* ___ @@ -2063,7 +2097,7 @@ ___ • **takerTokenAmount**: *`BigNumber`* -*Defined in [asset-swapper/src/types.ts:258](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L258)* +*Defined in [asset-swapper/src/types.ts:260](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L260)* ___ @@ -2071,7 +2105,7 @@ ___ • **totalTakerTokenAmount**: *`BigNumber`* -*Defined in [asset-swapper/src/types.ts:257](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L257)* +*Defined in [asset-swapper/src/types.ts:259](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L259)*
@@ -2087,7 +2121,7 @@ slippagePercentage: The percentage buffer to add to account for slippage. Affect • **shouldDisableRequestingFeeOrders**: *boolean* -*Defined in [asset-swapper/src/types.ts:267](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L267)* +*Defined in [asset-swapper/src/types.ts:269](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L269)* ___ @@ -2095,7 +2129,7 @@ ___ • **slippagePercentage**: *number* -*Defined in [asset-swapper/src/types.ts:268](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L268)* +*Defined in [asset-swapper/src/types.ts:270](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L270)*
@@ -2112,7 +2146,7 @@ expiryBufferMs: The number of seconds to add when calculating whether an order i • **chainId**: *number* -*Defined in [asset-swapper/src/types.ts:277](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L277)* +*Defined in [asset-swapper/src/types.ts:279](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L279)* ___ @@ -2120,7 +2154,7 @@ ___ • **expiryBufferMs**: *number* -*Defined in [asset-swapper/src/types.ts:279](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L279)* +*Defined in [asset-swapper/src/types.ts:281](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L281)* ___ @@ -2128,7 +2162,7 @@ ___ • **orderRefreshIntervalMs**: *number* -*Defined in [asset-swapper/src/types.ts:278](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L278)* +*Defined in [asset-swapper/src/types.ts:280](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L280)*
@@ -2171,7 +2205,7 @@ ___ • **components**? : *[DataItem](#class-dataitem)[]* -*Defined in [ethereum-types/src/index.ts:137](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L137)* +*Defined in [ethereum-types/src/index.ts:137](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L137)* ___ @@ -2179,7 +2213,7 @@ ___ • **name**: *string* -*Defined in [ethereum-types/src/index.ts:135](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L135)* +*Defined in [ethereum-types/src/index.ts:135](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L135)* ___ @@ -2187,7 +2221,7 @@ ___ • **type**: *string* -*Defined in [ethereum-types/src/index.ts:136](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L136)* +*Defined in [ethereum-types/src/index.ts:136](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L136)*
@@ -2206,7 +2240,7 @@ ___ • **isEIP1193**: *boolean* -*Defined in [ethereum-types/src/index.ts:73](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L73)* +*Defined in [ethereum-types/src/index.ts:73](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L73)* ## Methods @@ -2214,7 +2248,7 @@ ___ ▸ **on**(`event`: [EIP1193Event](#eip1193event), `listener`: function): *this* -*Defined in [ethereum-types/src/index.ts:75](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L75)* +*Defined in [ethereum-types/src/index.ts:75](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L75)* **Parameters:** @@ -2238,7 +2272,7 @@ ___ ▸ **send**(`method`: string, `params?`: any[]): *`Promise`* -*Defined in [ethereum-types/src/index.ts:74](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L74)* +*Defined in [ethereum-types/src/index.ts:74](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L74)* **Parameters:** @@ -2272,7 +2306,7 @@ Name | Type | ▸ **sendAsync**(`payload`: [JSONRPCRequestPayload](_ethereum_types_src_index_.jsonrpcrequestpayload.md), `callback`: [JSONRPCErrorCallback](#jsonrpcerrorcallback)): *void* -*Defined in [ethereum-types/src/index.ts:14](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L14)* +*Defined in [ethereum-types/src/index.ts:14](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L14)* **Parameters:** @@ -2296,7 +2330,7 @@ Name | Type | • **id**: *number* -*Defined in [ethereum-types/src/index.ts:330](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L330)* +*Defined in [ethereum-types/src/index.ts:330](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L330)* ___ @@ -2304,7 +2338,7 @@ ___ • **jsonrpc**: *string* -*Defined in [ethereum-types/src/index.ts:331](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L331)* +*Defined in [ethereum-types/src/index.ts:331](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L331)* ___ @@ -2312,7 +2346,7 @@ ___ • **method**: *string* -*Defined in [ethereum-types/src/index.ts:329](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L329)* +*Defined in [ethereum-types/src/index.ts:329](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L329)* ___ @@ -2320,7 +2354,7 @@ ___ • **params**: *any[]* -*Defined in [ethereum-types/src/index.ts:328](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L328)* +*Defined in [ethereum-types/src/index.ts:328](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L328)*
@@ -2333,7 +2367,7 @@ ___ • **code**: *number* -*Defined in [ethereum-types/src/index.ts:336](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L336)* +*Defined in [ethereum-types/src/index.ts:336](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L336)* ___ @@ -2341,7 +2375,7 @@ ___ • **message**: *string* -*Defined in [ethereum-types/src/index.ts:335](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L335)* +*Defined in [ethereum-types/src/index.ts:335](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L335)*
@@ -2354,7 +2388,7 @@ ___ • **error**? : *[JSONRPCResponseError](#class-jsonrpcresponseerror)* -*Defined in [ethereum-types/src/index.ts:343](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L343)* +*Defined in [ethereum-types/src/index.ts:343](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L343)* ___ @@ -2362,7 +2396,7 @@ ___ • **id**: *number* -*Defined in [ethereum-types/src/index.ts:341](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L341)* +*Defined in [ethereum-types/src/index.ts:341](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L341)* ___ @@ -2370,7 +2404,7 @@ ___ • **jsonrpc**: *string* -*Defined in [ethereum-types/src/index.ts:342](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L342)* +*Defined in [ethereum-types/src/index.ts:342](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L342)* ___ @@ -2378,7 +2412,7 @@ ___ • **result**: *any* -*Defined in [ethereum-types/src/index.ts:340](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L340)* +*Defined in [ethereum-types/src/index.ts:340](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L340)*
@@ -2397,7 +2431,7 @@ ___ • **constant**: *boolean* -*Defined in [ethereum-types/src/index.ts:94](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L94)* +*Defined in [ethereum-types/src/index.ts:94](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L94)* ___ @@ -2405,7 +2439,7 @@ ___ • **inputs**: *[DataItem](#class-dataitem)[]* -*Defined in [ethereum-types/src/index.ts:92](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L92)* +*Defined in [ethereum-types/src/index.ts:92](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L92)* ___ @@ -2413,7 +2447,7 @@ ___ • **name**: *string* -*Defined in [ethereum-types/src/index.ts:91](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L91)* +*Defined in [ethereum-types/src/index.ts:91](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L91)* ___ @@ -2421,7 +2455,7 @@ ___ • **outputs**: *[DataItem](#class-dataitem)[]* -*Defined in [ethereum-types/src/index.ts:93](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L93)* +*Defined in [ethereum-types/src/index.ts:93](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L93)* ___ @@ -2429,7 +2463,7 @@ ___ • **payable**: *boolean* -*Defined in [ethereum-types/src/index.ts:96](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L96)* +*Defined in [ethereum-types/src/index.ts:96](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L96)* ___ @@ -2437,7 +2471,7 @@ ___ • **stateMutability**: *[StateMutability](#statemutability)* -*Defined in [ethereum-types/src/index.ts:95](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L95)* +*Defined in [ethereum-types/src/index.ts:95](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L95)* ___ @@ -2445,7 +2479,7 @@ ___ • **type**: *string* -*Defined in [ethereum-types/src/index.ts:90](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L90)* +*Defined in [ethereum-types/src/index.ts:90](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L90)*
@@ -2479,46 +2513,18 @@ ___ -# Class: InsufficientAssetLiquidityError - -Error class representing insufficient asset liquidity - - -## Constructors - - - -\+ **new InsufficientAssetLiquidityError**(`amountAvailableToFill`: `BigNumber`): *[InsufficientAssetLiquidityError](#class-insufficientassetliquidityerror)* - -*Defined in [asset-swapper/src/errors.ts:12](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/errors.ts#L12)* - -**Parameters:** - -Name | Type | Description | ------- | ------ | ------ | -`amountAvailableToFill` | `BigNumber` | The amount availabe to fill (in base units) factoring in slippage | - -**Returns:** *[InsufficientAssetLiquidityError](#class-insufficientassetliquidityerror)* - -## Properties - -### amountAvailableToFill - -• **amountAvailableToFill**: *`BigNumber`* - -*Defined in [asset-swapper/src/errors.ts:12](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/errors.ts#L12)* - -The amount availabe to fill (in base units) factoring in slippage. - -___ +# Interface: TupleDataItem -### message -• **message**: *string* +## Properties +### components +• **components**: *[DataItem](#class-dataitem)[]* +*Overrides [DataItem](_ethereum_types_src_index_.dataitem.md).[components](#optional-components)* +*Defined in [ethereum-types/src/index.ts:141](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L141)* ___ @@ -2526,29 +2532,19 @@ ___ • **name**: *string* +*Inherited from [DataItem](#interface-dataitem).[name](#name)* - - - -___ - -### `Optional` stack - -• **stack**? : *undefined | string* - - - -*Overrides void* - - +*Defined in [ethereum-types/src/index.ts:135](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L135)* ___ -### `Static` Error +### type -▪ **Error**: *`ErrorConstructor`* +• **type**: *string* +*Inherited from [DataItem](#interface-dataitem).[type](#type)* +*Defined in [ethereum-types/src/index.ts:136](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L136)*
@@ -2569,7 +2565,7 @@ This interface allowed sending synchonous requests, support for which was later ▸ **send**(`payload`: [JSONRPCRequestPayload](_ethereum_types_src_index_.jsonrpcrequestpayload.md)): *[JSONRPCResponsePayload](#class-jsonrpcresponsepayload)* -*Defined in [ethereum-types/src/index.ts:45](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L45)* +*Defined in [ethereum-types/src/index.ts:45](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L45)* **Parameters:** @@ -2585,7 +2581,7 @@ ___ ▸ **sendAsync**(`payload`: [JSONRPCRequestPayload](_ethereum_types_src_index_.jsonrpcrequestpayload.md), `callback`: [JSONRPCErrorCallback](#jsonrpcerrorcallback)): *void* -*Defined in [ethereum-types/src/index.ts:44](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L44)* +*Defined in [ethereum-types/src/index.ts:44](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L44)* **Parameters:** @@ -2611,7 +2607,7 @@ before the first attempts to conform to EIP1193 ▸ **send**(`payload`: [JSONRPCRequestPayload](_ethereum_types_src_index_.jsonrpcrequestpayload.md), `callback`: [JSONRPCErrorCallback](#jsonrpcerrorcallback)): *void* -*Defined in [ethereum-types/src/index.ts:54](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L54)* +*Defined in [ethereum-types/src/index.ts:54](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L54)* **Parameters:** @@ -2637,7 +2633,7 @@ however it does not conform entirely. ▸ **send**(`method`: string, `params?`: any[]): *`Promise`* -*Defined in [ethereum-types/src/index.ts:63](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L63)* +*Defined in [ethereum-types/src/index.ts:63](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L63)* **Parameters:** @@ -2663,7 +2659,7 @@ add here • **isMetaMask**? : *undefined | false | true* -*Defined in [ethereum-types/src/index.ts:31](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L31)* +*Defined in [ethereum-types/src/index.ts:31](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L31)* ___ @@ -2671,7 +2667,7 @@ ___ • **isParity**? : *undefined | false | true* -*Defined in [ethereum-types/src/index.ts:32](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L32)* +*Defined in [ethereum-types/src/index.ts:32](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L32)* ___ @@ -2679,7 +2675,7 @@ ___ • **isZeroExProvider**? : *undefined | false | true* -*Defined in [ethereum-types/src/index.ts:30](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L30)* +*Defined in [ethereum-types/src/index.ts:30](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L30)* ## Methods @@ -2687,7 +2683,7 @@ ___ ▸ **enable**(): *`Promise`* -*Defined in [ethereum-types/src/index.ts:34](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L34)* +*Defined in [ethereum-types/src/index.ts:34](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L34)* **Returns:** *`Promise`* @@ -2697,7 +2693,7 @@ ___ ▸ **sendAsync**(`payload`: [JSONRPCRequestPayload](_ethereum_types_src_index_.jsonrpcrequestpayload.md), `callback`: [JSONRPCErrorCallback](#jsonrpcerrorcallback)): *void* -*Defined in [ethereum-types/src/index.ts:35](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L35)* +*Defined in [ethereum-types/src/index.ts:35](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L35)* **Parameters:** @@ -2714,7 +2710,7 @@ ___ ▸ **stop**(): *void* -*Defined in [ethereum-types/src/index.ts:33](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L33)* +*Defined in [ethereum-types/src/index.ts:33](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L33)* **Returns:** *void* @@ -2729,7 +2725,7 @@ ___ • **accepted**: *`SignedOrder`[]* -*Defined in [orderbook/src/types.ts:15](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/orderbook/src/types.ts#L15)* +*Defined in [orderbook/src/types.ts:15](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/orderbook/src/types.ts#L15)* ___ @@ -2737,7 +2733,7 @@ ___ • **rejected**: *[RejectedOrder](#class-rejectedorder)[]* -*Defined in [orderbook/src/types.ts:16](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/orderbook/src/types.ts#L16)* +*Defined in [orderbook/src/types.ts:16](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/orderbook/src/types.ts#L16)*
@@ -2750,7 +2746,7 @@ ___ • **added**: *`APIOrder`[]* -*Defined in [orderbook/src/types.ts:6](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/orderbook/src/types.ts#L6)* +*Defined in [orderbook/src/types.ts:6](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/orderbook/src/types.ts#L6)* ___ @@ -2758,7 +2754,7 @@ ___ • **assetPairKey**: *string* -*Defined in [orderbook/src/types.ts:5](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/orderbook/src/types.ts#L5)* +*Defined in [orderbook/src/types.ts:5](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/orderbook/src/types.ts#L5)* ___ @@ -2766,7 +2762,7 @@ ___ • **removed**: *`APIOrder`[]* -*Defined in [orderbook/src/types.ts:7](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/orderbook/src/types.ts#L7)* +*Defined in [orderbook/src/types.ts:7](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/orderbook/src/types.ts#L7)*
@@ -2781,7 +2777,7 @@ Constructor options for a Mesh Order Provider • **websocketEndpoint**: *string* -*Defined in [orderbook/src/types.ts:50](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/orderbook/src/types.ts#L50)* +*Defined in [orderbook/src/types.ts:52](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/orderbook/src/types.ts#L52)* ___ @@ -2789,7 +2785,7 @@ ___ • **wsOpts**? : *`WSOpts`* -*Defined in [orderbook/src/types.ts:52](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/orderbook/src/types.ts#L52)* +*Defined in [orderbook/src/types.ts:54](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/orderbook/src/types.ts#L54)*
@@ -2802,7 +2798,7 @@ ___ • **message**: *string* -*Defined in [orderbook/src/types.ts:11](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/orderbook/src/types.ts#L11)* +*Defined in [orderbook/src/types.ts:11](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/orderbook/src/types.ts#L11)* ___ @@ -2810,7 +2806,7 @@ ___ • **order**: *`SignedOrder`* -*Defined in [orderbook/src/types.ts:12](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/orderbook/src/types.ts#L12)* +*Defined in [orderbook/src/types.ts:12](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/orderbook/src/types.ts#L12)*
@@ -2825,7 +2821,7 @@ Constructor options for a SRA Polling Order Provider • **chainId**? : *undefined | number* -*Defined in [orderbook/src/types.ts:42](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/orderbook/src/types.ts#L42)* +*Defined in [orderbook/src/types.ts:44](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/orderbook/src/types.ts#L44)* ___ @@ -2833,7 +2829,7 @@ ___ • **httpEndpoint**: *string* -*Defined in [orderbook/src/types.ts:36](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/orderbook/src/types.ts#L36)* +*Defined in [orderbook/src/types.ts:38](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/orderbook/src/types.ts#L38)* ___ @@ -2841,7 +2837,7 @@ ___ • **perPage**? : *undefined | number* -*Defined in [orderbook/src/types.ts:40](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/orderbook/src/types.ts#L40)* +*Defined in [orderbook/src/types.ts:42](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/orderbook/src/types.ts#L42)* ___ @@ -2849,7 +2845,7 @@ ___ • **pollingIntervalMs**: *number* -*Defined in [orderbook/src/types.ts:38](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/orderbook/src/types.ts#L38)* +*Defined in [orderbook/src/types.ts:40](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/orderbook/src/types.ts#L40)*
@@ -2860,11 +2856,19 @@ Constructor options for a SRA Websocket Order Provider ## Properties +### `Optional` chainId + +• **chainId**? : *undefined | number* + +*Defined in [orderbook/src/types.ts:30](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/orderbook/src/types.ts#L30)* + +___ + ### httpEndpoint • **httpEndpoint**: *string* -*Defined in [orderbook/src/types.ts:26](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/orderbook/src/types.ts#L26)* +*Defined in [orderbook/src/types.ts:26](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/orderbook/src/types.ts#L26)* ___ @@ -2872,7 +2876,7 @@ ___ • **websocketEndpoint**: *string* -*Defined in [orderbook/src/types.ts:28](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/orderbook/src/types.ts#L28)* +*Defined in [orderbook/src/types.ts:28](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/orderbook/src/types.ts#L28)*
@@ -2885,7 +2889,7 @@ ___ • **metaData**: *object* -*Defined in [types/src/index.ts:408](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L408)* +*Defined in [types/src/index.ts:408](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L408)* ___ @@ -2893,7 +2897,7 @@ ___ • **order**: *[SignedOrder](#class-signedorder)* -*Defined in [types/src/index.ts:407](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L407)* +*Defined in [types/src/index.ts:407](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L407)*
@@ -2908,7 +2912,7 @@ ___ • **assetData**: *string* -*Defined in [types/src/index.ts:424](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L424)* +*Defined in [types/src/index.ts:424](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L424)* ___ @@ -2916,7 +2920,7 @@ ___ • **maxAmount**: *`BigNumber`* -*Defined in [types/src/index.ts:426](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L426)* +*Defined in [types/src/index.ts:426](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L426)* ___ @@ -2924,7 +2928,7 @@ ___ • **minAmount**: *`BigNumber`* -*Defined in [types/src/index.ts:425](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L425)* +*Defined in [types/src/index.ts:425](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L425)* ___ @@ -2932,7 +2936,7 @@ ___ • **precision**: *number* -*Defined in [types/src/index.ts:427](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L427)* +*Defined in [types/src/index.ts:427](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L427)*
@@ -2945,7 +2949,7 @@ ___ • **assetDataA**: *[Asset](#class-asset)* -*Defined in [types/src/index.ts:419](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L419)* +*Defined in [types/src/index.ts:419](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L419)* ___ @@ -2953,7 +2957,7 @@ ___ • **assetDataB**: *[Asset](#class-asset)* -*Defined in [types/src/index.ts:420](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L420)* +*Defined in [types/src/index.ts:420](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L420)*
@@ -2999,6 +3003,8 @@ ___ + + @@ -3064,7 +3070,7 @@ ___ *Inherited from [Order](#interface-order).[chainId](#chainid)* -*Defined in [types/src/index.ts:14](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L14)* +*Defined in [types/src/index.ts:14](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L14)* ___ @@ -3074,7 +3080,7 @@ ___ *Inherited from [Order](#interface-order).[exchangeAddress](#exchangeaddress)* -*Defined in [types/src/index.ts:15](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L15)* +*Defined in [types/src/index.ts:15](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L15)* ___ @@ -3084,7 +3090,7 @@ ___ *Inherited from [Order](#interface-order).[expirationTimeSeconds](#expirationtimeseconds)* -*Defined in [types/src/index.ts:24](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L24)* +*Defined in [types/src/index.ts:24](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L24)* ___ @@ -3094,7 +3100,7 @@ ___ *Inherited from [Order](#interface-order).[feeRecipientAddress](#feerecipientaddress)* -*Defined in [types/src/index.ts:18](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L18)* +*Defined in [types/src/index.ts:18](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L18)* ___ @@ -3104,7 +3110,7 @@ ___ *Inherited from [Order](#interface-order).[makerAddress](#makeraddress)* -*Defined in [types/src/index.ts:16](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L16)* +*Defined in [types/src/index.ts:16](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L16)* ___ @@ -3114,7 +3120,7 @@ ___ *Inherited from [Order](#interface-order).[makerAssetAmount](#makerassetamount)* -*Defined in [types/src/index.ts:20](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L20)* +*Defined in [types/src/index.ts:20](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L20)* ___ @@ -3124,7 +3130,7 @@ ___ *Inherited from [Order](#interface-order).[makerAssetData](#makerassetdata)* -*Defined in [types/src/index.ts:26](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L26)* +*Defined in [types/src/index.ts:26](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L26)* ___ @@ -3134,7 +3140,7 @@ ___ *Inherited from [Order](#interface-order).[makerFee](#makerfee)* -*Defined in [types/src/index.ts:22](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L22)* +*Defined in [types/src/index.ts:22](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L22)* ___ @@ -3144,7 +3150,7 @@ ___ *Inherited from [Order](#interface-order).[makerFeeAssetData](#makerfeeassetdata)* -*Defined in [types/src/index.ts:28](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L28)* +*Defined in [types/src/index.ts:28](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L28)* ___ @@ -3154,7 +3160,7 @@ ___ *Inherited from [Order](#interface-order).[salt](#salt)* -*Defined in [types/src/index.ts:25](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L25)* +*Defined in [types/src/index.ts:25](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L25)* ___ @@ -3164,7 +3170,7 @@ ___ *Inherited from [Order](#interface-order).[senderAddress](#senderaddress)* -*Defined in [types/src/index.ts:19](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L19)* +*Defined in [types/src/index.ts:19](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L19)* ___ @@ -3172,7 +3178,7 @@ ___ • **signature**: *string* -*Defined in [types/src/index.ts:33](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L33)* +*Defined in [types/src/index.ts:33](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L33)* ___ @@ -3182,7 +3188,7 @@ ___ *Inherited from [Order](#interface-order).[takerAddress](#takeraddress)* -*Defined in [types/src/index.ts:17](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L17)* +*Defined in [types/src/index.ts:17](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L17)* ___ @@ -3192,7 +3198,7 @@ ___ *Inherited from [Order](#interface-order).[takerAssetAmount](#takerassetamount)* -*Defined in [types/src/index.ts:21](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L21)* +*Defined in [types/src/index.ts:21](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L21)* ___ @@ -3202,7 +3208,7 @@ ___ *Inherited from [Order](#interface-order).[takerAssetData](#takerassetdata)* -*Defined in [types/src/index.ts:27](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L27)* +*Defined in [types/src/index.ts:27](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L27)* ___ @@ -3212,7 +3218,7 @@ ___ *Inherited from [Order](#interface-order).[takerFee](#takerfee)* -*Defined in [types/src/index.ts:23](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L23)* +*Defined in [types/src/index.ts:23](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L23)* ___ @@ -3222,7 +3228,7 @@ ___ *Inherited from [Order](#interface-order).[takerFeeAssetData](#takerfeeassetdata)* -*Defined in [types/src/index.ts:29](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L29)* +*Defined in [types/src/index.ts:29](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L29)*
@@ -3254,33 +3260,6 @@ ___ - - - - - - - - - - - - - - - - - - - - - -## Type aliases - - - - - @@ -3326,7 +3305,7 @@ ___ Ƭ **SwapQuote**: *[MarketBuySwapQuote](#interface-marketbuyswapquote) | [MarketSellSwapQuote](#interface-marketsellswapquote)* -*Defined in [asset-swapper/src/types.ts:182](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/asset-swapper/src/types.ts#L182)* +*Defined in [asset-swapper/src/types.ts:184](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/asset-swapper/src/types.ts#L184)* ___ @@ -3345,7 +3324,7 @@ ___ Ƭ **ConstructorStateMutability**: *"nonpayable" | "payable"* -*Defined in [ethereum-types/src/index.ts:84](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L84)* +*Defined in [ethereum-types/src/index.ts:84](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L84)* ___ @@ -3359,7 +3338,7 @@ ___ Ƭ **EIP1193Event**: *"accountsChanged" | "networkChanged" | "close" | "connect" | "notification"* -*Defined in [ethereum-types/src/index.ts:70](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L70)* +*Defined in [ethereum-types/src/index.ts:70](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L70)* Interface for providers that conform to EIP 1193 Source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1193.md @@ -3376,7 +3355,7 @@ ___ Ƭ **JSONRPCErrorCallback**: *function* -*Defined in [ethereum-types/src/index.ts:3](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L3)* +*Defined in [ethereum-types/src/index.ts:3](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L3)* #### Type declaration: @@ -3403,7 +3382,7 @@ ___ Ƭ **StateMutability**: *"pure" | "view" | [ConstructorStateMutability](#constructorstatemutability)* -*Defined in [ethereum-types/src/index.ts:85](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L85)* +*Defined in [ethereum-types/src/index.ts:85](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L85)* ___ @@ -3411,7 +3390,7 @@ ___ Ƭ **SupportedProvider**: *[Web3JsProvider](_ethereum_types_src_index_.md#web3jsprovider) | [GanacheProvider](#interface-ganacheprovider) | [EIP1193Provider](#interface-eip1193provider) | [ZeroExProvider](#interface-zeroexprovider)* -*Defined in [ethereum-types/src/index.ts:9](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L9)* +*Defined in [ethereum-types/src/index.ts:9](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L9)* Do not create your own provider. Use an existing provider from a Web3 or ProviderEngine library Read more about Providers in the guides section of the 0x docs. @@ -3426,7 +3405,7 @@ ___ Ƭ **Web3JsProvider**: *[Web3JsV1Provider](#interface-web3jsv1provider) | [Web3JsV2Provider](#interface-web3jsv2provider) | [Web3JsV3Provider](#interface-web3jsv3provider)* -*Defined in [ethereum-types/src/index.ts:11](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L11)* +*Defined in [ethereum-types/src/index.ts:11](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L11)*
@@ -3439,7 +3418,7 @@ ___ • **DEFAULT_TOKEN_PRECISION**: *`18`* = 18 -*Defined in [orderbook/src/order_provider/base_order_provider.ts:9](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/orderbook/src/order_provider/base_order_provider.ts#L9)* +*Defined in [orderbook/src/order_provider/base_order_provider.ts:9](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/orderbook/src/order_provider/base_order_provider.ts#L9)*
@@ -3462,3 +3441,34 @@ ___ + + + +## Type aliases + + + + + + + + + + + + + + + + + + + + + + + + + +
+ diff --git a/packages/connect/docs/reference.mdx b/packages/connect/docs/reference.mdx index 36c0122b32..3d59b4317a 100644 --- a/packages/connect/docs/reference.mdx +++ b/packages/connect/docs/reference.mdx @@ -1,131 +1,172 @@ +# Class: HttpClient +This class includes all the functionality related to interacting with a set of HTTP endpoints +that implement the standard relayer API v2 +## Constructors +\+ **new HttpClient**(`url`: string): *[HttpClient](#class-httpclient)* +*Defined in [connect/src/http_client.ts:44](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/connect/src/http_client.ts#L44)* +Instantiates a new HttpClient instance +**Parameters:** +Name | Type | Description | +------ | ------ | ------ | +`url` | string | The relayer API base HTTP url you would like to interact with | +**Returns:** *[HttpClient](#class-httpclient)* +An instance of HttpClient +## Methods +### getAssetPairsAsync +▸ **getAssetPairsAsync**(`requestOpts?`: `RequestOpts` & `AssetPairsRequestOpts` & `PagedRequestOpts`): *`Promise`* +*Defined in [connect/src/http_client.ts:59](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/connect/src/http_client.ts#L59)* +Retrieve assetData pair info from the API +**Parameters:** +Name | Type | Description | +------ | ------ | ------ | +`requestOpts?` | `RequestOpts` & `AssetPairsRequestOpts` & `PagedRequestOpts` | Options specifying assetData information to retrieve, page information, and chain id. | +**Returns:** *`Promise`* - - - - - - - - - - -## Type aliases - - - - - -### AssetPairsResponse - -Ƭ **AssetPairsResponse**: *[PaginatedCollection](#interface-paginatedcollection)‹*[AssetPairsItem](#interface-assetpairsitem)*›* - -*Defined in [types/src/index.ts:416](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L416)* +The resulting AssetPairsResponse that match the request ___ +### getFeeRecipientsAsync +▸ **getFeeRecipientsAsync**(`requestOpts?`: `RequestOpts` & `PagedRequestOpts`): *`Promise`* +*Defined in [connect/src/http_client.ts:160](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/connect/src/http_client.ts#L160)* +Retrieve the list of fee recipient addresses used by the relayer. +**Parameters:** +Name | Type | Description | +------ | ------ | ------ | +`requestOpts?` | `RequestOpts` & `PagedRequestOpts` | Options specifying page information, and chain id. | -### FeeRecipientsResponse - -Ƭ **FeeRecipientsResponse**: *[PaginatedCollection](#interface-paginatedcollection)‹*string*›* +**Returns:** *`Promise`* -*Defined in [types/src/index.ts:484](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L484)* +The resulting FeeRecipientsResponse ___ +### getOrderAsync +▸ **getOrderAsync**(`orderHash`: string, `requestOpts?`: [RequestOpts](#interface-requestopts)): *`Promise`* +*Defined in [connect/src/http_client.ts:99](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/connect/src/http_client.ts#L99)* +Retrieve a specific order from the API -### OrdersResponse - -Ƭ **OrdersResponse**: *[PaginatedCollection](#interface-paginatedcollection)‹*[APIOrder](#interface-apiorder)*›* - -*Defined in [types/src/index.ts:404](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L404)* - -___ - - +**Parameters:** +Name | Type | Description | +------ | ------ | ------ | +`orderHash` | string | An orderHash generated from the desired order | +`requestOpts?` | [RequestOpts](#interface-requestopts) | - | +**Returns:** *`Promise`* +The APIOrder that matches the supplied orderHash +___ +### getOrderConfigAsync +▸ **getOrderConfigAsync**(`request`: `OrderConfigRequest`, `requestOpts?`: [RequestOpts](#interface-requestopts)): *`Promise`* -# Interface: APIOrder +*Defined in [connect/src/http_client.ts:139](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/connect/src/http_client.ts#L139)* +Retrieve fee information from the API -## Properties +**Parameters:** -### metaData +Name | Type | Description | +------ | ------ | ------ | +`request` | `OrderConfigRequest` | A OrderConfigRequest instance describing the specific fees to retrieve | +`requestOpts?` | [RequestOpts](#interface-requestopts) | Options specifying chain id. | -• **metaData**: *object* +**Returns:** *`Promise`* -*Defined in [types/src/index.ts:408](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L408)* +The resulting OrderConfigResponse that matches the request ___ -### order - -• **order**: *[SignedOrder](#class-signedorder)* - -*Defined in [types/src/index.ts:407](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L407)* - -
- - - - +### getOrderbookAsync +▸ **getOrderbookAsync**(`request`: `OrderbookRequest`, `requestOpts?`: `RequestOpts` & `PagedRequestOpts`): *`Promise`* +*Defined in [connect/src/http_client.ts:117](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/connect/src/http_client.ts#L117)* +Retrieve an orderbook from the API +**Parameters:** +Name | Type | Description | +------ | ------ | ------ | +`request` | `OrderbookRequest` | An OrderbookRequest instance describing the specific orderbook to retrieve | +`requestOpts?` | `RequestOpts` & `PagedRequestOpts` | Options specifying page information, and chain id. | +**Returns:** *`Promise`* +The resulting OrderbookResponse that matches the request +___ +### getOrdersAsync +▸ **getOrdersAsync**(`requestOpts?`: `RequestOpts` & `OrdersRequestOpts` & `PagedRequestOpts`): *`Promise`* +*Defined in [connect/src/http_client.ts:79](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/connect/src/http_client.ts#L79)* +Retrieve orders from the API +**Parameters:** +Name | Type | Description | +------ | ------ | ------ | +`requestOpts?` | `RequestOpts` & `OrdersRequestOpts` & `PagedRequestOpts` | Options specifying orders to retrieve and page information, page information, and chain id. | +**Returns:** *`Promise`* +The resulting OrdersResponse that match the request +___ +### submitOrderAsync +▸ **submitOrderAsync**(`signedOrder`: `SignedOrder`, `requestOpts?`: [RequestOpts](#interface-requestopts)): *`Promise`* +*Defined in [connect/src/http_client.ts:177](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/connect/src/http_client.ts#L177)* +Submit a signed order to the API +**Parameters:** +Name | Type | Description | +------ | ------ | ------ | +`signedOrder` | `SignedOrder` | A SignedOrder instance to submit | +`requestOpts?` | [RequestOpts](#interface-requestopts) | Options specifying chain id. | +**Returns:** *`Promise`* +
@@ -146,7 +187,6 @@ ___ - @@ -154,172 +194,92 @@ ___ -# Class: HttpClient -This class includes all the functionality related to interacting with a set of HTTP endpoints -that implement the standard relayer API v2 -## Constructors -\+ **new HttpClient**(`url`: string): *[HttpClient](#class-httpclient)* +# Interface: APIOrder -*Defined in [connect/src/http_client.ts:43](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/connect/src/http_client.ts#L43)* -Instantiates a new HttpClient instance +## Properties -**Parameters:** +### metaData -Name | Type | Description | ------- | ------ | ------ | -`url` | string | The relayer API base HTTP url you would like to interact with | +• **metaData**: *object* -**Returns:** *[HttpClient](#class-httpclient)* +*Defined in [types/src/index.ts:408](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L408)* -An instance of HttpClient +___ -## Methods +### order -### getAssetPairsAsync +• **order**: *[SignedOrder](#class-signedorder)* -▸ **getAssetPairsAsync**(`requestOpts?`: `AssetPairsRequestOpts` & `PagedRequestOpts`): *`Promise`* +*Defined in [types/src/index.ts:407](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L407)* -*Defined in [connect/src/http_client.ts:58](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/connect/src/http_client.ts#L58)* +
-Retrieve assetData pair info from the API -**Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`requestOpts?` | `AssetPairsRequestOpts` & `PagedRequestOpts` | Options specifying assetData information to retrieve, page information. | -**Returns:** *`Promise`* -The resulting AssetPairsResponse that match the request -___ -### getFeeRecipientsAsync -▸ **getFeeRecipientsAsync**(`requestOpts?`: [PagedRequestOpts](#interface-pagedrequestopts)): *`Promise`* -*Defined in [connect/src/http_client.ts:140](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/connect/src/http_client.ts#L140)* -Retrieve the list of fee recipient addresses used by the relayer. -**Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`requestOpts?` | [PagedRequestOpts](#interface-pagedrequestopts) | Options specifying page information. | -**Returns:** *`Promise`* -The resulting FeeRecipientsResponse -___ -### getOrderAsync -▸ **getOrderAsync**(`orderHash`: string): *`Promise`* -*Defined in [connect/src/http_client.ts:94](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/connect/src/http_client.ts#L94)* -Retrieve a specific order from the API -**Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`orderHash` | string | An orderHash generated from the desired order | -**Returns:** *`Promise`* -The APIOrder that matches the supplied orderHash -___ -### getOrderConfigAsync -▸ **getOrderConfigAsync**(`request`: `OrderConfigRequest`): *`Promise`* -*Defined in [connect/src/http_client.ts:126](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/connect/src/http_client.ts#L126)* -Retrieve fee information from the API -**Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`request` | `OrderConfigRequest` | A OrderConfigRequest instance describing the specific fees to retrieve | -**Returns:** *`Promise`* -The resulting OrderConfigResponse that matches the request -___ -### getOrderbookAsync -▸ **getOrderbookAsync**(`request`: `OrderbookRequest`, `requestOpts?`: [PagedRequestOpts](#interface-pagedrequestopts)): *`Promise`* -*Defined in [connect/src/http_client.ts:106](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/connect/src/http_client.ts#L106)* -Retrieve an orderbook from the API -**Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`request` | `OrderbookRequest` | An OrderbookRequest instance describing the specific orderbook to retrieve | -`requestOpts?` | [PagedRequestOpts](#interface-pagedrequestopts) | Options specifying page information. | -**Returns:** *`Promise`* -The resulting OrderbookResponse that matches the request -___ -### getOrdersAsync -▸ **getOrdersAsync**(`requestOpts?`: `OrdersRequestOpts` & `PagedRequestOpts`): *`Promise`* -*Defined in [connect/src/http_client.ts:77](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/connect/src/http_client.ts#L77)* -Retrieve orders from the API -**Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`requestOpts?` | `OrdersRequestOpts` & `PagedRequestOpts` | Options specifying orders to retrieve and page information, page information. | -**Returns:** *`Promise`* -The resulting OrdersResponse that match the request -___ + -### submitOrderAsync -▸ **submitOrderAsync**(`signedOrder`: `SignedOrder`): *`Promise`* -*Defined in [connect/src/http_client.ts:155](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/connect/src/http_client.ts#L155)* -Submit a signed order to the API -**Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`signedOrder` | `SignedOrder` | A SignedOrder instance to submit | -**Returns:** *`Promise`* -
@@ -362,7 +322,7 @@ Name | Type | Description | • **page**? : *undefined | number* -*Defined in [types/src/index.ts:491](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L491)* +*Defined in [types/src/index.ts:491](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L491)* ___ @@ -370,7 +330,7 @@ ___ • **perPage**? : *undefined | number* -*Defined in [types/src/index.ts:492](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L492)* +*Defined in [types/src/index.ts:492](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L492)*
@@ -387,7 +347,7 @@ ___ • **page**: *number* -*Defined in [types/src/index.ts:459](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L459)* +*Defined in [types/src/index.ts:459](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L459)* ___ @@ -395,7 +355,7 @@ ___ • **perPage**: *number* -*Defined in [types/src/index.ts:460](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L460)* +*Defined in [types/src/index.ts:460](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L460)* ___ @@ -403,7 +363,7 @@ ___ • **records**: *`T`[]* -*Defined in [types/src/index.ts:461](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L461)* +*Defined in [types/src/index.ts:461](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L461)* ___ @@ -411,7 +371,7 @@ ___ • **total**: *number* -*Defined in [types/src/index.ts:458](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L458)* +*Defined in [types/src/index.ts:458](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L458)*
@@ -421,8 +381,6 @@ ___ - - # Interface: SignedOrder @@ -434,7 +392,7 @@ ___ *Inherited from [Order](#interface-order).[chainId](#chainid)* -*Defined in [types/src/index.ts:14](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L14)* +*Defined in [types/src/index.ts:14](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L14)* ___ @@ -444,7 +402,7 @@ ___ *Inherited from [Order](#interface-order).[exchangeAddress](#exchangeaddress)* -*Defined in [types/src/index.ts:15](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L15)* +*Defined in [types/src/index.ts:15](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L15)* ___ @@ -454,7 +412,7 @@ ___ *Inherited from [Order](#interface-order).[expirationTimeSeconds](#expirationtimeseconds)* -*Defined in [types/src/index.ts:24](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L24)* +*Defined in [types/src/index.ts:24](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L24)* ___ @@ -464,7 +422,7 @@ ___ *Inherited from [Order](#interface-order).[feeRecipientAddress](#feerecipientaddress)* -*Defined in [types/src/index.ts:18](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L18)* +*Defined in [types/src/index.ts:18](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L18)* ___ @@ -474,7 +432,7 @@ ___ *Inherited from [Order](#interface-order).[makerAddress](#makeraddress)* -*Defined in [types/src/index.ts:16](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L16)* +*Defined in [types/src/index.ts:16](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L16)* ___ @@ -484,7 +442,7 @@ ___ *Inherited from [Order](#interface-order).[makerAssetAmount](#makerassetamount)* -*Defined in [types/src/index.ts:20](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L20)* +*Defined in [types/src/index.ts:20](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L20)* ___ @@ -494,7 +452,7 @@ ___ *Inherited from [Order](#interface-order).[makerAssetData](#makerassetdata)* -*Defined in [types/src/index.ts:26](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L26)* +*Defined in [types/src/index.ts:26](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L26)* ___ @@ -504,7 +462,7 @@ ___ *Inherited from [Order](#interface-order).[makerFee](#makerfee)* -*Defined in [types/src/index.ts:22](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L22)* +*Defined in [types/src/index.ts:22](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L22)* ___ @@ -514,7 +472,7 @@ ___ *Inherited from [Order](#interface-order).[makerFeeAssetData](#makerfeeassetdata)* -*Defined in [types/src/index.ts:28](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L28)* +*Defined in [types/src/index.ts:28](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L28)* ___ @@ -524,7 +482,7 @@ ___ *Inherited from [Order](#interface-order).[salt](#salt)* -*Defined in [types/src/index.ts:25](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L25)* +*Defined in [types/src/index.ts:25](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L25)* ___ @@ -534,7 +492,7 @@ ___ *Inherited from [Order](#interface-order).[senderAddress](#senderaddress)* -*Defined in [types/src/index.ts:19](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L19)* +*Defined in [types/src/index.ts:19](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L19)* ___ @@ -542,7 +500,7 @@ ___ • **signature**: *string* -*Defined in [types/src/index.ts:33](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L33)* +*Defined in [types/src/index.ts:33](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L33)* ___ @@ -552,7 +510,7 @@ ___ *Inherited from [Order](#interface-order).[takerAddress](#takeraddress)* -*Defined in [types/src/index.ts:17](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L17)* +*Defined in [types/src/index.ts:17](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L17)* ___ @@ -562,7 +520,7 @@ ___ *Inherited from [Order](#interface-order).[takerAssetAmount](#takerassetamount)* -*Defined in [types/src/index.ts:21](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L21)* +*Defined in [types/src/index.ts:21](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L21)* ___ @@ -572,7 +530,7 @@ ___ *Inherited from [Order](#interface-order).[takerAssetData](#takerassetdata)* -*Defined in [types/src/index.ts:27](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L27)* +*Defined in [types/src/index.ts:27](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L27)* ___ @@ -582,7 +540,7 @@ ___ *Inherited from [Order](#interface-order).[takerFee](#takerfee)* -*Defined in [types/src/index.ts:23](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L23)* +*Defined in [types/src/index.ts:23](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L23)* ___ @@ -592,7 +550,7 @@ ___ *Inherited from [Order](#interface-order).[takerFeeAssetData](#takerfeeassetdata)* -*Defined in [types/src/index.ts:29](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L29)* +*Defined in [types/src/index.ts:29](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L29)*
@@ -643,10 +601,6 @@ ___ - -
- -
@@ -659,13 +613,13 @@ ___ #### ▪ **ordersChannelFactory**: *object* -*Defined in [connect/src/orders_channel_factory.ts:7](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/connect/src/orders_channel_factory.ts#L7)* +*Defined in [connect/src/orders_channel_factory.ts:7](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/connect/src/orders_channel_factory.ts#L7)* #### createWebSocketOrdersChannelAsync ▸ **createWebSocketOrdersChannelAsync**(`url`: string, `handler`: [OrdersChannelHandler](#interface-orderschannelhandler)): *`Promise`* -*Defined in [connect/src/orders_channel_factory.ts:15](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/connect/src/orders_channel_factory.ts#L15)* +*Defined in [connect/src/orders_channel_factory.ts:15](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/connect/src/orders_channel_factory.ts#L15)* Instantiates a new WebSocketOrdersChannel instance @@ -682,3 +636,52 @@ An OrdersChannel Promise
+ + +
+ + + + +## Type aliases + + + + + +### AssetPairsResponse + +Ƭ **AssetPairsResponse**: *[PaginatedCollection](#interface-paginatedcollection)‹*[AssetPairsItem](#interface-assetpairsitem)*›* + +*Defined in [types/src/index.ts:416](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L416)* + +___ + + + + + + + +### FeeRecipientsResponse + +Ƭ **FeeRecipientsResponse**: *[PaginatedCollection](#interface-paginatedcollection)‹*string*›* + +*Defined in [types/src/index.ts:484](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L484)* + +___ + + + + + +### OrdersResponse + +Ƭ **OrdersResponse**: *[PaginatedCollection](#interface-paginatedcollection)‹*[APIOrder](#interface-apiorder)*›* + +*Defined in [types/src/index.ts:404](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L404)* + +___ + + + diff --git a/packages/contract-wrappers/docs/reference.mdx b/packages/contract-wrappers/docs/reference.mdx index df339995f7..91f54d2ca8 100644 --- a/packages/contract-wrappers/docs/reference.mdx +++ b/packages/contract-wrappers/docs/reference.mdx @@ -1,17 +1,15 @@ - - -# Class: CoordinatorRegistryContract +# Class: CoordinatorContract ## Constructors -\+ **new CoordinatorRegistryContract**(`address`: string, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults?`: `Partial`, `logDecodeDependencies?`: undefined | object, `deployedBytecode`: string | undefined): *[CoordinatorRegistryContract](#class-coordinatorregistrycontract)* +\+ **new CoordinatorContract**(`address`: string, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults?`: `Partial`, `logDecodeDependencies?`: undefined | object, `deployedBytecode`: string | undefined): *[CoordinatorContract](#class-coordinatorcontract)* *Overrides void* -*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts:464](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts#L464)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator.ts:1112](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/coordinator.ts#L1112)* **Parameters:** @@ -21,9 +19,9 @@ Name | Type | Default | `supportedProvider` | [SupportedProvider](#supportedprovider) | - | `txDefaults?` | `Partial` | - | `logDecodeDependencies?` | undefined \| object | - | -`deployedBytecode` | string \| undefined | CoordinatorRegistryContract.deployedBytecode | +`deployedBytecode` | string \| undefined | CoordinatorContract.deployedBytecode | -**Returns:** *[CoordinatorRegistryContract](#class-coordinatorregistrycontract)* +**Returns:** *[CoordinatorContract](#class-coordinatorcontract)* ## Properties @@ -33,7 +31,7 @@ Name | Type | Default | -Defined in base-contract/lib/src/index.d.ts:32 +Defined in base-contract/lib/src/index.d.ts:31 ___ @@ -43,7 +41,7 @@ ___ -Defined in base-contract/lib/src/index.d.ts:28 +Defined in base-contract/lib/src/index.d.ts:27 ___ @@ -53,7 +51,7 @@ ___ -Defined in base-contract/lib/src/index.d.ts:29 +Defined in base-contract/lib/src/index.d.ts:28 ___ @@ -63,7 +61,7 @@ Args -Defined in base-contract/lib/src/index.d.ts:31 +Defined in base-contract/lib/src/index.d.ts:30 ___ @@ -73,286 +71,451 @@ ___ -Defined in base-contract/lib/src/index.d.ts:30 +Defined in base-contract/lib/src/index.d.ts:29 ## Methods -### getABIDecodedReturnData +### `Static` ABI + +▸ **ABI**(): *[ContractAbi](#contractabi)* -▸ **getABIDecodedReturnData**<**T**>(`methodName`: string, `callData`: string): *`T`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator.ts:818](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/coordinator.ts#L818)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts:208](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts#L208)* +**Returns:** *[ContractAbi](#contractabi)* -**Type parameters:** +The contract ABI -▪ **T** +___ + +### `Static` deployAsync + +▸ **deployAsync**(`bytecode`: string, `abi`: [ContractAbi](#contractabi), `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object, `_exchange`: string): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator.ts:771](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/coordinator.ts#L771)* **Parameters:** Name | Type | ------ | ------ | -`methodName` | string | -`callData` | string | +`bytecode` | string | +`abi` | [ContractAbi](#contractabi) | +`supportedProvider` | [SupportedProvider](#supportedprovider) | +`txDefaults` | `Partial` | +`logDecodeDependencies` | object | +`_exchange` | string | -**Returns:** *`T`* +**Returns:** *`Promise`* ___ -### getABIDecodedTransactionData - -▸ **getABIDecodedTransactionData**<**T**>(`methodName`: string, `callData`: string): *`T`* - -*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts:201](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts#L201)* +### `Static` deployFrom0xArtifactAsync -**Type parameters:** +▸ **deployFrom0xArtifactAsync**(`artifact`: `ContractArtifact` | `SimpleContractArtifact`, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object, `_exchange`: string): *`Promise`* -▪ **T** +*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator.ts:738](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/coordinator.ts#L738)* **Parameters:** Name | Type | ------ | ------ | -`methodName` | string | -`callData` | string | +`artifact` | `ContractArtifact` \| `SimpleContractArtifact` | +`supportedProvider` | [SupportedProvider](#supportedprovider) | +`txDefaults` | `Partial` | +`logDecodeDependencies` | object | +`_exchange` | string | -**Returns:** *`T`* +**Returns:** *`Promise`* ___ -### getCoordinatorEndpoint +### `Static` strictArgumentEncodingCheck -▸ **getCoordinatorEndpoint**(`coordinatorOperator`: string): *`ContractFunctionObj`* +▸ **strictArgumentEncodingCheck**(`inputAbi`: `DataItem`[], `args`: any[]): *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts:344](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts#L344)* -Gets the endpoint for a Coordinator. + +Defined in base-contract/lib/src/index.d.ts:41 **Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`coordinatorOperator` | string | operator of the Coordinator endpoint. | +Name | Type | +------ | ------ | +`inputAbi` | `DataItem`[] | +`args` | any[] | + +**Returns:** *string* -**Returns:** *`ContractFunctionObj`* +## Object literals -___ +### EIP712_COORDINATOR_DOMAIN_HASH + +#### ▪ **EIP712_COORDINATOR_DOMAIN_HASH**: *object* -### getFunctionSignature +*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator.ts:695](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/coordinator.ts#L695)* -▸ **getFunctionSignature**(`methodName`: string): *string* +#### callAsync -*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts:195](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts#L195)* +▸ **callAsync**(`callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator.ts:701](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/coordinator.ts#L701)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | ------- | ------ | -`methodName` | string | +Name | Type | Default | +------ | ------ | ------ | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | -**Returns:** *string* +**Returns:** *`Promise`* ___ -### getLogsAsync +### EIP712_EXCHANGE_DOMAIN_HASH -▸ **getLogsAsync**<**ArgsType**>(`eventName`: [CoordinatorRegistryEvents](#enumeration-coordinatorregistryevents), `blockRange`: `BlockRange`, `indexFilterValues`: `IndexedFilterValues`): *`Promise>>`* +#### ▪ **EIP712_EXCHANGE_DOMAIN_HASH**: *object* -*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts:448](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts#L448)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator.ts:498](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/coordinator.ts#L498)* -Gets historical logs without creating a subscription +#### callAsync -**Type parameters:** +▸ **callAsync**(`callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -▪ **ArgsType**: *[CoordinatorRegistryEventArgs](#coordinatorregistryeventargs)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator.ts:504](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/coordinator.ts#L504)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | Description | +Name | Type | Default | ------ | ------ | ------ | -`eventName` | [CoordinatorRegistryEvents](#enumeration-coordinatorregistryevents) | The CoordinatorRegistry contract event you would like to subscribe to. | -`blockRange` | `BlockRange` | Block range to get logs from. | -`indexFilterValues` | `IndexedFilterValues` | An object where the keys are indexed args returned by the event and the value is the value you are interested in. E.g `{_from: aUserAddressHex}` | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | -**Returns:** *`Promise>>`* - -Array of logs that match the parameters +**Returns:** *`Promise`* ___ -### getSelector +### assertValidCoordinatorApprovals + +#### ▪ **assertValidCoordinatorApprovals**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator.ts:545](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/coordinator.ts#L545)* + +Validates that the 0x transaction has been approved by all of the feeRecipients +that correspond to each order in the transaction's Exchange calldata. + +#### callAsync + +▸ **callAsync**(`transaction`: object, `txOrigin`: string, `transactionSignature`: string, `approvalExpirationTimeSeconds`: `BigNumber`[], `approvalSignatures`: string[], `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -▸ **getSelector**(`methodName`: string): *string* +*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator.ts:560](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/coordinator.ts#L560)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts:215](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts#L215)* +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | ------- | ------ | -`methodName` | string | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`transaction` | object | - | 0x transaction containing salt, signerAddress, and data. | +`txOrigin` | string | - | Required signer of Ethereum transaction calling this function. | +`transactionSignature` | string | - | Proof that the transaction has been signed by the signer. | +`approvalExpirationTimeSeconds` | `BigNumber`[] | - | Array of expiration times in seconds for which each corresponding approval signature expires. | +`approvalSignatures` | string[] | - | Array of signatures that correspond to the feeRecipients of each order in the transaction's Exchange calldata. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -**Returns:** *string* +**Returns:** *`Promise`* ___ -### setCoordinatorEndpoint +### decodeOrdersFromFillData -▸ **setCoordinatorEndpoint**(`coordinatorEndpoint`: string): *`ContractTxFunctionObj`* +#### ▪ **decodeOrdersFromFillData**: *object* -*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts:226](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts#L226)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator.ts:623](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/coordinator.ts#L623)* -Called by a Coordinator operator to set the endpoint of their Coordinator. +Decodes the orders from Exchange calldata representing any fill method. + +#### callAsync + +▸ **callAsync**(`data`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise>`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator.ts:631](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/coordinator.ts#L631)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`coordinatorEndpoint` | string | endpoint of the Coordinator. | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`data` | string | - | Exchange calldata representing a fill method. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -**Returns:** *`ContractTxFunctionObj`* +**Returns:** *`Promise>`* + +The orders from the Exchange calldata. ___ -### subscribe +### executeTransaction -▸ **subscribe**<**ArgsType**>(`eventName`: [CoordinatorRegistryEvents](#enumeration-coordinatorregistryevents), `indexFilterValues`: `IndexedFilterValues`, `callback`: [EventCallback](#eventcallback)‹*`ArgsType`*›, `isVerbose`: boolean, `blockPollingIntervalMs?`: undefined | number): *string* +#### ▪ **executeTransaction**: *object* -*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts:406](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts#L406)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator.ts:206](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/coordinator.ts#L206)* -Subscribe to an event type emitted by the CoordinatorRegistry contract. +Executes a 0x transaction that has been signed by the feeRecipients that correspond to each order in the transaction's Exchange calldata. -**Type parameters:** +#### awaitTransactionSuccessAsync -▪ **ArgsType**: *[CoordinatorRegistryEventArgs](#coordinatorregistryeventargs)* +▸ **awaitTransactionSuccessAsync**(`transaction`: object, `txOrigin`: string, `transactionSignature`: string, `approvalExpirationTimeSeconds`: `BigNumber`[], `approvalSignatures`: string[], `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator.ts:288](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/coordinator.ts#L288)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. **Parameters:** Name | Type | Default | Description | ------ | ------ | ------ | ------ | -`eventName` | [CoordinatorRegistryEvents](#enumeration-coordinatorregistryevents) | - | The CoordinatorRegistry contract event you would like to subscribe to. | -`indexFilterValues` | `IndexedFilterValues` | - | An object where the keys are indexed args returned by the event and the value is the value you are interested in. E.g `{maker: aUserAddressHex}` | -`callback` | [EventCallback](#eventcallback)‹*`ArgsType`*› | - | Callback that gets called when a log is added/removed | -`isVerbose` | boolean | false | Enable verbose subscription warnings (e.g recoverable network issues encountered) | -`blockPollingIntervalMs?` | undefined \| number | - | - | +`transaction` | object | - | 0x transaction containing salt, signerAddress, and data. | +`txOrigin` | string | - | Required signer of Ethereum transaction calling this function. | +`transactionSignature` | string | - | Proof that the transaction has been signed by the signer. | +`approvalExpirationTimeSeconds` | `BigNumber`[] | - | Array of expiration times in seconds for which each corresponding approval signature expires. | +`approvalSignatures` | string[] | - | Array of signatures that correspond to the feeRecipients of each order in the transaction's Exchange calldata. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | -**Returns:** *string* +**Returns:** *`PromiseWithTransactionHash`* -Subscription token used later to unsubscribe +A promise that resolves when the transaction is successful -___ +#### callAsync -### unsubscribe +▸ **callAsync**(`transaction`: object, `txOrigin`: string, `transactionSignature`: string, `approvalExpirationTimeSeconds`: `BigNumber`[], `approvalSignatures`: string[], `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -▸ **unsubscribe**(`subscriptionToken`: string): *void* +*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator.ts:389](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/coordinator.ts#L389)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts:431](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts#L431)* +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. -Cancel a subscription +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`transaction` | object | - | 0x transaction containing salt, signerAddress, and data. | +`txOrigin` | string | - | Required signer of Ethereum transaction calling this function. | +`transactionSignature` | string | - | Proof that the transaction has been signed by the signer. | +`approvalExpirationTimeSeconds` | `BigNumber`[] | - | Array of expiration times in seconds for which each corresponding approval signature expires. | +`approvalSignatures` | string[] | - | Array of signatures that correspond to the feeRecipients of each order in the transaction's Exchange calldata. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +#### estimateGasAsync + +▸ **estimateGasAsync**(`transaction`: object, `txOrigin`: string, `transactionSignature`: string, `approvalExpirationTimeSeconds`: `BigNumber`[], `approvalSignatures`: string[], `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator.ts:337](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/coordinator.ts#L337)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. **Parameters:** Name | Type | Description | ------ | ------ | ------ | -`subscriptionToken` | string | Subscription token returned by `subscribe()` | +`transaction` | object | 0x transaction containing salt, signerAddress, and data. | +`txOrigin` | string | Required signer of Ethereum transaction calling this function. | +`transactionSignature` | string | Proof that the transaction has been signed by the signer. | +`approvalExpirationTimeSeconds` | `BigNumber`[] | Array of expiration times in seconds for which each corresponding approval signature expires. | +`approvalSignatures` | string[] | Array of signatures that correspond to the feeRecipients of each order in the transaction's Exchange calldata. | +`txData?` | `Partial` \| undefined | Additional data for transaction | -**Returns:** *void* +**Returns:** *`Promise`* -___ +The hash of the transaction -### unsubscribeAll +#### getABIEncodedTransactionData -▸ **unsubscribeAll**(): *void* +▸ **getABIEncodedTransactionData**(`transaction`: object, `txOrigin`: string, `transactionSignature`: string, `approvalExpirationTimeSeconds`: `BigNumber`[], `approvalSignatures`: string[]): *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts:437](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts#L437)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator.ts:463](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/coordinator.ts#L463)* -Cancels all existing subscriptions +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). -**Returns:** *void* +**Parameters:** -___ +Name | Type | Description | +------ | ------ | ------ | +`transaction` | object | 0x transaction containing salt, signerAddress, and data. | +`txOrigin` | string | Required signer of Ethereum transaction calling this function. | +`transactionSignature` | string | Proof that the transaction has been signed by the signer. | +`approvalExpirationTimeSeconds` | `BigNumber`[] | Array of expiration times in seconds for which each corresponding approval signature expires. | +`approvalSignatures` | string[] | Array of signatures that correspond to the feeRecipients of each order in the transaction's Exchange calldata. | -### `Static` ABI +**Returns:** *string* -▸ **ABI**(): *[ContractAbi](#contractabi)* +The ABI encoded transaction data as a string -*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts:131](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts#L131)* +#### getSelector -**Returns:** *[ContractAbi](#contractabi)* +▸ **getSelector**(): *string* -The contract ABI +*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator.ts:490](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/coordinator.ts#L490)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`transaction`: object, `txOrigin`: string, `transactionSignature`: string, `approvalExpirationTimeSeconds`: `BigNumber`[], `approvalSignatures`: string[], `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator.ts:222](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/coordinator.ts#L222)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`transaction` | object | - | 0x transaction containing salt, signerAddress, and data. | +`txOrigin` | string | - | Required signer of Ethereum transaction calling this function. | +`transactionSignature` | string | - | Proof that the transaction has been signed by the signer. | +`approvalExpirationTimeSeconds` | `BigNumber`[] | - | Array of expiration times in seconds for which each corresponding approval signature expires. | +`approvalSignatures` | string[] | - | Array of signatures that correspond to the feeRecipients of each order in the transaction's Exchange calldata. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction ___ -### `Static` deployAsync +### getCoordinatorApprovalHash -▸ **deployAsync**(`bytecode`: string, `abi`: [ContractAbi](#contractabi), `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object): *`Promise`* +#### ▪ **getCoordinatorApprovalHash**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator.ts:145](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/coordinator.ts#L145)* + +Calculated the EIP712 hash of the Coordinator approval mesasage using the domain separator of this contract. + +#### callAsync + +▸ **callAsync**(`approval`: object, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator.ts:154](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/coordinator.ts#L154)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts:89](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts#L89)* +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | ------- | ------ | -`bytecode` | string | -`abi` | [ContractAbi](#contractabi) | -`supportedProvider` | [SupportedProvider](#supportedprovider) | -`txDefaults` | `Partial` | -`logDecodeDependencies` | object | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`approval` | object | - | Coordinator approval message containing the transaction hash, transaction signature, and expiration of the approval. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -**Returns:** *`Promise`* +**Returns:** *`Promise`* + +EIP712 hash of the Coordinator approval message with the domain separator of this contract. ___ -### `Static` deployFrom0xArtifactAsync +### getSignerAddress -▸ **deployFrom0xArtifactAsync**(`artifact`: `ContractArtifact` | `SimpleContractArtifact`, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object): *`Promise`* +#### ▪ **getSignerAddress**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator.ts:44](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/coordinator.ts#L44)* + +Recovers the address of a signer given a hash and signature. + +#### callAsync -*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts:58](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts#L58)* +▸ **callAsync**(`hash`: string, `signature`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator.ts:52](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/coordinator.ts#L52)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | ------- | ------ | -`artifact` | `ContractArtifact` \| `SimpleContractArtifact` | -`supportedProvider` | [SupportedProvider](#supportedprovider) | -`txDefaults` | `Partial` | -`logDecodeDependencies` | object | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`hash` | string | - | Any 32 byte hash. | +`signature` | string | - | Proof that the hash has been signed by signer. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -**Returns:** *`Promise`* +**Returns:** *`Promise`* ___ -### `Static` strictArgumentEncodingCheck +### getTransactionHash -▸ **strictArgumentEncodingCheck**(`inputAbi`: `DataItem`[], `args`: any[]): *string* +#### ▪ **getTransactionHash**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator.ts:91](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/coordinator.ts#L91)* +Calculates the EIP712 hash of a 0x transaction using the domain separator of the Exchange contract. + +#### callAsync +▸ **callAsync**(`transaction`: object, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -Defined in base-contract/lib/src/index.d.ts:42 +*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator.ts:99](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/coordinator.ts#L99)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | ------- | ------ | -`inputAbi` | `DataItem`[] | -`args` | any[] | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`transaction` | object | - | 0x transaction containing salt, signerAddress, and data. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -**Returns:** *string* +**Returns:** *`Promise`* + +EIP712 hash of the transaction with the domain separator of this contract.
-# Class: DevUtilsContract +# Class: CoordinatorRegistryContract ## Constructors -\+ **new DevUtilsContract**(`address`: string, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults?`: `Partial`, `logDecodeDependencies?`: undefined | object, `deployedBytecode`: string | undefined): *[DevUtilsContract](#class-devutilscontract)* +\+ **new CoordinatorRegistryContract**(`address`: string, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults?`: `Partial`, `logDecodeDependencies?`: undefined | object, `deployedBytecode`: string | undefined): *[CoordinatorRegistryContract](#class-coordinatorregistrycontract)* *Overrides void* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:3929](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L3929)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts:473](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts#L473)* **Parameters:** @@ -362,19 +525,19 @@ Name | Type | Default | `supportedProvider` | [SupportedProvider](#supportedprovider) | - | `txDefaults?` | `Partial` | - | `logDecodeDependencies?` | undefined \| object | - | -`deployedBytecode` | string \| undefined | DevUtilsContract.deployedBytecode | +`deployedBytecode` | string \| undefined | CoordinatorRegistryContract.deployedBytecode | -**Returns:** *[DevUtilsContract](#class-devutilscontract)* +**Returns:** *[CoordinatorRegistryContract](#class-coordinatorregistrycontract)* ## Properties -### `Optional` _deployedBytecodeIfExists +#### `Optional` _deployedBytecodeIfExists • **_deployedBytecodeIfExists**? : *`Buffer`* -Defined in base-contract/lib/src/index.d.ts:32 +Defined in base-contract/lib/src/index.d.ts:31 ___ @@ -384,7 +547,7 @@ ___ -Defined in base-contract/lib/src/index.d.ts:28 +Defined in base-contract/lib/src/index.d.ts:27 ___ @@ -394,7 +557,7 @@ ___ -Defined in base-contract/lib/src/index.d.ts:29 +Defined in base-contract/lib/src/index.d.ts:28 ___ @@ -404,7 +567,7 @@ Args -Defined in base-contract/lib/src/index.d.ts:31 +Defined in base-contract/lib/src/index.d.ts:30 ___ @@ -414,1925 +577,2078 @@ ___ -Defined in base-contract/lib/src/index.d.ts:30 +Defined in base-contract/lib/src/index.d.ts:29 ## Methods -### decodeAssetProxyDispatchError +### getLogsAsync -▸ **decodeAssetProxyDispatchError**(`encoded`: string): *`ContractFunctionObj<[number, string, string]>`* +▸ **getLogsAsync**<**ArgsType**>(`eventName`: [CoordinatorRegistryEvents](#enumeration-coordinatorregistryevents), `blockRange`: `BlockRange`, `indexFilterValues`: `IndexedFilterValues`): *`Promise>>`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1516](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1516)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts:457](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts#L457)* -Decompose an ABI-encoded AssetProxyDispatchError. +Gets historical logs without creating a subscription + +**Type parameters:** + +▪ **ArgsType**: *[CoordinatorRegistryEventArgs](#coordinatorregistryeventargs)* **Parameters:** Name | Type | Description | ------ | ------ | ------ | -`encoded` | string | ABI-encoded revert error. | +`eventName` | [CoordinatorRegistryEvents](#enumeration-coordinatorregistryevents) | The CoordinatorRegistry contract event you would like to subscribe to. | +`blockRange` | `BlockRange` | Block range to get logs from. | +`indexFilterValues` | `IndexedFilterValues` | An object where the keys are indexed args returned by the event and the value is the value you are interested in. E.g `{_from: aUserAddressHex}` | -**Returns:** *`ContractFunctionObj<[number, string, string]>`* +**Returns:** *`Promise>>`* -errorCode The error code.orderHash Hash of the order being dispatched.assetData Asset data of the order being dispatched. +Array of logs that match the parameters ___ -### decodeAssetProxyExistsError +### subscribe + +▸ **subscribe**<**ArgsType**>(`eventName`: [CoordinatorRegistryEvents](#enumeration-coordinatorregistryevents), `indexFilterValues`: `IndexedFilterValues`, `callback`: [EventCallback](#eventcallback)‹*`ArgsType`*›, `isVerbose`: boolean, `blockPollingIntervalMs?`: undefined | number): *string* -▸ **decodeAssetProxyExistsError**(`encoded`: string): *`ContractFunctionObj<[string, string]>`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts:415](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts#L415)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1564](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1564)* +Subscribe to an event type emitted by the CoordinatorRegistry contract. -Decompose an ABI-encoded AssetProxyExistsError. +**Type parameters:** + +▪ **ArgsType**: *[CoordinatorRegistryEventArgs](#coordinatorregistryeventargs)* **Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`encoded` | string | ABI-encoded revert error. | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`eventName` | [CoordinatorRegistryEvents](#enumeration-coordinatorregistryevents) | - | The CoordinatorRegistry contract event you would like to subscribe to. | +`indexFilterValues` | `IndexedFilterValues` | - | An object where the keys are indexed args returned by the event and the value is the value you are interested in. E.g `{maker: aUserAddressHex}` | +`callback` | [EventCallback](#eventcallback)‹*`ArgsType`*› | - | Callback that gets called when a log is added/removed | +`isVerbose` | boolean | false | Enable verbose subscription warnings (e.g recoverable network issues encountered) | +`blockPollingIntervalMs?` | undefined \| number | - | - | -**Returns:** *`ContractFunctionObj<[string, string]>`* +**Returns:** *string* -assetProxyId Id of asset proxy.assetProxyAddress The address of the asset proxy. +Subscription token used later to unsubscribe ___ -### decodeAssetProxyId +### unsubscribe -▸ **decodeAssetProxyId**(`assetData`: string): *`ContractFunctionObj`* +▸ **unsubscribe**(`subscriptionToken`: string): *void* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1610](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1610)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts:440](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts#L440)* -Decode AssetProxy identifier +Cancel a subscription **Parameters:** Name | Type | Description | ------ | ------ | ------ | -`assetData` | string | AssetProxy-compliant asset data describing an ERC-20, ERC- 721, ERC1155, or MultiAsset asset. | - -**Returns:** *`ContractFunctionObj`* +`subscriptionToken` | string | Subscription token returned by `subscribe()` | -The AssetProxy identifier +**Returns:** *void* ___ -### decodeAssetProxyTransferError +### unsubscribeAll -▸ **decodeAssetProxyTransferError**(`encoded`: string): *`ContractFunctionObj<[string, string, string]>`* +▸ **unsubscribeAll**(): *void* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1653](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1653)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts:446](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts#L446)* -Decompose an ABI-encoded AssetProxyTransferError. +Cancels all existing subscriptions -**Parameters:** +**Returns:** *void* -Name | Type | Description | ------- | ------ | ------ | -`encoded` | string | ABI-encoded revert error. | +___ -**Returns:** *`ContractFunctionObj<[string, string, string]>`* +### `Static` ABI -orderHash Hash of the order being dispatched.assetData Asset data of the order being dispatched.errorData ABI-encoded revert data from the asset proxy. +▸ **ABI**(): *[ContractAbi](#contractabi)* -___ +*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts:343](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts#L343)* -### decodeEIP1271SignatureError +**Returns:** *[ContractAbi](#contractabi)* -▸ **decodeEIP1271SignatureError**(`encoded`: string): *`ContractFunctionObj<[string, string, string, string]>`* +The contract ABI -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1701](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1701)* +___ -Decompose an ABI-encoded SignatureValidatorError. +### `Static` deployAsync -**Parameters:** +▸ **deployAsync**(`bytecode`: string, `abi`: [ContractAbi](#contractabi), `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object): *`Promise`* -Name | Type | Description | ------- | ------ | ------ | -`encoded` | string | ABI-encoded revert error. | +*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts:301](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts#L301)* -**Returns:** *`ContractFunctionObj<[string, string, string, string]>`* +**Parameters:** -signerAddress The expected signer of the hash.signature The full signature bytes.errorData The revert data thrown by the validator contract. +Name | Type | +------ | ------ | +`bytecode` | string | +`abi` | [ContractAbi](#contractabi) | +`supportedProvider` | [SupportedProvider](#supportedprovider) | +`txDefaults` | `Partial` | +`logDecodeDependencies` | object | -___ +**Returns:** *`Promise`* -### decodeERC1155AssetData +___ -▸ **decodeERC1155AssetData**(`assetData`: string): *`ContractFunctionObj<[string, string, BigNumber[], BigNumber[], string]>`* +### `Static` deployFrom0xArtifactAsync -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1750](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1750)* +▸ **deployFrom0xArtifactAsync**(`artifact`: `ContractArtifact` | `SimpleContractArtifact`, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object): *`Promise`* -Decode ERC-1155 asset data from the format described in the AssetProxy contract specification. +*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts:270](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts#L270)* **Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`assetData` | string | AssetProxy-compliant asset data describing an ERC-1155 set of assets. | - -**Returns:** *`ContractFunctionObj<[string, string, BigNumber[], BigNumber[], string]>`* +Name | Type | +------ | ------ | +`artifact` | `ContractArtifact` \| `SimpleContractArtifact` | +`supportedProvider` | [SupportedProvider](#supportedprovider) | +`txDefaults` | `Partial` | +`logDecodeDependencies` | object | -The ERC-1155 AssetProxy identifier, the address of the ERC-1155 contract hosting the assets, an array of the identifiers of the assets to be traded, an array of asset amounts to be traded, and callback data. Each element of the arrays corresponds to the same-indexed element of the other array. Return values specified as `memory` are returned as pointers to locations within the memory of the input parameter `assetData`. +**Returns:** *`Promise`* ___ -### decodeERC20AssetData +### `Static` strictArgumentEncodingCheck -▸ **decodeERC20AssetData**(`assetData`: string): *`ContractFunctionObj<[string, string]>`* +▸ **strictArgumentEncodingCheck**(`inputAbi`: `DataItem`[], `args`: any[]): *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1802](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1802)* -Decode ERC-20 asset data from the format described in the AssetProxy contract specification. + +Defined in base-contract/lib/src/index.d.ts:41 **Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`assetData` | string | AssetProxy-compliant asset data describing an ERC-20 asset. | +Name | Type | +------ | ------ | +`inputAbi` | `DataItem`[] | +`args` | any[] | -**Returns:** *`ContractFunctionObj<[string, string]>`* +**Returns:** *string* -The AssetProxy identifier, and the address of the ERC-20 contract hosting this asset. +## Object literals -___ +### getCoordinatorEndpoint -### decodeERC721AssetData +#### ▪ **getCoordinatorEndpoint**: *object* -▸ **decodeERC721AssetData**(`assetData`: string): *`ContractFunctionObj<[string, string, BigNumber]>`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts:218](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts#L218)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1848](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1848)* +Gets the endpoint for a Coordinator. -Decode ERC-721 asset data from the format described in the AssetProxy contract specification. +#### callAsync -**Parameters:** +▸ **callAsync**(`coordinatorOperator`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -Name | Type | Description | ------- | ------ | ------ | -`assetData` | string | AssetProxy-compliant asset data describing an ERC-721 asset. | +*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts:225](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts#L225)* -**Returns:** *`ContractFunctionObj<[string, string, BigNumber]>`* +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. -The ERC-721 AssetProxy identifier, the address of the ERC-721 contract hosting this asset, and the identifier of the specific asset to be traded. +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`coordinatorOperator` | string | - | operator of the Coordinator endpoint. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* ___ -### decodeExchangeInvalidContextError +### setCoordinatorEndpoint -▸ **decodeExchangeInvalidContextError**(`encoded`: string): *`ContractFunctionObj<[number, string, string]>`* +#### ▪ **setCoordinatorEndpoint**: *object* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1896](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1896)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts:56](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts#L56)* -Decompose an ABI-encoded OrderStatusError. +Called by a Coordinator operator to set the endpoint of their Coordinator. -**Parameters:** +#### awaitTransactionSuccessAsync -Name | Type | Description | ------- | ------ | ------ | -`encoded` | string | ABI-encoded revert error. | +▸ **awaitTransactionSuccessAsync**(`coordinatorEndpoint`: string, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* -**Returns:** *`ContractFunctionObj<[number, string, string]>`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts:99](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts#L99)* -errorCode Error code that corresponds to invalid maker, taker, or sender.orderHash The order hash.contextAddress The maker, taker, or sender address +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. -___ +**Parameters:** -### decodeFillError +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`coordinatorEndpoint` | string | - | endpoint of the Coordinator. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* -▸ **decodeFillError**(`encoded`: string): *`ContractFunctionObj<[number, string]>`* +A promise that resolves when the transaction is successful -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1945](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1945)* +#### callAsync -Decompose an ABI-encoded FillError. +▸ **callAsync**(`coordinatorEndpoint`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -**Parameters:** +*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts:150](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts#L150)* -Name | Type | Description | ------- | ------ | ------ | -`encoded` | string | ABI-encoded revert error. | +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. -**Returns:** *`ContractFunctionObj<[number, string]>`* +**Parameters:** -errorCode The error code.orderHash The order hash. +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`coordinatorEndpoint` | string | - | endpoint of the Coordinator. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -___ +**Returns:** *`Promise`* -### decodeIncompleteFillError +#### estimateGasAsync -▸ **decodeIncompleteFillError**(`encoded`: string): *`ContractFunctionObj<[number, BigNumber, BigNumber]>`* +▸ **estimateGasAsync**(`coordinatorEndpoint`: string, `txData?`: `Partial` | undefined): *`Promise`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1988](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1988)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts:125](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts#L125)* -Decompose an ABI-encoded IncompleteFillError. +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. **Parameters:** Name | Type | Description | ------ | ------ | ------ | -`encoded` | string | ABI-encoded revert error. | - -**Returns:** *`ContractFunctionObj<[number, BigNumber, BigNumber]>`* +`coordinatorEndpoint` | string | endpoint of the Coordinator. | +`txData?` | `Partial` \| undefined | Additional data for transaction | -orderHash Hash of the order being filled. +**Returns:** *`Promise`* -___ +The hash of the transaction -### decodeMultiAssetData +#### getABIEncodedTransactionData -▸ **decodeMultiAssetData**(`assetData`: string): *`ContractFunctionObj<[string, BigNumber[], string[]]>`* +▸ **getABIEncodedTransactionData**(`coordinatorEndpoint`: string): *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2036](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2036)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts:198](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts#L198)* -Decode multi-asset data from the format described in the AssetProxy contract specification. +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). **Parameters:** Name | Type | Description | ------ | ------ | ------ | -`assetData` | string | AssetProxy-compliant data describing a multi-asset basket. | - -**Returns:** *`ContractFunctionObj<[string, BigNumber[], string[]]>`* +`coordinatorEndpoint` | string | endpoint of the Coordinator. | -The Multi-Asset AssetProxy identifier, an array of the amounts of the assets to be traded, and an array of the AssetProxy-compliant data describing each asset to be traded. Each element of the arrays corresponds to the same-indexed element of the other array. +**Returns:** *string* -___ +The ABI encoded transaction data as a string -### decodeNegativeSpreadError +#### getSelector -▸ **decodeNegativeSpreadError**(`encoded`: string): *`ContractFunctionObj<[string, string]>`* +▸ **getSelector**(): *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2084](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2084)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts:209](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts#L209)* -Decompose an ABI-encoded NegativeSpreadError. +Returns the 4 byte function selector as a hex string. -**Parameters:** +**Returns:** *string* -Name | Type | Description | ------- | ------ | ------ | -`encoded` | string | ABI-encoded revert error. | +#### sendTransactionAsync -**Returns:** *`ContractFunctionObj<[string, string]>`* +▸ **sendTransactionAsync**(`coordinatorEndpoint`: string, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* -leftOrderHash Hash of the left order being matched.rightOrderHash Hash of the right order being matched. +*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts:64](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts#L64)* -___ +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. -### decodeOrderEpochError +**Parameters:** -▸ **decodeOrderEpochError**(`encoded`: string): *`ContractFunctionObj<[string, string, BigNumber]>`* +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`coordinatorEndpoint` | string | - | endpoint of the Coordinator. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2129](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2129)* +**Returns:** *`Promise`* -Decompose an ABI-encoded OrderEpochError. +The hash of the transaction -**Parameters:** +
-Name | Type | Description | ------- | ------ | ------ | -`encoded` | string | ABI-encoded revert error. | +# Class: DevUtilsContract -**Returns:** *`ContractFunctionObj<[string, string, BigNumber]>`* -makerAddress The order maker.orderSenderAddress The order sender.currentEpoch The current epoch for the maker. +## Constructors -___ -### decodeOrderStatusError -▸ **decodeOrderStatusError**(`encoded`: string): *`ContractFunctionObj<[string, number]>`* +\+ **new DevUtilsContract**(`address`: string, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults?`: `Partial`, `logDecodeDependencies?`: undefined | object, `deployedBytecode`: string | undefined): *[DevUtilsContract](#class-devutilscontract)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2177](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2177)* +*Overrides void* -Decompose an ABI-encoded OrderStatusError. +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:4076](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L4076)* **Parameters:** -Name | Type | Description | +Name | Type | Default | ------ | ------ | ------ | -`encoded` | string | ABI-encoded revert error. | - -**Returns:** *`ContractFunctionObj<[string, number]>`* +`address` | string | - | +`supportedProvider` | [SupportedProvider](#supportedprovider) | - | +`txDefaults?` | `Partial` | - | +`logDecodeDependencies?` | undefined \| object | - | +`deployedBytecode` | string \| undefined | DevUtilsContract.deployedBytecode | -orderHash The order hash.orderStatus The order status. +**Returns:** *[DevUtilsContract](#class-devutilscontract)* -___ +## Properties -### decodeSignatureError +#### `Optional` _deployedBytecodeIfExists -▸ **decodeSignatureError**(`encoded`: string): *`ContractFunctionObj<[number, string, string, string]>`* +• **_deployedBytecodeIfExists**? : *`Buffer`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2222](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2222)* -Decompose an ABI-encoded SignatureError. -**Parameters:** +Defined in base-contract/lib/src/index.d.ts:31 -Name | Type | Description | ------- | ------ | ------ | -`encoded` | string | ABI-encoded revert error. | +___ -**Returns:** *`ContractFunctionObj<[number, string, string, string]>`* +### abi -errorCode The error code.signerAddress The expected signer of the hash.signature The full signature. +• **abi**: *[ContractAbi](#contractabi)* -___ -### decodeSignatureValidatorNotApprovedError -▸ **decodeSignatureValidatorNotApprovedError**(`encoded`: string): *`ContractFunctionObj<[string, string]>`* +Defined in base-contract/lib/src/index.d.ts:27 -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2268](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2268)* +___ -Decompose an ABI-encoded SignatureValidatorNotApprovedError. +### address -**Parameters:** +• **address**: *string* -Name | Type | Description | ------- | ------ | ------ | -`encoded` | string | ABI-encoded revert error. | -**Returns:** *`ContractFunctionObj<[string, string]>`* -signerAddress The expected signer of the hash.validatorAddress The expected validator. +Defined in base-contract/lib/src/index.d.ts:28 ___ -### decodeSignatureWalletError +Args -▸ **decodeSignatureWalletError**(`encoded`: string): *`ContractFunctionObj<[string, string, string, string]>`* +• **constructorArgs**: *any[]* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2316](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2316)* -Decompose an ABI-encoded SignatureWalletError. -**Parameters:** +Defined in base-contract/lib/src/index.d.ts:30 -Name | Type | Description | ------- | ------ | ------ | -`encoded` | string | ABI-encoded revert error. | +___ -**Returns:** *`ContractFunctionObj<[string, string, string, string]>`* +### contractName -errorCode The error code.signerAddress The expected signer of the hash.signature The full signature bytes.errorData The revert data thrown by the validator contract. +• **contractName**: *string* -___ -### decodeStaticCallAssetData -▸ **decodeStaticCallAssetData**(`assetData`: string): *`ContractFunctionObj<[string, string, string, string]>`* +Defined in base-contract/lib/src/index.d.ts:29 -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2365](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2365)* +## Methods -Decode StaticCall asset data from the format described in the AssetProxy contract specification. +### `Static` ABI -**Parameters:** +▸ **ABI**(): *[ContractAbi](#contractabi)* -Name | Type | Description | ------- | ------ | ------ | -`assetData` | string | AssetProxy-compliant asset data describing a StaticCall asset | +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2719](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2719)* -**Returns:** *`ContractFunctionObj<[string, string, string, string]>`* +**Returns:** *[ContractAbi](#contractabi)* -The StaticCall AssetProxy identifier, the target address of the StaticCAll, the data to be passed to the target address, and the expected Keccak-256 hash of the static call return data. +The contract ABI ___ -### decodeTransactionError +### `Static` deployAsync -▸ **decodeTransactionError**(`encoded`: string): *`ContractFunctionObj<[number, string]>`* +▸ **deployAsync**(`bytecode`: string, `abi`: [ContractAbi](#contractabi), `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object, `_exchange`: string): *`Promise`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2413](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2413)* - -Decompose an ABI-encoded TransactionError. +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2672](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2672)* **Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`encoded` | string | ABI-encoded revert error. | - -**Returns:** *`ContractFunctionObj<[number, string]>`* +Name | Type | +------ | ------ | +`bytecode` | string | +`abi` | [ContractAbi](#contractabi) | +`supportedProvider` | [SupportedProvider](#supportedprovider) | +`txDefaults` | `Partial` | +`logDecodeDependencies` | object | +`_exchange` | string | -errorCode The error code.transactionHash Hash of the transaction. +**Returns:** *`Promise`* ___ -### decodeTransactionExecutionError - -▸ **decodeTransactionExecutionError**(`encoded`: string): *`ContractFunctionObj<[string, string]>`* +### `Static` deployFrom0xArtifactAsync -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2458](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2458)* +▸ **deployFrom0xArtifactAsync**(`artifact`: `ContractArtifact` | `SimpleContractArtifact`, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object, `_exchange`: string): *`Promise`* -Decompose an ABI-encoded TransactionExecutionError. +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2639](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2639)* **Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`encoded` | string | ABI-encoded revert error. | - -**Returns:** *`ContractFunctionObj<[string, string]>`* +Name | Type | +------ | ------ | +`artifact` | `ContractArtifact` \| `SimpleContractArtifact` | +`supportedProvider` | [SupportedProvider](#supportedprovider) | +`txDefaults` | `Partial` | +`logDecodeDependencies` | object | +`_exchange` | string | -transactionHash Hash of the transaction.errorData Error thrown by exeucteTransaction(). +**Returns:** *`Promise`* ___ -### decodeZeroExTransactionData +### `Static` strictArgumentEncodingCheck + +▸ **strictArgumentEncodingCheck**(`inputAbi`: `DataItem`[], `args`: any[]): *string* -▸ **decodeZeroExTransactionData**(`transactionData`: string): *`ContractFunctionObj<[string, Array, BigNumber[], string[]]>`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2505](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2505)* -Decodes the call data for an Exchange contract method call. +Defined in base-contract/lib/src/index.d.ts:41 **Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`transactionData` | string | ABI-encoded calldata for an Exchange contract method call. | +Name | Type | +------ | ------ | +`inputAbi` | `DataItem`[] | +`args` | any[] | -**Returns:** *`ContractFunctionObj<[string, Array, BigNumber[], string[]]>`* +**Returns:** *string* -The name of the function called, and the parameters it was given. For single-order fills and cancels, the arrays will have just one element. +## Object literals -___ +### decodeAssetProxyDispatchError -### encodeERC1155AssetData +#### ▪ **decodeAssetProxyDispatchError**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:45](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L45)* -▸ **encodeERC1155AssetData**(`tokenAddress`: string, `tokenIds`: `BigNumber`[], `tokenValues`: `BigNumber`[], `callbackData`: string): *`ContractFunctionObj`* +Decompose an ABI-encoded AssetProxyDispatchError. -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2628](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2628)* +#### callAsync -Encode ERC-1155 asset data into the format described in the AssetProxy contract specification. +▸ **callAsync**(`encoded`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise<[number, string, string]>`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:53](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L53)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`tokenAddress` | string | The address of the ERC-1155 contract hosting the asset(s) to be traded. | -`tokenIds` | `BigNumber`[] | The identifiers of the specific assets to be traded. | -`tokenValues` | `BigNumber`[] | The amounts of each asset to be traded. | -`callbackData` | string | Data to be passed to receiving contracts when a transfer is performed. | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`encoded` | string | - | ABI-encoded revert error. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -**Returns:** *`ContractFunctionObj`* +**Returns:** *`Promise<[number, string, string]>`* -AssetProxy-compliant asset data describing the set of assets. +errorCode The error code.orderHash Hash of the order being dispatched.assetData Asset data of the order being dispatched. ___ -### encodeERC20AssetData - -▸ **encodeERC20AssetData**(`tokenAddress`: string): *`ContractFunctionObj`* +### decodeAssetProxyExistsError -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2686](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2686)* +#### ▪ **decodeAssetProxyExistsError**: *object* -Encode ERC-20 asset data into the format described in the AssetProxy contract specification. +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:90](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L90)* -**Parameters:** +Decompose an ABI-encoded AssetProxyExistsError. -Name | Type | Description | ------- | ------ | ------ | -`tokenAddress` | string | The address of the ERC-20 contract hosting the asset to be traded. | +#### callAsync -**Returns:** *`ContractFunctionObj`* +▸ **callAsync**(`encoded`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise<[string, string]>`* -AssetProxy-compliant data describing the asset. +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:98](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L98)* -___ +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. -### encodeERC721AssetData +**Parameters:** -▸ **encodeERC721AssetData**(`tokenAddress`: string, `tokenId`: `BigNumber`): *`ContractFunctionObj`* +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`encoded` | string | - | ABI-encoded revert error. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2735](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2735)* +**Returns:** *`Promise<[string, string]>`* -Encode ERC-721 asset data into the format described in the AssetProxy specification. +assetProxyId Id of asset proxy.assetProxyAddress The address of the asset proxy. -**Parameters:** +___ -Name | Type | Description | ------- | ------ | ------ | -`tokenAddress` | string | The address of the ERC-721 contract hosting the asset to be traded. | -`tokenId` | `BigNumber` | The identifier of the specific asset to be traded. | +### decodeAssetProxyId -**Returns:** *`ContractFunctionObj`* +#### ▪ **decodeAssetProxyId**: *object* -AssetProxy-compliant asset data describing the asset. +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:135](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L135)* -___ +Decode AssetProxy identifier -### encodeMultiAssetData +#### callAsync -▸ **encodeMultiAssetData**(`amounts`: `BigNumber`[], `nestedAssetData`: string[]): *`ContractFunctionObj`* +▸ **callAsync**(`assetData`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2787](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2787)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:144](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L144)* -Encode data for multiple assets, per the AssetProxy contract specification. +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`amounts` | `BigNumber`[] | The amounts of each asset to be traded. | -`nestedAssetData` | string[] | AssetProxy-compliant data describing each asset to be traded. | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`assetData` | string | - | AssetProxy-compliant asset data describing an ERC-20, ERC- 721, ERC1155, or MultiAsset asset. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -**Returns:** *`ContractFunctionObj`* +**Returns:** *`Promise`* -AssetProxy-compliant data describing the set of assets. +The AssetProxy identifier ___ -### encodeStaticCallAssetData - -▸ **encodeStaticCallAssetData**(`staticCallTargetAddress`: string, `staticCallData`: string, `expectedReturnDataHash`: string): *`ContractFunctionObj`* - -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2841](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2841)* +### decodeAssetProxyTransferError -Encode StaticCall asset data into the format described in the AssetProxy contract specification. +#### ▪ **decodeAssetProxyTransferError**: *object* -**Parameters:** +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:181](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L181)* -Name | Type | Description | ------- | ------ | ------ | -`staticCallTargetAddress` | string | Target address of StaticCall. | -`staticCallData` | string | Data that will be passed to staticCallTargetAddress in the StaticCall. | -`expectedReturnDataHash` | string | Expected Keccak-256 hash of the StaticCall return data. | +Decompose an ABI-encoded AssetProxyTransferError. -**Returns:** *`ContractFunctionObj`* +#### callAsync -AssetProxy-compliant asset data describing the set of assets. +▸ **callAsync**(`encoded`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise<[string, string, string]>`* -___ +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:189](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L189)* -### getABIDecodedReturnData +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. -▸ **getABIDecodedReturnData**<**T**>(`methodName`: string, `callData`: string): *`T`* +**Parameters:** -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1497](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1497)* +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`encoded` | string | - | ABI-encoded revert error. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -**Type parameters:** +**Returns:** *`Promise<[string, string, string]>`* -▪ **T** +orderHash Hash of the order being dispatched.assetData Asset data of the order being dispatched.errorData ABI-encoded revert data from the asset proxy. -**Parameters:** +___ -Name | Type | ------- | ------ | -`methodName` | string | -`callData` | string | +### decodeEIP1271SignatureError -**Returns:** *`T`* +#### ▪ **decodeEIP1271SignatureError**: *object* -___ +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:226](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L226)* -### getABIDecodedTransactionData +Decompose an ABI-encoded SignatureValidatorError. -▸ **getABIDecodedTransactionData**<**T**>(`methodName`: string, `callData`: string): *`T`* +#### callAsync -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1490](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1490)* +▸ **callAsync**(`encoded`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise<[string, string, string, string]>`* -**Type parameters:** +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:234](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L234)* -▪ **T** +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | ------- | ------ | -`methodName` | string | -`callData` | string | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`encoded` | string | - | ABI-encoded revert error. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -**Returns:** *`T`* +**Returns:** *`Promise<[string, string, string, string]>`* -___ +signerAddress The expected signer of the hash.signature The full signature bytes.errorData The revert data thrown by the validator contract. -### getAssetProxyAllowance +___ -▸ **getAssetProxyAllowance**(`ownerAddress`: string, `assetData`: string): *`ContractFunctionObj`* +### decodeERC1155AssetData -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2899](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2899)* +#### ▪ **decodeERC1155AssetData**: *object* -Returns the number of asset(s) (described by assetData) that the corresponding AssetProxy contract is authorized to spend. When the asset data contains multiple assets (eg for Multi-Asset), the return value indicates how many complete "baskets" of those assets may be spent by all of the corresponding AssetProxy contracts. +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:271](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L271)* -**Parameters:** +Decode ERC-1155 asset data from the format described in the AssetProxy contract specification. -Name | Type | Description | ------- | ------ | ------ | -`ownerAddress` | string | Owner of the assets specified by assetData. | -`assetData` | string | Details of asset, encoded per the AssetProxy contract specification. | +#### callAsync -**Returns:** *`ContractFunctionObj`* +▸ **callAsync**(`assetData`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise<[string, string, BigNumber[], BigNumber[], string]>`* -Number of assets (or asset baskets) that the corresponding AssetProxy is authorized to spend. +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:280](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L280)* -___ +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. -### getBalance +**Parameters:** -▸ **getBalance**(`ownerAddress`: string, `assetData`: string): *`ContractFunctionObj`* +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`assetData` | string | - | AssetProxy-compliant asset data describing an ERC-1155 set of assets. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2961](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2961)* +**Returns:** *`Promise<[string, string, BigNumber[], BigNumber[], string]>`* -Returns the owner's balance of the assets(s) specified in assetData. When the asset data contains multiple assets (eg in ERC1155 or Multi-Asset), the return value indicates how many complete "baskets" of those assets are owned by owner. +The ERC-1155 AssetProxy identifier, the address of the ERC-1155 contract hosting the assets, an array of the identifiers of the assets to be traded, an array of asset amounts to be traded, and callback data. Each element of the arrays corresponds to the same-indexed element of the other array. Return values specified as `memory` are returned as pointers to locations within the memory of the input parameter `assetData`. -**Parameters:** +___ -Name | Type | Description | ------- | ------ | ------ | -`ownerAddress` | string | Owner of the assets specified by assetData. | -`assetData` | string | Details of asset, encoded per the AssetProxy contract specification. | +### decodeERC20AssetData -**Returns:** *`ContractFunctionObj`* +#### ▪ **decodeERC20AssetData**: *object* -Number of assets (or asset baskets) held by owner. +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:319](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L319)* -___ +Decode ERC-20 asset data from the format described in the AssetProxy contract specification. -### getBalanceAndAssetProxyAllowance +#### callAsync -▸ **getBalanceAndAssetProxyAllowance**(`ownerAddress`: string, `assetData`: string): *`ContractFunctionObj<[BigNumber, BigNumber]>`* +▸ **callAsync**(`assetData`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise<[string, string]>`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:3023](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L3023)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:327](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L327)* -Calls getBalance() and getAllowance() for assetData. +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`ownerAddress` | string | Owner of the assets specified by assetData. | -`assetData` | string | Details of asset, encoded per the AssetProxy contract specification. | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`assetData` | string | - | AssetProxy-compliant asset data describing an ERC-20 asset. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -**Returns:** *`ContractFunctionObj<[BigNumber, BigNumber]>`* +**Returns:** *`Promise<[string, string]>`* -Number of assets (or asset baskets) held by owner, and number of assets (or asset baskets) that the corresponding AssetProxy is authorized to spend. +The AssetProxy identifier, and the address of the ERC-20 contract hosting this asset. ___ -### getBatchAssetProxyAllowances - -▸ **getBatchAssetProxyAllowances**(`ownerAddress`: string, `assetData`: string[]): *`ContractFunctionObj`* +### decodeERC721AssetData -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:3091](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L3091)* +#### ▪ **decodeERC721AssetData**: *object* -Calls getAssetProxyAllowance() for each element of assetData. +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:364](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L364)* -**Parameters:** +Decode ERC-721 asset data from the format described in the AssetProxy contract specification. -Name | Type | Description | ------- | ------ | ------ | -`ownerAddress` | string | Owner of the assets specified by assetData. | -`assetData` | string[] | Array of asset details, each encoded per the AssetProxy contract specification. | +#### callAsync -**Returns:** *`ContractFunctionObj`* +▸ **callAsync**(`assetData`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise<[string, string, BigNumber]>`* -An array of asset allowances from getAllowance(), with each element corresponding to the same-indexed element in the assetData input. +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:373](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L373)* -___ +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. -### getBatchBalances +**Parameters:** -▸ **getBatchBalances**(`ownerAddress`: string, `assetData`: string[]): *`ContractFunctionObj`* +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`assetData` | string | - | AssetProxy-compliant asset data describing an ERC-721 asset. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:3153](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L3153)* +**Returns:** *`Promise<[string, string, BigNumber]>`* -Calls getBalance() for each element of assetData. +The ERC-721 AssetProxy identifier, the address of the ERC-721 contract hosting this asset, and the identifier of the specific asset to be traded. -**Parameters:** +___ -Name | Type | Description | ------- | ------ | ------ | -`ownerAddress` | string | Owner of the assets specified by assetData. | -`assetData` | string[] | Array of asset details, each encoded per the AssetProxy contract specification. | +### decodeExchangeInvalidContextError -**Returns:** *`ContractFunctionObj`* +#### ▪ **decodeExchangeInvalidContextError**: *object* -Array of asset balances from getBalance(), with each element corresponding to the same-indexed element in the assetData input. +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:410](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L410)* -___ +Decompose an ABI-encoded OrderStatusError. -### getBatchBalancesAndAssetProxyAllowances +#### callAsync -▸ **getBatchBalancesAndAssetProxyAllowances**(`ownerAddress`: string, `assetData`: string[]): *`ContractFunctionObj<[BigNumber[], BigNumber[]]>`* +▸ **callAsync**(`encoded`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise<[number, string, string]>`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:3215](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L3215)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:418](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L418)* -Calls getBatchBalances() and getBatchAllowances() for each element of assetData. +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`ownerAddress` | string | Owner of the assets specified by assetData. | -`assetData` | string[] | Array of asset details, each encoded per the AssetProxy contract specification. | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`encoded` | string | - | ABI-encoded revert error. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -**Returns:** *`ContractFunctionObj<[BigNumber[], BigNumber[]]>`* +**Returns:** *`Promise<[number, string, string]>`* -An array of asset balances from getBalance(), and an array of asset allowances from getAllowance(), with each element corresponding to the same-indexed element in the assetData input. +errorCode Error code that corresponds to invalid maker, taker, or sender.orderHash The order hash.contextAddress The maker, taker, or sender address ___ -### getEthBalances +### decodeFillError -▸ **getEthBalances**(`addresses`: string[]): *`ContractFunctionObj`* +#### ▪ **decodeFillError**: *object* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:3281](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L3281)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:455](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L455)* -Batch fetches ETH balances +Decompose an ABI-encoded FillError. -**Parameters:** +#### callAsync -Name | Type | Description | ------- | ------ | ------ | -`addresses` | string[] | Array of addresses. | +▸ **callAsync**(`encoded`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise<[number, string]>`* -**Returns:** *`ContractFunctionObj`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:463](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L463)* -Array of ETH balances. +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. -___ +**Parameters:** -### getFunctionSignature +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`encoded` | string | - | ABI-encoded revert error. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -▸ **getFunctionSignature**(`methodName`: string): *string* +**Returns:** *`Promise<[number, string]>`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1484](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1484)* +errorCode The error code.orderHash The order hash. -**Parameters:** +___ -Name | Type | ------- | ------ | -`methodName` | string | +### decodeIncompleteFillError -**Returns:** *string* +#### ▪ **decodeIncompleteFillError**: *object* -___ +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:500](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L500)* -### getOrderRelevantState +Decompose an ABI-encoded IncompleteFillError. -▸ **getOrderRelevantState**(`order`: object, `signature`: string): *`ContractFunctionObj<[object, BigNumber, boolean]>`* +#### callAsync -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:3337](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L3337)* +▸ **callAsync**(`encoded`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise<[number, BigNumber, BigNumber]>`* -Fetches all order-relevant information needed to validate if the supplied order is fillable. +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:508](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L508)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`order` | object | The order structure. | -`signature` | string | Signature provided by maker that proves the order's authenticity. `0x01` can always be provided if the signature does not need to be validated. | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`encoded` | string | - | ABI-encoded revert error. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -**Returns:** *`ContractFunctionObj<[object, BigNumber, boolean]>`* +**Returns:** *`Promise<[number, BigNumber, BigNumber]>`* -The orderInfo (hash, status, and `takerAssetAmount` already filled for the given order), fillableTakerAssetAmount (amount of the order's `takerAssetAmount` that is fillable given all on-chain state), and isValidSignature (validity of the provided signature). NOTE: If the `takerAssetData` encodes data for multiple assets, `fillableTakerAssetAmount` will represent a "scaled" amount, meaning it must be multiplied by all the individual asset amounts within the `takerAssetData` to get the final amount of each asset that can be filled. +orderHash Hash of the order being filled. ___ -### getOrderRelevantStates +### decodeMultiAssetData -▸ **getOrderRelevantStates**(`orders`: `Array`, `signatures`: string[]): *`ContractFunctionObj<[Array, BigNumber[], boolean[]]>`* +#### ▪ **decodeMultiAssetData**: *object* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:3433](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L3433)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:545](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L545)* -Fetches all order-relevant information needed to validate if the supplied orders are fillable. +Decode multi-asset data from the format described in the AssetProxy contract specification. -**Parameters:** +#### callAsync -Name | Type | Description | ------- | ------ | ------ | -`orders` | `Array` | Array of order structures. | -`signatures` | string[] | Array of signatures provided by makers that prove the authenticity of the orders. `0x01` can always be provided if a signature does not need to be validated. | +▸ **callAsync**(`assetData`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise<[string, BigNumber[], string[]]>`* -**Returns:** *`ContractFunctionObj<[Array, BigNumber[], boolean[]]>`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:553](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L553)* -The ordersInfo (array of the hash, status, and `takerAssetAmount` already filled for each order), fillableTakerAssetAmounts (array of amounts for each order's `takerAssetAmount` that is fillable given all on-chain state), and isValidSignature (array containing the validity of each provided signature). NOTE: If the `takerAssetData` encodes data for multiple assets, each element of `fillableTakerAssetAmounts` will represent a "scaled" amount, meaning it must be multiplied by all the individual asset amounts within the `takerAssetData` to get the final amount of each asset that can be filled. +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. -___ +**Parameters:** -### getSelector +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`assetData` | string | - | AssetProxy-compliant data describing a multi-asset basket. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -▸ **getSelector**(`methodName`: string): *string* +**Returns:** *`Promise<[string, BigNumber[], string[]]>`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1504](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1504)* +The Multi-Asset AssetProxy identifier, an array of the amounts of the assets to be traded, and an array of the AssetProxy-compliant data describing each asset to be traded. Each element of the arrays corresponds to the same-indexed element of the other array. -**Parameters:** +___ -Name | Type | ------- | ------ | -`methodName` | string | +### decodeNegativeSpreadError -**Returns:** *string* +#### ▪ **decodeNegativeSpreadError**: *object* -___ +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:590](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L590)* -### getSimulatedOrderTransferResults +Decompose an ABI-encoded NegativeSpreadError. -▸ **getSimulatedOrderTransferResults**(`order`: object, `takerAddress`: string, `takerAssetFillAmount`: `BigNumber`): *`ContractTxFunctionObj`* +#### callAsync -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:3537](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L3537)* +▸ **callAsync**(`encoded`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise<[string, string]>`* -Simulates all of the transfers within an order and returns the index of the first failed transfer. +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:598](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L598)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`order` | object | The order to simulate transfers for. | -`takerAddress` | string | The address of the taker that will fill the order. | -`takerAssetFillAmount` | `BigNumber` | The amount of takerAsset that the taker wished to fill. | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`encoded` | string | - | ABI-encoded revert error. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -**Returns:** *`ContractTxFunctionObj`* +**Returns:** *`Promise<[string, string]>`* -The index of the first failed transfer (or 4 if all transfers are successful). +leftOrderHash Hash of the left order being matched.rightOrderHash Hash of the right order being matched. ___ -### getSimulatedOrdersTransferResults +### decodeOrderEpochError -▸ **getSimulatedOrdersTransferResults**(`orders`: `Array`, `takerAddresses`: string[], `takerAssetFillAmounts`: `BigNumber`[]): *`ContractTxFunctionObj`* +#### ▪ **decodeOrderEpochError**: *object* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:3687](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L3687)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:635](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L635)* -Simulates all of the transfers for each given order and returns the indices of each first failed transfer. +Decompose an ABI-encoded OrderEpochError. -**Parameters:** +#### callAsync -Name | Type | Description | ------- | ------ | ------ | -`orders` | `Array` | Array of orders to individually simulate transfers for. | -`takerAddresses` | string[] | Array of addresses of takers that will fill each order. | -`takerAssetFillAmounts` | `BigNumber`[] | Array of amounts of takerAsset that will be filled for each order. | +▸ **callAsync**(`encoded`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise<[string, string, BigNumber]>`* -**Returns:** *`ContractTxFunctionObj`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:643](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L643)* -The indices of the first failed transfer (or 4 if all transfers are successful) for each order. +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. -___ +**Parameters:** -### getTransferableAssetAmount +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`encoded` | string | - | ABI-encoded revert error. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -▸ **getTransferableAssetAmount**(`ownerAddress`: string, `assetData`: string): *`ContractFunctionObj`* +**Returns:** *`Promise<[string, string, BigNumber]>`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:3835](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L3835)* +makerAddress The order maker.orderSenderAddress The order sender.currentEpoch The current epoch for the maker. -Gets the amount of an asset transferable by the owner. +___ -**Parameters:** +### decodeOrderStatusError -Name | Type | Description | ------- | ------ | ------ | -`ownerAddress` | string | Address of the owner of the asset. | -`assetData` | string | Description of tokens, per the AssetProxy contract specification. | +#### ▪ **decodeOrderStatusError**: *object* -**Returns:** *`ContractFunctionObj`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:680](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L680)* -The amount of the asset tranferable by the owner. NOTE: If the `assetData` encodes data for multiple assets, the `transferableAssetAmount` will represent the amount of times the entire `assetData` can be transferred. To calculate the total individual transferable amounts, this scaled `transferableAmount` must be multiplied by the individual asset amounts located within the `assetData`. +Decompose an ABI-encoded OrderStatusError. -___ +#### callAsync -### revertIfInvalidAssetData +▸ **callAsync**(`encoded`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise<[string, number]>`* -▸ **revertIfInvalidAssetData**(`assetData`: string): *`ContractFunctionObj`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:688](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L688)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:3890](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L3890)* +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | ------- | ------ | -`assetData` | string | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`encoded` | string | - | ABI-encoded revert error. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -**Returns:** *`ContractFunctionObj`* +**Returns:** *`Promise<[string, number]>`* -___ +orderHash The order hash.orderStatus The order status. -### `Static` ABI +___ -▸ **ABI**(): *[ContractAbi](#contractabi)* +### decodeSignatureError -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:125](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L125)* +#### ▪ **decodeSignatureError**: *object* -**Returns:** *[ContractAbi](#contractabi)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:725](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L725)* -The contract ABI +Decompose an ABI-encoded SignatureError. -___ +#### callAsync -### `Static` deployAsync +▸ **callAsync**(`encoded`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise<[number, string, string, string]>`* -▸ **deployAsync**(`bytecode`: string, `abi`: [ContractAbi](#contractabi), `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object, `_exchange`: string): *`Promise`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:733](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L733)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:78](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L78)* +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | ------- | ------ | -`bytecode` | string | -`abi` | [ContractAbi](#contractabi) | -`supportedProvider` | [SupportedProvider](#supportedprovider) | -`txDefaults` | `Partial` | -`logDecodeDependencies` | object | -`_exchange` | string | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`encoded` | string | - | ABI-encoded revert error. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -**Returns:** *`Promise`* +**Returns:** *`Promise<[number, string, string, string]>`* -___ +errorCode The error code.signerAddress The expected signer of the hash.signature The full signature. -### `Static` deployFrom0xArtifactAsync +___ -▸ **deployFrom0xArtifactAsync**(`artifact`: `ContractArtifact` | `SimpleContractArtifact`, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object, `_exchange`: string): *`Promise`* +### decodeSignatureValidatorNotApprovedError -*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:45](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L45)* +#### ▪ **decodeSignatureValidatorNotApprovedError**: *object* -**Parameters:** +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:770](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L770)* -Name | Type | ------- | ------ | -`artifact` | `ContractArtifact` \| `SimpleContractArtifact` | -`supportedProvider` | [SupportedProvider](#supportedprovider) | -`txDefaults` | `Partial` | -`logDecodeDependencies` | object | -`_exchange` | string | +Decompose an ABI-encoded SignatureValidatorNotApprovedError. -**Returns:** *`Promise`* +#### callAsync -___ +▸ **callAsync**(`encoded`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise<[string, string]>`* -### `Static` strictArgumentEncodingCheck +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:778](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L778)* -▸ **strictArgumentEncodingCheck**(`inputAbi`: `DataItem`[], `args`: any[]): *string* +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. +**Parameters:** +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`encoded` | string | - | ABI-encoded revert error. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -Defined in base-contract/lib/src/index.d.ts:42 +**Returns:** *`Promise<[string, string]>`* -**Parameters:** +signerAddress The expected signer of the hash.validatorAddress The expected validator. -Name | Type | ------- | ------ | -`inputAbi` | `DataItem`[] | -`args` | any[] | +___ -**Returns:** *string* +### decodeSignatureWalletError -
+#### ▪ **decodeSignatureWalletError**: *object* -# Class: DummyERC20TokenContract +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:817](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L817)* +Decompose an ABI-encoded SignatureWalletError. -## Constructors +#### callAsync +▸ **callAsync**(`encoded`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise<[string, string, string, string]>`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:825](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L825)* -\+ **new DummyERC20TokenContract**(`address`: string, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults?`: `Partial`, `logDecodeDependencies?`: undefined | object, `deployedBytecode`: string | undefined): *[DummyERC20TokenContract](#class-dummyerc20tokencontract)* +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. -*Overrides void* +**Parameters:** -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:1690](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L1690)* +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`encoded` | string | - | ABI-encoded revert error. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -**Parameters:** +**Returns:** *`Promise<[string, string, string, string]>`* -Name | Type | Default | ------- | ------ | ------ | -`address` | string | - | -`supportedProvider` | [SupportedProvider](#supportedprovider) | - | -`txDefaults?` | `Partial` | - | -`logDecodeDependencies?` | undefined \| object | - | -`deployedBytecode` | string \| undefined | DummyERC20TokenContract.deployedBytecode | +errorCode The error code.signerAddress The expected signer of the hash.signature The full signature bytes.errorData The revert data thrown by the validator contract. -**Returns:** *[DummyERC20TokenContract](#class-dummyerc20tokencontract)* +___ -## Properties +### decodeStaticCallAssetData -### `Optional` _deployedBytecodeIfExists +#### ▪ **decodeStaticCallAssetData**: *object* -• **_deployedBytecodeIfExists**? : *`Buffer`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:862](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L862)* +Decode StaticCall asset data from the format described in the AssetProxy contract specification. +#### callAsync -Defined in base-contract/lib/src/index.d.ts:32 +▸ **callAsync**(`assetData`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise<[string, string, string, string]>`* -___ +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:871](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L871)* -### abi +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. -• **abi**: *[ContractAbi](#contractabi)* +**Parameters:** +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`assetData` | string | - | AssetProxy-compliant asset data describing a StaticCall asset | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | +**Returns:** *`Promise<[string, string, string, string]>`* -Defined in base-contract/lib/src/index.d.ts:28 +The StaticCall AssetProxy identifier, the target address of the StaticCAll, the data to be passed to the target address, and the expected Keccak-256 hash of the static call return data. ___ -### address +### decodeTransactionError -• **address**: *string* +#### ▪ **decodeTransactionError**: *object* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:908](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L908)* +Decompose an ABI-encoded TransactionError. -Defined in base-contract/lib/src/index.d.ts:29 +#### callAsync -___ +▸ **callAsync**(`encoded`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise<[number, string]>`* -Args +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:916](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L916)* -• **constructorArgs**: *any[]* +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. +**Parameters:** +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`encoded` | string | - | ABI-encoded revert error. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -Defined in base-contract/lib/src/index.d.ts:31 +**Returns:** *`Promise<[number, string]>`* -___ +errorCode The error code.transactionHash Hash of the transaction. -### contractName +___ -• **contractName**: *string* +### decodeTransactionExecutionError +#### ▪ **decodeTransactionExecutionError**: *object* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:953](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L953)* -Defined in base-contract/lib/src/index.d.ts:30 +Decompose an ABI-encoded TransactionExecutionError. -## Methods +#### callAsync -### MAX_MINT_AMOUNT +▸ **callAsync**(`encoded`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise<[string, string]>`* -▸ **MAX_MINT_AMOUNT**(): *`ContractFunctionObj`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:961](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L961)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:503](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L503)* +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. -**Returns:** *`ContractFunctionObj`* +**Parameters:** -___ +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`encoded` | string | - | ABI-encoded revert error. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -### allowance +**Returns:** *`Promise<[string, string]>`* -▸ **allowance**(`_owner`: string, `_spender`: string): *`ContractFunctionObj`* +transactionHash Hash of the transaction.errorData Error thrown by exeucteTransaction(). -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:550](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L550)* +___ -**Parameters:** +### decodeZeroExTransactionData -Name | Type | ------- | ------ | -`_owner` | string | -`_spender` | string | +#### ▪ **decodeZeroExTransactionData**: *object* -**Returns:** *`ContractFunctionObj`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:998](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L998)* -___ +Decodes the call data for an Exchange contract method call. -### approve +#### callAsync -▸ **approve**(`_spender`: string, `_value`: `BigNumber`): *`ContractTxFunctionObj`* +▸ **callAsync**(`transactionData`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise<[string, Array, BigNumber[], string[]]>`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:611](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L611)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1007](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1007)* -`msg.sender` approves `_spender` to spend `_value` tokens +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`_spender` | string | The address of the account able to transfer the tokens | -`_value` | `BigNumber` | The amount of wei to be approved for transfer | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`transactionData` | string | - | ABI-encoded calldata for an Exchange contract method call. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -**Returns:** *`ContractTxFunctionObj`* +**Returns:** *`Promise<[string, Array, BigNumber[], string[]]>`* -Always true if the call has enough gas to complete execution +The name of the function called, and the parameters it was given. For single-order fills and cancels, the arrays will have just one element. ___ -### balanceOf - -▸ **balanceOf**(`_owner`: string): *`ContractFunctionObj`* +### encodeERC1155AssetData -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:735](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L735)* +#### ▪ **encodeERC1155AssetData**: *object* -Query the balance of owner +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1088](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1088)* -**Parameters:** +Encode ERC-1155 asset data into the format described in the AssetProxy contract specification. -Name | Type | Description | ------- | ------ | ------ | -`_owner` | string | The address from which the balance will be retrieved | +#### callAsync -**Returns:** *`ContractFunctionObj`* +▸ **callAsync**(`tokenAddress`: string, `tokenIds`: `BigNumber`[], `tokenValues`: `BigNumber`[], `callbackData`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -Balance of owner +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1101](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1101)* -___ +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. -### decimals +**Parameters:** -▸ **decimals**(): *`ContractFunctionObj`* +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`tokenAddress` | string | - | The address of the ERC-1155 contract hosting the asset(s) to be traded. | +`tokenIds` | `BigNumber`[] | - | The identifiers of the specific assets to be traded. | +`tokenValues` | `BigNumber`[] | - | The amounts of each asset to be traded. | +`callbackData` | string | - | Data to be passed to receiving contracts when a transfer is performed. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:785](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L785)* +**Returns:** *`Promise`* -**Returns:** *`ContractFunctionObj`* +AssetProxy-compliant asset data describing the set of assets. ___ -### getABIDecodedReturnData +### encodeERC20AssetData -▸ **getABIDecodedReturnData**<**T**>(`methodName`: string, `callData`: string): *`T`* +#### ▪ **encodeERC20AssetData**: *object* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:489](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L489)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1147](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1147)* -**Type parameters:** +Encode ERC-20 asset data into the format described in the AssetProxy contract specification. -▪ **T** +#### callAsync -**Parameters:** +▸ **callAsync**(`tokenAddress`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -Name | Type | ------- | ------ | -`methodName` | string | -`callData` | string | +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1156](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1156)* -**Returns:** *`T`* +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. -___ +**Parameters:** -### getABIDecodedTransactionData +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`tokenAddress` | string | - | The address of the ERC-20 contract hosting the asset to be traded. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -▸ **getABIDecodedTransactionData**<**T**>(`methodName`: string, `callData`: string): *`T`* +**Returns:** *`Promise`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:482](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L482)* +AssetProxy-compliant data describing the asset. -**Type parameters:** +___ -▪ **T** +### encodeERC721AssetData -**Parameters:** +#### ▪ **encodeERC721AssetData**: *object* -Name | Type | ------- | ------ | -`methodName` | string | -`callData` | string | +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1195](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1195)* -**Returns:** *`T`* +Encode ERC-721 asset data into the format described in the AssetProxy specification. -___ +#### callAsync -### getFunctionSignature +▸ **callAsync**(`tokenAddress`: string, `tokenId`: `BigNumber`, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -▸ **getFunctionSignature**(`methodName`: string): *string* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1205](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1205)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:476](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L476)* +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | ------- | ------ | -`methodName` | string | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`tokenAddress` | string | - | The address of the ERC-721 contract hosting the asset to be traded. | +`tokenId` | `BigNumber` | - | The identifier of the specific asset to be traded. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -**Returns:** *string* +**Returns:** *`Promise`* + +AssetProxy-compliant asset data describing the asset. ___ -### getLogsAsync +### encodeMultiAssetData -▸ **getLogsAsync**<**ArgsType**>(`eventName`: [DummyERC20TokenEvents](#enumeration-dummyerc20tokenevents), `blockRange`: `BlockRange`, `indexFilterValues`: `IndexedFilterValues`): *`Promise>>`* +#### ▪ **encodeMultiAssetData**: *object* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:1674](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L1674)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1247](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1247)* -Gets historical logs without creating a subscription +Encode data for multiple assets, per the AssetProxy contract specification. -**Type parameters:** +#### callAsync -▪ **ArgsType**: *[DummyERC20TokenEventArgs](#dummyerc20tokeneventargs)* +▸ **callAsync**(`amounts`: `BigNumber`[], `nestedAssetData`: string[], `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1257](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1257)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`eventName` | [DummyERC20TokenEvents](#enumeration-dummyerc20tokenevents) | The DummyERC20Token contract event you would like to subscribe to. | -`blockRange` | `BlockRange` | Block range to get logs from. | -`indexFilterValues` | `IndexedFilterValues` | An object where the keys are indexed args returned by the event and the value is the value you are interested in. E.g `{_from: aUserAddressHex}` | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`amounts` | `BigNumber`[] | - | The amounts of each asset to be traded. | +`nestedAssetData` | string[] | - | AssetProxy-compliant data describing each asset to be traded. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -**Returns:** *`Promise>>`* +**Returns:** *`Promise`* -Array of logs that match the parameters +AssetProxy-compliant data describing the set of assets. ___ -### getSelector +### encodeStaticCallAssetData + +#### ▪ **encodeStaticCallAssetData**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1299](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1299)* + +Encode StaticCall asset data into the format described in the AssetProxy contract specification. + +#### callAsync + +▸ **callAsync**(`staticCallTargetAddress`: string, `staticCallData`: string, `expectedReturnDataHash`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -▸ **getSelector**(`methodName`: string): *string* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1311](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1311)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:496](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L496)* +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | ------- | ------ | -`methodName` | string | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`staticCallTargetAddress` | string | - | Target address of StaticCall. | +`staticCallData` | string | - | Data that will be passed to staticCallTargetAddress in the StaticCall. | +`expectedReturnDataHash` | string | - | Expected Keccak-256 hash of the StaticCall return data. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -**Returns:** *string* +**Returns:** *`Promise`* + +AssetProxy-compliant asset data describing the set of assets. ___ -### mint +### getAssetProxyAllowance -▸ **mint**(`_value`: `BigNumber`): *`ContractTxFunctionObj`* +#### ▪ **getAssetProxyAllowance**: *object* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:836](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L836)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1356](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1356)* -Mints new tokens for sender +Returns the number of asset(s) (described by assetData) that the corresponding AssetProxy contract is authorized to spend. When the asset data contains multiple assets (eg for Multi-Asset), the return value indicates how many complete "baskets" of those assets may be spent by all of the corresponding AssetProxy contracts. -**Parameters:** +#### callAsync -Name | Type | Description | ------- | ------ | ------ | -`_value` | `BigNumber` | Amount of tokens to mint | +▸ **callAsync**(`ownerAddress`: string, `assetData`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -**Returns:** *`ContractTxFunctionObj`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1366](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1366)* -___ +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. -### name +**Parameters:** -▸ **name**(): *`ContractFunctionObj`* +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`ownerAddress` | string | - | Owner of the assets specified by assetData. | +`assetData` | string | - | Details of asset, encoded per the AssetProxy contract specification. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:942](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L942)* +**Returns:** *`Promise`* -**Returns:** *`ContractFunctionObj`* +Number of assets (or asset baskets) that the corresponding AssetProxy is authorized to spend. ___ -### owner +### getBalance -▸ **owner**(): *`ContractFunctionObj`* +#### ▪ **getBalance**: *object* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:989](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L989)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1416](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1416)* -**Returns:** *`ContractFunctionObj`* +Returns the owner's balance of the assets(s) specified in assetData. When the asset data contains multiple assets (eg in ERC1155 or Multi-Asset), the return value indicates how many complete "baskets" of those assets are owned by owner. -___ +#### callAsync -### setBalance +▸ **callAsync**(`ownerAddress`: string, `assetData`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -▸ **setBalance**(`_target`: string, `_value`: `BigNumber`): *`ContractTxFunctionObj`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1426](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1426)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:1041](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L1041)* - -Sets the balance of target address +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`_target` | string | Address or which balance will be updated | -`_value` | `BigNumber` | New balance of target address | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`ownerAddress` | string | - | Owner of the assets specified by assetData. | +`assetData` | string | - | Details of asset, encoded per the AssetProxy contract specification. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* -**Returns:** *`ContractTxFunctionObj`* +Number of assets (or asset baskets) held by owner. ___ -### subscribe +### getBalanceAndAssetProxyAllowance -▸ **subscribe**<**ArgsType**>(`eventName`: [DummyERC20TokenEvents](#enumeration-dummyerc20tokenevents), `indexFilterValues`: `IndexedFilterValues`, `callback`: [EventCallback](#eventcallback)‹*`ArgsType`*›, `isVerbose`: boolean, `blockPollingIntervalMs?`: undefined | number): *string* +#### ▪ **getBalanceAndAssetProxyAllowance**: *object* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:1632](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L1632)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1476](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1476)* -Subscribe to an event type emitted by the DummyERC20Token contract. +Calls getBalance() and getAllowance() for assetData. -**Type parameters:** +#### callAsync -▪ **ArgsType**: *[DummyERC20TokenEventArgs](#dummyerc20tokeneventargs)* +▸ **callAsync**(`ownerAddress`: string, `assetData`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise<[BigNumber, BigNumber]>`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1486](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1486)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** Name | Type | Default | Description | ------ | ------ | ------ | ------ | -`eventName` | [DummyERC20TokenEvents](#enumeration-dummyerc20tokenevents) | - | The DummyERC20Token contract event you would like to subscribe to. | -`indexFilterValues` | `IndexedFilterValues` | - | An object where the keys are indexed args returned by the event and the value is the value you are interested in. E.g `{maker: aUserAddressHex}` | -`callback` | [EventCallback](#eventcallback)‹*`ArgsType`*› | - | Callback that gets called when a log is added/removed | -`isVerbose` | boolean | false | Enable verbose subscription warnings (e.g recoverable network issues encountered) | -`blockPollingIntervalMs?` | undefined \| number | - | - | +`ownerAddress` | string | - | Owner of the assets specified by assetData. | +`assetData` | string | - | Details of asset, encoded per the AssetProxy contract specification. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -**Returns:** *string* +**Returns:** *`Promise<[BigNumber, BigNumber]>`* -Subscription token used later to unsubscribe +Number of assets (or asset baskets) held by owner, and number of assets (or asset baskets) that the corresponding AssetProxy is authorized to spend. ___ -### symbol +### getBatchAssetProxyAllowances -▸ **symbol**(): *`ContractFunctionObj`* +#### ▪ **getBatchAssetProxyAllowances**: *object* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:1160](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L1160)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1536](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1536)* -**Returns:** *`ContractFunctionObj`* +Calls getAssetProxyAllowance() for each element of assetData. -___ +#### callAsync -### totalSupply +▸ **callAsync**(`ownerAddress`: string, `assetData`: string[], `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -▸ **totalSupply**(): *`ContractFunctionObj`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1546](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1546)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:1211](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L1211)* +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. -Query total supply of token +**Parameters:** -**Returns:** *`ContractFunctionObj`* +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`ownerAddress` | string | - | Owner of the assets specified by assetData. | +`assetData` | string[] | - | Array of asset details, each encoded per the AssetProxy contract specification. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -Total supply of token +**Returns:** *`Promise`* + +An array of asset allowances from getAllowance(), with each element corresponding to the same-indexed element in the assetData input. ___ -### transfer +### getBatchBalances -▸ **transfer**(`_to`: string, `_value`: `BigNumber`): *`ContractTxFunctionObj`* +#### ▪ **getBatchBalances**: *object* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:1264](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L1264)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1596](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1596)* -send `value` token to `to` from `msg.sender` +Calls getBalance() for each element of assetData. -**Parameters:** +#### callAsync -Name | Type | Description | ------- | ------ | ------ | -`_to` | string | The address of the recipient | -`_value` | `BigNumber` | The amount of token to be transferred | +▸ **callAsync**(`ownerAddress`: string, `assetData`: string[], `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -**Returns:** *`ContractTxFunctionObj`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1606](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1606)* -True if transfer was successful +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. -___ +**Parameters:** -### transferFrom +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`ownerAddress` | string | - | Owner of the assets specified by assetData. | +`assetData` | string[] | - | Array of asset details, each encoded per the AssetProxy contract specification. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -▸ **transferFrom**(`_from`: string, `_to`: string, `_value`: `BigNumber`): *`ContractTxFunctionObj`* +**Returns:** *`Promise`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:1390](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L1390)* +Array of asset balances from getBalance(), with each element corresponding to the same-indexed element in the assetData input. -ERC20 transferFrom, modified such that an allowance of MAX_UINT represents an unlimited allowance. See https://github.com/ethereum/EIPs/issues/717 +___ -**Parameters:** +### getBatchBalancesAndAssetProxyAllowances -Name | Type | Description | ------- | ------ | ------ | -`_from` | string | Address to transfer from. | -`_to` | string | Address to transfer to. | -`_value` | `BigNumber` | Amount to transfer. | +#### ▪ **getBatchBalancesAndAssetProxyAllowances**: *object* -**Returns:** *`ContractTxFunctionObj`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1656](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1656)* -Success of transfer. +Calls getBatchBalances() and getBatchAllowances() for each element of assetData. -___ +#### callAsync -### transferOwnership +▸ **callAsync**(`ownerAddress`: string, `assetData`: string[], `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise<[BigNumber[], BigNumber[]]>`* -▸ **transferOwnership**(`newOwner`: string): *`ContractTxFunctionObj`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1666](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1666)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:1514](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L1514)* +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | ------- | ------ | -`newOwner` | string | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`ownerAddress` | string | - | Owner of the assets specified by assetData. | +`assetData` | string[] | - | Array of asset details, each encoded per the AssetProxy contract specification. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -**Returns:** *`ContractTxFunctionObj`* +**Returns:** *`Promise<[BigNumber[], BigNumber[]]>`* + +An array of asset balances from getBalance(), and an array of asset allowances from getAllowance(), with each element corresponding to the same-indexed element in the assetData input. ___ -### unsubscribe +### getEthBalances -▸ **unsubscribe**(`subscriptionToken`: string): *void* +#### ▪ **getEthBalances**: *object* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:1657](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L1657)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1716](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1716)* -Cancel a subscription +Batch fetches ETH balances + +#### callAsync + +▸ **callAsync**(`addresses`: string[], `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1724](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1724)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`subscriptionToken` | string | Subscription token returned by `subscribe()` | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`addresses` | string[] | - | Array of addresses. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -**Returns:** *void* +**Returns:** *`Promise`* + +Array of ETH balances. ___ -### unsubscribeAll +### getOrderRelevantState -▸ **unsubscribeAll**(): *void* +#### ▪ **getOrderRelevantState**: *object* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:1663](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L1663)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1769](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1769)* -Cancels all existing subscriptions +Fetches all order-relevant information needed to validate if the supplied order is fillable. -**Returns:** *void* +#### callAsync -___ +▸ **callAsync**(`order`: object, `signature`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise<[object, BigNumber, boolean]>`* -### `Static` ABI +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1780](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1780)* -▸ **ABI**(): *[ContractAbi](#contractabi)* +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:155](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L155)* +**Parameters:** -**Returns:** *[ContractAbi](#contractabi)* +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`order` | object | - | The order structure. | +`signature` | string | - | Signature provided by maker that proves the order's authenticity. `0x01` can always be provided if the signature does not need to be validated. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -The contract ABI +**Returns:** *`Promise<[object, BigNumber, boolean]>`* + +The orderInfo (hash, status, and `takerAssetAmount` already filled for the given order), fillableTakerAssetAmount (amount of the order's `takerAssetAmount` that is fillable given all on-chain state), and isValidSignature (validity of the provided signature). NOTE: If the `takerAssetData` encodes data for multiple assets, `fillableTakerAssetAmount` will represent a "scaled" amount, meaning it must be multiplied by all the individual asset amounts within the `takerAssetData` to get the final amount of each asset that can be filled. ___ -### `Static` deployAsync +### getOrderRelevantStates -▸ **deployAsync**(`bytecode`: string, `abi`: [ContractAbi](#contractabi), `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object, `_name`: string, `_symbol`: string, `_decimals`: `BigNumber`, `_totalSupply`: `BigNumber`): *`Promise`* +#### ▪ **getOrderRelevantStates**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1850](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1850)* + +Fetches all order-relevant information needed to validate if the supplied orders are fillable. + +#### callAsync + +▸ **callAsync**(`orders`: `Array`, `signatures`: string[], `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise<[Array, BigNumber[], boolean[]]>`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1861](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1861)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:105](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L105)* +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | ------- | ------ | -`bytecode` | string | -`abi` | [ContractAbi](#contractabi) | -`supportedProvider` | [SupportedProvider](#supportedprovider) | -`txDefaults` | `Partial` | -`logDecodeDependencies` | object | -`_name` | string | -`_symbol` | string | -`_decimals` | `BigNumber` | -`_totalSupply` | `BigNumber` | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`orders` | `Array` | - | Array of order structures. | +`signatures` | string[] | - | Array of signatures provided by makers that prove the authenticity of the orders. `0x01` can always be provided if a signature does not need to be validated. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -**Returns:** *`Promise`* +**Returns:** *`Promise<[Array, BigNumber[], boolean[]]>`* + +The ordersInfo (array of the hash, status, and `takerAssetAmount` already filled for each order), fillableTakerAssetAmounts (array of amounts for each order's `takerAssetAmount` that is fillable given all on-chain state), and isValidSignature (array containing the validity of each provided signature). NOTE: If the `takerAssetData` encodes data for multiple assets, each element of `fillableTakerAssetAmounts` will represent a "scaled" amount, meaning it must be multiplied by all the individual asset amounts within the `takerAssetData` to get the final amount of each asset that can be filled. ___ -### `Static` deployFrom0xArtifactAsync +### getSimulatedOrderTransferResults -▸ **deployFrom0xArtifactAsync**(`artifact`: `ContractArtifact` | `SimpleContractArtifact`, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object, `_name`: string, `_symbol`: string, `_decimals`: `BigNumber`, `_totalSupply`: `BigNumber`): *`Promise`* +#### ▪ **getSimulatedOrderTransferResults**: *object* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:66](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L66)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1940](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1940)* -**Parameters:** +Simulates all of the transfers within an order and returns the index of the first failed transfer. -Name | Type | ------- | ------ | -`artifact` | `ContractArtifact` \| `SimpleContractArtifact` | -`supportedProvider` | [SupportedProvider](#supportedprovider) | -`txDefaults` | `Partial` | -`logDecodeDependencies` | object | -`_name` | string | -`_symbol` | string | -`_decimals` | `BigNumber` | -`_totalSupply` | `BigNumber` | +#### awaitTransactionSuccessAsync -**Returns:** *`Promise`* +▸ **awaitTransactionSuccessAsync**(`order`: object, `takerAddress`: string, `takerAssetFillAmount`: `BigNumber`, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* -___ +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2015](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2015)* -### `Static` strictArgumentEncodingCheck +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. -▸ **strictArgumentEncodingCheck**(`inputAbi`: `DataItem`[], `args`: any[]): *string* +**Parameters:** +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`order` | object | - | The order to simulate transfers for. | +`takerAddress` | string | - | The address of the taker that will fill the order. | +`takerAssetFillAmount` | `BigNumber` | - | The amount of takerAsset that the taker wished to fill. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | +**Returns:** *`PromiseWithTransactionHash`* -Defined in base-contract/lib/src/index.d.ts:42 +A promise that resolves when the transaction is successful -**Parameters:** +#### callAsync -Name | Type | ------- | ------ | -`inputAbi` | `DataItem`[] | -`args` | any[] | +▸ **callAsync**(`order`: object, `takerAddress`: string, `takerAssetFillAmount`: `BigNumber`, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -**Returns:** *string* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2121](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2121)* -
+Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. -# Class: DummyERC721TokenContract +**Parameters:** +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`order` | object | - | The order to simulate transfers for. | +`takerAddress` | string | - | The address of the taker that will fill the order. | +`takerAssetFillAmount` | `BigNumber` | - | The amount of takerAsset that the taker wished to fill. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -## Constructors +**Returns:** *`Promise`* +The index of the first failed transfer (or 4 if all transfers are successful). +#### estimateGasAsync -\+ **new DummyERC721TokenContract**(`address`: string, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults?`: `Partial`, `logDecodeDependencies?`: undefined | object, `deployedBytecode`: string | undefined): *[DummyERC721TokenContract](#class-dummyerc721tokencontract)* +▸ **estimateGasAsync**(`order`: object, `takerAddress`: string, `takerAssetFillAmount`: `BigNumber`, `txData?`: `Partial` | undefined): *`Promise`* -*Overrides void* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2068](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2068)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:1990](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L1990)* +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. **Parameters:** -Name | Type | Default | +Name | Type | Description | ------ | ------ | ------ | -`address` | string | - | -`supportedProvider` | [SupportedProvider](#supportedprovider) | - | -`txDefaults?` | `Partial` | - | -`logDecodeDependencies?` | undefined \| object | - | -`deployedBytecode` | string \| undefined | DummyERC721TokenContract.deployedBytecode | +`order` | object | The order to simulate transfers for. | +`takerAddress` | string | The address of the taker that will fill the order. | +`takerAssetFillAmount` | `BigNumber` | The amount of takerAsset that the taker wished to fill. | +`txData?` | `Partial` \| undefined | Additional data for transaction | -**Returns:** *[DummyERC721TokenContract](#class-dummyerc721tokencontract)* +**Returns:** *`Promise`* -## Properties +The hash of the transaction -### `Optional` _deployedBytecodeIfExists +#### getABIEncodedTransactionData -• **_deployedBytecodeIfExists**? : *`Buffer`* +▸ **getABIEncodedTransactionData**(`order`: object, `takerAddress`: string, `takerAssetFillAmount`: `BigNumber`): *string* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2195](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2195)* +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). -Defined in base-contract/lib/src/index.d.ts:32 +**Parameters:** -___ +Name | Type | Description | +------ | ------ | ------ | +`order` | object | The order to simulate transfers for. | +`takerAddress` | string | The address of the taker that will fill the order. | +`takerAssetFillAmount` | `BigNumber` | The amount of takerAsset that the taker wished to fill. | -### abi +**Returns:** *string* -• **abi**: *[ContractAbi](#contractabi)* +The ABI encoded transaction data as a string +#### getSelector +▸ **getSelector**(): *string* -Defined in base-contract/lib/src/index.d.ts:28 +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2227](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2227)* -___ +Returns the 4 byte function selector as a hex string. -### address +**Returns:** *string* -• **address**: *string* +#### sendTransactionAsync +▸ **sendTransactionAsync**(`order`: object, `takerAddress`: string, `takerAssetFillAmount`: `BigNumber`, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:1951](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L1951)* -Defined in base-contract/lib/src/index.d.ts:29 +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`order` | object | - | The order to simulate transfers for. | +`takerAddress` | string | - | The address of the taker that will fill the order. | +`takerAssetFillAmount` | `BigNumber` | - | The amount of takerAsset that the taker wished to fill. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction ___ -Args +### getSimulatedOrdersTransferResults -• **constructorArgs**: *any[]* +#### ▪ **getSimulatedOrdersTransferResults**: *object* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2238](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2238)* +Simulates all of the transfers for each given order and returns the indices of each first failed transfer. -Defined in base-contract/lib/src/index.d.ts:31 +#### awaitTransactionSuccessAsync -___ +▸ **awaitTransactionSuccessAsync**(`orders`: `Array`, `takerAddresses`: string[], `takerAssetFillAmounts`: `BigNumber`[], `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* -### contractName +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2316](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2316)* -• **contractName**: *string* +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. +**Parameters:** +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`orders` | `Array` | - | Array of orders to individually simulate transfers for. | +`takerAddresses` | string[] | - | Array of addresses of takers that will fill each order. | +`takerAssetFillAmounts` | `BigNumber`[] | - | Array of amounts of takerAsset that will be filled for each order. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | -Defined in base-contract/lib/src/index.d.ts:30 +**Returns:** *`PromiseWithTransactionHash`* -## Methods +A promise that resolves when the transaction is successful -### approve +#### callAsync -▸ **approve**(`_approved`: string, `_tokenId`: `BigNumber`): *`ContractTxFunctionObj`* +▸ **callAsync**(`orders`: `Array`, `takerAddresses`: string[], `takerAssetFillAmounts`: `BigNumber`[], `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:562](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L562)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2426](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2426)* -The zero address indicates there is no approved address. -Throws unless `msg.sender` is the current NFT owner, or an authorized -operator of the current owner. +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`_approved` | string | The new approved NFT controller | -`_tokenId` | `BigNumber` | The NFT to approve | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`orders` | `Array` | - | Array of orders to individually simulate transfers for. | +`takerAddresses` | string[] | - | Array of addresses of takers that will fill each order. | +`takerAssetFillAmounts` | `BigNumber`[] | - | Array of amounts of takerAsset that will be filled for each order. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -**Returns:** *`ContractTxFunctionObj`* +**Returns:** *`Promise`* -___ +The indices of the first failed transfer (or 4 if all transfers are successful) for each order. -### balanceOf +#### estimateGasAsync -▸ **balanceOf**(`_owner`: string): *`ContractFunctionObj`* +▸ **estimateGasAsync**(`orders`: `Array`, `takerAddresses`: string[], `takerAssetFillAmounts`: `BigNumber`[], `txData?`: `Partial` | undefined): *`Promise`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:687](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L687)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2371](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2371)* -NFTs assigned to the zero address are considered invalid, and this -function throws for queries about the zero address. +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. **Parameters:** Name | Type | Description | ------ | ------ | ------ | -`_owner` | string | An address for whom to query the balance | - -**Returns:** *`ContractFunctionObj`* +`orders` | `Array` | Array of orders to individually simulate transfers for. | +`takerAddresses` | string[] | Array of addresses of takers that will fill each order. | +`takerAssetFillAmounts` | `BigNumber`[] | Array of amounts of takerAsset that will be filled for each order. | +`txData?` | `Partial` \| undefined | Additional data for transaction | -The number of NFTs owned by `_owner`, possibly zero +**Returns:** *`Promise`* -___ +The hash of the transaction -### burn +#### getABIEncodedTransactionData -▸ **burn**(`_owner`: string, `_tokenId`: `BigNumber`): *`ContractTxFunctionObj`* +▸ **getABIEncodedTransactionData**(`orders`: `Array`, `takerAddresses`: string[], `takerAssetFillAmounts`: `BigNumber`[]): *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:743](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L743)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2502](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2502)* -Function to burn a token -Reverts if the given token ID doesn't exist or not called by contract owner +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). **Parameters:** Name | Type | Description | ------ | ------ | ------ | -`_owner` | string | Owner of token with given token ID | -`_tokenId` | `BigNumber` | ID of the token to be burned by the msg.sender | +`orders` | `Array` | Array of orders to individually simulate transfers for. | +`takerAddresses` | string[] | Array of addresses of takers that will fill each order. | +`takerAssetFillAmounts` | `BigNumber`[] | Array of amounts of takerAsset that will be filled for each order. | -**Returns:** *`ContractTxFunctionObj`* +**Returns:** *string* -___ +The ABI encoded transaction data as a string -### getABIDecodedReturnData +#### getSelector -▸ **getABIDecodedReturnData**<**T**>(`methodName`: string, `callData`: string): *`T`* +▸ **getSelector**(): *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:541](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L541)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2535](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2535)* -**Type parameters:** +Returns the 4 byte function selector as a hex string. -▪ **T** +**Returns:** *string* -**Parameters:** +#### sendTransactionAsync -Name | Type | ------- | ------ | -`methodName` | string | -`callData` | string | +▸ **sendTransactionAsync**(`orders`: `Array`, `takerAddresses`: string[], `takerAssetFillAmounts`: `BigNumber`[], `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* -**Returns:** *`T`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2250](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2250)* -___ +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. -### getABIDecodedTransactionData +**Parameters:** -▸ **getABIDecodedTransactionData**<**T**>(`methodName`: string, `callData`: string): *`T`* +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`orders` | `Array` | - | Array of orders to individually simulate transfers for. | +`takerAddresses` | string[] | - | Array of addresses of takers that will fill each order. | +`takerAssetFillAmounts` | `BigNumber`[] | - | Array of amounts of takerAsset that will be filled for each order. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:534](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L534)* +**Returns:** *`Promise`* -**Type parameters:** +The hash of the transaction -▪ **T** +___ -**Parameters:** +### getTransferableAssetAmount -Name | Type | ------- | ------ | -`methodName` | string | -`callData` | string | +#### ▪ **getTransferableAssetAmount**: *object* -**Returns:** *`T`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2546](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2546)* -___ +Gets the amount of an asset transferable by the owner. -### getApproved +#### callAsync -▸ **getApproved**(`_tokenId`: `BigNumber`): *`ContractFunctionObj`* +▸ **callAsync**(`ownerAddress`: string, `assetData`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:867](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L867)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2556](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2556)* -Throws if `_tokenId` is not a valid NFT. +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`_tokenId` | `BigNumber` | The NFT to find the approved address for | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`ownerAddress` | string | - | Address of the owner of the asset. | +`assetData` | string | - | Description of tokens, per the AssetProxy contract specification. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -**Returns:** *`ContractFunctionObj`* +**Returns:** *`Promise`* -The approved address for this NFT, or the zero address if there is none +The amount of the asset tranferable by the owner. NOTE: If the `assetData` encodes data for multiple assets, the `transferableAssetAmount` will represent the amount of times the entire `assetData` can be transferred. To calculate the total individual transferable amounts, this scaled `transferableAmount` must be multiplied by the individual asset amounts located within the `assetData`. ___ -### getFunctionSignature - -▸ **getFunctionSignature**(`methodName`: string): *string* - -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:528](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L528)* - -**Parameters:** - -Name | Type | ------- | ------ | -`methodName` | string | - -**Returns:** *string* - -___ +### revertIfInvalidAssetData -### getLogsAsync +#### ▪ **revertIfInvalidAssetData**: *object* -▸ **getLogsAsync**<**ArgsType**>(`eventName`: [DummyERC721TokenEvents](#enumeration-dummyerc721tokenevents), `blockRange`: `BlockRange`, `indexFilterValues`: `IndexedFilterValues`): *`Promise>>`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2603](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2603)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:1974](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L1974)* +#### callAsync -Gets historical logs without creating a subscription +▸ **callAsync**(`assetData`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -**Type parameters:** +*Defined in [abi-gen-wrappers/src/generated-wrappers/dev_utils.ts:2609](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts#L2609)* -▪ **ArgsType**: *[DummyERC721TokenEventArgs](#dummyerc721tokeneventargs)* +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | Description | +Name | Type | Default | ------ | ------ | ------ | -`eventName` | [DummyERC721TokenEvents](#enumeration-dummyerc721tokenevents) | The DummyERC721Token contract event you would like to subscribe to. | -`blockRange` | `BlockRange` | Block range to get logs from. | -`indexFilterValues` | `IndexedFilterValues` | An object where the keys are indexed args returned by the event and the value is the value you are interested in. E.g `{_from: aUserAddressHex}` | - -**Returns:** *`Promise>>`* +`assetData` | string | - | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | -Array of logs that match the parameters - -___ - -### getSelector +**Returns:** *`Promise`* -▸ **getSelector**(`methodName`: string): *string* +
-*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:548](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L548)* +# Class: DummyERC20TokenContract -**Parameters:** -Name | Type | ------- | ------ | -`methodName` | string | +## Constructors -**Returns:** *string* -___ -### isApprovedForAll +\+ **new DummyERC20TokenContract**(`address`: string, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults?`: `Partial`, `logDecodeDependencies?`: undefined | object, `deployedBytecode`: string | undefined): *[DummyERC20TokenContract](#class-dummyerc20tokencontract)* -▸ **isApprovedForAll**(`_owner`: string, `_operator`: string): *`ContractFunctionObj`* +*Overrides void* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:915](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L915)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:1985](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L1985)* **Parameters:** -Name | Type | ------- | ------ | -`_owner` | string | -`_operator` | string | - -**Returns:** *`ContractFunctionObj`* - -___ +Name | Type | Default | +------ | ------ | ------ | +`address` | string | - | +`supportedProvider` | [SupportedProvider](#supportedprovider) | - | +`txDefaults?` | `Partial` | - | +`logDecodeDependencies?` | undefined \| object | - | +`deployedBytecode` | string \| undefined | DummyERC20TokenContract.deployedBytecode | -### mint +**Returns:** *[DummyERC20TokenContract](#class-dummyerc20tokencontract)* -▸ **mint**(`_to`: string, `_tokenId`: `BigNumber`): *`ContractTxFunctionObj`* +## Properties -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:976](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L976)* +#### `Optional` _deployedBytecodeIfExists -Function to mint a new token -Reverts if the given token ID already exists +• **_deployedBytecodeIfExists**? : *`Buffer`* -**Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`_to` | string | Address of the beneficiary that will own the minted token | -`_tokenId` | `BigNumber` | ID of the token to be minted by the msg.sender | -**Returns:** *`ContractTxFunctionObj`* +Defined in base-contract/lib/src/index.d.ts:31 ___ -### name - -▸ **name**(): *`ContractFunctionObj`* - -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:1086](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L1086)* - -**Returns:** *`ContractFunctionObj`* - -___ +### abi -### owner +• **abi**: *[ContractAbi](#contractabi)* -▸ **owner**(): *`ContractFunctionObj`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:1133](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L1133)* -**Returns:** *`ContractFunctionObj`* +Defined in base-contract/lib/src/index.d.ts:27 ___ -### ownerOf - -▸ **ownerOf**(`_tokenId`: `BigNumber`): *`ContractFunctionObj`* - -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:1186](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L1186)* - -NFTs assigned to zero address are considered invalid, and queries -about them do throw. +### address -**Parameters:** +• **address**: *string* -Name | Type | Description | ------- | ------ | ------ | -`_tokenId` | `BigNumber` | The identifier for an NFT | -**Returns:** *`ContractFunctionObj`* -The address of the owner of the NFT +Defined in base-contract/lib/src/index.d.ts:28 ___ -### safeTransferFrom1 - -▸ **safeTransferFrom1**(`_from`: string, `_to`: string, `_tokenId`: `BigNumber`): *`ContractTxFunctionObj`* - -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:1241](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L1241)* +Args -This works identically to the other function with an extra data parameter, -except this function just sets data to "". +• **constructorArgs**: *any[]* -**Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`_from` | string | The current owner of the NFT | -`_to` | string | The new owner | -`_tokenId` | `BigNumber` | The NFT to transfer | -**Returns:** *`ContractTxFunctionObj`* +Defined in base-contract/lib/src/index.d.ts:30 ___ -### safeTransferFrom2 +### contractName -▸ **safeTransferFrom2**(`_from`: string, `_to`: string, `_tokenId`: `BigNumber`, `_data`: string): *`ContractTxFunctionObj`* +• **contractName**: *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:1377](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L1377)* -Throws unless `msg.sender` is the current owner, an authorized -operator, or the approved address for this NFT. Throws if `_from` is -not the current owner. Throws if `_to` is the zero address. Throws if -`_tokenId` is not a valid NFT. When transfer is complete, this function -checks if `_to` is a smart contract (code size > 0). If so, it calls -`onERC721Received` on `_to` and throws if the return value is not -`bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`. -**Parameters:** +Defined in base-contract/lib/src/index.d.ts:29 -Name | Type | Description | ------- | ------ | ------ | -`_from` | string | The current owner of the NFT | -`_to` | string | The new owner | -`_tokenId` | `BigNumber` | The NFT to transfer | -`_data` | string | Additional data with no specified format, sent in call to `_to` | +## Methods -**Returns:** *`ContractTxFunctionObj`* +### getLogsAsync -___ +▸ **getLogsAsync**<**ArgsType**>(`eventName`: [DummyERC20TokenEvents](#enumeration-dummyerc20tokenevents), `blockRange`: `BlockRange`, `indexFilterValues`: `IndexedFilterValues`): *`Promise>>`* -### setApprovalForAll +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:1969](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L1969)* -▸ **setApprovalForAll**(`_operator`: string, `_approved`: boolean): *`ContractTxFunctionObj`* +Gets historical logs without creating a subscription -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:1515](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L1515)* +**Type parameters:** -Emits the ApprovalForAll event. The contract MUST allow -multiple operators per owner. +▪ **ArgsType**: *[DummyERC20TokenEventArgs](#dummyerc20tokeneventargs)* **Parameters:** Name | Type | Description | ------ | ------ | ------ | -`_operator` | string | Address to add to the set of authorized operators | -`_approved` | boolean | True if the operator is approved, false to revoke approval | +`eventName` | [DummyERC20TokenEvents](#enumeration-dummyerc20tokenevents) | The DummyERC20Token contract event you would like to subscribe to. | +`blockRange` | `BlockRange` | Block range to get logs from. | +`indexFilterValues` | `IndexedFilterValues` | An object where the keys are indexed args returned by the event and the value is the value you are interested in. E.g `{_from: aUserAddressHex}` | + +**Returns:** *`Promise>>`* -**Returns:** *`ContractTxFunctionObj`* +Array of logs that match the parameters ___ ### subscribe -▸ **subscribe**<**ArgsType**>(`eventName`: [DummyERC721TokenEvents](#enumeration-dummyerc721tokenevents), `indexFilterValues`: `IndexedFilterValues`, `callback`: [EventCallback](#eventcallback)‹*`ArgsType`*›, `isVerbose`: boolean, `blockPollingIntervalMs?`: undefined | number): *string* +▸ **subscribe**<**ArgsType**>(`eventName`: [DummyERC20TokenEvents](#enumeration-dummyerc20tokenevents), `indexFilterValues`: `IndexedFilterValues`, `callback`: [EventCallback](#eventcallback)‹*`ArgsType`*›, `isVerbose`: boolean, `blockPollingIntervalMs?`: undefined | number): *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:1932](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L1932)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:1927](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L1927)* -Subscribe to an event type emitted by the DummyERC721Token contract. +Subscribe to an event type emitted by the DummyERC20Token contract. **Type parameters:** -▪ **ArgsType**: *[DummyERC721TokenEventArgs](#dummyerc721tokeneventargs)* +▪ **ArgsType**: *[DummyERC20TokenEventArgs](#dummyerc20tokeneventargs)* **Parameters:** Name | Type | Default | Description | ------ | ------ | ------ | ------ | -`eventName` | [DummyERC721TokenEvents](#enumeration-dummyerc721tokenevents) | - | The DummyERC721Token contract event you would like to subscribe to. | +`eventName` | [DummyERC20TokenEvents](#enumeration-dummyerc20tokenevents) | - | The DummyERC20Token contract event you would like to subscribe to. | `indexFilterValues` | `IndexedFilterValues` | - | An object where the keys are indexed args returned by the event and the value is the value you are interested in. E.g `{maker: aUserAddressHex}` | `callback` | [EventCallback](#eventcallback)‹*`ArgsType`*› | - | Callback that gets called when a log is added/removed | `isVerbose` | boolean | false | Enable verbose subscription warnings (e.g recoverable network issues encountered) | @@ -2344,60 +2660,11 @@ Subscription token used later to unsubscribe ___ -### symbol - -▸ **symbol**(): *`ContractFunctionObj`* - -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:1634](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L1634)* - -**Returns:** *`ContractFunctionObj`* - -___ - -### transferFrom - -▸ **transferFrom**(`_from`: string, `_to`: string, `_tokenId`: `BigNumber`): *`ContractTxFunctionObj`* - -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:1690](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L1690)* - -Throws unless `msg.sender` is the current owner, an authorized -operator, or the approved address for this NFT. Throws if `_from` is -not the current owner. Throws if `_to` is the zero address. Throws if -`_tokenId` is not a valid NFT. - -**Parameters:** - -Name | Type | Description | ------- | ------ | ------ | -`_from` | string | The current owner of the NFT | -`_to` | string | The new owner | -`_tokenId` | `BigNumber` | The NFT to transfer | - -**Returns:** *`ContractTxFunctionObj`* - -___ - -### transferOwnership - -▸ **transferOwnership**(`newOwner`: string): *`ContractTxFunctionObj`* - -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:1814](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L1814)* - -**Parameters:** - -Name | Type | ------- | ------ | -`newOwner` | string | - -**Returns:** *`ContractTxFunctionObj`* - -___ - ### unsubscribe ▸ **unsubscribe**(`subscriptionToken`: string): *void* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:1957](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L1957)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:1952](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L1952)* Cancel a subscription @@ -2415,7 +2682,7 @@ ___ ▸ **unsubscribeAll**(): *void* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:1963](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L1963)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:1958](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L1958)* Cancels all existing subscriptions @@ -2427,7 +2694,7 @@ ___ ▸ **ABI**(): *[ContractAbi](#contractabi)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:159](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L159)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:1598](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L1598)* **Returns:** *[ContractAbi](#contractabi)* @@ -2437,9 +2704,9 @@ ___ ### `Static` deployAsync -▸ **deployAsync**(`bytecode`: string, `abi`: [ContractAbi](#contractabi), `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object, `_name`: string, `_symbol`: string): *`Promise`* +▸ **deployAsync**(`bytecode`: string, `abi`: [ContractAbi](#contractabi), `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object, `_name`: string, `_symbol`: string, `_decimals`: `BigNumber`, `_totalSupply`: `BigNumber`): *`Promise`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:111](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L111)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:1548](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L1548)* **Parameters:** @@ -2452,16 +2719,18 @@ Name | Type | `logDecodeDependencies` | object | `_name` | string | `_symbol` | string | +`_decimals` | `BigNumber` | +`_totalSupply` | `BigNumber` | -**Returns:** *`Promise`* +**Returns:** *`Promise`* ___ ### `Static` deployFrom0xArtifactAsync -▸ **deployFrom0xArtifactAsync**(`artifact`: `ContractArtifact` | `SimpleContractArtifact`, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object, `_name`: string, `_symbol`: string): *`Promise`* +▸ **deployFrom0xArtifactAsync**(`artifact`: `ContractArtifact` | `SimpleContractArtifact`, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object, `_name`: string, `_symbol`: string, `_decimals`: `BigNumber`, `_totalSupply`: `BigNumber`): *`Promise`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:76](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L76)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:1509](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L1509)* **Parameters:** @@ -2473,8 +2742,10 @@ Name | Type | `logDecodeDependencies` | object | `_name` | string | `_symbol` | string | +`_decimals` | `BigNumber` | +`_totalSupply` | `BigNumber` | -**Returns:** *`Promise`* +**Returns:** *`Promise`* ___ @@ -2484,7 +2755,7 @@ ___ -Defined in base-contract/lib/src/index.d.ts:42 +Defined in base-contract/lib/src/index.d.ts:41 **Parameters:** @@ -2495,109 +2766,126 @@ Name | Type | **Returns:** *string* -
- -# Class: ERC20TokenContract +## Object literals +### MAX_MINT_AMOUNT -## Constructors +#### ▪ **MAX_MINT_AMOUNT**: *object* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:61](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L61)* +#### callAsync -\+ **new ERC20TokenContract**(`address`: string, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults?`: `Partial`, `logDecodeDependencies?`: undefined | object, `deployedBytecode`: string | undefined): *[ERC20TokenContract](#class-erc20tokencontract)* +▸ **callAsync**(`callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -*Overrides void* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:67](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L67)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:951](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L951)* +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** Name | Type | Default | ------ | ------ | ------ | -`address` | string | - | -`supportedProvider` | [SupportedProvider](#supportedprovider) | - | -`txDefaults?` | `Partial` | - | -`logDecodeDependencies?` | undefined \| object | - | -`deployedBytecode` | string \| undefined | ERC20TokenContract.deployedBytecode | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | -**Returns:** *[ERC20TokenContract](#class-erc20tokencontract)* +**Returns:** *`Promise`* -## Properties +___ -### `Optional` _deployedBytecodeIfExists +### allowance -• **_deployedBytecodeIfExists**? : *`Buffer`* +#### ▪ **allowance**: *object* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:104](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L104)* +#### callAsync -Defined in base-contract/lib/src/index.d.ts:32 +▸ **callAsync**(`_owner`: string, `_spender`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -___ +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:113](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L113)* -### abi +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. -• **abi**: *[ContractAbi](#contractabi)* +**Parameters:** +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_owner` | string | - | The address of the account owning tokens | +`_spender` | string | - | The address of the account able to transfer the tokens | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | +**Returns:** *`Promise`* -Defined in base-contract/lib/src/index.d.ts:28 +Amount of remaining tokens allowed to spent ___ -### address +### approve -• **address**: *string* +#### ▪ **approve**: *object* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:163](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L163)* +`msg.sender` approves `_spender` to spend `_value` tokens -Defined in base-contract/lib/src/index.d.ts:29 +#### awaitTransactionSuccessAsync -___ +▸ **awaitTransactionSuccessAsync**(`_spender`: string, `_value`: `BigNumber`, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* -Args +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:213](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L213)* -• **constructorArgs**: *any[]* +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. +**Parameters:** +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_spender` | string | - | The address of the account able to transfer the tokens | +`_value` | `BigNumber` | - | The amount of wei to be approved for transfer | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | -Defined in base-contract/lib/src/index.d.ts:31 +**Returns:** *`PromiseWithTransactionHash`* -___ +A promise that resolves when the transaction is successful -### contractName +#### callAsync -• **contractName**: *string* +▸ **callAsync**(`_spender`: string, `_value`: `BigNumber`, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:277](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L277)* - -Defined in base-contract/lib/src/index.d.ts:30 - -## Methods - -### allowance - -▸ **allowance**(`_owner`: string, `_spender`: string): *`ContractFunctionObj`* - -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:828](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L828)* +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | ------- | ------ | -`_owner` | string | -`_spender` | string | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_spender` | string | - | The address of the account able to transfer the tokens | +`_value` | `BigNumber` | - | The amount of wei to be approved for transfer | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -**Returns:** *`ContractFunctionObj`* +**Returns:** *`Promise`* -___ +Always true if the call has enough gas to complete execution -### approve +#### estimateGasAsync -▸ **approve**(`_spender`: string, `_value`: `BigNumber`): *`ContractTxFunctionObj`* +▸ **estimateGasAsync**(`_spender`: string, `_value`: `BigNumber`, `txData?`: `Partial` | undefined): *`Promise`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:347](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L347)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:242](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L242)* -`msg.sender` approves `_spender` to spend `_value` tokens +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. **Parameters:** @@ -2605,826 +2893,877 @@ Name | Type | Description | ------ | ------ | ------ | `_spender` | string | The address of the account able to transfer the tokens | `_value` | `BigNumber` | The amount of wei to be approved for transfer | +`txData?` | `Partial` \| undefined | Additional data for transaction | -**Returns:** *`ContractTxFunctionObj`* - -Always true if the call has enough gas to complete execution +**Returns:** *`Promise`* -___ +The hash of the transaction -### balanceOf +#### getABIEncodedTransactionData -▸ **balanceOf**(`_owner`: string): *`ContractFunctionObj`* +▸ **getABIEncodedTransactionData**(`_spender`: string, `_value`: `BigNumber`): *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:653](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L653)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:331](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L331)* -Query the balance of owner +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). **Parameters:** Name | Type | Description | ------ | ------ | ------ | -`_owner` | string | The address from which the balance will be retrieved | +`_spender` | string | The address of the account able to transfer the tokens | +`_value` | `BigNumber` | The amount of wei to be approved for transfer | -**Returns:** *`ContractFunctionObj`* +**Returns:** *string* -Balance of owner +The ABI encoded transaction data as a string -___ +#### getSelector -### getABIDecodedReturnData +▸ **getSelector**(): *string* -▸ **getABIDecodedReturnData**<**T**>(`methodName`: string, `callData`: string): *`T`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:344](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L344)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:327](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L327)* +Returns the 4 byte function selector as a hex string. -**Type parameters:** +**Returns:** *string* -▪ **T** +#### sendTransactionAsync -**Parameters:** +▸ **sendTransactionAsync**(`_spender`: string, `_value`: `BigNumber`, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* -Name | Type | ------- | ------ | -`methodName` | string | -`callData` | string | +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:172](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L172)* -**Returns:** *`T`* +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. -___ +**Parameters:** -### getABIDecodedTransactionData +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_spender` | string | - | The address of the account able to transfer the tokens | +`_value` | `BigNumber` | - | The amount of wei to be approved for transfer | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | -▸ **getABIDecodedTransactionData**<**T**>(`methodName`: string, `callData`: string): *`T`* +**Returns:** *`Promise`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:320](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L320)* +The hash of the transaction -**Type parameters:** +___ -▪ **T** +### balanceOf -**Parameters:** +#### ▪ **balanceOf**: *object* -Name | Type | ------- | ------ | -`methodName` | string | -`callData` | string | +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:353](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L353)* -**Returns:** *`T`* +Query the balance of owner -___ +#### callAsync -### getFunctionSignature +▸ **callAsync**(`_owner`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -▸ **getFunctionSignature**(`methodName`: string): *string* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:361](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L361)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:314](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L314)* +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | ------- | ------ | -`methodName` | string | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_owner` | string | - | The address from which the balance will be retrieved | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -**Returns:** *string* +**Returns:** *`Promise`* + +Balance of owner ___ -### getLogsAsync +### decimals -▸ **getLogsAsync**<**ArgsType**>(`eventName`: [ERC20TokenEvents](#enumeration-erc20tokenevents), `blockRange`: `BlockRange`, `indexFilterValues`: `IndexedFilterValues`): *`Promise>>`* +#### ▪ **decimals**: *object* -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:935](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L935)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:403](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L403)* -Gets historical logs without creating a subscription +#### callAsync -**Type parameters:** +▸ **callAsync**(`callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -▪ **ArgsType**: *[ERC20TokenEventArgs](#erc20tokeneventargs)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:409](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L409)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | Description | +Name | Type | Default | ------ | ------ | ------ | -`eventName` | [ERC20TokenEvents](#enumeration-erc20tokenevents) | The ERC20Token contract event you would like to subscribe to. | -`blockRange` | `BlockRange` | Block range to get logs from. | -`indexFilterValues` | `IndexedFilterValues` | An object where the keys are indexed args returned by the event and the value is the value you are interested in. E.g `{_from: aUserAddressHex}` | - -**Returns:** *`Promise>>`* +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | -Array of logs that match the parameters +**Returns:** *`Promise`* ___ -### getSelector - -▸ **getSelector**(`methodName`: string): *string* - -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:334](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L334)* - -**Parameters:** - -Name | Type | ------- | ------ | -`methodName` | string | - -**Returns:** *string* +### mint -___ +#### ▪ **mint**: *object* -### subscribe +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:449](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L449)* -▸ **subscribe**<**ArgsType**>(`eventName`: [ERC20TokenEvents](#enumeration-erc20tokenevents), `indexFilterValues`: `IndexedFilterValues`, `callback`: [EventCallback](#eventcallback)‹*`ArgsType`*›, `isVerbose`: boolean, `blockPollingIntervalMs?`: undefined | number): *string* +Mints new tokens for sender -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:893](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L893)* +#### awaitTransactionSuccessAsync -Subscribe to an event type emitted by the ERC20Token contract. +▸ **awaitTransactionSuccessAsync**(`_value`: `BigNumber`, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* -**Type parameters:** +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:492](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L492)* -▪ **ArgsType**: *[ERC20TokenEventArgs](#erc20tokeneventargs)* +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. **Parameters:** Name | Type | Default | Description | ------ | ------ | ------ | ------ | -`eventName` | [ERC20TokenEvents](#enumeration-erc20tokenevents) | - | The ERC20Token contract event you would like to subscribe to. | -`indexFilterValues` | `IndexedFilterValues` | - | An object where the keys are indexed args returned by the event and the value is the value you are interested in. E.g `{maker: aUserAddressHex}` | -`callback` | [EventCallback](#eventcallback)‹*`ArgsType`*› | - | Callback that gets called when a log is added/removed | -`isVerbose` | boolean | false | Enable verbose subscription warnings (e.g recoverable network issues encountered) | -`blockPollingIntervalMs?` | undefined \| number | - | - | - -**Returns:** *string* +`_value` | `BigNumber` | - | Amount of tokens to mint | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | -Subscription token used later to unsubscribe +**Returns:** *`PromiseWithTransactionHash`* -___ +A promise that resolves when the transaction is successful -### totalSupply +#### callAsync -▸ **totalSupply**(): *`ContractFunctionObj`* +▸ **callAsync**(`_value`: `BigNumber`, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:470](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L470)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:543](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L543)* -Query total supply of token +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. -**Returns:** *`ContractFunctionObj`* +**Parameters:** -Total supply of token +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_value` | `BigNumber` | - | Amount of tokens to mint | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -___ +**Returns:** *`Promise`* -### transfer +#### estimateGasAsync -▸ **transfer**(`_to`: string, `_value`: `BigNumber`): *`ContractTxFunctionObj`* +▸ **estimateGasAsync**(`_value`: `BigNumber`, `txData?`: `Partial` | undefined): *`Promise`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:709](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L709)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:518](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L518)* -send `value` token to `to` from `msg.sender` +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. **Parameters:** Name | Type | Description | ------ | ------ | ------ | -`_to` | string | The address of the recipient | -`_value` | `BigNumber` | The amount of token to be transferred | - -**Returns:** *`ContractTxFunctionObj`* +`_value` | `BigNumber` | Amount of tokens to mint | +`txData?` | `Partial` \| undefined | Additional data for transaction | -True if transfer was successful +**Returns:** *`Promise`* -___ +The hash of the transaction -### transferFrom +#### getABIEncodedTransactionData -▸ **transferFrom**(`_from`: string, `_to`: string, `_value`: `BigNumber`): *`ContractTxFunctionObj`* +▸ **getABIEncodedTransactionData**(`_value`: `BigNumber`): *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:524](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L524)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:587](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L587)* -send `value` token to `to` from `from` on the condition it is approved by `from` +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). **Parameters:** Name | Type | Description | ------ | ------ | ------ | -`_from` | string | The address of the sender | -`_to` | string | The address of the recipient | -`_value` | `BigNumber` | The amount of token to be transferred | +`_value` | `BigNumber` | Amount of tokens to mint | -**Returns:** *`ContractTxFunctionObj`* - -True if transfer was successful +**Returns:** *string* -___ +The ABI encoded transaction data as a string -### unsubscribe +#### getSelector -▸ **unsubscribe**(`subscriptionToken`: string): *void* +▸ **getSelector**(): *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:918](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L918)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:596](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L596)* -Cancel a subscription +Returns the 4 byte function selector as a hex string. -**Parameters:** +**Returns:** *string* -Name | Type | Description | ------- | ------ | ------ | -`subscriptionToken` | string | Subscription token returned by `subscribe()` | +#### sendTransactionAsync -**Returns:** *void* +▸ **sendTransactionAsync**(`_value`: `BigNumber`, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* -___ +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:457](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L457)* -### unsubscribeAll +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. -▸ **unsubscribeAll**(): *void* +**Parameters:** -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:924](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L924)* +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_value` | `BigNumber` | - | Amount of tokens to mint | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | -Cancels all existing subscriptions +**Returns:** *`Promise`* -**Returns:** *void* +The hash of the transaction ___ -### `Static` ABI - -▸ **ABI**(): *[ContractAbi](#contractabi)* - -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:133](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L133)* +### name -**Returns:** *[ContractAbi](#contractabi)* +#### ▪ **name**: *object* -The contract ABI +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:602](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L602)* -___ +#### callAsync -### `Static` deployAsync +▸ **callAsync**(`callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -▸ **deployAsync**(`bytecode`: string, `abi`: [ContractAbi](#contractabi), `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object): *`Promise`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:608](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L608)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:91](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L91)* +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | ------- | ------ | -`bytecode` | string | -`abi` | [ContractAbi](#contractabi) | -`supportedProvider` | [SupportedProvider](#supportedprovider) | -`txDefaults` | `Partial` | -`logDecodeDependencies` | object | +Name | Type | Default | +------ | ------ | ------ | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | -**Returns:** *`Promise`* +**Returns:** *`Promise`* ___ -### `Static` deployFrom0xArtifactAsync +### owner -▸ **deployFrom0xArtifactAsync**(`artifact`: `ContractArtifact` | `SimpleContractArtifact`, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object): *`Promise`* +#### ▪ **owner**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:645](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L645)* + +#### callAsync -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:66](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L66)* +▸ **callAsync**(`callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:651](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L651)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | ------- | ------ | -`artifact` | `ContractArtifact` \| `SimpleContractArtifact` | -`supportedProvider` | [SupportedProvider](#supportedprovider) | -`txDefaults` | `Partial` | -`logDecodeDependencies` | object | +Name | Type | Default | +------ | ------ | ------ | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | -**Returns:** *`Promise`* +**Returns:** *`Promise`* ___ -### `Static` strictArgumentEncodingCheck - -▸ **strictArgumentEncodingCheck**(`inputAbi`: `DataItem`[], `args`: any[]): *string* +### setBalance +#### ▪ **setBalance**: *object* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:691](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L691)* -Defined in base-contract/lib/src/index.d.ts:42 +Sets the balance of target address -**Parameters:** +#### awaitTransactionSuccessAsync -Name | Type | ------- | ------ | -`inputAbi` | `DataItem`[] | -`args` | any[] | +▸ **awaitTransactionSuccessAsync**(`_target`: string, `_value`: `BigNumber`, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* -**Returns:** *string* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:741](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L741)* -
+Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. -# Class: ERC721TokenContract +**Parameters:** +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_target` | string | - | Address or which balance will be updated | +`_value` | `BigNumber` | - | New balance of target address | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | -## Constructors +**Returns:** *`PromiseWithTransactionHash`* +A promise that resolves when the transaction is successful +#### callAsync -\+ **new ERC721TokenContract**(`address`: string, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults?`: `Partial`, `logDecodeDependencies?`: undefined | object, `deployedBytecode`: string | undefined): *[ERC721TokenContract](#class-erc721tokencontract)* +▸ **callAsync**(`_target`: string, `_value`: `BigNumber`, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -*Overrides void* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:804](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L804)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:1376](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L1376)* +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | Default | ------- | ------ | ------ | -`address` | string | - | -`supportedProvider` | [SupportedProvider](#supportedprovider) | - | -`txDefaults?` | `Partial` | - | -`logDecodeDependencies?` | undefined \| object | - | -`deployedBytecode` | string \| undefined | ERC721TokenContract.deployedBytecode | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_target` | string | - | Address or which balance will be updated | +`_value` | `BigNumber` | - | New balance of target address | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -**Returns:** *[ERC721TokenContract](#class-erc721tokencontract)* +**Returns:** *`Promise`* -## Properties +#### estimateGasAsync -### `Optional` _deployedBytecodeIfExists +▸ **estimateGasAsync**(`_target`: string, `_value`: `BigNumber`, `txData?`: `Partial` | undefined): *`Promise`* -• **_deployedBytecodeIfExists**? : *`Buffer`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:770](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L770)* +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. +**Parameters:** -Defined in base-contract/lib/src/index.d.ts:32 +Name | Type | Description | +------ | ------ | ------ | +`_target` | string | Address or which balance will be updated | +`_value` | `BigNumber` | New balance of target address | +`txData?` | `Partial` \| undefined | Additional data for transaction | -___ +**Returns:** *`Promise`* -### abi +The hash of the transaction -• **abi**: *[ContractAbi](#contractabi)* +#### getABIEncodedTransactionData +▸ **getABIEncodedTransactionData**(`_target`: string, `_value`: `BigNumber`): *string* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:858](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L858)* -Defined in base-contract/lib/src/index.d.ts:28 +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). -___ +**Parameters:** -### address +Name | Type | Description | +------ | ------ | ------ | +`_target` | string | Address or which balance will be updated | +`_value` | `BigNumber` | New balance of target address | -• **address**: *string* +**Returns:** *string* +The ABI encoded transaction data as a string +#### getSelector -Defined in base-contract/lib/src/index.d.ts:29 +▸ **getSelector**(): *string* -___ +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:871](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L871)* -Args +Returns the 4 byte function selector as a hex string. -• **constructorArgs**: *any[]* +**Returns:** *string* +#### sendTransactionAsync +▸ **sendTransactionAsync**(`_target`: string, `_value`: `BigNumber`, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* -Defined in base-contract/lib/src/index.d.ts:31 +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:700](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L700)* -___ +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. -### contractName +**Parameters:** -• **contractName**: *string* +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_target` | string | - | Address or which balance will be updated | +`_value` | `BigNumber` | - | New balance of target address | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* +The hash of the transaction +___ -Defined in base-contract/lib/src/index.d.ts:30 +### symbol -## Methods +#### ▪ **symbol**: *object* -### approve +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:877](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L877)* -▸ **approve**(`_approved`: string, `_tokenId`: `BigNumber`): *`ContractTxFunctionObj`* +#### callAsync -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:438](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L438)* +▸ **callAsync**(`callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -The zero address indicates there is no approved address. -Throws unless `msg.sender` is the current NFT owner, or an authorized -operator of the current owner. +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:883](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L883)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | Description | +Name | Type | Default | ------ | ------ | ------ | -`_approved` | string | The new approved NFT controller | -`_tokenId` | `BigNumber` | The NFT to approve | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | -**Returns:** *`ContractTxFunctionObj`* +**Returns:** *`Promise`* ___ -### balanceOf +### totalSupply -▸ **balanceOf**(`_owner`: string): *`ContractFunctionObj`* +#### ▪ **totalSupply**: *object* -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:563](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L563)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:923](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L923)* -NFTs assigned to the zero address are considered invalid, and this -function throws for queries about the zero address. +Query total supply of token + +#### callAsync + +▸ **callAsync**(`callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:930](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L930)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | Description | +Name | Type | Default | ------ | ------ | ------ | -`_owner` | string | An address for whom to query the balance | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | -**Returns:** *`ContractFunctionObj`* +**Returns:** *`Promise`* -The number of NFTs owned by `_owner`, possibly zero +Total supply of token ___ -### getABIDecodedReturnData +### transfer -▸ **getABIDecodedReturnData**<**T**>(`methodName`: string, `callData`: string): *`T`* +#### ▪ **transfer**: *object* -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:417](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L417)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:970](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L970)* -**Type parameters:** +send `value` token to `to` from `msg.sender` -▪ **T** +#### awaitTransactionSuccessAsync -**Parameters:** +▸ **awaitTransactionSuccessAsync**(`_to`: string, `_value`: `BigNumber`, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* -Name | Type | ------- | ------ | -`methodName` | string | -`callData` | string | +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:1017](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L1017)* -**Returns:** *`T`* +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. -___ +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_to` | string | - | The address of the recipient | +`_value` | `BigNumber` | - | The amount of token to be transferred | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | -### getABIDecodedTransactionData +**Returns:** *`PromiseWithTransactionHash`* -▸ **getABIDecodedTransactionData**<**T**>(`methodName`: string, `callData`: string): *`T`* +A promise that resolves when the transaction is successful -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:410](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L410)* +#### callAsync -**Type parameters:** +▸ **callAsync**(`_to`: string, `_value`: `BigNumber`, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -▪ **T** +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:1074](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L1074)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | ------- | ------ | -`methodName` | string | -`callData` | string | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_to` | string | - | The address of the recipient | +`_value` | `BigNumber` | - | The amount of token to be transferred | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -**Returns:** *`T`* +**Returns:** *`Promise`* -___ +True if transfer was successful -### getApproved +#### estimateGasAsync -▸ **getApproved**(`_tokenId`: `BigNumber`): *`ContractFunctionObj`* +▸ **estimateGasAsync**(`_to`: string, `_value`: `BigNumber`, `txData?`: `Partial` | undefined): *`Promise`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:618](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L618)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:1046](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L1046)* -Throws if `_tokenId` is not a valid NFT. +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. **Parameters:** Name | Type | Description | ------ | ------ | ------ | -`_tokenId` | `BigNumber` | The NFT to find the approved address for | +`_to` | string | The address of the recipient | +`_value` | `BigNumber` | The amount of token to be transferred | +`txData?` | `Partial` \| undefined | Additional data for transaction | -**Returns:** *`ContractFunctionObj`* +**Returns:** *`Promise`* -The approved address for this NFT, or the zero address if there is none +The hash of the transaction -___ +#### getABIEncodedTransactionData -### getFunctionSignature +▸ **getABIEncodedTransactionData**(`_to`: string, `_value`: `BigNumber`): *string* -▸ **getFunctionSignature**(`methodName`: string): *string* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:1125](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L1125)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:404](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L404)* +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). **Parameters:** -Name | Type | ------- | ------ | -`methodName` | string | +Name | Type | Description | +------ | ------ | ------ | +`_to` | string | The address of the recipient | +`_value` | `BigNumber` | The amount of token to be transferred | **Returns:** *string* -___ +The ABI encoded transaction data as a string -### getLogsAsync +#### getSelector -▸ **getLogsAsync**<**ArgsType**>(`eventName`: [ERC721TokenEvents](#enumeration-erc721tokenevents), `blockRange`: `BlockRange`, `indexFilterValues`: `IndexedFilterValues`): *`Promise>>`* +▸ **getSelector**(): *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:1360](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L1360)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:1138](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L1138)* -Gets historical logs without creating a subscription +Returns the 4 byte function selector as a hex string. -**Type parameters:** +**Returns:** *string* -▪ **ArgsType**: *[ERC721TokenEventArgs](#erc721tokeneventargs)* +#### sendTransactionAsync -**Parameters:** +▸ **sendTransactionAsync**(`_to`: string, `_value`: `BigNumber`, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* -Name | Type | Description | ------- | ------ | ------ | -`eventName` | [ERC721TokenEvents](#enumeration-erc721tokenevents) | The ERC721Token contract event you would like to subscribe to. | -`blockRange` | `BlockRange` | Block range to get logs from. | -`indexFilterValues` | `IndexedFilterValues` | An object where the keys are indexed args returned by the event and the value is the value you are interested in. E.g `{_from: aUserAddressHex}` | +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:979](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L979)* -**Returns:** *`Promise>>`* +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. -Array of logs that match the parameters +**Parameters:** -___ +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_to` | string | - | The address of the recipient | +`_value` | `BigNumber` | - | The amount of token to be transferred | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* -### getSelector +The hash of the transaction -▸ **getSelector**(`methodName`: string): *string* +___ -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:424](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L424)* +### transferFrom -**Parameters:** +#### ▪ **transferFrom**: *object* -Name | Type | ------- | ------ | -`methodName` | string | +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:1147](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L1147)* -**Returns:** *string* +ERC20 transferFrom, modified such that an allowance of MAX_UINT represents an unlimited allowance. See https://github.com/ethereum/EIPs/issues/717 -___ +#### awaitTransactionSuccessAsync -### isApprovedForAll +▸ **awaitTransactionSuccessAsync**(`_from`: string, `_to`: string, `_value`: `BigNumber`, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* -▸ **isApprovedForAll**(`_owner`: string, `_operator`: string): *`ContractFunctionObj`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:1202](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L1202)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:666](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L666)* +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. **Parameters:** -Name | Type | ------- | ------ | -`_owner` | string | -`_operator` | string | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_from` | string | - | Address to transfer from. | +`_to` | string | - | Address to transfer to. | +`_value` | `BigNumber` | - | Amount to transfer. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | -**Returns:** *`ContractFunctionObj`* +**Returns:** *`PromiseWithTransactionHash`* -___ +A promise that resolves when the transaction is successful -### ownerOf +#### callAsync -▸ **ownerOf**(`_tokenId`: `BigNumber`): *`ContractFunctionObj`* +▸ **callAsync**(`_from`: string, `_to`: string, `_value`: `BigNumber`, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:727](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L727)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:1279](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L1279)* -NFTs assigned to zero address are considered invalid, and queries -about them do throw. +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`_tokenId` | `BigNumber` | The identifier for an NFT | - -**Returns:** *`ContractFunctionObj`* +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_from` | string | - | Address to transfer from. | +`_to` | string | - | Address to transfer to. | +`_value` | `BigNumber` | - | Amount to transfer. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -The address of the owner of the NFT +**Returns:** *`Promise`* -___ +Success of transfer. -### safeTransferFrom1 +#### estimateGasAsync -▸ **safeTransferFrom1**(`_from`: string, `_to`: string, `_tokenId`: `BigNumber`): *`ContractTxFunctionObj`* +▸ **estimateGasAsync**(`_from`: string, `_to`: string, `_value`: `BigNumber`, `txData?`: `Partial` | undefined): *`Promise`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:782](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L782)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:1240](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L1240)* -This works identically to the other function with an extra data parameter, -except this function just sets data to "". +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. **Parameters:** Name | Type | Description | ------ | ------ | ------ | -`_from` | string | The current owner of the NFT | -`_to` | string | The new owner | -`_tokenId` | `BigNumber` | The NFT to transfer | +`_from` | string | Address to transfer from. | +`_to` | string | Address to transfer to. | +`_value` | `BigNumber` | Amount to transfer. | +`txData?` | `Partial` \| undefined | Additional data for transaction | -**Returns:** *`ContractTxFunctionObj`* +**Returns:** *`Promise`* -___ +The hash of the transaction -### safeTransferFrom2 +#### getABIEncodedTransactionData -▸ **safeTransferFrom2**(`_from`: string, `_to`: string, `_tokenId`: `BigNumber`, `_data`: string): *`ContractTxFunctionObj`* +▸ **getABIEncodedTransactionData**(`_from`: string, `_to`: string, `_value`: `BigNumber`): *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:918](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L918)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:1337](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L1337)* -Throws unless `msg.sender` is the current owner, an authorized -operator, or the approved address for this NFT. Throws if `_from` is -not the current owner. Throws if `_to` is the zero address. Throws if -`_tokenId` is not a valid NFT. When transfer is complete, this function -checks if `_to` is a smart contract (code size > 0). If so, it calls -`onERC721Received` on `_to` and throws if the return value is not -`bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`. +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). **Parameters:** Name | Type | Description | ------ | ------ | ------ | -`_from` | string | The current owner of the NFT | -`_to` | string | The new owner | -`_tokenId` | `BigNumber` | The NFT to transfer | -`_data` | string | Additional data with no specified format, sent in call to `_to` | - -**Returns:** *`ContractTxFunctionObj`* - -___ - -### setApprovalForAll - -▸ **setApprovalForAll**(`_operator`: string, `_approved`: boolean): *`ContractTxFunctionObj`* - -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:1056](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L1056)* +`_from` | string | Address to transfer from. | +`_to` | string | Address to transfer to. | +`_value` | `BigNumber` | Amount to transfer. | -Emits the ApprovalForAll event. The contract MUST allow -multiple operators per owner. +**Returns:** *string* -**Parameters:** +The ABI encoded transaction data as a string -Name | Type | Description | ------- | ------ | ------ | -`_operator` | string | Address to add to the set of authorized operators | -`_approved` | boolean | True if the operator is approved, false to revoke approval | +#### getSelector -**Returns:** *`ContractTxFunctionObj`* +▸ **getSelector**(): *string* -___ +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:1352](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L1352)* -### subscribe +Returns the 4 byte function selector as a hex string. -▸ **subscribe**<**ArgsType**>(`eventName`: [ERC721TokenEvents](#enumeration-erc721tokenevents), `indexFilterValues`: `IndexedFilterValues`, `callback`: [EventCallback](#eventcallback)‹*`ArgsType`*›, `isVerbose`: boolean, `blockPollingIntervalMs?`: undefined | number): *string* +**Returns:** *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:1318](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L1318)* +#### sendTransactionAsync -Subscribe to an event type emitted by the ERC721Token contract. +▸ **sendTransactionAsync**(`_from`: string, `_to`: string, `_value`: `BigNumber`, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* -**Type parameters:** +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:1157](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L1157)* -▪ **ArgsType**: *[ERC721TokenEventArgs](#erc721tokeneventargs)* +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. **Parameters:** Name | Type | Default | Description | ------ | ------ | ------ | ------ | -`eventName` | [ERC721TokenEvents](#enumeration-erc721tokenevents) | - | The ERC721Token contract event you would like to subscribe to. | -`indexFilterValues` | `IndexedFilterValues` | - | An object where the keys are indexed args returned by the event and the value is the value you are interested in. E.g `{maker: aUserAddressHex}` | -`callback` | [EventCallback](#eventcallback)‹*`ArgsType`*› | - | Callback that gets called when a log is added/removed | -`isVerbose` | boolean | false | Enable verbose subscription warnings (e.g recoverable network issues encountered) | -`blockPollingIntervalMs?` | undefined \| number | - | - | +`_from` | string | - | Address to transfer from. | +`_to` | string | - | Address to transfer to. | +`_value` | `BigNumber` | - | Amount to transfer. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | -**Returns:** *string* +**Returns:** *`Promise`* -Subscription token used later to unsubscribe +The hash of the transaction ___ -### transferFrom - -▸ **transferFrom**(`_from`: string, `_to`: string, `_tokenId`: `BigNumber`): *`ContractTxFunctionObj`* +### transferOwnership -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:1184](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L1184)* +#### ▪ **transferOwnership**: *object* -Throws unless `msg.sender` is the current owner, an authorized -operator, or the approved address for this NFT. Throws if `_from` is -not the current owner. Throws if `_to` is the zero address. Throws if -`_tokenId` is not a valid NFT. +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:1358](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L1358)* -**Parameters:** +#### awaitTransactionSuccessAsync -Name | Type | Description | ------- | ------ | ------ | -`_from` | string | The current owner of the NFT | -`_to` | string | The new owner | -`_tokenId` | `BigNumber` | The NFT to transfer | +▸ **awaitTransactionSuccessAsync**(`newOwner`: string, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* -**Returns:** *`ContractTxFunctionObj`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:1399](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L1399)* -___ +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. -### unsubscribe +**Parameters:** -▸ **unsubscribe**(`subscriptionToken`: string): *void* +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`newOwner` | string | - | - | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:1343](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L1343)* +**Returns:** *`PromiseWithTransactionHash`* -Cancel a subscription +A promise that resolves when the transaction is successful -**Parameters:** +#### callAsync -Name | Type | Description | ------- | ------ | ------ | -`subscriptionToken` | string | Subscription token returned by `subscribe()` | +▸ **callAsync**(`newOwner`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -**Returns:** *void* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:1448](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L1448)* -___ +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. -### unsubscribeAll +**Parameters:** -▸ **unsubscribeAll**(): *void* +Name | Type | Default | +------ | ------ | ------ | +`newOwner` | string | - | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:1349](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L1349)* +**Returns:** *`Promise`* -Cancels all existing subscriptions +#### estimateGasAsync -**Returns:** *void* +▸ **estimateGasAsync**(`newOwner`: string, `txData?`: `Partial` | undefined): *`Promise`* -___ +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:1424](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L1424)* -### `Static` ABI +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. -▸ **ABI**(): *[ContractAbi](#contractabi)* +**Parameters:** -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:143](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L143)* +Name | Type | Description | +------ | ------ | ------ | +`newOwner` | string | - | +`txData?` | `Partial` \| undefined | Additional data for transaction | -**Returns:** *[ContractAbi](#contractabi)* +**Returns:** *`Promise`* -The contract ABI +The hash of the transaction -___ +#### getABIEncodedTransactionData -### `Static` deployAsync +▸ **getABIEncodedTransactionData**(`newOwner`: string): *string* -▸ **deployAsync**(`bytecode`: string, `abi`: [ContractAbi](#contractabi), `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object): *`Promise`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:1491](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L1491)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:101](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L101)* +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). **Parameters:** Name | Type | ------ | ------ | -`bytecode` | string | -`abi` | [ContractAbi](#contractabi) | -`supportedProvider` | [SupportedProvider](#supportedprovider) | -`txDefaults` | `Partial` | -`logDecodeDependencies` | object | - -**Returns:** *`Promise`* - -___ - -### `Static` deployFrom0xArtifactAsync +`newOwner` | string | -▸ **deployFrom0xArtifactAsync**(`artifact`: `ContractArtifact` | `SimpleContractArtifact`, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object): *`Promise`* +**Returns:** *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:76](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L76)* +The ABI encoded transaction data as a string -**Parameters:** +#### getSelector -Name | Type | ------- | ------ | -`artifact` | `ContractArtifact` \| `SimpleContractArtifact` | -`supportedProvider` | [SupportedProvider](#supportedprovider) | -`txDefaults` | `Partial` | -`logDecodeDependencies` | object | +▸ **getSelector**(): *string* -**Returns:** *`Promise`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:1502](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L1502)* -___ +Returns the 4 byte function selector as a hex string. -### `Static` strictArgumentEncodingCheck +**Returns:** *string* -▸ **strictArgumentEncodingCheck**(`inputAbi`: `DataItem`[], `args`: any[]): *string* +#### sendTransactionAsync +▸ **sendTransactionAsync**(`newOwner`: string, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:1365](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L1365)* -Defined in base-contract/lib/src/index.d.ts:42 +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. **Parameters:** -Name | Type | ------- | ------ | -`inputAbi` | `DataItem`[] | -`args` | any[] | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`newOwner` | string | - | - | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | -**Returns:** *string* +**Returns:** *`Promise`* + +The hash of the transaction
-# Class: ExchangeContract +# Class: DummyERC721TokenContract ## Constructors -\+ **new ExchangeContract**(`address`: string, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults?`: `Partial`, `logDecodeDependencies?`: undefined | object, `deployedBytecode`: string | undefined): *[ExchangeContract](#class-exchangecontract)* +\+ **new DummyERC721TokenContract**(`address`: string, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults?`: `Partial`, `logDecodeDependencies?`: undefined | object, `deployedBytecode`: string | undefined): *[DummyERC721TokenContract](#class-dummyerc721tokencontract)* *Overrides void* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:8066](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L8066)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:2500](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L2500)* **Parameters:** @@ -3434,19 +3773,19 @@ Name | Type | Default | `supportedProvider` | [SupportedProvider](#supportedprovider) | - | `txDefaults?` | `Partial` | - | `logDecodeDependencies?` | undefined \| object | - | -`deployedBytecode` | string \| undefined | ExchangeContract.deployedBytecode | +`deployedBytecode` | string \| undefined | DummyERC721TokenContract.deployedBytecode | -**Returns:** *[ExchangeContract](#class-exchangecontract)* +**Returns:** *[DummyERC721TokenContract](#class-dummyerc721tokencontract)* ## Properties -### `Optional` _deployedBytecodeIfExists +#### `Optional` _deployedBytecodeIfExists • **_deployedBytecodeIfExists**? : *`Buffer`* -Defined in base-contract/lib/src/index.d.ts:32 +Defined in base-contract/lib/src/index.d.ts:31 ___ @@ -3456,7 +3795,7 @@ ___ -Defined in base-contract/lib/src/index.d.ts:28 +Defined in base-contract/lib/src/index.d.ts:27 ___ @@ -3466,7 +3805,7 @@ ___ -Defined in base-contract/lib/src/index.d.ts:29 +Defined in base-contract/lib/src/index.d.ts:28 ___ @@ -3476,7 +3815,7 @@ Args -Defined in base-contract/lib/src/index.d.ts:31 +Defined in base-contract/lib/src/index.d.ts:30 ___ @@ -3486,1050 +3825,1426 @@ ___ -Defined in base-contract/lib/src/index.d.ts:30 +Defined in base-contract/lib/src/index.d.ts:29 ## Methods -### EIP1271_MAGIC_VALUE +### getLogsAsync -▸ **EIP1271_MAGIC_VALUE**(): *`ContractFunctionObj`* +▸ **getLogsAsync**<**ArgsType**>(`eventName`: [DummyERC721TokenEvents](#enumeration-dummyerc721tokenevents), `blockRange`: `BlockRange`, `indexFilterValues`: `IndexedFilterValues`): *`Promise>>`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3106](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3106)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:2484](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L2484)* -**Returns:** *`ContractFunctionObj`* +Gets historical logs without creating a subscription -___ +**Type parameters:** -### EIP712_EXCHANGE_DOMAIN_HASH +▪ **ArgsType**: *[DummyERC721TokenEventArgs](#dummyerc721tokeneventargs)* -▸ **EIP712_EXCHANGE_DOMAIN_HASH**(): *`ContractFunctionObj`* +**Parameters:** -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3153](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3153)* +Name | Type | Description | +------ | ------ | ------ | +`eventName` | [DummyERC721TokenEvents](#enumeration-dummyerc721tokenevents) | The DummyERC721Token contract event you would like to subscribe to. | +`blockRange` | `BlockRange` | Block range to get logs from. | +`indexFilterValues` | `IndexedFilterValues` | An object where the keys are indexed args returned by the event and the value is the value you are interested in. E.g `{_from: aUserAddressHex}` | -**Returns:** *`ContractFunctionObj`* +**Returns:** *`Promise>>`* + +Array of logs that match the parameters ___ -### allowedValidators +### subscribe + +▸ **subscribe**<**ArgsType**>(`eventName`: [DummyERC721TokenEvents](#enumeration-dummyerc721tokenevents), `indexFilterValues`: `IndexedFilterValues`, `callback`: [EventCallback](#eventcallback)‹*`ArgsType`*›, `isVerbose`: boolean, `blockPollingIntervalMs?`: undefined | number): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:2442](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L2442)* -▸ **allowedValidators**(`index_0`: string, `index_1`: string): *`ContractFunctionObj`* +Subscribe to an event type emitted by the DummyERC721Token contract. + +**Type parameters:** -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3200](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3200)* +▪ **ArgsType**: *[DummyERC721TokenEventArgs](#dummyerc721tokeneventargs)* **Parameters:** -Name | Type | ------- | ------ | -`index_0` | string | -`index_1` | string | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`eventName` | [DummyERC721TokenEvents](#enumeration-dummyerc721tokenevents) | - | The DummyERC721Token contract event you would like to subscribe to. | +`indexFilterValues` | `IndexedFilterValues` | - | An object where the keys are indexed args returned by the event and the value is the value you are interested in. E.g `{maker: aUserAddressHex}` | +`callback` | [EventCallback](#eventcallback)‹*`ArgsType`*› | - | Callback that gets called when a log is added/removed | +`isVerbose` | boolean | false | Enable verbose subscription warnings (e.g recoverable network issues encountered) | +`blockPollingIntervalMs?` | undefined \| number | - | - | + +**Returns:** *string* -**Returns:** *`ContractFunctionObj`* +Subscription token used later to unsubscribe ___ -### batchCancelOrders +### unsubscribe -▸ **batchCancelOrders**(`orders`: `Array`): *`ContractTxFunctionObj`* +▸ **unsubscribe**(`subscriptionToken`: string): *void* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3259](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3259)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:2467](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L2467)* -Executes multiple calls of cancelOrder. +Cancel a subscription **Parameters:** Name | Type | Description | ------ | ------ | ------ | -`orders` | `Array` | Array of order specifications. | +`subscriptionToken` | string | Subscription token returned by `subscribe()` | -**Returns:** *`ContractTxFunctionObj`* +**Returns:** *void* ___ -### batchExecuteTransactions +### unsubscribeAll -▸ **batchExecuteTransactions**(`transactions`: `Array`, `signatures`: string[]): *`ContractTxFunctionObj`* +▸ **unsubscribeAll**(): *void* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3403](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3403)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:2473](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L2473)* -Executes a batch of Exchange method calls in the context of signer(s). +Cancels all existing subscriptions -**Parameters:** +**Returns:** *void* -Name | Type | Description | ------- | ------ | ------ | -`transactions` | `Array` | Array of 0x transaction structures. | -`signatures` | string[] | Array of proofs that transactions have been signed by signer(s). | +___ -**Returns:** *`ContractTxFunctionObj`* +### `Static` ABI -Array containing ABI encoded return data for each of the underlying Exchange function calls. +▸ **ABI**(): *[ContractAbi](#contractabi)* -___ +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:2065](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L2065)* -### batchFillOrKillOrders +**Returns:** *[ContractAbi](#contractabi)* -▸ **batchFillOrKillOrders**(`orders`: `Array`, `takerAssetFillAmounts`: `BigNumber`[], `signatures`: string[]): *`ContractTxFunctionObj>`* +The contract ABI -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3541](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3541)* +___ -Executes multiple calls of fillOrKillOrder. +### `Static` deployAsync -**Parameters:** +▸ **deployAsync**(`bytecode`: string, `abi`: [ContractAbi](#contractabi), `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object, `_name`: string, `_symbol`: string): *`Promise`* -Name | Type | Description | ------- | ------ | ------ | -`orders` | `Array` | Array of order specifications. | -`takerAssetFillAmounts` | `BigNumber`[] | Array of desired amounts of takerAsset to sell in orders. | -`signatures` | string[] | Proofs that orders have been created by makers. | +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:2017](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L2017)* -**Returns:** *`ContractTxFunctionObj>`* +**Parameters:** -Array of amounts filled and fees paid by makers and taker. +Name | Type | +------ | ------ | +`bytecode` | string | +`abi` | [ContractAbi](#contractabi) | +`supportedProvider` | [SupportedProvider](#supportedprovider) | +`txDefaults` | `Partial` | +`logDecodeDependencies` | object | +`_name` | string | +`_symbol` | string | -___ +**Returns:** *`Promise`* -### batchFillOrders +___ -▸ **batchFillOrders**(`orders`: `Array`, `takerAssetFillAmounts`: `BigNumber`[], `signatures`: string[]): *`ContractTxFunctionObj>`* +### `Static` deployFrom0xArtifactAsync -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3717](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3717)* +▸ **deployFrom0xArtifactAsync**(`artifact`: `ContractArtifact` | `SimpleContractArtifact`, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object, `_name`: string, `_symbol`: string): *`Promise`* -Executes multiple calls of fillOrder. +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:1982](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L1982)* **Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`orders` | `Array` | Array of order specifications. | -`takerAssetFillAmounts` | `BigNumber`[] | Array of desired amounts of takerAsset to sell in orders. | -`signatures` | string[] | Proofs that orders have been created by makers. | - -**Returns:** *`ContractTxFunctionObj>`* +Name | Type | +------ | ------ | +`artifact` | `ContractArtifact` \| `SimpleContractArtifact` | +`supportedProvider` | [SupportedProvider](#supportedprovider) | +`txDefaults` | `Partial` | +`logDecodeDependencies` | object | +`_name` | string | +`_symbol` | string | -Array of amounts filled and fees paid by makers and taker. +**Returns:** *`Promise`* ___ -### batchFillOrdersNoThrow +### `Static` strictArgumentEncodingCheck -▸ **batchFillOrdersNoThrow**(`orders`: `Array`, `takerAssetFillAmounts`: `BigNumber`[], `signatures`: string[]): *`ContractTxFunctionObj>`* +▸ **strictArgumentEncodingCheck**(`inputAbi`: `DataItem`[], `args`: any[]): *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3893](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3893)* -Executes multiple calls of fillOrder. If any fill reverts, the error is caught and ignored. + +Defined in base-contract/lib/src/index.d.ts:41 **Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`orders` | `Array` | Array of order specifications. | -`takerAssetFillAmounts` | `BigNumber`[] | Array of desired amounts of takerAsset to sell in orders. | -`signatures` | string[] | Proofs that orders have been created by makers. | +Name | Type | +------ | ------ | +`inputAbi` | `DataItem`[] | +`args` | any[] | -**Returns:** *`ContractTxFunctionObj>`* +**Returns:** *string* -Array of amounts filled and fees paid by makers and taker. +## Object literals -___ +### approve -### batchMatchOrders +#### ▪ **approve**: *object* -▸ **batchMatchOrders**(`leftOrders`: `Array`, `rightOrders`: `Array`, `leftSignatures`: string[], `rightSignatures`: string[]): *`ContractTxFunctionObj`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:76](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L76)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4073](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4073)* +The zero address indicates there is no approved address. +Throws unless `msg.sender` is the current NFT owner, or an authorized +operator of the current owner. -Match complementary orders that have a profitable spread. -Each order is filled at their respective price point, and -the matcher receives a profit denominated in the left maker asset. +#### awaitTransactionSuccessAsync -**Parameters:** +▸ **awaitTransactionSuccessAsync**(`_approved`: string, `_tokenId`: `BigNumber`, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* -Name | Type | Description | ------- | ------ | ------ | -`leftOrders` | `Array` | Set of orders with the same maker / taker asset. | -`rightOrders` | `Array` | Set of orders to match against `leftOrders` | -`leftSignatures` | string[] | Proof that left orders were created by the left makers. | -`rightSignatures` | string[] | Proof that right orders were created by the right makers. | +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:126](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L126)* -**Returns:** *`ContractTxFunctionObj`* +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. -batchMatchedFillResults Amounts filled and profit generated. +**Parameters:** -___ +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_approved` | string | - | The new approved NFT controller | +`_tokenId` | `BigNumber` | - | The NFT to approve | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | -### batchMatchOrdersWithMaximalFill +**Returns:** *`PromiseWithTransactionHash`* -▸ **batchMatchOrdersWithMaximalFill**(`leftOrders`: `Array`, `rightOrders`: `Array`, `leftSignatures`: string[], `rightSignatures`: string[]): *`ContractTxFunctionObj`* +A promise that resolves when the transaction is successful -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4298](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4298)* +#### callAsync -Match complementary orders that have a profitable spread. -Each order is maximally filled at their respective price point, and -the matcher receives a profit denominated in either the left maker asset, -right maker asset, or a combination of both. +▸ **callAsync**(`_approved`: string, `_tokenId`: `BigNumber`, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -**Parameters:** +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:189](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L189)* -Name | Type | Description | ------- | ------ | ------ | -`leftOrders` | `Array` | Set of orders with the same maker / taker asset. | -`rightOrders` | `Array` | Set of orders to match against `leftOrders` | -`leftSignatures` | string[] | Proof that left orders were created by the left makers. | -`rightSignatures` | string[] | Proof that right orders were created by the right makers. | +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. -**Returns:** *`ContractTxFunctionObj`* +**Parameters:** -batchMatchedFillResults Amounts filled and profit generated. +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_approved` | string | - | The new approved NFT controller | +`_tokenId` | `BigNumber` | - | The NFT to approve | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -___ +**Returns:** *`Promise`* -### cancelOrder +#### estimateGasAsync -▸ **cancelOrder**(`order`: object): *`ContractTxFunctionObj`* +▸ **estimateGasAsync**(`_approved`: string, `_tokenId`: `BigNumber`, `txData?`: `Partial` | undefined): *`Promise`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4514](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4514)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:155](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L155)* -After calling, the order can not be filled anymore. +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. **Parameters:** Name | Type | Description | ------ | ------ | ------ | -`order` | object | Order struct containing order specifications. | +`_approved` | string | The new approved NFT controller | +`_tokenId` | `BigNumber` | The NFT to approve | +`txData?` | `Partial` \| undefined | Additional data for transaction | -**Returns:** *`ContractTxFunctionObj`* +**Returns:** *`Promise`* -___ +The hash of the transaction -### cancelOrdersUpTo +#### getABIEncodedTransactionData -▸ **cancelOrdersUpTo**(`targetOrderEpoch`: `BigNumber`): *`ContractTxFunctionObj`* +▸ **getABIEncodedTransactionData**(`_approved`: string, `_tokenId`: `BigNumber`): *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4654](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4654)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:243](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L243)* -Cancels all orders created by makerAddress with a salt less than or equal to the targetOrderEpoch -and senderAddress equal to msg.sender (or null address if msg.sender == makerAddress). +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). **Parameters:** Name | Type | Description | ------ | ------ | ------ | -`targetOrderEpoch` | `BigNumber` | Orders created with a salt less or equal to this value will be cancelled. | +`_approved` | string | The new approved NFT controller | +`_tokenId` | `BigNumber` | The NFT to approve | + +**Returns:** *string* -**Returns:** *`ContractTxFunctionObj`* +The ABI encoded transaction data as a string -___ +#### getSelector -### cancelled +▸ **getSelector**(): *string* -▸ **cancelled**(`index_0`: string): *`ContractFunctionObj`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:256](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L256)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4762](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4762)* +Returns the 4 byte function selector as a hex string. -**Parameters:** +**Returns:** *string* -Name | Type | ------- | ------ | -`index_0` | string | +#### sendTransactionAsync -**Returns:** *`ContractFunctionObj`* +▸ **sendTransactionAsync**(`_approved`: string, `_tokenId`: `BigNumber`, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* -___ +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:85](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L85)* -### currentContextAddress +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** -▸ **currentContextAddress**(): *`ContractFunctionObj`* +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_approved` | string | - | The new approved NFT controller | +`_tokenId` | `BigNumber` | - | The NFT to approve | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4810](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4810)* +**Returns:** *`Promise`* -**Returns:** *`ContractFunctionObj`* +The hash of the transaction ___ -### executeTransaction +### balanceOf -▸ **executeTransaction**(`transaction`: object, `signature`: string): *`ContractTxFunctionObj`* +#### ▪ **balanceOf**: *object* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4863](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4863)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:266](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L266)* -Executes an Exchange method call in the context of signer. +NFTs assigned to the zero address are considered invalid, and this +function throws for queries about the zero address. -**Parameters:** +#### callAsync -Name | Type | Description | ------- | ------ | ------ | -`transaction` | object | 0x transaction structure. | -`signature` | string | Proof that transaction has been signed by signer. | +▸ **callAsync**(`_owner`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -**Returns:** *`ContractTxFunctionObj`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:274](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L274)* -ABI encoded return data of the underlying Exchange function call. +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. -___ +**Parameters:** -### fillOrKillOrder +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_owner` | string | - | An address for whom to query the balance | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -▸ **fillOrKillOrder**(`order`: object, `takerAssetFillAmount`: `BigNumber`, `signature`: string): *`ContractTxFunctionObj`* +**Returns:** *`Promise`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4999](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4999)* +The number of NFTs owned by `_owner`, possibly zero -Fills the input order. Reverts if exact takerAssetFillAmount not filled. +___ -**Parameters:** +### burn -Name | Type | Description | ------- | ------ | ------ | -`order` | object | Order struct containing order specifications. | -`takerAssetFillAmount` | `BigNumber` | Desired amount of takerAsset to sell. | -`signature` | string | Proof that order has been created by maker. | +#### ▪ **burn**: *object* -**Returns:** *`ContractTxFunctionObj`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:320](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L320)* -___ +Function to burn a token +Reverts if the given token ID doesn't exist or not called by contract owner -### fillOrder +#### awaitTransactionSuccessAsync -▸ **fillOrder**(`order`: object, `takerAssetFillAmount`: `BigNumber`, `signature`: string): *`ContractTxFunctionObj`* +▸ **awaitTransactionSuccessAsync**(`_owner`: string, `_tokenId`: `BigNumber`, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:5168](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L5168)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:367](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L367)* -Fills the input order. +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. **Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`order` | object | Order struct containing order specifications. | -`takerAssetFillAmount` | `BigNumber` | Desired amount of takerAsset to sell. | -`signature` | string | Proof that order has been created by maker. | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_owner` | string | - | Owner of token with given token ID | +`_tokenId` | `BigNumber` | - | ID of the token to be burned by the msg.sender | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | -**Returns:** *`ContractTxFunctionObj`* +**Returns:** *`PromiseWithTransactionHash`* -Amounts filled and fees paid by maker and taker. +A promise that resolves when the transaction is successful -___ +#### callAsync -### filled +▸ **callAsync**(`_owner`: string, `_tokenId`: `BigNumber`, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -▸ **filled**(`index_0`: string): *`ContractFunctionObj`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:427](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L427)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:5330](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L5330)* +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | ------- | ------ | -`index_0` | string | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_owner` | string | - | Owner of token with given token ID | +`_tokenId` | `BigNumber` | - | ID of the token to be burned by the msg.sender | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* -**Returns:** *`ContractFunctionObj`* +#### estimateGasAsync -___ +▸ **estimateGasAsync**(`_owner`: string, `_tokenId`: `BigNumber`, `txData?`: `Partial` | undefined): *`Promise`* -### getABIDecodedReturnData +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:396](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L396)* -▸ **getABIDecodedReturnData**<**T**>(`methodName`: string, `callData`: string): *`T`* +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3092](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3092)* +**Parameters:** -**Type parameters:** +Name | Type | Description | +------ | ------ | ------ | +`_owner` | string | Owner of token with given token ID | +`_tokenId` | `BigNumber` | ID of the token to be burned by the msg.sender | +`txData?` | `Partial` \| undefined | Additional data for transaction | -▪ **T** +**Returns:** *`Promise`* -**Parameters:** +The hash of the transaction -Name | Type | ------- | ------ | -`methodName` | string | -`callData` | string | +#### getABIEncodedTransactionData -**Returns:** *`T`* +▸ **getABIEncodedTransactionData**(`_owner`: string, `_tokenId`: `BigNumber`): *string* -___ +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:478](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L478)* -### getABIDecodedTransactionData +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). -▸ **getABIDecodedTransactionData**<**T**>(`methodName`: string, `callData`: string): *`T`* +**Parameters:** -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3085](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3085)* +Name | Type | Description | +------ | ------ | ------ | +`_owner` | string | Owner of token with given token ID | +`_tokenId` | `BigNumber` | ID of the token to be burned by the msg.sender | -**Type parameters:** +**Returns:** *string* -▪ **T** +The ABI encoded transaction data as a string -**Parameters:** +#### getSelector -Name | Type | ------- | ------ | -`methodName` | string | -`callData` | string | +▸ **getSelector**(): *string* -**Returns:** *`T`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:491](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L491)* -___ +Returns the 4 byte function selector as a hex string. -### getAssetProxy +**Returns:** *string* -▸ **getAssetProxy**(`assetProxyId`: string): *`ContractFunctionObj`* +#### sendTransactionAsync -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:5383](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L5383)* +▸ **sendTransactionAsync**(`_owner`: string, `_tokenId`: `BigNumber`, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* -Gets an asset proxy. +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:329](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L329)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. **Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`assetProxyId` | string | Id of the asset proxy. | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_owner` | string | - | Owner of token with given token ID | +`_tokenId` | `BigNumber` | - | ID of the token to be burned by the msg.sender | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | -**Returns:** *`ContractFunctionObj`* +**Returns:** *`Promise`* -The asset proxy registered to assetProxyId. Returns 0x0 if no proxy is registered. +The hash of the transaction ___ -### getFunctionSignature +### getApproved -▸ **getFunctionSignature**(`methodName`: string): *string* +#### ▪ **getApproved**: *object* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3079](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3079)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:500](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L500)* -**Parameters:** +Throws if `_tokenId` is not a valid NFT. -Name | Type | ------- | ------ | -`methodName` | string | +#### callAsync -**Returns:** *string* +▸ **callAsync**(`_tokenId`: `BigNumber`, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:508](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L508)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_tokenId` | `BigNumber` | - | The NFT to find the approved address for | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +The approved address for this NFT, or the zero address if there is none ___ -### getLogsAsync +### isApprovedForAll -▸ **getLogsAsync**<**ArgsType**>(`eventName`: [ExchangeEvents](#enumeration-exchangeevents), `blockRange`: `BlockRange`, `indexFilterValues`: `IndexedFilterValues`): *`Promise>>`* +#### ▪ **isApprovedForAll**: *object* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:8050](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L8050)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:550](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L550)* -Gets historical logs without creating a subscription +#### callAsync -**Type parameters:** +▸ **callAsync**(`_owner`: string, `_operator`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -▪ **ArgsType**: *[ExchangeEventArgs](#exchangeeventargs)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:559](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L559)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`eventName` | [ExchangeEvents](#enumeration-exchangeevents) | The Exchange contract event you would like to subscribe to. | -`blockRange` | `BlockRange` | Block range to get logs from. | -`indexFilterValues` | `IndexedFilterValues` | An object where the keys are indexed args returned by the event and the value is the value you are interested in. E.g `{_from: aUserAddressHex}` | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_owner` | string | - | The address that owns the NFTs | +`_operator` | string | - | The address that acts on behalf of the owner | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -**Returns:** *`Promise>>`* +**Returns:** *`Promise`* -Array of logs that match the parameters +True if `_operator` is an approved operator for `_owner`, false otherwise ___ -### getOrderInfo +### mint -▸ **getOrderInfo**(`order`: object): *`ContractFunctionObj`* +#### ▪ **mint**: *object* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:5436](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L5436)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:610](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L610)* -Gets information about an order: status, hash, and amount filled. +Function to mint a new token +Reverts if the given token ID already exists + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`_to`: string, `_tokenId`: `BigNumber`, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:657](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L657)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. **Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`order` | object | Order to gather information on. | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_to` | string | - | Address of the beneficiary that will own the minted token | +`_tokenId` | `BigNumber` | - | ID of the token to be minted by the msg.sender | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | -**Returns:** *`ContractFunctionObj`* +**Returns:** *`PromiseWithTransactionHash`* -OrderInfo Information about the order and its state. See LibOrder.OrderInfo for a complete description. +A promise that resolves when the transaction is successful -___ +#### callAsync -### getSelector +▸ **callAsync**(`_to`: string, `_tokenId`: `BigNumber`, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -▸ **getSelector**(`methodName`: string): *string* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:717](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L717)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3099](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3099)* +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | ------- | ------ | -`methodName` | string | - -**Returns:** *string* +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_to` | string | - | Address of the beneficiary that will own the minted token | +`_tokenId` | `BigNumber` | - | ID of the token to be minted by the msg.sender | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -___ +**Returns:** *`Promise`* -### isValidHashSignature +#### estimateGasAsync -▸ **isValidHashSignature**(`hash`: string, `signerAddress`: string, `signature`: string): *`ContractFunctionObj`* +▸ **estimateGasAsync**(`_to`: string, `_tokenId`: `BigNumber`, `txData?`: `Partial` | undefined): *`Promise`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:5520](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L5520)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:686](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L686)* -Verifies that a hash has been signed by the given signer. +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. **Parameters:** Name | Type | Description | ------ | ------ | ------ | -`hash` | string | Any 32-byte hash. | -`signerAddress` | string | Address that should have signed the given hash. | -`signature` | string | Proof that the hash has been signed by signer. | - -**Returns:** *`ContractFunctionObj`* +`_to` | string | Address of the beneficiary that will own the minted token | +`_tokenId` | `BigNumber` | ID of the token to be minted by the msg.sender | +`txData?` | `Partial` \| undefined | Additional data for transaction | -isValid `true` if the signature is valid for the given hash and signer. +**Returns:** *`Promise`* -___ +The hash of the transaction -### isValidOrderSignature +#### getABIEncodedTransactionData -▸ **isValidOrderSignature**(`order`: object, `signature`: string): *`ContractFunctionObj`* +▸ **getABIEncodedTransactionData**(`_to`: string, `_tokenId`: `BigNumber`): *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:5583](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L5583)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:768](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L768)* -Verifies that a signature for an order is valid. +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). **Parameters:** Name | Type | Description | ------ | ------ | ------ | -`order` | object | The order. | -`signature` | string | Proof that the order has been signed by signer. | +`_to` | string | Address of the beneficiary that will own the minted token | +`_tokenId` | `BigNumber` | ID of the token to be minted by the msg.sender | -**Returns:** *`ContractFunctionObj`* +**Returns:** *string* -isValid `true` if the signature is valid for the given order and signer. +The ABI encoded transaction data as a string -___ +#### getSelector -### isValidTransactionSignature +▸ **getSelector**(): *string* -▸ **isValidTransactionSignature**(`transaction`: object, `signature`: string): *`ContractFunctionObj`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:781](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L781)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:5664](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L5664)* +Returns the 4 byte function selector as a hex string. -Verifies that a signature for a transaction is valid. +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`_to`: string, `_tokenId`: `BigNumber`, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:619](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L619)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. **Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`transaction` | object | The transaction. | -`signature` | string | Proof that the order has been signed by signer. | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_to` | string | - | Address of the beneficiary that will own the minted token | +`_tokenId` | `BigNumber` | - | ID of the token to be minted by the msg.sender | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | -**Returns:** *`ContractFunctionObj`* +**Returns:** *`Promise`* -isValid `true` if the signature is valid for the given transaction and signer. +The hash of the transaction ___ -### marketBuyOrdersFillOrKill +### name -▸ **marketBuyOrdersFillOrKill**(`orders`: `Array`, `makerAssetFillAmount`: `BigNumber`, `signatures`: string[]): *`ContractTxFunctionObj`* +#### ▪ **name**: *object* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:5738](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L5738)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:787](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L787)* -Calls marketBuyOrdersNoThrow then reverts if < makerAssetFillAmount has been bought. -NOTE: This function does not enforce that the makerAsset is the same for each order. +#### callAsync + +▸ **callAsync**(`callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:793](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L793)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | Description | +Name | Type | Default | ------ | ------ | ------ | -`orders` | `Array` | Array of order specifications. | -`makerAssetFillAmount` | `BigNumber` | Minimum amount of makerAsset to buy. | -`signatures` | string[] | Proofs that orders have been signed by makers. | - -**Returns:** *`ContractTxFunctionObj`* +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | -Amounts filled and fees paid by makers and taker. +**Returns:** *`Promise`* ___ -### marketBuyOrdersNoThrow +### owner -▸ **marketBuyOrdersNoThrow**(`orders`: `Array`, `makerAssetFillAmount`: `BigNumber`, `signatures`: string[]): *`ContractTxFunctionObj`* +#### ▪ **owner**: *object* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:5909](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L5909)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:830](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L830)* -Executes multiple calls of fillOrder until total amount of makerAsset is bought by taker. -If any fill reverts, the error is caught and ignored. -NOTE: This function does not enforce that the makerAsset is the same for each order. +#### callAsync + +▸ **callAsync**(`callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:836](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L836)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | Description | +Name | Type | Default | ------ | ------ | ------ | -`orders` | `Array` | Array of order specifications. | -`makerAssetFillAmount` | `BigNumber` | Desired amount of makerAsset to buy. | -`signatures` | string[] | Proofs that orders have been signed by makers. | - -**Returns:** *`ContractTxFunctionObj`* +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | -Amounts filled and fees paid by makers and taker. +**Returns:** *`Promise`* ___ -### marketSellOrdersFillOrKill +### ownerOf -▸ **marketSellOrdersFillOrKill**(`orders`: `Array`, `takerAssetFillAmount`: `BigNumber`, `signatures`: string[]): *`ContractTxFunctionObj`* +#### ▪ **ownerOf**: *object* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6079](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6079)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:877](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L877)* -Calls marketSellOrdersNoThrow then reverts if < takerAssetFillAmount has been sold. -NOTE: This function does not enforce that the takerAsset is the same for each order. +NFTs assigned to zero address are considered invalid, and queries +about them do throw. + +#### callAsync + +▸ **callAsync**(`_tokenId`: `BigNumber`, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:885](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L885)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`orders` | `Array` | Array of order specifications. | -`takerAssetFillAmount` | `BigNumber` | Minimum amount of takerAsset to sell. | -`signatures` | string[] | Proofs that orders have been signed by makers. | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_tokenId` | `BigNumber` | - | The identifier for an NFT | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -**Returns:** *`ContractTxFunctionObj`* +**Returns:** *`Promise`* -Amounts filled and fees paid by makers and taker. +The address of the owner of the NFT ___ -### marketSellOrdersNoThrow +### safeTransferFrom1 -▸ **marketSellOrdersNoThrow**(`orders`: `Array`, `takerAssetFillAmount`: `BigNumber`, `signatures`: string[]): *`ContractTxFunctionObj`* +#### ▪ **safeTransferFrom1**: *object* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6250](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6250)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:931](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L931)* -Executes multiple calls of fillOrder until total amount of takerAsset is sold by taker. -If any fill reverts, the error is caught and ignored. -NOTE: This function does not enforce that the takerAsset is the same for each order. +This works identically to the other function with an extra data parameter, +except this function just sets data to "". -**Parameters:** +#### awaitTransactionSuccessAsync -Name | Type | Description | ------- | ------ | ------ | -`orders` | `Array` | Array of order specifications. | -`takerAssetFillAmount` | `BigNumber` | Desired amount of takerAsset to sell. | -`signatures` | string[] | Proofs that orders have been signed by makers. | +▸ **awaitTransactionSuccessAsync**(`_from`: string, `_to`: string, `_tokenId`: `BigNumber`, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* -**Returns:** *`ContractTxFunctionObj`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:986](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L986)* -Amounts filled and fees paid by makers and taker. +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. -___ +**Parameters:** -### matchOrders +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_from` | string | - | The current owner of the NFT | +`_to` | string | - | The new owner | +`_tokenId` | `BigNumber` | - | The NFT to transfer | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | -▸ **matchOrders**(`leftOrder`: object, `rightOrder`: object, `leftSignature`: string, `rightSignature`: string): *`ContractTxFunctionObj`* +**Returns:** *`PromiseWithTransactionHash`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6423](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6423)* +A promise that resolves when the transaction is successful -Match two complementary orders that have a profitable spread. -Each order is filled at their respective price point. However, the calculations are -carried out as though the orders are both being filled at the right order's price point. -The profit made by the left order goes to the taker (who matched the two orders). +#### callAsync -**Parameters:** +▸ **callAsync**(`_from`: string, `_to`: string, `_tokenId`: `BigNumber`, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -Name | Type | Description | ------- | ------ | ------ | -`leftOrder` | object | First order to match. | -`rightOrder` | object | Second order to match. | -`leftSignature` | string | Proof that order was created by the left maker. | -`rightSignature` | string | Proof that order was created by the right maker. | +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:1062](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L1062)* -**Returns:** *`ContractTxFunctionObj`* +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. -matchedFillResults Amounts filled and fees paid by maker and taker of matched orders. +**Parameters:** -___ +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_from` | string | - | The current owner of the NFT | +`_to` | string | - | The new owner | +`_tokenId` | `BigNumber` | - | The NFT to transfer | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -### matchOrdersWithMaximalFill +**Returns:** *`Promise`* -▸ **matchOrdersWithMaximalFill**(`leftOrder`: object, `rightOrder`: object, `leftSignature`: string, `rightSignature`: string): *`ContractTxFunctionObj`* +#### estimateGasAsync -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6645](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6645)* +▸ **estimateGasAsync**(`_from`: string, `_to`: string, `_tokenId`: `BigNumber`, `txData?`: `Partial` | undefined): *`Promise`* -Match two complementary orders that have a profitable spread. -Each order is maximally filled at their respective price point, and -the matcher receives a profit denominated in either the left maker asset, -right maker asset, or a combination of both. +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:1024](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L1024)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. **Parameters:** Name | Type | Description | ------ | ------ | ------ | -`leftOrder` | object | First order to match. | -`rightOrder` | object | Second order to match. | -`leftSignature` | string | Proof that order was created by the left maker. | -`rightSignature` | string | Proof that order was created by the right maker. | +`_from` | string | The current owner of the NFT | +`_to` | string | The new owner | +`_tokenId` | `BigNumber` | The NFT to transfer | +`txData?` | `Partial` \| undefined | Additional data for transaction | -**Returns:** *`ContractTxFunctionObj`* +**Returns:** *`Promise`* -matchedFillResults Amounts filled by maker and taker of matched orders. +The hash of the transaction -___ +#### getABIEncodedTransactionData -### orderEpoch +▸ **getABIEncodedTransactionData**(`_from`: string, `_to`: string, `_tokenId`: `BigNumber`): *string* -▸ **orderEpoch**(`index_0`: string, `index_1`: string): *`ContractFunctionObj`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:1120](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L1120)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6856](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6856)* +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). **Parameters:** -Name | Type | ------- | ------ | -`index_0` | string | -`index_1` | string | +Name | Type | Description | +------ | ------ | ------ | +`_from` | string | The current owner of the NFT | +`_to` | string | The new owner | +`_tokenId` | `BigNumber` | The NFT to transfer | -**Returns:** *`ContractFunctionObj`* +**Returns:** *string* -___ +The ABI encoded transaction data as a string -### owner +#### getSelector -▸ **owner**(): *`ContractFunctionObj`* +▸ **getSelector**(): *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6911](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6911)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:1135](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L1135)* -**Returns:** *`ContractFunctionObj`* +Returns the 4 byte function selector as a hex string. -___ +**Returns:** *string* -### preSign +#### sendTransactionAsync -▸ **preSign**(`hash`: string): *`ContractTxFunctionObj`* +▸ **sendTransactionAsync**(`_from`: string, `_to`: string, `_tokenId`: `BigNumber`, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6963](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6963)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:941](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L941)* -Approves a hash on-chain. -After presigning a hash, the preSign signature type will become valid for that hash and signer. +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. **Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`hash` | string | Any 32-byte hash. | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_from` | string | - | The current owner of the NFT | +`_to` | string | - | The new owner | +`_tokenId` | `BigNumber` | - | The NFT to transfer | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* -**Returns:** *`ContractTxFunctionObj`* +The hash of the transaction ___ -### preSigned +### safeTransferFrom2 -▸ **preSigned**(`index_0`: string, `index_1`: string): *`ContractFunctionObj`* +#### ▪ **safeTransferFrom2**: *object* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7069](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7069)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:1150](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L1150)* -**Parameters:** +Throws unless `msg.sender` is the current owner, an authorized +operator, or the approved address for this NFT. Throws if `_from` is +not the current owner. Throws if `_to` is the zero address. Throws if +`_tokenId` is not a valid NFT. When transfer is complete, this function +checks if `_to` is a smart contract (code size > 0). If so, it calls +`onERC721Received` on `_to` and throws if the return value is not +`bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`. -Name | Type | ------- | ------ | -`index_0` | string | -`index_1` | string | +#### awaitTransactionSuccessAsync -**Returns:** *`ContractFunctionObj`* +▸ **awaitTransactionSuccessAsync**(`_from`: string, `_to`: string, `_tokenId`: `BigNumber`, `_data`: string, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* -___ +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:1210](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L1210)* -### protocolFeeCollector +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_from` | string | - | The current owner of the NFT | +`_to` | string | - | The new owner | +`_tokenId` | `BigNumber` | - | The NFT to transfer | +`_data` | string | - | Additional data with no specified format, sent in call to `_to` | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | -▸ **protocolFeeCollector**(): *`ContractFunctionObj`* +**Returns:** *`PromiseWithTransactionHash`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7124](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7124)* +A promise that resolves when the transaction is successful -**Returns:** *`ContractFunctionObj`* +#### callAsync -___ +▸ **callAsync**(`_from`: string, `_to`: string, `_tokenId`: `BigNumber`, `_data`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -### protocolFeeMultiplier +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:1294](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L1294)* -▸ **protocolFeeMultiplier**(): *`ContractFunctionObj`* +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7171](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7171)* +**Parameters:** -**Returns:** *`ContractFunctionObj`* +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_from` | string | - | The current owner of the NFT | +`_to` | string | - | The new owner | +`_tokenId` | `BigNumber` | - | The NFT to transfer | +`_data` | string | - | Additional data with no specified format, sent in call to `_to` | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -___ +**Returns:** *`Promise`* -### registerAssetProxy +#### estimateGasAsync -▸ **registerAssetProxy**(`assetProxy`: string): *`ContractTxFunctionObj`* +▸ **estimateGasAsync**(`_from`: string, `_to`: string, `_tokenId`: `BigNumber`, `_data`: string, `txData?`: `Partial` | undefined): *`Promise`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7223](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7223)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:1252](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L1252)* -Registers an asset proxy to its asset proxy id. -Once an asset proxy is registered, it cannot be unregistered. +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. **Parameters:** Name | Type | Description | ------ | ------ | ------ | -`assetProxy` | string | Address of new asset proxy to register. | +`_from` | string | The current owner of the NFT | +`_to` | string | The new owner | +`_tokenId` | `BigNumber` | The NFT to transfer | +`_data` | string | Additional data with no specified format, sent in call to `_to` | +`txData?` | `Partial` \| undefined | Additional data for transaction | -**Returns:** *`ContractTxFunctionObj`* +**Returns:** *`Promise`* -___ +The hash of the transaction -### setProtocolFeeCollectorAddress +#### getABIEncodedTransactionData -▸ **setProtocolFeeCollectorAddress**(`updatedProtocolFeeCollector`: string): *`ContractTxFunctionObj`* +▸ **getABIEncodedTransactionData**(`_from`: string, `_to`: string, `_tokenId`: `BigNumber`, `_data`: string): *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7342](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7342)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:1356](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L1356)* -Allows the owner to update the protocolFeeCollector address. +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). **Parameters:** Name | Type | Description | ------ | ------ | ------ | -`updatedProtocolFeeCollector` | string | The updated protocolFeeCollector contract address. | +`_from` | string | The current owner of the NFT | +`_to` | string | The new owner | +`_tokenId` | `BigNumber` | The NFT to transfer | +`_data` | string | Additional data with no specified format, sent in call to `_to` | -**Returns:** *`ContractTxFunctionObj`* +**Returns:** *string* -___ +The ABI encoded transaction data as a string -### setProtocolFeeMultiplier +#### getSelector -▸ **setProtocolFeeMultiplier**(`updatedProtocolFeeMultiplier`: `BigNumber`): *`ContractTxFunctionObj`* +▸ **getSelector**(): *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7461](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7461)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:1371](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L1371)* -Allows the owner to update the protocol fee multiplier. +Returns the 4 byte function selector as a hex string. -**Parameters:** +**Returns:** *string* -Name | Type | Description | ------- | ------ | ------ | -`updatedProtocolFeeMultiplier` | `BigNumber` | The updated protocol fee multiplier. | +#### sendTransactionAsync -**Returns:** *`ContractTxFunctionObj`* +▸ **sendTransactionAsync**(`_from`: string, `_to`: string, `_tokenId`: `BigNumber`, `_data`: string, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* -___ +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:1161](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L1161)* -### setSignatureValidatorApproval +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** -▸ **setSignatureValidatorApproval**(`validatorAddress`: string, `approval`: boolean): *`ContractTxFunctionObj`* +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_from` | string | - | The current owner of the NFT | +`_to` | string | - | The new owner | +`_tokenId` | `BigNumber` | - | The NFT to transfer | +`_data` | string | - | Additional data with no specified format, sent in call to `_to` | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7581](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7581)* +**Returns:** *`Promise`* -Approves/unnapproves a Validator contract to verify signatures on signer's behalf -using the `Validator` signature type. +The hash of the transaction + +___ + +### setApprovalForAll + +#### ▪ **setApprovalForAll**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:1381](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L1381)* + +Emits the ApprovalForAll event. The contract MUST allow +multiple operators per owner. + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`_operator`: string, `_approved`: boolean, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:1431](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L1431)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_operator` | string | - | Address to add to the set of authorized operators | +`_approved` | boolean | - | True if the operator is approved, false to revoke approval | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`_operator`: string, `_approved`: boolean, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:1499](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L1499)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_operator` | string | - | Address to add to the set of authorized operators | +`_approved` | boolean | - | True if the operator is approved, false to revoke approval | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +#### estimateGasAsync + +▸ **estimateGasAsync**(`_operator`: string, `_approved`: boolean, `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:1465](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L1465)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. **Parameters:** Name | Type | Description | ------ | ------ | ------ | -`validatorAddress` | string | Address of Validator contract. | -`approval` | boolean | Approval or disapproval of Validator contract. | +`_operator` | string | Address to add to the set of authorized operators | +`_approved` | boolean | True if the operator is approved, false to revoke approval | +`txData?` | `Partial` \| undefined | Additional data for transaction | -**Returns:** *`ContractTxFunctionObj`* +**Returns:** *`Promise`* -___ +The hash of the transaction -### simulateDispatchTransferFromCalls +#### getABIEncodedTransactionData -▸ **simulateDispatchTransferFromCalls**(`assetData`: string[], `fromAddresses`: string[], `toAddresses`: string[], `amounts`: `BigNumber`[]): *`ContractTxFunctionObj`* +▸ **getABIEncodedTransactionData**(`_operator`: string, `_approved`: boolean): *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7712](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7712)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:1553](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L1553)* -This function may be used to simulate any amount of transfers As they would occur through the Exchange contract. Note that this function will always revert, even if all transfers are successful. However, it may be used with eth_call or with a try/catch pattern in order to simulate the results of the transfers. +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). **Parameters:** Name | Type | Description | ------ | ------ | ------ | -`assetData` | string[] | Array of asset details, each encoded per the AssetProxy contract specification. | -`fromAddresses` | string[] | Array containing the `from` addresses that correspond with each transfer. | -`toAddresses` | string[] | Array containing the `to` addresses that correspond with each transfer. | -`amounts` | `BigNumber`[] | Array containing the amounts that correspond to each transfer. | +`_operator` | string | Address to add to the set of authorized operators | +`_approved` | boolean | True if the operator is approved, false to revoke approval | -**Returns:** *`ContractTxFunctionObj`* +**Returns:** *string* -This function does not return a value. However, it will always revert with `Error("TRANSFERS_SUCCESSFUL")` if all of the transfers were successful. +The ABI encoded transaction data as a string -___ +#### getSelector -### subscribe +▸ **getSelector**(): *string* -▸ **subscribe**<**ArgsType**>(`eventName`: [ExchangeEvents](#enumeration-exchangeevents), `indexFilterValues`: `IndexedFilterValues`, `callback`: [EventCallback](#eventcallback)‹*`ArgsType`*›, `isVerbose`: boolean, `blockPollingIntervalMs?`: undefined | number): *string* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:1566](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L1566)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:8008](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L8008)* +Returns the 4 byte function selector as a hex string. -Subscribe to an event type emitted by the Exchange contract. +**Returns:** *string* -**Type parameters:** +#### sendTransactionAsync -▪ **ArgsType**: *[ExchangeEventArgs](#exchangeeventargs)* +▸ **sendTransactionAsync**(`_operator`: string, `_approved`: boolean, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:1390](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L1390)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. **Parameters:** Name | Type | Default | Description | ------ | ------ | ------ | ------ | -`eventName` | [ExchangeEvents](#enumeration-exchangeevents) | - | The Exchange contract event you would like to subscribe to. | -`indexFilterValues` | `IndexedFilterValues` | - | An object where the keys are indexed args returned by the event and the value is the value you are interested in. E.g `{maker: aUserAddressHex}` | -`callback` | [EventCallback](#eventcallback)‹*`ArgsType`*› | - | Callback that gets called when a log is added/removed | -`isVerbose` | boolean | false | Enable verbose subscription warnings (e.g recoverable network issues encountered) | -`blockPollingIntervalMs?` | undefined \| number | - | - | +`_operator` | string | - | Address to add to the set of authorized operators | +`_approved` | boolean | - | True if the operator is approved, false to revoke approval | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | -**Returns:** *string* +**Returns:** *`Promise`* -Subscription token used later to unsubscribe +The hash of the transaction ___ -### transactionsExecuted +### symbol + +#### ▪ **symbol**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:1572](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L1572)* + +#### callAsync + +▸ **callAsync**(`callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -▸ **transactionsExecuted**(`index_0`: string): *`ContractFunctionObj`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:1578](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L1578)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7840](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7840)* +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | ------- | ------ | -`index_0` | string | +Name | Type | Default | +------ | ------ | ------ | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | -**Returns:** *`ContractFunctionObj`* +**Returns:** *`Promise`* ___ -### transferOwnership +### transferFrom + +#### ▪ **transferFrom**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:1621](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L1621)* + +Throws unless `msg.sender` is the current owner, an authorized +operator, or the approved address for this NFT. Throws if `_from` is +not the current owner. Throws if `_to` is the zero address. Throws if +`_tokenId` is not a valid NFT. + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`_from`: string, `_to`: string, `_tokenId`: `BigNumber`, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* -▸ **transferOwnership**(`newOwner`: string): *`ContractTxFunctionObj`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:1676](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L1676)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7890](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7890)* +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. **Parameters:** -Name | Type | ------- | ------ | -`newOwner` | string | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_from` | string | - | The current owner of the NFT | +`_to` | string | - | The new owner | +`_tokenId` | `BigNumber` | - | The NFT to transfer | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | -**Returns:** *`ContractTxFunctionObj`* +**Returns:** *`PromiseWithTransactionHash`* -___ +A promise that resolves when the transaction is successful -### unsubscribe +#### callAsync -▸ **unsubscribe**(`subscriptionToken`: string): *void* +▸ **callAsync**(`_from`: string, `_to`: string, `_tokenId`: `BigNumber`, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:8033](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L8033)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:1752](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L1752)* -Cancel a subscription +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_from` | string | - | The current owner of the NFT | +`_to` | string | - | The new owner | +`_tokenId` | `BigNumber` | - | The NFT to transfer | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +#### estimateGasAsync + +▸ **estimateGasAsync**(`_from`: string, `_to`: string, `_tokenId`: `BigNumber`, `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:1714](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L1714)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. **Parameters:** Name | Type | Description | ------ | ------ | ------ | -`subscriptionToken` | string | Subscription token returned by `subscribe()` | +`_from` | string | The current owner of the NFT | +`_to` | string | The new owner | +`_tokenId` | `BigNumber` | The NFT to transfer | +`txData?` | `Partial` \| undefined | Additional data for transaction | -**Returns:** *void* +**Returns:** *`Promise`* -___ +The hash of the transaction -### unsubscribeAll +#### getABIEncodedTransactionData -▸ **unsubscribeAll**(): *void* +▸ **getABIEncodedTransactionData**(`_from`: string, `_to`: string, `_tokenId`: `BigNumber`): *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:8039](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L8039)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:1810](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L1810)* -Cancels all existing subscriptions +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). -**Returns:** *void* +**Parameters:** -___ +Name | Type | Description | +------ | ------ | ------ | +`_from` | string | The current owner of the NFT | +`_to` | string | The new owner | +`_tokenId` | `BigNumber` | The NFT to transfer | -### `Static` ABI +**Returns:** *string* -▸ **ABI**(): *[ContractAbi](#contractabi)* +The ABI encoded transaction data as a string -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:198](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L198)* +#### getSelector -**Returns:** *[ContractAbi](#contractabi)* +▸ **getSelector**(): *string* -The contract ABI +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:1825](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L1825)* -___ +Returns the 4 byte function selector as a hex string. -### `Static` deployAsync +**Returns:** *string* -▸ **deployAsync**(`bytecode`: string, `abi`: [ContractAbi](#contractabi), `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object, `chainId`: `BigNumber`): *`Promise`* +#### sendTransactionAsync -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:151](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L151)* +▸ **sendTransactionAsync**(`_from`: string, `_to`: string, `_tokenId`: `BigNumber`, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:1631](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L1631)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. **Parameters:** -Name | Type | ------- | ------ | -`bytecode` | string | -`abi` | [ContractAbi](#contractabi) | -`supportedProvider` | [SupportedProvider](#supportedprovider) | -`txDefaults` | `Partial` | -`logDecodeDependencies` | object | -`chainId` | `BigNumber` | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_from` | string | - | The current owner of the NFT | +`_to` | string | - | The new owner | +`_tokenId` | `BigNumber` | - | The NFT to transfer | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | -**Returns:** *`Promise`* +**Returns:** *`Promise`* + +The hash of the transaction ___ -### `Static` deployFrom0xArtifactAsync +### transferOwnership -▸ **deployFrom0xArtifactAsync**(`artifact`: `ContractArtifact` | `SimpleContractArtifact`, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object, `chainId`: `BigNumber`): *`Promise`* +#### ▪ **transferOwnership**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:1831](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L1831)* + +#### awaitTransactionSuccessAsync -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:125](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L125)* +▸ **awaitTransactionSuccessAsync**(`newOwner`: string, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:1872](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L1872)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. **Parameters:** -Name | Type | ------- | ------ | -`artifact` | `ContractArtifact` \| `SimpleContractArtifact` | -`supportedProvider` | [SupportedProvider](#supportedprovider) | -`txDefaults` | `Partial` | -`logDecodeDependencies` | object | -`chainId` | `BigNumber` | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`newOwner` | string | - | - | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | -**Returns:** *`Promise`* +**Returns:** *`PromiseWithTransactionHash`* -___ +A promise that resolves when the transaction is successful -### `Static` strictArgumentEncodingCheck +#### callAsync -▸ **strictArgumentEncodingCheck**(`inputAbi`: `DataItem`[], `args`: any[]): *string* +▸ **callAsync**(`newOwner`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:1921](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L1921)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`newOwner` | string | - | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +#### estimateGasAsync + +▸ **estimateGasAsync**(`newOwner`: string, `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:1897](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L1897)* +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`newOwner` | string | - | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData -Defined in base-contract/lib/src/index.d.ts:42 +▸ **getABIEncodedTransactionData**(`newOwner`: string): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:1964](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L1964)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). **Parameters:** Name | Type | ------ | ------ | -`inputAbi` | `DataItem`[] | -`args` | any[] | +`newOwner` | string | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:1975](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L1975)* + +Returns the 4 byte function selector as a hex string. **Returns:** *string* +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`newOwner`: string, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:1838](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L1838)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`newOwner` | string | - | - | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction +
-# Class: ForwarderContract +# Class: DutchAuctionContract ## Constructors -\+ **new ForwarderContract**(`address`: string, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults?`: `Partial`, `logDecodeDependencies?`: undefined | object, `deployedBytecode`: string | undefined): *[ForwarderContract](#class-forwardercontract)* +\+ **new DutchAuctionContract**(`address`: string, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults?`: `Partial`, `logDecodeDependencies?`: undefined | object, `deployedBytecode`: string | undefined): *[DutchAuctionContract](#class-dutchauctioncontract)* *Overrides void* -*Defined in [abi-gen-wrappers/src/generated-wrappers/forwarder.ts:1147](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts#L1147)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dutch_auction.ts:1073](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dutch_auction.ts#L1073)* **Parameters:** @@ -4539,19 +5254,19 @@ Name | Type | Default | `supportedProvider` | [SupportedProvider](#supportedprovider) | - | `txDefaults?` | `Partial` | - | `logDecodeDependencies?` | undefined \| object | - | -`deployedBytecode` | string \| undefined | ForwarderContract.deployedBytecode | +`deployedBytecode` | string \| undefined | DutchAuctionContract.deployedBytecode | -**Returns:** *[ForwarderContract](#class-forwardercontract)* +**Returns:** *[DutchAuctionContract](#class-dutchauctioncontract)* ## Properties -### `Optional` _deployedBytecodeIfExists +#### `Optional` _deployedBytecodeIfExists • **_deployedBytecodeIfExists**? : *`Buffer`* -Defined in base-contract/lib/src/index.d.ts:32 +Defined in base-contract/lib/src/index.d.ts:31 ___ @@ -4561,7 +5276,7 @@ ___ -Defined in base-contract/lib/src/index.d.ts:28 +Defined in base-contract/lib/src/index.d.ts:27 ___ @@ -4571,7 +5286,7 @@ ___ -Defined in base-contract/lib/src/index.d.ts:29 +Defined in base-contract/lib/src/index.d.ts:28 ___ @@ -4581,7 +5296,7 @@ Args -Defined in base-contract/lib/src/index.d.ts:31 +Defined in base-contract/lib/src/index.d.ts:30 ___ @@ -4591,290 +5306,369 @@ ___ -Defined in base-contract/lib/src/index.d.ts:30 +Defined in base-contract/lib/src/index.d.ts:29 ## Methods -### approveMakerAssetProxy - -▸ **approveMakerAssetProxy**(`assetData`: string): *`ContractTxFunctionObj`* - -*Defined in [abi-gen-wrappers/src/generated-wrappers/forwarder.ts:449](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts#L449)* +### `Static` ABI -Approves the respective proxy for a given asset to transfer tokens on the Forwarder contract's behalf. -This is necessary because an order fee denominated in the maker asset (i.e. a percentage fee) is sent by the -Forwarder contract to the fee recipient. -This method needs to be called before forwarding orders of a maker asset that hasn't -previously been approved. +▸ **ABI**(): *[ContractAbi](#contractabi)* -**Parameters:** +*Defined in [abi-gen-wrappers/src/generated-wrappers/dutch_auction.ts:781](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dutch_auction.ts#L781)* -Name | Type | Description | ------- | ------ | ------ | -`assetData` | string | Byte array encoded for the respective asset proxy. | +**Returns:** *[ContractAbi](#contractabi)* -**Returns:** *`ContractTxFunctionObj`* +The contract ABI ___ -### getABIDecodedReturnData - -▸ **getABIDecodedReturnData**<**T**>(`methodName`: string, `callData`: string): *`T`* - -*Defined in [abi-gen-wrappers/src/generated-wrappers/forwarder.ts:427](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts#L427)* +### `Static` deployAsync -**Type parameters:** +▸ **deployAsync**(`bytecode`: string, `abi`: [ContractAbi](#contractabi), `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object, `_exchange`: string): *`Promise`* -▪ **T** +*Defined in [abi-gen-wrappers/src/generated-wrappers/dutch_auction.ts:734](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dutch_auction.ts#L734)* **Parameters:** Name | Type | ------ | ------ | -`methodName` | string | -`callData` | string | +`bytecode` | string | +`abi` | [ContractAbi](#contractabi) | +`supportedProvider` | [SupportedProvider](#supportedprovider) | +`txDefaults` | `Partial` | +`logDecodeDependencies` | object | +`_exchange` | string | -**Returns:** *`T`* +**Returns:** *`Promise`* ___ -### getABIDecodedTransactionData - -▸ **getABIDecodedTransactionData**<**T**>(`methodName`: string, `callData`: string): *`T`* - -*Defined in [abi-gen-wrappers/src/generated-wrappers/forwarder.ts:420](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts#L420)* +### `Static` deployFrom0xArtifactAsync -**Type parameters:** +▸ **deployFrom0xArtifactAsync**(`artifact`: `ContractArtifact` | `SimpleContractArtifact`, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object, `_exchange`: string): *`Promise`* -▪ **T** +*Defined in [abi-gen-wrappers/src/generated-wrappers/dutch_auction.ts:701](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dutch_auction.ts#L701)* **Parameters:** Name | Type | ------ | ------ | -`methodName` | string | -`callData` | string | +`artifact` | `ContractArtifact` \| `SimpleContractArtifact` | +`supportedProvider` | [SupportedProvider](#supportedprovider) | +`txDefaults` | `Partial` | +`logDecodeDependencies` | object | +`_exchange` | string | -**Returns:** *`T`* +**Returns:** *`Promise`* ___ -### getFunctionSignature +### `Static` strictArgumentEncodingCheck + +▸ **strictArgumentEncodingCheck**(`inputAbi`: `DataItem`[], `args`: any[]): *string* + -▸ **getFunctionSignature**(`methodName`: string): *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/forwarder.ts:414](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts#L414)* +Defined in base-contract/lib/src/index.d.ts:41 **Parameters:** Name | Type | ------ | ------ | -`methodName` | string | +`inputAbi` | `DataItem`[] | +`args` | any[] | **Returns:** *string* -___ +## Object literals + +### getAuctionDetails + +#### ▪ **getAuctionDetails**: *object* -### getSelector +*Defined in [abi-gen-wrappers/src/generated-wrappers/dutch_auction.ts:44](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dutch_auction.ts#L44)* -▸ **getSelector**(`methodName`: string): *string* +Calculates the Auction Details for the given order -*Defined in [abi-gen-wrappers/src/generated-wrappers/forwarder.ts:434](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts#L434)* +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`order`: object, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/dutch_auction.ts:102](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dutch_auction.ts#L102)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. **Parameters:** -Name | Type | ------- | ------ | -`methodName` | string | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`order` | object | - | The sell order | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | -**Returns:** *string* +**Returns:** *`PromiseWithTransactionHash`* -___ +A promise that resolves when the transaction is successful -### marketBuyOrdersWithEth +#### callAsync -▸ **marketBuyOrdersWithEth**(`orders`: `Array`, `makerAssetBuyAmount`: `BigNumber`, `signatures`: string[], `feePercentage`: `BigNumber`, `feeRecipient`: string): *`ContractTxFunctionObj<[BigNumber, BigNumber, BigNumber]>`* +▸ **callAsync**(`order`: object, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/forwarder.ts:571](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts#L571)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dutch_auction.ts:184](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dutch_auction.ts#L184)* -Attempt to buy makerAssetBuyAmount of makerAsset by selling ETH provided with transaction. -The Forwarder may *fill* more than makerAssetBuyAmount of the makerAsset so that it can -pay takerFees where takerFeeAssetData == makerAssetData (i.e. percentage fees). -Any ETH not spent will be refunded to sender. +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`order` | object | - | The sell order | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +AuctionDetails + +#### estimateGasAsync + +▸ **estimateGasAsync**(`order`: object, `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/dutch_auction.ts:140](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dutch_auction.ts#L140)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. **Parameters:** Name | Type | Description | ------ | ------ | ------ | -`orders` | `Array` | Array of order specifications used containing desired makerAsset and WETH as takerAsset. | -`makerAssetBuyAmount` | `BigNumber` | Desired amount of makerAsset to purchase. | -`signatures` | string[] | Proofs that orders have been created by makers. | -`feePercentage` | `BigNumber` | Percentage of WETH sold that will payed as fee to forwarding contract feeRecipient. | -`feeRecipient` | string | Address that will receive ETH when orders are filled. | - -**Returns:** *`ContractTxFunctionObj<[BigNumber, BigNumber, BigNumber]>`* +`order` | object | The sell order | +`txData?` | `Partial` \| undefined | Additional data for transaction | -wethSpentAmount Amount of WETH spent on the given set of orders.makerAssetAcquiredAmount Amount of maker asset acquired from the given set of orders.ethFeePaid Amount of ETH spent on the given forwarder fee. +**Returns:** *`Promise`* -___ +The hash of the transaction -### marketSellOrdersWithEth +#### getABIEncodedTransactionData -▸ **marketSellOrdersWithEth**(`orders`: `Array`, `signatures`: string[], `feePercentage`: `BigNumber`, `feeRecipient`: string): *`ContractTxFunctionObj<[BigNumber, BigNumber, BigNumber]>`* +▸ **getABIEncodedTransactionData**(`order`: object): *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/forwarder.ts:730](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts#L730)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dutch_auction.ts:263](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dutch_auction.ts#L263)* -Purchases as much of orders' makerAssets as possible by selling as much of the ETH value sent -as possible, accounting for order and forwarder fees. +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). **Parameters:** Name | Type | Description | ------ | ------ | ------ | -`orders` | `Array` | Array of order specifications used containing desired makerAsset and WETH as takerAsset. | -`signatures` | string[] | Proofs that orders have been created by makers. | -`feePercentage` | `BigNumber` | Percentage of WETH sold that will payed as fee to forwarding contract feeRecipient. | -`feeRecipient` | string | Address that will receive ETH when orders are filled. | +`order` | object | The sell order | -**Returns:** *`ContractTxFunctionObj<[BigNumber, BigNumber, BigNumber]>`* +**Returns:** *string* -wethSpentAmount Amount of WETH spent on the given set of orders.makerAssetAcquiredAmount Amount of maker asset acquired from the given set of orders.ethFeePaid Amount of ETH spent on the given forwarder fee. +The ABI encoded transaction data as a string -___ +#### getSelector -### owner +▸ **getSelector**(): *string* -▸ **owner**(): *`ContractFunctionObj`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dutch_auction.ts:287](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dutch_auction.ts#L287)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/forwarder.ts:876](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts#L876)* +Returns the 4 byte function selector as a hex string. -**Returns:** *`ContractFunctionObj`* +**Returns:** *string* -___ +#### sendTransactionAsync -### transferOwnership +▸ **sendTransactionAsync**(`order`: object, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* -▸ **transferOwnership**(`newOwner`: string): *`ContractTxFunctionObj`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dutch_auction.ts:52](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dutch_auction.ts#L52)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/forwarder.ts:923](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts#L923)* +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. **Parameters:** -Name | Type | ------- | ------ | -`newOwner` | string | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`order` | object | - | The sell order | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* -**Returns:** *`ContractTxFunctionObj`* +The hash of the transaction ___ -### withdrawAsset +### matchOrders -▸ **withdrawAsset**(`assetData`: string, `amount`: `BigNumber`): *`ContractTxFunctionObj`* +#### ▪ **matchOrders**: *object* -*Defined in [abi-gen-wrappers/src/generated-wrappers/forwarder.ts:1038](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts#L1038)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dutch_auction.ts:312](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dutch_auction.ts#L312)* -Withdraws assets from this contract. The contract formerly required a ZRX balance in order -to function optimally, and this function allows the ZRX to be withdrawn by owner. -It may also be used to withdraw assets that were accidentally sent to this contract. +Matches the buy and sell orders at an amount given the following: the current block time, the auction +start time and the auction begin amount. The sell order is a an order at the lowest amount +at the end of the auction. Excess from the match is transferred to the seller. +Over time the price moves from beginAmount to endAmount given the current block.timestamp. +sellOrder.expiryTimeSeconds is the end time of the auction. +sellOrder.takerAssetAmount is the end amount of the auction (lowest possible amount). +sellOrder.makerAssetData is the ABI encoded Asset Proxy data with the following data appended +buyOrder.makerAssetData is the buyers bid on the auction, must meet the amount for the current block timestamp +(uint256 beginTimeSeconds, uint256 beginAmount). +This function reverts in the following scenarios: +* Auction has not started (auctionDetails.currentTimeSeconds < auctionDetails.beginTimeSeconds) +* Auction has expired (auctionDetails.endTimeSeconds < auctionDetails.currentTimeSeconds) +* Amount is invalid: Buy order amount is too low (buyOrder.makerAssetAmount < auctionDetails.currentAmount) +* Amount is invalid: Invalid begin amount (auctionDetails.beginAmount > auctionDetails.endAmount) +* Any failure in the 0x Match Orders + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`buyOrder`: object, `sellOrder`: object, `buySignature`: string, `sellSignature`: string, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/dutch_auction.ts:398](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dutch_auction.ts#L398)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. **Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`assetData` | string | Byte array encoded for the respective asset proxy. | -`amount` | `BigNumber` | Amount of ERC20 token to withdraw. | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`buyOrder` | object | - | The Buyer's order. This order is for the current expected price of the auction. | +`sellOrder` | object | - | The Seller's order. This order is for the lowest amount (at the end of the auction). | +`buySignature` | string | - | Proof that order was created by the buyer. | +`sellSignature` | string | - | Proof that order was created by the seller. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | -**Returns:** *`ContractTxFunctionObj`* +**Returns:** *`PromiseWithTransactionHash`* -___ +A promise that resolves when the transaction is successful -### `Static` ABI +#### callAsync -▸ **ABI**(): *[ContractAbi](#contractabi)* +▸ **callAsync**(`buyOrder`: object, `sellOrder`: object, `buySignature`: string, `sellSignature`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/forwarder.ts:127](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts#L127)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dutch_auction.ts:533](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dutch_auction.ts#L533)* -**Returns:** *[ContractAbi](#contractabi)* +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. -The contract ABI +**Parameters:** -___ +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`buyOrder` | object | - | The Buyer's order. This order is for the current expected price of the auction. | +`sellOrder` | object | - | The Seller's order. This order is for the lowest amount (at the end of the auction). | +`buySignature` | string | - | Proof that order was created by the buyer. | +`sellSignature` | string | - | Proof that order was created by the seller. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -### `Static` deployAsync +**Returns:** *`Promise`* -▸ **deployAsync**(`bytecode`: string, `abi`: [ContractAbi](#contractabi), `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object, `_exchange`: string, `_wethAssetData`: string): *`Promise`* +matchedFillResults amounts filled and fees paid by maker and taker of matched orders. + +#### estimateGasAsync + +▸ **estimateGasAsync**(`buyOrder`: object, `sellOrder`: object, `buySignature`: string, `sellSignature`: string, `txData?`: `Partial` | undefined): *`Promise`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/forwarder.ts:79](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts#L79)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dutch_auction.ts:466](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dutch_auction.ts#L466)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. **Parameters:** -Name | Type | ------- | ------ | -`bytecode` | string | -`abi` | [ContractAbi](#contractabi) | -`supportedProvider` | [SupportedProvider](#supportedprovider) | -`txDefaults` | `Partial` | -`logDecodeDependencies` | object | -`_exchange` | string | -`_wethAssetData` | string | +Name | Type | Description | +------ | ------ | ------ | +`buyOrder` | object | The Buyer's order. This order is for the current expected price of the auction. | +`sellOrder` | object | The Seller's order. This order is for the lowest amount (at the end of the auction). | +`buySignature` | string | Proof that order was created by the buyer. | +`sellSignature` | string | Proof that order was created by the seller. | +`txData?` | `Partial` \| undefined | Additional data for transaction | -**Returns:** *`Promise`* +**Returns:** *`Promise`* -___ +The hash of the transaction -### `Static` deployFrom0xArtifactAsync +#### getABIEncodedTransactionData -▸ **deployFrom0xArtifactAsync**(`artifact`: `ContractArtifact` | `SimpleContractArtifact`, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object, `_exchange`: string, `_wethAssetData`: string): *`Promise`* +▸ **getABIEncodedTransactionData**(`buyOrder`: object, `sellOrder`: object, `buySignature`: string, `sellSignature`: string): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/dutch_auction.ts:649](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dutch_auction.ts#L649)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/forwarder.ts:44](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts#L44)* +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). **Parameters:** -Name | Type | ------- | ------ | -`artifact` | `ContractArtifact` \| `SimpleContractArtifact` | -`supportedProvider` | [SupportedProvider](#supportedprovider) | -`txDefaults` | `Partial` | -`logDecodeDependencies` | object | -`_exchange` | string | -`_wethAssetData` | string | +Name | Type | Description | +------ | ------ | ------ | +`buyOrder` | object | The Buyer's order. This order is for the current expected price of the auction. | +`sellOrder` | object | The Seller's order. This order is for the lowest amount (at the end of the auction). | +`buySignature` | string | Proof that order was created by the buyer. | +`sellSignature` | string | Proof that order was created by the seller. | -**Returns:** *`Promise`* +**Returns:** *string* -___ +The ABI encoded transaction data as a string -### `Static` strictArgumentEncodingCheck +#### getSelector -▸ **strictArgumentEncodingCheck**(`inputAbi`: `DataItem`[], `args`: any[]): *string* +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/dutch_auction.ts:693](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dutch_auction.ts#L693)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync +▸ **sendTransactionAsync**(`buyOrder`: object, `sellOrder`: object, `buySignature`: string, `sellSignature`: string, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dutch_auction.ts:325](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dutch_auction.ts#L325)* -Defined in base-contract/lib/src/index.d.ts:42 +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. **Parameters:** -Name | Type | ------- | ------ | -`inputAbi` | `DataItem`[] | -`args` | any[] | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`buyOrder` | object | - | The Buyer's order. This order is for the current expected price of the auction. | +`sellOrder` | object | - | The Seller's order. This order is for the lowest amount (at the end of the auction). | +`buySignature` | string | - | Proof that order was created by the buyer. | +`sellSignature` | string | - | Proof that order was created by the seller. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | -**Returns:** *string* +**Returns:** *`Promise`* + +The hash of the transaction
-# Class: IValidatorContract +# Class: ERC1155ProxyContract ## Constructors -\+ **new IValidatorContract**(`address`: string, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults?`: `Partial`, `logDecodeDependencies?`: undefined | object, `deployedBytecode`: string | undefined): *[IValidatorContract](#class-ivalidatorcontract)* +\+ **new ERC1155ProxyContract**(`address`: string, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults?`: `Partial`, `logDecodeDependencies?`: undefined | object, `deployedBytecode`: string | undefined): *[ERC1155ProxyContract](#class-erc1155proxycontract)* *Overrides void* -*Defined in [abi-gen-wrappers/src/generated-wrappers/i_validator.ts:234](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/i_validator.ts#L234)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts:1529](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts#L1529)* **Parameters:** @@ -4884,19 +5678,19 @@ Name | Type | Default | `supportedProvider` | [SupportedProvider](#supportedprovider) | - | `txDefaults?` | `Partial` | - | `logDecodeDependencies?` | undefined \| object | - | -`deployedBytecode` | string \| undefined | IValidatorContract.deployedBytecode | +`deployedBytecode` | string \| undefined | ERC1155ProxyContract.deployedBytecode | -**Returns:** *[IValidatorContract](#class-ivalidatorcontract)* +**Returns:** *[ERC1155ProxyContract](#class-erc1155proxycontract)* ## Properties -### `Optional` _deployedBytecodeIfExists +#### `Optional` _deployedBytecodeIfExists • **_deployedBytecodeIfExists**? : *`Buffer`* -Defined in base-contract/lib/src/index.d.ts:32 +Defined in base-contract/lib/src/index.d.ts:31 ___ @@ -4906,7 +5700,7 @@ ___ -Defined in base-contract/lib/src/index.d.ts:28 +Defined in base-contract/lib/src/index.d.ts:27 ___ @@ -4916,7 +5710,7 @@ ___ -Defined in base-contract/lib/src/index.d.ts:29 +Defined in base-contract/lib/src/index.d.ts:28 ___ @@ -4926,7 +5720,7 @@ Args -Defined in base-contract/lib/src/index.d.ts:31 +Defined in base-contract/lib/src/index.d.ts:30 ___ @@ -4936,103 +5730,91 @@ ___ -Defined in base-contract/lib/src/index.d.ts:30 +Defined in base-contract/lib/src/index.d.ts:29 ## Methods -### getABIDecodedReturnData +### getLogsAsync + +▸ **getLogsAsync**<**ArgsType**>(`eventName`: [ERC1155ProxyEvents](#enumeration-erc1155proxyevents), `blockRange`: `BlockRange`, `indexFilterValues`: `IndexedFilterValues`): *`Promise>>`* -▸ **getABIDecodedReturnData**<**T**>(`methodName`: string, `callData`: string): *`T`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts:1513](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts#L1513)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/i_validator.ts:157](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/i_validator.ts#L157)* +Gets historical logs without creating a subscription **Type parameters:** -▪ **T** +▪ **ArgsType**: *[ERC1155ProxyEventArgs](#erc1155proxyeventargs)* **Parameters:** -Name | Type | ------- | ------ | -`methodName` | string | -`callData` | string | - -**Returns:** *`T`* - -___ - -### getABIDecodedTransactionData - -▸ **getABIDecodedTransactionData**<**T**>(`methodName`: string, `callData`: string): *`T`* - -*Defined in [abi-gen-wrappers/src/generated-wrappers/i_validator.ts:150](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/i_validator.ts#L150)* +Name | Type | Description | +------ | ------ | ------ | +`eventName` | [ERC1155ProxyEvents](#enumeration-erc1155proxyevents) | The ERC1155Proxy contract event you would like to subscribe to. | +`blockRange` | `BlockRange` | Block range to get logs from. | +`indexFilterValues` | `IndexedFilterValues` | An object where the keys are indexed args returned by the event and the value is the value you are interested in. E.g `{_from: aUserAddressHex}` | -**Type parameters:** +**Returns:** *`Promise>>`* -▪ **T** +Array of logs that match the parameters -**Parameters:** +___ -Name | Type | ------- | ------ | -`methodName` | string | -`callData` | string | +### subscribe -**Returns:** *`T`* +▸ **subscribe**<**ArgsType**>(`eventName`: [ERC1155ProxyEvents](#enumeration-erc1155proxyevents), `indexFilterValues`: `IndexedFilterValues`, `callback`: [EventCallback](#eventcallback)‹*`ArgsType`*›, `isVerbose`: boolean, `blockPollingIntervalMs?`: undefined | number): *string* -___ +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts:1471](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts#L1471)* -### getFunctionSignature +Subscribe to an event type emitted by the ERC1155Proxy contract. -▸ **getFunctionSignature**(`methodName`: string): *string* +**Type parameters:** -*Defined in [abi-gen-wrappers/src/generated-wrappers/i_validator.ts:144](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/i_validator.ts#L144)* +▪ **ArgsType**: *[ERC1155ProxyEventArgs](#erc1155proxyeventargs)* **Parameters:** -Name | Type | ------- | ------ | -`methodName` | string | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`eventName` | [ERC1155ProxyEvents](#enumeration-erc1155proxyevents) | - | The ERC1155Proxy contract event you would like to subscribe to. | +`indexFilterValues` | `IndexedFilterValues` | - | An object where the keys are indexed args returned by the event and the value is the value you are interested in. E.g `{maker: aUserAddressHex}` | +`callback` | [EventCallback](#eventcallback)‹*`ArgsType`*› | - | Callback that gets called when a log is added/removed | +`isVerbose` | boolean | false | Enable verbose subscription warnings (e.g recoverable network issues encountered) | +`blockPollingIntervalMs?` | undefined \| number | - | - | **Returns:** *string* +Subscription token used later to unsubscribe + ___ -### getSelector +### unsubscribe + +▸ **unsubscribe**(`subscriptionToken`: string): *void* -▸ **getSelector**(`methodName`: string): *string* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts:1496](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts#L1496)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/i_validator.ts:164](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/i_validator.ts#L164)* +Cancel a subscription **Parameters:** -Name | Type | ------- | ------ | -`methodName` | string | +Name | Type | Description | +------ | ------ | ------ | +`subscriptionToken` | string | Subscription token returned by `subscribe()` | -**Returns:** *string* +**Returns:** *void* ___ -### isValidSignature - -▸ **isValidSignature**(`hash`: string, `signerAddress`: string, `signature`: string): *`ContractFunctionObj`* - -*Defined in [abi-gen-wrappers/src/generated-wrappers/i_validator.ts:178](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/i_validator.ts#L178)* - -Verifies that a signature is valid. +### unsubscribeAll -**Parameters:** +▸ **unsubscribeAll**(): *void* -Name | Type | Description | ------- | ------ | ------ | -`hash` | string | Message hash that is signed. | -`signerAddress` | string | Address that should have signed the given hash. | -`signature` | string | Proof of signing. | +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts:1502](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts#L1502)* -**Returns:** *`ContractFunctionObj`* +Cancels all existing subscriptions -Magic bytes4 value if the signature is valid. Magic value is bytes4(keccak256("isValidValidatorSignature(address,bytes32,address,bytes)")) +**Returns:** *void* ___ @@ -5040,7 +5822,7 @@ ___ ▸ **ABI**(): *[ContractAbi](#contractabi)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/i_validator.ts:111](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/i_validator.ts#L111)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts:1255](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts#L1255)* **Returns:** *[ContractAbi](#contractabi)* @@ -5050,9 +5832,9 @@ ___ ### `Static` deployAsync -▸ **deployAsync**(`bytecode`: string, `abi`: [ContractAbi](#contractabi), `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object): *`Promise`* +▸ **deployAsync**(`bytecode`: string, `abi`: [ContractAbi](#contractabi), `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object): *`Promise`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/i_validator.ts:69](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/i_validator.ts#L69)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts:1213](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts#L1213)* **Parameters:** @@ -5064,15 +5846,15 @@ Name | Type | `txDefaults` | `Partial` | `logDecodeDependencies` | object | -**Returns:** *`Promise`* +**Returns:** *`Promise`* ___ ### `Static` deployFrom0xArtifactAsync -▸ **deployFrom0xArtifactAsync**(`artifact`: `ContractArtifact` | `SimpleContractArtifact`, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object): *`Promise`* +▸ **deployFrom0xArtifactAsync**(`artifact`: `ContractArtifact` | `SimpleContractArtifact`, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object): *`Promise`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/i_validator.ts:44](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/i_validator.ts#L44)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts:1188](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts#L1188)* **Parameters:** @@ -5083,7 +5865,7 @@ Name | Type | `txDefaults` | `Partial` | `logDecodeDependencies` | object | -**Returns:** *`Promise`* +**Returns:** *`Promise`* ___ @@ -5093,7 +5875,7 @@ ___ -Defined in base-contract/lib/src/index.d.ts:42 +Defined in base-contract/lib/src/index.d.ts:41 **Parameters:** @@ -5104,816 +5886,870 @@ Name | Type | **Returns:** *string* -
+## Object literals -# Class: IWalletContract +### addAuthorizedAddress +#### ▪ **addAuthorizedAddress**: *object* -## Constructors +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts:65](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts#L65)* +Authorizes an address. +#### awaitTransactionSuccessAsync -\+ **new IWalletContract**(`address`: string, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults?`: `Partial`, `logDecodeDependencies?`: undefined | object, `deployedBytecode`: string | undefined): *[IWalletContract](#class-iwalletcontract)* +▸ **awaitTransactionSuccessAsync**(`target`: string, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* -*Overrides void* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts:108](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts#L108)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/i_wallet.ts:224](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/i_wallet.ts#L224)* +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. **Parameters:** -Name | Type | Default | ------- | ------ | ------ | -`address` | string | - | -`supportedProvider` | [SupportedProvider](#supportedprovider) | - | -`txDefaults?` | `Partial` | - | -`logDecodeDependencies?` | undefined \| object | - | -`deployedBytecode` | string \| undefined | IWalletContract.deployedBytecode | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`target` | string | - | Address to authorize. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | -**Returns:** *[IWalletContract](#class-iwalletcontract)* +**Returns:** *`PromiseWithTransactionHash`* -## Properties +A promise that resolves when the transaction is successful -### `Optional` _deployedBytecodeIfExists +#### callAsync -• **_deployedBytecodeIfExists**? : *`Buffer`* +▸ **callAsync**(`target`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts:159](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts#L159)* +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. -Defined in base-contract/lib/src/index.d.ts:32 +**Parameters:** -___ +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`target` | string | - | Address to authorize. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -### abi +**Returns:** *`Promise`* -• **abi**: *[ContractAbi](#contractabi)* +#### estimateGasAsync +▸ **estimateGasAsync**(`target`: string, `txData?`: `Partial` | undefined): *`Promise`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts:134](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts#L134)* -Defined in base-contract/lib/src/index.d.ts:28 +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. -___ +**Parameters:** -### address +Name | Type | Description | +------ | ------ | ------ | +`target` | string | Address to authorize. | +`txData?` | `Partial` \| undefined | Additional data for transaction | -• **address**: *string* +**Returns:** *`Promise`* +The hash of the transaction +#### getABIEncodedTransactionData -Defined in base-contract/lib/src/index.d.ts:29 +▸ **getABIEncodedTransactionData**(`target`: string): *string* -___ +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts:203](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts#L203)* -Args +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). -• **constructorArgs**: *any[]* +**Parameters:** +Name | Type | Description | +------ | ------ | ------ | +`target` | string | Address to authorize. | +**Returns:** *string* -Defined in base-contract/lib/src/index.d.ts:31 +The ABI encoded transaction data as a string -___ +#### getSelector -### contractName +▸ **getSelector**(): *string* -• **contractName**: *string* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts:214](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts#L214)* +Returns the 4 byte function selector as a hex string. +**Returns:** *string* -Defined in base-contract/lib/src/index.d.ts:30 +#### sendTransactionAsync -## Methods +▸ **sendTransactionAsync**(`target`: string, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* -### getABIDecodedReturnData +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts:73](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts#L73)* -▸ **getABIDecodedReturnData**<**T**>(`methodName`: string, `callData`: string): *`T`* +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. -*Defined in [abi-gen-wrappers/src/generated-wrappers/i_wallet.ts:153](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/i_wallet.ts#L153)* +**Parameters:** -**Type parameters:** +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`target` | string | - | Address to authorize. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | -▪ **T** +**Returns:** *`Promise`* -**Parameters:** +The hash of the transaction -Name | Type | ------- | ------ | -`methodName` | string | -`callData` | string | +___ -**Returns:** *`T`* +### authorities -___ +#### ▪ **authorities**: *object* -### getABIDecodedTransactionData +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts:220](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts#L220)* -▸ **getABIDecodedTransactionData**<**T**>(`methodName`: string, `callData`: string): *`T`* +#### callAsync -*Defined in [abi-gen-wrappers/src/generated-wrappers/i_wallet.ts:146](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/i_wallet.ts#L146)* +▸ **callAsync**(`index_0`: `BigNumber`, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -**Type parameters:** +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts:226](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts#L226)* -▪ **T** +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | ------- | ------ | -`methodName` | string | -`callData` | string | +Name | Type | Default | +------ | ------ | ------ | +`index_0` | `BigNumber` | - | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | -**Returns:** *`T`* +**Returns:** *`Promise`* ___ -### getFunctionSignature +### authorized -▸ **getFunctionSignature**(`methodName`: string): *string* +#### ▪ **authorized**: *object* -*Defined in [abi-gen-wrappers/src/generated-wrappers/i_wallet.ts:140](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/i_wallet.ts#L140)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts:268](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts#L268)* -**Parameters:** +#### callAsync -Name | Type | ------- | ------ | -`methodName` | string | +▸ **callAsync**(`index_0`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -**Returns:** *string* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts:274](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts#L274)* -___ +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** -### getSelector +Name | Type | Default | +------ | ------ | ------ | +`index_0` | string | - | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | -▸ **getSelector**(`methodName`: string): *string* +**Returns:** *`Promise`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/i_wallet.ts:160](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/i_wallet.ts#L160)* +___ -**Parameters:** +### getAuthorizedAddresses -Name | Type | ------- | ------ | -`methodName` | string | +#### ▪ **getAuthorizedAddresses**: *object* -**Returns:** *string* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts:319](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts#L319)* -___ +Gets all authorized addresses. -### isValidSignature +#### callAsync -▸ **isValidSignature**(`hash`: string, `signature`: string): *`ContractFunctionObj`* +▸ **callAsync**(`callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/i_wallet.ts:173](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/i_wallet.ts#L173)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts:326](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts#L326)* -Validates a hash with the `Wallet` signature type. +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | Description | +Name | Type | Default | ------ | ------ | ------ | -`hash` | string | Message hash that is signed. | -`signature` | string | Proof of signing. | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | -**Returns:** *`ContractFunctionObj`* +**Returns:** *`Promise`* -magicValue `bytes4(0xb0671381)` if the signature check succeeds. +Array of authorized addresses. ___ -### `Static` ABI - -▸ **ABI**(): *[ContractAbi](#contractabi)* +### getProxyId -*Defined in [abi-gen-wrappers/src/generated-wrappers/i_wallet.ts:111](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/i_wallet.ts#L111)* +#### ▪ **getProxyId**: *object* -**Returns:** *[ContractAbi](#contractabi)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts:366](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts#L366)* -The contract ABI +Gets the proxy id associated with the proxy address. -___ +#### callAsync -### `Static` deployAsync +▸ **callAsync**(`callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -▸ **deployAsync**(`bytecode`: string, `abi`: [ContractAbi](#contractabi), `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object): *`Promise`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts:373](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts#L373)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/i_wallet.ts:69](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/i_wallet.ts#L69)* +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | ------- | ------ | -`bytecode` | string | -`abi` | [ContractAbi](#contractabi) | -`supportedProvider` | [SupportedProvider](#supportedprovider) | -`txDefaults` | `Partial` | -`logDecodeDependencies` | object | +Name | Type | Default | +------ | ------ | ------ | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | -**Returns:** *`Promise`* +**Returns:** *`Promise`* + +Proxy id. ___ -### `Static` deployFrom0xArtifactAsync +### owner -▸ **deployFrom0xArtifactAsync**(`artifact`: `ContractArtifact` | `SimpleContractArtifact`, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object): *`Promise`* +#### ▪ **owner**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts:402](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts#L402)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/i_wallet.ts:44](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/i_wallet.ts#L44)* +#### callAsync + +▸ **callAsync**(`callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts:408](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts#L408)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | ------- | ------ | -`artifact` | `ContractArtifact` \| `SimpleContractArtifact` | -`supportedProvider` | [SupportedProvider](#supportedprovider) | -`txDefaults` | `Partial` | -`logDecodeDependencies` | object | +Name | Type | Default | +------ | ------ | ------ | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | -**Returns:** *`Promise`* +**Returns:** *`Promise`* ___ -### `Static` strictArgumentEncodingCheck - -▸ **strictArgumentEncodingCheck**(`inputAbi`: `DataItem`[], `args`: any[]): *string* +### removeAuthorizedAddress +#### ▪ **removeAuthorizedAddress**: *object* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts:448](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts#L448)* -Defined in base-contract/lib/src/index.d.ts:42 +Removes authorizion of an address. -**Parameters:** +#### awaitTransactionSuccessAsync -Name | Type | ------- | ------ | -`inputAbi` | `DataItem`[] | -`args` | any[] | +▸ **awaitTransactionSuccessAsync**(`target`: string, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* -**Returns:** *string* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts:491](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts#L491)* -
+Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. -# Class: OrderValidatorContract +**Parameters:** +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`target` | string | - | Address to remove authorization from. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | -## Constructors +**Returns:** *`PromiseWithTransactionHash`* +A promise that resolves when the transaction is successful +#### callAsync -\+ **new OrderValidatorContract**(`address`: string, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults?`: `Partial`, `logDecodeDependencies?`: undefined | object, `deployedBytecode`: string | undefined): *[OrderValidatorContract](#class-ordervalidatorcontract)* +▸ **callAsync**(`target`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -*Overrides void* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts:542](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts#L542)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/order_validator.ts:1338](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/order_validator.ts#L1338)* +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | Default | ------- | ------ | ------ | -`address` | string | - | -`supportedProvider` | [SupportedProvider](#supportedprovider) | - | -`txDefaults?` | `Partial` | - | -`logDecodeDependencies?` | undefined \| object | - | -`deployedBytecode` | string \| undefined | OrderValidatorContract.deployedBytecode | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`target` | string | - | Address to remove authorization from. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -**Returns:** *[OrderValidatorContract](#class-ordervalidatorcontract)* +**Returns:** *`Promise`* -## Properties +#### estimateGasAsync -### `Optional` _deployedBytecodeIfExists +▸ **estimateGasAsync**(`target`: string, `txData?`: `Partial` | undefined): *`Promise`* -• **_deployedBytecodeIfExists**? : *`Buffer`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts:517](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts#L517)* +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. +**Parameters:** -Defined in base-contract/lib/src/index.d.ts:32 +Name | Type | Description | +------ | ------ | ------ | +`target` | string | Address to remove authorization from. | +`txData?` | `Partial` \| undefined | Additional data for transaction | -___ +**Returns:** *`Promise`* -### abi +The hash of the transaction -• **abi**: *[ContractAbi](#contractabi)* +#### getABIEncodedTransactionData +▸ **getABIEncodedTransactionData**(`target`: string): *string* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts:586](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts#L586)* -Defined in base-contract/lib/src/index.d.ts:28 +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). -___ +**Parameters:** -### address +Name | Type | Description | +------ | ------ | ------ | +`target` | string | Address to remove authorization from. | -• **address**: *string* +**Returns:** *string* +The ABI encoded transaction data as a string +#### getSelector -Defined in base-contract/lib/src/index.d.ts:29 +▸ **getSelector**(): *string* -___ +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts:597](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts#L597)* -Args +Returns the 4 byte function selector as a hex string. -• **constructorArgs**: *any[]* +**Returns:** *string* +#### sendTransactionAsync +▸ **sendTransactionAsync**(`target`: string, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* -Defined in base-contract/lib/src/index.d.ts:31 +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts:456](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts#L456)* -___ +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. -### contractName +**Parameters:** -• **contractName**: *string* +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`target` | string | - | Address to remove authorization from. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | +**Returns:** *`Promise`* +The hash of the transaction -Defined in base-contract/lib/src/index.d.ts:30 +___ -## Methods +### removeAuthorizedAddressAtIndex -### getABIDecodedReturnData +#### ▪ **removeAuthorizedAddressAtIndex**: *object* -▸ **getABIDecodedReturnData**<**T**>(`methodName`: string, `callData`: string): *`T`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts:606](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts#L606)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/order_validator.ts:703](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/order_validator.ts#L703)* +Removes authorizion of an address. -**Type parameters:** +#### awaitTransactionSuccessAsync -▪ **T** +▸ **awaitTransactionSuccessAsync**(`target`: string, `index`: `BigNumber`, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* -**Parameters:** +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts:656](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts#L656)* -Name | Type | ------- | ------ | -`methodName` | string | -`callData` | string | +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. -**Returns:** *`T`* +**Parameters:** -___ +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`target` | string | - | Address to remove authorization from. | +`index` | `BigNumber` | - | Index of target in authorities array. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | -### getABIDecodedTransactionData +**Returns:** *`PromiseWithTransactionHash`* -▸ **getABIDecodedTransactionData**<**T**>(`methodName`: string, `callData`: string): *`T`* +A promise that resolves when the transaction is successful -*Defined in [abi-gen-wrappers/src/generated-wrappers/order_validator.ts:696](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/order_validator.ts#L696)* +#### callAsync -**Type parameters:** +▸ **callAsync**(`target`: string, `index`: `BigNumber`, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -▪ **T** +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts:724](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts#L724)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | ------- | ------ | -`methodName` | string | -`callData` | string | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`target` | string | - | Address to remove authorization from. | +`index` | `BigNumber` | - | Index of target in authorities array. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -**Returns:** *`T`* +**Returns:** *`Promise`* -___ +#### estimateGasAsync -### getBalanceAndAllowance +▸ **estimateGasAsync**(`target`: string, `index`: `BigNumber`, `txData?`: `Partial` | undefined): *`Promise`* -▸ **getBalanceAndAllowance**(`target`: string, `assetData`: string): *`ContractFunctionObj<[BigNumber, BigNumber]>`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts:690](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts#L690)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/order_validator.ts:835](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/order_validator.ts#L835)* +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. **Parameters:** -Name | Type | ------- | ------ | -`target` | string | -`assetData` | string | +Name | Type | Description | +------ | ------ | ------ | +`target` | string | Address to remove authorization from. | +`index` | `BigNumber` | Index of target in authorities array. | +`txData?` | `Partial` \| undefined | Additional data for transaction | -**Returns:** *`ContractFunctionObj<[BigNumber, BigNumber]>`* +**Returns:** *`Promise`* -___ +The hash of the transaction -### getBalancesAndAllowances +#### getABIEncodedTransactionData -▸ **getBalancesAndAllowances**(`target`: string, `assetData`: string[]): *`ContractFunctionObj<[BigNumber[], BigNumber[]]>`* +▸ **getABIEncodedTransactionData**(`target`: string, `index`: `BigNumber`): *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/order_validator.ts:1175](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/order_validator.ts#L1175)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts:778](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts#L778)* -**Parameters:** +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). -Name | Type | ------- | ------ | -`target` | string | -`assetData` | string[] | +**Parameters:** -**Returns:** *`ContractFunctionObj<[BigNumber[], BigNumber[]]>`* +Name | Type | Description | +------ | ------ | ------ | +`target` | string | Address to remove authorization from. | +`index` | `BigNumber` | Index of target in authorities array. | -___ +**Returns:** *string* -### getERC721TokenOwner +The ABI encoded transaction data as a string -▸ **getERC721TokenOwner**(`token`: string, `tokenId`: `BigNumber`): *`ContractFunctionObj`* +#### getSelector -*Defined in [abi-gen-wrappers/src/generated-wrappers/order_validator.ts:1120](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/order_validator.ts#L1120)* +▸ **getSelector**(): *string* -**Parameters:** +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts:791](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts#L791)* -Name | Type | ------- | ------ | -`token` | string | -`tokenId` | `BigNumber` | +Returns the 4 byte function selector as a hex string. -**Returns:** *`ContractFunctionObj`* +**Returns:** *string* -___ +#### sendTransactionAsync -### getFunctionSignature +▸ **sendTransactionAsync**(`target`: string, `index`: `BigNumber`, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* -▸ **getFunctionSignature**(`methodName`: string): *string* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts:615](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts#L615)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/order_validator.ts:690](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/order_validator.ts#L690)* +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. **Parameters:** -Name | Type | ------- | ------ | -`methodName` | string | - -**Returns:** *string* +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`target` | string | - | Address to remove authorization from. | +`index` | `BigNumber` | - | Index of target in authorities array. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | -___ +**Returns:** *`Promise`* -### getOrderAndTraderInfo +The hash of the transaction -▸ **getOrderAndTraderInfo**(`order`: object, `takerAddress`: string): *`ContractFunctionObj<[object, object]>`* +___ -*Defined in [abi-gen-wrappers/src/generated-wrappers/order_validator.ts:717](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/order_validator.ts#L717)* +### transferFrom -**Parameters:** +#### ▪ **transferFrom**: *object* -Name | Type | ------- | ------ | -`order` | object | -`takerAddress` | string | +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts:800](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts#L800)* -**Returns:** *`ContractFunctionObj<[object, object]>`* +Transfers batch of ERC1155 assets. Either succeeds or throws. -___ +#### awaitTransactionSuccessAsync -### getOrdersAndTradersInfo +▸ **awaitTransactionSuccessAsync**(`assetData`: string, `from`: string, `to`: string, `amount`: `BigNumber`, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* -▸ **getOrdersAndTradersInfo**(`orders`: `Array`, `takerAddresses`: string[]): *`ContractFunctionObj<[Array, Array]>`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts:864](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts#L864)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/order_validator.ts:893](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/order_validator.ts#L893)* +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. **Parameters:** -Name | Type | ------- | ------ | -`orders` | `Array` | -`takerAddresses` | string[] | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`assetData` | string | - | Byte array encoded with ERC1155 token address, array of ids, array of values, and callback data. | +`from` | string | - | Address to transfer assets from. | +`to` | string | - | Address to transfer assets to. | +`amount` | `BigNumber` | - | Amount that will be multiplied with each element of `assetData.values` to scale the values that will be transferred. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* -**Returns:** *`ContractFunctionObj<[Array, Array]>`* +A promise that resolves when the transaction is successful -___ +#### callAsync -### getSelector +▸ **callAsync**(`assetData`: string, `from`: string, `to`: string, `amount`: `BigNumber`, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -▸ **getSelector**(`methodName`: string): *string* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts:952](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts#L952)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/order_validator.ts:710](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/order_validator.ts#L710)* +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | ------- | ------ | -`methodName` | string | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`assetData` | string | - | Byte array encoded with ERC1155 token address, array of ids, array of values, and callback data. | +`from` | string | - | Address to transfer assets from. | +`to` | string | - | Address to transfer assets to. | +`amount` | `BigNumber` | - | Amount that will be multiplied with each element of `assetData.values` to scale the values that will be transferred. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -**Returns:** *string* +**Returns:** *`Promise`* -___ +#### estimateGasAsync -### getTraderInfo +▸ **estimateGasAsync**(`assetData`: string, `from`: string, `to`: string, `amount`: `BigNumber`, `txData?`: `Partial` | undefined): *`Promise`* -▸ **getTraderInfo**(`order`: object, `takerAddress`: string): *`ContractFunctionObj`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts:908](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts#L908)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/order_validator.ts:1236](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/order_validator.ts#L1236)* +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. **Parameters:** -Name | Type | ------- | ------ | -`order` | object | -`takerAddress` | string | +Name | Type | Description | +------ | ------ | ------ | +`assetData` | string | Byte array encoded with ERC1155 token address, array of ids, array of values, and callback data. | +`from` | string | Address to transfer assets from. | +`to` | string | Address to transfer assets to. | +`amount` | `BigNumber` | Amount that will be multiplied with each element of `assetData.values` to scale the values that will be transferred. | +`txData?` | `Partial` \| undefined | Additional data for transaction | -**Returns:** *`ContractFunctionObj`* +**Returns:** *`Promise`* -___ +The hash of the transaction -### getTradersInfo +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`assetData`: string, `from`: string, `to`: string, `amount`: `BigNumber`): *string* -▸ **getTradersInfo**(`orders`: `Array`, `takerAddresses`: string[]): *`ContractFunctionObj>`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts:1016](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts#L1016)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/order_validator.ts:1011](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/order_validator.ts#L1011)* +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). **Parameters:** -Name | Type | ------- | ------ | -`orders` | `Array` | -`takerAddresses` | string[] | +Name | Type | Description | +------ | ------ | ------ | +`assetData` | string | Byte array encoded with ERC1155 token address, array of ids, array of values, and callback data. | +`from` | string | Address to transfer assets from. | +`to` | string | Address to transfer assets to. | +`amount` | `BigNumber` | Amount that will be multiplied with each element of `assetData.values` to scale the values that will be transferred. | -**Returns:** *`ContractFunctionObj>`* +**Returns:** *string* -___ +The ABI encoded transaction data as a string -### `Static` ABI +#### getSelector -▸ **ABI**(): *[ContractAbi](#contractabi)* +▸ **getSelector**(): *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/order_validator.ts:127](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/order_validator.ts#L127)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts:1031](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts#L1031)* -**Returns:** *[ContractAbi](#contractabi)* +Returns the 4 byte function selector as a hex string. -The contract ABI +**Returns:** *string* -___ +#### sendTransactionAsync -### `Static` deployAsync +▸ **sendTransactionAsync**(`assetData`: string, `from`: string, `to`: string, `amount`: `BigNumber`, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* -▸ **deployAsync**(`bytecode`: string, `abi`: [ContractAbi](#contractabi), `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object, `_exchange`: string, `_zrxAssetData`: string): *`Promise`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts:813](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts#L813)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/order_validator.ts:79](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/order_validator.ts#L79)* +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. **Parameters:** -Name | Type | ------- | ------ | -`bytecode` | string | -`abi` | [ContractAbi](#contractabi) | -`supportedProvider` | [SupportedProvider](#supportedprovider) | -`txDefaults` | `Partial` | -`logDecodeDependencies` | object | -`_exchange` | string | -`_zrxAssetData` | string | - -**Returns:** *`Promise`* - -___ - -### `Static` deployFrom0xArtifactAsync - -▸ **deployFrom0xArtifactAsync**(`artifact`: `ContractArtifact` | `SimpleContractArtifact`, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object, `_exchange`: string, `_zrxAssetData`: string): *`Promise`* - -*Defined in [abi-gen-wrappers/src/generated-wrappers/order_validator.ts:44](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/order_validator.ts#L44)* - -**Parameters:** +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`assetData` | string | - | Byte array encoded with ERC1155 token address, array of ids, array of values, and callback data. | +`from` | string | - | Address to transfer assets from. | +`to` | string | - | Address to transfer assets to. | +`amount` | `BigNumber` | - | Amount that will be multiplied with each element of `assetData.values` to scale the values that will be transferred. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | -Name | Type | ------- | ------ | -`artifact` | `ContractArtifact` \| `SimpleContractArtifact` | -`supportedProvider` | [SupportedProvider](#supportedprovider) | -`txDefaults` | `Partial` | -`logDecodeDependencies` | object | -`_exchange` | string | -`_zrxAssetData` | string | +**Returns:** *`Promise`* -**Returns:** *`Promise`* +The hash of the transaction ___ -### `Static` strictArgumentEncodingCheck - -▸ **strictArgumentEncodingCheck**(`inputAbi`: `DataItem`[], `args`: any[]): *string* - +### transferOwnership +#### ▪ **transferOwnership**: *object* -Defined in base-contract/lib/src/index.d.ts:42 +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts:1037](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts#L1037)* -**Parameters:** +#### awaitTransactionSuccessAsync -Name | Type | ------- | ------ | -`inputAbi` | `DataItem`[] | -`args` | any[] | +▸ **awaitTransactionSuccessAsync**(`newOwner`: string, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* -**Returns:** *string* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts:1078](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts#L1078)* -
+Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. -# Class: WETH9Contract +**Parameters:** +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`newOwner` | string | - | - | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | -## Constructors +**Returns:** *`PromiseWithTransactionHash`* +A promise that resolves when the transaction is successful +#### callAsync -\+ **new WETH9Contract**(`address`: string, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults?`: `Partial`, `logDecodeDependencies?`: undefined | object, `deployedBytecode`: string | undefined): *[WETH9Contract](#class-weth9contract)* +▸ **callAsync**(`newOwner`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -*Overrides void* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts:1127](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts#L1127)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:1381](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L1381)* +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** Name | Type | Default | ------ | ------ | ------ | -`address` | string | - | -`supportedProvider` | [SupportedProvider](#supportedprovider) | - | -`txDefaults?` | `Partial` | - | -`logDecodeDependencies?` | undefined \| object | - | -`deployedBytecode` | string \| undefined | WETH9Contract.deployedBytecode | - -**Returns:** *[WETH9Contract](#class-weth9contract)* - -## Properties - -### `Optional` _deployedBytecodeIfExists +`newOwner` | string | - | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | -• **_deployedBytecodeIfExists**? : *`Buffer`* +**Returns:** *`Promise`* +#### estimateGasAsync +▸ **estimateGasAsync**(`newOwner`: string, `txData?`: `Partial` | undefined): *`Promise`* -Defined in base-contract/lib/src/index.d.ts:32 +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts:1103](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts#L1103)* -___ +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. -### abi +**Parameters:** -• **abi**: *[ContractAbi](#contractabi)* +Name | Type | Description | +------ | ------ | ------ | +`newOwner` | string | - | +`txData?` | `Partial` \| undefined | Additional data for transaction | +**Returns:** *`Promise`* +The hash of the transaction -Defined in base-contract/lib/src/index.d.ts:28 +#### getABIEncodedTransactionData -___ +▸ **getABIEncodedTransactionData**(`newOwner`: string): *string* -### address +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts:1170](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts#L1170)* -• **address**: *string* +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). +**Parameters:** +Name | Type | +------ | ------ | +`newOwner` | string | -Defined in base-contract/lib/src/index.d.ts:29 +**Returns:** *string* -___ +The ABI encoded transaction data as a string -Args +#### getSelector -• **constructorArgs**: *any[]* +▸ **getSelector**(): *string* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts:1181](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts#L1181)* +Returns the 4 byte function selector as a hex string. -Defined in base-contract/lib/src/index.d.ts:31 +**Returns:** *string* -___ +#### sendTransactionAsync -### contractName +▸ **sendTransactionAsync**(`newOwner`: string, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* -• **contractName**: *string* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts:1044](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts#L1044)* +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. +**Parameters:** -Defined in base-contract/lib/src/index.d.ts:30 +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`newOwner` | string | - | - | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | -## Methods +**Returns:** *`Promise`* -### allowance +The hash of the transaction -▸ **allowance**(`index_0`: string, `index_1`: string): *`ContractFunctionObj`* +
-*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:1258](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L1258)* +# Class: ERC20ProxyContract -**Parameters:** -Name | Type | ------- | ------ | -`index_0` | string | -`index_1` | string | +## Constructors -**Returns:** *`ContractFunctionObj`* -___ -### approve +\+ **new ERC20ProxyContract**(`address`: string, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults?`: `Partial`, `logDecodeDependencies?`: undefined | object, `deployedBytecode`: string | undefined): *[ERC20ProxyContract](#class-erc20proxycontract)* -▸ **approve**(`guy`: string, `wad`: `BigNumber`): *`ContractTxFunctionObj`* +*Overrides void* -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:512](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L512)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts:1270](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts#L1270)* **Parameters:** -Name | Type | ------- | ------ | -`guy` | string | -`wad` | `BigNumber` | - -**Returns:** *`ContractTxFunctionObj`* +Name | Type | Default | +------ | ------ | ------ | +`address` | string | - | +`supportedProvider` | [SupportedProvider](#supportedprovider) | - | +`txDefaults?` | `Partial` | - | +`logDecodeDependencies?` | undefined \| object | - | +`deployedBytecode` | string \| undefined | ERC20ProxyContract.deployedBytecode | -___ +**Returns:** *[ERC20ProxyContract](#class-erc20proxycontract)* -### balanceOf +## Properties -▸ **balanceOf**(`index_0`: string): *`ContractFunctionObj`* +#### `Optional` _deployedBytecodeIfExists -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:946](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L946)* +• **_deployedBytecodeIfExists**? : *`Buffer`* -**Parameters:** -Name | Type | ------- | ------ | -`index_0` | string | -**Returns:** *`ContractFunctionObj`* +Defined in base-contract/lib/src/index.d.ts:31 ___ -### decimals - -▸ **decimals**(): *`ContractFunctionObj`* - -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:899](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L899)* - -**Returns:** *`ContractFunctionObj`* - -___ +### abi -### deposit +• **abi**: *[ContractAbi](#contractabi)* -▸ **deposit**(): *`ContractTxFunctionObj`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:1153](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L1153)* -**Returns:** *`ContractTxFunctionObj`* +Defined in base-contract/lib/src/index.d.ts:27 ___ -### getABIDecodedReturnData - -▸ **getABIDecodedReturnData**<**T**>(`methodName`: string, `callData`: string): *`T`* - -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:451](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L451)* - -**Type parameters:** +### address -▪ **T** +• **address**: *string* -**Parameters:** -Name | Type | ------- | ------ | -`methodName` | string | -`callData` | string | -**Returns:** *`T`* +Defined in base-contract/lib/src/index.d.ts:28 ___ -### getABIDecodedTransactionData - -▸ **getABIDecodedTransactionData**<**T**>(`methodName`: string, `callData`: string): *`T`* - -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:444](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L444)* - -**Type parameters:** +Args -▪ **T** +• **constructorArgs**: *any[]* -**Parameters:** -Name | Type | ------- | ------ | -`methodName` | string | -`callData` | string | -**Returns:** *`T`* +Defined in base-contract/lib/src/index.d.ts:30 ___ -### getFunctionSignature - -▸ **getFunctionSignature**(`methodName`: string): *string* +### contractName -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:438](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L438)* +• **contractName**: *string* -**Parameters:** -Name | Type | ------- | ------ | -`methodName` | string | -**Returns:** *string* +Defined in base-contract/lib/src/index.d.ts:29 -___ +## Methods ### getLogsAsync -▸ **getLogsAsync**<**ArgsType**>(`eventName`: [WETH9Events](#enumeration-weth9events), `blockRange`: `BlockRange`, `indexFilterValues`: `IndexedFilterValues`): *`Promise>>`* +▸ **getLogsAsync**<**ArgsType**>(`eventName`: [ERC20ProxyEvents](#enumeration-erc20proxyevents), `blockRange`: `BlockRange`, `indexFilterValues`: `IndexedFilterValues`): *`Promise>>`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:1365](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L1365)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts:1254](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts#L1254)* Gets historical logs without creating a subscription **Type parameters:** -▪ **ArgsType**: *[WETH9EventArgs](#weth9eventargs)* +▪ **ArgsType**: *[ERC20ProxyEventArgs](#erc20proxyeventargs)* **Parameters:** Name | Type | Description | ------ | ------ | ------ | -`eventName` | [WETH9Events](#enumeration-weth9events) | The WETH9 contract event you would like to subscribe to. | +`eventName` | [ERC20ProxyEvents](#enumeration-erc20proxyevents) | The ERC20Proxy contract event you would like to subscribe to. | `blockRange` | `BlockRange` | Block range to get logs from. | `indexFilterValues` | `IndexedFilterValues` | An object where the keys are indexed args returned by the event and the value is the value you are interested in. E.g `{_from: aUserAddressHex}` | @@ -5923,49 +6759,23 @@ Array of logs that match the parameters ___ -### getSelector - -▸ **getSelector**(`methodName`: string): *string* - -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:458](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L458)* - -**Parameters:** - -Name | Type | ------- | ------ | -`methodName` | string | - -**Returns:** *string* - -___ - -### name - -▸ **name**(): *`ContractFunctionObj`* - -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:465](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L465)* - -**Returns:** *`ContractFunctionObj`* - -___ - ### subscribe -▸ **subscribe**<**ArgsType**>(`eventName`: [WETH9Events](#enumeration-weth9events), `indexFilterValues`: `IndexedFilterValues`, `callback`: [EventCallback](#eventcallback)‹*`ArgsType`*›, `isVerbose`: boolean, `blockPollingIntervalMs?`: undefined | number): *string* +▸ **subscribe**<**ArgsType**>(`eventName`: [ERC20ProxyEvents](#enumeration-erc20proxyevents), `indexFilterValues`: `IndexedFilterValues`, `callback`: [EventCallback](#eventcallback)‹*`ArgsType`*›, `isVerbose`: boolean, `blockPollingIntervalMs?`: undefined | number): *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:1323](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L1323)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts:1212](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts#L1212)* -Subscribe to an event type emitted by the WETH9 contract. +Subscribe to an event type emitted by the ERC20Proxy contract. **Type parameters:** -▪ **ArgsType**: *[WETH9EventArgs](#weth9eventargs)* +▪ **ArgsType**: *[ERC20ProxyEventArgs](#erc20proxyeventargs)* **Parameters:** Name | Type | Default | Description | ------ | ------ | ------ | ------ | -`eventName` | [WETH9Events](#enumeration-weth9events) | - | The WETH9 contract event you would like to subscribe to. | +`eventName` | [ERC20ProxyEvents](#enumeration-erc20proxyevents) | - | The ERC20Proxy contract event you would like to subscribe to. | `indexFilterValues` | `IndexedFilterValues` | - | An object where the keys are indexed args returned by the event and the value is the value you are interested in. E.g `{maker: aUserAddressHex}` | `callback` | [EventCallback](#eventcallback)‹*`ArgsType`*› | - | Callback that gets called when a log is added/removed | `isVerbose` | boolean | false | Enable verbose subscription warnings (e.g recoverable network issues encountered) | @@ -5977,66 +6787,11 @@ Subscription token used later to unsubscribe ___ -### symbol - -▸ **symbol**(): *`ContractFunctionObj`* - -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:996](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L996)* - -**Returns:** *`ContractFunctionObj`* - -___ - -### totalSupply - -▸ **totalSupply**(): *`ContractFunctionObj`* - -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:622](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L622)* - -**Returns:** *`ContractFunctionObj`* - -___ - -### transfer - -▸ **transfer**(`dst`: string, `wad`: `BigNumber`): *`ContractTxFunctionObj`* - -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:1043](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L1043)* - -**Parameters:** - -Name | Type | ------- | ------ | -`dst` | string | -`wad` | `BigNumber` | - -**Returns:** *`ContractTxFunctionObj`* - -___ - -### transferFrom - -▸ **transferFrom**(`src`: string, `dst`: string, `wad`: `BigNumber`): *`ContractTxFunctionObj`* - -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:669](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L669)* - -**Parameters:** - -Name | Type | ------- | ------ | -`src` | string | -`dst` | string | -`wad` | `BigNumber` | - -**Returns:** *`ContractTxFunctionObj`* - -___ - ### unsubscribe ▸ **unsubscribe**(`subscriptionToken`: string): *void* -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:1348](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L1348)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts:1237](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts#L1237)* Cancel a subscription @@ -6054,7 +6809,7 @@ ___ ▸ **unsubscribeAll**(): *void* -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:1354](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L1354)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts:1243](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts#L1243)* Cancels all existing subscriptions @@ -6062,27 +6817,11 @@ Cancels all existing subscriptions ___ -### withdraw - -▸ **withdraw**(`wad`: `BigNumber`): *`ContractTxFunctionObj`* - -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:793](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L793)* - -**Parameters:** - -Name | Type | ------- | ------ | -`wad` | `BigNumber` | - -**Returns:** *`ContractTxFunctionObj`* - -___ - ### `Static` ABI ▸ **ABI**(): *[ContractAbi](#contractabi)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:149](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L149)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts:1015](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts#L1015)* **Returns:** *[ContractAbi](#contractabi)* @@ -6092,9 +6831,9 @@ ___ ### `Static` deployAsync -▸ **deployAsync**(`bytecode`: string, `abi`: [ContractAbi](#contractabi), `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object): *`Promise`* +▸ **deployAsync**(`bytecode`: string, `abi`: [ContractAbi](#contractabi), `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object): *`Promise`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:107](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L107)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts:973](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts#L973)* **Parameters:** @@ -6106,15 +6845,15 @@ Name | Type | `txDefaults` | `Partial` | `logDecodeDependencies` | object | -**Returns:** *`Promise`* +**Returns:** *`Promise`* ___ ### `Static` deployFrom0xArtifactAsync -▸ **deployFrom0xArtifactAsync**(`artifact`: `ContractArtifact` | `SimpleContractArtifact`, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object): *`Promise`* +▸ **deployFrom0xArtifactAsync**(`artifact`: `ContractArtifact` | `SimpleContractArtifact`, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object): *`Promise`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:82](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L82)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts:948](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts#L948)* **Parameters:** @@ -6125,7 +6864,7 @@ Name | Type | `txDefaults` | `Partial` | `logDecodeDependencies` | object | -**Returns:** *`Promise`* +**Returns:** *`Promise`* ___ @@ -6135,7 +6874,7 @@ ___ -Defined in base-contract/lib/src/index.d.ts:42 +Defined in base-contract/lib/src/index.d.ts:41 **Parameters:** @@ -6146,1851 +6885,12018 @@ Name | Type | **Returns:** *string* -
- -# Class: ContractWrappers +## Object literals -The ContractWrappers class contains smart contract wrappers helpful when building on 0x protocol. +### addAuthorizedAddress +#### ▪ **addAuthorizedAddress**: *object* -## Constructors +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts:65](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts#L65)* +Authorizes an address. +#### awaitTransactionSuccessAsync -\+ **new ContractWrappers**(`supportedProvider`: [SupportedProvider](#supportedprovider), `config`: [ContractWrappersConfig](#interface-contractwrappersconfig)): *[ContractWrappers](#class-contractwrappers)* +▸ **awaitTransactionSuccessAsync**(`target`: string, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* -*Defined in [contract-wrappers/src/contract_wrappers.ts:66](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-wrappers/src/contract_wrappers.ts#L66)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts:108](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts#L108)* -Instantiates a new ContractWrappers instance. +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. **Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`supportedProvider` | [SupportedProvider](#supportedprovider) | The Provider instance you would like the contract-wrappers library to use for interacting with the Ethereum network. | -`config` | [ContractWrappersConfig](#interface-contractwrappersconfig) | The configuration object. Look up the type for the description. | - -**Returns:** *[ContractWrappers](#class-contractwrappers)* - -An instance of the ContractWrappers class. +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`target` | string | - | Address to authorize. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | -## Properties +**Returns:** *`PromiseWithTransactionHash`* -### contractAddresses +A promise that resolves when the transaction is successful -• **contractAddresses**: *`ContractAddresses`* +#### callAsync -*Defined in [contract-wrappers/src/contract_wrappers.ts:38](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-wrappers/src/contract_wrappers.ts#L38)* +▸ **callAsync**(`target`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -An index of the default contract addresses for this chain. +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts:159](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts#L159)* -___ +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. -### coordinator +**Parameters:** -• **coordinator**: *[CoordinatorWrapper](#class-coordinatorwrapper)* +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`target` | string | - | Address to authorize. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -*Defined in [contract-wrappers/src/contract_wrappers.ts:64](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-wrappers/src/contract_wrappers.ts#L64)* +**Returns:** *`Promise`* -An instance of the CoordinatorWrapper class containing methods for interacting with the Coordinator extension contract. +#### estimateGasAsync -___ +▸ **estimateGasAsync**(`target`: string, `txData?`: `Partial` | undefined): *`Promise`* -### devUtils +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts:134](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts#L134)* -• **devUtils**: *`DevUtilsContract`* +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. -*Defined in [contract-wrappers/src/contract_wrappers.ts:60](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-wrappers/src/contract_wrappers.ts#L60)* +**Parameters:** -An instance of the DevUtilsContract class containing methods for interacting with the DevUtils smart contract. +Name | Type | Description | +------ | ------ | ------ | +`target` | string | Address to authorize. | +`txData?` | `Partial` \| undefined | Additional data for transaction | -___ +**Returns:** *`Promise`* -### exchange +The hash of the transaction -• **exchange**: *`ExchangeContract`* +#### getABIEncodedTransactionData -*Defined in [contract-wrappers/src/contract_wrappers.ts:42](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-wrappers/src/contract_wrappers.ts#L42)* +▸ **getABIEncodedTransactionData**(`target`: string): *string* -An instance of the ExchangeContract class containing methods for interacting with the 0x Exchange smart contract. +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts:203](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts#L203)* -___ +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). -### forwarder +**Parameters:** -• **forwarder**: *`ForwarderContract`* +Name | Type | Description | +------ | ------ | ------ | +`target` | string | Address to authorize. | -*Defined in [contract-wrappers/src/contract_wrappers.ts:51](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-wrappers/src/contract_wrappers.ts#L51)* +**Returns:** *string* -An instance of the ForwarderContract class containing methods for interacting with any Forwarder smart contract. +The ABI encoded transaction data as a string -___ +#### getSelector -### orderValidator +▸ **getSelector**(): *string* -• **orderValidator**: *`OrderValidatorContract`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts:214](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts#L214)* -*Defined in [contract-wrappers/src/contract_wrappers.ts:56](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-wrappers/src/contract_wrappers.ts#L56)* +Returns the 4 byte function selector as a hex string. -An instance of the OrderValidatorContract class containing methods for interacting with any OrderValidator smart contract. +**Returns:** *string* -___ +#### sendTransactionAsync -### weth9 +▸ **sendTransactionAsync**(`target`: string, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* -• **weth9**: *`WETH9Contract`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts:73](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts#L73)* -*Defined in [contract-wrappers/src/contract_wrappers.ts:47](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-wrappers/src/contract_wrappers.ts#L47)* +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. -An instance of the WETH9Contract class containing methods for interacting with the -WETH9 smart contract. +**Parameters:** -## Methods +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`target` | string | - | Address to authorize. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | -### getAbiDecoder +**Returns:** *`Promise`* -▸ **getAbiDecoder**(): *`AbiDecoder`* +The hash of the transaction -*Defined in [contract-wrappers/src/contract_wrappers.ts:130](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-wrappers/src/contract_wrappers.ts#L130)* +___ -Get the abi decoder instance currently used by contract-wrappers +### authorities -**Returns:** *`AbiDecoder`* +#### ▪ **authorities**: *object* -AbiDecoder instance +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts:220](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts#L220)* -___ +#### callAsync -### getProvider +▸ **callAsync**(`index_0`: `BigNumber`, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -▸ **getProvider**(): *[SupportedProvider](#supportedprovider)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts:226](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts#L226)* -*Defined in [contract-wrappers/src/contract_wrappers.ts:123](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-wrappers/src/contract_wrappers.ts#L123)* +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. -Get the provider instance currently used by contract-wrappers +**Parameters:** -**Returns:** *[SupportedProvider](#supportedprovider)* +Name | Type | Default | +------ | ------ | ------ | +`index_0` | `BigNumber` | - | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | -Web3 provider instance +**Returns:** *`Promise`* ___ -### unsubscribeAll +### authorized -▸ **unsubscribeAll**(): *void* +#### ▪ **authorized**: *object* -*Defined in [contract-wrappers/src/contract_wrappers.ts:115](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-wrappers/src/contract_wrappers.ts#L115)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts:702](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts#L702)* -Unsubscribes from all subscriptions for all contracts. +#### callAsync -**Returns:** *void* +▸ **callAsync**(`index_0`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -
+*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts:708](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts#L708)* -# Class: CoordinatorWrapper +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. -This class includes all the functionality related to filling or cancelling orders through -the 0x V2 Coordinator extension contract. +**Parameters:** +Name | Type | Default | +------ | ------ | ------ | +`index_0` | string | - | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | -## Constructors +**Returns:** *`Promise`* +___ +### getAuthorizedAddresses -\+ **new CoordinatorWrapper**(`provider`: [SupportedProvider](#supportedprovider), `chainId`: number, `address?`: undefined | string, `exchangeAddress?`: undefined | string, `registryAddress?`: undefined | string): *[CoordinatorWrapper](#class-coordinatorwrapper)* +#### ▪ **getAuthorizedAddresses**: *object* -*Defined in [contract-wrappers/src/coordinator_wrapper.ts:42](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-wrappers/src/coordinator_wrapper.ts#L42)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts:753](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts#L753)* -Instantiate CoordinatorWrapper +Gets all authorized addresses. -**Parameters:** +#### callAsync -Name | Type | Description | ------- | ------ | ------ | -`provider` | [SupportedProvider](#supportedprovider) | - | -`chainId` | number | Desired chainId. | -`address?` | undefined \| string | The address of the Coordinator contract. If undefined, will default to the known address corresponding to the chainId. | -`exchangeAddress?` | undefined \| string | The address of the Exchange contract. If undefined, will default to the known address corresponding to the chainId. | -`registryAddress?` | undefined \| string | The address of the CoordinatorRegistry contract. If undefined, will default to the known address corresponding to the chainId. | +▸ **callAsync**(`callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -**Returns:** *[CoordinatorWrapper](#class-coordinatorwrapper)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts:760](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts#L760)* -## Properties +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. -### abi +**Parameters:** -• **abi**: *[ContractAbi](#contractabi)* = Coordinator.compilerOutput.abi +Name | Type | Default | +------ | ------ | ------ | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* -*Defined in [contract-wrappers/src/coordinator_wrapper.ts:33](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-wrappers/src/coordinator_wrapper.ts#L33)* +Array of authorized addresses. ___ -### address +### getProxyId -• **address**: *string* +#### ▪ **getProxyId**: *object* -*Defined in [contract-wrappers/src/coordinator_wrapper.ts:35](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-wrappers/src/coordinator_wrapper.ts#L35)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts:666](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts#L666)* -___ +Gets the proxy id associated with the proxy address. -### chainId +#### callAsync -• **chainId**: *number* +▸ **callAsync**(`callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -*Defined in [contract-wrappers/src/coordinator_wrapper.ts:34](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-wrappers/src/coordinator_wrapper.ts#L34)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts:673](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts#L673)* -___ +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. -### exchangeAddress +**Parameters:** -• **exchangeAddress**: *string* +Name | Type | Default | +------ | ------ | ------ | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* -*Defined in [contract-wrappers/src/coordinator_wrapper.ts:36](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-wrappers/src/coordinator_wrapper.ts#L36)* +Proxy id. ___ -### registryAddress - -• **registryAddress**: *string* +### owner -*Defined in [contract-wrappers/src/coordinator_wrapper.ts:37](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-wrappers/src/coordinator_wrapper.ts#L37)* +#### ▪ **owner**: *object* -## Methods +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts:426](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts#L426)* -### assertValidCoordinatorApprovalsOrThrowAsync +#### callAsync -▸ **assertValidCoordinatorApprovalsOrThrowAsync**(`transaction`: `ZeroExTransaction`, `txOrigin`: string, `transactionSignature`: string, `approvalExpirationTimeSeconds`: `BigNumber`[], `approvalSignatures`: string[]): *`Promise`* +▸ **callAsync**(`callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -*Defined in [contract-wrappers/src/coordinator_wrapper.ts:507](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-wrappers/src/coordinator_wrapper.ts#L507)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts:432](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts#L432)* -Validates that the 0x transaction has been approved by all of the feeRecipients that correspond to each order in the transaction's Exchange calldata. -Throws an error if the transaction approvals are not valid. Will not detect failures that would occur when the transaction is executed on the Exchange contract. +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | Description | +Name | Type | Default | ------ | ------ | ------ | -`transaction` | `ZeroExTransaction` | 0x transaction containing salt, signerAddress, and data. | -`txOrigin` | string | Required signer of Ethereum transaction calling this function. | -`transactionSignature` | string | Proof that the transaction has been signed by the signer. | -`approvalExpirationTimeSeconds` | `BigNumber`[] | Array of expiration times in seconds for which each corresponding approval signature expires. | -`approvalSignatures` | string[] | Array of signatures that correspond to the feeRecipients of each order in the transaction's Exchange calldata. | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | -**Returns:** *`Promise`* +**Returns:** *`Promise`* ___ -### batchFillOrKillOrdersAsync +### removeAuthorizedAddress -▸ **batchFillOrKillOrdersAsync**(`signedOrders`: `SignedOrder`[], `takerAssetFillAmounts`: `BigNumber`[], `takerAddress`: string, `orderTransactionOpts`: [OrderTransactionOpts](#interface-ordertransactionopts)): *`Promise`* +#### ▪ **removeAuthorizedAddress**: *object* -*Defined in [contract-wrappers/src/coordinator_wrapper.ts:228](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-wrappers/src/coordinator_wrapper.ts#L228)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts:271](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts#L271)* -Batch version of fillOrKillOrderAsync. Executes multiple fills atomically in a single transaction. +Removes authorizion of an address. + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`target`: string, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts:314](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts#L314)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. **Parameters:** Name | Type | Default | Description | ------ | ------ | ------ | ------ | -`signedOrders` | `SignedOrder`[] | - | An array of signed orders to fill. | -`takerAssetFillAmounts` | `BigNumber`[] | - | The amounts of the orders (in taker asset baseUnits) that you wish to fill. | -`takerAddress` | string | - | The user Ethereum address who would like to fill these orders. Must be available via the supplied Provider provided at instantiation. | -`orderTransactionOpts` | [OrderTransactionOpts](#interface-ordertransactionopts) | { shouldValidate: true } | Optional arguments this method accepts. | - -**Returns:** *`Promise`* +`target` | string | - | Address to remove authorization from. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | -Transaction hash. +**Returns:** *`PromiseWithTransactionHash`* -___ +A promise that resolves when the transaction is successful -### batchFillOrdersAsync +#### callAsync -▸ **batchFillOrdersAsync**(`signedOrders`: `SignedOrder`[], `takerAssetFillAmounts`: `BigNumber`[], `takerAddress`: string, `orderTransactionOpts`: [OrderTransactionOpts](#interface-ordertransactionopts)): *`Promise`* +▸ **callAsync**(`target`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -*Defined in [contract-wrappers/src/coordinator_wrapper.ts:164](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-wrappers/src/coordinator_wrapper.ts#L164)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts:365](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts#L365)* -Batch version of fillOrderAsync. Executes multiple fills atomically in a single transaction. -Under-the-hood, this method uses the `feeRecipientAddress`s of the orders to looks up the coordinator server endpoints -registered in the coordinator registry contract. It requests a signature from each coordinator server before -submitting the orders and signatures as a 0x transaction to the coordinator extension contract, which validates the -signatures and then fills the order through the Exchange contract. -If any `feeRecipientAddress` in the batch is not registered to a coordinator server, the whole batch fails. +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** Name | Type | Default | Description | ------ | ------ | ------ | ------ | -`signedOrders` | `SignedOrder`[] | - | An array of signed orders to fill. | -`takerAssetFillAmounts` | `BigNumber`[] | - | The amounts of the orders (in taker asset baseUnits) that you wish to fill. | -`takerAddress` | string | - | The user Ethereum address who would like to fill these orders. Must be available via the supplied Provider provided at instantiation. | -`orderTransactionOpts` | [OrderTransactionOpts](#interface-ordertransactionopts) | { shouldValidate: true } | Optional arguments this method accepts. | +`target` | string | - | Address to remove authorization from. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -**Returns:** *`Promise`* +**Returns:** *`Promise`* -Transaction hash. +#### estimateGasAsync -___ +▸ **estimateGasAsync**(`target`: string, `txData?`: `Partial` | undefined): *`Promise`* -### batchFillOrdersNoThrowAsync +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts:340](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts#L340)* -▸ **batchFillOrdersNoThrowAsync**(`signedOrders`: `SignedOrder`[], `takerAssetFillAmounts`: `BigNumber`[], `takerAddress`: string, `orderTransactionOpts`: [OrderTransactionOpts](#interface-ordertransactionopts)): *`Promise`* +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. -*Defined in [contract-wrappers/src/coordinator_wrapper.ts:196](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-wrappers/src/coordinator_wrapper.ts#L196)* +**Parameters:** -No throw version of batchFillOrdersAsync +Name | Type | Description | +------ | ------ | ------ | +`target` | string | Address to remove authorization from. | +`txData?` | `Partial` \| undefined | Additional data for transaction | -**Parameters:** +**Returns:** *`Promise`* -Name | Type | Default | Description | ------- | ------ | ------ | ------ | -`signedOrders` | `SignedOrder`[] | - | An array of signed orders to fill. | -`takerAssetFillAmounts` | `BigNumber`[] | - | The amounts of the orders (in taker asset baseUnits) that you wish to fill. | -`takerAddress` | string | - | The user Ethereum address who would like to fill these orders. Must be available via the supplied Provider provided at instantiation. | -`orderTransactionOpts` | [OrderTransactionOpts](#interface-ordertransactionopts) | { shouldValidate: true } | Optional arguments this method accepts. | +The hash of the transaction -**Returns:** *`Promise`* +#### getABIEncodedTransactionData -Transaction hash. +▸ **getABIEncodedTransactionData**(`target`: string): *string* -___ +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts:409](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts#L409)* -### batchHardCancelOrdersAsync +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). -▸ **batchHardCancelOrdersAsync**(`orders`: `SignedOrder`[], `orderTransactionOpts`: [OrderTransactionOpts](#interface-ordertransactionopts)): *`Promise`* +**Parameters:** -*Defined in [contract-wrappers/src/coordinator_wrapper.ts:438](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-wrappers/src/coordinator_wrapper.ts#L438)* +Name | Type | Description | +------ | ------ | ------ | +`target` | string | Address to remove authorization from. | -Batch version of hardCancelOrderAsync. Cancels orders on-chain by submitting an Ethereum transaction. -Executes multiple cancels atomically in a single transaction. +**Returns:** *string* -**Parameters:** +The ABI encoded transaction data as a string -Name | Type | Default | Description | ------- | ------ | ------ | ------ | -`orders` | `SignedOrder`[] | - | An array of orders to cancel. | -`orderTransactionOpts` | [OrderTransactionOpts](#interface-ordertransactionopts) | { shouldValidate: true } | Optional arguments this method accepts. | +#### getSelector -**Returns:** *`Promise`* +▸ **getSelector**(): *string* -Transaction hash. +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts:420](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts#L420)* -___ +Returns the 4 byte function selector as a hex string. -### batchSoftCancelOrdersAsync +**Returns:** *string* -▸ **batchSoftCancelOrdersAsync**(`orders`: `SignedOrder`[]): *`Promise`* +#### sendTransactionAsync -*Defined in [contract-wrappers/src/coordinator_wrapper.ts:352](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-wrappers/src/coordinator_wrapper.ts#L352)* +▸ **sendTransactionAsync**(`target`: string, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* -Batch version of softCancelOrderAsync. Requests multiple soft cancels +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts:279](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts#L279)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. **Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`orders` | `SignedOrder`[] | An array of orders to cancel. | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`target` | string | - | Address to remove authorization from. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | -**Returns:** *`Promise`* +**Returns:** *`Promise`* -CoordinatorServerCancellationResponse. See [Cancellation Response](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/coordinator-specification.md#response). +The hash of the transaction ___ -### fillOrKillOrderAsync +### removeAuthorizedAddressAtIndex -▸ **fillOrKillOrderAsync**(`signedOrder`: `SignedOrder`, `takerAssetFillAmount`: `BigNumber`, `takerAddress`: string, `orderTransactionOpts`: [OrderTransactionOpts](#interface-ordertransactionopts)): *`Promise`* +#### ▪ **removeAuthorizedAddressAtIndex**: *object* -*Defined in [contract-wrappers/src/coordinator_wrapper.ts:130](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-wrappers/src/coordinator_wrapper.ts#L130)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts:472](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts#L472)* -Attempts to fill a specific amount of an order. If the entire amount specified cannot be filled, -the fill order is abandoned. +Removes authorizion of an address. + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`target`: string, `index`: `BigNumber`, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts:522](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts#L522)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. **Parameters:** Name | Type | Default | Description | ------ | ------ | ------ | ------ | -`signedOrder` | `SignedOrder` | - | An object that conforms to the SignedOrder interface. | -`takerAssetFillAmount` | `BigNumber` | - | The amount of the order (in taker asset baseUnits) that you wish to fill. | -`takerAddress` | string | - | The user Ethereum address who would like to fill this order. Must be available via the supplied Provider provided at instantiation. | -`orderTransactionOpts` | [OrderTransactionOpts](#interface-ordertransactionopts) | { shouldValidate: true } | Optional arguments this method accepts. | - -**Returns:** *`Promise`* +`target` | string | - | Address to remove authorization from. | +`index` | `BigNumber` | - | Index of target in authorities array. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | -Transaction hash. +**Returns:** *`PromiseWithTransactionHash`* -___ +A promise that resolves when the transaction is successful -### fillOrderAsync +#### callAsync -▸ **fillOrderAsync**(`signedOrder`: `SignedOrder`, `takerAssetFillAmount`: `BigNumber`, `takerAddress`: string, `orderTransactionOpts`: [OrderTransactionOpts](#interface-ordertransactionopts)): *`Promise`* +▸ **callAsync**(`target`: string, `index`: `BigNumber`, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -*Defined in [contract-wrappers/src/coordinator_wrapper.ts:100](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-wrappers/src/coordinator_wrapper.ts#L100)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts:590](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts#L590)* -Fills a signed order with an amount denominated in baseUnits of the taker asset. Under-the-hood, this -method uses the `feeRecipientAddress` of the order to look up the coordinator server endpoint registered in the -coordinator registry contract. It requests a signature from that coordinator server before -submitting the order and signature as a 0x transaction to the coordinator extension contract. The coordinator extension -contract validates signatures and then fills the order via the Exchange contract. +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** Name | Type | Default | Description | ------ | ------ | ------ | ------ | -`signedOrder` | `SignedOrder` | - | An object that conforms to the SignedOrder interface. | -`takerAssetFillAmount` | `BigNumber` | - | The amount of the order (in taker asset baseUnits) that you wish to fill. | -`takerAddress` | string | - | The user Ethereum address who would like to fill this order. Must be available via the supplied Provider provided at instantiation. | -`orderTransactionOpts` | [OrderTransactionOpts](#interface-ordertransactionopts) | { shouldValidate: true } | Optional arguments this method accepts. | - -**Returns:** *`Promise`* - -Transaction hash. +`target` | string | - | Address to remove authorization from. | +`index` | `BigNumber` | - | Index of target in authorities array. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | -___ +**Returns:** *`Promise`* -### getSignerAddressAsync +#### estimateGasAsync -▸ **getSignerAddressAsync**(`hash`: string, `signature`: string): *`Promise`* +▸ **estimateGasAsync**(`target`: string, `index`: `BigNumber`, `txData?`: `Partial` | undefined): *`Promise`* -*Defined in [contract-wrappers/src/coordinator_wrapper.ts:541](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-wrappers/src/coordinator_wrapper.ts#L541)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts:556](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts#L556)* -Recovers the address of a signer given a hash and signature. +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. **Parameters:** Name | Type | Description | ------ | ------ | ------ | -`hash` | string | Any 32 byte hash. | -`signature` | string | Proof that the hash has been signed by signer. | +`target` | string | Address to remove authorization from. | +`index` | `BigNumber` | Index of target in authorities array. | +`txData?` | `Partial` \| undefined | Additional data for transaction | -**Returns:** *`Promise`* - -Signer address. +**Returns:** *`Promise`* -___ +The hash of the transaction -### hardCancelOrderAsync +#### getABIEncodedTransactionData -▸ **hardCancelOrderAsync**(`order`: `Order` | `SignedOrder`, `orderTransactionOpts`: [OrderTransactionOpts](#interface-ordertransactionopts)): *`Promise`* +▸ **getABIEncodedTransactionData**(`target`: string, `index`: `BigNumber`): *string* -*Defined in [contract-wrappers/src/coordinator_wrapper.ts:406](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-wrappers/src/coordinator_wrapper.ts#L406)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts:644](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts#L644)* -Cancels an order on-chain by submitting an Ethereum transaction. +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). **Parameters:** -Name | Type | Default | Description | ------- | ------ | ------ | ------ | -`order` | `Order` \| `SignedOrder` | - | An object that conforms to the Order or SignedOrder interface. The order you would like to cancel. | -`orderTransactionOpts` | [OrderTransactionOpts](#interface-ordertransactionopts) | { shouldValidate: true } | Optional arguments this method accepts. | - -**Returns:** *`Promise`* - -Transaction hash. - -___ - -### hardCancelOrdersUpToAsync - -▸ **hardCancelOrdersUpToAsync**(`targetOrderEpoch`: `BigNumber`, `senderAddress`: string, `orderTransactionOpts`: [OrderTransactionOpts](#interface-ordertransactionopts)): *`Promise`* +Name | Type | Description | +------ | ------ | ------ | +`target` | string | Address to remove authorization from. | +`index` | `BigNumber` | Index of target in authorities array. | -*Defined in [contract-wrappers/src/coordinator_wrapper.ts:473](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-wrappers/src/coordinator_wrapper.ts#L473)* +**Returns:** *string* -Cancels orders on-chain by submitting an Ethereum transaction. -Cancels all orders created by makerAddress with a salt less than or equal to the targetOrderEpoch -and senderAddress equal to coordinator extension contract address. +The ABI encoded transaction data as a string -**Parameters:** +#### getSelector -Name | Type | Default | Description | ------- | ------ | ------ | ------ | -`targetOrderEpoch` | `BigNumber` | - | Target order epoch. | -`senderAddress` | string | - | Address that should send the transaction. | -`orderTransactionOpts` | [OrderTransactionOpts](#interface-ordertransactionopts) | { shouldValidate: true } | Optional arguments this method accepts. | +▸ **getSelector**(): *string* -**Returns:** *`Promise`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts:657](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts#L657)* -Transaction hash. +Returns the 4 byte function selector as a hex string. -___ +**Returns:** *string* -### marketBuyOrdersNoThrowAsync +#### sendTransactionAsync -▸ **marketBuyOrdersNoThrowAsync**(`signedOrders`: `SignedOrder`[], `makerAssetFillAmount`: `BigNumber`, `takerAddress`: string, `orderTransactionOpts`: [OrderTransactionOpts](#interface-ordertransactionopts)): *`Promise`* +▸ **sendTransactionAsync**(`target`: string, `index`: `BigNumber`, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* -*Defined in [contract-wrappers/src/coordinator_wrapper.ts:260](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-wrappers/src/coordinator_wrapper.ts#L260)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts:481](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts#L481)* -No throw version of marketBuyOrdersAsync +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. **Parameters:** Name | Type | Default | Description | ------ | ------ | ------ | ------ | -`signedOrders` | `SignedOrder`[] | - | An array of signed orders to fill. | -`makerAssetFillAmount` | `BigNumber` | - | Maker asset fill amount. | -`takerAddress` | string | - | The user Ethereum address who would like to fill these orders. Must be available via the supplied Provider provided at instantiation. | -`orderTransactionOpts` | [OrderTransactionOpts](#interface-ordertransactionopts) | { shouldValidate: true } | Optional arguments this method accepts. | +`target` | string | - | Address to remove authorization from. | +`index` | `BigNumber` | - | Index of target in authorities array. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | **Returns:** *`Promise`* -Transaction hash. +The hash of the transaction ___ -### marketSellOrdersNoThrowAsync +### transferOwnership -▸ **marketSellOrdersNoThrowAsync**(`signedOrders`: `SignedOrder`[], `takerAssetFillAmount`: `BigNumber`, `takerAddress`: string, `orderTransactionOpts`: [OrderTransactionOpts](#interface-ordertransactionopts)): *`Promise`* +#### ▪ **transferOwnership**: *object* -*Defined in [contract-wrappers/src/coordinator_wrapper.ts:290](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-wrappers/src/coordinator_wrapper.ts#L290)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts:797](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts#L797)* -No throw version of marketSellOrdersAsync +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`newOwner`: string, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts:838](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts#L838)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. **Parameters:** Name | Type | Default | Description | ------ | ------ | ------ | ------ | -`signedOrders` | `SignedOrder`[] | - | An array of signed orders to fill. | -`takerAssetFillAmount` | `BigNumber` | - | Taker asset fill amount. | -`takerAddress` | string | - | The user Ethereum address who would like to fill these orders. Must be available via the supplied Provider provided at instantiation. | -`orderTransactionOpts` | [OrderTransactionOpts](#interface-ordertransactionopts) | { shouldValidate: true } | Optional arguments this method accepts. | - -**Returns:** *`Promise`* +`newOwner` | string | - | - | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | -Transaction hash. +**Returns:** *`PromiseWithTransactionHash`* -___ +A promise that resolves when the transaction is successful -### softCancelOrderAsync +#### callAsync -▸ **softCancelOrderAsync**(`order`: `Order` | `SignedOrder`): *`Promise`* +▸ **callAsync**(`newOwner`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -*Defined in [contract-wrappers/src/coordinator_wrapper.ts:317](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-wrappers/src/coordinator_wrapper.ts#L317)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts:887](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts#L887)* -Soft cancel a given order. -Soft cancels are recorded only on coordinator operator servers and do not involve an Ethereum transaction. -See [soft cancels](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/coordinator-specification.md#soft-cancels). +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. **Parameters:** -Name | Type | Description | +Name | Type | Default | ------ | ------ | ------ | -`order` | `Order` \| `SignedOrder` | An object that conforms to the Order or SignedOrder interface. The order you would like to cancel. | - -**Returns:** *`Promise`* +`newOwner` | string | - | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | -CoordinatorServerCancellationResponse. See [Cancellation Response](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/coordinator-specification.md#response). +**Returns:** *`Promise`* -
+#### estimateGasAsync -# Class: AbiDecoder +▸ **estimateGasAsync**(`newOwner`: string, `txData?`: `Partial` | undefined): *`Promise`* -AbiDecoder allows you to decode event logs given a set of supplied contract ABI's. It takes the contract's event -signature from the ABI and attempts to decode the logs using it. +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts:863](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts#L863)* +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. -## Constructors +**Parameters:** +Name | Type | Description | +------ | ------ | ------ | +`newOwner` | string | - | +`txData?` | `Partial` \| undefined | Additional data for transaction | +**Returns:** *`Promise`* -\+ **new AbiDecoder**(`abiArrays`: [AbiDefinition](#abidefinition)[][]): *[AbiDecoder](#class-abidecoder)* +The hash of the transaction -*Defined in [utils/src/abi_decoder.ts:42](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/utils/src/abi_decoder.ts#L42)* +#### getABIEncodedTransactionData -Instantiate an AbiDecoder +▸ **getABIEncodedTransactionData**(`newOwner`: string): *string* -**Parameters:** +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts:930](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts#L930)* -Name | Type | Description | ------- | ------ | ------ | -`abiArrays` | [AbiDefinition](#abidefinition)[][] | An array of contract ABI's | +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). -**Returns:** *[AbiDecoder](#class-abidecoder)* +**Parameters:** -AbiDecoder instance +Name | Type | +------ | ------ | +`newOwner` | string | -## Methods +**Returns:** *string* -### addABI +The ABI encoded transaction data as a string -▸ **addABI**(`abiArray`: [AbiDefinition](#abidefinition)[], `contractName?`: undefined | string): *void* +#### getSelector -*Defined in [utils/src/abi_decoder.ts:158](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/utils/src/abi_decoder.ts#L158)* +▸ **getSelector**(): *string* -Adds a set of ABI definitions, after which calldata and logs targeting these ABI's can be decoded. -Additional properties can be included to disambiguate similar ABI's. For example, if two functions -have the same signature but different parameter names, then their ABI definitions can be disambiguated -by specifying a contract name. +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts:941](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts#L941)* -**Parameters:** +Returns the 4 byte function selector as a hex string. -Name | Type | Description | ------- | ------ | ------ | -`abiArray` | [AbiDefinition](#abidefinition)[] | - | -`contractName?` | undefined \| string | Name of contract that encapsulates the ABI definitions (optional). This can be used when decoding calldata to disambiguate methods with the same signature but different parameter names. | +**Returns:** *string* -**Returns:** *void* +#### sendTransactionAsync -___ +▸ **sendTransactionAsync**(`newOwner`: string, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* -### decodeCalldataOrThrow +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts:804](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts#L804)* -▸ **decodeCalldataOrThrow**(`calldata`: string, `contractName?`: undefined | string): *`DecodedCalldata`* +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. -*Defined in [utils/src/abi_decoder.ts:118](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/utils/src/abi_decoder.ts#L118)* +**Parameters:** -Decodes calldata for a known ABI. +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`newOwner` | string | - | - | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | -**Parameters:** +**Returns:** *`Promise`* -Name | Type | Description | ------- | ------ | ------ | -`calldata` | string | hex-encoded calldata. | -`contractName?` | undefined \| string | used to disambiguate similar ABI's (optional). | +The hash of the transaction -**Returns:** *`DecodedCalldata`* +
-Decoded calldata. Includes: function name and signature, along with the decoded arguments. +# Class: ERC20TokenContract -___ -### tryToDecodeLogOrNoop +## Constructors -▸ **tryToDecodeLogOrNoop**<**ArgsType**>(`log`: `LogEntry`): *`LogWithDecodedArgs` | [RawLog](#rawlog)* -*Defined in [utils/src/abi_decoder.ts:58](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/utils/src/abi_decoder.ts#L58)* -Attempt to decode a log given the ABI's the AbiDecoder knows about. +\+ **new ERC20TokenContract**(`address`: string, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults?`: `Partial`, `logDecodeDependencies?`: undefined | object, `deployedBytecode`: string | undefined): *[ERC20TokenContract](#class-erc20tokencontract)* -**Type parameters:** +*Overrides void* -▪ **ArgsType**: *`DecodedLogArgs`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:1113](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L1113)* **Parameters:** -Name | Type | Description | +Name | Type | Default | ------ | ------ | ------ | -`log` | `LogEntry` | The log to attempt to decode | +`address` | string | - | +`supportedProvider` | [SupportedProvider](#supportedprovider) | - | +`txDefaults?` | `Partial` | - | +`logDecodeDependencies?` | undefined \| object | - | +`deployedBytecode` | string \| undefined | ERC20TokenContract.deployedBytecode | -**Returns:** *`LogWithDecodedArgs` | [RawLog](#rawlog)* +**Returns:** *[ERC20TokenContract](#class-erc20tokencontract)* -The decoded log if the requisite ABI was available. Otherwise the log unaltered. +## Properties -
+#### `Optional` _deployedBytecodeIfExists -# Enumeration: CoordinatorRegistryEvents +• **_deployedBytecodeIfExists**? : *`Buffer`* -## Enumeration members -### CoordinatorEndpointSet +Defined in base-contract/lib/src/index.d.ts:31 -• **CoordinatorEndpointSet**: = "CoordinatorEndpointSet" +___ -*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts:40](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts#L40)* +### abi -
+• **abi**: *[ContractAbi](#contractabi)* -# Enumeration: DummyERC20TokenEvents -## Enumeration members +Defined in base-contract/lib/src/index.d.ts:27 -### Approval +___ -• **Approval**: = "Approval" +### address -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:40](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L40)* +• **address**: *string* -___ -### Transfer -• **Transfer**: = "Transfer" +Defined in base-contract/lib/src/index.d.ts:28 -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:41](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L41)* +___ -
+Args -# Enumeration: DummyERC721TokenEvents +• **constructorArgs**: *any[]* -## Enumeration members -### Approval +Defined in base-contract/lib/src/index.d.ts:30 -• **Approval**: = "Approval" +___ -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:43](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L43)* +### contractName -___ +• **contractName**: *string* -### ApprovalForAll -• **ApprovalForAll**: = "ApprovalForAll" -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:44](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L44)* +Defined in base-contract/lib/src/index.d.ts:29 -___ +## Methods -### Transfer +### getLogsAsync -• **Transfer**: = "Transfer" +▸ **getLogsAsync**<**ArgsType**>(`eventName`: [ERC20TokenEvents](#enumeration-erc20tokenevents), `blockRange`: `BlockRange`, `indexFilterValues`: `IndexedFilterValues`): *`Promise>>`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:45](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L45)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:1097](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L1097)* -
+Gets historical logs without creating a subscription -# Enumeration: ERC20TokenEvents +**Type parameters:** +▪ **ArgsType**: *[ERC20TokenEventArgs](#erc20tokeneventargs)* -## Enumeration members +**Parameters:** -### Approval +Name | Type | Description | +------ | ------ | ------ | +`eventName` | [ERC20TokenEvents](#enumeration-erc20tokenevents) | The ERC20Token contract event you would like to subscribe to. | +`blockRange` | `BlockRange` | Block range to get logs from. | +`indexFilterValues` | `IndexedFilterValues` | An object where the keys are indexed args returned by the event and the value is the value you are interested in. E.g `{_from: aUserAddressHex}` | -• **Approval**: = "Approval" +**Returns:** *`Promise>>`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:41](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L41)* +Array of logs that match the parameters ___ -### Transfer +### subscribe -• **Transfer**: = "Transfer" +▸ **subscribe**<**ArgsType**>(`eventName`: [ERC20TokenEvents](#enumeration-erc20tokenevents), `indexFilterValues`: `IndexedFilterValues`, `callback`: [EventCallback](#eventcallback)‹*`ArgsType`*›, `isVerbose`: boolean, `blockPollingIntervalMs?`: undefined | number): *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:40](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L40)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:1055](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L1055)* -
+Subscribe to an event type emitted by the ERC20Token contract. -# Enumeration: ERC721TokenEvents +**Type parameters:** +▪ **ArgsType**: *[ERC20TokenEventArgs](#erc20tokeneventargs)* -## Enumeration members +**Parameters:** -### Approval +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`eventName` | [ERC20TokenEvents](#enumeration-erc20tokenevents) | - | The ERC20Token contract event you would like to subscribe to. | +`indexFilterValues` | `IndexedFilterValues` | - | An object where the keys are indexed args returned by the event and the value is the value you are interested in. E.g `{maker: aUserAddressHex}` | +`callback` | [EventCallback](#eventcallback)‹*`ArgsType`*› | - | Callback that gets called when a log is added/removed | +`isVerbose` | boolean | false | Enable verbose subscription warnings (e.g recoverable network issues encountered) | +`blockPollingIntervalMs?` | undefined \| number | - | - | -• **Approval**: = "Approval" +**Returns:** *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:43](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L43)* +Subscription token used later to unsubscribe ___ -### ApprovalForAll - -• **ApprovalForAll**: = "ApprovalForAll" +### unsubscribe -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:44](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L44)* +▸ **unsubscribe**(`subscriptionToken`: string): *void* -___ +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:1080](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L1080)* -### Transfer +Cancel a subscription -• **Transfer**: = "Transfer" +**Parameters:** -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:45](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L45)* +Name | Type | Description | +------ | ------ | ------ | +`subscriptionToken` | string | Subscription token returned by `subscribe()` | -
+**Returns:** *void* -# Enumeration: ExchangeEvents +___ +### unsubscribeAll -## Enumeration members +▸ **unsubscribeAll**(): *void* -### AssetProxyRegistered +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:1086](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L1086)* -• **AssetProxyRegistered**: = "AssetProxyRegistered" +Cancels all existing subscriptions -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:48](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L48)* +**Returns:** *void* ___ -### Cancel +### `Static` ABI -• **Cancel**: = "Cancel" +▸ **ABI**(): *[ContractAbi](#contractabi)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:49](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L49)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:866](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L866)* -___ +**Returns:** *[ContractAbi](#contractabi)* -### CancelUpTo +The contract ABI -• **CancelUpTo**: = "CancelUpTo" +___ -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:50](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L50)* +### `Static` deployAsync + +▸ **deployAsync**(`bytecode`: string, `abi`: [ContractAbi](#contractabi), `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:824](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L824)* + +**Parameters:** + +Name | Type | +------ | ------ | +`bytecode` | string | +`abi` | [ContractAbi](#contractabi) | +`supportedProvider` | [SupportedProvider](#supportedprovider) | +`txDefaults` | `Partial` | +`logDecodeDependencies` | object | + +**Returns:** *`Promise`* + +___ + +### `Static` deployFrom0xArtifactAsync + +▸ **deployFrom0xArtifactAsync**(`artifact`: `ContractArtifact` | `SimpleContractArtifact`, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:799](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L799)* + +**Parameters:** + +Name | Type | +------ | ------ | +`artifact` | `ContractArtifact` \| `SimpleContractArtifact` | +`supportedProvider` | [SupportedProvider](#supportedprovider) | +`txDefaults` | `Partial` | +`logDecodeDependencies` | object | + +**Returns:** *`Promise`* + +___ + +### `Static` strictArgumentEncodingCheck + +▸ **strictArgumentEncodingCheck**(`inputAbi`: `DataItem`[], `args`: any[]): *string* + + + +Defined in base-contract/lib/src/index.d.ts:41 + +**Parameters:** + +Name | Type | +------ | ------ | +`inputAbi` | `DataItem`[] | +`args` | any[] | + +**Returns:** *string* + +## Object literals + +### allowance + +#### ▪ **allowance**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:742](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L742)* + +#### callAsync + +▸ **callAsync**(`_owner`: string, `_spender`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:751](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L751)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_owner` | string | - | The address of the account owning tokens | +`_spender` | string | - | The address of the account able to transfer the tokens | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +Amount of remaining tokens allowed to spent + +___ + +### approve + +#### ▪ **approve**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:64](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L64)* + +`msg.sender` approves `_spender` to spend `_value` tokens + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`_spender`: string, `_value`: `BigNumber`, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:114](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L114)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_spender` | string | - | The address of the account able to transfer the tokens | +`_value` | `BigNumber` | - | The amount of wei to be approved for transfer | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`_spender`: string, `_value`: `BigNumber`, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:178](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L178)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_spender` | string | - | The address of the account able to transfer the tokens | +`_value` | `BigNumber` | - | The amount of wei to be approved for transfer | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +Always true if the call has enough gas to complete execution + +#### estimateGasAsync + +▸ **estimateGasAsync**(`_spender`: string, `_value`: `BigNumber`, `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:143](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L143)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`_spender` | string | The address of the account able to transfer the tokens | +`_value` | `BigNumber` | The amount of wei to be approved for transfer | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`_spender`: string, `_value`: `BigNumber`): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:232](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L232)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`_spender` | string | The address of the account able to transfer the tokens | +`_value` | `BigNumber` | The amount of wei to be approved for transfer | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:245](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L245)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`_spender`: string, `_value`: `BigNumber`, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:73](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L73)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_spender` | string | - | The address of the account able to transfer the tokens | +`_value` | `BigNumber` | - | The amount of wei to be approved for transfer | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### balanceOf + +#### ▪ **balanceOf**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:515](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L515)* + +Query the balance of owner + +#### callAsync + +▸ **callAsync**(`_owner`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:523](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L523)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_owner` | string | - | The address from which the balance will be retrieved | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +Balance of owner + +___ + +### totalSupply + +#### ▪ **totalSupply**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:254](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L254)* + +Query total supply of token + +#### callAsync + +▸ **callAsync**(`callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:261](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L261)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +Total supply of token + +___ + +### transfer + +#### ▪ **transfer**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:568](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L568)* + +send `value` token to `to` from `msg.sender` + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`_to`: string, `_value`: `BigNumber`, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:615](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L615)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_to` | string | - | The address of the recipient | +`_value` | `BigNumber` | - | The amount of token to be transferred | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`_to`: string, `_value`: `BigNumber`, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:672](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L672)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_to` | string | - | The address of the recipient | +`_value` | `BigNumber` | - | The amount of token to be transferred | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +True if transfer was successful + +#### estimateGasAsync + +▸ **estimateGasAsync**(`_to`: string, `_value`: `BigNumber`, `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:644](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L644)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`_to` | string | The address of the recipient | +`_value` | `BigNumber` | The amount of token to be transferred | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`_to`: string, `_value`: `BigNumber`): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:723](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L723)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`_to` | string | The address of the recipient | +`_value` | `BigNumber` | The amount of token to be transferred | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:736](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L736)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`_to`: string, `_value`: `BigNumber`, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:577](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L577)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_to` | string | - | The address of the recipient | +`_value` | `BigNumber` | - | The amount of token to be transferred | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### transferFrom + +#### ▪ **transferFrom**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:301](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L301)* + +send `value` token to `to` from `from` on the condition it is approved by `from` + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`_from`: string, `_to`: string, `_value`: `BigNumber`, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:356](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L356)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_from` | string | - | The address of the sender | +`_to` | string | - | The address of the recipient | +`_value` | `BigNumber` | - | The amount of token to be transferred | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`_from`: string, `_to`: string, `_value`: `BigNumber`, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:433](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L433)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_from` | string | - | The address of the sender | +`_to` | string | - | The address of the recipient | +`_value` | `BigNumber` | - | The amount of token to be transferred | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +True if transfer was successful + +#### estimateGasAsync + +▸ **estimateGasAsync**(`_from`: string, `_to`: string, `_value`: `BigNumber`, `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:394](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L394)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`_from` | string | The address of the sender | +`_to` | string | The address of the recipient | +`_value` | `BigNumber` | The amount of token to be transferred | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`_from`: string, `_to`: string, `_value`: `BigNumber`): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:491](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L491)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`_from` | string | The address of the sender | +`_to` | string | The address of the recipient | +`_value` | `BigNumber` | The amount of token to be transferred | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:506](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L506)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`_from`: string, `_to`: string, `_value`: `BigNumber`, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:311](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L311)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_from` | string | - | The address of the sender | +`_to` | string | - | The address of the recipient | +`_value` | `BigNumber` | - | The amount of token to be transferred | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +
+ +# Class: ERC721ProxyContract + + +## Constructors + + + +\+ **new ERC721ProxyContract**(`address`: string, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults?`: `Partial`, `logDecodeDependencies?`: undefined | object, `deployedBytecode`: string | undefined): *[ERC721ProxyContract](#class-erc721proxycontract)* + +*Overrides void* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts:1270](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts#L1270)* + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`address` | string | - | +`supportedProvider` | [SupportedProvider](#supportedprovider) | - | +`txDefaults?` | `Partial` | - | +`logDecodeDependencies?` | undefined \| object | - | +`deployedBytecode` | string \| undefined | ERC721ProxyContract.deployedBytecode | + +**Returns:** *[ERC721ProxyContract](#class-erc721proxycontract)* + +## Properties + +#### `Optional` _deployedBytecodeIfExists + +• **_deployedBytecodeIfExists**? : *`Buffer`* + + + +Defined in base-contract/lib/src/index.d.ts:31 + +___ + +### abi + +• **abi**: *[ContractAbi](#contractabi)* + + + +Defined in base-contract/lib/src/index.d.ts:27 + +___ + +### address + +• **address**: *string* + + + +Defined in base-contract/lib/src/index.d.ts:28 + +___ + +Args + +• **constructorArgs**: *any[]* + + + +Defined in base-contract/lib/src/index.d.ts:30 + +___ + +### contractName + +• **contractName**: *string* + + + +Defined in base-contract/lib/src/index.d.ts:29 + +## Methods + +### getLogsAsync + +▸ **getLogsAsync**<**ArgsType**>(`eventName`: [ERC721ProxyEvents](#enumeration-erc721proxyevents), `blockRange`: `BlockRange`, `indexFilterValues`: `IndexedFilterValues`): *`Promise>>`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts:1254](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts#L1254)* + +Gets historical logs without creating a subscription + +**Type parameters:** + +▪ **ArgsType**: *[ERC721ProxyEventArgs](#erc721proxyeventargs)* + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`eventName` | [ERC721ProxyEvents](#enumeration-erc721proxyevents) | The ERC721Proxy contract event you would like to subscribe to. | +`blockRange` | `BlockRange` | Block range to get logs from. | +`indexFilterValues` | `IndexedFilterValues` | An object where the keys are indexed args returned by the event and the value is the value you are interested in. E.g `{_from: aUserAddressHex}` | + +**Returns:** *`Promise>>`* + +Array of logs that match the parameters + +___ + +### subscribe + +▸ **subscribe**<**ArgsType**>(`eventName`: [ERC721ProxyEvents](#enumeration-erc721proxyevents), `indexFilterValues`: `IndexedFilterValues`, `callback`: [EventCallback](#eventcallback)‹*`ArgsType`*›, `isVerbose`: boolean, `blockPollingIntervalMs?`: undefined | number): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts:1212](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts#L1212)* + +Subscribe to an event type emitted by the ERC721Proxy contract. + +**Type parameters:** + +▪ **ArgsType**: *[ERC721ProxyEventArgs](#erc721proxyeventargs)* + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`eventName` | [ERC721ProxyEvents](#enumeration-erc721proxyevents) | - | The ERC721Proxy contract event you would like to subscribe to. | +`indexFilterValues` | `IndexedFilterValues` | - | An object where the keys are indexed args returned by the event and the value is the value you are interested in. E.g `{maker: aUserAddressHex}` | +`callback` | [EventCallback](#eventcallback)‹*`ArgsType`*› | - | Callback that gets called when a log is added/removed | +`isVerbose` | boolean | false | Enable verbose subscription warnings (e.g recoverable network issues encountered) | +`blockPollingIntervalMs?` | undefined \| number | - | - | + +**Returns:** *string* + +Subscription token used later to unsubscribe + +___ + +### unsubscribe + +▸ **unsubscribe**(`subscriptionToken`: string): *void* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts:1237](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts#L1237)* + +Cancel a subscription + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`subscriptionToken` | string | Subscription token returned by `subscribe()` | + +**Returns:** *void* + +___ + +### unsubscribeAll + +▸ **unsubscribeAll**(): *void* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts:1243](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts#L1243)* + +Cancels all existing subscriptions + +**Returns:** *void* + +___ + +### `Static` ABI + +▸ **ABI**(): *[ContractAbi](#contractabi)* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts:1015](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts#L1015)* + +**Returns:** *[ContractAbi](#contractabi)* + +The contract ABI + +___ + +### `Static` deployAsync + +▸ **deployAsync**(`bytecode`: string, `abi`: [ContractAbi](#contractabi), `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts:973](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts#L973)* + +**Parameters:** + +Name | Type | +------ | ------ | +`bytecode` | string | +`abi` | [ContractAbi](#contractabi) | +`supportedProvider` | [SupportedProvider](#supportedprovider) | +`txDefaults` | `Partial` | +`logDecodeDependencies` | object | + +**Returns:** *`Promise`* + +___ + +### `Static` deployFrom0xArtifactAsync + +▸ **deployFrom0xArtifactAsync**(`artifact`: `ContractArtifact` | `SimpleContractArtifact`, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts:948](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts#L948)* + +**Parameters:** + +Name | Type | +------ | ------ | +`artifact` | `ContractArtifact` \| `SimpleContractArtifact` | +`supportedProvider` | [SupportedProvider](#supportedprovider) | +`txDefaults` | `Partial` | +`logDecodeDependencies` | object | + +**Returns:** *`Promise`* + +___ + +### `Static` strictArgumentEncodingCheck + +▸ **strictArgumentEncodingCheck**(`inputAbi`: `DataItem`[], `args`: any[]): *string* + + + +Defined in base-contract/lib/src/index.d.ts:41 + +**Parameters:** + +Name | Type | +------ | ------ | +`inputAbi` | `DataItem`[] | +`args` | any[] | + +**Returns:** *string* + +## Object literals + +### addAuthorizedAddress + +#### ▪ **addAuthorizedAddress**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts:65](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts#L65)* + +Authorizes an address. + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`target`: string, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts:108](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts#L108)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`target` | string | - | Address to authorize. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`target`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts:159](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts#L159)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`target` | string | - | Address to authorize. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +#### estimateGasAsync + +▸ **estimateGasAsync**(`target`: string, `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts:134](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts#L134)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`target` | string | Address to authorize. | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`target`: string): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts:203](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts#L203)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`target` | string | Address to authorize. | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts:214](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts#L214)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`target`: string, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts:73](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts#L73)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`target` | string | - | Address to authorize. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### authorities + +#### ▪ **authorities**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts:220](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts#L220)* + +#### callAsync + +▸ **callAsync**(`index_0`: `BigNumber`, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts:226](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts#L226)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`index_0` | `BigNumber` | - | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +___ + +### authorized + +#### ▪ **authorized**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts:702](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts#L702)* + +#### callAsync + +▸ **callAsync**(`index_0`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts:708](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts#L708)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`index_0` | string | - | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +___ + +### getAuthorizedAddresses + +#### ▪ **getAuthorizedAddresses**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts:753](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts#L753)* + +Gets all authorized addresses. + +#### callAsync + +▸ **callAsync**(`callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts:760](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts#L760)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +Array of authorized addresses. + +___ + +### getProxyId + +#### ▪ **getProxyId**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts:666](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts#L666)* + +Gets the proxy id associated with the proxy address. + +#### callAsync + +▸ **callAsync**(`callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts:673](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts#L673)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +Proxy id. + +___ + +### owner + +#### ▪ **owner**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts:426](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts#L426)* + +#### callAsync + +▸ **callAsync**(`callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts:432](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts#L432)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +___ + +### removeAuthorizedAddress + +#### ▪ **removeAuthorizedAddress**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts:271](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts#L271)* + +Removes authorizion of an address. + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`target`: string, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts:314](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts#L314)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`target` | string | - | Address to remove authorization from. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`target`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts:365](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts#L365)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`target` | string | - | Address to remove authorization from. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +#### estimateGasAsync + +▸ **estimateGasAsync**(`target`: string, `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts:340](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts#L340)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`target` | string | Address to remove authorization from. | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`target`: string): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts:409](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts#L409)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`target` | string | Address to remove authorization from. | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts:420](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts#L420)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`target`: string, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts:279](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts#L279)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`target` | string | - | Address to remove authorization from. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### removeAuthorizedAddressAtIndex + +#### ▪ **removeAuthorizedAddressAtIndex**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts:472](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts#L472)* + +Removes authorizion of an address. + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`target`: string, `index`: `BigNumber`, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts:522](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts#L522)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`target` | string | - | Address to remove authorization from. | +`index` | `BigNumber` | - | Index of target in authorities array. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`target`: string, `index`: `BigNumber`, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts:590](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts#L590)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`target` | string | - | Address to remove authorization from. | +`index` | `BigNumber` | - | Index of target in authorities array. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +#### estimateGasAsync + +▸ **estimateGasAsync**(`target`: string, `index`: `BigNumber`, `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts:556](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts#L556)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`target` | string | Address to remove authorization from. | +`index` | `BigNumber` | Index of target in authorities array. | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`target`: string, `index`: `BigNumber`): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts:644](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts#L644)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`target` | string | Address to remove authorization from. | +`index` | `BigNumber` | Index of target in authorities array. | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts:657](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts#L657)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`target`: string, `index`: `BigNumber`, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts:481](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts#L481)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`target` | string | - | Address to remove authorization from. | +`index` | `BigNumber` | - | Index of target in authorities array. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### transferOwnership + +#### ▪ **transferOwnership**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts:797](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts#L797)* + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`newOwner`: string, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts:838](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts#L838)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`newOwner` | string | - | - | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`newOwner`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts:887](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts#L887)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`newOwner` | string | - | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +#### estimateGasAsync + +▸ **estimateGasAsync**(`newOwner`: string, `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts:863](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts#L863)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`newOwner` | string | - | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`newOwner`: string): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts:930](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts#L930)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | +------ | ------ | +`newOwner` | string | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts:941](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts#L941)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`newOwner`: string, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts:804](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts#L804)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`newOwner` | string | - | - | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +
+ +# Class: ERC721TokenContract + + +## Constructors + + + +\+ **new ERC721TokenContract**(`address`: string, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults?`: `Partial`, `logDecodeDependencies?`: undefined | object, `deployedBytecode`: string | undefined): *[ERC721TokenContract](#class-erc721tokencontract)* + +*Overrides void* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:1735](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L1735)* + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`address` | string | - | +`supportedProvider` | [SupportedProvider](#supportedprovider) | - | +`txDefaults?` | `Partial` | - | +`logDecodeDependencies?` | undefined \| object | - | +`deployedBytecode` | string \| undefined | ERC721TokenContract.deployedBytecode | + +**Returns:** *[ERC721TokenContract](#class-erc721tokencontract)* + +## Properties + +#### `Optional` _deployedBytecodeIfExists + +• **_deployedBytecodeIfExists**? : *`Buffer`* + + + +Defined in base-contract/lib/src/index.d.ts:31 + +___ + +### abi + +• **abi**: *[ContractAbi](#contractabi)* + + + +Defined in base-contract/lib/src/index.d.ts:27 + +___ + +### address + +• **address**: *string* + + + +Defined in base-contract/lib/src/index.d.ts:28 + +___ + +Args + +• **constructorArgs**: *any[]* + + + +Defined in base-contract/lib/src/index.d.ts:30 + +___ + +### contractName + +• **contractName**: *string* + + + +Defined in base-contract/lib/src/index.d.ts:29 + +## Methods + +### getLogsAsync + +▸ **getLogsAsync**<**ArgsType**>(`eventName`: [ERC721TokenEvents](#enumeration-erc721tokenevents), `blockRange`: `BlockRange`, `indexFilterValues`: `IndexedFilterValues`): *`Promise>>`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:1719](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L1719)* + +Gets historical logs without creating a subscription + +**Type parameters:** + +▪ **ArgsType**: *[ERC721TokenEventArgs](#erc721tokeneventargs)* + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`eventName` | [ERC721TokenEvents](#enumeration-erc721tokenevents) | The ERC721Token contract event you would like to subscribe to. | +`blockRange` | `BlockRange` | Block range to get logs from. | +`indexFilterValues` | `IndexedFilterValues` | An object where the keys are indexed args returned by the event and the value is the value you are interested in. E.g `{_from: aUserAddressHex}` | + +**Returns:** *`Promise>>`* + +Array of logs that match the parameters + +___ + +### subscribe + +▸ **subscribe**<**ArgsType**>(`eventName`: [ERC721TokenEvents](#enumeration-erc721tokenevents), `indexFilterValues`: `IndexedFilterValues`, `callback`: [EventCallback](#eventcallback)‹*`ArgsType`*›, `isVerbose`: boolean, `blockPollingIntervalMs?`: undefined | number): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:1677](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L1677)* + +Subscribe to an event type emitted by the ERC721Token contract. + +**Type parameters:** + +▪ **ArgsType**: *[ERC721TokenEventArgs](#erc721tokeneventargs)* + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`eventName` | [ERC721TokenEvents](#enumeration-erc721tokenevents) | - | The ERC721Token contract event you would like to subscribe to. | +`indexFilterValues` | `IndexedFilterValues` | - | An object where the keys are indexed args returned by the event and the value is the value you are interested in. E.g `{maker: aUserAddressHex}` | +`callback` | [EventCallback](#eventcallback)‹*`ArgsType`*› | - | Callback that gets called when a log is added/removed | +`isVerbose` | boolean | false | Enable verbose subscription warnings (e.g recoverable network issues encountered) | +`blockPollingIntervalMs?` | undefined \| number | - | - | + +**Returns:** *string* + +Subscription token used later to unsubscribe + +___ + +### unsubscribe + +▸ **unsubscribe**(`subscriptionToken`: string): *void* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:1702](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L1702)* + +Cancel a subscription + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`subscriptionToken` | string | Subscription token returned by `subscribe()` | + +**Returns:** *void* + +___ + +### unsubscribeAll + +▸ **unsubscribeAll**(): *void* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:1708](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L1708)* + +Cancels all existing subscriptions + +**Returns:** *void* + +___ + +### `Static` ABI + +▸ **ABI**(): *[ContractAbi](#contractabi)* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:1408](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L1408)* + +**Returns:** *[ContractAbi](#contractabi)* + +The contract ABI + +___ + +### `Static` deployAsync + +▸ **deployAsync**(`bytecode`: string, `abi`: [ContractAbi](#contractabi), `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:1366](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L1366)* + +**Parameters:** + +Name | Type | +------ | ------ | +`bytecode` | string | +`abi` | [ContractAbi](#contractabi) | +`supportedProvider` | [SupportedProvider](#supportedprovider) | +`txDefaults` | `Partial` | +`logDecodeDependencies` | object | + +**Returns:** *`Promise`* + +___ + +### `Static` deployFrom0xArtifactAsync + +▸ **deployFrom0xArtifactAsync**(`artifact`: `ContractArtifact` | `SimpleContractArtifact`, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:1341](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L1341)* + +**Parameters:** + +Name | Type | +------ | ------ | +`artifact` | `ContractArtifact` \| `SimpleContractArtifact` | +`supportedProvider` | [SupportedProvider](#supportedprovider) | +`txDefaults` | `Partial` | +`logDecodeDependencies` | object | + +**Returns:** *`Promise`* + +___ + +### `Static` strictArgumentEncodingCheck + +▸ **strictArgumentEncodingCheck**(`inputAbi`: `DataItem`[], `args`: any[]): *string* + + + +Defined in base-contract/lib/src/index.d.ts:41 + +**Parameters:** + +Name | Type | +------ | ------ | +`inputAbi` | `DataItem`[] | +`args` | any[] | + +**Returns:** *string* + +## Object literals + +### approve + +#### ▪ **approve**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:76](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L76)* + +The zero address indicates there is no approved address. +Throws unless `msg.sender` is the current NFT owner, or an authorized +operator of the current owner. + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`_approved`: string, `_tokenId`: `BigNumber`, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:126](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L126)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_approved` | string | - | The new approved NFT controller | +`_tokenId` | `BigNumber` | - | The NFT to approve | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`_approved`: string, `_tokenId`: `BigNumber`, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:189](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L189)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_approved` | string | - | The new approved NFT controller | +`_tokenId` | `BigNumber` | - | The NFT to approve | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +#### estimateGasAsync + +▸ **estimateGasAsync**(`_approved`: string, `_tokenId`: `BigNumber`, `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:155](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L155)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`_approved` | string | The new approved NFT controller | +`_tokenId` | `BigNumber` | The NFT to approve | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`_approved`: string, `_tokenId`: `BigNumber`): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:243](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L243)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`_approved` | string | The new approved NFT controller | +`_tokenId` | `BigNumber` | The NFT to approve | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:256](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L256)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`_approved`: string, `_tokenId`: `BigNumber`, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:85](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L85)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_approved` | string | - | The new approved NFT controller | +`_tokenId` | `BigNumber` | - | The NFT to approve | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### balanceOf + +#### ▪ **balanceOf**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:266](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L266)* + +NFTs assigned to the zero address are considered invalid, and this +function throws for queries about the zero address. + +#### callAsync + +▸ **callAsync**(`_owner`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:274](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L274)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_owner` | string | - | An address for whom to query the balance | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +The number of NFTs owned by `_owner`, possibly zero + +___ + +### getApproved + +#### ▪ **getApproved**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:319](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L319)* + +Throws if `_tokenId` is not a valid NFT. + +#### callAsync + +▸ **callAsync**(`_tokenId`: `BigNumber`, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:327](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L327)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_tokenId` | `BigNumber` | - | The NFT to find the approved address for | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +The approved address for this NFT, or the zero address if there is none + +___ + +### isApprovedForAll + +#### ▪ **isApprovedForAll**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:369](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L369)* + +#### callAsync + +▸ **callAsync**(`_owner`: string, `_operator`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:378](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L378)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_owner` | string | - | The address that owns the NFTs | +`_operator` | string | - | The address that acts on behalf of the owner | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +True if `_operator` is an approved operator for `_owner`, false otherwise + +___ + +### ownerOf + +#### ▪ **ownerOf**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:429](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L429)* + +NFTs assigned to zero address are considered invalid, and queries +about them do throw. + +#### callAsync + +▸ **callAsync**(`_tokenId`: `BigNumber`, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:437](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L437)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_tokenId` | `BigNumber` | - | The identifier for an NFT | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +The address of the owner of the NFT + +___ + +### safeTransferFrom1 + +#### ▪ **safeTransferFrom1**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:483](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L483)* + +This works identically to the other function with an extra data parameter, +except this function just sets data to "". + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`_from`: string, `_to`: string, `_tokenId`: `BigNumber`, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:538](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L538)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_from` | string | - | The current owner of the NFT | +`_to` | string | - | The new owner | +`_tokenId` | `BigNumber` | - | The NFT to transfer | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`_from`: string, `_to`: string, `_tokenId`: `BigNumber`, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:614](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L614)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_from` | string | - | The current owner of the NFT | +`_to` | string | - | The new owner | +`_tokenId` | `BigNumber` | - | The NFT to transfer | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +#### estimateGasAsync + +▸ **estimateGasAsync**(`_from`: string, `_to`: string, `_tokenId`: `BigNumber`, `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:576](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L576)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`_from` | string | The current owner of the NFT | +`_to` | string | The new owner | +`_tokenId` | `BigNumber` | The NFT to transfer | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`_from`: string, `_to`: string, `_tokenId`: `BigNumber`): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:672](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L672)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`_from` | string | The current owner of the NFT | +`_to` | string | The new owner | +`_tokenId` | `BigNumber` | The NFT to transfer | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:687](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L687)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`_from`: string, `_to`: string, `_tokenId`: `BigNumber`, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:493](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L493)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_from` | string | - | The current owner of the NFT | +`_to` | string | - | The new owner | +`_tokenId` | `BigNumber` | - | The NFT to transfer | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### safeTransferFrom2 + +#### ▪ **safeTransferFrom2**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:702](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L702)* + +Throws unless `msg.sender` is the current owner, an authorized +operator, or the approved address for this NFT. Throws if `_from` is +not the current owner. Throws if `_to` is the zero address. Throws if +`_tokenId` is not a valid NFT. When transfer is complete, this function +checks if `_to` is a smart contract (code size > 0). If so, it calls +`onERC721Received` on `_to` and throws if the return value is not +`bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`. + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`_from`: string, `_to`: string, `_tokenId`: `BigNumber`, `_data`: string, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:762](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L762)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_from` | string | - | The current owner of the NFT | +`_to` | string | - | The new owner | +`_tokenId` | `BigNumber` | - | The NFT to transfer | +`_data` | string | - | Additional data with no specified format, sent in call to `_to` | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`_from`: string, `_to`: string, `_tokenId`: `BigNumber`, `_data`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:846](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L846)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_from` | string | - | The current owner of the NFT | +`_to` | string | - | The new owner | +`_tokenId` | `BigNumber` | - | The NFT to transfer | +`_data` | string | - | Additional data with no specified format, sent in call to `_to` | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +#### estimateGasAsync + +▸ **estimateGasAsync**(`_from`: string, `_to`: string, `_tokenId`: `BigNumber`, `_data`: string, `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:804](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L804)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`_from` | string | The current owner of the NFT | +`_to` | string | The new owner | +`_tokenId` | `BigNumber` | The NFT to transfer | +`_data` | string | Additional data with no specified format, sent in call to `_to` | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`_from`: string, `_to`: string, `_tokenId`: `BigNumber`, `_data`: string): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:908](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L908)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`_from` | string | The current owner of the NFT | +`_to` | string | The new owner | +`_tokenId` | `BigNumber` | The NFT to transfer | +`_data` | string | Additional data with no specified format, sent in call to `_to` | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:923](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L923)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`_from`: string, `_to`: string, `_tokenId`: `BigNumber`, `_data`: string, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:713](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L713)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_from` | string | - | The current owner of the NFT | +`_to` | string | - | The new owner | +`_tokenId` | `BigNumber` | - | The NFT to transfer | +`_data` | string | - | Additional data with no specified format, sent in call to `_to` | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### setApprovalForAll + +#### ▪ **setApprovalForAll**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:933](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L933)* + +Emits the ApprovalForAll event. The contract MUST allow +multiple operators per owner. + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`_operator`: string, `_approved`: boolean, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:983](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L983)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_operator` | string | - | Address to add to the set of authorized operators | +`_approved` | boolean | - | True if the operator is approved, false to revoke approval | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`_operator`: string, `_approved`: boolean, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:1051](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L1051)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_operator` | string | - | Address to add to the set of authorized operators | +`_approved` | boolean | - | True if the operator is approved, false to revoke approval | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +#### estimateGasAsync + +▸ **estimateGasAsync**(`_operator`: string, `_approved`: boolean, `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:1017](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L1017)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`_operator` | string | Address to add to the set of authorized operators | +`_approved` | boolean | True if the operator is approved, false to revoke approval | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`_operator`: string, `_approved`: boolean): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:1105](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L1105)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`_operator` | string | Address to add to the set of authorized operators | +`_approved` | boolean | True if the operator is approved, false to revoke approval | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:1118](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L1118)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`_operator`: string, `_approved`: boolean, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:942](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L942)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_operator` | string | - | Address to add to the set of authorized operators | +`_approved` | boolean | - | True if the operator is approved, false to revoke approval | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### transferFrom + +#### ▪ **transferFrom**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:1130](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L1130)* + +Throws unless `msg.sender` is the current owner, an authorized +operator, or the approved address for this NFT. Throws if `_from` is +not the current owner. Throws if `_to` is the zero address. Throws if +`_tokenId` is not a valid NFT. + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`_from`: string, `_to`: string, `_tokenId`: `BigNumber`, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:1185](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L1185)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_from` | string | - | The current owner of the NFT | +`_to` | string | - | The new owner | +`_tokenId` | `BigNumber` | - | The NFT to transfer | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`_from`: string, `_to`: string, `_tokenId`: `BigNumber`, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:1261](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L1261)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_from` | string | - | The current owner of the NFT | +`_to` | string | - | The new owner | +`_tokenId` | `BigNumber` | - | The NFT to transfer | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +#### estimateGasAsync + +▸ **estimateGasAsync**(`_from`: string, `_to`: string, `_tokenId`: `BigNumber`, `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:1223](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L1223)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`_from` | string | The current owner of the NFT | +`_to` | string | The new owner | +`_tokenId` | `BigNumber` | The NFT to transfer | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`_from`: string, `_to`: string, `_tokenId`: `BigNumber`): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:1319](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L1319)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`_from` | string | The current owner of the NFT | +`_to` | string | The new owner | +`_tokenId` | `BigNumber` | The NFT to transfer | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:1334](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L1334)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`_from`: string, `_to`: string, `_tokenId`: `BigNumber`, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:1140](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L1140)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_from` | string | - | The current owner of the NFT | +`_to` | string | - | The new owner | +`_tokenId` | `BigNumber` | - | The NFT to transfer | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +
+ +# Class: ExchangeContract + + +## Constructors + + + +\+ **new ExchangeContract**(`address`: string, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults?`: `Partial`, `logDecodeDependencies?`: undefined | object, `deployedBytecode`: string | undefined): *[ExchangeContract](#class-exchangecontract)* + +*Overrides void* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:10951](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L10951)* + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`address` | string | - | +`supportedProvider` | [SupportedProvider](#supportedprovider) | - | +`txDefaults?` | `Partial` | - | +`logDecodeDependencies?` | undefined \| object | - | +`deployedBytecode` | string \| undefined | ExchangeContract.deployedBytecode | + +**Returns:** *[ExchangeContract](#class-exchangecontract)* + +## Properties + +#### `Optional` _deployedBytecodeIfExists + +• **_deployedBytecodeIfExists**? : *`Buffer`* + + + +Defined in base-contract/lib/src/index.d.ts:31 + +___ + +### abi + +• **abi**: *[ContractAbi](#contractabi)* + + + +Defined in base-contract/lib/src/index.d.ts:27 + +___ + +### address + +• **address**: *string* + + + +Defined in base-contract/lib/src/index.d.ts:28 + +___ + +Args + +• **constructorArgs**: *any[]* + + + +Defined in base-contract/lib/src/index.d.ts:30 + +___ + +### contractName + +• **contractName**: *string* + + + +Defined in base-contract/lib/src/index.d.ts:29 + +## Methods + +### getLogsAsync + +▸ **getLogsAsync**<**ArgsType**>(`eventName`: [ExchangeEvents](#enumeration-exchangeevents), `blockRange`: `BlockRange`, `indexFilterValues`: `IndexedFilterValues`): *`Promise>>`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:10935](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L10935)* + +Gets historical logs without creating a subscription + +**Type parameters:** + +▪ **ArgsType**: *[ExchangeEventArgs](#exchangeeventargs)* + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`eventName` | [ExchangeEvents](#enumeration-exchangeevents) | The Exchange contract event you would like to subscribe to. | +`blockRange` | `BlockRange` | Block range to get logs from. | +`indexFilterValues` | `IndexedFilterValues` | An object where the keys are indexed args returned by the event and the value is the value you are interested in. E.g `{_from: aUserAddressHex}` | + +**Returns:** *`Promise>>`* + +Array of logs that match the parameters + +___ + +### subscribe + +▸ **subscribe**<**ArgsType**>(`eventName`: [ExchangeEvents](#enumeration-exchangeevents), `indexFilterValues`: `IndexedFilterValues`, `callback`: [EventCallback](#eventcallback)‹*`ArgsType`*›, `isVerbose`: boolean, `blockPollingIntervalMs?`: undefined | number): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:10893](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L10893)* + +Subscribe to an event type emitted by the Exchange contract. + +**Type parameters:** + +▪ **ArgsType**: *[ExchangeEventArgs](#exchangeeventargs)* + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`eventName` | [ExchangeEvents](#enumeration-exchangeevents) | - | The Exchange contract event you would like to subscribe to. | +`indexFilterValues` | `IndexedFilterValues` | - | An object where the keys are indexed args returned by the event and the value is the value you are interested in. E.g `{maker: aUserAddressHex}` | +`callback` | [EventCallback](#eventcallback)‹*`ArgsType`*› | - | Callback that gets called when a log is added/removed | +`isVerbose` | boolean | false | Enable verbose subscription warnings (e.g recoverable network issues encountered) | +`blockPollingIntervalMs?` | undefined \| number | - | - | + +**Returns:** *string* + +Subscription token used later to unsubscribe + +___ + +### unsubscribe + +▸ **unsubscribe**(`subscriptionToken`: string): *void* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:10918](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L10918)* + +Cancel a subscription + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`subscriptionToken` | string | Subscription token returned by `subscribe()` | + +**Returns:** *void* + +___ + +### unsubscribeAll + +▸ **unsubscribeAll**(): *void* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:10924](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L10924)* + +Cancels all existing subscriptions + +**Returns:** *void* + +___ + +### `Static` ABI + +▸ **ABI**(): *[ContractAbi](#contractabi)* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:8004](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L8004)* + +**Returns:** *[ContractAbi](#contractabi)* + +The contract ABI + +___ + +### `Static` deployAsync + +▸ **deployAsync**(`bytecode`: string, `abi`: [ContractAbi](#contractabi), `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object, `chainId`: `BigNumber`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7957](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7957)* + +**Parameters:** + +Name | Type | +------ | ------ | +`bytecode` | string | +`abi` | [ContractAbi](#contractabi) | +`supportedProvider` | [SupportedProvider](#supportedprovider) | +`txDefaults` | `Partial` | +`logDecodeDependencies` | object | +`chainId` | `BigNumber` | + +**Returns:** *`Promise`* + +___ + +### `Static` deployFrom0xArtifactAsync + +▸ **deployFrom0xArtifactAsync**(`artifact`: `ContractArtifact` | `SimpleContractArtifact`, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object, `chainId`: `BigNumber`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7931](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7931)* + +**Parameters:** + +Name | Type | +------ | ------ | +`artifact` | `ContractArtifact` \| `SimpleContractArtifact` | +`supportedProvider` | [SupportedProvider](#supportedprovider) | +`txDefaults` | `Partial` | +`logDecodeDependencies` | object | +`chainId` | `BigNumber` | + +**Returns:** *`Promise`* + +___ + +### `Static` strictArgumentEncodingCheck + +▸ **strictArgumentEncodingCheck**(`inputAbi`: `DataItem`[], `args`: any[]): *string* + + + +Defined in base-contract/lib/src/index.d.ts:41 + +**Parameters:** + +Name | Type | +------ | ------ | +`inputAbi` | `DataItem`[] | +`args` | any[] | + +**Returns:** *string* + +## Object literals + +### EIP1271_MAGIC_VALUE + +#### ▪ **EIP1271_MAGIC_VALUE**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:120](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L120)* + +#### callAsync + +▸ **callAsync**(`callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:126](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L126)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +___ + +### EIP712_EXCHANGE_DOMAIN_HASH + +#### ▪ **EIP712_EXCHANGE_DOMAIN_HASH**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:163](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L163)* + +#### callAsync + +▸ **callAsync**(`callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:169](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L169)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +___ + +### allowedValidators + +#### ▪ **allowedValidators**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:206](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L206)* + +#### callAsync + +▸ **callAsync**(`index_0`: string, `index_1`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:212](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L212)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`index_0` | string | - | +`index_1` | string | - | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +___ + +### batchCancelOrders + +#### ▪ **batchCancelOrders**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:262](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L262)* + +Executes multiple calls of cancelOrder. + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`orders`: `Array`, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:323](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L323)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`orders` | `Array` | - | Array of order specifications. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`orders`: `Array`, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:410](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L410)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`orders` | `Array` | - | Array of order specifications. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +#### estimateGasAsync + +▸ **estimateGasAsync**(`orders`: `Array`, `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:364](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L364)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`orders` | `Array` | Array of order specifications. | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`orders`: `Array`): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:478](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L478)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`orders` | `Array` | Array of order specifications. | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:507](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L507)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`orders`: `Array`, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:270](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L270)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`orders` | `Array` | - | Array of order specifications. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### batchExecuteTransactions + +#### ▪ **batchExecuteTransactions**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:518](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L518)* + +Executes a batch of Exchange method calls in the context of signer(s). + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`transactions`: `Array`, `signatures`: string[], `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:576](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L576)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`transactions` | `Array` | - | Array of 0x transaction structures. | +`signatures` | string[] | - | Array of proofs that transactions have been signed by signer(s). | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`transactions`: `Array`, `signatures`: string[], `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:659](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L659)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`transactions` | `Array` | - | Array of 0x transaction structures. | +`signatures` | string[] | - | Array of proofs that transactions have been signed by signer(s). | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +Array containing ABI encoded return data for each of the underlying Exchange function calls. + +#### estimateGasAsync + +▸ **estimateGasAsync**(`transactions`: `Array`, `signatures`: string[], `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:617](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L617)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`transactions` | `Array` | Array of 0x transaction structures. | +`signatures` | string[] | Array of proofs that transactions have been signed by signer(s). | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`transactions`: `Array`, `signatures`: string[]): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:722](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L722)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`transactions` | `Array` | Array of 0x transaction structures. | +`signatures` | string[] | Array of proofs that transactions have been signed by signer(s). | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:744](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L744)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`transactions`: `Array`, `signatures`: string[], `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:528](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L528)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`transactions` | `Array` | - | Array of 0x transaction structures. | +`signatures` | string[] | - | Array of proofs that transactions have been signed by signer(s). | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### batchFillOrKillOrders + +#### ▪ **batchFillOrKillOrders**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:755](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L755)* + +Executes multiple calls of fillOrKillOrder. + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`orders`: `Array`, `takerAssetFillAmounts`: `BigNumber`[], `signatures`: string[], `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:831](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L831)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`orders` | `Array` | - | Array of order specifications. | +`takerAssetFillAmounts` | `BigNumber`[] | - | Array of desired amounts of takerAsset to sell in orders. | +`signatures` | string[] | - | Proofs that orders have been created by makers. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`orders`: `Array`, `takerAssetFillAmounts`: `BigNumber`[], `signatures`: string[], `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise>`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:939](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L939)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`orders` | `Array` | - | Array of order specifications. | +`takerAssetFillAmounts` | `BigNumber`[] | - | Array of desired amounts of takerAsset to sell in orders. | +`signatures` | string[] | - | Proofs that orders have been created by makers. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise>`* + +Array of amounts filled and fees paid by makers and taker. + +#### estimateGasAsync + +▸ **estimateGasAsync**(`orders`: `Array`, `takerAssetFillAmounts`: `BigNumber`[], `signatures`: string[], `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:885](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L885)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`orders` | `Array` | Array of order specifications. | +`takerAssetFillAmounts` | `BigNumber`[] | Array of desired amounts of takerAsset to sell in orders. | +`signatures` | string[] | Proofs that orders have been created by makers. | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`orders`: `Array`, `takerAssetFillAmounts`: `BigNumber`[], `signatures`: string[]): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:1030](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L1030)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`orders` | `Array` | Array of order specifications. | +`takerAssetFillAmounts` | `BigNumber`[] | Array of desired amounts of takerAsset to sell in orders. | +`signatures` | string[] | Proofs that orders have been created by makers. | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:1063](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L1063)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`orders`: `Array`, `takerAssetFillAmounts`: `BigNumber`[], `signatures`: string[], `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:766](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L766)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`orders` | `Array` | - | Array of order specifications. | +`takerAssetFillAmounts` | `BigNumber`[] | - | Array of desired amounts of takerAsset to sell in orders. | +`signatures` | string[] | - | Proofs that orders have been created by makers. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### batchFillOrders + +#### ▪ **batchFillOrders**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:1074](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L1074)* + +Executes multiple calls of fillOrder. + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`orders`: `Array`, `takerAssetFillAmounts`: `BigNumber`[], `signatures`: string[], `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:1145](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L1145)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`orders` | `Array` | - | Array of order specifications. | +`takerAssetFillAmounts` | `BigNumber`[] | - | Array of desired amounts of takerAsset to sell in orders. | +`signatures` | string[] | - | Proofs that orders have been created by makers. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`orders`: `Array`, `takerAssetFillAmounts`: `BigNumber`[], `signatures`: string[], `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise>`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:1253](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L1253)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`orders` | `Array` | - | Array of order specifications. | +`takerAssetFillAmounts` | `BigNumber`[] | - | Array of desired amounts of takerAsset to sell in orders. | +`signatures` | string[] | - | Proofs that orders have been created by makers. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise>`* + +Array of amounts filled and fees paid by makers and taker. + +#### estimateGasAsync + +▸ **estimateGasAsync**(`orders`: `Array`, `takerAssetFillAmounts`: `BigNumber`[], `signatures`: string[], `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:1199](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L1199)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`orders` | `Array` | Array of order specifications. | +`takerAssetFillAmounts` | `BigNumber`[] | Array of desired amounts of takerAsset to sell in orders. | +`signatures` | string[] | Proofs that orders have been created by makers. | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`orders`: `Array`, `takerAssetFillAmounts`: `BigNumber`[], `signatures`: string[]): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:1344](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L1344)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`orders` | `Array` | Array of order specifications. | +`takerAssetFillAmounts` | `BigNumber`[] | Array of desired amounts of takerAsset to sell in orders. | +`signatures` | string[] | Proofs that orders have been created by makers. | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:1377](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L1377)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`orders`: `Array`, `takerAssetFillAmounts`: `BigNumber`[], `signatures`: string[], `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:1085](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L1085)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`orders` | `Array` | - | Array of order specifications. | +`takerAssetFillAmounts` | `BigNumber`[] | - | Array of desired amounts of takerAsset to sell in orders. | +`signatures` | string[] | - | Proofs that orders have been created by makers. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### batchFillOrdersNoThrow + +#### ▪ **batchFillOrdersNoThrow**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:1388](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L1388)* + +Executes multiple calls of fillOrder. If any fill reverts, the error is caught and ignored. + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`orders`: `Array`, `takerAssetFillAmounts`: `BigNumber`[], `signatures`: string[], `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:1464](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L1464)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`orders` | `Array` | - | Array of order specifications. | +`takerAssetFillAmounts` | `BigNumber`[] | - | Array of desired amounts of takerAsset to sell in orders. | +`signatures` | string[] | - | Proofs that orders have been created by makers. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`orders`: `Array`, `takerAssetFillAmounts`: `BigNumber`[], `signatures`: string[], `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise>`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:1572](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L1572)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`orders` | `Array` | - | Array of order specifications. | +`takerAssetFillAmounts` | `BigNumber`[] | - | Array of desired amounts of takerAsset to sell in orders. | +`signatures` | string[] | - | Proofs that orders have been created by makers. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise>`* + +Array of amounts filled and fees paid by makers and taker. + +#### estimateGasAsync + +▸ **estimateGasAsync**(`orders`: `Array`, `takerAssetFillAmounts`: `BigNumber`[], `signatures`: string[], `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:1518](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L1518)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`orders` | `Array` | Array of order specifications. | +`takerAssetFillAmounts` | `BigNumber`[] | Array of desired amounts of takerAsset to sell in orders. | +`signatures` | string[] | Proofs that orders have been created by makers. | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`orders`: `Array`, `takerAssetFillAmounts`: `BigNumber`[], `signatures`: string[]): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:1663](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L1663)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`orders` | `Array` | Array of order specifications. | +`takerAssetFillAmounts` | `BigNumber`[] | Array of desired amounts of takerAsset to sell in orders. | +`signatures` | string[] | Proofs that orders have been created by makers. | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:1696](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L1696)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`orders`: `Array`, `takerAssetFillAmounts`: `BigNumber`[], `signatures`: string[], `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:1399](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L1399)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`orders` | `Array` | - | Array of order specifications. | +`takerAssetFillAmounts` | `BigNumber`[] | - | Array of desired amounts of takerAsset to sell in orders. | +`signatures` | string[] | - | Proofs that orders have been created by makers. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### batchMatchOrders + +#### ▪ **batchMatchOrders**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:1709](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L1709)* + +Match complementary orders that have a profitable spread. +Each order is filled at their respective price point, and +the matcher receives a profit denominated in the left maker asset. + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`leftOrders`: `Array`, `rightOrders`: `Array`, `leftSignatures`: string[], `rightSignatures`: string[], `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:1807](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L1807)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`leftOrders` | `Array` | - | Set of orders with the same maker / taker asset. | +`rightOrders` | `Array` | - | Set of orders to match against `leftOrders` | +`leftSignatures` | string[] | - | Proof that left orders were created by the left makers. | +`rightSignatures` | string[] | - | Proof that right orders were created by the right makers. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`leftOrders`: `Array`, `rightOrders`: `Array`, `leftSignatures`: string[], `rightSignatures`: string[], `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:1954](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L1954)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`leftOrders` | `Array` | - | Set of orders with the same maker / taker asset. | +`rightOrders` | `Array` | - | Set of orders to match against `leftOrders` | +`leftSignatures` | string[] | - | Proof that left orders were created by the left makers. | +`rightSignatures` | string[] | - | Proof that right orders were created by the right makers. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +batchMatchedFillResults Amounts filled and profit generated. + +#### estimateGasAsync + +▸ **estimateGasAsync**(`leftOrders`: `Array`, `rightOrders`: `Array`, `leftSignatures`: string[], `rightSignatures`: string[], `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:1881](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L1881)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`leftOrders` | `Array` | Set of orders with the same maker / taker asset. | +`rightOrders` | `Array` | Set of orders to match against `leftOrders` | +`leftSignatures` | string[] | Proof that left orders were created by the left makers. | +`rightSignatures` | string[] | Proof that right orders were created by the right makers. | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`leftOrders`: `Array`, `rightOrders`: `Array`, `leftSignatures`: string[], `rightSignatures`: string[]): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:2082](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L2082)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`leftOrders` | `Array` | Set of orders with the same maker / taker asset. | +`rightOrders` | `Array` | Set of orders to match against `leftOrders` | +`leftSignatures` | string[] | Proof that left orders were created by the left makers. | +`rightSignatures` | string[] | Proof that right orders were created by the right makers. | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:2132](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L2132)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`leftOrders`: `Array`, `rightOrders`: `Array`, `leftSignatures`: string[], `rightSignatures`: string[], `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:1722](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L1722)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`leftOrders` | `Array` | - | Set of orders with the same maker / taker asset. | +`rightOrders` | `Array` | - | Set of orders to match against `leftOrders` | +`leftSignatures` | string[] | - | Proof that left orders were created by the left makers. | +`rightSignatures` | string[] | - | Proof that right orders were created by the right makers. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### batchMatchOrdersWithMaximalFill + +#### ▪ **batchMatchOrdersWithMaximalFill**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:2146](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L2146)* + +Match complementary orders that have a profitable spread. +Each order is maximally filled at their respective price point, and +the matcher receives a profit denominated in either the left maker asset, +right maker asset, or a combination of both. + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`leftOrders`: `Array`, `rightOrders`: `Array`, `leftSignatures`: string[], `rightSignatures`: string[], `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:2244](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L2244)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`leftOrders` | `Array` | - | Set of orders with the same maker / taker asset. | +`rightOrders` | `Array` | - | Set of orders to match against `leftOrders` | +`leftSignatures` | string[] | - | Proof that left orders were created by the left makers. | +`rightSignatures` | string[] | - | Proof that right orders were created by the right makers. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`leftOrders`: `Array`, `rightOrders`: `Array`, `leftSignatures`: string[], `rightSignatures`: string[], `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:2391](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L2391)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`leftOrders` | `Array` | - | Set of orders with the same maker / taker asset. | +`rightOrders` | `Array` | - | Set of orders to match against `leftOrders` | +`leftSignatures` | string[] | - | Proof that left orders were created by the left makers. | +`rightSignatures` | string[] | - | Proof that right orders were created by the right makers. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +batchMatchedFillResults Amounts filled and profit generated. + +#### estimateGasAsync + +▸ **estimateGasAsync**(`leftOrders`: `Array`, `rightOrders`: `Array`, `leftSignatures`: string[], `rightSignatures`: string[], `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:2318](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L2318)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`leftOrders` | `Array` | Set of orders with the same maker / taker asset. | +`rightOrders` | `Array` | Set of orders to match against `leftOrders` | +`leftSignatures` | string[] | Proof that left orders were created by the left makers. | +`rightSignatures` | string[] | Proof that right orders were created by the right makers. | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`leftOrders`: `Array`, `rightOrders`: `Array`, `leftSignatures`: string[], `rightSignatures`: string[]): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:2519](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L2519)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`leftOrders` | `Array` | Set of orders with the same maker / taker asset. | +`rightOrders` | `Array` | Set of orders to match against `leftOrders` | +`leftSignatures` | string[] | Proof that left orders were created by the left makers. | +`rightSignatures` | string[] | Proof that right orders were created by the right makers. | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:2569](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L2569)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`leftOrders`: `Array`, `rightOrders`: `Array`, `leftSignatures`: string[], `rightSignatures`: string[], `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:2159](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L2159)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`leftOrders` | `Array` | - | Set of orders with the same maker / taker asset. | +`rightOrders` | `Array` | - | Set of orders to match against `leftOrders` | +`leftSignatures` | string[] | - | Proof that left orders were created by the left makers. | +`rightSignatures` | string[] | - | Proof that right orders were created by the right makers. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### cancelOrder + +#### ▪ **cancelOrder**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:2580](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L2580)* + +After calling, the order can not be filled anymore. + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`order`: object, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:2640](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L2640)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`order` | object | - | Order struct containing order specifications. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`order`: object, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:2725](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L2725)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`order` | object | - | Order struct containing order specifications. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +#### estimateGasAsync + +▸ **estimateGasAsync**(`order`: object, `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:2680](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L2680)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`order` | object | Order struct containing order specifications. | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`order`: object): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:2792](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L2792)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`order` | object | Order struct containing order specifications. | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:2818](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L2818)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`order`: object, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:2588](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L2588)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`order` | object | - | Order struct containing order specifications. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### cancelOrdersUpTo + +#### ▪ **cancelOrdersUpTo**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:2830](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L2830)* + +Cancels all orders created by makerAddress with a salt less than or equal to the targetOrderEpoch +and senderAddress equal to msg.sender (or null address if msg.sender == makerAddress). + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`targetOrderEpoch`: `BigNumber`, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:2875](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L2875)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`targetOrderEpoch` | `BigNumber` | - | Orders created with a salt less or equal to this value will be cancelled. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`targetOrderEpoch`: `BigNumber`, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:2928](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L2928)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`targetOrderEpoch` | `BigNumber` | - | Orders created with a salt less or equal to this value will be cancelled. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +#### estimateGasAsync + +▸ **estimateGasAsync**(`targetOrderEpoch`: `BigNumber`, `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:2902](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L2902)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`targetOrderEpoch` | `BigNumber` | Orders created with a salt less or equal to this value will be cancelled. | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`targetOrderEpoch`: `BigNumber`): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:2977](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L2977)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`targetOrderEpoch` | `BigNumber` | Orders created with a salt less or equal to this value will be cancelled. | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:2988](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L2988)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`targetOrderEpoch`: `BigNumber`, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:2839](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L2839)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`targetOrderEpoch` | `BigNumber` | - | Orders created with a salt less or equal to this value will be cancelled. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### cancelled + +#### ▪ **cancelled**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:2994](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L2994)* + +#### callAsync + +▸ **callAsync**(`index_0`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3000](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3000)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`index_0` | string | - | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +___ + +### currentContextAddress + +#### ▪ **currentContextAddress**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3042](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3042)* + +#### callAsync + +▸ **callAsync**(`callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3048](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3048)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +___ + +### executeTransaction + +#### ▪ **executeTransaction**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3088](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3088)* + +Executes an Exchange method call in the context of signer. + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`transaction`: object, `signature`: string, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3143](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3143)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`transaction` | object | - | 0x transaction structure. | +`signature` | string | - | Proof that transaction has been signed by signer. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`transaction`: object, `signature`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3217](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3217)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`transaction` | object | - | 0x transaction structure. | +`signature` | string | - | Proof that transaction has been signed by signer. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +ABI encoded return data of the underlying Exchange function call. + +#### estimateGasAsync + +▸ **estimateGasAsync**(`transaction`: object, `signature`: string, `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3177](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3177)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`transaction` | object | 0x transaction structure. | +`signature` | string | Proof that transaction has been signed by signer. | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`transaction`: object, `signature`: string): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3278](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3278)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`transaction` | object | 0x transaction structure. | +`signature` | string | Proof that transaction has been signed by signer. | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3299](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3299)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`transaction`: object, `signature`: string, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3097](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3097)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`transaction` | object | - | 0x transaction structure. | +`signature` | string | - | Proof that transaction has been signed by signer. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### fillOrKillOrder + +#### ▪ **fillOrKillOrder**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3310](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3310)* + +Fills the input order. Reverts if exact takerAssetFillAmount not filled. + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`order`: object, `takerAssetFillAmount`: `BigNumber`, `signature`: string, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3378](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3378)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`order` | object | - | Order struct containing order specifications. | +`takerAssetFillAmount` | `BigNumber` | - | Desired amount of takerAsset to sell. | +`signature` | string | - | Proof that order has been created by maker. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`order`: object, `takerAssetFillAmount`: `BigNumber`, `signature`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3481](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3481)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`order` | object | - | Order struct containing order specifications. | +`takerAssetFillAmount` | `BigNumber` | - | Desired amount of takerAsset to sell. | +`signature` | string | - | Proof that order has been created by maker. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +#### estimateGasAsync + +▸ **estimateGasAsync**(`order`: object, `takerAssetFillAmount`: `BigNumber`, `signature`: string, `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3430](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3430)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`order` | object | Order struct containing order specifications. | +`takerAssetFillAmount` | `BigNumber` | Desired amount of takerAsset to sell. | +`signature` | string | Proof that order has been created by maker. | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`order`: object, `takerAssetFillAmount`: `BigNumber`, `signature`: string): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3566](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3566)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`order` | object | Order struct containing order specifications. | +`takerAssetFillAmount` | `BigNumber` | Desired amount of takerAsset to sell. | +`signature` | string | Proof that order has been created by maker. | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3598](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3598)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`order`: object, `takerAssetFillAmount`: `BigNumber`, `signature`: string, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3320](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3320)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`order` | object | - | Order struct containing order specifications. | +`takerAssetFillAmount` | `BigNumber` | - | Desired amount of takerAsset to sell. | +`signature` | string | - | Proof that order has been created by maker. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### fillOrder + +#### ▪ **fillOrder**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3609](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3609)* + +Fills the input order. + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`order`: object, `takerAssetFillAmount`: `BigNumber`, `signature`: string, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3677](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3677)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`order` | object | - | Order struct containing order specifications. | +`takerAssetFillAmount` | `BigNumber` | - | Desired amount of takerAsset to sell. | +`signature` | string | - | Proof that order has been created by maker. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`order`: object, `takerAssetFillAmount`: `BigNumber`, `signature`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3781](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3781)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`order` | object | - | Order struct containing order specifications. | +`takerAssetFillAmount` | `BigNumber` | - | Desired amount of takerAsset to sell. | +`signature` | string | - | Proof that order has been created by maker. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +Amounts filled and fees paid by maker and taker. + +#### estimateGasAsync + +▸ **estimateGasAsync**(`order`: object, `takerAssetFillAmount`: `BigNumber`, `signature`: string, `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3729](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3729)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`order` | object | Order struct containing order specifications. | +`takerAssetFillAmount` | `BigNumber` | Desired amount of takerAsset to sell. | +`signature` | string | Proof that order has been created by maker. | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`order`: object, `takerAssetFillAmount`: `BigNumber`, `signature`: string): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3866](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3866)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`order` | object | Order struct containing order specifications. | +`takerAssetFillAmount` | `BigNumber` | Desired amount of takerAsset to sell. | +`signature` | string | Proof that order has been created by maker. | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3898](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3898)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`order`: object, `takerAssetFillAmount`: `BigNumber`, `signature`: string, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3619](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3619)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`order` | object | - | Order struct containing order specifications. | +`takerAssetFillAmount` | `BigNumber` | - | Desired amount of takerAsset to sell. | +`signature` | string | - | Proof that order has been created by maker. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### filled + +#### ▪ **filled**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3906](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3906)* + +#### callAsync + +▸ **callAsync**(`index_0`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3912](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3912)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`index_0` | string | - | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +___ + +### getAssetProxy + +#### ▪ **getAssetProxy**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3957](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3957)* + +Gets an asset proxy. + +#### callAsync + +▸ **callAsync**(`assetProxyId`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:3965](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L3965)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`assetProxyId` | string | - | Id of the asset proxy. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +The asset proxy registered to assetProxyId. Returns 0x0 if no proxy is registered. + +___ + +### getOrderInfo + +#### ▪ **getOrderInfo**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4010](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4010)* + +Gets information about an order: status, hash, and amount filled. + +#### callAsync + +▸ **callAsync**(`order`: object, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4018](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4018)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`order` | object | - | Order to gather information on. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +OrderInfo Information about the order and its state. See LibOrder.OrderInfo for a complete description. + +___ + +### isValidHashSignature + +#### ▪ **isValidHashSignature**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4086](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4086)* + +Verifies that a hash has been signed by the given signer. + +#### callAsync + +▸ **callAsync**(`hash`: string, `signerAddress`: string, `signature`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4096](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4096)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`hash` | string | - | Any 32-byte hash. | +`signerAddress` | string | - | Address that should have signed the given hash. | +`signature` | string | - | Proof that the hash has been signed by signer. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +isValid `true` if the signature is valid for the given hash and signer. + +___ + +### isValidOrderSignature + +#### ▪ **isValidOrderSignature**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4149](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4149)* + +Verifies that a signature for an order is valid. + +#### callAsync + +▸ **callAsync**(`order`: object, `signature`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4158](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4158)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`order` | object | - | The order. | +`signature` | string | - | Proof that the order has been signed by signer. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +isValid `true` if the signature is valid for the given order and signer. + +___ + +### isValidTransactionSignature + +#### ▪ **isValidTransactionSignature**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4224](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4224)* + +Verifies that a signature for a transaction is valid. + +#### callAsync + +▸ **callAsync**(`transaction`: object, `signature`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4233](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4233)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`transaction` | object | - | The transaction. | +`signature` | string | - | Proof that the order has been signed by signer. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +isValid `true` if the signature is valid for the given transaction and signer. + +___ + +### marketBuyOrdersFillOrKill + +#### ▪ **marketBuyOrdersFillOrKill**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4291](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4291)* + +Calls marketBuyOrdersNoThrow then reverts if < makerAssetFillAmount has been bought. +NOTE: This function does not enforce that the makerAsset is the same for each order. + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`orders`: `Array`, `makerAssetFillAmount`: `BigNumber`, `signatures`: string[], `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4365](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4365)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`orders` | `Array` | - | Array of order specifications. | +`makerAssetFillAmount` | `BigNumber` | - | Minimum amount of makerAsset to buy. | +`signatures` | string[] | - | Proofs that orders have been signed by makers. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`orders`: `Array`, `makerAssetFillAmount`: `BigNumber`, `signatures`: string[], `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4471](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4471)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`orders` | `Array` | - | Array of order specifications. | +`makerAssetFillAmount` | `BigNumber` | - | Minimum amount of makerAsset to buy. | +`signatures` | string[] | - | Proofs that orders have been signed by makers. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +Amounts filled and fees paid by makers and taker. + +#### estimateGasAsync + +▸ **estimateGasAsync**(`orders`: `Array`, `makerAssetFillAmount`: `BigNumber`, `signatures`: string[], `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4418](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4418)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`orders` | `Array` | Array of order specifications. | +`makerAssetFillAmount` | `BigNumber` | Minimum amount of makerAsset to buy. | +`signatures` | string[] | Proofs that orders have been signed by makers. | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`orders`: `Array`, `makerAssetFillAmount`: `BigNumber`, `signatures`: string[]): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4557](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4557)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`orders` | `Array` | Array of order specifications. | +`makerAssetFillAmount` | `BigNumber` | Minimum amount of makerAsset to buy. | +`signatures` | string[] | Proofs that orders have been signed by makers. | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4590](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4590)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`orders`: `Array`, `makerAssetFillAmount`: `BigNumber`, `signatures`: string[], `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4301](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4301)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`orders` | `Array` | - | Array of order specifications. | +`makerAssetFillAmount` | `BigNumber` | - | Minimum amount of makerAsset to buy. | +`signatures` | string[] | - | Proofs that orders have been signed by makers. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### marketBuyOrdersNoThrow + +#### ▪ **marketBuyOrdersNoThrow**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4603](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4603)* + +Executes multiple calls of fillOrder until total amount of makerAsset is bought by taker. +If any fill reverts, the error is caught and ignored. +NOTE: This function does not enforce that the makerAsset is the same for each order. + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`orders`: `Array`, `makerAssetFillAmount`: `BigNumber`, `signatures`: string[], `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4677](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4677)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`orders` | `Array` | - | Array of order specifications. | +`makerAssetFillAmount` | `BigNumber` | - | Desired amount of makerAsset to buy. | +`signatures` | string[] | - | Proofs that orders have been signed by makers. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`orders`: `Array`, `makerAssetFillAmount`: `BigNumber`, `signatures`: string[], `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4783](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4783)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`orders` | `Array` | - | Array of order specifications. | +`makerAssetFillAmount` | `BigNumber` | - | Desired amount of makerAsset to buy. | +`signatures` | string[] | - | Proofs that orders have been signed by makers. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +Amounts filled and fees paid by makers and taker. + +#### estimateGasAsync + +▸ **estimateGasAsync**(`orders`: `Array`, `makerAssetFillAmount`: `BigNumber`, `signatures`: string[], `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4730](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4730)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`orders` | `Array` | Array of order specifications. | +`makerAssetFillAmount` | `BigNumber` | Desired amount of makerAsset to buy. | +`signatures` | string[] | Proofs that orders have been signed by makers. | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`orders`: `Array`, `makerAssetFillAmount`: `BigNumber`, `signatures`: string[]): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4869](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4869)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`orders` | `Array` | Array of order specifications. | +`makerAssetFillAmount` | `BigNumber` | Desired amount of makerAsset to buy. | +`signatures` | string[] | Proofs that orders have been signed by makers. | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4902](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4902)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`orders`: `Array`, `makerAssetFillAmount`: `BigNumber`, `signatures`: string[], `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4613](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4613)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`orders` | `Array` | - | Array of order specifications. | +`makerAssetFillAmount` | `BigNumber` | - | Desired amount of makerAsset to buy. | +`signatures` | string[] | - | Proofs that orders have been signed by makers. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### marketSellOrdersFillOrKill + +#### ▪ **marketSellOrdersFillOrKill**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4914](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4914)* + +Calls marketSellOrdersNoThrow then reverts if < takerAssetFillAmount has been sold. +NOTE: This function does not enforce that the takerAsset is the same for each order. + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`orders`: `Array`, `takerAssetFillAmount`: `BigNumber`, `signatures`: string[], `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4988](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4988)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`orders` | `Array` | - | Array of order specifications. | +`takerAssetFillAmount` | `BigNumber` | - | Minimum amount of takerAsset to sell. | +`signatures` | string[] | - | Proofs that orders have been signed by makers. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`orders`: `Array`, `takerAssetFillAmount`: `BigNumber`, `signatures`: string[], `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:5094](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L5094)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`orders` | `Array` | - | Array of order specifications. | +`takerAssetFillAmount` | `BigNumber` | - | Minimum amount of takerAsset to sell. | +`signatures` | string[] | - | Proofs that orders have been signed by makers. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +Amounts filled and fees paid by makers and taker. + +#### estimateGasAsync + +▸ **estimateGasAsync**(`orders`: `Array`, `takerAssetFillAmount`: `BigNumber`, `signatures`: string[], `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:5041](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L5041)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`orders` | `Array` | Array of order specifications. | +`takerAssetFillAmount` | `BigNumber` | Minimum amount of takerAsset to sell. | +`signatures` | string[] | Proofs that orders have been signed by makers. | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`orders`: `Array`, `takerAssetFillAmount`: `BigNumber`, `signatures`: string[]): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:5180](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L5180)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`orders` | `Array` | Array of order specifications. | +`takerAssetFillAmount` | `BigNumber` | Minimum amount of takerAsset to sell. | +`signatures` | string[] | Proofs that orders have been signed by makers. | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:5213](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L5213)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`orders`: `Array`, `takerAssetFillAmount`: `BigNumber`, `signatures`: string[], `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:4924](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L4924)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`orders` | `Array` | - | Array of order specifications. | +`takerAssetFillAmount` | `BigNumber` | - | Minimum amount of takerAsset to sell. | +`signatures` | string[] | - | Proofs that orders have been signed by makers. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### marketSellOrdersNoThrow + +#### ▪ **marketSellOrdersNoThrow**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:5226](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L5226)* + +Executes multiple calls of fillOrder until total amount of takerAsset is sold by taker. +If any fill reverts, the error is caught and ignored. +NOTE: This function does not enforce that the takerAsset is the same for each order. + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`orders`: `Array`, `takerAssetFillAmount`: `BigNumber`, `signatures`: string[], `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:5300](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L5300)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`orders` | `Array` | - | Array of order specifications. | +`takerAssetFillAmount` | `BigNumber` | - | Desired amount of takerAsset to sell. | +`signatures` | string[] | - | Proofs that orders have been signed by makers. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`orders`: `Array`, `takerAssetFillAmount`: `BigNumber`, `signatures`: string[], `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:5406](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L5406)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`orders` | `Array` | - | Array of order specifications. | +`takerAssetFillAmount` | `BigNumber` | - | Desired amount of takerAsset to sell. | +`signatures` | string[] | - | Proofs that orders have been signed by makers. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +Amounts filled and fees paid by makers and taker. + +#### estimateGasAsync + +▸ **estimateGasAsync**(`orders`: `Array`, `takerAssetFillAmount`: `BigNumber`, `signatures`: string[], `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:5353](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L5353)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`orders` | `Array` | Array of order specifications. | +`takerAssetFillAmount` | `BigNumber` | Desired amount of takerAsset to sell. | +`signatures` | string[] | Proofs that orders have been signed by makers. | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`orders`: `Array`, `takerAssetFillAmount`: `BigNumber`, `signatures`: string[]): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:5492](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L5492)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`orders` | `Array` | Array of order specifications. | +`takerAssetFillAmount` | `BigNumber` | Desired amount of takerAsset to sell. | +`signatures` | string[] | Proofs that orders have been signed by makers. | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:5525](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L5525)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`orders`: `Array`, `takerAssetFillAmount`: `BigNumber`, `signatures`: string[], `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:5236](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L5236)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`orders` | `Array` | - | Array of order specifications. | +`takerAssetFillAmount` | `BigNumber` | - | Desired amount of takerAsset to sell. | +`signatures` | string[] | - | Proofs that orders have been signed by makers. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### matchOrders + +#### ▪ **matchOrders**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:5539](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L5539)* + +Match two complementary orders that have a profitable spread. +Each order is filled at their respective price point. However, the calculations are +carried out as though the orders are both being filled at the right order's price point. +The profit made by the left order goes to the taker (who matched the two orders). + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`leftOrder`: object, `rightOrder`: object, `leftSignature`: string, `rightSignature`: string, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:5631](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L5631)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`leftOrder` | object | - | First order to match. | +`rightOrder` | object | - | Second order to match. | +`leftSignature` | string | - | Proof that order was created by the left maker. | +`rightSignature` | string | - | Proof that order was created by the right maker. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`leftOrder`: object, `rightOrder`: object, `leftSignature`: string, `rightSignature`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:5770](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L5770)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`leftOrder` | object | - | First order to match. | +`rightOrder` | object | - | Second order to match. | +`leftSignature` | string | - | Proof that order was created by the left maker. | +`rightSignature` | string | - | Proof that order was created by the right maker. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +matchedFillResults Amounts filled and fees paid by maker and taker of matched orders. + +#### estimateGasAsync + +▸ **estimateGasAsync**(`leftOrder`: object, `rightOrder`: object, `leftSignature`: string, `rightSignature`: string, `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:5701](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L5701)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`leftOrder` | object | First order to match. | +`rightOrder` | object | Second order to match. | +`leftSignature` | string | Proof that order was created by the left maker. | +`rightSignature` | string | Proof that order was created by the right maker. | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`leftOrder`: object, `rightOrder`: object, `leftSignature`: string, `rightSignature`: string): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:5894](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L5894)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`leftOrder` | object | First order to match. | +`rightOrder` | object | Second order to match. | +`leftSignature` | string | Proof that order was created by the left maker. | +`rightSignature` | string | Proof that order was created by the right maker. | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:5942](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L5942)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`leftOrder`: object, `rightOrder`: object, `leftSignature`: string, `rightSignature`: string, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:5550](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L5550)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`leftOrder` | object | - | First order to match. | +`rightOrder` | object | - | Second order to match. | +`leftSignature` | string | - | Proof that order was created by the left maker. | +`rightSignature` | string | - | Proof that order was created by the right maker. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### matchOrdersWithMaximalFill + +#### ▪ **matchOrdersWithMaximalFill**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:5956](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L5956)* + +Match two complementary orders that have a profitable spread. +Each order is maximally filled at their respective price point, and +the matcher receives a profit denominated in either the left maker asset, +right maker asset, or a combination of both. + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`leftOrder`: object, `rightOrder`: object, `leftSignature`: string, `rightSignature`: string, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6048](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6048)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`leftOrder` | object | - | First order to match. | +`rightOrder` | object | - | Second order to match. | +`leftSignature` | string | - | Proof that order was created by the left maker. | +`rightSignature` | string | - | Proof that order was created by the right maker. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`leftOrder`: object, `rightOrder`: object, `leftSignature`: string, `rightSignature`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6187](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6187)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`leftOrder` | object | - | First order to match. | +`rightOrder` | object | - | Second order to match. | +`leftSignature` | string | - | Proof that order was created by the left maker. | +`rightSignature` | string | - | Proof that order was created by the right maker. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +matchedFillResults Amounts filled by maker and taker of matched orders. + +#### estimateGasAsync + +▸ **estimateGasAsync**(`leftOrder`: object, `rightOrder`: object, `leftSignature`: string, `rightSignature`: string, `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6118](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6118)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`leftOrder` | object | First order to match. | +`rightOrder` | object | Second order to match. | +`leftSignature` | string | Proof that order was created by the left maker. | +`rightSignature` | string | Proof that order was created by the right maker. | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`leftOrder`: object, `rightOrder`: object, `leftSignature`: string, `rightSignature`: string): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6311](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6311)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`leftOrder` | object | First order to match. | +`rightOrder` | object | Second order to match. | +`leftSignature` | string | Proof that order was created by the left maker. | +`rightSignature` | string | Proof that order was created by the right maker. | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6359](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6359)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`leftOrder`: object, `rightOrder`: object, `leftSignature`: string, `rightSignature`: string, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:5967](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L5967)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`leftOrder` | object | - | First order to match. | +`rightOrder` | object | - | Second order to match. | +`leftSignature` | string | - | Proof that order was created by the left maker. | +`rightSignature` | string | - | Proof that order was created by the right maker. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### orderEpoch + +#### ▪ **orderEpoch**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6367](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6367)* + +#### callAsync + +▸ **callAsync**(`index_0`: string, `index_1`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6373](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6373)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`index_0` | string | - | +`index_1` | string | - | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +___ + +### owner + +#### ▪ **owner**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6420](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6420)* + +#### callAsync + +▸ **callAsync**(`callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6426](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6426)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +___ + +### preSign + +#### ▪ **preSign**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6467](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6467)* + +Approves a hash on-chain. +After presigning a hash, the preSign signature type will become valid for that hash and signer. + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`hash`: string, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6510](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6510)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`hash` | string | - | Any 32-byte hash. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`hash`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6561](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6561)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`hash` | string | - | Any 32-byte hash. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +#### estimateGasAsync + +▸ **estimateGasAsync**(`hash`: string, `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6536](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6536)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`hash` | string | Any 32-byte hash. | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`hash`: string): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6605](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6605)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`hash` | string | Any 32-byte hash. | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6614](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6614)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`hash`: string, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6475](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6475)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`hash` | string | - | Any 32-byte hash. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### preSigned + +#### ▪ **preSigned**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6620](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6620)* + +#### callAsync + +▸ **callAsync**(`index_0`: string, `index_1`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6626](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6626)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`index_0` | string | - | +`index_1` | string | - | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +___ + +### protocolFeeCollector + +#### ▪ **protocolFeeCollector**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6673](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6673)* + +#### callAsync + +▸ **callAsync**(`callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6679](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6679)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +___ + +### protocolFeeMultiplier + +#### ▪ **protocolFeeMultiplier**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6716](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6716)* + +#### callAsync + +▸ **callAsync**(`callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6722](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6722)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +___ + +### registerAssetProxy + +#### ▪ **registerAssetProxy**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6763](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6763)* + +Registers an asset proxy to its asset proxy id. +Once an asset proxy is registered, it cannot be unregistered. + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`assetProxy`: string, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6806](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6806)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`assetProxy` | string | - | Address of new asset proxy to register. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`assetProxy`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6857](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6857)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`assetProxy` | string | - | Address of new asset proxy to register. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +#### estimateGasAsync + +▸ **estimateGasAsync**(`assetProxy`: string, `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6832](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6832)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`assetProxy` | string | Address of new asset proxy to register. | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`assetProxy`: string): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6905](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6905)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`assetProxy` | string | Address of new asset proxy to register. | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6916](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6916)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`assetProxy`: string, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6771](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6771)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`assetProxy` | string | - | Address of new asset proxy to register. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### setProtocolFeeCollectorAddress + +#### ▪ **setProtocolFeeCollectorAddress**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6925](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6925)* + +Allows the owner to update the protocolFeeCollector address. + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`updatedProtocolFeeCollector`: string, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6972](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6972)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`updatedProtocolFeeCollector` | string | - | The updated protocolFeeCollector contract address. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`updatedProtocolFeeCollector`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7034](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7034)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`updatedProtocolFeeCollector` | string | - | The updated protocolFeeCollector contract address. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +#### estimateGasAsync + +▸ **estimateGasAsync**(`updatedProtocolFeeCollector`: string, `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7003](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7003)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`updatedProtocolFeeCollector` | string | The updated protocolFeeCollector contract address. | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`updatedProtocolFeeCollector`: string): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7085](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7085)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`updatedProtocolFeeCollector` | string | The updated protocolFeeCollector contract address. | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7096](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7096)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`updatedProtocolFeeCollector`: string, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:6934](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L6934)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`updatedProtocolFeeCollector` | string | - | The updated protocolFeeCollector contract address. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### setProtocolFeeMultiplier + +#### ▪ **setProtocolFeeMultiplier**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7105](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7105)* + +Allows the owner to update the protocol fee multiplier. + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`updatedProtocolFeeMultiplier`: `BigNumber`, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7150](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7150)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`updatedProtocolFeeMultiplier` | `BigNumber` | - | The updated protocol fee multiplier. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`updatedProtocolFeeMultiplier`: `BigNumber`, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7210](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7210)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`updatedProtocolFeeMultiplier` | `BigNumber` | - | The updated protocol fee multiplier. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +#### estimateGasAsync + +▸ **estimateGasAsync**(`updatedProtocolFeeMultiplier`: `BigNumber`, `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7180](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7180)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`updatedProtocolFeeMultiplier` | `BigNumber` | The updated protocol fee multiplier. | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`updatedProtocolFeeMultiplier`: `BigNumber`): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7260](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7260)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`updatedProtocolFeeMultiplier` | `BigNumber` | The updated protocol fee multiplier. | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7271](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7271)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`updatedProtocolFeeMultiplier`: `BigNumber`, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7113](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7113)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`updatedProtocolFeeMultiplier` | `BigNumber` | - | The updated protocol fee multiplier. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### setSignatureValidatorApproval + +#### ▪ **setSignatureValidatorApproval**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7281](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7281)* + +Approves/unnapproves a Validator contract to verify signatures on signer's behalf +using the `Validator` signature type. + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`validatorAddress`: string, `approval`: boolean, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7331](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7331)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`validatorAddress` | string | - | Address of Validator contract. | +`approval` | boolean | - | Approval or disapproval of Validator contract. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`validatorAddress`: string, `approval`: boolean, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7399](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7399)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`validatorAddress` | string | - | Address of Validator contract. | +`approval` | boolean | - | Approval or disapproval of Validator contract. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +#### estimateGasAsync + +▸ **estimateGasAsync**(`validatorAddress`: string, `approval`: boolean, `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7365](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7365)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`validatorAddress` | string | Address of Validator contract. | +`approval` | boolean | Approval or disapproval of Validator contract. | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`validatorAddress`: string, `approval`: boolean): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7453](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7453)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`validatorAddress` | string | Address of Validator contract. | +`approval` | boolean | Approval or disapproval of Validator contract. | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7466](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7466)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`validatorAddress`: string, `approval`: boolean, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7290](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7290)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`validatorAddress` | string | - | Address of Validator contract. | +`approval` | boolean | - | Approval or disapproval of Validator contract. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### simulateDispatchTransferFromCalls + +#### ▪ **simulateDispatchTransferFromCalls**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7475](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7475)* + +This function may be used to simulate any amount of transfers As they would occur through the Exchange contract. Note that this function will always revert, even if all transfers are successful. However, it may be used with eth_call or with a try/catch pattern in order to simulate the results of the transfers. + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`assetData`: string[], `fromAddresses`: string[], `toAddresses`: string[], `amounts`: `BigNumber`[], `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7547](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7547)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`assetData` | string[] | - | Array of asset details, each encoded per the AssetProxy contract specification. | +`fromAddresses` | string[] | - | Array containing the `from` addresses that correspond with each transfer. | +`toAddresses` | string[] | - | Array containing the `to` addresses that correspond with each transfer. | +`amounts` | `BigNumber`[] | - | Array containing the amounts that correspond to each transfer. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`assetData`: string[], `fromAddresses`: string[], `toAddresses`: string[], `amounts`: `BigNumber`[], `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7638](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7638)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`assetData` | string[] | - | Array of asset details, each encoded per the AssetProxy contract specification. | +`fromAddresses` | string[] | - | Array containing the `from` addresses that correspond with each transfer. | +`toAddresses` | string[] | - | Array containing the `to` addresses that correspond with each transfer. | +`amounts` | `BigNumber`[] | - | Array containing the amounts that correspond to each transfer. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +This function does not return a value. However, it will always revert with `Error("TRANSFERS_SUCCESSFUL")` if all of the transfers were successful. + +#### estimateGasAsync + +▸ **estimateGasAsync**(`assetData`: string[], `fromAddresses`: string[], `toAddresses`: string[], `amounts`: `BigNumber`[], `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7593](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7593)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`assetData` | string[] | Array of asset details, each encoded per the AssetProxy contract specification. | +`fromAddresses` | string[] | Array containing the `from` addresses that correspond with each transfer. | +`toAddresses` | string[] | Array containing the `to` addresses that correspond with each transfer. | +`amounts` | `BigNumber`[] | Array containing the amounts that correspond to each transfer. | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`assetData`: string[], `fromAddresses`: string[], `toAddresses`: string[], `amounts`: `BigNumber`[]): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7704](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7704)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`assetData` | string[] | Array of asset details, each encoded per the AssetProxy contract specification. | +`fromAddresses` | string[] | Array containing the `from` addresses that correspond with each transfer. | +`toAddresses` | string[] | Array containing the `to` addresses that correspond with each transfer. | +`amounts` | `BigNumber`[] | Array containing the amounts that correspond to each transfer. | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7724](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7724)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`assetData`: string[], `fromAddresses`: string[], `toAddresses`: string[], `amounts`: `BigNumber`[], `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7490](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7490)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`assetData` | string[] | - | Array of asset details, each encoded per the AssetProxy contract specification. | +`fromAddresses` | string[] | - | Array containing the `from` addresses that correspond with each transfer. | +`toAddresses` | string[] | - | Array containing the `to` addresses that correspond with each transfer. | +`amounts` | `BigNumber`[] | - | Array containing the amounts that correspond to each transfer. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### transactionsExecuted + +#### ▪ **transactionsExecuted**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7732](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7732)* + +#### callAsync + +▸ **callAsync**(`index_0`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7738](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7738)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`index_0` | string | - | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +___ + +### transferOwnership + +#### ▪ **transferOwnership**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7780](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7780)* + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`newOwner`: string, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7821](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7821)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`newOwner` | string | - | - | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`newOwner`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7870](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7870)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`newOwner` | string | - | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +#### estimateGasAsync + +▸ **estimateGasAsync**(`newOwner`: string, `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7846](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7846)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`newOwner` | string | - | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`newOwner`: string): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7913](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7913)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | +------ | ------ | +`newOwner` | string | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7924](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7924)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`newOwner`: string, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:7787](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L7787)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`newOwner` | string | - | - | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +
+ +# Class: ForwarderContract + + +## Constructors + + + +\+ **new ForwarderContract**(`address`: string, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults?`: `Partial`, `logDecodeDependencies?`: undefined | object, `deployedBytecode`: string | undefined): *[ForwarderContract](#class-forwardercontract)* + +*Overrides void* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/forwarder.ts:1615](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts#L1615)* + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`address` | string | - | +`supportedProvider` | [SupportedProvider](#supportedprovider) | - | +`txDefaults?` | `Partial` | - | +`logDecodeDependencies?` | undefined \| object | - | +`deployedBytecode` | string \| undefined | ForwarderContract.deployedBytecode | + +**Returns:** *[ForwarderContract](#class-forwardercontract)* + +## Properties + +#### `Optional` _deployedBytecodeIfExists + +• **_deployedBytecodeIfExists**? : *`Buffer`* + + + +Defined in base-contract/lib/src/index.d.ts:31 + +___ + +### abi + +• **abi**: *[ContractAbi](#contractabi)* + + + +Defined in base-contract/lib/src/index.d.ts:27 + +___ + +### address + +• **address**: *string* + + + +Defined in base-contract/lib/src/index.d.ts:28 + +___ + +Args + +• **constructorArgs**: *any[]* + + + +Defined in base-contract/lib/src/index.d.ts:30 + +___ + +### contractName + +• **contractName**: *string* + + + +Defined in base-contract/lib/src/index.d.ts:29 + +## Methods + +### `Static` ABI + +▸ **ABI**(): *[ContractAbi](#contractabi)* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/forwarder.ts:1330](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts#L1330)* + +**Returns:** *[ContractAbi](#contractabi)* + +The contract ABI + +___ + +### `Static` deployAsync + +▸ **deployAsync**(`bytecode`: string, `abi`: [ContractAbi](#contractabi), `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object, `_exchange`: string, `_wethAssetData`: string): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/forwarder.ts:1282](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts#L1282)* + +**Parameters:** + +Name | Type | +------ | ------ | +`bytecode` | string | +`abi` | [ContractAbi](#contractabi) | +`supportedProvider` | [SupportedProvider](#supportedprovider) | +`txDefaults` | `Partial` | +`logDecodeDependencies` | object | +`_exchange` | string | +`_wethAssetData` | string | + +**Returns:** *`Promise`* + +___ + +### `Static` deployFrom0xArtifactAsync + +▸ **deployFrom0xArtifactAsync**(`artifact`: `ContractArtifact` | `SimpleContractArtifact`, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object, `_exchange`: string, `_wethAssetData`: string): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/forwarder.ts:1247](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts#L1247)* + +**Parameters:** + +Name | Type | +------ | ------ | +`artifact` | `ContractArtifact` \| `SimpleContractArtifact` | +`supportedProvider` | [SupportedProvider](#supportedprovider) | +`txDefaults` | `Partial` | +`logDecodeDependencies` | object | +`_exchange` | string | +`_wethAssetData` | string | + +**Returns:** *`Promise`* + +___ + +### `Static` strictArgumentEncodingCheck + +▸ **strictArgumentEncodingCheck**(`inputAbi`: `DataItem`[], `args`: any[]): *string* + + + +Defined in base-contract/lib/src/index.d.ts:41 + +**Parameters:** + +Name | Type | +------ | ------ | +`inputAbi` | `DataItem`[] | +`args` | any[] | + +**Returns:** *string* + +## Object literals + +### approveMakerAssetProxy + +#### ▪ **approveMakerAssetProxy**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/forwarder.ts:48](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts#L48)* + +Approves the respective proxy for a given asset to transfer tokens on the Forwarder contract's behalf. +This is necessary because an order fee denominated in the maker asset (i.e. a percentage fee) is sent by the +Forwarder contract to the fee recipient. +This method needs to be called before forwarding orders of a maker asset that hasn't +previously been approved. + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`assetData`: string, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/forwarder.ts:91](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts#L91)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`assetData` | string | - | Byte array encoded for the respective asset proxy. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`assetData`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/forwarder.ts:142](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts#L142)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`assetData` | string | - | Byte array encoded for the respective asset proxy. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +#### estimateGasAsync + +▸ **estimateGasAsync**(`assetData`: string, `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/forwarder.ts:117](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts#L117)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`assetData` | string | Byte array encoded for the respective asset proxy. | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`assetData`: string): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/forwarder.ts:186](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts#L186)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`assetData` | string | Byte array encoded for the respective asset proxy. | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/forwarder.ts:195](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts#L195)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`assetData`: string, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/forwarder.ts:56](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts#L56)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`assetData` | string | - | Byte array encoded for the respective asset proxy. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### marketBuyOrdersWithEth + +#### ▪ **marketBuyOrdersWithEth**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/forwarder.ts:207](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts#L207)* + +Attempt to buy makerAssetBuyAmount of makerAsset by selling ETH provided with transaction. +The Forwarder may *fill* more than makerAssetBuyAmount of the makerAsset so that it can +pay takerFees where takerFeeAssetData == makerAssetData (i.e. percentage fees). +Any ETH not spent will be refunded to sender. + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`orders`: `Array`, `makerAssetBuyAmount`: `BigNumber`, `signatures`: string[], `feePercentage`: `BigNumber`, `feeRecipient`: string, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/forwarder.ts:295](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts#L295)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`orders` | `Array` | - | Array of order specifications used containing desired makerAsset and WETH as takerAsset. | +`makerAssetBuyAmount` | `BigNumber` | - | Desired amount of makerAsset to purchase. | +`signatures` | string[] | - | Proofs that orders have been created by makers. | +`feePercentage` | `BigNumber` | - | Percentage of WETH sold that will payed as fee to forwarding contract feeRecipient. | +`feeRecipient` | string | - | Address that will receive ETH when orders are filled. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`orders`: `Array`, `makerAssetBuyAmount`: `BigNumber`, `signatures`: string[], `feePercentage`: `BigNumber`, `feeRecipient`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise<[BigNumber, BigNumber, BigNumber]>`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/forwarder.ts:419](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts#L419)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`orders` | `Array` | - | Array of order specifications used containing desired makerAsset and WETH as takerAsset. | +`makerAssetBuyAmount` | `BigNumber` | - | Desired amount of makerAsset to purchase. | +`signatures` | string[] | - | Proofs that orders have been created by makers. | +`feePercentage` | `BigNumber` | - | Percentage of WETH sold that will payed as fee to forwarding contract feeRecipient. | +`feeRecipient` | string | - | Address that will receive ETH when orders are filled. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise<[BigNumber, BigNumber, BigNumber]>`* + +wethSpentAmount Amount of WETH spent on the given set of orders.makerAssetAcquiredAmount Amount of maker asset acquired from the given set of orders.ethFeePaid Amount of ETH spent on the given forwarder fee. + +#### estimateGasAsync + +▸ **estimateGasAsync**(`orders`: `Array`, `makerAssetBuyAmount`: `BigNumber`, `signatures`: string[], `feePercentage`: `BigNumber`, `feeRecipient`: string, `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/forwarder.ts:358](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts#L358)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`orders` | `Array` | Array of order specifications used containing desired makerAsset and WETH as takerAsset. | +`makerAssetBuyAmount` | `BigNumber` | Desired amount of makerAsset to purchase. | +`signatures` | string[] | Proofs that orders have been created by makers. | +`feePercentage` | `BigNumber` | Percentage of WETH sold that will payed as fee to forwarding contract feeRecipient. | +`feeRecipient` | string | Address that will receive ETH when orders are filled. | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`orders`: `Array`, `makerAssetBuyAmount`: `BigNumber`, `signatures`: string[], `feePercentage`: `BigNumber`, `feeRecipient`: string): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/forwarder.ts:501](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts#L501)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`orders` | `Array` | Array of order specifications used containing desired makerAsset and WETH as takerAsset. | +`makerAssetBuyAmount` | `BigNumber` | Desired amount of makerAsset to purchase. | +`signatures` | string[] | Proofs that orders have been created by makers. | +`feePercentage` | `BigNumber` | Percentage of WETH sold that will payed as fee to forwarding contract feeRecipient. | +`feeRecipient` | string | Address that will receive ETH when orders are filled. | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/forwarder.ts:538](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts#L538)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`orders`: `Array`, `makerAssetBuyAmount`: `BigNumber`, `signatures`: string[], `feePercentage`: `BigNumber`, `feeRecipient`: string, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/forwarder.ts:221](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts#L221)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`orders` | `Array` | - | Array of order specifications used containing desired makerAsset and WETH as takerAsset. | +`makerAssetBuyAmount` | `BigNumber` | - | Desired amount of makerAsset to purchase. | +`signatures` | string[] | - | Proofs that orders have been created by makers. | +`feePercentage` | `BigNumber` | - | Percentage of WETH sold that will payed as fee to forwarding contract feeRecipient. | +`feeRecipient` | string | - | Address that will receive ETH when orders are filled. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### marketSellOrdersWithEth + +#### ▪ **marketSellOrdersWithEth**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/forwarder.ts:550](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts#L550)* + +Purchases as much of orders' makerAssets as possible by selling as much of the ETH value sent +as possible, accounting for order and forwarder fees. + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`orders`: `Array`, `signatures`: string[], `feePercentage`: `BigNumber`, `feeRecipient`: string, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/forwarder.ts:633](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts#L633)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`orders` | `Array` | - | Array of order specifications used containing desired makerAsset and WETH as takerAsset. | +`signatures` | string[] | - | Proofs that orders have been created by makers. | +`feePercentage` | `BigNumber` | - | Percentage of WETH sold that will payed as fee to forwarding contract feeRecipient. | +`feeRecipient` | string | - | Address that will receive ETH when orders are filled. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`orders`: `Array`, `signatures`: string[], `feePercentage`: `BigNumber`, `feeRecipient`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise<[BigNumber, BigNumber, BigNumber]>`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/forwarder.ts:750](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts#L750)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`orders` | `Array` | - | Array of order specifications used containing desired makerAsset and WETH as takerAsset. | +`signatures` | string[] | - | Proofs that orders have been created by makers. | +`feePercentage` | `BigNumber` | - | Percentage of WETH sold that will payed as fee to forwarding contract feeRecipient. | +`feeRecipient` | string | - | Address that will receive ETH when orders are filled. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise<[BigNumber, BigNumber, BigNumber]>`* + +wethSpentAmount Amount of WETH spent on the given set of orders.makerAssetAcquiredAmount Amount of maker asset acquired from the given set of orders.ethFeePaid Amount of ETH spent on the given forwarder fee. + +#### estimateGasAsync + +▸ **estimateGasAsync**(`orders`: `Array`, `signatures`: string[], `feePercentage`: `BigNumber`, `feeRecipient`: string, `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/forwarder.ts:692](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts#L692)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`orders` | `Array` | Array of order specifications used containing desired makerAsset and WETH as takerAsset. | +`signatures` | string[] | Proofs that orders have been created by makers. | +`feePercentage` | `BigNumber` | Percentage of WETH sold that will payed as fee to forwarding contract feeRecipient. | +`feeRecipient` | string | Address that will receive ETH when orders are filled. | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`orders`: `Array`, `signatures`: string[], `feePercentage`: `BigNumber`, `feeRecipient`: string): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/forwarder.ts:829](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts#L829)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`orders` | `Array` | Array of order specifications used containing desired makerAsset and WETH as takerAsset. | +`signatures` | string[] | Proofs that orders have been created by makers. | +`feePercentage` | `BigNumber` | Percentage of WETH sold that will payed as fee to forwarding contract feeRecipient. | +`feeRecipient` | string | Address that will receive ETH when orders are filled. | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/forwarder.ts:864](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts#L864)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`orders`: `Array`, `signatures`: string[], `feePercentage`: `BigNumber`, `feeRecipient`: string, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/forwarder.ts:563](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts#L563)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`orders` | `Array` | - | Array of order specifications used containing desired makerAsset and WETH as takerAsset. | +`signatures` | string[] | - | Proofs that orders have been created by makers. | +`feePercentage` | `BigNumber` | - | Percentage of WETH sold that will payed as fee to forwarding contract feeRecipient. | +`feeRecipient` | string | - | Address that will receive ETH when orders are filled. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### owner + +#### ▪ **owner**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/forwarder.ts:872](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts#L872)* + +#### callAsync + +▸ **callAsync**(`callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/forwarder.ts:878](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts#L878)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +___ + +### transferOwnership + +#### ▪ **transferOwnership**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/forwarder.ts:915](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts#L915)* + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`newOwner`: string, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/forwarder.ts:956](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts#L956)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`newOwner` | string | - | - | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`newOwner`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/forwarder.ts:1005](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts#L1005)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`newOwner` | string | - | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +#### estimateGasAsync + +▸ **estimateGasAsync**(`newOwner`: string, `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/forwarder.ts:981](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts#L981)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`newOwner` | string | - | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`newOwner`: string): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/forwarder.ts:1048](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts#L1048)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | +------ | ------ | +`newOwner` | string | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/forwarder.ts:1059](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts#L1059)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`newOwner`: string, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/forwarder.ts:922](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts#L922)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`newOwner` | string | - | - | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### withdrawAsset + +#### ▪ **withdrawAsset**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/forwarder.ts:1070](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts#L1070)* + +Withdraws assets from this contract. The contract formerly required a ZRX balance in order +to function optimally, and this function allows the ZRX to be withdrawn by owner. +It may also be used to withdraw assets that were accidentally sent to this contract. + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`assetData`: string, `amount`: `BigNumber`, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/forwarder.ts:1117](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts#L1117)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`assetData` | string | - | Byte array encoded for the respective asset proxy. | +`amount` | `BigNumber` | - | Amount of ERC20 token to withdraw. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`assetData`: string, `amount`: `BigNumber`, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/forwarder.ts:1177](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts#L1177)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`assetData` | string | - | Byte array encoded for the respective asset proxy. | +`amount` | `BigNumber` | - | Amount of ERC20 token to withdraw. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +#### estimateGasAsync + +▸ **estimateGasAsync**(`assetData`: string, `amount`: `BigNumber`, `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/forwarder.ts:1146](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts#L1146)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`assetData` | string | Byte array encoded for the respective asset proxy. | +`amount` | `BigNumber` | Amount of ERC20 token to withdraw. | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`assetData`: string, `amount`: `BigNumber`): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/forwarder.ts:1228](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts#L1228)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`assetData` | string | Byte array encoded for the respective asset proxy. | +`amount` | `BigNumber` | Amount of ERC20 token to withdraw. | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/forwarder.ts:1241](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts#L1241)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`assetData`: string, `amount`: `BigNumber`, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/forwarder.ts:1079](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts#L1079)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`assetData` | string | - | Byte array encoded for the respective asset proxy. | +`amount` | `BigNumber` | - | Amount of ERC20 token to withdraw. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +
+ +# Class: IValidatorContract + + +## Constructors + + + +\+ **new IValidatorContract**(`address`: string, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults?`: `Partial`, `logDecodeDependencies?`: undefined | object, `deployedBytecode`: string | undefined): *[IValidatorContract](#class-ivalidatorcontract)* + +*Overrides void* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/i_validator.ts:202](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/i_validator.ts#L202)* + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`address` | string | - | +`supportedProvider` | [SupportedProvider](#supportedprovider) | - | +`txDefaults?` | `Partial` | - | +`logDecodeDependencies?` | undefined \| object | - | +`deployedBytecode` | string \| undefined | IValidatorContract.deployedBytecode | + +**Returns:** *[IValidatorContract](#class-ivalidatorcontract)* + +## Properties + +#### `Optional` _deployedBytecodeIfExists + +• **_deployedBytecodeIfExists**? : *`Buffer`* + + + +Defined in base-contract/lib/src/index.d.ts:31 + +___ + +### abi + +• **abi**: *[ContractAbi](#contractabi)* + + + +Defined in base-contract/lib/src/index.d.ts:27 + +___ + +### address + +• **address**: *string* + + + +Defined in base-contract/lib/src/index.d.ts:28 + +___ + +Args + +• **constructorArgs**: *any[]* + + + +Defined in base-contract/lib/src/index.d.ts:30 + +___ + +### contractName + +• **contractName**: *string* + + + +Defined in base-contract/lib/src/index.d.ts:29 + +## Methods + +### `Static` ABI + +▸ **ABI**(): *[ContractAbi](#contractabi)* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/i_validator.ts:171](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/i_validator.ts#L171)* + +**Returns:** *[ContractAbi](#contractabi)* + +The contract ABI + +___ + +### `Static` deployAsync + +▸ **deployAsync**(`bytecode`: string, `abi`: [ContractAbi](#contractabi), `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/i_validator.ts:129](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/i_validator.ts#L129)* + +**Parameters:** + +Name | Type | +------ | ------ | +`bytecode` | string | +`abi` | [ContractAbi](#contractabi) | +`supportedProvider` | [SupportedProvider](#supportedprovider) | +`txDefaults` | `Partial` | +`logDecodeDependencies` | object | + +**Returns:** *`Promise`* + +___ + +### `Static` deployFrom0xArtifactAsync + +▸ **deployFrom0xArtifactAsync**(`artifact`: `ContractArtifact` | `SimpleContractArtifact`, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/i_validator.ts:104](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/i_validator.ts#L104)* + +**Parameters:** + +Name | Type | +------ | ------ | +`artifact` | `ContractArtifact` \| `SimpleContractArtifact` | +`supportedProvider` | [SupportedProvider](#supportedprovider) | +`txDefaults` | `Partial` | +`logDecodeDependencies` | object | + +**Returns:** *`Promise`* + +___ + +### `Static` strictArgumentEncodingCheck + +▸ **strictArgumentEncodingCheck**(`inputAbi`: `DataItem`[], `args`: any[]): *string* + + + +Defined in base-contract/lib/src/index.d.ts:41 + +**Parameters:** + +Name | Type | +------ | ------ | +`inputAbi` | `DataItem`[] | +`args` | any[] | + +**Returns:** *string* + +## Object literals + +### isValidSignature + +#### ▪ **isValidSignature**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/i_validator.ts:44](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/i_validator.ts#L44)* + +Verifies that a signature is valid. + +#### callAsync + +▸ **callAsync**(`hash`: string, `signerAddress`: string, `signature`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/i_validator.ts:54](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/i_validator.ts#L54)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`hash` | string | - | Message hash that is signed. | +`signerAddress` | string | - | Address that should have signed the given hash. | +`signature` | string | - | Proof of signing. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +Magic bytes4 value if the signature is valid. Magic value is bytes4(keccak256("isValidValidatorSignature(address,bytes32,address,bytes)")) + +
+ +# Class: IWalletContract + + +## Constructors + + + +\+ **new IWalletContract**(`address`: string, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults?`: `Partial`, `logDecodeDependencies?`: undefined | object, `deployedBytecode`: string | undefined): *[IWalletContract](#class-iwalletcontract)* + +*Overrides void* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/i_wallet.ts:191](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/i_wallet.ts#L191)* + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`address` | string | - | +`supportedProvider` | [SupportedProvider](#supportedprovider) | - | +`txDefaults?` | `Partial` | - | +`logDecodeDependencies?` | undefined \| object | - | +`deployedBytecode` | string \| undefined | IWalletContract.deployedBytecode | + +**Returns:** *[IWalletContract](#class-iwalletcontract)* + +## Properties + +#### `Optional` _deployedBytecodeIfExists + +• **_deployedBytecodeIfExists**? : *`Buffer`* + + + +Defined in base-contract/lib/src/index.d.ts:31 + +___ + +### abi + +• **abi**: *[ContractAbi](#contractabi)* + + + +Defined in base-contract/lib/src/index.d.ts:27 + +___ + +### address + +• **address**: *string* + + + +Defined in base-contract/lib/src/index.d.ts:28 + +___ + +Args + +• **constructorArgs**: *any[]* + + + +Defined in base-contract/lib/src/index.d.ts:30 + +___ + +### contractName + +• **contractName**: *string* + + + +Defined in base-contract/lib/src/index.d.ts:29 + +## Methods + +### `Static` ABI + +▸ **ABI**(): *[ContractAbi](#contractabi)* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/i_wallet.ts:164](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/i_wallet.ts#L164)* + +**Returns:** *[ContractAbi](#contractabi)* + +The contract ABI + +___ + +### `Static` deployAsync + +▸ **deployAsync**(`bytecode`: string, `abi`: [ContractAbi](#contractabi), `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/i_wallet.ts:122](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/i_wallet.ts#L122)* + +**Parameters:** + +Name | Type | +------ | ------ | +`bytecode` | string | +`abi` | [ContractAbi](#contractabi) | +`supportedProvider` | [SupportedProvider](#supportedprovider) | +`txDefaults` | `Partial` | +`logDecodeDependencies` | object | + +**Returns:** *`Promise`* + +___ + +### `Static` deployFrom0xArtifactAsync + +▸ **deployFrom0xArtifactAsync**(`artifact`: `ContractArtifact` | `SimpleContractArtifact`, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/i_wallet.ts:97](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/i_wallet.ts#L97)* + +**Parameters:** + +Name | Type | +------ | ------ | +`artifact` | `ContractArtifact` \| `SimpleContractArtifact` | +`supportedProvider` | [SupportedProvider](#supportedprovider) | +`txDefaults` | `Partial` | +`logDecodeDependencies` | object | + +**Returns:** *`Promise`* + +___ + +### `Static` strictArgumentEncodingCheck + +▸ **strictArgumentEncodingCheck**(`inputAbi`: `DataItem`[], `args`: any[]): *string* + + + +Defined in base-contract/lib/src/index.d.ts:41 + +**Parameters:** + +Name | Type | +------ | ------ | +`inputAbi` | `DataItem`[] | +`args` | any[] | + +**Returns:** *string* + +## Object literals + +### isValidSignature + +#### ▪ **isValidSignature**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/i_wallet.ts:44](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/i_wallet.ts#L44)* + +Validates a hash with the `Wallet` signature type. + +#### callAsync + +▸ **callAsync**(`hash`: string, `signature`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/i_wallet.ts:53](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/i_wallet.ts#L53)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`hash` | string | - | Message hash that is signed. | +`signature` | string | - | Proof of signing. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +magicValue `bytes4(0xb0671381)` if the signature check succeeds. + +
+ +# Class: OrderValidatorContract + + +## Constructors + + + +\+ **new OrderValidatorContract**(`address`: string, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults?`: `Partial`, `logDecodeDependencies?`: undefined | object, `deployedBytecode`: string | undefined): *[OrderValidatorContract](#class-ordervalidatorcontract)* + +*Overrides void* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/order_validator.ts:1210](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/order_validator.ts#L1210)* + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`address` | string | - | +`supportedProvider` | [SupportedProvider](#supportedprovider) | - | +`txDefaults?` | `Partial` | - | +`logDecodeDependencies?` | undefined \| object | - | +`deployedBytecode` | string \| undefined | OrderValidatorContract.deployedBytecode | + +**Returns:** *[OrderValidatorContract](#class-ordervalidatorcontract)* + +## Properties + +#### `Optional` _deployedBytecodeIfExists + +• **_deployedBytecodeIfExists**? : *`Buffer`* + + + +Defined in base-contract/lib/src/index.d.ts:31 + +___ + +### abi + +• **abi**: *[ContractAbi](#contractabi)* + + + +Defined in base-contract/lib/src/index.d.ts:27 + +___ + +### address + +• **address**: *string* + + + +Defined in base-contract/lib/src/index.d.ts:28 + +___ + +Args + +• **constructorArgs**: *any[]* + + + +Defined in base-contract/lib/src/index.d.ts:30 + +___ + +### contractName + +• **contractName**: *string* + + + +Defined in base-contract/lib/src/index.d.ts:29 + +## Methods + +### `Static` ABI + +▸ **ABI**(): *[ContractAbi](#contractabi)* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/order_validator.ts:649](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/order_validator.ts#L649)* + +**Returns:** *[ContractAbi](#contractabi)* + +The contract ABI + +___ + +### `Static` deployAsync + +▸ **deployAsync**(`bytecode`: string, `abi`: [ContractAbi](#contractabi), `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object, `_exchange`: string, `_zrxAssetData`: string): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/order_validator.ts:601](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/order_validator.ts#L601)* + +**Parameters:** + +Name | Type | +------ | ------ | +`bytecode` | string | +`abi` | [ContractAbi](#contractabi) | +`supportedProvider` | [SupportedProvider](#supportedprovider) | +`txDefaults` | `Partial` | +`logDecodeDependencies` | object | +`_exchange` | string | +`_zrxAssetData` | string | + +**Returns:** *`Promise`* + +___ + +### `Static` deployFrom0xArtifactAsync + +▸ **deployFrom0xArtifactAsync**(`artifact`: `ContractArtifact` | `SimpleContractArtifact`, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object, `_exchange`: string, `_zrxAssetData`: string): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/order_validator.ts:566](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/order_validator.ts#L566)* + +**Parameters:** + +Name | Type | +------ | ------ | +`artifact` | `ContractArtifact` \| `SimpleContractArtifact` | +`supportedProvider` | [SupportedProvider](#supportedprovider) | +`txDefaults` | `Partial` | +`logDecodeDependencies` | object | +`_exchange` | string | +`_zrxAssetData` | string | + +**Returns:** *`Promise`* + +___ + +### `Static` strictArgumentEncodingCheck + +▸ **strictArgumentEncodingCheck**(`inputAbi`: `DataItem`[], `args`: any[]): *string* + + + +Defined in base-contract/lib/src/index.d.ts:41 + +**Parameters:** + +Name | Type | +------ | ------ | +`inputAbi` | `DataItem`[] | +`args` | any[] | + +**Returns:** *string* + +## Object literals + +### getBalanceAndAllowance + +#### ▪ **getBalanceAndAllowance**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/order_validator.ts:136](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/order_validator.ts#L136)* + +#### callAsync + +▸ **callAsync**(`target`: string, `assetData`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise<[BigNumber, BigNumber]>`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/order_validator.ts:142](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/order_validator.ts#L142)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`target` | string | - | +`assetData` | string | - | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise<[BigNumber, BigNumber]>`* + +___ + +### getBalancesAndAllowances + +#### ▪ **getBalancesAndAllowances**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/order_validator.ts:428](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/order_validator.ts#L428)* + +#### callAsync + +▸ **callAsync**(`target`: string, `assetData`: string[], `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise<[BigNumber[], BigNumber[]]>`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/order_validator.ts:434](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/order_validator.ts#L434)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`target` | string | - | +`assetData` | string[] | - | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise<[BigNumber[], BigNumber[]]>`* + +___ + +### getERC721TokenOwner + +#### ▪ **getERC721TokenOwner**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/order_validator.ts:375](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/order_validator.ts#L375)* + +#### callAsync + +▸ **callAsync**(`token`: string, `tokenId`: `BigNumber`, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/order_validator.ts:381](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/order_validator.ts#L381)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`token` | string | - | +`tokenId` | `BigNumber` | - | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +___ + +### getOrderAndTraderInfo + +#### ▪ **getOrderAndTraderInfo**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/order_validator.ts:41](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/order_validator.ts#L41)* + +#### callAsync + +▸ **callAsync**(`order`: object, `takerAddress`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise<[object, object]>`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/order_validator.ts:47](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/order_validator.ts#L47)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`order` | object | - | +`takerAddress` | string | - | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise<[object, object]>`* + +___ + +### getOrdersAndTradersInfo + +#### ▪ **getOrdersAndTradersInfo**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/order_validator.ts:189](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/order_validator.ts#L189)* + +#### callAsync + +▸ **callAsync**(`orders`: `Array`, `takerAddresses`: string[], `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise<[Array, Array]>`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/order_validator.ts:195](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/order_validator.ts#L195)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`orders` | `Array` | - | +`takerAddresses` | string[] | - | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise<[Array, Array]>`* + +___ + +### getTraderInfo + +#### ▪ **getTraderInfo**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/order_validator.ts:481](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/order_validator.ts#L481)* + +#### callAsync + +▸ **callAsync**(`order`: object, `takerAddress`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/order_validator.ts:487](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/order_validator.ts#L487)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`order` | object | - | +`takerAddress` | string | - | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +___ + +### getTradersInfo + +#### ▪ **getTradersInfo**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/order_validator.ts:285](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/order_validator.ts#L285)* + +#### callAsync + +▸ **callAsync**(`orders`: `Array`, `takerAddresses`: string[], `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise>`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/order_validator.ts:291](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/order_validator.ts#L291)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`orders` | `Array` | - | +`takerAddresses` | string[] | - | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise>`* + +
+ +# Class: WETH9Contract + + +## Constructors + + + +\+ **new WETH9Contract**(`address`: string, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults?`: `Partial`, `logDecodeDependencies?`: undefined | object, `deployedBytecode`: string | undefined): *[WETH9Contract](#class-weth9contract)* + +*Overrides void* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:1583](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L1583)* + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`address` | string | - | +`supportedProvider` | [SupportedProvider](#supportedprovider) | - | +`txDefaults?` | `Partial` | - | +`logDecodeDependencies?` | undefined \| object | - | +`deployedBytecode` | string \| undefined | WETH9Contract.deployedBytecode | + +**Returns:** *[WETH9Contract](#class-weth9contract)* + +## Properties + +#### `Optional` _deployedBytecodeIfExists + +• **_deployedBytecodeIfExists**? : *`Buffer`* + + + +Defined in base-contract/lib/src/index.d.ts:31 + +___ + +### abi + +• **abi**: *[ContractAbi](#contractabi)* + + + +Defined in base-contract/lib/src/index.d.ts:27 + +___ + +### address + +• **address**: *string* + + + +Defined in base-contract/lib/src/index.d.ts:28 + +___ + +Args + +• **constructorArgs**: *any[]* + + + +Defined in base-contract/lib/src/index.d.ts:30 + +___ + +### contractName + +• **contractName**: *string* + + + +Defined in base-contract/lib/src/index.d.ts:29 + +## Methods + +### getLogsAsync + +▸ **getLogsAsync**<**ArgsType**>(`eventName`: [WETH9Events](#enumeration-weth9events), `blockRange`: `BlockRange`, `indexFilterValues`: `IndexedFilterValues`): *`Promise>>`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:1567](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L1567)* + +Gets historical logs without creating a subscription + +**Type parameters:** + +▪ **ArgsType**: *[WETH9EventArgs](#weth9eventargs)* + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`eventName` | [WETH9Events](#enumeration-weth9events) | The WETH9 contract event you would like to subscribe to. | +`blockRange` | `BlockRange` | Block range to get logs from. | +`indexFilterValues` | `IndexedFilterValues` | An object where the keys are indexed args returned by the event and the value is the value you are interested in. E.g `{_from: aUserAddressHex}` | + +**Returns:** *`Promise>>`* + +Array of logs that match the parameters + +___ + +### subscribe + +▸ **subscribe**<**ArgsType**>(`eventName`: [WETH9Events](#enumeration-weth9events), `indexFilterValues`: `IndexedFilterValues`, `callback`: [EventCallback](#eventcallback)‹*`ArgsType`*›, `isVerbose`: boolean, `blockPollingIntervalMs?`: undefined | number): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:1525](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L1525)* + +Subscribe to an event type emitted by the WETH9 contract. + +**Type parameters:** + +▪ **ArgsType**: *[WETH9EventArgs](#weth9eventargs)* + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`eventName` | [WETH9Events](#enumeration-weth9events) | - | The WETH9 contract event you would like to subscribe to. | +`indexFilterValues` | `IndexedFilterValues` | - | An object where the keys are indexed args returned by the event and the value is the value you are interested in. E.g `{maker: aUserAddressHex}` | +`callback` | [EventCallback](#eventcallback)‹*`ArgsType`*› | - | Callback that gets called when a log is added/removed | +`isVerbose` | boolean | false | Enable verbose subscription warnings (e.g recoverable network issues encountered) | +`blockPollingIntervalMs?` | undefined \| number | - | - | + +**Returns:** *string* + +Subscription token used later to unsubscribe + +___ + +### unsubscribe + +▸ **unsubscribe**(`subscriptionToken`: string): *void* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:1550](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L1550)* + +Cancel a subscription + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`subscriptionToken` | string | Subscription token returned by `subscribe()` | + +**Returns:** *void* + +___ + +### unsubscribeAll + +▸ **unsubscribeAll**(): *void* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:1556](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L1556)* + +Cancels all existing subscriptions + +**Returns:** *void* + +___ + +### `Static` ABI + +▸ **ABI**(): *[ContractAbi](#contractabi)* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:1228](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L1228)* + +**Returns:** *[ContractAbi](#contractabi)* + +The contract ABI + +___ + +### `Static` deployAsync + +▸ **deployAsync**(`bytecode`: string, `abi`: [ContractAbi](#contractabi), `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:1186](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L1186)* + +**Parameters:** + +Name | Type | +------ | ------ | +`bytecode` | string | +`abi` | [ContractAbi](#contractabi) | +`supportedProvider` | [SupportedProvider](#supportedprovider) | +`txDefaults` | `Partial` | +`logDecodeDependencies` | object | + +**Returns:** *`Promise`* + +___ + +### `Static` deployFrom0xArtifactAsync + +▸ **deployFrom0xArtifactAsync**(`artifact`: `ContractArtifact` | `SimpleContractArtifact`, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:1161](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L1161)* + +**Parameters:** + +Name | Type | +------ | ------ | +`artifact` | `ContractArtifact` \| `SimpleContractArtifact` | +`supportedProvider` | [SupportedProvider](#supportedprovider) | +`txDefaults` | `Partial` | +`logDecodeDependencies` | object | + +**Returns:** *`Promise`* + +___ + +### `Static` strictArgumentEncodingCheck + +▸ **strictArgumentEncodingCheck**(`inputAbi`: `DataItem`[], `args`: any[]): *string* + + + +Defined in base-contract/lib/src/index.d.ts:41 + +**Parameters:** + +Name | Type | +------ | ------ | +`inputAbi` | `DataItem`[] | +`args` | any[] | + +**Returns:** *string* + +## Object literals + +### allowance + +#### ▪ **allowance**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:1107](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L1107)* + +#### callAsync + +▸ **callAsync**(`index_0`: string, `index_1`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:1113](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L1113)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`index_0` | string | - | +`index_1` | string | - | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +___ + +### approve + +#### ▪ **approve**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:120](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L120)* + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`guy`: string, `wad`: `BigNumber`, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:163](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L163)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`guy` | string | - | - | +`wad` | `BigNumber` | - | - | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`guy`: string, `wad`: `BigNumber`, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:215](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L215)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`guy` | string | - | +`wad` | `BigNumber` | - | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +#### estimateGasAsync + +▸ **estimateGasAsync**(`guy`: string, `wad`: `BigNumber`, `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:190](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L190)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`guy` | string | - | +`wad` | `BigNumber` | - | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`guy`: string, `wad`: `BigNumber`): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:264](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L264)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | +------ | ------ | +`guy` | string | +`wad` | `BigNumber` | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:277](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L277)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`guy`: string, `wad`: `BigNumber`, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:127](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L127)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`guy` | string | - | - | +`wad` | `BigNumber` | - | - | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### balanceOf + +#### ▪ **balanceOf**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:712](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L712)* + +#### callAsync + +▸ **callAsync**(`index_0`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:718](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L718)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`index_0` | string | - | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +___ + +### decimals + +#### ▪ **decimals**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:669](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L669)* + +#### callAsync + +▸ **callAsync**(`callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:675](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L675)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +___ + +### deposit + +#### ▪ **deposit**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:966](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L966)* + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:1005](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L1005)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:1051](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L1051)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +#### estimateGasAsync + +▸ **estimateGasAsync**(`txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:1028](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L1028)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:1093](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L1093)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:1101](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L1101)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:973](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L973)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### name + +#### ▪ **name**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:77](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L77)* + +#### callAsync + +▸ **callAsync**(`callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:83](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L83)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +___ + +### symbol + +#### ▪ **symbol**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:760](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L760)* + +#### callAsync + +▸ **callAsync**(`callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:766](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L766)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +___ + +### totalSupply + +#### ▪ **totalSupply**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:283](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L283)* + +#### callAsync + +▸ **callAsync**(`callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:289](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L289)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +___ + +### transfer + +#### ▪ **transfer**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:803](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L803)* + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`dst`: string, `wad`: `BigNumber`, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:846](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L846)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`dst` | string | - | - | +`wad` | `BigNumber` | - | - | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`dst`: string, `wad`: `BigNumber`, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:898](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L898)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`dst` | string | - | +`wad` | `BigNumber` | - | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +#### estimateGasAsync + +▸ **estimateGasAsync**(`dst`: string, `wad`: `BigNumber`, `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:873](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L873)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`dst` | string | - | +`wad` | `BigNumber` | - | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`dst`: string, `wad`: `BigNumber`): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:947](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L947)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | +------ | ------ | +`dst` | string | +`wad` | `BigNumber` | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:960](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L960)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`dst`: string, `wad`: `BigNumber`, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:810](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L810)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`dst` | string | - | - | +`wad` | `BigNumber` | - | - | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### transferFrom + +#### ▪ **transferFrom**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:326](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L326)* + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`src`: string, `dst`: string, `wad`: `BigNumber`, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:375](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L375)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`src` | string | - | - | +`dst` | string | - | - | +`wad` | `BigNumber` | - | - | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`src`: string, `dst`: string, `wad`: `BigNumber`, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:445](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L445)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`src` | string | - | +`dst` | string | - | +`wad` | `BigNumber` | - | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +#### estimateGasAsync + +▸ **estimateGasAsync**(`src`: string, `dst`: string, `wad`: `BigNumber`, `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:410](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L410)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`src` | string | - | +`dst` | string | - | +`wad` | `BigNumber` | - | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`src`: string, `dst`: string, `wad`: `BigNumber`): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:500](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L500)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | +------ | ------ | +`src` | string | +`dst` | string | +`wad` | `BigNumber` | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:515](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L515)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`src`: string, `dst`: string, `wad`: `BigNumber`, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:333](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L333)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`src` | string | - | - | +`dst` | string | - | - | +`wad` | `BigNumber` | - | - | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### withdraw + +#### ▪ **withdraw**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:521](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L521)* + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`wad`: `BigNumber`, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:562](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L562)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`wad` | `BigNumber` | - | - | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`wad`: `BigNumber`, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:611](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L611)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`wad` | `BigNumber` | - | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +#### estimateGasAsync + +▸ **estimateGasAsync**(`wad`: `BigNumber`, `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:587](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L587)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`wad` | `BigNumber` | - | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`wad`: `BigNumber`): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:654](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L654)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | +------ | ------ | +`wad` | `BigNumber` | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:663](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L663)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`wad`: `BigNumber`, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:528](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L528)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`wad` | `BigNumber` | - | - | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +
+ +# Class: ZRXTokenContract + + +## Constructors + + + +\+ **new ZRXTokenContract**(`address`: string, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults?`: `Partial`, `logDecodeDependencies?`: undefined | object, `deployedBytecode`: string | undefined): *[ZRXTokenContract](#class-zrxtokencontract)* + +*Overrides void* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:1241](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L1241)* + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`address` | string | - | +`supportedProvider` | [SupportedProvider](#supportedprovider) | - | +`txDefaults?` | `Partial` | - | +`logDecodeDependencies?` | undefined \| object | - | +`deployedBytecode` | string \| undefined | ZRXTokenContract.deployedBytecode | + +**Returns:** *[ZRXTokenContract](#class-zrxtokencontract)* + +## Properties + +#### `Optional` _deployedBytecodeIfExists + +• **_deployedBytecodeIfExists**? : *`Buffer`* + + + +Defined in base-contract/lib/src/index.d.ts:31 + +___ + +### abi + +• **abi**: *[ContractAbi](#contractabi)* + + + +Defined in base-contract/lib/src/index.d.ts:27 + +___ + +### address + +• **address**: *string* + + + +Defined in base-contract/lib/src/index.d.ts:28 + +___ + +Args + +• **constructorArgs**: *any[]* + + + +Defined in base-contract/lib/src/index.d.ts:30 + +___ + +### contractName + +• **contractName**: *string* + + + +Defined in base-contract/lib/src/index.d.ts:29 + +## Methods + +### getLogsAsync + +▸ **getLogsAsync**<**ArgsType**>(`eventName`: [ZRXTokenEvents](#enumeration-zrxtokenevents), `blockRange`: `BlockRange`, `indexFilterValues`: `IndexedFilterValues`): *`Promise>>`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:1225](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L1225)* + +Gets historical logs without creating a subscription + +**Type parameters:** + +▪ **ArgsType**: *[ZRXTokenEventArgs](#zrxtokeneventargs)* + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`eventName` | [ZRXTokenEvents](#enumeration-zrxtokenevents) | The ZRXToken contract event you would like to subscribe to. | +`blockRange` | `BlockRange` | Block range to get logs from. | +`indexFilterValues` | `IndexedFilterValues` | An object where the keys are indexed args returned by the event and the value is the value you are interested in. E.g `{_from: aUserAddressHex}` | + +**Returns:** *`Promise>>`* + +Array of logs that match the parameters + +___ + +### subscribe + +▸ **subscribe**<**ArgsType**>(`eventName`: [ZRXTokenEvents](#enumeration-zrxtokenevents), `indexFilterValues`: `IndexedFilterValues`, `callback`: [EventCallback](#eventcallback)‹*`ArgsType`*›, `isVerbose`: boolean, `blockPollingIntervalMs?`: undefined | number): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:1183](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L1183)* + +Subscribe to an event type emitted by the ZRXToken contract. + +**Type parameters:** + +▪ **ArgsType**: *[ZRXTokenEventArgs](#zrxtokeneventargs)* + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`eventName` | [ZRXTokenEvents](#enumeration-zrxtokenevents) | - | The ZRXToken contract event you would like to subscribe to. | +`indexFilterValues` | `IndexedFilterValues` | - | An object where the keys are indexed args returned by the event and the value is the value you are interested in. E.g `{maker: aUserAddressHex}` | +`callback` | [EventCallback](#eventcallback)‹*`ArgsType`*› | - | Callback that gets called when a log is added/removed | +`isVerbose` | boolean | false | Enable verbose subscription warnings (e.g recoverable network issues encountered) | +`blockPollingIntervalMs?` | undefined \| number | - | - | + +**Returns:** *string* + +Subscription token used later to unsubscribe + +___ + +### unsubscribe + +▸ **unsubscribe**(`subscriptionToken`: string): *void* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:1208](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L1208)* + +Cancel a subscription + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`subscriptionToken` | string | Subscription token returned by `subscribe()` | + +**Returns:** *void* + +___ + +### unsubscribeAll + +▸ **unsubscribeAll**(): *void* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:1214](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L1214)* + +Cancels all existing subscriptions + +**Returns:** *void* + +___ + +### `Static` ABI + +▸ **ABI**(): *[ContractAbi](#contractabi)* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:955](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L955)* + +**Returns:** *[ContractAbi](#contractabi)* + +The contract ABI + +___ + +### `Static` deployAsync + +▸ **deployAsync**(`bytecode`: string, `abi`: [ContractAbi](#contractabi), `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:913](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L913)* + +**Parameters:** + +Name | Type | +------ | ------ | +`bytecode` | string | +`abi` | [ContractAbi](#contractabi) | +`supportedProvider` | [SupportedProvider](#supportedprovider) | +`txDefaults` | `Partial` | +`logDecodeDependencies` | object | + +**Returns:** *`Promise`* + +___ + +### `Static` deployFrom0xArtifactAsync + +▸ **deployFrom0xArtifactAsync**(`artifact`: `ContractArtifact` | `SimpleContractArtifact`, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:888](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L888)* + +**Parameters:** + +Name | Type | +------ | ------ | +`artifact` | `ContractArtifact` \| `SimpleContractArtifact` | +`supportedProvider` | [SupportedProvider](#supportedprovider) | +`txDefaults` | `Partial` | +`logDecodeDependencies` | object | + +**Returns:** *`Promise`* + +___ + +### `Static` strictArgumentEncodingCheck + +▸ **strictArgumentEncodingCheck**(`inputAbi`: `DataItem`[], `args`: any[]): *string* + + + +Defined in base-contract/lib/src/index.d.ts:41 + +**Parameters:** + +Name | Type | +------ | ------ | +`inputAbi` | `DataItem`[] | +`args` | any[] | + +**Returns:** *string* + +## Object literals + +### allowance + +#### ▪ **allowance**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:834](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L834)* + +#### callAsync + +▸ **callAsync**(`_owner`: string, `_spender`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:840](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L840)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`_owner` | string | - | +`_spender` | string | - | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +___ + +### approve + +#### ▪ **approve**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:104](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L104)* + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`_spender`: string, `_value`: `BigNumber`, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:150](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L150)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_spender` | string | - | - | +`_value` | `BigNumber` | - | - | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`_spender`: string, `_value`: `BigNumber`, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:209](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L209)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`_spender` | string | - | +`_value` | `BigNumber` | - | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +#### estimateGasAsync + +▸ **estimateGasAsync**(`_spender`: string, `_value`: `BigNumber`, `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:177](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L177)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`_spender` | string | - | +`_value` | `BigNumber` | - | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`_spender`: string, `_value`: `BigNumber`): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:261](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L261)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | +------ | ------ | +`_spender` | string | +`_value` | `BigNumber` | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:274](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L274)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`_spender`: string, `_value`: `BigNumber`, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:111](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L111)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_spender` | string | - | - | +`_value` | `BigNumber` | - | - | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### balanceOf + +#### ▪ **balanceOf**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:580](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L580)* + +#### callAsync + +▸ **callAsync**(`_owner`: string, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:586](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L586)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`_owner` | string | - | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +___ + +### decimals + +#### ▪ **decimals**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:537](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L537)* + +#### callAsync + +▸ **callAsync**(`callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:543](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L543)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +___ + +### name + +#### ▪ **name**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:61](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L61)* + +#### callAsync + +▸ **callAsync**(`callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:67](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L67)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +___ + +### symbol + +#### ▪ **symbol**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:628](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L628)* + +#### callAsync + +▸ **callAsync**(`callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:634](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L634)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +___ + +### totalSupply + +#### ▪ **totalSupply**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:280](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L280)* + +#### callAsync + +▸ **callAsync**(`callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:286](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L286)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +___ + +### transfer + +#### ▪ **transfer**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:671](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L671)* + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`_to`: string, `_value`: `BigNumber`, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:714](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L714)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_to` | string | - | - | +`_value` | `BigNumber` | - | - | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`_to`: string, `_value`: `BigNumber`, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:766](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L766)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`_to` | string | - | +`_value` | `BigNumber` | - | +`callData` | `Partial` | {} | +`defaultBlock?` | [BlockParam](#blockparam) | - | + +**Returns:** *`Promise`* + +#### estimateGasAsync + +▸ **estimateGasAsync**(`_to`: string, `_value`: `BigNumber`, `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:741](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L741)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`_to` | string | - | +`_value` | `BigNumber` | - | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`_to`: string, `_value`: `BigNumber`): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:815](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L815)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | +------ | ------ | +`_to` | string | +`_value` | `BigNumber` | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:828](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L828)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`_to`: string, `_value`: `BigNumber`, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:678](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L678)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_to` | string | - | - | +`_value` | `BigNumber` | - | - | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +___ + +### transferFrom + +#### ▪ **transferFrom**: *object* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:326](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L326)* + +ERC20 transferFrom, modified such that an allowance of MAX_UINT represents an unlimited allowance. + +#### awaitTransactionSuccessAsync + +▸ **awaitTransactionSuccessAsync**(`_from`: string, `_to`: string, `_value`: `BigNumber`, `txData?`: `Partial`, `opts`: `AwaitTransactionSuccessOpts`): *`PromiseWithTransactionHash`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:381](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L381)* + +Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. +If the transaction was mined, but reverted, an error is thrown. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_from` | string | - | Address to transfer from. | +`_to` | string | - | Address to transfer to. | +`_value` | `BigNumber` | - | Amount to transfer. | +`txData?` | `Partial` | - | Additional data for transaction | +`opts` | `AwaitTransactionSuccessOpts` | { shouldValidate: true } | - | + +**Returns:** *`PromiseWithTransactionHash`* + +A promise that resolves when the transaction is successful + +#### callAsync + +▸ **callAsync**(`_from`: string, `_to`: string, `_value`: `BigNumber`, `callData`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:458](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L458)* + +Sends a read-only call to the contract method. Returns the result that would happen if one were to send an +Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas +since they don't modify state. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_from` | string | - | Address to transfer from. | +`_to` | string | - | Address to transfer to. | +`_value` | `BigNumber` | - | Amount to transfer. | +`callData` | `Partial` | {} | - | +`defaultBlock?` | [BlockParam](#blockparam) | - | - | + +**Returns:** *`Promise`* + +Success of transfer. + +#### estimateGasAsync + +▸ **estimateGasAsync**(`_from`: string, `_to`: string, `_value`: `BigNumber`, `txData?`: `Partial` | undefined): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:419](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L419)* + +Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`_from` | string | Address to transfer from. | +`_to` | string | Address to transfer to. | +`_value` | `BigNumber` | Amount to transfer. | +`txData?` | `Partial` \| undefined | Additional data for transaction | + +**Returns:** *`Promise`* + +The hash of the transaction + +#### getABIEncodedTransactionData + +▸ **getABIEncodedTransactionData**(`_from`: string, `_to`: string, `_value`: `BigNumber`): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:516](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L516)* + +Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before +sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used +to create a 0x transaction (see protocol spec for more details). + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`_from` | string | Address to transfer from. | +`_to` | string | Address to transfer to. | +`_value` | `BigNumber` | Amount to transfer. | + +**Returns:** *string* + +The ABI encoded transaction data as a string + +#### getSelector + +▸ **getSelector**(): *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:531](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L531)* + +Returns the 4 byte function selector as a hex string. + +**Returns:** *string* + +#### sendTransactionAsync + +▸ **sendTransactionAsync**(`_from`: string, `_to`: string, `_value`: `BigNumber`, `txData?`: `Partial` | undefined, `opts`: `SendTransactionOpts`): *`Promise`* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:336](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L336)* + +Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write +Ethereum operation and will cost gas. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`_from` | string | - | Address to transfer from. | +`_to` | string | - | Address to transfer to. | +`_value` | `BigNumber` | - | Amount to transfer. | +`txData?` | `Partial` \| undefined | - | Additional data for transaction | +`opts` | `SendTransactionOpts` | { shouldValidate: true } | - | + +**Returns:** *`Promise`* + +The hash of the transaction + +
+ +# Class: ContractWrappers + +The ContractWrappers class contains smart contract wrappers helpful when building on 0x protocol. + + +## Constructors + + + +\+ **new ContractWrappers**(`supportedProvider`: [SupportedProvider](#supportedprovider), `config`: [ContractWrappersConfig](#interface-contractwrappersconfig)): *[ContractWrappers](#class-contractwrappers)* + +*Defined in [contract-wrappers/src/contract_wrappers.ts:84](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-wrappers/src/contract_wrappers.ts#L84)* + +Instantiates a new ContractWrappers instance. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`supportedProvider` | [SupportedProvider](#supportedprovider) | The Provider instance you would like the contract-wrappers library to use for interacting with the Ethereum network. | +`config` | [ContractWrappersConfig](#interface-contractwrappersconfig) | The configuration object. Look up the type for the description. | + +**Returns:** *[ContractWrappers](#class-contractwrappers)* + +An instance of the ContractWrappers class. + +## Properties + +#### contractAddresses + +• **contractAddresses**: *`ContractAddresses`* + +*Defined in [contract-wrappers/src/contract_wrappers.ts:43](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-wrappers/src/contract_wrappers.ts#L43)* + +An index of the default contract addresses for this chain. + +___ + +### coordinator + +• **coordinator**: *[CoordinatorWrapper](#class-coordinatorwrapper)* + +*Defined in [contract-wrappers/src/contract_wrappers.ts:82](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-wrappers/src/contract_wrappers.ts#L82)* + +An instance of the CoordinatorWrapper class containing methods for interacting with the Coordinator extension contract. + +___ + +### devUtils + +• **devUtils**: *`DevUtilsContract`* + +*Defined in [contract-wrappers/src/contract_wrappers.ts:78](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-wrappers/src/contract_wrappers.ts#L78)* + +An instance of the DevUtilsContract class containing methods for interacting with the DevUtils smart contract. + +___ + +### dutchAuction + +• **dutchAuction**: *`DutchAuctionContract`* + +*Defined in [contract-wrappers/src/contract_wrappers.ts:74](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-wrappers/src/contract_wrappers.ts#L74)* + +An instance of the DutchAuctionContract class containing methods for interacting with any DutchAuction smart contract. + +___ + +### erc20Proxy + +• **erc20Proxy**: *`ERC20ProxyContract`* + +*Defined in [contract-wrappers/src/contract_wrappers.ts:52](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-wrappers/src/contract_wrappers.ts#L52)* + +An instance of the ERC20ProxyContract class containing methods for interacting with the +erc20Proxy smart contract. + +___ + +### erc721Proxy + +• **erc721Proxy**: *`ERC721ProxyContract`* + +*Defined in [contract-wrappers/src/contract_wrappers.ts:57](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-wrappers/src/contract_wrappers.ts#L57)* + +An instance of the ERC721ProxyContract class containing methods for interacting with the +erc721Proxy smart contract. + +___ + +### exchange + +• **exchange**: *`ExchangeContract`* + +*Defined in [contract-wrappers/src/contract_wrappers.ts:47](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-wrappers/src/contract_wrappers.ts#L47)* + +An instance of the ExchangeContract class containing methods for interacting with the 0x Exchange smart contract. + +___ + +### forwarder + +• **forwarder**: *`ForwarderContract`* + +*Defined in [contract-wrappers/src/contract_wrappers.ts:66](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-wrappers/src/contract_wrappers.ts#L66)* + +An instance of the ForwarderContract class containing methods for interacting with any Forwarder smart contract. + +___ + +### orderValidator + +• **orderValidator**: *`OrderValidatorContract`* + +*Defined in [contract-wrappers/src/contract_wrappers.ts:70](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-wrappers/src/contract_wrappers.ts#L70)* + +An instance of the OrderValidatorContract class containing methods for interacting with any OrderValidator smart contract. + +___ + +### weth9 + +• **weth9**: *`WETH9Contract`* + +*Defined in [contract-wrappers/src/contract_wrappers.ts:62](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-wrappers/src/contract_wrappers.ts#L62)* + +An instance of the WETH9Contract class containing methods for interacting with the +WETH9 smart contract. + +## Methods + +### getAbiDecoder + +▸ **getAbiDecoder**(): *`AbiDecoder`* + +*Defined in [contract-wrappers/src/contract_wrappers.ts:155](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-wrappers/src/contract_wrappers.ts#L155)* + +Get the abi decoder instance currently used by contract-wrappers + +**Returns:** *`AbiDecoder`* + +AbiDecoder instance + +___ + +### getProvider + +▸ **getProvider**(): *[SupportedProvider](#supportedprovider)* + +*Defined in [contract-wrappers/src/contract_wrappers.ts:148](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-wrappers/src/contract_wrappers.ts#L148)* + +Get the provider instance currently used by contract-wrappers + +**Returns:** *[SupportedProvider](#supportedprovider)* + +Web3 provider instance + +___ + +### unsubscribeAll + +▸ **unsubscribeAll**(): *void* + +*Defined in [contract-wrappers/src/contract_wrappers.ts:138](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-wrappers/src/contract_wrappers.ts#L138)* + +Unsubscribes from all subscriptions for all contracts. + +**Returns:** *void* + +
+ +# Class: CoordinatorWrapper + +This class includes all the functionality related to filling or cancelling orders through +the 0x V2 Coordinator extension contract. + + +## Constructors + + + +\+ **new CoordinatorWrapper**(`provider`: [SupportedProvider](#supportedprovider), `chainId`: number, `address?`: undefined | string, `exchangeAddress?`: undefined | string, `registryAddress?`: undefined | string): *[CoordinatorWrapper](#class-coordinatorwrapper)* + +*Defined in [contract-wrappers/src/coordinator_wrapper.ts:43](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-wrappers/src/coordinator_wrapper.ts#L43)* + +Instantiate CoordinatorWrapper + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`provider` | [SupportedProvider](#supportedprovider) | - | +`chainId` | number | Desired chainId. | +`address?` | undefined \| string | The address of the Coordinator contract. If undefined, will default to the known address corresponding to the chainId. | +`exchangeAddress?` | undefined \| string | The address of the Exchange contract. If undefined, will default to the known address corresponding to the chainId. | +`registryAddress?` | undefined \| string | The address of the CoordinatorRegistry contract. If undefined, will default to the known address corresponding to the chainId. | + +**Returns:** *[CoordinatorWrapper](#class-coordinatorwrapper)* + +## Properties + +### abi + +• **abi**: *[ContractAbi](#contractabi)* = Coordinator.compilerOutput.abi + +*Defined in [contract-wrappers/src/coordinator_wrapper.ts:34](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-wrappers/src/coordinator_wrapper.ts#L34)* + +___ + +### address + +• **address**: *string* + +*Defined in [contract-wrappers/src/coordinator_wrapper.ts:36](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-wrappers/src/coordinator_wrapper.ts#L36)* + +___ + +### chainId + +• **chainId**: *number* + +*Defined in [contract-wrappers/src/coordinator_wrapper.ts:35](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-wrappers/src/coordinator_wrapper.ts#L35)* + +___ + +### exchangeAddress + +• **exchangeAddress**: *string* + +*Defined in [contract-wrappers/src/coordinator_wrapper.ts:37](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-wrappers/src/coordinator_wrapper.ts#L37)* + +___ + +### registryAddress + +• **registryAddress**: *string* + +*Defined in [contract-wrappers/src/coordinator_wrapper.ts:38](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-wrappers/src/coordinator_wrapper.ts#L38)* + +## Methods + +### assertValidCoordinatorApprovalsOrThrowAsync + +▸ **assertValidCoordinatorApprovalsOrThrowAsync**(`transaction`: `ZeroExTransaction`, `txOrigin`: string, `transactionSignature`: string, `approvalExpirationTimeSeconds`: `BigNumber`[], `approvalSignatures`: string[]): *`Promise`* + +*Defined in [contract-wrappers/src/coordinator_wrapper.ts:529](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-wrappers/src/coordinator_wrapper.ts#L529)* + +Validates that the 0x transaction has been approved by all of the feeRecipients that correspond to each order in the transaction's Exchange calldata. +Throws an error if the transaction approvals are not valid. Will not detect failures that would occur when the transaction is executed on the Exchange contract. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`transaction` | `ZeroExTransaction` | 0x transaction containing salt, signerAddress, and data. | +`txOrigin` | string | Required signer of Ethereum transaction calling this function. | +`transactionSignature` | string | Proof that the transaction has been signed by the signer. | +`approvalExpirationTimeSeconds` | `BigNumber`[] | Array of expiration times in seconds for which each corresponding approval signature expires. | +`approvalSignatures` | string[] | Array of signatures that correspond to the feeRecipients of each order in the transaction's Exchange calldata. | + +**Returns:** *`Promise`* + +___ + +### batchFillOrKillOrdersAsync + +▸ **batchFillOrKillOrdersAsync**(`signedOrders`: `SignedOrder`[], `takerAssetFillAmounts`: `BigNumber`[], `takerAddress`: string, `orderTransactionOpts`: [OrderTransactionOpts](#interface-ordertransactionopts)): *`Promise`* + +*Defined in [contract-wrappers/src/coordinator_wrapper.ts:241](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-wrappers/src/coordinator_wrapper.ts#L241)* + +Batch version of fillOrKillOrderAsync. Executes multiple fills atomically in a single transaction. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`signedOrders` | `SignedOrder`[] | - | An array of signed orders to fill. | +`takerAssetFillAmounts` | `BigNumber`[] | - | The amounts of the orders (in taker asset baseUnits) that you wish to fill. | +`takerAddress` | string | - | The user Ethereum address who would like to fill these orders. Must be available via the supplied Provider provided at instantiation. | +`orderTransactionOpts` | [OrderTransactionOpts](#interface-ordertransactionopts) | { shouldValidate: true } | Optional arguments this method accepts. | + +**Returns:** *`Promise`* + +Transaction hash. + +___ + +### batchFillOrdersAsync + +▸ **batchFillOrdersAsync**(`signedOrders`: `SignedOrder`[], `takerAssetFillAmounts`: `BigNumber`[], `takerAddress`: string, `orderTransactionOpts`: [OrderTransactionOpts](#interface-ordertransactionopts)): *`Promise`* + +*Defined in [contract-wrappers/src/coordinator_wrapper.ts:171](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-wrappers/src/coordinator_wrapper.ts#L171)* + +Batch version of fillOrderAsync. Executes multiple fills atomically in a single transaction. +Under-the-hood, this method uses the `feeRecipientAddress`s of the orders to looks up the coordinator server endpoints +registered in the coordinator registry contract. It requests a signature from each coordinator server before +submitting the orders and signatures as a 0x transaction to the coordinator extension contract, which validates the +signatures and then fills the order through the Exchange contract. +If any `feeRecipientAddress` in the batch is not registered to a coordinator server, the whole batch fails. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`signedOrders` | `SignedOrder`[] | - | An array of signed orders to fill. | +`takerAssetFillAmounts` | `BigNumber`[] | - | The amounts of the orders (in taker asset baseUnits) that you wish to fill. | +`takerAddress` | string | - | The user Ethereum address who would like to fill these orders. Must be available via the supplied Provider provided at instantiation. | +`orderTransactionOpts` | [OrderTransactionOpts](#interface-ordertransactionopts) | { shouldValidate: true } | Optional arguments this method accepts. | + +**Returns:** *`Promise`* + +Transaction hash. + +___ + +### batchFillOrdersNoThrowAsync + +▸ **batchFillOrdersNoThrowAsync**(`signedOrders`: `SignedOrder`[], `takerAssetFillAmounts`: `BigNumber`[], `takerAddress`: string, `orderTransactionOpts`: [OrderTransactionOpts](#interface-ordertransactionopts)): *`Promise`* + +*Defined in [contract-wrappers/src/coordinator_wrapper.ts:206](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-wrappers/src/coordinator_wrapper.ts#L206)* + +No throw version of batchFillOrdersAsync + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`signedOrders` | `SignedOrder`[] | - | An array of signed orders to fill. | +`takerAssetFillAmounts` | `BigNumber`[] | - | The amounts of the orders (in taker asset baseUnits) that you wish to fill. | +`takerAddress` | string | - | The user Ethereum address who would like to fill these orders. Must be available via the supplied Provider provided at instantiation. | +`orderTransactionOpts` | [OrderTransactionOpts](#interface-ordertransactionopts) | { shouldValidate: true } | Optional arguments this method accepts. | + +**Returns:** *`Promise`* + +Transaction hash. + +___ + +### batchHardCancelOrdersAsync + +▸ **batchHardCancelOrdersAsync**(`orders`: `SignedOrder`[], `orderTransactionOpts`: [OrderTransactionOpts](#interface-ordertransactionopts)): *`Promise`* + +*Defined in [contract-wrappers/src/coordinator_wrapper.ts:460](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-wrappers/src/coordinator_wrapper.ts#L460)* + +Batch version of hardCancelOrderAsync. Cancels orders on-chain by submitting an Ethereum transaction. +Executes multiple cancels atomically in a single transaction. -___ +**Parameters:** -### Fill +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`orders` | `SignedOrder`[] | - | An array of orders to cancel. | +`orderTransactionOpts` | [OrderTransactionOpts](#interface-ordertransactionopts) | { shouldValidate: true } | Optional arguments this method accepts. | -• **Fill**: = "Fill" +**Returns:** *`Promise`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:51](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L51)* +Transaction hash. ___ -### ProtocolFeeCollectorAddress +### batchSoftCancelOrdersAsync -• **ProtocolFeeCollectorAddress**: = "ProtocolFeeCollectorAddress" +▸ **batchSoftCancelOrdersAsync**(`orders`: `SignedOrder`[]): *`Promise`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:52](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L52)* +*Defined in [contract-wrappers/src/coordinator_wrapper.ts:374](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-wrappers/src/coordinator_wrapper.ts#L374)* -___ +Batch version of softCancelOrderAsync. Requests multiple soft cancels -### ProtocolFeeMultiplier +**Parameters:** -• **ProtocolFeeMultiplier**: = "ProtocolFeeMultiplier" +Name | Type | Description | +------ | ------ | ------ | +`orders` | `SignedOrder`[] | An array of orders to cancel. | + +**Returns:** *`Promise`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:53](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L53)* +CoordinatorServerCancellationResponse. See [Cancellation Response](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/coordinator-specification.md#response). ___ -### SignatureValidatorApproval +### fillOrKillOrderAsync -• **SignatureValidatorApproval**: = "SignatureValidatorApproval" +▸ **fillOrKillOrderAsync**(`signedOrder`: `SignedOrder`, `takerAssetFillAmount`: `BigNumber`, `takerAddress`: string, `orderTransactionOpts`: [OrderTransactionOpts](#interface-ordertransactionopts)): *`Promise`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:54](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L54)* +*Defined in [contract-wrappers/src/coordinator_wrapper.ts:134](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-wrappers/src/coordinator_wrapper.ts#L134)* -___ +Attempts to fill a specific amount of an order. If the entire amount specified cannot be filled, +the fill order is abandoned. -### TransactionExecution +**Parameters:** -• **TransactionExecution**: = "TransactionExecution" +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`signedOrder` | `SignedOrder` | - | An object that conforms to the SignedOrder interface. | +`takerAssetFillAmount` | `BigNumber` | - | The amount of the order (in taker asset baseUnits) that you wish to fill. | +`takerAddress` | string | - | The user Ethereum address who would like to fill this order. Must be available via the supplied Provider provided at instantiation. | +`orderTransactionOpts` | [OrderTransactionOpts](#interface-ordertransactionopts) | { shouldValidate: true } | Optional arguments this method accepts. | -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:55](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L55)* +**Returns:** *`Promise`* -
+Transaction hash. -# Enumeration: WETH9Events +___ + +### fillOrderAsync +▸ **fillOrderAsync**(`signedOrder`: `SignedOrder`, `takerAssetFillAmount`: `BigNumber`, `takerAddress`: string, `orderTransactionOpts`: [OrderTransactionOpts](#interface-ordertransactionopts)): *`Promise`* -## Enumeration members +*Defined in [contract-wrappers/src/coordinator_wrapper.ts:101](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-wrappers/src/coordinator_wrapper.ts#L101)* -### Approval +Fills a signed order with an amount denominated in baseUnits of the taker asset. Under-the-hood, this +method uses the `feeRecipientAddress` of the order to look up the coordinator server endpoint registered in the +coordinator registry contract. It requests a signature from that coordinator server before +submitting the order and signature as a 0x transaction to the coordinator extension contract. The coordinator extension +contract validates signatures and then fills the order via the Exchange contract. -• **Approval**: = "Approval" +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`signedOrder` | `SignedOrder` | - | An object that conforms to the SignedOrder interface. | +`takerAssetFillAmount` | `BigNumber` | - | The amount of the order (in taker asset baseUnits) that you wish to fill. | +`takerAddress` | string | - | The user Ethereum address who would like to fill this order. Must be available via the supplied Provider provided at instantiation. | +`orderTransactionOpts` | [OrderTransactionOpts](#interface-ordertransactionopts) | { shouldValidate: true } | Optional arguments this method accepts. | + +**Returns:** *`Promise`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:44](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L44)* +Transaction hash. ___ -### Deposit +### getSignerAddressAsync -• **Deposit**: = "Deposit" +▸ **getSignerAddressAsync**(`hash`: string, `signature`: string): *`Promise`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:46](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L46)* +*Defined in [contract-wrappers/src/coordinator_wrapper.ts:561](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-wrappers/src/coordinator_wrapper.ts#L561)* -___ +Recovers the address of a signer given a hash and signature. -### Transfer +**Parameters:** -• **Transfer**: = "Transfer" +Name | Type | Description | +------ | ------ | ------ | +`hash` | string | Any 32 byte hash. | +`signature` | string | Proof that the hash has been signed by signer. | + +**Returns:** *`Promise`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:45](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L45)* +Signer address. ___ -### Withdrawal +### hardCancelOrderAsync -• **Withdrawal**: = "Withdrawal" +▸ **hardCancelOrderAsync**(`order`: `Order` | `SignedOrder`, `orderTransactionOpts`: [OrderTransactionOpts](#interface-ordertransactionopts)): *`Promise`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:47](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L47)* +*Defined in [contract-wrappers/src/coordinator_wrapper.ts:428](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-wrappers/src/coordinator_wrapper.ts#L428)* -
+Cancels an order on-chain by submitting an Ethereum transaction. + +**Parameters:** + +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`order` | `Order` \| `SignedOrder` | - | An object that conforms to the Order or SignedOrder interface. The order you would like to cancel. | +`orderTransactionOpts` | [OrderTransactionOpts](#interface-ordertransactionopts) | { shouldValidate: true } | Optional arguments this method accepts. | +**Returns:** *`Promise`* +Transaction hash. +___ +### hardCancelOrdersUpToAsync -# Enumeration: ContractError +▸ **hardCancelOrdersUpToAsync**(`targetOrderEpoch`: `BigNumber`, `senderAddress`: string, `orderTransactionOpts`: [OrderTransactionOpts](#interface-ordertransactionopts)): *`Promise`* +*Defined in [contract-wrappers/src/coordinator_wrapper.ts:495](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-wrappers/src/coordinator_wrapper.ts#L495)* -## Enumeration members +Cancels orders on-chain by submitting an Ethereum transaction. +Cancels all orders created by makerAddress with a salt less than or equal to the targetOrderEpoch +and senderAddress equal to coordinator extension contract address. -### ContractNotDeployedOnChain +**Parameters:** -• **ContractNotDeployedOnChain**: = "CONTRACT_NOT_DEPLOYED_ON_CHAIN" +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`targetOrderEpoch` | `BigNumber` | - | Target order epoch. | +`senderAddress` | string | - | Address that should send the transaction. | +`orderTransactionOpts` | [OrderTransactionOpts](#interface-ordertransactionopts) | { shouldValidate: true } | Optional arguments this method accepts. | -*Defined in [contract-wrappers/src/types.ts:16](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-wrappers/src/types.ts#L16)* +**Returns:** *`Promise`* + +Transaction hash. ___ -### ERC721NoApproval +### marketBuyOrdersNoThrowAsync -• **ERC721NoApproval**: = "ERC_721_NO_APPROVAL" +▸ **marketBuyOrdersNoThrowAsync**(`signedOrders`: `SignedOrder`[], `makerAssetFillAmount`: `BigNumber`, `takerAddress`: string, `orderTransactionOpts`: [OrderTransactionOpts](#interface-ordertransactionopts)): *`Promise`* -*Defined in [contract-wrappers/src/types.ts:26](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-wrappers/src/types.ts#L26)* +*Defined in [contract-wrappers/src/coordinator_wrapper.ts:276](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-wrappers/src/coordinator_wrapper.ts#L276)* -___ +No throw version of marketBuyOrdersAsync -### ERC721OwnerNotFound +**Parameters:** -• **ERC721OwnerNotFound**: = "ERC_721_OWNER_NOT_FOUND" +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`signedOrders` | `SignedOrder`[] | - | An array of signed orders to fill. | +`makerAssetFillAmount` | `BigNumber` | - | Maker asset fill amount. | +`takerAddress` | string | - | The user Ethereum address who would like to fill these orders. Must be available via the supplied Provider provided at instantiation. | +`orderTransactionOpts` | [OrderTransactionOpts](#interface-ordertransactionopts) | { shouldValidate: true } | Optional arguments this method accepts. | + +**Returns:** *`Promise`* -*Defined in [contract-wrappers/src/types.ts:25](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-wrappers/src/types.ts#L25)* +Transaction hash. ___ -### InsufficientAllowanceForTransfer +### marketSellOrdersNoThrowAsync -• **InsufficientAllowanceForTransfer**: = "INSUFFICIENT_ALLOWANCE_FOR_TRANSFER" +▸ **marketSellOrdersNoThrowAsync**(`signedOrders`: `SignedOrder`[], `takerAssetFillAmount`: `BigNumber`, `takerAddress`: string, `orderTransactionOpts`: [OrderTransactionOpts](#interface-ordertransactionopts)): *`Promise`* -*Defined in [contract-wrappers/src/types.ts:17](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-wrappers/src/types.ts#L17)* +*Defined in [contract-wrappers/src/coordinator_wrapper.ts:309](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-wrappers/src/coordinator_wrapper.ts#L309)* -___ +No throw version of marketSellOrdersAsync -### InsufficientBalanceForTransfer +**Parameters:** -• **InsufficientBalanceForTransfer**: = "INSUFFICIENT_BALANCE_FOR_TRANSFER" +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`signedOrders` | `SignedOrder`[] | - | An array of signed orders to fill. | +`takerAssetFillAmount` | `BigNumber` | - | Taker asset fill amount. | +`takerAddress` | string | - | The user Ethereum address who would like to fill these orders. Must be available via the supplied Provider provided at instantiation. | +`orderTransactionOpts` | [OrderTransactionOpts](#interface-ordertransactionopts) | { shouldValidate: true } | Optional arguments this method accepts. | -*Defined in [contract-wrappers/src/types.ts:18](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-wrappers/src/types.ts#L18)* +**Returns:** *`Promise`* + +Transaction hash. ___ -### InsufficientEthBalanceForDeposit +### softCancelOrderAsync -• **InsufficientEthBalanceForDeposit**: = "INSUFFICIENT_ETH_BALANCE_FOR_DEPOSIT" +▸ **softCancelOrderAsync**(`order`: `Order` | `SignedOrder`): *`Promise`* -*Defined in [contract-wrappers/src/types.ts:19](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-wrappers/src/types.ts#L19)* +*Defined in [contract-wrappers/src/coordinator_wrapper.ts:339](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-wrappers/src/coordinator_wrapper.ts#L339)* -___ +Soft cancel a given order. +Soft cancels are recorded only on coordinator operator servers and do not involve an Ethereum transaction. +See [soft cancels](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/coordinator-specification.md#soft-cancels). -### InsufficientWEthBalanceForWithdrawal +**Parameters:** -• **InsufficientWEthBalanceForWithdrawal**: = "INSUFFICIENT_WETH_BALANCE_FOR_WITHDRAWAL" +Name | Type | Description | +------ | ------ | ------ | +`order` | `Order` \| `SignedOrder` | An object that conforms to the Order or SignedOrder interface. The order you would like to cancel. | -*Defined in [contract-wrappers/src/types.ts:20](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-wrappers/src/types.ts#L20)* +**Returns:** *`Promise`* -___ +CoordinatorServerCancellationResponse. See [Cancellation Response](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/coordinator-specification.md#response). -### InvalidJump +
-• **InvalidJump**: = "INVALID_JUMP" +# Class: AbiDecoder -*Defined in [contract-wrappers/src/types.ts:21](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-wrappers/src/types.ts#L21)* +AbiDecoder allows you to decode event logs given a set of supplied contract ABI's. It takes the contract's event +signature from the ABI and attempts to decode the logs using it. -___ -### OutOfGas +## Constructors -• **OutOfGas**: = "OUT_OF_GAS" -*Defined in [contract-wrappers/src/types.ts:22](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-wrappers/src/types.ts#L22)* + +\+ **new AbiDecoder**(`abiArrays`: [AbiDefinition](#abidefinition)[][]): *[AbiDecoder](#class-abidecoder)* + +*Defined in [utils/src/abi_decoder.ts:42](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/utils/src/abi_decoder.ts#L42)* + +Instantiate an AbiDecoder + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`abiArrays` | [AbiDefinition](#abidefinition)[][] | An array of contract ABI's | + +**Returns:** *[AbiDecoder](#class-abidecoder)* + +AbiDecoder instance + +## Methods + +### addABI + +▸ **addABI**(`abiArray`: [AbiDefinition](#abidefinition)[], `contractName?`: undefined | string): *void* + +*Defined in [utils/src/abi_decoder.ts:158](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/utils/src/abi_decoder.ts#L158)* + +Adds a set of ABI definitions, after which calldata and logs targeting these ABI's can be decoded. +Additional properties can be included to disambiguate similar ABI's. For example, if two functions +have the same signature but different parameter names, then their ABI definitions can be disambiguated +by specifying a contract name. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`abiArray` | [AbiDefinition](#abidefinition)[] | - | +`contractName?` | undefined \| string | Name of contract that encapsulates the ABI definitions (optional). This can be used when decoding calldata to disambiguate methods with the same signature but different parameter names. | + +**Returns:** *void* ___ -### SignatureRequestDenied +### decodeCalldataOrThrow -• **SignatureRequestDenied**: = "SIGNATURE_REQUEST_DENIED" +▸ **decodeCalldataOrThrow**(`calldata`: string, `contractName?`: undefined | string): *`DecodedCalldata`* + +*Defined in [utils/src/abi_decoder.ts:118](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/utils/src/abi_decoder.ts#L118)* + +Decodes calldata for a known ABI. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`calldata` | string | hex-encoded calldata. | +`contractName?` | undefined \| string | used to disambiguate similar ABI's (optional). | -*Defined in [contract-wrappers/src/types.ts:27](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-wrappers/src/types.ts#L27)* +**Returns:** *`DecodedCalldata`* + +Decoded calldata. Includes: function name and signature, along with the decoded arguments. ___ -### SubscriptionAlreadyPresent +### tryToDecodeLogOrNoop + +▸ **tryToDecodeLogOrNoop**<**ArgsType**>(`log`: `LogEntry`): *`LogWithDecodedArgs` | [RawLog](#rawlog)* + +*Defined in [utils/src/abi_decoder.ts:58](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/utils/src/abi_decoder.ts#L58)* + +Attempt to decode a log given the ABI's the AbiDecoder knows about. + +**Type parameters:** + +▪ **ArgsType**: *`DecodedLogArgs`* + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`log` | `LogEntry` | The log to attempt to decode | + +**Returns:** *`LogWithDecodedArgs` | [RawLog](#rawlog)* + +The decoded log if the requisite ABI was available. Otherwise the log unaltered. + +
-• **SubscriptionAlreadyPresent**: = "SUBSCRIPTION_ALREADY_PRESENT" +# Enumeration: CoordinatorRegistryEvents -*Defined in [contract-wrappers/src/types.ts:24](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-wrappers/src/types.ts#L24)* -___ +## Enumeration members -### SubscriptionNotFound +### CoordinatorEndpointSet -• **SubscriptionNotFound**: = "SUBSCRIPTION_NOT_FOUND" +• **CoordinatorEndpointSet**: = "CoordinatorEndpointSet" -*Defined in [contract-wrappers/src/types.ts:23](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-wrappers/src/types.ts#L23)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts:37](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts#L37)*
-# Enumeration: ForwarderError +# Enumeration: DummyERC20TokenEvents ## Enumeration members -### CompleteFillFailed +### Approval -• **CompleteFillFailed**: = "COMPLETE_FILL_FAILED" +• **Approval**: = "Approval" -*Defined in [contract-wrappers/src/types.ts:12](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-wrappers/src/types.ts#L12)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:37](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L37)* -
+___ +### Transfer +• **Transfer**: = "Transfer" +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:38](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L38)* +
-# Enumeration: BlockParamLiteral +# Enumeration: DummyERC721TokenEvents ## Enumeration members -### Earliest +### Approval -• **Earliest**: = "earliest" +• **Approval**: = "Approval" -*Defined in [ethereum-types/src/index.ts:478](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L478)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:40](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L40)* ___ -### Latest +### ApprovalForAll -• **Latest**: = "latest" +• **ApprovalForAll**: = "ApprovalForAll" -*Defined in [ethereum-types/src/index.ts:479](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L479)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:41](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L41)* ___ -### Pending +### Transfer -• **Pending**: = "pending" +• **Transfer**: = "Transfer" -*Defined in [ethereum-types/src/index.ts:480](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L480)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:42](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L42)*
+# Enumeration: ERC1155ProxyEvents +## Enumeration members +### AuthorizedAddressAdded +• **AuthorizedAddressAdded**: = "AuthorizedAddressAdded" +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts:39](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts#L39)* +___ +### AuthorizedAddressRemoved +• **AuthorizedAddressRemoved**: = "AuthorizedAddressRemoved" +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts:40](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts#L40)* +
+# Enumeration: ERC20ProxyEvents +## Enumeration members +### AuthorizedAddressAdded +• **AuthorizedAddressAdded**: = "AuthorizedAddressAdded" +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts:39](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts#L39)* +___ +### AuthorizedAddressRemoved +• **AuthorizedAddressRemoved**: = "AuthorizedAddressRemoved" +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts:40](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts#L40)* +
+# Enumeration: ERC20TokenEvents +## Enumeration members +### Approval +• **Approval**: = "Approval" +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:38](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L38)* +___ +### Transfer -
- -# Interface: CoordinatorRegistryCoordinatorEndpointSetEventArgs +• **Transfer**: = "Transfer" +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:37](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L37)* -## Index +
-### Properties +# Enumeration: ERC721ProxyEvents -* [coordinatorEndpoint](#coordinatorendpoint) -* [coordinatorOperator](#coordinatoroperator) -## Properties +## Enumeration members -### coordinatorEndpoint +### AuthorizedAddressAdded -• **coordinatorEndpoint**: *string* +• **AuthorizedAddressAdded**: = "AuthorizedAddressAdded" -*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts:45](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts#L45)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts:39](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts#L39)* ___ -### coordinatorOperator +### AuthorizedAddressRemoved -• **coordinatorOperator**: *string* +• **AuthorizedAddressRemoved**: = "AuthorizedAddressRemoved" -*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts:44](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts#L44)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts:40](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts#L40)*
-# Interface: DummyERC20TokenApprovalEventArgs - - -## Index - -### Properties +# Enumeration: ERC721TokenEvents -* [_owner](#_owner) -* [_spender](#_spender) -* [_value](#_value) -## Properties +## Enumeration members -### _owner +### Approval -• **_owner**: *string* +• **Approval**: = "Approval" -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:45](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L45)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:40](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L40)* ___ -### _spender +### ApprovalForAll -• **_spender**: *string* +• **ApprovalForAll**: = "ApprovalForAll" -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:46](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L46)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:41](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L41)* ___ -### _value +### Transfer -• **_value**: *`BigNumber`* +• **Transfer**: = "Transfer" -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:47](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L47)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:42](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L42)*
-# Interface: DummyERC20TokenTransferEventArgs +# Enumeration: ExchangeEvents -## Index +## Enumeration members -### Properties +### AssetProxyRegistered -* [_from](#_from) -* [_to](#_to) -* [_value](#_value) +• **AssetProxyRegistered**: = "AssetProxyRegistered" -## Properties +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:45](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L45)* -### _from +___ -• **_from**: *string* +### Cancel + +• **Cancel**: = "Cancel" -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:51](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L51)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:46](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L46)* ___ -### _to +### CancelUpTo -• **_to**: *string* +• **CancelUpTo**: = "CancelUpTo" -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:52](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L52)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:47](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L47)* ___ -### _value - -• **_value**: *`BigNumber`* - -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:53](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L53)* +### Fill -
+• **Fill**: = "Fill" -# Interface: DummyERC721TokenApprovalEventArgs +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:48](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L48)* +___ -## Index +### ProtocolFeeCollectorAddress -### Properties +• **ProtocolFeeCollectorAddress**: = "ProtocolFeeCollectorAddress" -* [_approved](#_approved) -* [_owner](#_owner) -* [_tokenId](#_tokenid) +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:49](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L49)* -## Properties +___ -### _approved +### ProtocolFeeMultiplier -• **_approved**: *string* +• **ProtocolFeeMultiplier**: = "ProtocolFeeMultiplier" -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:50](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L50)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:50](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L50)* ___ -### _owner +### SignatureValidatorApproval -• **_owner**: *string* +• **SignatureValidatorApproval**: = "SignatureValidatorApproval" -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:49](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L49)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:51](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L51)* ___ -### _tokenId +### TransactionExecution -• **_tokenId**: *`BigNumber`* +• **TransactionExecution**: = "TransactionExecution" -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:51](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L51)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:52](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L52)*
-# Interface: DummyERC721TokenApprovalForAllEventArgs - - -## Index - -### Properties +# Enumeration: WETH9Events -* [_approved](#_approved) -* [_operator](#_operator) -* [_owner](#_owner) -## Properties +## Enumeration members -### _approved +### Approval -• **_approved**: *boolean* +• **Approval**: = "Approval" -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:57](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L57)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:41](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L41)* ___ -### _operator +### Deposit -• **_operator**: *string* +• **Deposit**: = "Deposit" -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:56](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L56)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:43](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L43)* ___ -### _owner - -• **_owner**: *string* - -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:55](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L55)* - -
+### Transfer -# Interface: DummyERC721TokenTransferEventArgs +• **Transfer**: = "Transfer" +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:42](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L42)* -## Index +___ -### Properties +### Withdrawal -* [_from](#_from) -* [_to](#_to) -* [_tokenId](#_tokenid) +• **Withdrawal**: = "Withdrawal" -## Properties +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:44](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L44)* -### _from +
-• **_from**: *string* +# Enumeration: ZRXTokenEvents -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:61](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L61)* -___ +## Enumeration members -### _to +### Approval -• **_to**: *string* +• **Approval**: = "Approval" -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:62](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L62)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:38](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L38)* ___ -### _tokenId +### Transfer -• **_tokenId**: *`BigNumber`* +• **Transfer**: = "Transfer" -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:63](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L63)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:37](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L37)*
-# Interface: ERC20TokenApprovalEventArgs - -## Index -### Properties +# Enumeration: ContractError -* [_owner](#_owner) -* [_spender](#_spender) -* [_value](#_value) -## Properties +## Enumeration members -### _owner +### ContractNotDeployedOnChain -• **_owner**: *string* +• **ContractNotDeployedOnChain**: = "CONTRACT_NOT_DEPLOYED_ON_CHAIN" -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:51](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L51)* +*Defined in [contract-wrappers/src/types.ts:16](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-wrappers/src/types.ts#L16)* ___ -### _spender +### ERC721NoApproval -• **_spender**: *string* +• **ERC721NoApproval**: = "ERC_721_NO_APPROVAL" -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:52](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L52)* +*Defined in [contract-wrappers/src/types.ts:26](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-wrappers/src/types.ts#L26)* ___ -### _value - -• **_value**: *`BigNumber`* - -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:53](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L53)* - -
- -# Interface: ERC20TokenTransferEventArgs - - -## Index - -### Properties - -* [_from](#_from) -* [_to](#_to) -* [_value](#_value) - -## Properties - -### _from +### ERC721OwnerNotFound -• **_from**: *string* +• **ERC721OwnerNotFound**: = "ERC_721_OWNER_NOT_FOUND" -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:45](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L45)* +*Defined in [contract-wrappers/src/types.ts:25](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-wrappers/src/types.ts#L25)* ___ -### _to +### InsufficientAllowanceForTransfer -• **_to**: *string* +• **InsufficientAllowanceForTransfer**: = "INSUFFICIENT_ALLOWANCE_FOR_TRANSFER" -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:46](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L46)* +*Defined in [contract-wrappers/src/types.ts:17](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-wrappers/src/types.ts#L17)* ___ -### _value - -• **_value**: *`BigNumber`* - -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:47](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L47)* +### InsufficientBalanceForTransfer -
+• **InsufficientBalanceForTransfer**: = "INSUFFICIENT_BALANCE_FOR_TRANSFER" -# Interface: ERC721TokenApprovalEventArgs +*Defined in [contract-wrappers/src/types.ts:18](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-wrappers/src/types.ts#L18)* +___ -## Index +### InsufficientEthBalanceForDeposit -### Properties +• **InsufficientEthBalanceForDeposit**: = "INSUFFICIENT_ETH_BALANCE_FOR_DEPOSIT" -* [_approved](#_approved) -* [_owner](#_owner) -* [_tokenId](#_tokenid) +*Defined in [contract-wrappers/src/types.ts:19](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-wrappers/src/types.ts#L19)* -## Properties +___ -### _approved +### InsufficientWEthBalanceForWithdrawal -• **_approved**: *string* +• **InsufficientWEthBalanceForWithdrawal**: = "INSUFFICIENT_WETH_BALANCE_FOR_WITHDRAWAL" -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:50](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L50)* +*Defined in [contract-wrappers/src/types.ts:20](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-wrappers/src/types.ts#L20)* ___ -### _owner +### InvalidJump -• **_owner**: *string* +• **InvalidJump**: = "INVALID_JUMP" -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:49](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L49)* +*Defined in [contract-wrappers/src/types.ts:21](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-wrappers/src/types.ts#L21)* ___ -### _tokenId +### OutOfGas -• **_tokenId**: *`BigNumber`* +• **OutOfGas**: = "OUT_OF_GAS" -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:51](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L51)* +*Defined in [contract-wrappers/src/types.ts:22](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-wrappers/src/types.ts#L22)* -
+___ -# Interface: ERC721TokenApprovalForAllEventArgs +### SignatureRequestDenied +• **SignatureRequestDenied**: = "SIGNATURE_REQUEST_DENIED" -## Index +*Defined in [contract-wrappers/src/types.ts:27](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-wrappers/src/types.ts#L27)* -### Properties +___ -* [_approved](#_approved) -* [_operator](#_operator) -* [_owner](#_owner) +### SubscriptionAlreadyPresent -## Properties +• **SubscriptionAlreadyPresent**: = "SUBSCRIPTION_ALREADY_PRESENT" -### _approved +*Defined in [contract-wrappers/src/types.ts:24](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-wrappers/src/types.ts#L24)* -• **_approved**: *boolean* +___ -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:57](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L57)* +### SubscriptionNotFound -___ +• **SubscriptionNotFound**: = "SUBSCRIPTION_NOT_FOUND" -### _operator +*Defined in [contract-wrappers/src/types.ts:23](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-wrappers/src/types.ts#L23)* -• **_operator**: *string* +
+ +# Enumeration: ForwarderError -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:56](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L56)* -___ +## Enumeration members -### _owner +### CompleteFillFailed -• **_owner**: *string* +• **CompleteFillFailed**: = "COMPLETE_FILL_FAILED" -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:55](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L55)* +*Defined in [contract-wrappers/src/types.ts:12](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-wrappers/src/types.ts#L12)*
-# Interface: ERC721TokenTransferEventArgs -## Index -### Properties -* [_from](#_from) -* [_to](#_to) -* [_tokenId](#_tokenid) +# Enumeration: BlockParamLiteral -## Properties -### _from +## Enumeration members -• **_from**: *string* +### Earliest + +• **Earliest**: = "earliest" -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:61](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L61)* +*Defined in [ethereum-types/src/index.ts:478](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L478)* ___ -### _to +### Latest -• **_to**: *string* +• **Latest**: = "latest" -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:62](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L62)* +*Defined in [ethereum-types/src/index.ts:479](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L479)* ___ -### _tokenId +### Pending -• **_tokenId**: *`BigNumber`* +• **Pending**: = "pending" -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:63](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L63)* +*Defined in [ethereum-types/src/index.ts:480](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L480)*
-# Interface: ExchangeAssetProxyRegisteredEventArgs - - -## Index -### Properties -* [assetProxy](#assetproxy) -* [id](#id) -## Properties -### assetProxy -• **assetProxy**: *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:60](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L60)* -___ -### id -• **id**: *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:59](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L59)* -
-# Interface: ExchangeCancelEventArgs -## Index -### Properties -* [feeRecipientAddress](#feerecipientaddress) -* [makerAddress](#makeraddress) -* [makerAssetData](#makerassetdata) -* [orderHash](#orderhash) -* [senderAddress](#senderaddress) -* [takerAssetData](#takerassetdata) -## Properties -### feeRecipientAddress -• **feeRecipientAddress**: *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:65](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L65)* -___ -### makerAddress -• **makerAddress**: *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:64](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L64)* -___ -### makerAssetData -• **makerAssetData**: *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:66](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L66)* +# Interface: CoordinatorRegistryCoordinatorEndpointSetEventArgs -___ -### orderHash +## Index -• **orderHash**: *string* +### Properties -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:69](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L69)* +* [coordinatorEndpoint](#coordinatorendpoint) +* [coordinatorOperator](#coordinatoroperator) -___ +## Properties -### senderAddress +### coordinatorEndpoint -• **senderAddress**: *string* +• **coordinatorEndpoint**: *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:68](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L68)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts:42](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts#L42)* ___ -### takerAssetData +### coordinatorOperator -• **takerAssetData**: *string* +• **coordinatorOperator**: *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:67](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L67)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts:41](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts#L41)*
-# Interface: ExchangeCancelUpToEventArgs +# Interface: DummyERC20TokenApprovalEventArgs ## Index ### Properties -* [makerAddress](#makeraddress) -* [orderEpoch](#orderepoch) -* [orderSenderAddress](#ordersenderaddress) +* [_owner](#_owner) +* [_spender](#_spender) +* [_value](#_value) ## Properties -### makerAddress +### _owner -• **makerAddress**: *string* +• **_owner**: *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:73](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L73)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:42](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L42)* ___ -### orderEpoch +### _spender -• **orderEpoch**: *`BigNumber`* +• **_spender**: *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:75](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L75)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:43](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L43)* ___ -### orderSenderAddress +### _value -• **orderSenderAddress**: *string* +• **_value**: *`BigNumber`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:74](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L74)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:44](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L44)*
-# Interface: ExchangeFillEventArgs +# Interface: DummyERC20TokenTransferEventArgs ## Index ### Properties -* [feeRecipientAddress](#feerecipientaddress) -* [makerAddress](#makeraddress) -* [makerAssetData](#makerassetdata) -* [makerAssetFilledAmount](#makerassetfilledamount) -* [makerFeeAssetData](#makerfeeassetdata) -* [makerFeePaid](#makerfeepaid) -* [orderHash](#orderhash) -* [protocolFeePaid](#protocolfeepaid) -* [senderAddress](#senderaddress) -* [takerAddress](#takeraddress) -* [takerAssetData](#takerassetdata) -* [takerAssetFilledAmount](#takerassetfilledamount) -* [takerFeeAssetData](#takerfeeassetdata) -* [takerFeePaid](#takerfeepaid) +* [_from](#_from) +* [_to](#_to) +* [_value](#_value) ## Properties -### feeRecipientAddress - -• **feeRecipientAddress**: *string* - -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:80](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L80)* - -___ - -### makerAddress +### _from -• **makerAddress**: *string* +• **_from**: *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:79](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L79)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:48](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L48)* ___ -### makerAssetData +### _to -• **makerAssetData**: *string* +• **_to**: *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:81](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L81)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:49](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L49)* ___ -### makerAssetFilledAmount - -• **makerAssetFilledAmount**: *`BigNumber`* - -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:88](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L88)* +### _value -___ +• **_value**: *`BigNumber`* -### makerFeeAssetData +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:50](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L50)* -• **makerFeeAssetData**: *string* +
-*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:83](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L83)* +# Interface: DummyERC721TokenApprovalEventArgs -___ -### makerFeePaid +## Index -• **makerFeePaid**: *`BigNumber`* +### Properties -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:90](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L90)* +* [_approved](#_approved) +* [_owner](#_owner) +* [_tokenId](#_tokenid) -___ +## Properties -### orderHash +### _approved -• **orderHash**: *string* +• **_approved**: *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:85](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L85)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:47](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L47)* ___ -### protocolFeePaid +### _owner -• **protocolFeePaid**: *`BigNumber`* +• **_owner**: *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:92](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L92)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:46](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L46)* ___ -### senderAddress - -• **senderAddress**: *string* - -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:87](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L87)* +### _tokenId -___ +• **_tokenId**: *`BigNumber`* -### takerAddress +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:48](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L48)* -• **takerAddress**: *string* +
-*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:86](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L86)* +# Interface: DummyERC721TokenApprovalForAllEventArgs -___ -### takerAssetData +## Index -• **takerAssetData**: *string* +### Properties -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:82](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L82)* +* [_approved](#_approved) +* [_operator](#_operator) +* [_owner](#_owner) -___ +## Properties -### takerAssetFilledAmount +### _approved -• **takerAssetFilledAmount**: *`BigNumber`* +• **_approved**: *boolean* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:89](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L89)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:54](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L54)* ___ -### takerFeeAssetData +### _operator -• **takerFeeAssetData**: *string* +• **_operator**: *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:84](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L84)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:53](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L53)* ___ -### takerFeePaid +### _owner -• **takerFeePaid**: *`BigNumber`* +• **_owner**: *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:91](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L91)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:52](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L52)*
-# Interface: ExchangeProtocolFeeCollectorAddressEventArgs +# Interface: DummyERC721TokenTransferEventArgs ## Index ### Properties -* [oldProtocolFeeCollector](#oldprotocolfeecollector) -* [updatedProtocolFeeCollector](#updatedprotocolfeecollector) +* [_from](#_from) +* [_to](#_to) +* [_tokenId](#_tokenid) ## Properties -### oldProtocolFeeCollector +### _from -• **oldProtocolFeeCollector**: *string* +• **_from**: *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:96](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L96)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:58](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L58)* ___ -### updatedProtocolFeeCollector +### _to -• **updatedProtocolFeeCollector**: *string* +• **_to**: *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:59](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L59)* + +___ + +### _tokenId + +• **_tokenId**: *`BigNumber`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:97](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L97)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:60](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L60)*
-# Interface: ExchangeProtocolFeeMultiplierEventArgs +# Interface: ERC1155ProxyAuthorizedAddressAddedEventArgs ## Index ### Properties -* [oldProtocolFeeMultiplier](#oldprotocolfeemultiplier) -* [updatedProtocolFeeMultiplier](#updatedprotocolfeemultiplier) +* [caller](#caller) +* [target](#target) ## Properties -### oldProtocolFeeMultiplier +### caller -• **oldProtocolFeeMultiplier**: *`BigNumber`* +• **caller**: *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:101](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L101)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts:45](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts#L45)* ___ -### updatedProtocolFeeMultiplier +### target -• **updatedProtocolFeeMultiplier**: *`BigNumber`* +• **target**: *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:102](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L102)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts:44](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts#L44)*
-# Interface: ExchangeSignatureValidatorApprovalEventArgs +# Interface: ERC1155ProxyAuthorizedAddressRemovedEventArgs ## Index ### Properties -* [isApproved](#isapproved) -* [signerAddress](#signeraddress) -* [validatorAddress](#validatoraddress) +* [caller](#caller) +* [target](#target) ## Properties -### isApproved - -• **isApproved**: *boolean* - -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:108](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L108)* +### caller -___ - -### signerAddress - -• **signerAddress**: *string* +• **caller**: *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:106](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L106)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts:50](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts#L50)* ___ -### validatorAddress +### target -• **validatorAddress**: *string* +• **target**: *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:107](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L107)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts:49](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts#L49)*
-# Interface: ExchangeTransactionExecutionEventArgs +# Interface: ERC20ProxyAuthorizedAddressAddedEventArgs ## Index ### Properties -* [transactionHash](#transactionhash) +* [caller](#caller) +* [target](#target) ## Properties -### transactionHash +### caller -• **transactionHash**: *string* +• **caller**: *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:112](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L112)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts:45](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts#L45)* -
+___ -# Interface: WETH9ApprovalEventArgs +### target +• **target**: *string* -## Index +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts:44](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts#L44)* -### Properties +
-* [_owner](#_owner) -* [_spender](#_spender) -* [_value](#_value) +# Interface: ERC20ProxyAuthorizedAddressRemovedEventArgs -## Properties -### _owner +## Index -• **_owner**: *string* +### Properties -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:51](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L51)* +* [caller](#caller) +* [target](#target) -___ +## Properties -### _spender +### caller -• **_spender**: *string* +• **caller**: *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:52](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L52)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts:50](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts#L50)* ___ -### _value +### target -• **_value**: *`BigNumber`* +• **target**: *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:53](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L53)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts:49](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts#L49)*
-# Interface: WETH9DepositEventArgs +# Interface: ERC20TokenApprovalEventArgs ## Index @@ -7998,6 +18904,7 @@ ___ ### Properties * [_owner](#_owner) +* [_spender](#_spender) * [_value](#_value) ## Properties @@ -8006,7 +18913,15 @@ ___ • **_owner**: *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:63](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L63)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:48](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L48)* + +___ + +### _spender + +• **_spender**: *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:49](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L49)* ___ @@ -8014,11 +18929,11 @@ ___ • **_value**: *`BigNumber`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:64](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L64)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:50](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L50)*
-# Interface: WETH9TransferEventArgs +# Interface: ERC20TokenTransferEventArgs ## Index @@ -8035,7 +18950,7 @@ ___ • **_from**: *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:57](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L57)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:42](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L42)* ___ @@ -8043,7 +18958,7 @@ ___ • **_to**: *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:58](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L58)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:43](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L43)* ___ @@ -8051,1438 +18966,1500 @@ ___ • **_value**: *`BigNumber`* -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:59](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L59)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:44](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L44)*
-# Interface: WETH9WithdrawalEventArgs +# Interface: ERC721ProxyAuthorizedAddressAddedEventArgs ## Index ### Properties -* [_owner](#_owner) -* [_value](#_value) +* [caller](#caller) +* [target](#target) ## Properties -### _owner +### caller -• **_owner**: *string* +• **caller**: *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:68](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L68)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts:45](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts#L45)* ___ -### _value +### target -• **_value**: *`BigNumber`* +• **target**: *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:69](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L69)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts:44](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts#L44)*
-# Interface: AwaitTransactionSuccessOpts - -Used with `awaitTransactionSuccessAsync` -* pollingIntervalMs: Determine polling intervals in milliseconds -* timeoutMs: Determines timeout in milliseconds - +# Interface: ERC721ProxyAuthorizedAddressRemovedEventArgs -## Properties - -### `Optional` pollingIntervalMs -• **pollingIntervalMs**? : *undefined | number* +## Index -*Defined in [base-contract/src/types.ts:39](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/base-contract/src/types.ts#L39)* +### Properties -___ +* [caller](#caller) +* [target](#target) -### `Optional` shouldValidate +## Properties -• **shouldValidate**? : *undefined | false | true* +### caller -*Inherited from [SendTransactionOpts](#interface-sendtransactionopts).[shouldValidate](#optional-shouldvalidate)* +• **caller**: *string* -*Defined in [base-contract/src/types.ts:30](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/base-contract/src/types.ts#L30)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts:50](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts#L50)* ___ -### `Optional` timeoutMs +### target -• **timeoutMs**? : *undefined | number* +• **target**: *string* -*Defined in [base-contract/src/types.ts:40](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/base-contract/src/types.ts#L40)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts:49](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts#L49)*
+# Interface: ERC721TokenApprovalEventArgs -# Interface: ContractFunctionObj <**T**> +## Index -## Type parameters +### Properties -▪ **T** +* [_approved](#_approved) +* [_owner](#_owner) +* [_tokenId](#_tokenid) +## Properties -## Methods +### _approved -### callAsync +• **_approved**: *string* -▸ **callAsync**(`callData?`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:47](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L47)* -*Defined in [base-contract/src/types.ts:44](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/base-contract/src/types.ts#L44)* +___ -**Parameters:** +### _owner -Name | Type | ------- | ------ | -`callData?` | `Partial` | -`defaultBlock?` | [BlockParam](#blockparam) | +• **_owner**: *string* -**Returns:** *`Promise`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:46](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L46)* ___ -### getABIEncodedTransactionData - -▸ **getABIEncodedTransactionData**(): *string* +### _tokenId -*Defined in [base-contract/src/types.ts:45](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/base-contract/src/types.ts#L45)* +• **_tokenId**: *`BigNumber`* -**Returns:** *string* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:48](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L48)*
-# Interface: ContractTxFunctionObj <**T**> +# Interface: ERC721TokenApprovalForAllEventArgs -## Type parameters -▪ **T** +## Index +### Properties -## Methods +* [_approved](#_approved) +* [_operator](#_operator) +* [_owner](#_owner) -### awaitTransactionSuccessAsync +## Properties -▸ **awaitTransactionSuccessAsync**(`txData?`: `Partial`, `opts?`: [AwaitTransactionSuccessOpts](#class-awaittransactionsuccessopts)): *`PromiseWithTransactionHash`* +### _approved -*Defined in [base-contract/src/types.ts:50](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/base-contract/src/types.ts#L50)* +• **_approved**: *boolean* -**Parameters:** +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:54](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L54)* -Name | Type | ------- | ------ | -`txData?` | `Partial` | -`opts?` | [AwaitTransactionSuccessOpts](#class-awaittransactionsuccessopts) | +___ -**Returns:** *`PromiseWithTransactionHash`* +### _operator + +• **_operator**: *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:53](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L53)* ___ -### callAsync +### _owner -▸ **callAsync**(`callData?`: `Partial`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* +• **_owner**: *string* -*Inherited from [ContractFunctionObj](#interface-contractfunctionobj).[callAsync](#callasync)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:52](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L52)* -*Defined in [base-contract/src/types.ts:44](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/base-contract/src/types.ts#L44)* +
-**Parameters:** +# Interface: ERC721TokenTransferEventArgs -Name | Type | ------- | ------ | -`callData?` | `Partial` | -`defaultBlock?` | [BlockParam](#blockparam) | -**Returns:** *`Promise`* +## Index -___ +### Properties -### estimateGasAsync +* [_from](#_from) +* [_to](#_to) +* [_tokenId](#_tokenid) -▸ **estimateGasAsync**(`txData?`: `Partial`): *`Promise`* +## Properties -*Defined in [base-contract/src/types.ts:54](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/base-contract/src/types.ts#L54)* +### _from -**Parameters:** +• **_from**: *string* -Name | Type | ------- | ------ | -`txData?` | `Partial` | +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:58](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L58)* -**Returns:** *`Promise`* +___ + +### _to + +• **_to**: *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:59](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L59)* ___ -### getABIEncodedTransactionData +### _tokenId -▸ **getABIEncodedTransactionData**(): *string* +• **_tokenId**: *`BigNumber`* -*Inherited from [ContractFunctionObj](#interface-contractfunctionobj).[getABIEncodedTransactionData](#getabiencodedtransactiondata)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:60](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L60)* -*Defined in [base-contract/src/types.ts:45](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/base-contract/src/types.ts#L45)* +
-**Returns:** *string* +# Interface: ExchangeAssetProxyRegisteredEventArgs -___ -### sendTransactionAsync +## Index -▸ **sendTransactionAsync**(`txData?`: `Partial`, `opts?`: [SendTransactionOpts](#class-sendtransactionopts)): *`Promise`* +### Properties -*Defined in [base-contract/src/types.ts:49](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/base-contract/src/types.ts#L49)* +* [assetProxy](#assetproxy) +* [id](#id) -**Parameters:** +## Properties -Name | Type | ------- | ------ | -`txData?` | `Partial` | -`opts?` | [SendTransactionOpts](#class-sendtransactionopts) | +### assetProxy -**Returns:** *`Promise`* +• **assetProxy**: *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:57](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L57)* + +___ + +### id + +• **id**: *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:56](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L56)*
+# Interface: ExchangeCancelEventArgs -# Interface: ContractAddresses +## Index +### Properties -## Properties +* [feeRecipientAddress](#feerecipientaddress) +* [makerAddress](#makeraddress) +* [makerAssetData](#makerassetdata) +* [orderHash](#orderhash) +* [senderAddress](#senderaddress) +* [takerAssetData](#takerassetdata) -### assetProxyOwner +## Properties -• **assetProxyOwner**: *string* +### feeRecipientAddress + +• **feeRecipientAddress**: *string* -*Defined in [contract-addresses/src/index.ts:12](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L12)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:62](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L62)* ___ -### coordinator +### makerAddress -• **coordinator**: *string* +• **makerAddress**: *string* -*Defined in [contract-addresses/src/index.ts:18](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L18)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:61](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L61)* ___ -### coordinatorRegistry +### makerAssetData -• **coordinatorRegistry**: *string* +• **makerAssetData**: *string* -*Defined in [contract-addresses/src/index.ts:17](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L17)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:63](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L63)* ___ -### devUtils +### orderHash -• **devUtils**: *string* +• **orderHash**: *string* -*Defined in [contract-addresses/src/index.ts:22](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L22)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:66](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L66)* ___ -### dutchAuction +### senderAddress -• **dutchAuction**: *string* +• **senderAddress**: *string* -*Defined in [contract-addresses/src/index.ts:16](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L16)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:65](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L65)* ___ -### erc1155Proxy +### takerAssetData -• **erc1155Proxy**: *string* +• **takerAssetData**: *string* -*Defined in [contract-addresses/src/index.ts:21](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L21)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:64](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L64)* -___ +
-### erc20BridgeProxy +# Interface: ExchangeCancelUpToEventArgs -• **erc20BridgeProxy**: *string* -*Defined in [contract-addresses/src/index.ts:26](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L26)* +## Index -___ +### Properties -### erc20Proxy +* [makerAddress](#makeraddress) +* [orderEpoch](#orderepoch) +* [orderSenderAddress](#ordersenderaddress) -• **erc20Proxy**: *string* +## Properties + +### makerAddress -*Defined in [contract-addresses/src/index.ts:6](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L6)* +• **makerAddress**: *string* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:70](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L70)* ___ -### erc721Proxy +### orderEpoch -• **erc721Proxy**: *string* +• **orderEpoch**: *`BigNumber`* -*Defined in [contract-addresses/src/index.ts:7](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L7)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:72](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L72)* ___ -### etherToken +### orderSenderAddress -• **etherToken**: *string* +• **orderSenderAddress**: *string* -*Defined in [contract-addresses/src/index.ts:9](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L9)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:71](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L71)* -___ +
-### exchange +# Interface: ExchangeFillEventArgs -• **exchange**: *string* -*Defined in [contract-addresses/src/index.ts:11](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L11)* +## Index + +### Properties + +* [feeRecipientAddress](#feerecipientaddress) +* [makerAddress](#makeraddress) +* [makerAssetData](#makerassetdata) +* [makerAssetFilledAmount](#makerassetfilledamount) +* [makerFeeAssetData](#makerfeeassetdata) +* [makerFeePaid](#makerfeepaid) +* [orderHash](#orderhash) +* [protocolFeePaid](#protocolfeepaid) +* [senderAddress](#senderaddress) +* [takerAddress](#takeraddress) +* [takerAssetData](#takerassetdata) +* [takerAssetFilledAmount](#takerassetfilledamount) +* [takerFeeAssetData](#takerfeeassetdata) +* [takerFeePaid](#takerfeepaid) -___ +## Properties -### exchangeV2 +### feeRecipientAddress -• **exchangeV2**: *string* +• **feeRecipientAddress**: *string* -*Defined in [contract-addresses/src/index.ts:10](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L10)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:77](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L77)* ___ -### forwarder +### makerAddress -• **forwarder**: *string* +• **makerAddress**: *string* -*Defined in [contract-addresses/src/index.ts:14](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L14)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:76](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L76)* ___ -### multiAssetProxy +### makerAssetData -• **multiAssetProxy**: *string* +• **makerAssetData**: *string* -*Defined in [contract-addresses/src/index.ts:19](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L19)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:78](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L78)* ___ -### orderValidator +### makerAssetFilledAmount -• **orderValidator**: *string* +• **makerAssetFilledAmount**: *`BigNumber`* -*Defined in [contract-addresses/src/index.ts:15](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L15)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:85](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L85)* ___ -### staking +### makerFeeAssetData -• **staking**: *string* +• **makerFeeAssetData**: *string* -*Defined in [contract-addresses/src/index.ts:24](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L24)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:80](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L80)* ___ -### stakingProxy +### makerFeePaid -• **stakingProxy**: *string* +• **makerFeePaid**: *`BigNumber`* -*Defined in [contract-addresses/src/index.ts:25](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L25)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:87](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L87)* ___ -### staticCallProxy +### orderHash -• **staticCallProxy**: *string* +• **orderHash**: *string* -*Defined in [contract-addresses/src/index.ts:20](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L20)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:82](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L82)* ___ -### zeroExGovernor +### protocolFeePaid -• **zeroExGovernor**: *string* +• **protocolFeePaid**: *`BigNumber`* -*Defined in [contract-addresses/src/index.ts:13](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L13)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:89](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L89)* ___ -### zrxToken +### senderAddress -• **zrxToken**: *string* +• **senderAddress**: *string* -*Defined in [contract-addresses/src/index.ts:8](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L8)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:84](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L84)* ___ -### zrxVault - -• **zrxVault**: *string* - -*Defined in [contract-addresses/src/index.ts:23](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L23)* - -
- -# Interface: ContractWrappersConfig +### takerAddress -chainId: The id of the underlying ethereum chain your provider is connected to. (1-mainnet, 3-ropsten, 4-rinkeby, 42-kovan, 1337-testrpc) -gasPrice: Gas price to use with every transaction -contractAddresses: The address of all contracts to use. Defaults to the known addresses based on chainId. -blockPollingIntervalMs: The interval to use for block polling in event watching methods (defaults to 1000) +• **takerAddress**: *string* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:83](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L83)* -## Properties +___ -### `Optional` blockPollingIntervalMs +### takerAssetData -• **blockPollingIntervalMs**? : *undefined | number* +• **takerAssetData**: *string* -*Defined in [contract-wrappers/src/types.ts:40](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-wrappers/src/types.ts#L40)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:79](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L79)* ___ -### chainId +### takerAssetFilledAmount -• **chainId**: *number* +• **takerAssetFilledAmount**: *`BigNumber`* -*Defined in [contract-wrappers/src/types.ts:37](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-wrappers/src/types.ts#L37)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:86](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L86)* ___ -### `Optional` contractAddresses +### takerFeeAssetData -• **contractAddresses**? : *[ContractAddresses](#class-contractaddresses)* +• **takerFeeAssetData**: *string* -*Defined in [contract-wrappers/src/types.ts:39](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-wrappers/src/types.ts#L39)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:81](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L81)* ___ -### `Optional` gasPrice +### takerFeePaid -• **gasPrice**? : *`BigNumber`* +• **takerFeePaid**: *`BigNumber`* -*Defined in [contract-wrappers/src/types.ts:38](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-wrappers/src/types.ts#L38)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:88](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L88)*
+# Interface: ExchangeProtocolFeeCollectorAddressEventArgs +## Index +### Properties +* [oldProtocolFeeCollector](#oldprotocolfeecollector) +* [updatedProtocolFeeCollector](#updatedprotocolfeecollector) +## Properties -# Interface: OrderTransactionOpts - -shouldValidate: Flag indicating whether the library should make attempts to validate a transaction before -broadcasting it. For example, order has a valid signature, maker has sufficient funds, etc. Default=true. +### oldProtocolFeeCollector +• **oldProtocolFeeCollector**: *string* -## Properties +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:93](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L93)* -### `Optional` gasLimit +___ -• **gasLimit**? : *undefined | number* +### updatedProtocolFeeCollector -*Inherited from [TransactionOpts](#interface-transactionopts).[gasLimit](#optional-gaslimit)* +• **updatedProtocolFeeCollector**: *string* -*Defined in [contract-wrappers/src/types.ts:51](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-wrappers/src/types.ts#L51)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:94](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L94)* -___ +
-### `Optional` gasPrice +# Interface: ExchangeProtocolFeeMultiplierEventArgs -• **gasPrice**? : *`BigNumber`* -*Inherited from [TransactionOpts](#interface-transactionopts).[gasPrice](#optional-gasprice)* +## Index -*Defined in [contract-wrappers/src/types.ts:50](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-wrappers/src/types.ts#L50)* +### Properties -___ +* [oldProtocolFeeMultiplier](#oldprotocolfeemultiplier) +* [updatedProtocolFeeMultiplier](#updatedprotocolfeemultiplier) -### `Optional` nonce +## Properties -• **nonce**? : *undefined | number* +### oldProtocolFeeMultiplier -*Inherited from [TransactionOpts](#interface-transactionopts).[nonce](#optional-nonce)* +• **oldProtocolFeeMultiplier**: *`BigNumber`* -*Defined in [contract-wrappers/src/types.ts:52](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-wrappers/src/types.ts#L52)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:98](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L98)* ___ -### `Optional` shouldValidate +### updatedProtocolFeeMultiplier -• **shouldValidate**? : *undefined | false | true* +• **updatedProtocolFeeMultiplier**: *`BigNumber`* -*Defined in [contract-wrappers/src/types.ts:61](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-wrappers/src/types.ts#L61)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:99](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L99)*
+# Interface: ExchangeSignatureValidatorApprovalEventArgs +## Index +### Properties +* [isApproved](#isapproved) +* [signerAddress](#signeraddress) +* [validatorAddress](#validatoraddress) +## Properties +### isApproved +• **isApproved**: *boolean* -# Interface: BlockRange - +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:105](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L105)* -## Properties +___ -### fromBlock +### signerAddress -• **fromBlock**: *[BlockParam](#blockparam)* +• **signerAddress**: *string* -*Defined in [ethereum-types/src/index.ts:742](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L742)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:103](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L103)* ___ -### toBlock +### validatorAddress -• **toBlock**: *[BlockParam](#blockparam)* +• **validatorAddress**: *string* -*Defined in [ethereum-types/src/index.ts:743](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L743)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:104](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L104)*
+# Interface: ExchangeTransactionExecutionEventArgs +## Index +### Properties -# Interface: CallData - +* [transactionHash](#transactionhash) -## Properties +## Properties -### `Optional` data +### transactionHash -• **data**? : *undefined | string* +• **transactionHash**: *string* -*Inherited from [CallTxDataBase](#interface-calltxdatabase).[data](#optional-data)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:109](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L109)* -*Defined in [ethereum-types/src/index.ts:393](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L393)* +
-___ +# Interface: WETH9ApprovalEventArgs -### `Optional` from -• **from**? : *undefined | string* +## Index -*Defined in [ethereum-types/src/index.ts:402](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L402)* +### Properties -___ +* [_owner](#_owner) +* [_spender](#_spender) +* [_value](#_value) -### `Optional` gas +## Properties -• **gas**? : *number | string | `BigNumber`* +### _owner -*Inherited from [CallTxDataBase](#interface-calltxdatabase).[gas](#optional-gas)* +• **_owner**: *string* -*Defined in [ethereum-types/src/index.ts:391](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L391)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:48](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L48)* ___ -### `Optional` gasPrice - -• **gasPrice**? : *number | string | `BigNumber`* +### _spender -*Inherited from [CallTxDataBase](#interface-calltxdatabase).[gasPrice](#optional-gasprice)* +• **_spender**: *string* -*Defined in [ethereum-types/src/index.ts:392](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L392)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:49](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L49)* ___ -### `Optional` nonce - -• **nonce**? : *undefined | number* - -*Inherited from [CallTxDataBase](#interface-calltxdatabase).[nonce](#optional-nonce)* +### _value -*Defined in [ethereum-types/src/index.ts:394](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L394)* +• **_value**: *`BigNumber`* -___ +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:50](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L50)* -### `Optional` to +
-• **to**? : *undefined | string* +# Interface: WETH9DepositEventArgs -*Inherited from [CallTxDataBase](#interface-calltxdatabase).[to](#optional-to)* -*Defined in [ethereum-types/src/index.ts:389](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L389)* +## Index -___ +### Properties -### `Optional` value +* [_owner](#_owner) +* [_value](#_value) -• **value**? : *number | string | `BigNumber`* +## Properties -*Inherited from [CallTxDataBase](#interface-calltxdatabase).[value](#optional-value)* +### _owner -*Defined in [ethereum-types/src/index.ts:390](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L390)* +• **_owner**: *string* -
+*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:60](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L60)* +___ +### _value +• **_value**: *`BigNumber`* +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:61](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L61)* -# Interface: CompilerOpts +
+# Interface: WETH9TransferEventArgs -## Properties -### name +## Index -• **name**: *"solc"* +### Properties -*Defined in [ethereum-types/src/index.ts:655](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L655)* +* [_from](#_from) +* [_to](#_to) +* [_value](#_value) -___ +## Properties -### settings +### _from -• **settings**: *[CompilerSettings](#class-compilersettings)* +• **_from**: *string* -*Defined in [ethereum-types/src/index.ts:657](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L657)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:54](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L54)* ___ -### version - -• **version**: *string* +### _to -*Defined in [ethereum-types/src/index.ts:656](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L656)* +• **_to**: *string* -
+*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:55](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L55)* -# Interface: CompilerSettings +___ +### _value -## Properties +• **_value**: *`BigNumber`* -### `Optional` evmVersion +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:56](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L56)* -• **evmVersion**? : *"homestead" | "tangerineWhistle" | "spuriousDragon" | "byzantium" | "constantinople"* +
-*Defined in [ethereum-types/src/index.ts:689](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L689)* +# Interface: WETH9WithdrawalEventArgs -___ -### `Optional` libraries +## Index -• **libraries**? : *undefined | object* +### Properties -*Defined in [ethereum-types/src/index.ts:691](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L691)* +* [_owner](#_owner) +* [_value](#_value) -___ +## Properties -### `Optional` metadata +### _owner -• **metadata**? : *[CompilerSettingsMetadata](#class-compilersettingsmetadata)* +• **_owner**: *string* -*Defined in [ethereum-types/src/index.ts:690](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L690)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:65](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L65)* ___ -### `Optional` optimizer +### _value -• **optimizer**? : *[OptimizerSettings](#class-optimizersettings)* +• **_value**: *`BigNumber`* -*Defined in [ethereum-types/src/index.ts:688](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L688)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:66](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L66)* -___ +
-### outputSelection +# Interface: ZRXTokenApprovalEventArgs -• **outputSelection**: *object* -*Defined in [ethereum-types/src/index.ts:696](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L696)* +## Index -#### Type declaration: +### Properties -● \[▪ **fileName**: *string*\]: object +* [_owner](#_owner) +* [_spender](#_spender) +* [_value](#_value) -● \[▪ **contractName**: *string*\]: [OutputField](#outputfield)[] +## Properties -___ +### _owner -### `Optional` remappings +• **_owner**: *string* -• **remappings**? : *string[]* +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:48](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L48)* -*Defined in [ethereum-types/src/index.ts:687](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L687)* +___ -
+### _spender -# Interface: CompilerSettingsMetadata +• **_spender**: *string* +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:49](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L49)* -## Properties +___ -### useLiteralContent +### _value -• **useLiteralContent**: *true* +• **_value**: *`BigNumber`* -*Defined in [ethereum-types/src/index.ts:704](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L704)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:50](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L50)*
-# Interface: ConstructorAbi - +# Interface: ZRXTokenTransferEventArgs -## Properties -### inputs +## Index -• **inputs**: *[DataItem](#class-dataitem)[]* +### Properties -*Defined in [ethereum-types/src/index.ts:103](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L103)* +* [_from](#_from) +* [_to](#_to) +* [_value](#_value) -___ +## Properties -### payable +### _from -• **payable**: *boolean* +• **_from**: *string* -*Defined in [ethereum-types/src/index.ts:104](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L104)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:42](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L42)* ___ -### stateMutability +### _to -• **stateMutability**: *[ConstructorStateMutability](#constructorstatemutability)* +• **_to**: *string* -*Defined in [ethereum-types/src/index.ts:105](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L105)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:43](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L43)* ___ -### type +### _value -• **type**: *string* +• **_value**: *`BigNumber`* -*Defined in [ethereum-types/src/index.ts:102](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L102)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:44](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L44)*
-# Interface: ContractArtifact - -This type defines the schema of the artifact.json file generated by Sol-compiler -schemaVersion: The version of the artifact schema -contractName: The contract name it represents -chains: Chain specific information by chain (address, id, constructor args, etc...) -compilerOutput: The Solidity compiler output generated from the specified compiler input -description (http://solidity.readthedocs.io/en/v0.4.24/using-the-compiler.html#compiler-input-and-output-json-description) -compiler: The compiler settings used -sourceCodes: The source code of the contract and all it's dependencies -sources: A mapping from source filePath to sourceMap id -sourceTreeHashHex: A unique hash generated from the contract source and that of it's dependencies. -If any of the sources change, the hash would change notifying us that a re-compilation is necessary +# Interface: ContractAddresses ## Properties -### chains +### assetProxyOwner -• **chains**: *[ContractChains](#class-contractchains)* +• **assetProxyOwner**: *string* -*Defined in [ethereum-types/src/index.ts:676](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L676)* +*Defined in [contract-addresses/src/index.ts:12](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L12)* ___ -### compiler - -• **compiler**: *[CompilerOpts](#class-compileropts)* +### coordinator -*Inherited from [ContractVersionData](#interface-contractversiondata).[compiler](#compiler)* +• **coordinator**: *string* -*Defined in [ethereum-types/src/index.ts:641](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L641)* +*Defined in [contract-addresses/src/index.ts:18](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L18)* ___ -### compilerOutput - -• **compilerOutput**: *[StandardContractOutput](#class-standardcontractoutput)* +### coordinatorRegistry -*Inherited from [ContractVersionData](#interface-contractversiondata).[compilerOutput](#compileroutput)* +• **coordinatorRegistry**: *string* -*Defined in [ethereum-types/src/index.ts:651](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L651)* +*Defined in [contract-addresses/src/index.ts:17](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L17)* ___ -### contractName +### devUtils -• **contractName**: *string* +• **devUtils**: *string* -*Defined in [ethereum-types/src/index.ts:675](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L675)* +*Defined in [contract-addresses/src/index.ts:22](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L22)* ___ -### schemaVersion +### dutchAuction -• **schemaVersion**: *string* +• **dutchAuction**: *string* -*Defined in [ethereum-types/src/index.ts:674](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L674)* +*Defined in [contract-addresses/src/index.ts:16](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L16)* ___ -### sourceCodes +### erc1155Proxy -• **sourceCodes**: *object* +• **erc1155Proxy**: *string* -*Inherited from [ContractVersionData](#interface-contractversiondata).[sourceCodes](#sourcecodes)* +*Defined in [contract-addresses/src/index.ts:21](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L21)* -*Defined in [ethereum-types/src/index.ts:647](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L647)* +___ -#### Type declaration: +### erc20BridgeProxy -● \[▪ **sourceName**: *string*\]: string +• **erc20BridgeProxy**: *string* -___ +*Defined in [contract-addresses/src/index.ts:26](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L26)* -### sourceTreeHashHex +___ -• **sourceTreeHashHex**: *string* +### erc20Proxy -*Inherited from [ContractVersionData](#interface-contractversiondata).[sourceTreeHashHex](#sourcetreehashhex)* +• **erc20Proxy**: *string* -*Defined in [ethereum-types/src/index.ts:650](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L650)* +*Defined in [contract-addresses/src/index.ts:6](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L6)* ___ -### sources - -• **sources**: *object* - -*Inherited from [ContractVersionData](#interface-contractversiondata).[sources](#sources)* +### erc721Proxy -*Defined in [ethereum-types/src/index.ts:642](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L642)* +• **erc721Proxy**: *string* -#### Type declaration: +*Defined in [contract-addresses/src/index.ts:7](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L7)* -● \[▪ **sourceName**: *string*\]: object +___ -
+### etherToken -# Interface: ContractChainData +• **etherToken**: *string* +*Defined in [contract-addresses/src/index.ts:9](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L9)* -## Properties +___ -### address +### exchange -• **address**: *string* +• **exchange**: *string* -*Defined in [ethereum-types/src/index.ts:554](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L554)* +*Defined in [contract-addresses/src/index.ts:11](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L11)* ___ -Args +### exchangeV2 -• **constructorArgs**: *string* +• **exchangeV2**: *string* -*Defined in [ethereum-types/src/index.ts:558](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L558)* +*Defined in [contract-addresses/src/index.ts:10](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L10)* ___ -### links - -• **links**: *object* +### forwarder -*Defined in [ethereum-types/src/index.ts:555](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L555)* +• **forwarder**: *string* -#### Type declaration: +*Defined in [contract-addresses/src/index.ts:14](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L14)* -● \[▪ **linkName**: *string*\]: string +___ -
+### multiAssetProxy -# Interface: ContractChains +• **multiAssetProxy**: *string* +*Defined in [contract-addresses/src/index.ts:19](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L19)* -## Hierarchy +___ -* **ContractVersionData** +### orderValidator - * [ContractArtifact](#class-contractartifact) +• **orderValidator**: *string* +*Defined in [contract-addresses/src/index.ts:15](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L15)* -## Properties +___ -### compiler +### staking -• **compiler**: *[CompilerOpts](#class-compileropts)* +• **staking**: *string* -*Defined in [ethereum-types/src/index.ts:641](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L641)* +*Defined in [contract-addresses/src/index.ts:24](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L24)* ___ -### compilerOutput +### stakingProxy -• **compilerOutput**: *[StandardContractOutput](#class-standardcontractoutput)* +• **stakingProxy**: *string* -*Defined in [ethereum-types/src/index.ts:651](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L651)* +*Defined in [contract-addresses/src/index.ts:25](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L25)* ___ -### sourceCodes - -• **sourceCodes**: *object* - -*Defined in [ethereum-types/src/index.ts:647](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L647)* +### staticCallProxy -#### Type declaration: +• **staticCallProxy**: *string* -● \[▪ **sourceName**: *string*\]: string +*Defined in [contract-addresses/src/index.ts:20](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L20)* ___ -### sourceTreeHashHex +### zeroExGovernor -• **sourceTreeHashHex**: *string* +• **zeroExGovernor**: *string* -*Defined in [ethereum-types/src/index.ts:650](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L650)* +*Defined in [contract-addresses/src/index.ts:13](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L13)* ___ -### sources +### zrxToken -• **sources**: *object* +• **zrxToken**: *string* -*Defined in [ethereum-types/src/index.ts:642](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L642)* +*Defined in [contract-addresses/src/index.ts:8](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L8)* -#### Type declaration: +___ -● \[▪ **sourceName**: *string*\]: object +### zrxVault + +• **zrxVault**: *string* + +*Defined in [contract-addresses/src/index.ts:23](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L23)*
-# Interface: DataItem +# Interface: ContractWrappersConfig + +chainId: The id of the underlying ethereum chain your provider is connected to. (1-mainnet, 3-ropsten, 4-rinkeby, 42-kovan, 1337-testrpc) +gasPrice: Gas price to use with every transaction +contractAddresses: The address of all contracts to use. Defaults to the known addresses based on chainId. +blockPollingIntervalMs: The interval to use for block polling in event watching methods (defaults to 1000) ## Properties -### `Optional` components +### `Optional` blockPollingIntervalMs -• **components**? : *[DataItem](#class-dataitem)[]* +• **blockPollingIntervalMs**? : *undefined | number* -*Defined in [ethereum-types/src/index.ts:137](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L137)* +*Defined in [contract-wrappers/src/types.ts:40](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-wrappers/src/types.ts#L40)* ___ -### name +### chainId -• **name**: *string* +• **chainId**: *number* -*Defined in [ethereum-types/src/index.ts:135](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L135)* +*Defined in [contract-wrappers/src/types.ts:37](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-wrappers/src/types.ts#L37)* ___ -### type +### `Optional` contractAddresses -• **type**: *string* +• **contractAddresses**? : *[ContractAddresses](#class-contractaddresses)* + +*Defined in [contract-wrappers/src/types.ts:39](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-wrappers/src/types.ts#L39)* -*Defined in [ethereum-types/src/index.ts:136](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L136)* +___ + +### `Optional` gasPrice + +• **gasPrice**? : *`BigNumber`* + +*Defined in [contract-wrappers/src/types.ts:38](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-wrappers/src/types.ts#L38)*
-# Interface: DecodedLogArgs -## Type parameters -▪ **A** + + + +# Interface: OrderTransactionOpts + +shouldValidate: Flag indicating whether the library should make attempts to validate a transaction before +broadcasting it. For example, order has a valid signature, maker has sufficient funds, etc. Default=true. ## Properties -### address +### `Optional` gasLimit -• **address**: *string* +• **gasLimit**? : *undefined | number* -*Inherited from [LogEntry](#interface-logentry).[address](#address)* +*Inherited from [TransactionOpts](#interface-transactionopts).[gasLimit](#optional-gaslimit)* -*Defined in [ethereum-types/src/index.ts:434](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L434)* +*Defined in [contract-wrappers/src/types.ts:51](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-wrappers/src/types.ts#L51)* ___ -### args +### `Optional` gasPrice -• **args**: *`A`* +• **gasPrice**? : *`BigNumber`* + +*Inherited from [TransactionOpts](#interface-transactionopts).[gasPrice](#optional-gasprice)* -*Defined in [ethereum-types/src/index.ts:417](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L417)* +*Defined in [contract-wrappers/src/types.ts:50](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-wrappers/src/types.ts#L50)* ___ -### blockHash +### `Optional` nonce -• **blockHash**: *string | null* +• **nonce**? : *undefined | number* -*Inherited from [LogEntry](#interface-logentry).[blockHash](#blockhash)* +*Inherited from [TransactionOpts](#interface-transactionopts).[nonce](#optional-nonce)* -*Defined in [ethereum-types/src/index.ts:432](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L432)* +*Defined in [contract-wrappers/src/types.ts:52](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-wrappers/src/types.ts#L52)* ___ -### blockNumber +### `Optional` shouldValidate -• **blockNumber**: *number | null* +• **shouldValidate**? : *undefined | false | true* -*Inherited from [LogEntry](#interface-logentry).[blockNumber](#blocknumber)* +*Defined in [contract-wrappers/src/types.ts:61](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-wrappers/src/types.ts#L61)* -*Defined in [ethereum-types/src/index.ts:433](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L433)* +
-___ -### data -• **data**: *string* -*Inherited from [LogEntry](#interface-logentry).[data](#data)* -*Defined in [ethereum-types/src/index.ts:435](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L435)* -___ -### event -• **event**: *string* -*Defined in [ethereum-types/src/index.ts:416](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L416)* +# Interface: BlockRange -___ -### logIndex +## Properties -• **logIndex**: *number | null* +### fromBlock -*Inherited from [LogEntry](#interface-logentry).[logIndex](#logindex)* +• **fromBlock**: *[BlockParam](#blockparam)* -*Defined in [ethereum-types/src/index.ts:429](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L429)* +*Defined in [ethereum-types/src/index.ts:740](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L740)* ___ -### topics +### toBlock -• **topics**: *string[]* +• **toBlock**: *[BlockParam](#blockparam)* -*Inherited from [LogEntry](#interface-logentry).[topics](#topics)* +*Defined in [ethereum-types/src/index.ts:741](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L741)* -*Defined in [ethereum-types/src/index.ts:436](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L436)* +
-___ -### transactionHash -• **transactionHash**: *string* -*Inherited from [LogEntry](#interface-logentry).[transactionHash](#transactionhash)* -*Defined in [ethereum-types/src/index.ts:431](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L431)* +# Interface: CallData -___ -### transactionIndex +## Properties -• **transactionIndex**: *number | null* +### `Optional` data -*Inherited from [LogEntry](#interface-logentry).[transactionIndex](#transactionindex)* +• **data**? : *undefined | string* -*Defined in [ethereum-types/src/index.ts:430](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L430)* +*Inherited from [CallTxDataBase](#interface-calltxdatabase).[data](#optional-data)* -
+*Defined in [ethereum-types/src/index.ts:393](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L393)* -# Interface: DecodedLogEntryEvent <**A**> +___ -## Type parameters +### `Optional` from -▪ **A** +• **from**? : *undefined | string* +*Defined in [ethereum-types/src/index.ts:402](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L402)* -## Properties +___ -### address +### `Optional` gas -• **address**: *string* +• **gas**? : *number | string | `BigNumber`* -*Inherited from [LogEntry](#interface-logentry).[address](#address)* +*Inherited from [CallTxDataBase](#interface-calltxdatabase).[gas](#optional-gas)* -*Defined in [ethereum-types/src/index.ts:434](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L434)* +*Defined in [ethereum-types/src/index.ts:391](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L391)* ___ -### args +### `Optional` gasPrice -• **args**: *`A`* +• **gasPrice**? : *number | string | `BigNumber`* -*Inherited from [DecodedLogEntry](#interface-decodedlogentry).[args](#args)* +*Inherited from [CallTxDataBase](#interface-calltxdatabase).[gasPrice](#optional-gasprice)* -*Defined in [ethereum-types/src/index.ts:417](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L417)* +*Defined in [ethereum-types/src/index.ts:392](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L392)* ___ -### blockHash +### `Optional` nonce -• **blockHash**: *string | null* +• **nonce**? : *undefined | number* -*Inherited from [LogEntry](#interface-logentry).[blockHash](#blockhash)* +*Inherited from [CallTxDataBase](#interface-calltxdatabase).[nonce](#optional-nonce)* -*Defined in [ethereum-types/src/index.ts:432](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L432)* +*Defined in [ethereum-types/src/index.ts:394](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L394)* ___ -### blockNumber +### `Optional` to -• **blockNumber**: *number | null* +• **to**? : *undefined | string* -*Inherited from [LogEntry](#interface-logentry).[blockNumber](#blocknumber)* +*Inherited from [CallTxDataBase](#interface-calltxdatabase).[to](#optional-to)* -*Defined in [ethereum-types/src/index.ts:433](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L433)* +*Defined in [ethereum-types/src/index.ts:389](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L389)* ___ -### data +### `Optional` value -• **data**: *string* +• **value**? : *number | string | `BigNumber`* -*Inherited from [LogEntry](#interface-logentry).[data](#data)* +*Inherited from [CallTxDataBase](#interface-calltxdatabase).[value](#optional-value)* -*Defined in [ethereum-types/src/index.ts:435](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L435)* +*Defined in [ethereum-types/src/index.ts:390](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L390)* -___ +
-### event -• **event**: *string* -*Inherited from [DecodedLogEntry](#interface-decodedlogentry).[event](#event)* -*Defined in [ethereum-types/src/index.ts:416](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L416)* -___ +# Interface: CompilerOpts -### logIndex -• **logIndex**: *number | null* +## Properties -*Inherited from [LogEntry](#interface-logentry).[logIndex](#logindex)* +### name + +• **name**: *"solc"* -*Defined in [ethereum-types/src/index.ts:429](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L429)* +*Defined in [ethereum-types/src/index.ts:655](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L655)* ___ -### removed +### settings -• **removed**: *boolean* +• **settings**: *[CompilerSettings](#class-compilersettings)* -*Defined in [ethereum-types/src/index.ts:421](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L421)* +*Defined in [ethereum-types/src/index.ts:657](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L657)* ___ -### topics +### version -• **topics**: *string[]* +• **version**: *string* -*Inherited from [LogEntry](#interface-logentry).[topics](#topics)* +*Defined in [ethereum-types/src/index.ts:656](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L656)* -*Defined in [ethereum-types/src/index.ts:436](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L436)* +
-___ +# Interface: CompilerSettings -### transactionHash -• **transactionHash**: *string* +## Properties -*Inherited from [LogEntry](#interface-logentry).[transactionHash](#transactionhash)* +### `Optional` evmVersion -*Defined in [ethereum-types/src/index.ts:431](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L431)* +• **evmVersion**? : *"homestead" | "tangerineWhistle" | "spuriousDragon" | "byzantium" | "constantinople"* + +*Defined in [ethereum-types/src/index.ts:689](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L689)* ___ -### transactionIndex +### `Optional` libraries -• **transactionIndex**: *number | null* +• **libraries**? : *undefined | object* -*Inherited from [LogEntry](#interface-logentry).[transactionIndex](#transactionindex)* +*Defined in [ethereum-types/src/index.ts:691](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L691)* -*Defined in [ethereum-types/src/index.ts:430](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L430)* +___ -
+### `Optional` metadata -# Interface: DevdocOutput +• **metadata**? : *[CompilerSettingsMetadata](#class-compilersettingsmetadata)* +*Defined in [ethereum-types/src/index.ts:690](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L690)* -## Properties +___ -### `Optional` author +### `Optional` optimizer -• **author**? : *undefined | string* +• **optimizer**? : *[OptimizerSettings](#class-optimizersettings)* -*Defined in [ethereum-types/src/index.ts:628](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L628)* +*Defined in [ethereum-types/src/index.ts:688](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L688)* ___ -### methods +### outputSelection -• **methods**: *object* +• **outputSelection**: *object* -*Defined in [ethereum-types/src/index.ts:629](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L629)* +*Defined in [ethereum-types/src/index.ts:696](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L696)* #### Type declaration: -● \[▪ **signature**: *string*\]: object +● \[▪ **fileName**: *string*\]: object + +● \[▪ **contractName**: *string*\]: [OutputField](#outputfield)[] ___ -### `Optional` title +### `Optional` remappings -• **title**? : *undefined | string* +• **remappings**? : *string[]* -*Defined in [ethereum-types/src/index.ts:627](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L627)* +*Defined in [ethereum-types/src/index.ts:687](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L687)*
-# Interface: EIP1193Provider +# Interface: CompilerSettingsMetadata ## Properties -### isEIP1193 +### useLiteralContent -• **isEIP1193**: *boolean* +• **useLiteralContent**: *true* -*Defined in [ethereum-types/src/index.ts:73](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L73)* +*Defined in [ethereum-types/src/index.ts:704](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L704)* -## Methods +
-### on +# Interface: ConstructorAbi -▸ **on**(`event`: [EIP1193Event](#eip1193event), `listener`: function): *this* -*Defined in [ethereum-types/src/index.ts:75](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L75)* +## Properties -**Parameters:** +### inputs -▪ **event**: *[EIP1193Event](#eip1193event)* +• **inputs**: *[DataItem](#class-dataitem)[]* -▪ **listener**: *function* +*Defined in [ethereum-types/src/index.ts:103](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L103)* -▸ (`result`: any): *void* +___ -**Parameters:** +### payable -Name | Type | ------- | ------ | -`result` | any | +• **payable**: *boolean* -**Returns:** *this* +*Defined in [ethereum-types/src/index.ts:104](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L104)* ___ -### send +### stateMutability -▸ **send**(`method`: string, `params?`: any[]): *`Promise`* +• **stateMutability**: *[ConstructorStateMutability](#constructorstatemutability)* -*Defined in [ethereum-types/src/index.ts:74](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L74)* +*Defined in [ethereum-types/src/index.ts:105](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L105)* -**Parameters:** +___ -Name | Type | ------- | ------ | -`method` | string | -`params?` | any[] | +### type -**Returns:** *`Promise`* +• **type**: *string* + +*Defined in [ethereum-types/src/index.ts:102](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L102)*
+# Interface: ContractArtifact + +This type defines the schema of the artifact.json file generated by Sol-compiler +schemaVersion: The version of the artifact schema +contractName: The contract name it represents +chains: Chain specific information by chain (address, id, constructor args, etc...) +compilerOutput: The Solidity compiler output generated from the specified compiler input +description (http://solidity.readthedocs.io/en/v0.4.24/using-the-compiler.html#compiler-input-and-output-json-description) +compiler: The compiler settings used +sourceCodes: The source code of the contract and all it's dependencies +sources: A mapping from source filePath to sourceMap id +sourceTreeHashHex: A unique hash generated from the contract source and that of it's dependencies. +If any of the sources change, the hash would change notifying us that a re-compilation is necessary + +## Properties +### chains +• **chains**: *[ContractChains](#class-contractchains)* -# Interface: EvmBytecodeOutput +*Defined in [ethereum-types/src/index.ts:676](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L676)* +___ -## Properties +### compiler -### object +• **compiler**: *[CompilerOpts](#class-compileropts)* -• **object**: *string* +*Inherited from [ContractVersionData](#interface-contractversiondata).[compiler](#compiler)* -*Defined in [ethereum-types/src/index.ts:622](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L622)* +*Defined in [ethereum-types/src/index.ts:641](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L641)* ___ -### sourceMap +### compilerOutput -• **sourceMap**: *string* +• **compilerOutput**: *[StandardContractOutput](#class-standardcontractoutput)* + +*Inherited from [ContractVersionData](#interface-contractversiondata).[compilerOutput](#compileroutput)* -*Defined in [ethereum-types/src/index.ts:623](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L623)* +*Defined in [ethereum-types/src/index.ts:651](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L651)* -
+___ -# Interface: EvmOutput +### contractName +• **contractName**: *string* -## Properties +*Defined in [ethereum-types/src/index.ts:675](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L675)* -### bytecode +___ -• **bytecode**: *[EvmBytecodeOutput](#class-evmbytecodeoutput)* +### schemaVersion + +• **schemaVersion**: *string* -*Defined in [ethereum-types/src/index.ts:617](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L617)* +*Defined in [ethereum-types/src/index.ts:674](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L674)* ___ -### deployedBytecode +### sourceCodes -• **deployedBytecode**: *[EvmBytecodeOutput](#class-evmbytecodeoutput)* +• **sourceCodes**: *object* -*Defined in [ethereum-types/src/index.ts:618](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L618)* +*Inherited from [ContractVersionData](#interface-contractversiondata).[sourceCodes](#sourcecodes)* -
+*Defined in [ethereum-types/src/index.ts:647](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L647)* -# Interface: FallbackAbi +#### Type declaration: +● \[▪ **sourceName**: *string*\]: string -## Properties +___ -### payable +### sourceTreeHashHex -• **payable**: *boolean* +• **sourceTreeHashHex**: *string* -*Defined in [ethereum-types/src/index.ts:112](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L112)* +*Inherited from [ContractVersionData](#interface-contractversiondata).[sourceTreeHashHex](#sourcetreehashhex)* + +*Defined in [ethereum-types/src/index.ts:650](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L650)* ___ -### type +### sources -• **type**: *string* +• **sources**: *object* + +*Inherited from [ContractVersionData](#interface-contractversiondata).[sources](#sources)* -*Defined in [ethereum-types/src/index.ts:111](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L111)* +*Defined in [ethereum-types/src/index.ts:642](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L642)* + +#### Type declaration: + +● \[▪ **sourceName**: *string*\]: object
+# Interface: ContractChainData -# Interface: GanacheProvider +## Properties + +### address +• **address**: *string* -## Methods +*Defined in [ethereum-types/src/index.ts:554](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L554)* -### sendAsync +___ -▸ **sendAsync**(`payload`: [JSONRPCRequestPayload](_ethereum_types_src_index_.jsonrpcrequestpayload.md), `callback`: [JSONRPCErrorCallback](#jsonrpcerrorcallback)): *void* +Args -*Defined in [ethereum-types/src/index.ts:14](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L14)* +• **constructorArgs**: *string* -**Parameters:** +*Defined in [ethereum-types/src/index.ts:558](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L558)* -Name | Type | ------- | ------ | -`payload` | [JSONRPCRequestPayload](#class-jsonrpcrequestpayload) | -`callback` | [JSONRPCErrorCallback](#jsonrpcerrorcallback) | +___ -**Returns:** *void* +### links -
+• **links**: *object* +*Defined in [ethereum-types/src/index.ts:555](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L555)* +#### Type declaration: -# Interface: JSONRPCRequestPayload +● \[▪ **linkName**: *string*\]: string +
-## Properties +# Interface: ContractChains -### id -• **id**: *number* +## Hierarchy + +* **ContractVersionData** + + * [ContractArtifact](#class-contractartifact) -*Defined in [ethereum-types/src/index.ts:330](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L330)* -___ +## Properties -### jsonrpc +### compiler -• **jsonrpc**: *string* +• **compiler**: *[CompilerOpts](#class-compileropts)* -*Defined in [ethereum-types/src/index.ts:331](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L331)* +*Defined in [ethereum-types/src/index.ts:641](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L641)* ___ -### method +### compilerOutput -• **method**: *string* +• **compilerOutput**: *[StandardContractOutput](#class-standardcontractoutput)* -*Defined in [ethereum-types/src/index.ts:329](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L329)* +*Defined in [ethereum-types/src/index.ts:651](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L651)* ___ -### params - -• **params**: *any[]* +### sourceCodes -*Defined in [ethereum-types/src/index.ts:328](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L328)* +• **sourceCodes**: *object* -
+*Defined in [ethereum-types/src/index.ts:647](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L647)* -# Interface: JSONRPCResponseError +#### Type declaration: +● \[▪ **sourceName**: *string*\]: string -## Properties +___ -### code +### sourceTreeHashHex -• **code**: *number* +• **sourceTreeHashHex**: *string* -*Defined in [ethereum-types/src/index.ts:336](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L336)* +*Defined in [ethereum-types/src/index.ts:650](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L650)* ___ -### message +### sources -• **message**: *string* +• **sources**: *object* -*Defined in [ethereum-types/src/index.ts:335](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L335)* +*Defined in [ethereum-types/src/index.ts:642](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L642)* + +#### Type declaration: + +● \[▪ **sourceName**: *string*\]: object
-# Interface: JSONRPCResponsePayload +# Interface: DataItem ## Properties -### `Optional` error +### `Optional` components -• **error**? : *[JSONRPCResponseError](#class-jsonrpcresponseerror)* +• **components**? : *[DataItem](#class-dataitem)[]* -*Defined in [ethereum-types/src/index.ts:343](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L343)* +*Defined in [ethereum-types/src/index.ts:137](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L137)* ___ -### id +### name -• **id**: *number* +• **name**: *string* -*Defined in [ethereum-types/src/index.ts:341](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L341)* +*Defined in [ethereum-types/src/index.ts:135](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L135)* ___ -### jsonrpc - -• **jsonrpc**: *string* +### type -*Defined in [ethereum-types/src/index.ts:342](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L342)* +• **type**: *string* -___ +*Defined in [ethereum-types/src/index.ts:136](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L136)* -### result +
-• **result**: *any* +# Interface: DecodedLogArgs -*Defined in [ethereum-types/src/index.ts:340](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L340)* -
+## Type parameters -# Interface: LogEntry +▪ **A** ## Properties @@ -9491,7 +20468,17 @@ ___ • **address**: *string* -*Defined in [ethereum-types/src/index.ts:434](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L434)* +*Inherited from [LogEntry](#interface-logentry).[address](#address)* + +*Defined in [ethereum-types/src/index.ts:434](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L434)* + +___ + +### args + +• **args**: *`A`* + +*Defined in [ethereum-types/src/index.ts:417](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L417)* ___ @@ -9499,7 +20486,9 @@ ___ • **blockHash**: *string | null* -*Defined in [ethereum-types/src/index.ts:432](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L432)* +*Inherited from [LogEntry](#interface-logentry).[blockHash](#blockhash)* + +*Defined in [ethereum-types/src/index.ts:432](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L432)* ___ @@ -9507,7 +20496,9 @@ ___ • **blockNumber**: *number | null* -*Defined in [ethereum-types/src/index.ts:433](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L433)* +*Inherited from [LogEntry](#interface-logentry).[blockNumber](#blocknumber)* + +*Defined in [ethereum-types/src/index.ts:433](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L433)* ___ @@ -9515,7 +20506,17 @@ ___ • **data**: *string* -*Defined in [ethereum-types/src/index.ts:435](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L435)* +*Inherited from [LogEntry](#interface-logentry).[data](#data)* + +*Defined in [ethereum-types/src/index.ts:435](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L435)* + +___ + +### event + +• **event**: *string* + +*Defined in [ethereum-types/src/index.ts:416](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L416)* ___ @@ -9523,7 +20524,9 @@ ___ • **logIndex**: *number | null* -*Defined in [ethereum-types/src/index.ts:429](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L429)* +*Inherited from [LogEntry](#interface-logentry).[logIndex](#logindex)* + +*Defined in [ethereum-types/src/index.ts:429](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L429)* ___ @@ -9531,7 +20534,9 @@ ___ • **topics**: *string[]* -*Defined in [ethereum-types/src/index.ts:436](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L436)* +*Inherited from [LogEntry](#interface-logentry).[topics](#topics)* + +*Defined in [ethereum-types/src/index.ts:436](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L436)* ___ @@ -9539,7 +20544,9 @@ ___ • **transactionHash**: *string* -*Defined in [ethereum-types/src/index.ts:431](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L431)* +*Inherited from [LogEntry](#interface-logentry).[transactionHash](#transactionhash)* + +*Defined in [ethereum-types/src/index.ts:431](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L431)* ___ @@ -9547,11 +20554,17 @@ ___ • **transactionIndex**: *number | null* -*Defined in [ethereum-types/src/index.ts:430](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L430)* +*Inherited from [LogEntry](#interface-logentry).[transactionIndex](#transactionindex)* + +*Defined in [ethereum-types/src/index.ts:430](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L430)*
-# Interface: LogEntryEvent +# Interface: DecodedLogEntryEvent <**A**> + +## Type parameters + +▪ **A** ## Properties @@ -9562,7 +20575,17 @@ ___ *Inherited from [LogEntry](#interface-logentry).[address](#address)* -*Defined in [ethereum-types/src/index.ts:434](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L434)* +*Defined in [ethereum-types/src/index.ts:434](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L434)* + +___ + +### args + +• **args**: *`A`* + +*Inherited from [DecodedLogEntry](#interface-decodedlogentry).[args](#args)* + +*Defined in [ethereum-types/src/index.ts:417](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L417)* ___ @@ -9572,7 +20595,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[blockHash](#blockhash)* -*Defined in [ethereum-types/src/index.ts:432](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L432)* +*Defined in [ethereum-types/src/index.ts:432](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L432)* ___ @@ -9582,7 +20605,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[blockNumber](#blocknumber)* -*Defined in [ethereum-types/src/index.ts:433](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L433)* +*Defined in [ethereum-types/src/index.ts:433](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L433)* ___ @@ -9592,7 +20615,17 @@ ___ *Inherited from [LogEntry](#interface-logentry).[data](#data)* -*Defined in [ethereum-types/src/index.ts:435](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L435)* +*Defined in [ethereum-types/src/index.ts:435](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L435)* + +___ + +### event + +• **event**: *string* + +*Inherited from [DecodedLogEntry](#interface-decodedlogentry).[event](#event)* + +*Defined in [ethereum-types/src/index.ts:416](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L416)* ___ @@ -9602,7 +20635,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[logIndex](#logindex)* -*Defined in [ethereum-types/src/index.ts:429](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L429)* +*Defined in [ethereum-types/src/index.ts:429](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L429)* ___ @@ -9610,7 +20643,7 @@ ___ • **removed**: *boolean* -*Defined in [ethereum-types/src/index.ts:425](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L425)* +*Defined in [ethereum-types/src/index.ts:421](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L421)* ___ @@ -9620,7 +20653,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[topics](#topics)* -*Defined in [ethereum-types/src/index.ts:436](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L436)* +*Defined in [ethereum-types/src/index.ts:436](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L436)* ___ @@ -9630,7 +20663,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[transactionHash](#transactionhash)* -*Defined in [ethereum-types/src/index.ts:431](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L431)* +*Defined in [ethereum-types/src/index.ts:431](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L431)* ___ @@ -9640,598 +20673,668 @@ ___ *Inherited from [LogEntry](#interface-logentry).[transactionIndex](#transactionindex)* -*Defined in [ethereum-types/src/index.ts:430](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L430)* +*Defined in [ethereum-types/src/index.ts:430](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L430)*
-# Interface: LogWithDecodedArgs <**ArgsType**> +# Interface: DevdocOutput -## Type parameters -▪ **ArgsType**: *[DecodedLogArgs](#class-decodedlogargs)* +## Properties +### `Optional` author -## Properties +• **author**? : *undefined | string* -### address +*Defined in [ethereum-types/src/index.ts:628](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L628)* -• **address**: *string* +___ -*Inherited from [LogEntry](#interface-logentry).[address](#address)* +### methods + +• **methods**: *object* + +*Defined in [ethereum-types/src/index.ts:629](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L629)* + +#### Type declaration: -*Defined in [ethereum-types/src/index.ts:434](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L434)* +● \[▪ **signature**: *string*\]: object ___ -### args +### `Optional` title -• **args**: *`ArgsType`* +• **title**? : *undefined | string* -*Inherited from [DecodedLogEntry](#interface-decodedlogentry).[args](#args)* +*Defined in [ethereum-types/src/index.ts:627](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L627)* + +
+ +# Interface: EIP1193Provider + + +## Properties + +### isEIP1193 + +• **isEIP1193**: *boolean* + +*Defined in [ethereum-types/src/index.ts:73](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L73)* + +## Methods + +### on + +▸ **on**(`event`: [EIP1193Event](#eip1193event), `listener`: function): *this* + +*Defined in [ethereum-types/src/index.ts:75](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L75)* + +**Parameters:** + +▪ **event**: *[EIP1193Event](#eip1193event)* + +▪ **listener**: *function* + +▸ (`result`: any): *void* + +**Parameters:** + +Name | Type | +------ | ------ | +`result` | any | -*Defined in [ethereum-types/src/index.ts:417](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L417)* +**Returns:** *this* ___ -### blockHash +### send -• **blockHash**: *string | null* +▸ **send**(`method`: string, `params?`: any[]): *`Promise`* -*Inherited from [LogEntry](#interface-logentry).[blockHash](#blockhash)* +*Defined in [ethereum-types/src/index.ts:74](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L74)* + +**Parameters:** + +Name | Type | +------ | ------ | +`method` | string | +`params?` | any[] | + +**Returns:** *`Promise`* + +
+ + + + + +# Interface: EvmBytecodeOutput + + +## Properties + +### object + +• **object**: *string* -*Defined in [ethereum-types/src/index.ts:432](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L432)* +*Defined in [ethereum-types/src/index.ts:622](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L622)* ___ -### blockNumber +### sourceMap -• **blockNumber**: *number | null* +• **sourceMap**: *string* -*Inherited from [LogEntry](#interface-logentry).[blockNumber](#blocknumber)* +*Defined in [ethereum-types/src/index.ts:623](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L623)* + +
+ +# Interface: EvmOutput + + +## Properties + +### bytecode + +• **bytecode**: *[EvmBytecodeOutput](#class-evmbytecodeoutput)* -*Defined in [ethereum-types/src/index.ts:433](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L433)* +*Defined in [ethereum-types/src/index.ts:617](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L617)* ___ -### data +### deployedBytecode -• **data**: *string* +• **deployedBytecode**: *[EvmBytecodeOutput](#class-evmbytecodeoutput)* -*Inherited from [LogEntry](#interface-logentry).[data](#data)* +*Defined in [ethereum-types/src/index.ts:618](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L618)* + +
+ +# Interface: FallbackAbi + + +## Properties + +### payable + +• **payable**: *boolean* -*Defined in [ethereum-types/src/index.ts:435](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L435)* +*Defined in [ethereum-types/src/index.ts:112](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L112)* ___ -### event +### type + +• **type**: *string* + +*Defined in [ethereum-types/src/index.ts:111](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L111)* + +
+ + + +# Interface: GanacheProvider + + +## Methods + +### sendAsync + +▸ **sendAsync**(`payload`: [JSONRPCRequestPayload](_ethereum_types_src_index_.jsonrpcrequestpayload.md), `callback`: [JSONRPCErrorCallback](#jsonrpcerrorcallback)): *void* + +*Defined in [ethereum-types/src/index.ts:14](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L14)* + +**Parameters:** + +Name | Type | +------ | ------ | +`payload` | [JSONRPCRequestPayload](#class-jsonrpcrequestpayload) | +`callback` | [JSONRPCErrorCallback](#jsonrpcerrorcallback) | + +**Returns:** *void* + +
-• **event**: *string* -*Inherited from [DecodedLogEntry](#interface-decodedlogentry).[event](#event)* -*Defined in [ethereum-types/src/index.ts:416](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L416)* +# Interface: JSONRPCRequestPayload -___ -### logIndex +## Properties -• **logIndex**: *number | null* +### id -*Inherited from [LogEntry](#interface-logentry).[logIndex](#logindex)* +• **id**: *number* -*Defined in [ethereum-types/src/index.ts:429](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L429)* +*Defined in [ethereum-types/src/index.ts:330](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L330)* ___ -### topics - -• **topics**: *string[]* +### jsonrpc -*Inherited from [LogEntry](#interface-logentry).[topics](#topics)* +• **jsonrpc**: *string* -*Defined in [ethereum-types/src/index.ts:436](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L436)* +*Defined in [ethereum-types/src/index.ts:331](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L331)* ___ -### transactionHash - -• **transactionHash**: *string* +### method -*Inherited from [LogEntry](#interface-logentry).[transactionHash](#transactionhash)* +• **method**: *string* -*Defined in [ethereum-types/src/index.ts:431](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L431)* +*Defined in [ethereum-types/src/index.ts:329](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L329)* ___ -### transactionIndex - -• **transactionIndex**: *number | null* +### params -*Inherited from [LogEntry](#interface-logentry).[transactionIndex](#transactionindex)* +• **params**: *any[]* -*Defined in [ethereum-types/src/index.ts:430](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L430)* +*Defined in [ethereum-types/src/index.ts:328](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L328)*
-# Interface: MethodAbi +# Interface: JSONRPCResponseError ## Properties -### constant +### code -• **constant**: *boolean* +• **code**: *number* -*Defined in [ethereum-types/src/index.ts:94](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L94)* +*Defined in [ethereum-types/src/index.ts:336](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L336)* ___ -### inputs - -• **inputs**: *[DataItem](#class-dataitem)[]* +### message -*Defined in [ethereum-types/src/index.ts:92](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L92)* +• **message**: *string* -___ +*Defined in [ethereum-types/src/index.ts:335](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L335)* -### name +
-• **name**: *string* +# Interface: JSONRPCResponsePayload -*Defined in [ethereum-types/src/index.ts:91](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L91)* -___ +## Properties -### outputs +### `Optional` error -• **outputs**: *[DataItem](#class-dataitem)[]* +• **error**? : *[JSONRPCResponseError](#class-jsonrpcresponseerror)* -*Defined in [ethereum-types/src/index.ts:93](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L93)* +*Defined in [ethereum-types/src/index.ts:343](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L343)* ___ -### payable +### id -• **payable**: *boolean* +• **id**: *number* -*Defined in [ethereum-types/src/index.ts:96](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L96)* +*Defined in [ethereum-types/src/index.ts:341](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L341)* ___ -### stateMutability +### jsonrpc -• **stateMutability**: *[StateMutability](#statemutability)* +• **jsonrpc**: *string* -*Defined in [ethereum-types/src/index.ts:95](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L95)* +*Defined in [ethereum-types/src/index.ts:342](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L342)* ___ -### type +### result -• **type**: *string* +• **result**: *any* -*Defined in [ethereum-types/src/index.ts:90](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L90)* +*Defined in [ethereum-types/src/index.ts:340](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L340)*
-# Interface: OptimizerSettings +# Interface: LogEntry ## Properties -### enabled +### address -• **enabled**: *boolean* +• **address**: *string* -*Defined in [ethereum-types/src/index.ts:708](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L708)* +*Defined in [ethereum-types/src/index.ts:434](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L434)* ___ -### `Optional` runs +### blockHash -• **runs**? : *undefined | number* +• **blockHash**: *string | null* -*Defined in [ethereum-types/src/index.ts:709](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L709)* +*Defined in [ethereum-types/src/index.ts:432](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L432)* -
+___ + +### blockNumber +• **blockNumber**: *number | null* +*Defined in [ethereum-types/src/index.ts:433](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L433)* +___ +### data -# Interface: RevertErrorAbi +• **data**: *string* +*Defined in [ethereum-types/src/index.ts:435](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L435)* -## Properties +___ -### `Optional` arguments +### logIndex -• **arguments**? : *[DataItem](#class-dataitem)[]* +• **logIndex**: *number | null* -*Defined in [ethereum-types/src/index.ts:122](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L122)* +*Defined in [ethereum-types/src/index.ts:429](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L429)* ___ -### name +### topics -• **name**: *string* +• **topics**: *string[]* -*Defined in [ethereum-types/src/index.ts:121](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L121)* +*Defined in [ethereum-types/src/index.ts:436](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L436)* ___ -### type - -• **type**: *"error"* +### transactionHash -*Defined in [ethereum-types/src/index.ts:120](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L120)* +• **transactionHash**: *string* -
+*Defined in [ethereum-types/src/index.ts:431](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L431)* -# Class: CoordinatorContract +___ +### transactionIndex -## Constructors +• **transactionIndex**: *number | null* +*Defined in [ethereum-types/src/index.ts:430](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L430)* +
-\+ **new CoordinatorContract**(`address`: string, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults?`: `Partial`, `logDecodeDependencies?`: undefined | object, `deployedBytecode`: string | undefined): *[CoordinatorContract](#class-coordinatorcontract)* +# Interface: LogEntryEvent -*Overrides void* -*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator.ts:1066](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/coordinator.ts#L1066)* +## Properties -**Parameters:** +### address -Name | Type | Default | ------- | ------ | ------ | -`address` | string | - | -`supportedProvider` | [SupportedProvider](#supportedprovider) | - | -`txDefaults?` | `Partial` | - | -`logDecodeDependencies?` | undefined \| object | - | -`deployedBytecode` | string \| undefined | CoordinatorContract.deployedBytecode | +• **address**: *string* -**Returns:** *[CoordinatorContract](#class-coordinatorcontract)* +*Inherited from [LogEntry](#interface-logentry).[address](#address)* -## Properties +*Defined in [ethereum-types/src/index.ts:434](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L434)* -### `Optional` _deployedBytecodeIfExists +___ -• **_deployedBytecodeIfExists**? : *`Buffer`* +### blockHash +• **blockHash**: *string | null* +*Inherited from [LogEntry](#interface-logentry).[blockHash](#blockhash)* -Defined in base-contract/lib/src/index.d.ts:32 +*Defined in [ethereum-types/src/index.ts:432](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L432)* ___ -### abi - -• **abi**: *[ContractAbi](#contractabi)* +### blockNumber +• **blockNumber**: *number | null* +*Inherited from [LogEntry](#interface-logentry).[blockNumber](#blocknumber)* -Defined in base-contract/lib/src/index.d.ts:28 +*Defined in [ethereum-types/src/index.ts:433](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L433)* ___ -### address - -• **address**: *string* +### data +• **data**: *string* +*Inherited from [LogEntry](#interface-logentry).[data](#data)* -Defined in base-contract/lib/src/index.d.ts:29 +*Defined in [ethereum-types/src/index.ts:435](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L435)* ___ -Args - -• **constructorArgs**: *any[]* +### logIndex +• **logIndex**: *number | null* +*Inherited from [LogEntry](#interface-logentry).[logIndex](#logindex)* -Defined in base-contract/lib/src/index.d.ts:31 +*Defined in [ethereum-types/src/index.ts:429](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L429)* ___ -### contractName - -• **contractName**: *string* - +### removed +• **removed**: *boolean* -Defined in base-contract/lib/src/index.d.ts:30 +*Defined in [ethereum-types/src/index.ts:425](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L425)* -## Methods +___ -### EIP712_COORDINATOR_DOMAIN_HASH +### topics -▸ **EIP712_COORDINATOR_DOMAIN_HASH**(): *`ContractFunctionObj`* +• **topics**: *string[]* -*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator.ts:1020](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/coordinator.ts#L1020)* +*Inherited from [LogEntry](#interface-logentry).[topics](#topics)* -**Returns:** *`ContractFunctionObj`* +*Defined in [ethereum-types/src/index.ts:436](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L436)* ___ -### EIP712_EXCHANGE_DOMAIN_HASH +### transactionHash -▸ **EIP712_EXCHANGE_DOMAIN_HASH**(): *`ContractFunctionObj`* +• **transactionHash**: *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator.ts:787](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/coordinator.ts#L787)* +*Inherited from [LogEntry](#interface-logentry).[transactionHash](#transactionhash)* -**Returns:** *`ContractFunctionObj`* +*Defined in [ethereum-types/src/index.ts:431](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L431)* ___ -### assertValidCoordinatorApprovals +### transactionIndex -▸ **assertValidCoordinatorApprovals**(`transaction`: object, `txOrigin`: string, `transactionSignature`: string, `approvalExpirationTimeSeconds`: `BigNumber`[], `approvalSignatures`: string[]): *`ContractFunctionObj`* +• **transactionIndex**: *number | null* -*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator.ts:847](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/coordinator.ts#L847)* +*Inherited from [LogEntry](#interface-logentry).[transactionIndex](#transactionindex)* -Validates that the 0x transaction has been approved by all of the feeRecipients -that correspond to each order in the transaction's Exchange calldata. +*Defined in [ethereum-types/src/index.ts:430](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L430)* -**Parameters:** +
-Name | Type | Description | ------- | ------ | ------ | -`transaction` | object | 0x transaction containing salt, signerAddress, and data. | -`txOrigin` | string | Required signer of Ethereum transaction calling this function. | -`transactionSignature` | string | Proof that the transaction has been signed by the signer. | -`approvalExpirationTimeSeconds` | `BigNumber`[] | Array of expiration times in seconds for which each corresponding approval signature expires. | -`approvalSignatures` | string[] | Array of signatures that correspond to the feeRecipients of each order in the transaction's Exchange calldata. | +# Interface: LogWithDecodedArgs <**ArgsType**> -**Returns:** *`ContractFunctionObj`* +## Type parameters -___ +▪ **ArgsType**: *[DecodedLogArgs](#class-decodedlogargs)* -### decodeOrdersFromFillData -▸ **decodeOrdersFromFillData**(`data`: string): *`ContractFunctionObj>`* +## Properties -*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator.ts:930](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/coordinator.ts#L930)* +### address -Decodes the orders from Exchange calldata representing any fill method. +• **address**: *string* -**Parameters:** +*Inherited from [LogEntry](#interface-logentry).[address](#address)* -Name | Type | Description | ------- | ------ | ------ | -`data` | string | Exchange calldata representing a fill method. | +*Defined in [ethereum-types/src/index.ts:434](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L434)* -**Returns:** *`ContractFunctionObj>`* +___ -The orders from the Exchange calldata. +### args + +• **args**: *`ArgsType`* + +*Inherited from [DecodedLogEntry](#interface-decodedlogentry).[args](#args)* + +*Defined in [ethereum-types/src/index.ts:417](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L417)* ___ -### executeTransaction +### blockHash -▸ **executeTransaction**(`transaction`: object, `txOrigin`: string, `transactionSignature`: string, `approvalExpirationTimeSeconds`: `BigNumber`[], `approvalSignatures`: string[]): *`ContractTxFunctionObj`* +• **blockHash**: *string | null* -*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator.ts:633](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/coordinator.ts#L633)* +*Inherited from [LogEntry](#interface-logentry).[blockHash](#blockhash)* -Executes a 0x transaction that has been signed by the feeRecipients that correspond to each order in the transaction's Exchange calldata. +*Defined in [ethereum-types/src/index.ts:432](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L432)* -**Parameters:** +___ -Name | Type | Description | ------- | ------ | ------ | -`transaction` | object | 0x transaction containing salt, signerAddress, and data. | -`txOrigin` | string | Required signer of Ethereum transaction calling this function. | -`transactionSignature` | string | Proof that the transaction has been signed by the signer. | -`approvalExpirationTimeSeconds` | `BigNumber`[] | Array of expiration times in seconds for which each corresponding approval signature expires. | -`approvalSignatures` | string[] | Array of signatures that correspond to the feeRecipients of each order in the transaction's Exchange calldata. | +### blockNumber -**Returns:** *`ContractTxFunctionObj`* +• **blockNumber**: *number | null* + +*Inherited from [LogEntry](#interface-logentry).[blockNumber](#blocknumber)* + +*Defined in [ethereum-types/src/index.ts:433](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L433)* ___ -### getABIDecodedReturnData +### data -▸ **getABIDecodedReturnData**<**T**>(`methodName`: string, `callData`: string): *`T`* +• **data**: *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator.ts:433](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/coordinator.ts#L433)* +*Inherited from [LogEntry](#interface-logentry).[data](#data)* -**Type parameters:** +*Defined in [ethereum-types/src/index.ts:435](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L435)* -▪ **T** +___ -**Parameters:** +### event -Name | Type | ------- | ------ | -`methodName` | string | -`callData` | string | +• **event**: *string* + +*Inherited from [DecodedLogEntry](#interface-decodedlogentry).[event](#event)* -**Returns:** *`T`* +*Defined in [ethereum-types/src/index.ts:416](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L416)* ___ -### getABIDecodedTransactionData +### logIndex -▸ **getABIDecodedTransactionData**<**T**>(`methodName`: string, `callData`: string): *`T`* +• **logIndex**: *number | null* -*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator.ts:426](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/coordinator.ts#L426)* +*Inherited from [LogEntry](#interface-logentry).[logIndex](#logindex)* -**Type parameters:** +*Defined in [ethereum-types/src/index.ts:429](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L429)* -▪ **T** +___ -**Parameters:** +### topics -Name | Type | ------- | ------ | -`methodName` | string | -`callData` | string | +• **topics**: *string[]* + +*Inherited from [LogEntry](#interface-logentry).[topics](#topics)* -**Returns:** *`T`* +*Defined in [ethereum-types/src/index.ts:436](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L436)* ___ -### getCoordinatorApprovalHash +### transactionHash + +• **transactionHash**: *string* -▸ **getCoordinatorApprovalHash**(`approval`: object): *`ContractFunctionObj`* +*Inherited from [LogEntry](#interface-logentry).[transactionHash](#transactionhash)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator.ts:561](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/coordinator.ts#L561)* +*Defined in [ethereum-types/src/index.ts:431](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L431)* -Calculated the EIP712 hash of the Coordinator approval mesasage using the domain separator of this contract. +___ -**Parameters:** +### transactionIndex -Name | Type | Description | ------- | ------ | ------ | -`approval` | object | Coordinator approval message containing the transaction hash, transaction signature, and expiration of the approval. | +• **transactionIndex**: *number | null* -**Returns:** *`ContractFunctionObj`* +*Inherited from [LogEntry](#interface-logentry).[transactionIndex](#transactionindex)* -EIP712 hash of the Coordinator approval message with the domain separator of this contract. +*Defined in [ethereum-types/src/index.ts:430](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L430)* -___ +
-### getFunctionSignature +# Interface: MethodAbi -▸ **getFunctionSignature**(`methodName`: string): *string* -*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator.ts:420](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/coordinator.ts#L420)* +## Properties -**Parameters:** +### constant -Name | Type | ------- | ------ | -`methodName` | string | +• **constant**: *boolean* -**Returns:** *string* +*Defined in [ethereum-types/src/index.ts:94](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L94)* ___ -### getSelector +### inputs -▸ **getSelector**(`methodName`: string): *string* +• **inputs**: *[DataItem](#class-dataitem)[]* -*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator.ts:440](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/coordinator.ts#L440)* +*Defined in [ethereum-types/src/index.ts:92](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L92)* -**Parameters:** +___ -Name | Type | ------- | ------ | -`methodName` | string | +### name -**Returns:** *string* +• **name**: *string* + +*Defined in [ethereum-types/src/index.ts:91](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L91)* ___ -### getSignerAddress +### outputs -▸ **getSignerAddress**(`hash`: string, `signature`: string): *`ContractFunctionObj`* +• **outputs**: *[DataItem](#class-dataitem)[]* -*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator.ts:452](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/coordinator.ts#L452)* +*Defined in [ethereum-types/src/index.ts:93](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L93)* -Recovers the address of a signer given a hash and signature. +___ -**Parameters:** +### payable -Name | Type | Description | ------- | ------ | ------ | -`hash` | string | Any 32 byte hash. | -`signature` | string | Proof that the hash has been signed by signer. | +• **payable**: *boolean* -**Returns:** *`ContractFunctionObj`* +*Defined in [ethereum-types/src/index.ts:96](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L96)* ___ -### getTransactionHash +### stateMutability -▸ **getTransactionHash**(`transaction`: object): *`ContractFunctionObj`* +• **stateMutability**: *[StateMutability](#statemutability)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator.ts:499](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/coordinator.ts#L499)* +*Defined in [ethereum-types/src/index.ts:95](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L95)* -Calculates the EIP712 hash of a 0x transaction using the domain separator of the Exchange contract. +___ -**Parameters:** +### type -Name | Type | Description | ------- | ------ | ------ | -`transaction` | object | 0x transaction containing salt, signerAddress, and data. | +• **type**: *string* -**Returns:** *`ContractFunctionObj`* +*Defined in [ethereum-types/src/index.ts:90](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L90)* -EIP712 hash of the transaction with the domain separator of this contract. +
-___ +# Interface: OptimizerSettings -### `Static` ABI -▸ **ABI**(): *[ContractAbi](#contractabi)* +## Properties -*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator.ts:124](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/coordinator.ts#L124)* +### enabled -**Returns:** *[ContractAbi](#contractabi)* +• **enabled**: *boolean* -The contract ABI +*Defined in [ethereum-types/src/index.ts:708](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L708)* ___ -### `Static` deployAsync +### `Optional` runs -▸ **deployAsync**(`bytecode`: string, `abi`: [ContractAbi](#contractabi), `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object, `_exchange`: string): *`Promise`* +• **runs**? : *undefined | number* -*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator.ts:77](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/coordinator.ts#L77)* +*Defined in [ethereum-types/src/index.ts:709](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L709)* -**Parameters:** +
-Name | Type | ------- | ------ | -`bytecode` | string | -`abi` | [ContractAbi](#contractabi) | -`supportedProvider` | [SupportedProvider](#supportedprovider) | -`txDefaults` | `Partial` | -`logDecodeDependencies` | object | -`_exchange` | string | -**Returns:** *`Promise`* -___ -### `Static` deployFrom0xArtifactAsync -▸ **deployFrom0xArtifactAsync**(`artifact`: `ContractArtifact` | `SimpleContractArtifact`, `supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `Partial`, `logDecodeDependencies`: object, `_exchange`: string): *`Promise`* +# Interface: RevertErrorAbi -*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator.ts:44](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/coordinator.ts#L44)* -**Parameters:** +## Properties -Name | Type | ------- | ------ | -`artifact` | `ContractArtifact` \| `SimpleContractArtifact` | -`supportedProvider` | [SupportedProvider](#supportedprovider) | -`txDefaults` | `Partial` | -`logDecodeDependencies` | object | -`_exchange` | string | +### `Optional` arguments -**Returns:** *`Promise`* +• **arguments**? : *[DataItem](#class-dataitem)[]* -___ +*Defined in [ethereum-types/src/index.ts:122](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L122)* -### `Static` strictArgumentEncodingCheck +___ -▸ **strictArgumentEncodingCheck**(`inputAbi`: `DataItem`[], `args`: any[]): *string* +### name +• **name**: *string* +*Defined in [ethereum-types/src/index.ts:121](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L121)* -Defined in base-contract/lib/src/index.d.ts:42 +___ -**Parameters:** +### type -Name | Type | ------- | ------ | -`inputAbi` | `DataItem`[] | -`args` | any[] | +• **type**: *"error"* -**Returns:** *string* +*Defined in [ethereum-types/src/index.ts:120](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L120)*
@@ -10239,6 +21342,8 @@ Name | Type | + + # Interface: StandardContractOutput @@ -10248,7 +21353,7 @@ Name | Type | • **abi**: *[ContractAbi](#contractabi)* -*Defined in [ethereum-types/src/index.ts:564](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L564)* +*Defined in [ethereum-types/src/index.ts:564](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L564)* ___ @@ -10256,7 +21361,7 @@ ___ • **devdoc**? : *[DevdocOutput](#class-devdocoutput)* -*Defined in [ethereum-types/src/index.ts:566](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L566)* +*Defined in [ethereum-types/src/index.ts:566](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L566)* ___ @@ -10264,7 +21369,7 @@ ___ • **evm**: *[EvmOutput](#class-evmoutput)* -*Defined in [ethereum-types/src/index.ts:565](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L565)* +*Defined in [ethereum-types/src/index.ts:565](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L565)*
@@ -10293,7 +21398,7 @@ ___ *Overrides [DataItem](_ethereum_types_src_index_.dataitem.md).[components](#optional-components)* -*Defined in [ethereum-types/src/index.ts:141](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L141)* +*Defined in [ethereum-types/src/index.ts:141](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L141)* ___ @@ -10303,7 +21408,7 @@ ___ *Inherited from [DataItem](#interface-dataitem).[name](#name)* -*Defined in [ethereum-types/src/index.ts:135](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L135)* +*Defined in [ethereum-types/src/index.ts:135](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L135)* ___ @@ -10313,7 +21418,7 @@ ___ *Inherited from [DataItem](#interface-dataitem).[type](#type)* -*Defined in [ethereum-types/src/index.ts:136](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L136)* +*Defined in [ethereum-types/src/index.ts:136](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L136)*
@@ -10328,7 +21433,7 @@ ___ *Inherited from [CallTxDataBase](#interface-calltxdatabase).[data](#optional-data)* -*Defined in [ethereum-types/src/index.ts:393](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L393)* +*Defined in [ethereum-types/src/index.ts:393](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L393)* ___ @@ -10336,7 +21441,7 @@ ___ • **from**: *string* -*Defined in [ethereum-types/src/index.ts:398](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L398)* +*Defined in [ethereum-types/src/index.ts:398](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L398)* ___ @@ -10346,7 +21451,7 @@ ___ *Inherited from [CallTxDataBase](#interface-calltxdatabase).[gas](#optional-gas)* -*Defined in [ethereum-types/src/index.ts:391](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L391)* +*Defined in [ethereum-types/src/index.ts:391](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L391)* ___ @@ -10356,7 +21461,7 @@ ___ *Inherited from [CallTxDataBase](#interface-calltxdatabase).[gasPrice](#optional-gasprice)* -*Defined in [ethereum-types/src/index.ts:392](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L392)* +*Defined in [ethereum-types/src/index.ts:392](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L392)* ___ @@ -10366,7 +21471,7 @@ ___ *Inherited from [CallTxDataBase](#interface-calltxdatabase).[nonce](#optional-nonce)* -*Defined in [ethereum-types/src/index.ts:394](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L394)* +*Defined in [ethereum-types/src/index.ts:394](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L394)* ___ @@ -10376,7 +21481,7 @@ ___ *Inherited from [CallTxDataBase](#interface-calltxdatabase).[to](#optional-to)* -*Defined in [ethereum-types/src/index.ts:389](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L389)* +*Defined in [ethereum-types/src/index.ts:389](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L389)* ___ @@ -10386,7 +21491,7 @@ ___ *Inherited from [CallTxDataBase](#interface-calltxdatabase).[value](#optional-value)* -*Defined in [ethereum-types/src/index.ts:390](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L390)* +*Defined in [ethereum-types/src/index.ts:390](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L390)*
@@ -10401,7 +21506,7 @@ ___ *Inherited from [CallTxDataBase](#interface-calltxdatabase).[data](#optional-data)* -*Defined in [ethereum-types/src/index.ts:393](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L393)* +*Defined in [ethereum-types/src/index.ts:393](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L393)* ___ @@ -10411,7 +21516,7 @@ ___ *Inherited from [TxData](#interface-txdata).[from](#from)* -*Defined in [ethereum-types/src/index.ts:398](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L398)* +*Defined in [ethereum-types/src/index.ts:398](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L398)* ___ @@ -10421,7 +21526,7 @@ ___ *Inherited from [CallTxDataBase](#interface-calltxdatabase).[gas](#optional-gas)* -*Defined in [ethereum-types/src/index.ts:391](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L391)* +*Defined in [ethereum-types/src/index.ts:391](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L391)* ___ @@ -10431,7 +21536,7 @@ ___ *Inherited from [CallTxDataBase](#interface-calltxdatabase).[gasPrice](#optional-gasprice)* -*Defined in [ethereum-types/src/index.ts:392](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L392)* +*Defined in [ethereum-types/src/index.ts:392](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L392)* ___ @@ -10441,7 +21546,7 @@ ___ *Inherited from [CallTxDataBase](#interface-calltxdatabase).[nonce](#optional-nonce)* -*Defined in [ethereum-types/src/index.ts:394](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L394)* +*Defined in [ethereum-types/src/index.ts:394](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L394)* ___ @@ -10451,7 +21556,7 @@ ___ *Inherited from [CallTxDataBase](#interface-calltxdatabase).[to](#optional-to)* -*Defined in [ethereum-types/src/index.ts:389](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L389)* +*Defined in [ethereum-types/src/index.ts:389](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L389)* ___ @@ -10461,7 +21566,7 @@ ___ *Overrides [CallTxDataBase](_ethereum_types_src_index_.calltxdatabase.md).[value](#optional-value)* -*Defined in [ethereum-types/src/index.ts:442](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L442)* +*Defined in [ethereum-types/src/index.ts:442](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L442)*
@@ -10478,7 +21583,7 @@ This interface allowed sending synchonous requests, support for which was later ▸ **send**(`payload`: [JSONRPCRequestPayload](_ethereum_types_src_index_.jsonrpcrequestpayload.md)): *[JSONRPCResponsePayload](#class-jsonrpcresponsepayload)* -*Defined in [ethereum-types/src/index.ts:45](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L45)* +*Defined in [ethereum-types/src/index.ts:45](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L45)* **Parameters:** @@ -10494,7 +21599,7 @@ ___ ▸ **sendAsync**(`payload`: [JSONRPCRequestPayload](_ethereum_types_src_index_.jsonrpcrequestpayload.md), `callback`: [JSONRPCErrorCallback](#jsonrpcerrorcallback)): *void* -*Defined in [ethereum-types/src/index.ts:44](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L44)* +*Defined in [ethereum-types/src/index.ts:44](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L44)* **Parameters:** @@ -10520,7 +21625,7 @@ before the first attempts to conform to EIP1193 ▸ **send**(`payload`: [JSONRPCRequestPayload](_ethereum_types_src_index_.jsonrpcrequestpayload.md), `callback`: [JSONRPCErrorCallback](#jsonrpcerrorcallback)): *void* -*Defined in [ethereum-types/src/index.ts:54](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L54)* +*Defined in [ethereum-types/src/index.ts:54](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L54)* **Parameters:** @@ -10546,7 +21651,7 @@ however it does not conform entirely. ▸ **send**(`method`: string, `params?`: any[]): *`Promise`* -*Defined in [ethereum-types/src/index.ts:63](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L63)* +*Defined in [ethereum-types/src/index.ts:63](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L63)* **Parameters:** @@ -10572,7 +21677,7 @@ add here • **isMetaMask**? : *undefined | false | true* -*Defined in [ethereum-types/src/index.ts:31](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L31)* +*Defined in [ethereum-types/src/index.ts:31](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L31)* ___ @@ -10580,7 +21685,7 @@ ___ • **isParity**? : *undefined | false | true* -*Defined in [ethereum-types/src/index.ts:32](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L32)* +*Defined in [ethereum-types/src/index.ts:32](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L32)* ___ @@ -10588,7 +21693,7 @@ ___ • **isZeroExProvider**? : *undefined | false | true* -*Defined in [ethereum-types/src/index.ts:30](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L30)* +*Defined in [ethereum-types/src/index.ts:30](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L30)* ## Methods @@ -10596,7 +21701,7 @@ ___ ▸ **enable**(): *`Promise`* -*Defined in [ethereum-types/src/index.ts:34](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L34)* +*Defined in [ethereum-types/src/index.ts:34](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L34)* **Returns:** *`Promise`* @@ -10606,7 +21711,7 @@ ___ ▸ **sendAsync**(`payload`: [JSONRPCRequestPayload](_ethereum_types_src_index_.jsonrpcrequestpayload.md), `callback`: [JSONRPCErrorCallback](#jsonrpcerrorcallback)): *void* -*Defined in [ethereum-types/src/index.ts:35](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L35)* +*Defined in [ethereum-types/src/index.ts:35](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L35)* **Parameters:** @@ -10623,7 +21728,7 @@ ___ ▸ **stop**(): *void* -*Defined in [ethereum-types/src/index.ts:33](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L33)* +*Defined in [ethereum-types/src/index.ts:33](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L33)* **Returns:** *void* @@ -10639,6 +21744,47 @@ ___ +# Interface: AwaitTransactionSuccessOpts + +Used with `awaitTransactionSuccessAsync` +* pollingIntervalMs: Determine polling intervals in milliseconds +* timeoutMs: Determines timeout in milliseconds + + +## Properties + +### `Optional` pollingIntervalMs + +• **pollingIntervalMs**? : *undefined | number* + +*Overrides [SendTransactionOpts](_types_src_index_.sendtransactionopts.md).[pollingIntervalMs](#optional-pollingintervalms)* + +*Defined in [types/src/index.ts:877](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L877)* + +___ + +### `Optional` shouldValidate + +• **shouldValidate**? : *undefined | false | true* + +*Inherited from [SendTransactionOpts](#interface-sendtransactionopts).[shouldValidate](#optional-shouldvalidate)* + +*Overrides [SendTransactionOpts](_types_src_index_.sendtransactionopts.md).[shouldValidate](#optional-shouldvalidate)* + +*Defined in [types/src/index.ts:680](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L680)* + +___ + +### `Optional` timeoutMs + +• **timeoutMs**? : *undefined | number* + +*Overrides [SendTransactionOpts](_types_src_index_.sendtransactionopts.md).[timeoutMs](#optional-timeoutms)* + +*Defined in [types/src/index.ts:878](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L878)* + +
+ @@ -10662,7 +21808,7 @@ ___ • **isRemoved**: *boolean* -*Defined in [types/src/index.ts:844](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L844)* +*Defined in [types/src/index.ts:844](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L844)* ___ @@ -10670,7 +21816,7 @@ ___ • **log**: *`LogWithDecodedArgs`* -*Defined in [types/src/index.ts:845](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L845)* +*Defined in [types/src/index.ts:845](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L845)*
@@ -10691,7 +21837,7 @@ ___ • **chainId**: *number* -*Defined in [types/src/index.ts:793](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L793)* +*Defined in [types/src/index.ts:793](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L793)* ___ @@ -10699,7 +21845,7 @@ ___ • **name**? : *undefined | string* -*Defined in [types/src/index.ts:791](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L791)* +*Defined in [types/src/index.ts:791](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L791)* ___ @@ -10707,7 +21853,7 @@ ___ • **verifyingContract**: *string* -*Defined in [types/src/index.ts:794](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L794)* +*Defined in [types/src/index.ts:794](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L794)* ___ @@ -10715,7 +21861,7 @@ ___ • **version**? : *undefined | string* -*Defined in [types/src/index.ts:792](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L792)* +*Defined in [types/src/index.ts:792](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L792)*
@@ -10757,7 +21903,7 @@ ___ • **keyName**: *string* -*Defined in [types/src/index.ts:691](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L691)* +*Defined in [types/src/index.ts:691](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L691)* ___ @@ -10765,7 +21911,7 @@ ___ • **keyType**: *[Type](#class-type)* -*Defined in [types/src/index.ts:692](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L692)* +*Defined in [types/src/index.ts:692](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L692)* ___ @@ -10773,7 +21919,7 @@ ___ • **valueName**: *string* -*Defined in [types/src/index.ts:693](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L693)* +*Defined in [types/src/index.ts:693](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L693)*
@@ -10821,7 +21967,44 @@ ___ +# Interface: SendTransactionOpts + +* shouldValidate: Flag indicating whether the library should make attempts to validate a transaction before +broadcasting it. For example, order has a valid signature, maker has sufficient funds, etc. Default=true. +* pollingIntervalMs: Used with `awaitTransactionSuccessAsync` to determine polling interval in milliseconds +* timeoutMs: Used with `awaitTransactionSuccessAsync` to determine timeout in milliseconds +Used with `sendTransactionAsync` +* shouldValidate: Flag indicating whether the library should make attempts to validate a transaction before +broadcasting it. For example, order has a valid signature, maker has sufficient funds, etc. Default=true. + + +## Properties + +### `Optional` pollingIntervalMs + +• **pollingIntervalMs**? : *undefined | number* + +*Defined in [types/src/index.ts:681](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L681)* + +___ + +### `Optional` shouldValidate + +• **shouldValidate**? : *undefined | false | true* + +*Defined in [types/src/index.ts:680](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L680)* + +*Defined in [types/src/index.ts:868](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L868)* + +___ + +### `Optional` timeoutMs + +• **timeoutMs**? : *undefined | number* + +*Defined in [types/src/index.ts:682](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L682)* +
# Interface: SignedOrder @@ -10834,7 +22017,7 @@ ___ *Inherited from [Order](#interface-order).[chainId](#chainid)* -*Defined in [types/src/index.ts:14](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L14)* +*Defined in [types/src/index.ts:14](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L14)* ___ @@ -10844,7 +22027,7 @@ ___ *Inherited from [Order](#interface-order).[exchangeAddress](#exchangeaddress)* -*Defined in [types/src/index.ts:15](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L15)* +*Defined in [types/src/index.ts:15](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L15)* ___ @@ -10854,7 +22037,7 @@ ___ *Inherited from [Order](#interface-order).[expirationTimeSeconds](#expirationtimeseconds)* -*Defined in [types/src/index.ts:24](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L24)* +*Defined in [types/src/index.ts:24](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L24)* ___ @@ -10864,7 +22047,7 @@ ___ *Inherited from [Order](#interface-order).[feeRecipientAddress](#feerecipientaddress)* -*Defined in [types/src/index.ts:18](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L18)* +*Defined in [types/src/index.ts:18](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L18)* ___ @@ -10874,7 +22057,7 @@ ___ *Inherited from [Order](#interface-order).[makerAddress](#makeraddress)* -*Defined in [types/src/index.ts:16](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L16)* +*Defined in [types/src/index.ts:16](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L16)* ___ @@ -10884,7 +22067,7 @@ ___ *Inherited from [Order](#interface-order).[makerAssetAmount](#makerassetamount)* -*Defined in [types/src/index.ts:20](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L20)* +*Defined in [types/src/index.ts:20](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L20)* ___ @@ -10894,7 +22077,7 @@ ___ *Inherited from [Order](#interface-order).[makerAssetData](#makerassetdata)* -*Defined in [types/src/index.ts:26](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L26)* +*Defined in [types/src/index.ts:26](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L26)* ___ @@ -10904,7 +22087,7 @@ ___ *Inherited from [Order](#interface-order).[makerFee](#makerfee)* -*Defined in [types/src/index.ts:22](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L22)* +*Defined in [types/src/index.ts:22](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L22)* ___ @@ -10914,7 +22097,7 @@ ___ *Inherited from [Order](#interface-order).[makerFeeAssetData](#makerfeeassetdata)* -*Defined in [types/src/index.ts:28](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L28)* +*Defined in [types/src/index.ts:28](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L28)* ___ @@ -10924,7 +22107,7 @@ ___ *Inherited from [Order](#interface-order).[salt](#salt)* -*Defined in [types/src/index.ts:25](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L25)* +*Defined in [types/src/index.ts:25](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L25)* ___ @@ -10934,7 +22117,7 @@ ___ *Inherited from [Order](#interface-order).[senderAddress](#senderaddress)* -*Defined in [types/src/index.ts:19](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L19)* +*Defined in [types/src/index.ts:19](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L19)* ___ @@ -10942,7 +22125,7 @@ ___ • **signature**: *string* -*Defined in [types/src/index.ts:33](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L33)* +*Defined in [types/src/index.ts:33](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L33)* ___ @@ -10952,7 +22135,7 @@ ___ *Inherited from [Order](#interface-order).[takerAddress](#takeraddress)* -*Defined in [types/src/index.ts:17](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L17)* +*Defined in [types/src/index.ts:17](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L17)* ___ @@ -10962,7 +22145,7 @@ ___ *Inherited from [Order](#interface-order).[takerAssetAmount](#takerassetamount)* -*Defined in [types/src/index.ts:21](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L21)* +*Defined in [types/src/index.ts:21](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L21)* ___ @@ -10972,7 +22155,7 @@ ___ *Inherited from [Order](#interface-order).[takerAssetData](#takerassetdata)* -*Defined in [types/src/index.ts:27](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L27)* +*Defined in [types/src/index.ts:27](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L27)* ___ @@ -10982,7 +22165,7 @@ ___ *Inherited from [Order](#interface-order).[takerFee](#takerfee)* -*Defined in [types/src/index.ts:23](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L23)* +*Defined in [types/src/index.ts:23](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L23)* ___ @@ -10992,7 +22175,7 @@ ___ *Inherited from [Order](#interface-order).[takerFeeAssetData](#takerfeeassetdata)* -*Defined in [types/src/index.ts:29](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L29)* +*Defined in [types/src/index.ts:29](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L29)*
@@ -11007,7 +22190,7 @@ ___ *Inherited from [ZeroExTransaction](#interface-zeroextransaction).[data](#data)* -*Defined in [types/src/index.ts:49](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L49)* +*Defined in [types/src/index.ts:49](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L49)* ___ @@ -11017,7 +22200,7 @@ ___ *Inherited from [ZeroExTransaction](#interface-zeroextransaction).[domain](#domain)* -*Defined in [types/src/index.ts:50](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L50)* +*Defined in [types/src/index.ts:50](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L50)* ___ @@ -11027,7 +22210,7 @@ ___ *Inherited from [ZeroExTransaction](#interface-zeroextransaction).[expirationTimeSeconds](#expirationtimeseconds)* -*Defined in [types/src/index.ts:46](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L46)* +*Defined in [types/src/index.ts:46](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L46)* ___ @@ -11037,7 +22220,7 @@ ___ *Inherited from [ZeroExTransaction](#interface-zeroextransaction).[gasPrice](#gasprice)* -*Defined in [types/src/index.ts:47](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L47)* +*Defined in [types/src/index.ts:47](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L47)* ___ @@ -11047,7 +22230,7 @@ ___ *Inherited from [ZeroExTransaction](#interface-zeroextransaction).[salt](#salt)* -*Defined in [types/src/index.ts:45](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L45)* +*Defined in [types/src/index.ts:45](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L45)* ___ @@ -11055,7 +22238,7 @@ ___ • **signature**: *string* -*Defined in [types/src/index.ts:54](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L54)* +*Defined in [types/src/index.ts:54](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L54)* ___ @@ -11065,7 +22248,7 @@ ___ *Inherited from [ZeroExTransaction](#interface-zeroextransaction).[signerAddress](#signeraddress)* -*Defined in [types/src/index.ts:48](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L48)* +*Defined in [types/src/index.ts:48](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L48)*
@@ -11078,7 +22261,7 @@ ___ • **chains**: *`ContractChains`* -*Defined in [types/src/index.ts:861](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L861)* +*Defined in [types/src/index.ts:885](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L885)* ___ @@ -11086,7 +22269,7 @@ ___ • **compilerOutput**: *[SimpleStandardContractOutput](#class-simplestandardcontractoutput)* -*Defined in [types/src/index.ts:860](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L860)* +*Defined in [types/src/index.ts:884](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L884)* ___ @@ -11094,7 +22277,7 @@ ___ • **contractName**: *string* -*Defined in [types/src/index.ts:859](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L859)* +*Defined in [types/src/index.ts:883](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L883)* ___ @@ -11102,7 +22285,7 @@ ___ • **schemaVersion**: *string* -*Defined in [types/src/index.ts:858](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L858)* +*Defined in [types/src/index.ts:882](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L882)*
@@ -11115,7 +22298,7 @@ ___ • **object**: *string* -*Defined in [types/src/index.ts:875](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L875)* +*Defined in [types/src/index.ts:899](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L899)*
@@ -11128,7 +22311,7 @@ ___ • **bytecode**: *[SimpleEvmBytecodeOutput](#class-simpleevmbytecodeoutput)* -*Defined in [types/src/index.ts:871](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L871)* +*Defined in [types/src/index.ts:895](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L895)*
@@ -11141,7 +22324,7 @@ ___ • **abi**: *[ContractAbi](#contractabi)* -*Defined in [types/src/index.ts:865](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L865)* +*Defined in [types/src/index.ts:889](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L889)* ___ @@ -11149,7 +22332,7 @@ ___ • **devdoc**? : *[DevdocOutput](#class-devdocoutput)* -*Defined in [types/src/index.ts:867](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L867)* +*Defined in [types/src/index.ts:891](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L891)* ___ @@ -11157,7 +22340,7 @@ ___ • **evm**: *[SimpleEvmOutput](#class-simpleevmoutput)* -*Defined in [types/src/index.ts:866](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L866)* +*Defined in [types/src/index.ts:890](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L890)*
@@ -11206,7 +22389,7 @@ ZeroExTransaction for use with 0x Exchange executeTransaction • **data**: *string* -*Defined in [types/src/index.ts:49](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L49)* +*Defined in [types/src/index.ts:49](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L49)* ___ @@ -11214,7 +22397,7 @@ ___ • **domain**: *[EIP712DomainWithDefaultSchema](#class-eip712domainwithdefaultschema)* -*Defined in [types/src/index.ts:50](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L50)* +*Defined in [types/src/index.ts:50](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L50)* ___ @@ -11222,7 +22405,7 @@ ___ • **expirationTimeSeconds**: *`BigNumber`* -*Defined in [types/src/index.ts:46](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L46)* +*Defined in [types/src/index.ts:46](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L46)* ___ @@ -11230,7 +22413,7 @@ ___ • **gasPrice**: *`BigNumber`* -*Defined in [types/src/index.ts:47](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L47)* +*Defined in [types/src/index.ts:47](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L47)* ___ @@ -11238,7 +22421,7 @@ ___ • **salt**: *`BigNumber`* -*Defined in [types/src/index.ts:45](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L45)* +*Defined in [types/src/index.ts:45](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L45)* ___ @@ -11246,53 +22429,56 @@ ___ • **signerAddress**: *string* -*Defined in [types/src/index.ts:48](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L48)* +*Defined in [types/src/index.ts:48](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L48)*
- -## Type aliases - +
+## Type aliases +### CoordinatorRegistryEventArgs +Ƭ **CoordinatorRegistryEventArgs**: *[CoordinatorRegistryCoordinatorEndpointSetEventArgs](#interface-coordinatorregistrycoordinatorendpointseteventargs)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts:34](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts#L34)* +
-### EventCallback -Ƭ **EventCallback**: *function* +
-*Defined in [types/src/index.ts:848](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L848)* -#### Type declaration: -▸ (`err`: null | `Error`, `log?`: [DecodedLogEvent](#interface-decodedlogevent)‹*`ArgsType`*›): *void* -**Parameters:** +## Type aliases -Name | Type | ------- | ------ | -`err` | null \| `Error` | -`log?` | [DecodedLogEvent](#interface-decodedlogevent)‹*`ArgsType`*› | +### DummyERC20TokenEventArgs -___ +Ƭ **DummyERC20TokenEventArgs**: *[DummyERC20TokenApprovalEventArgs](#interface-dummyerc20tokenapprovaleventargs) | [DummyERC20TokenTransferEventArgs](#interface-dummyerc20tokentransfereventargs)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:34](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L34)* +
+## Type aliases +### DummyERC721TokenEventArgs +Ƭ **DummyERC721TokenEventArgs**: *[DummyERC721TokenApprovalEventArgs](#interface-dummyerc721tokenapprovaleventargs) | [DummyERC721TokenApprovalForAllEventArgs](#interface-dummyerc721tokenapprovalforalleventargs) | [DummyERC721TokenTransferEventArgs](#interface-dummyerc721tokentransfereventargs)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:34](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L34)* +
@@ -11303,28 +22489,24 @@ ___ ## Type aliases -### CoordinatorRegistryEventArgs +### ERC1155ProxyEventArgs -Ƭ **CoordinatorRegistryEventArgs**: *[CoordinatorRegistryCoordinatorEndpointSetEventArgs](#interface-coordinatorregistrycoordinatorendpointseteventargs)* +Ƭ **ERC1155ProxyEventArgs**: *[ERC1155ProxyAuthorizedAddressAddedEventArgs](#interface-erc1155proxyauthorizedaddressaddedeventargs) | [ERC1155ProxyAuthorizedAddressRemovedEventArgs](#interface-erc1155proxyauthorizedaddressremovedeventargs)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts:37](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts#L37)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts:34](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts#L34)*
-
- - - ## Type aliases -### DummyERC20TokenEventArgs +### ERC20ProxyEventArgs -Ƭ **DummyERC20TokenEventArgs**: *[DummyERC20TokenApprovalEventArgs](#interface-dummyerc20tokenapprovaleventargs) | [DummyERC20TokenTransferEventArgs](#interface-dummyerc20tokentransfereventargs)* +Ƭ **ERC20ProxyEventArgs**: *[ERC20ProxyAuthorizedAddressAddedEventArgs](#interface-erc20proxyauthorizedaddressaddedeventargs) | [ERC20ProxyAuthorizedAddressRemovedEventArgs](#interface-erc20proxyauthorizedaddressremovedeventargs)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts:37](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts#L37)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts:34](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts#L34)*
@@ -11333,11 +22515,11 @@ ___ ## Type aliases -### DummyERC721TokenEventArgs +### ERC20TokenEventArgs -Ƭ **DummyERC721TokenEventArgs**: *[DummyERC721TokenApprovalEventArgs](#interface-dummyerc721tokenapprovaleventargs) | [DummyERC721TokenApprovalForAllEventArgs](#interface-dummyerc721tokenapprovalforalleventargs) | [DummyERC721TokenTransferEventArgs](#interface-dummyerc721tokentransfereventargs)* +Ƭ **ERC20TokenEventArgs**: *[ERC20TokenTransferEventArgs](#interface-erc20tokentransfereventargs) | [ERC20TokenApprovalEventArgs](#interface-erc20tokenapprovaleventargs)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts:37](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts#L37)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:34](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L34)*
@@ -11346,11 +22528,11 @@ ___ ## Type aliases -### ERC20TokenEventArgs +### ERC721ProxyEventArgs -Ƭ **ERC20TokenEventArgs**: *[ERC20TokenTransferEventArgs](#interface-erc20tokentransfereventargs) | [ERC20TokenApprovalEventArgs](#interface-erc20tokenapprovaleventargs)* +Ƭ **ERC721ProxyEventArgs**: *[ERC721ProxyAuthorizedAddressAddedEventArgs](#interface-erc721proxyauthorizedaddressaddedeventargs) | [ERC721ProxyAuthorizedAddressRemovedEventArgs](#interface-erc721proxyauthorizedaddressremovedeventargs)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc20_token.ts:37](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts#L37)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts:34](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts#L34)*
@@ -11363,7 +22545,7 @@ ___ Ƭ **ERC721TokenEventArgs**: *[ERC721TokenApprovalEventArgs](#interface-erc721tokenapprovaleventargs) | [ERC721TokenApprovalForAllEventArgs](#interface-erc721tokenapprovalforalleventargs) | [ERC721TokenTransferEventArgs](#interface-erc721tokentransfereventargs)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:37](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L37)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/erc721_token.ts:34](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts#L34)*
@@ -11376,7 +22558,7 @@ ___ Ƭ **ExchangeEventArgs**: *[ExchangeAssetProxyRegisteredEventArgs](#interface-exchangeassetproxyregisteredeventargs) | [ExchangeCancelEventArgs](#interface-exchangecanceleventargs) | [ExchangeCancelUpToEventArgs](#interface-exchangecanceluptoeventargs) | [ExchangeFillEventArgs](#interface-exchangefilleventargs) | [ExchangeProtocolFeeCollectorAddressEventArgs](#interface-exchangeprotocolfeecollectoraddresseventargs) | [ExchangeProtocolFeeMultiplierEventArgs](#interface-exchangeprotocolfeemultipliereventargs) | [ExchangeSignatureValidatorApprovalEventArgs](#interface-exchangesignaturevalidatorapprovaleventargs) | [ExchangeTransactionExecutionEventArgs](#interface-exchangetransactionexecutioneventargs)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:37](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L37)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/exchange.ts:34](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts#L34)*
@@ -11405,7 +22587,7 @@ ___ Ƭ **WETH9EventArgs**: *[WETH9ApprovalEventArgs](#interface-weth9approvaleventargs) | [WETH9TransferEventArgs](#interface-weth9transfereventargs) | [WETH9DepositEventArgs](#interface-weth9depositeventargs) | [WETH9WithdrawalEventArgs](#interface-weth9withdrawaleventargs)* -*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:37](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L37)* +*Defined in [abi-gen-wrappers/src/generated-wrappers/weth9.ts:34](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts#L34)*
@@ -11414,7 +22596,13 @@ ___ ## Type aliases +### ZRXTokenEventArgs + +Ƭ **ZRXTokenEventArgs**: *[ZRXTokenTransferEventArgs](#interface-zrxtokentransfereventargs) | [ZRXTokenApprovalEventArgs](#interface-zrxtokenapprovaleventargs)* + +*Defined in [abi-gen-wrappers/src/generated-wrappers/zrx_token.ts:34](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts#L34)* +
@@ -11425,7 +22613,7 @@ ___ ▸ **getContractAddressesForChainOrThrow**(`chainId`: [ChainId](#enumeration-chainid)): *[ContractAddresses](#interface-contractaddresses)* -*Defined in [contract-addresses/src/index.ts:45](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L45)* +*Defined in [contract-addresses/src/index.ts:45](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L45)* Used to get addresses of contracts that have been deployed to either the Ethereum mainnet or a supported testnet. Throws if there are no known @@ -11465,7 +22653,7 @@ given chainId. Ƭ **AbiDefinition**: *[FunctionAbi](_ethereum_types_src_index_.md#functionabi) | [EventAbi](#interface-eventabi) | [RevertErrorAbi](#interface-reverterrorabi)* -*Defined in [ethereum-types/src/index.ts:80](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L80)* +*Defined in [ethereum-types/src/index.ts:80](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L80)* ___ @@ -11473,7 +22661,7 @@ ___ Ƭ **BlockParam**: *[BlockParamLiteral](#enumeration-blockparamliteral) | number* -*Defined in [ethereum-types/src/index.ts:483](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L483)* +*Defined in [ethereum-types/src/index.ts:483](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L483)* ___ @@ -11481,7 +22669,7 @@ ___ Ƭ **ConstructorStateMutability**: *"nonpayable" | "payable"* -*Defined in [ethereum-types/src/index.ts:84](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L84)* +*Defined in [ethereum-types/src/index.ts:84](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L84)* ___ @@ -11489,7 +22677,7 @@ ___ Ƭ **ContractAbi**: *[AbiDefinition](#abidefinition)[]* -*Defined in [ethereum-types/src/index.ts:78](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L78)* +*Defined in [ethereum-types/src/index.ts:78](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L78)* ___ @@ -11497,7 +22685,7 @@ ___ Ƭ **ContractEventArg**: *any* -*Defined in [ethereum-types/src/index.ts:468](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L468)* +*Defined in [ethereum-types/src/index.ts:468](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L468)* ___ @@ -11507,7 +22695,7 @@ ___ Ƭ **EIP1193Event**: *"accountsChanged" | "networkChanged" | "close" | "connect" | "notification"* -*Defined in [ethereum-types/src/index.ts:70](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L70)* +*Defined in [ethereum-types/src/index.ts:70](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L70)* Interface for providers that conform to EIP 1193 Source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1193.md @@ -11522,7 +22710,7 @@ ___ Ƭ **FunctionAbi**: *[MethodAbi](#interface-methodabi) | [ConstructorAbi](#interface-constructorabi) | [FallbackAbi](#interface-fallbackabi)* -*Defined in [ethereum-types/src/index.ts:82](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L82)* +*Defined in [ethereum-types/src/index.ts:82](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L82)* ___ @@ -11530,7 +22718,7 @@ ___ Ƭ **JSONRPCErrorCallback**: *function* -*Defined in [ethereum-types/src/index.ts:3](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L3)* +*Defined in [ethereum-types/src/index.ts:3](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L3)* #### Type declaration: @@ -11551,7 +22739,7 @@ ___ Ƭ **OutputField**: *"*" | "ast" | "legacyAST" | "abi" | "devdoc" | "userdoc" | "metadata" | "ir" | "evm.assembly" | "evm.legacyAssembly" | "evm.bytecode.object" | "evm.bytecode.opcodes" | "evm.bytecode.sourceMap" | "evm.bytecode.linkReferences" | "evm.deployedBytecode.object" | "evm.deployedBytecode.opcodes" | "evm.deployedBytecode.sourceMap" | "evm.deployedBytecode.linkReferences" | "evm.methodIdentifiers" | "evm.gasEstimates" | "ewasm.wast" | "ewasm.wasm"* -*Defined in [ethereum-types/src/index.ts:525](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L525)* +*Defined in [ethereum-types/src/index.ts:525](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L525)* ___ @@ -11559,7 +22747,7 @@ ___ Ƭ **ParamDescription**: *string* -*Defined in [ethereum-types/src/index.ts:561](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L561)* +*Defined in [ethereum-types/src/index.ts:561](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L561)* ___ @@ -11567,7 +22755,7 @@ ___ Ƭ **RawLog**: *[LogEntry](#interface-logentry)* -*Defined in [ethereum-types/src/index.ts:475](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L475)* +*Defined in [ethereum-types/src/index.ts:475](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L475)* ___ @@ -11575,7 +22763,7 @@ ___ Ƭ **StateMutability**: *"pure" | "view" | [ConstructorStateMutability](#constructorstatemutability)* -*Defined in [ethereum-types/src/index.ts:85](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L85)* +*Defined in [ethereum-types/src/index.ts:85](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L85)* ___ @@ -11583,7 +22771,7 @@ ___ Ƭ **SupportedProvider**: *[Web3JsProvider](_ethereum_types_src_index_.md#web3jsprovider) | [GanacheProvider](#interface-ganacheprovider) | [EIP1193Provider](#interface-eip1193provider) | [ZeroExProvider](#interface-zeroexprovider)* -*Defined in [ethereum-types/src/index.ts:9](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L9)* +*Defined in [ethereum-types/src/index.ts:9](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L9)* Do not create your own provider. Use an existing provider from a Web3 or ProviderEngine library Read more about Providers in the guides section of the 0x docs. @@ -11598,7 +22786,55 @@ ___ Ƭ **Web3JsProvider**: *[Web3JsV1Provider](#interface-web3jsv1provider) | [Web3JsV2Provider](#interface-web3jsv2provider) | [Web3JsV3Provider](#interface-web3jsv3provider)* -*Defined in [ethereum-types/src/index.ts:11](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L11)* +*Defined in [ethereum-types/src/index.ts:11](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L11)*
+ + + +## Type aliases + + + + + + + + + + + +### EventCallback + +Ƭ **EventCallback**: *function* + +*Defined in [types/src/index.ts:848](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L848)* + +#### Type declaration: + +▸ (`err`: null | `Error`, `log?`: [DecodedLogEvent](#interface-decodedlogevent)‹*`ArgsType`*›): *void* + +**Parameters:** + +Name | Type | +------ | ------ | +`err` | null \| `Error` | +`log?` | [DecodedLogEvent](#interface-decodedlogevent)‹*`ArgsType`*› | + +___ + + + + + + + + + + + + + +
+ diff --git a/packages/ethereum-types/docs/reference.mdx b/packages/ethereum-types/docs/reference.mdx index 25fea802b0..55d6545035 100644 --- a/packages/ethereum-types/docs/reference.mdx +++ b/packages/ethereum-types/docs/reference.mdx @@ -1,22 +1,37 @@ -# Interface: GanacheProvider +# Enumeration: AbiType -## Methods +## Enumeration members -### sendAsync +### Constructor -▸ **sendAsync**(`payload`: [JSONRPCRequestPayload](_index_.jsonrpcrequestpayload.md), `callback`: [JSONRPCErrorCallback](#jsonrpcerrorcallback)): *void* +• **Constructor**: = "constructor" -*Defined in [index.ts:14](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L14)* +*Defined in [index.ts:463](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L463)* -**Parameters:** +___ -Name | Type | ------- | ------ | -`payload` | [JSONRPCRequestPayload](#class-jsonrpcrequestpayload) | -`callback` | [JSONRPCErrorCallback](#jsonrpcerrorcallback) | +### Event -**Returns:** *void* +• **Event**: = "event" + +*Defined in [index.ts:464](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L464)* + +___ + +### Fallback + +• **Fallback**: = "fallback" + +*Defined in [index.ts:465](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L465)* + +___ + +### Function + +• **Function**: = "function" + +*Defined in [index.ts:462](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L462)*
@@ -29,7 +44,7 @@ Name | Type | • **Earliest**: = "earliest" -*Defined in [index.ts:478](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L478)* +*Defined in [index.ts:478](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L478)* ___ @@ -37,7 +52,7 @@ ___ • **Latest**: = "latest" -*Defined in [index.ts:479](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L479)* +*Defined in [index.ts:479](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L479)* ___ @@ -45,7 +60,7 @@ ___ • **Pending**: = "pending" -*Defined in [index.ts:480](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L480)* +*Defined in [index.ts:480](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L480)*
@@ -58,7 +73,7 @@ ___ • **Add**: = "ADD" -*Defined in [index.ts:147](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L147)* +*Defined in [index.ts:147](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L147)* ___ @@ -66,7 +81,7 @@ ___ • **AddMod**: = "ADDMOD" -*Defined in [index.ts:154](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L154)* +*Defined in [index.ts:154](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L154)* ___ @@ -74,7 +89,7 @@ ___ • **Address**: = "ADDRESS" -*Defined in [index.ts:173](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L173)* +*Defined in [index.ts:173](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L173)* ___ @@ -82,7 +97,7 @@ ___ • **And**: = "AND" -*Defined in [index.ts:165](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L165)* +*Defined in [index.ts:165](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L165)* ___ @@ -90,7 +105,7 @@ ___ • **Balance**: = "BALANCE" -*Defined in [index.ts:174](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L174)* +*Defined in [index.ts:174](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L174)* ___ @@ -98,7 +113,7 @@ ___ • **BlockHash**: = "BLOCKHASH" -*Defined in [index.ts:189](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L189)* +*Defined in [index.ts:189](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L189)* ___ @@ -106,7 +121,7 @@ ___ • **Byte**: = "BYTE" -*Defined in [index.ts:169](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L169)* +*Defined in [index.ts:169](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L169)* ___ @@ -114,7 +129,7 @@ ___ • **Call**: = "CALL" -*Defined in [index.ts:282](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L282)* +*Defined in [index.ts:282](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L282)* ___ @@ -122,7 +137,7 @@ ___ • **CallCode**: = "CALLCODE" -*Defined in [index.ts:283](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L283)* +*Defined in [index.ts:283](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L283)* ___ @@ -130,7 +145,7 @@ ___ • **CallDataCopy**: = "CALLDATACOPY" -*Defined in [index.ts:180](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L180)* +*Defined in [index.ts:180](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L180)* ___ @@ -138,7 +153,7 @@ ___ • **CallDataLoad**: = "CALLDATALOAD" -*Defined in [index.ts:178](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L178)* +*Defined in [index.ts:178](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L178)* ___ @@ -146,7 +161,7 @@ ___ • **CallDataSize**: = "CALLDATASIZE" -*Defined in [index.ts:179](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L179)* +*Defined in [index.ts:179](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L179)* ___ @@ -154,7 +169,7 @@ ___ • **CallValue**: = "CALLVALUE" -*Defined in [index.ts:177](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L177)* +*Defined in [index.ts:177](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L177)* ___ @@ -162,7 +177,7 @@ ___ • **Caller**: = "CALLER" -*Defined in [index.ts:176](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L176)* +*Defined in [index.ts:176](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L176)* ___ @@ -170,7 +185,7 @@ ___ • **CodeCopy**: = "CODECOPY" -*Defined in [index.ts:182](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L182)* +*Defined in [index.ts:182](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L182)* ___ @@ -178,7 +193,7 @@ ___ • **CodeSize**: = "CODESIZE" -*Defined in [index.ts:181](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L181)* +*Defined in [index.ts:181](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L181)* ___ @@ -186,7 +201,7 @@ ___ • **Coinbase**: = "COINBASE" -*Defined in [index.ts:190](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L190)* +*Defined in [index.ts:190](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L190)* ___ @@ -194,7 +209,7 @@ ___ • **Create**: = "CREATE" -*Defined in [index.ts:281](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L281)* +*Defined in [index.ts:281](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L281)* ___ @@ -202,7 +217,7 @@ ___ • **DelegateCall**: = "DELEGATECALL" -*Defined in [index.ts:285](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L285)* +*Defined in [index.ts:285](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L285)* ___ @@ -210,7 +225,7 @@ ___ • **Difficulty**: = "DIFFICULTY" -*Defined in [index.ts:193](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L193)* +*Defined in [index.ts:193](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L193)* ___ @@ -218,7 +233,7 @@ ___ • **Div**: = "DIV" -*Defined in [index.ts:150](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L150)* +*Defined in [index.ts:150](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L150)* ___ @@ -226,7 +241,7 @@ ___ • **Dup1**: = "DUP1" -*Defined in [index.ts:242](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L242)* +*Defined in [index.ts:242](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L242)* ___ @@ -234,7 +249,7 @@ ___ • **Dup10**: = "DUP10" -*Defined in [index.ts:251](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L251)* +*Defined in [index.ts:251](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L251)* ___ @@ -242,7 +257,7 @@ ___ • **Dup11**: = "DUP11" -*Defined in [index.ts:252](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L252)* +*Defined in [index.ts:252](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L252)* ___ @@ -250,7 +265,7 @@ ___ • **Dup12**: = "DUP12" -*Defined in [index.ts:253](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L253)* +*Defined in [index.ts:253](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L253)* ___ @@ -258,7 +273,7 @@ ___ • **Dup13**: = "DUP13" -*Defined in [index.ts:254](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L254)* +*Defined in [index.ts:254](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L254)* ___ @@ -266,7 +281,7 @@ ___ • **Dup14**: = "DUP14" -*Defined in [index.ts:255](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L255)* +*Defined in [index.ts:255](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L255)* ___ @@ -274,7 +289,7 @@ ___ • **Dup15**: = "DUP15" -*Defined in [index.ts:256](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L256)* +*Defined in [index.ts:256](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L256)* ___ @@ -282,7 +297,7 @@ ___ • **Dup16**: = "DUP16" -*Defined in [index.ts:257](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L257)* +*Defined in [index.ts:257](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L257)* ___ @@ -290,7 +305,7 @@ ___ • **Dup2**: = "DUP2" -*Defined in [index.ts:243](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L243)* +*Defined in [index.ts:243](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L243)* ___ @@ -298,7 +313,7 @@ ___ • **Dup3**: = "DUP3" -*Defined in [index.ts:244](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L244)* +*Defined in [index.ts:244](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L244)* ___ @@ -306,7 +321,7 @@ ___ • **Dup4**: = "DUP4" -*Defined in [index.ts:245](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L245)* +*Defined in [index.ts:245](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L245)* ___ @@ -314,7 +329,7 @@ ___ • **Dup5**: = "DUP5" -*Defined in [index.ts:246](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L246)* +*Defined in [index.ts:246](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L246)* ___ @@ -322,7 +337,7 @@ ___ • **Dup6**: = "DUP6" -*Defined in [index.ts:247](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L247)* +*Defined in [index.ts:247](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L247)* ___ @@ -330,7 +345,7 @@ ___ • **Dup7**: = "DUP7" -*Defined in [index.ts:248](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L248)* +*Defined in [index.ts:248](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L248)* ___ @@ -338,7 +353,7 @@ ___ • **Dup8**: = "DUP8" -*Defined in [index.ts:249](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L249)* +*Defined in [index.ts:249](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L249)* ___ @@ -346,7 +361,7 @@ ___ • **Dup9**: = "DUP9" -*Defined in [index.ts:250](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L250)* +*Defined in [index.ts:250](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L250)* ___ @@ -354,7 +369,7 @@ ___ • **Eq**: = "EQ" -*Defined in [index.ts:163](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L163)* +*Defined in [index.ts:163](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L163)* ___ @@ -362,7 +377,7 @@ ___ • **Exp**: = "EXP" -*Defined in [index.ts:156](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L156)* +*Defined in [index.ts:156](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L156)* ___ @@ -370,7 +385,7 @@ ___ • **ExtCodeCopy**: = "EXTCODECOPY" -*Defined in [index.ts:185](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L185)* +*Defined in [index.ts:185](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L185)* ___ @@ -378,7 +393,7 @@ ___ • **ExtCodeSize**: = "EXTCODESIZE" -*Defined in [index.ts:184](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L184)* +*Defined in [index.ts:184](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L184)* ___ @@ -386,7 +401,7 @@ ___ • **Gas**: = "GAS" -*Defined in [index.ts:206](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L206)* +*Defined in [index.ts:206](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L206)* ___ @@ -394,7 +409,7 @@ ___ • **GasPrice**: = "GASPRICE" -*Defined in [index.ts:183](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L183)* +*Defined in [index.ts:183](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L183)* ___ @@ -402,7 +417,7 @@ ___ • **Gaslimit**: = "GASLIMIT" -*Defined in [index.ts:194](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L194)* +*Defined in [index.ts:194](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L194)* ___ @@ -410,7 +425,7 @@ ___ • **Gt**: = "GT" -*Defined in [index.ts:160](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L160)* +*Defined in [index.ts:160](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L160)* ___ @@ -418,7 +433,7 @@ ___ • **Invalid**: = "INVALID" -*Defined in [index.ts:288](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L288)* +*Defined in [index.ts:288](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L288)* ___ @@ -426,7 +441,7 @@ ___ • **IsZero**: = "ISZERO" -*Defined in [index.ts:164](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L164)* +*Defined in [index.ts:164](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L164)* ___ @@ -434,7 +449,7 @@ ___ • **Jump**: = "JUMP" -*Defined in [index.ts:202](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L202)* +*Defined in [index.ts:202](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L202)* ___ @@ -442,7 +457,7 @@ ___ • **JumpDest**: = "JUMPDEST" -*Defined in [index.ts:207](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L207)* +*Defined in [index.ts:207](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L207)* ___ @@ -450,7 +465,7 @@ ___ • **Jumpi**: = "JUMPI" -*Defined in [index.ts:203](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L203)* +*Defined in [index.ts:203](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L203)* ___ @@ -458,7 +473,7 @@ ___ • **Log1**: = "LOG1" -*Defined in [index.ts:276](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L276)* +*Defined in [index.ts:276](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L276)* ___ @@ -466,7 +481,7 @@ ___ • **Log2**: = "LOG2" -*Defined in [index.ts:277](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L277)* +*Defined in [index.ts:277](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L277)* ___ @@ -474,7 +489,7 @@ ___ • **Log3**: = "LOG3" -*Defined in [index.ts:278](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L278)* +*Defined in [index.ts:278](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L278)* ___ @@ -482,7 +497,7 @@ ___ • **Log4**: = "LOG4" -*Defined in [index.ts:279](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L279)* +*Defined in [index.ts:279](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L279)* ___ @@ -490,7 +505,7 @@ ___ • **Lt**: = "LT" -*Defined in [index.ts:159](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L159)* +*Defined in [index.ts:159](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L159)* ___ @@ -498,7 +513,7 @@ ___ • **MLoad**: = "MLOAD" -*Defined in [index.ts:197](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L197)* +*Defined in [index.ts:197](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L197)* ___ @@ -506,7 +521,7 @@ ___ • **MSize**: = "MSIZE" -*Defined in [index.ts:205](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L205)* +*Defined in [index.ts:205](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L205)* ___ @@ -514,7 +529,7 @@ ___ • **MStore**: = "MSTORE" -*Defined in [index.ts:198](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L198)* +*Defined in [index.ts:198](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L198)* ___ @@ -522,7 +537,7 @@ ___ • **MStore8**: = "MSTORE8" -*Defined in [index.ts:199](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L199)* +*Defined in [index.ts:199](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L199)* ___ @@ -530,7 +545,7 @@ ___ • **Mod**: = "MOD" -*Defined in [index.ts:152](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L152)* +*Defined in [index.ts:152](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L152)* ___ @@ -538,7 +553,7 @@ ___ • **Mul**: = "MUL" -*Defined in [index.ts:148](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L148)* +*Defined in [index.ts:148](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L148)* ___ @@ -546,7 +561,7 @@ ___ • **MulMod**: = "MULMOD" -*Defined in [index.ts:155](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L155)* +*Defined in [index.ts:155](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L155)* ___ @@ -554,7 +569,7 @@ ___ • **Not**: = "NOT" -*Defined in [index.ts:168](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L168)* +*Defined in [index.ts:168](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L168)* ___ @@ -562,7 +577,7 @@ ___ • **Number**: = "NUMBER" -*Defined in [index.ts:192](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L192)* +*Defined in [index.ts:192](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L192)* ___ @@ -570,7 +585,7 @@ ___ • **Or**: = "OR" -*Defined in [index.ts:166](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L166)* +*Defined in [index.ts:166](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L166)* ___ @@ -578,7 +593,7 @@ ___ • **Origin**: = "ORIGIN" -*Defined in [index.ts:175](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L175)* +*Defined in [index.ts:175](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L175)* ___ @@ -586,7 +601,7 @@ ___ • **Pc**: = "PC" -*Defined in [index.ts:204](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L204)* +*Defined in [index.ts:204](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L204)* ___ @@ -594,7 +609,7 @@ ___ • **Pop**: = "POP" -*Defined in [index.ts:196](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L196)* +*Defined in [index.ts:196](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L196)* ___ @@ -602,7 +617,7 @@ ___ • **Push1**: = "PUSH1" -*Defined in [index.ts:209](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L209)* +*Defined in [index.ts:209](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L209)* ___ @@ -610,7 +625,7 @@ ___ • **Push10**: = "PUSH10" -*Defined in [index.ts:218](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L218)* +*Defined in [index.ts:218](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L218)* ___ @@ -618,7 +633,7 @@ ___ • **Push11**: = "PUSH11" -*Defined in [index.ts:219](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L219)* +*Defined in [index.ts:219](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L219)* ___ @@ -626,7 +641,7 @@ ___ • **Push12**: = "PUSH12" -*Defined in [index.ts:220](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L220)* +*Defined in [index.ts:220](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L220)* ___ @@ -634,7 +649,7 @@ ___ • **Push13**: = "PUSH13" -*Defined in [index.ts:221](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L221)* +*Defined in [index.ts:221](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L221)* ___ @@ -642,7 +657,7 @@ ___ • **Push14**: = "PUSH14" -*Defined in [index.ts:222](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L222)* +*Defined in [index.ts:222](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L222)* ___ @@ -650,7 +665,7 @@ ___ • **Push15**: = "PUSH15" -*Defined in [index.ts:223](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L223)* +*Defined in [index.ts:223](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L223)* ___ @@ -658,7 +673,7 @@ ___ • **Push16**: = "PUSH16" -*Defined in [index.ts:224](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L224)* +*Defined in [index.ts:224](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L224)* ___ @@ -666,7 +681,7 @@ ___ • **Push17**: = "PUSH17" -*Defined in [index.ts:225](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L225)* +*Defined in [index.ts:225](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L225)* ___ @@ -674,7 +689,7 @@ ___ • **Push18**: = "PUSH18" -*Defined in [index.ts:226](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L226)* +*Defined in [index.ts:226](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L226)* ___ @@ -682,7 +697,7 @@ ___ • **Push19**: = "PUSH19" -*Defined in [index.ts:227](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L227)* +*Defined in [index.ts:227](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L227)* ___ @@ -690,7 +705,7 @@ ___ • **Push2**: = "PUSH2" -*Defined in [index.ts:210](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L210)* +*Defined in [index.ts:210](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L210)* ___ @@ -698,7 +713,7 @@ ___ • **Push20**: = "PUSH20" -*Defined in [index.ts:228](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L228)* +*Defined in [index.ts:228](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L228)* ___ @@ -706,7 +721,7 @@ ___ • **Push21**: = "PUSH21" -*Defined in [index.ts:229](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L229)* +*Defined in [index.ts:229](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L229)* ___ @@ -714,7 +729,7 @@ ___ • **Push22**: = "PUSH22" -*Defined in [index.ts:230](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L230)* +*Defined in [index.ts:230](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L230)* ___ @@ -722,7 +737,7 @@ ___ • **Push23**: = "PUSH23" -*Defined in [index.ts:231](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L231)* +*Defined in [index.ts:231](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L231)* ___ @@ -730,7 +745,7 @@ ___ • **Push24**: = "PUSH24" -*Defined in [index.ts:232](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L232)* +*Defined in [index.ts:232](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L232)* ___ @@ -738,7 +753,7 @@ ___ • **Push25**: = "PUSH25" -*Defined in [index.ts:233](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L233)* +*Defined in [index.ts:233](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L233)* ___ @@ -746,7 +761,7 @@ ___ • **Push26**: = "PUSH26" -*Defined in [index.ts:234](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L234)* +*Defined in [index.ts:234](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L234)* ___ @@ -754,7 +769,7 @@ ___ • **Push27**: = "PUSH27" -*Defined in [index.ts:235](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L235)* +*Defined in [index.ts:235](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L235)* ___ @@ -762,7 +777,7 @@ ___ • **Push28**: = "PUSH28" -*Defined in [index.ts:236](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L236)* +*Defined in [index.ts:236](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L236)* ___ @@ -770,7 +785,7 @@ ___ • **Push29**: = "PUSH29" -*Defined in [index.ts:237](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L237)* +*Defined in [index.ts:237](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L237)* ___ @@ -778,7 +793,7 @@ ___ • **Push3**: = "PUSH3" -*Defined in [index.ts:211](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L211)* +*Defined in [index.ts:211](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L211)* ___ @@ -786,7 +801,7 @@ ___ • **Push30**: = "PUSH30" -*Defined in [index.ts:238](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L238)* +*Defined in [index.ts:238](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L238)* ___ @@ -794,7 +809,7 @@ ___ • **Push31**: = "PUSH31" -*Defined in [index.ts:239](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L239)* +*Defined in [index.ts:239](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L239)* ___ @@ -802,7 +817,7 @@ ___ • **Push32**: = "PUSH32" -*Defined in [index.ts:240](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L240)* +*Defined in [index.ts:240](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L240)* ___ @@ -810,7 +825,7 @@ ___ • **Push4**: = "PUSH4" -*Defined in [index.ts:212](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L212)* +*Defined in [index.ts:212](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L212)* ___ @@ -818,7 +833,7 @@ ___ • **Push5**: = "PUSH5" -*Defined in [index.ts:213](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L213)* +*Defined in [index.ts:213](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L213)* ___ @@ -826,7 +841,7 @@ ___ • **Push6**: = "PUSH6" -*Defined in [index.ts:214](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L214)* +*Defined in [index.ts:214](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L214)* ___ @@ -834,7 +849,7 @@ ___ • **Push7**: = "PUSH7" -*Defined in [index.ts:215](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L215)* +*Defined in [index.ts:215](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L215)* ___ @@ -842,7 +857,7 @@ ___ • **Push8**: = "PUSH8" -*Defined in [index.ts:216](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L216)* +*Defined in [index.ts:216](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L216)* ___ @@ -850,7 +865,7 @@ ___ • **Push9**: = "PUSH9" -*Defined in [index.ts:217](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L217)* +*Defined in [index.ts:217](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L217)* ___ @@ -858,7 +873,7 @@ ___ • **Return**: = "RETURN" -*Defined in [index.ts:284](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L284)* +*Defined in [index.ts:284](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L284)* ___ @@ -866,7 +881,7 @@ ___ • **ReturnDataCopy**: = "RETURNDATACOPY" -*Defined in [index.ts:187](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L187)* +*Defined in [index.ts:187](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L187)* ___ @@ -874,7 +889,7 @@ ___ • **ReturnDataSize**: = "RETURNDATASIZE" -*Defined in [index.ts:186](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L186)* +*Defined in [index.ts:186](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L186)* ___ @@ -882,7 +897,7 @@ ___ • **Revert**: = "REVERT" -*Defined in [index.ts:287](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L287)* +*Defined in [index.ts:287](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L287)* ___ @@ -890,7 +905,7 @@ ___ • **SDiv**: = "SDIV" -*Defined in [index.ts:151](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L151)* +*Defined in [index.ts:151](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L151)* ___ @@ -898,7 +913,7 @@ ___ • **SGt**: = "SGT" -*Defined in [index.ts:162](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L162)* +*Defined in [index.ts:162](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L162)* ___ @@ -906,7 +921,7 @@ ___ • **SLoad**: = "SLOAD" -*Defined in [index.ts:200](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L200)* +*Defined in [index.ts:200](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L200)* ___ @@ -914,7 +929,7 @@ ___ • **SLt**: = "SLT" -*Defined in [index.ts:161](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L161)* +*Defined in [index.ts:161](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L161)* ___ @@ -922,7 +937,7 @@ ___ • **SMod**: = "SMOD" -*Defined in [index.ts:153](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L153)* +*Defined in [index.ts:153](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L153)* ___ @@ -930,7 +945,7 @@ ___ • **SStore**: = "SSTORE" -*Defined in [index.ts:201](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L201)* +*Defined in [index.ts:201](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L201)* ___ @@ -938,7 +953,7 @@ ___ • **SelfDestruct**: = "SELFDESTRUCT" -*Defined in [index.ts:289](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L289)* +*Defined in [index.ts:289](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L289)* ___ @@ -946,7 +961,7 @@ ___ • **Sha3**: = "SHA3" -*Defined in [index.ts:171](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L171)* +*Defined in [index.ts:171](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L171)* ___ @@ -954,7 +969,7 @@ ___ • **SignExtend**: = "SIGNEXTEND" -*Defined in [index.ts:157](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L157)* +*Defined in [index.ts:157](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L157)* ___ @@ -962,7 +977,7 @@ ___ • **StaticCall**: = "STATICCALL" -*Defined in [index.ts:286](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L286)* +*Defined in [index.ts:286](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L286)* ___ @@ -970,7 +985,7 @@ ___ • **Stop**: = "STOP" -*Defined in [index.ts:146](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L146)* +*Defined in [index.ts:146](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L146)* ___ @@ -978,7 +993,7 @@ ___ • **Sub**: = "SUB" -*Defined in [index.ts:149](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L149)* +*Defined in [index.ts:149](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L149)* ___ @@ -986,7 +1001,7 @@ ___ • **Swap1**: = "SWAP1" -*Defined in [index.ts:259](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L259)* +*Defined in [index.ts:259](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L259)* ___ @@ -994,7 +1009,7 @@ ___ • **Swap10**: = "SWAP10" -*Defined in [index.ts:268](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L268)* +*Defined in [index.ts:268](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L268)* ___ @@ -1002,7 +1017,7 @@ ___ • **Swap11**: = "SWAP11" -*Defined in [index.ts:269](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L269)* +*Defined in [index.ts:269](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L269)* ___ @@ -1010,7 +1025,7 @@ ___ • **Swap12**: = "SWAP12" -*Defined in [index.ts:270](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L270)* +*Defined in [index.ts:270](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L270)* ___ @@ -1018,7 +1033,7 @@ ___ • **Swap13**: = "SWAP13" -*Defined in [index.ts:271](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L271)* +*Defined in [index.ts:271](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L271)* ___ @@ -1026,7 +1041,7 @@ ___ • **Swap14**: = "SWAP14" -*Defined in [index.ts:272](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L272)* +*Defined in [index.ts:272](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L272)* ___ @@ -1034,7 +1049,7 @@ ___ • **Swap15**: = "SWAP15" -*Defined in [index.ts:273](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L273)* +*Defined in [index.ts:273](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L273)* ___ @@ -1042,7 +1057,7 @@ ___ • **Swap16**: = "SWAP16" -*Defined in [index.ts:274](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L274)* +*Defined in [index.ts:274](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L274)* ___ @@ -1050,7 +1065,7 @@ ___ • **Swap2**: = "SWAP2" -*Defined in [index.ts:260](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L260)* +*Defined in [index.ts:260](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L260)* ___ @@ -1058,7 +1073,7 @@ ___ • **Swap3**: = "SWAP3" -*Defined in [index.ts:261](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L261)* +*Defined in [index.ts:261](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L261)* ___ @@ -1066,7 +1081,7 @@ ___ • **Swap4**: = "SWAP4" -*Defined in [index.ts:262](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L262)* +*Defined in [index.ts:262](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L262)* ___ @@ -1074,7 +1089,7 @@ ___ • **Swap5**: = "SWAP5" -*Defined in [index.ts:263](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L263)* +*Defined in [index.ts:263](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L263)* ___ @@ -1082,7 +1097,7 @@ ___ • **Swap6**: = "SWAP6" -*Defined in [index.ts:264](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L264)* +*Defined in [index.ts:264](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L264)* ___ @@ -1090,7 +1105,7 @@ ___ • **Swap7**: = "SWAP7" -*Defined in [index.ts:265](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L265)* +*Defined in [index.ts:265](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L265)* ___ @@ -1098,7 +1113,7 @@ ___ • **Swap8**: = "SWAP8" -*Defined in [index.ts:266](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L266)* +*Defined in [index.ts:266](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L266)* ___ @@ -1106,7 +1121,7 @@ ___ • **Swap9**: = "SWAP9" -*Defined in [index.ts:267](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L267)* +*Defined in [index.ts:267](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L267)* ___ @@ -1114,7 +1129,7 @@ ___ • **TimeStamp**: = "TimeStamp" -*Defined in [index.ts:191](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L191)* +*Defined in [index.ts:191](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L191)* ___ @@ -1122,7 +1137,7 @@ ___ • **Xor**: = "XOR" -*Defined in [index.ts:167](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L167)* +*Defined in [index.ts:167](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L167)*
@@ -1135,7 +1150,7 @@ ___ • **Address**: = "address" -*Defined in [index.ts:497](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L497)* +*Defined in [index.ts:497](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L497)* ___ @@ -1143,7 +1158,7 @@ ___ • **Bool**: = "bool" -*Defined in [index.ts:498](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L498)* +*Defined in [index.ts:498](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L498)* ___ @@ -1151,7 +1166,7 @@ ___ • **Bytes**: = "bytes" -*Defined in [index.ts:499](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L499)* +*Defined in [index.ts:499](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L499)* ___ @@ -1159,7 +1174,7 @@ ___ • **Int**: = "int" -*Defined in [index.ts:500](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L500)* +*Defined in [index.ts:500](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L500)* ___ @@ -1167,7 +1182,7 @@ ___ • **String**: = "string" -*Defined in [index.ts:501](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L501)* +*Defined in [index.ts:501](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L501)* ___ @@ -1175,7 +1190,7 @@ ___ • **Tuple**: = "tuple" -*Defined in [index.ts:502](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L502)* +*Defined in [index.ts:502](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L502)* ___ @@ -1183,7 +1198,7 @@ ___ • **Uint**: = "uint" -*Defined in [index.ts:505](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L505)* +*Defined in [index.ts:505](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L505)* ___ @@ -1191,7 +1206,7 @@ ___ • **Uint256**: = "uint256" -*Defined in [index.ts:503](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L503)* +*Defined in [index.ts:503](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L503)* ___ @@ -1199,7 +1214,7 @@ ___ • **Uint8**: = "uint8" -*Defined in [index.ts:504](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L504)* +*Defined in [index.ts:504](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L504)*
@@ -1212,7 +1227,7 @@ ___ • **difficulty**: *`BigNumber`* -*Defined in [index.ts:356](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L356)* +*Defined in [index.ts:356](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L356)* ___ @@ -1220,7 +1235,7 @@ ___ • **extraData**: *string* -*Defined in [index.ts:358](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L358)* +*Defined in [index.ts:358](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L358)* ___ @@ -1228,7 +1243,7 @@ ___ • **gasLimit**: *number* -*Defined in [index.ts:360](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L360)* +*Defined in [index.ts:360](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L360)* ___ @@ -1236,7 +1251,7 @@ ___ • **gasUsed**: *number* -*Defined in [index.ts:361](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L361)* +*Defined in [index.ts:361](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L361)* ___ @@ -1244,7 +1259,7 @@ ___ • **hash**: *string | null* -*Defined in [index.ts:348](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L348)* +*Defined in [index.ts:348](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L348)* ___ @@ -1252,7 +1267,7 @@ ___ • **logsBloom**: *string | null* -*Defined in [index.ts:352](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L352)* +*Defined in [index.ts:352](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L352)* ___ @@ -1260,7 +1275,7 @@ ___ • **miner**: *string* -*Defined in [index.ts:355](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L355)* +*Defined in [index.ts:355](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L355)* ___ @@ -1268,7 +1283,7 @@ ___ • **nonce**: *string | null* -*Defined in [index.ts:350](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L350)* +*Defined in [index.ts:350](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L350)* ___ @@ -1276,7 +1291,7 @@ ___ • **number**: *number | null* -*Defined in [index.ts:347](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L347)* +*Defined in [index.ts:347](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L347)* ___ @@ -1284,7 +1299,7 @@ ___ • **parentHash**: *string* -*Defined in [index.ts:349](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L349)* +*Defined in [index.ts:349](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L349)* ___ @@ -1292,7 +1307,7 @@ ___ • **sha3Uncles**: *string* -*Defined in [index.ts:351](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L351)* +*Defined in [index.ts:351](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L351)* ___ @@ -1300,7 +1315,7 @@ ___ • **size**: *number* -*Defined in [index.ts:359](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L359)* +*Defined in [index.ts:359](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L359)* ___ @@ -1308,7 +1323,7 @@ ___ • **stateRoot**: *string* -*Defined in [index.ts:354](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L354)* +*Defined in [index.ts:354](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L354)* ___ @@ -1316,7 +1331,7 @@ ___ • **timestamp**: *number* -*Defined in [index.ts:362](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L362)* +*Defined in [index.ts:362](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L362)* ___ @@ -1324,7 +1339,7 @@ ___ • **totalDifficulty**: *`BigNumber`* -*Defined in [index.ts:357](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L357)* +*Defined in [index.ts:357](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L357)* ___ @@ -1332,7 +1347,7 @@ ___ • **transactionsRoot**: *string* -*Defined in [index.ts:353](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L353)* +*Defined in [index.ts:353](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L353)* ___ @@ -1340,7 +1355,7 @@ ___ • **uncles**: *string[]* -*Defined in [index.ts:363](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L363)* +*Defined in [index.ts:363](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L363)*
@@ -1353,7 +1368,7 @@ ___ • **fromBlock**: *[BlockParam](#blockparam)* -*Defined in [index.ts:742](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L742)* +*Defined in [index.ts:740](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L740)* ___ @@ -1361,7 +1376,7 @@ ___ • **toBlock**: *[BlockParam](#blockparam)* -*Defined in [index.ts:743](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L743)* +*Defined in [index.ts:741](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L741)*
@@ -1376,7 +1391,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[difficulty](#difficulty)* -*Defined in [index.ts:356](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L356)* +*Defined in [index.ts:356](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L356)* ___ @@ -1386,7 +1401,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[extraData](#extradata)* -*Defined in [index.ts:358](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L358)* +*Defined in [index.ts:358](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L358)* ___ @@ -1396,7 +1411,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[gasLimit](#gaslimit)* -*Defined in [index.ts:360](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L360)* +*Defined in [index.ts:360](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L360)* ___ @@ -1406,7 +1421,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[gasUsed](#gasused)* -*Defined in [index.ts:361](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L361)* +*Defined in [index.ts:361](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L361)* ___ @@ -1416,7 +1431,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[hash](#hash)* -*Defined in [index.ts:348](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L348)* +*Defined in [index.ts:348](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L348)* ___ @@ -1426,7 +1441,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[logsBloom](#logsbloom)* -*Defined in [index.ts:352](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L352)* +*Defined in [index.ts:352](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L352)* ___ @@ -1436,7 +1451,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[miner](#miner)* -*Defined in [index.ts:355](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L355)* +*Defined in [index.ts:355](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L355)* ___ @@ -1446,7 +1461,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[nonce](#nonce)* -*Defined in [index.ts:350](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L350)* +*Defined in [index.ts:350](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L350)* ___ @@ -1456,7 +1471,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[number](#number)* -*Defined in [index.ts:347](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L347)* +*Defined in [index.ts:347](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L347)* ___ @@ -1466,7 +1481,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[parentHash](#parenthash)* -*Defined in [index.ts:349](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L349)* +*Defined in [index.ts:349](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L349)* ___ @@ -1476,7 +1491,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[sha3Uncles](#sha3uncles)* -*Defined in [index.ts:351](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L351)* +*Defined in [index.ts:351](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L351)* ___ @@ -1486,7 +1501,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[size](#size)* -*Defined in [index.ts:359](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L359)* +*Defined in [index.ts:359](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L359)* ___ @@ -1496,7 +1511,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[stateRoot](#stateroot)* -*Defined in [index.ts:354](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L354)* +*Defined in [index.ts:354](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L354)* ___ @@ -1506,7 +1521,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[timestamp](#timestamp)* -*Defined in [index.ts:362](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L362)* +*Defined in [index.ts:362](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L362)* ___ @@ -1516,7 +1531,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[totalDifficulty](#totaldifficulty)* -*Defined in [index.ts:357](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L357)* +*Defined in [index.ts:357](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L357)* ___ @@ -1524,7 +1539,7 @@ ___ • **transactions**: *string[]* -*Defined in [index.ts:367](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L367)* +*Defined in [index.ts:367](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L367)* ___ @@ -1534,7 +1549,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[transactionsRoot](#transactionsroot)* -*Defined in [index.ts:353](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L353)* +*Defined in [index.ts:353](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L353)* ___ @@ -1544,7 +1559,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[uncles](#uncles)* -*Defined in [index.ts:363](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L363)* +*Defined in [index.ts:363](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L363)*
@@ -1559,7 +1574,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[difficulty](#difficulty)* -*Defined in [index.ts:356](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L356)* +*Defined in [index.ts:356](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L356)* ___ @@ -1569,7 +1584,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[extraData](#extradata)* -*Defined in [index.ts:358](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L358)* +*Defined in [index.ts:358](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L358)* ___ @@ -1579,7 +1594,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[gasLimit](#gaslimit)* -*Defined in [index.ts:360](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L360)* +*Defined in [index.ts:360](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L360)* ___ @@ -1589,7 +1604,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[gasUsed](#gasused)* -*Defined in [index.ts:361](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L361)* +*Defined in [index.ts:361](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L361)* ___ @@ -1599,7 +1614,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[hash](#hash)* -*Defined in [index.ts:348](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L348)* +*Defined in [index.ts:348](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L348)* ___ @@ -1609,7 +1624,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[logsBloom](#logsbloom)* -*Defined in [index.ts:352](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L352)* +*Defined in [index.ts:352](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L352)* ___ @@ -1619,7 +1634,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[miner](#miner)* -*Defined in [index.ts:355](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L355)* +*Defined in [index.ts:355](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L355)* ___ @@ -1629,7 +1644,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[nonce](#nonce)* -*Defined in [index.ts:350](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L350)* +*Defined in [index.ts:350](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L350)* ___ @@ -1639,7 +1654,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[number](#number)* -*Defined in [index.ts:347](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L347)* +*Defined in [index.ts:347](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L347)* ___ @@ -1649,7 +1664,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[parentHash](#parenthash)* -*Defined in [index.ts:349](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L349)* +*Defined in [index.ts:349](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L349)* ___ @@ -1659,7 +1674,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[sha3Uncles](#sha3uncles)* -*Defined in [index.ts:351](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L351)* +*Defined in [index.ts:351](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L351)* ___ @@ -1669,7 +1684,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[size](#size)* -*Defined in [index.ts:359](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L359)* +*Defined in [index.ts:359](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L359)* ___ @@ -1679,7 +1694,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[stateRoot](#stateroot)* -*Defined in [index.ts:354](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L354)* +*Defined in [index.ts:354](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L354)* ___ @@ -1689,7 +1704,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[timestamp](#timestamp)* -*Defined in [index.ts:362](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L362)* +*Defined in [index.ts:362](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L362)* ___ @@ -1699,7 +1714,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[totalDifficulty](#totaldifficulty)* -*Defined in [index.ts:357](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L357)* +*Defined in [index.ts:357](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L357)* ___ @@ -1707,7 +1722,7 @@ ___ • **transactions**: *[Transaction](#class-transaction)[]* -*Defined in [index.ts:371](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L371)* +*Defined in [index.ts:371](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L371)* ___ @@ -1717,7 +1732,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[transactionsRoot](#transactionsroot)* -*Defined in [index.ts:353](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L353)* +*Defined in [index.ts:353](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L353)* ___ @@ -1727,7 +1742,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[uncles](#uncles)* -*Defined in [index.ts:363](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L363)* +*Defined in [index.ts:363](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L363)*
@@ -1742,7 +1757,7 @@ ___ *Inherited from [CallTxDataBase](#interface-calltxdatabase).[data](#optional-data)* -*Defined in [index.ts:393](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L393)* +*Defined in [index.ts:393](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L393)* ___ @@ -1750,7 +1765,7 @@ ___ • **from**? : *undefined | string* -*Defined in [index.ts:402](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L402)* +*Defined in [index.ts:402](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L402)* ___ @@ -1760,7 +1775,7 @@ ___ *Inherited from [CallTxDataBase](#interface-calltxdatabase).[gas](#optional-gas)* -*Defined in [index.ts:391](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L391)* +*Defined in [index.ts:391](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L391)* ___ @@ -1770,7 +1785,7 @@ ___ *Inherited from [CallTxDataBase](#interface-calltxdatabase).[gasPrice](#optional-gasprice)* -*Defined in [index.ts:392](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L392)* +*Defined in [index.ts:392](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L392)* ___ @@ -1780,7 +1795,7 @@ ___ *Inherited from [CallTxDataBase](#interface-calltxdatabase).[nonce](#optional-nonce)* -*Defined in [index.ts:394](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L394)* +*Defined in [index.ts:394](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L394)* ___ @@ -1790,7 +1805,7 @@ ___ *Inherited from [CallTxDataBase](#interface-calltxdatabase).[to](#optional-to)* -*Defined in [index.ts:389](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L389)* +*Defined in [index.ts:389](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L389)* ___ @@ -1800,7 +1815,7 @@ ___ *Inherited from [CallTxDataBase](#interface-calltxdatabase).[value](#optional-value)* -*Defined in [index.ts:390](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L390)* +*Defined in [index.ts:390](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L390)*
@@ -1813,7 +1828,7 @@ ___ • **data**? : *undefined | string* -*Defined in [index.ts:393](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L393)* +*Defined in [index.ts:393](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L393)* ___ @@ -1821,7 +1836,7 @@ ___ • **gas**? : *number | string | `BigNumber`* -*Defined in [index.ts:391](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L391)* +*Defined in [index.ts:391](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L391)* ___ @@ -1829,7 +1844,7 @@ ___ • **gasPrice**? : *number | string | `BigNumber`* -*Defined in [index.ts:392](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L392)* +*Defined in [index.ts:392](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L392)* ___ @@ -1837,7 +1852,7 @@ ___ • **nonce**? : *undefined | number* -*Defined in [index.ts:394](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L394)* +*Defined in [index.ts:394](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L394)* ___ @@ -1845,7 +1860,7 @@ ___ • **to**? : *undefined | string* -*Defined in [index.ts:389](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L389)* +*Defined in [index.ts:389](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L389)* ___ @@ -1853,7 +1868,7 @@ ___ • **value**? : *number | string | `BigNumber`* -*Defined in [index.ts:390](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L390)* +*Defined in [index.ts:390](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L390)*
@@ -1870,7 +1885,6 @@ useDockerisedSolc: If set to true - sol-compiler will try calling a dockerized i isOfflineMode: If set to true - sol-compiler will not fetch the list of solc releases from github. It will use the hardcoded list. Defaults to false. solcVersion: If you don't want to compile each contract with the Solidity version specified in-file, you can force all contracts to compile with the the version specified here. -shouldSaveStandardInput: Write the standard JSON input in ${contractsDir}/${contractName}.input.json ## Properties @@ -1879,7 +1893,7 @@ shouldSaveStandardInput: Write the standard JSON input in ${contractsDir}/${cont • **artifactsDir**? : *undefined | string* -*Defined in [index.ts:732](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L732)* +*Defined in [index.ts:731](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L731)* ___ @@ -1887,7 +1901,7 @@ ___ • **compilerSettings**? : *[CompilerSettings](#class-compilersettings)* -*Defined in [index.ts:733](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L733)* +*Defined in [index.ts:732](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L732)* ___ @@ -1895,7 +1909,7 @@ ___ • **contracts**? : *string[] | "*"* -*Defined in [index.ts:734](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L734)* +*Defined in [index.ts:733](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L733)* ___ @@ -1903,7 +1917,7 @@ ___ • **contractsDir**? : *undefined | string* -*Defined in [index.ts:731](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L731)* +*Defined in [index.ts:730](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L730)* ___ @@ -1911,15 +1925,7 @@ ___ • **isOfflineMode**? : *undefined | false | true* -*Defined in [index.ts:736](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L736)* - -___ - -### `Optional` shouldSaveStandardInput - -• **shouldSaveStandardInput**? : *undefined | false | true* - -*Defined in [index.ts:738](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L738)* +*Defined in [index.ts:735](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L735)* ___ @@ -1927,7 +1933,7 @@ ___ • **solcVersion**? : *undefined | string* -*Defined in [index.ts:737](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L737)* +*Defined in [index.ts:736](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L736)* ___ @@ -1935,7 +1941,7 @@ ___ • **useDockerisedSolc**? : *undefined | false | true* -*Defined in [index.ts:735](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L735)* +*Defined in [index.ts:734](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L734)*
@@ -1948,7 +1954,7 @@ ___ • **name**: *"solc"* -*Defined in [index.ts:655](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L655)* +*Defined in [index.ts:655](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L655)* ___ @@ -1956,7 +1962,7 @@ ___ • **settings**: *[CompilerSettings](#class-compilersettings)* -*Defined in [index.ts:657](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L657)* +*Defined in [index.ts:657](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L657)* ___ @@ -1964,7 +1970,7 @@ ___ • **version**: *string* -*Defined in [index.ts:656](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L656)* +*Defined in [index.ts:656](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L656)*
@@ -1977,7 +1983,7 @@ ___ • **evmVersion**? : *"homestead" | "tangerineWhistle" | "spuriousDragon" | "byzantium" | "constantinople"* -*Defined in [index.ts:689](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L689)* +*Defined in [index.ts:689](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L689)* ___ @@ -1985,7 +1991,7 @@ ___ • **libraries**? : *undefined | object* -*Defined in [index.ts:691](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L691)* +*Defined in [index.ts:691](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L691)* ___ @@ -1993,7 +1999,7 @@ ___ • **metadata**? : *[CompilerSettingsMetadata](#class-compilersettingsmetadata)* -*Defined in [index.ts:690](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L690)* +*Defined in [index.ts:690](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L690)* ___ @@ -2001,7 +2007,7 @@ ___ • **optimizer**? : *[OptimizerSettings](#class-optimizersettings)* -*Defined in [index.ts:688](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L688)* +*Defined in [index.ts:688](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L688)* ___ @@ -2009,7 +2015,7 @@ ___ • **outputSelection**: *object* -*Defined in [index.ts:696](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L696)* +*Defined in [index.ts:696](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L696)* #### Type declaration: @@ -2023,7 +2029,7 @@ ___ • **remappings**? : *string[]* -*Defined in [index.ts:687](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L687)* +*Defined in [index.ts:687](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L687)*
@@ -2036,7 +2042,7 @@ ___ • **useLiteralContent**: *true* -*Defined in [index.ts:704](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L704)* +*Defined in [index.ts:704](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L704)*
@@ -2049,7 +2055,7 @@ ___ • **inputs**: *[DataItem](#class-dataitem)[]* -*Defined in [index.ts:103](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L103)* +*Defined in [index.ts:103](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L103)* ___ @@ -2057,7 +2063,7 @@ ___ • **payable**: *boolean* -*Defined in [index.ts:104](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L104)* +*Defined in [index.ts:104](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L104)* ___ @@ -2065,7 +2071,7 @@ ___ • **stateMutability**: *[ConstructorStateMutability](#constructorstatemutability)* -*Defined in [index.ts:105](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L105)* +*Defined in [index.ts:105](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L105)* ___ @@ -2073,7 +2079,7 @@ ___ • **type**: *string* -*Defined in [index.ts:102](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L102)* +*Defined in [index.ts:102](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L102)*
@@ -2098,7 +2104,7 @@ If any of the sources change, the hash would change notifying us that a re-compi • **chains**: *[ContractChains](#class-contractchains)* -*Defined in [index.ts:676](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L676)* +*Defined in [index.ts:676](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L676)* ___ @@ -2108,7 +2114,7 @@ ___ *Inherited from [ContractVersionData](#interface-contractversiondata).[compiler](#compiler)* -*Defined in [index.ts:641](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L641)* +*Defined in [index.ts:641](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L641)* ___ @@ -2118,7 +2124,7 @@ ___ *Inherited from [ContractVersionData](#interface-contractversiondata).[compilerOutput](#compileroutput)* -*Defined in [index.ts:651](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L651)* +*Defined in [index.ts:651](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L651)* ___ @@ -2126,7 +2132,7 @@ ___ • **contractName**: *string* -*Defined in [index.ts:675](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L675)* +*Defined in [index.ts:675](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L675)* ___ @@ -2134,7 +2140,7 @@ ___ • **schemaVersion**: *string* -*Defined in [index.ts:674](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L674)* +*Defined in [index.ts:674](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L674)* ___ @@ -2144,7 +2150,7 @@ ___ *Inherited from [ContractVersionData](#interface-contractversiondata).[sourceCodes](#sourcecodes)* -*Defined in [index.ts:647](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L647)* +*Defined in [index.ts:647](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L647)* #### Type declaration: @@ -2158,7 +2164,7 @@ ___ *Inherited from [ContractVersionData](#interface-contractversiondata).[sourceTreeHashHex](#sourcetreehashhex)* -*Defined in [index.ts:650](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L650)* +*Defined in [index.ts:650](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L650)* ___ @@ -2168,7 +2174,7 @@ ___ *Inherited from [ContractVersionData](#interface-contractversiondata).[sources](#sources)* -*Defined in [index.ts:642](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L642)* +*Defined in [index.ts:642](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L642)* #### Type declaration: @@ -2185,7 +2191,7 @@ ___ • **address**: *string* -*Defined in [index.ts:554](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L554)* +*Defined in [index.ts:554](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L554)* ___ @@ -2193,7 +2199,7 @@ Args • **constructorArgs**: *string* -*Defined in [index.ts:558](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L558)* +*Defined in [index.ts:558](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L558)* ___ @@ -2201,7 +2207,7 @@ ___ • **links**: *object* -*Defined in [index.ts:555](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L555)* +*Defined in [index.ts:555](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L555)* #### Type declaration: @@ -2225,7 +2231,7 @@ ___ • **compiler**: *[CompilerOpts](#class-compileropts)* -*Defined in [index.ts:641](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L641)* +*Defined in [index.ts:641](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L641)* ___ @@ -2233,7 +2239,7 @@ ___ • **compilerOutput**: *[StandardContractOutput](#class-standardcontractoutput)* -*Defined in [index.ts:651](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L651)* +*Defined in [index.ts:651](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L651)* ___ @@ -2241,7 +2247,7 @@ ___ • **sourceCodes**: *object* -*Defined in [index.ts:647](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L647)* +*Defined in [index.ts:647](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L647)* #### Type declaration: @@ -2253,7 +2259,7 @@ ___ • **sourceTreeHashHex**: *string* -*Defined in [index.ts:650](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L650)* +*Defined in [index.ts:650](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L650)* ___ @@ -2261,7 +2267,7 @@ ___ • **sources**: *object* -*Defined in [index.ts:642](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L642)* +*Defined in [index.ts:642](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L642)* #### Type declaration: @@ -2278,7 +2284,7 @@ ___ • **components**? : *[DataItem](#class-dataitem)[]* -*Defined in [index.ts:137](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L137)* +*Defined in [index.ts:137](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L137)* ___ @@ -2286,7 +2292,7 @@ ___ • **name**: *string* -*Defined in [index.ts:135](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L135)* +*Defined in [index.ts:135](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L135)* ___ @@ -2294,7 +2300,7 @@ ___ • **type**: *string* -*Defined in [index.ts:136](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L136)* +*Defined in [index.ts:136](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L136)*
@@ -2314,7 +2320,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[address](#address)* -*Defined in [index.ts:434](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L434)* +*Defined in [index.ts:434](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L434)* ___ @@ -2322,7 +2328,7 @@ ___ • **args**: *`A`* -*Defined in [index.ts:417](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L417)* +*Defined in [index.ts:417](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L417)* ___ @@ -2332,7 +2338,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[blockHash](#blockhash)* -*Defined in [index.ts:432](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L432)* +*Defined in [index.ts:432](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L432)* ___ @@ -2342,7 +2348,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[blockNumber](#blocknumber)* -*Defined in [index.ts:433](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L433)* +*Defined in [index.ts:433](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L433)* ___ @@ -2352,7 +2358,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[data](#data)* -*Defined in [index.ts:435](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L435)* +*Defined in [index.ts:435](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L435)* ___ @@ -2360,7 +2366,7 @@ ___ • **event**: *string* -*Defined in [index.ts:416](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L416)* +*Defined in [index.ts:416](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L416)* ___ @@ -2370,7 +2376,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[logIndex](#logindex)* -*Defined in [index.ts:429](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L429)* +*Defined in [index.ts:429](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L429)* ___ @@ -2380,7 +2386,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[topics](#topics)* -*Defined in [index.ts:436](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L436)* +*Defined in [index.ts:436](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L436)* ___ @@ -2390,7 +2396,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[transactionHash](#transactionhash)* -*Defined in [index.ts:431](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L431)* +*Defined in [index.ts:431](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L431)* ___ @@ -2400,7 +2406,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[transactionIndex](#transactionindex)* -*Defined in [index.ts:430](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L430)* +*Defined in [index.ts:430](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L430)*
@@ -2419,7 +2425,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[address](#address)* -*Defined in [index.ts:434](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L434)* +*Defined in [index.ts:434](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L434)* ___ @@ -2429,7 +2435,7 @@ ___ *Inherited from [DecodedLogEntry](#interface-decodedlogentry).[args](#args)* -*Defined in [index.ts:417](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L417)* +*Defined in [index.ts:417](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L417)* ___ @@ -2439,7 +2445,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[blockHash](#blockhash)* -*Defined in [index.ts:432](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L432)* +*Defined in [index.ts:432](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L432)* ___ @@ -2449,7 +2455,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[blockNumber](#blocknumber)* -*Defined in [index.ts:433](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L433)* +*Defined in [index.ts:433](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L433)* ___ @@ -2459,7 +2465,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[data](#data)* -*Defined in [index.ts:435](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L435)* +*Defined in [index.ts:435](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L435)* ___ @@ -2469,7 +2475,7 @@ ___ *Inherited from [DecodedLogEntry](#interface-decodedlogentry).[event](#event)* -*Defined in [index.ts:416](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L416)* +*Defined in [index.ts:416](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L416)* ___ @@ -2479,7 +2485,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[logIndex](#logindex)* -*Defined in [index.ts:429](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L429)* +*Defined in [index.ts:429](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L429)* ___ @@ -2487,7 +2493,7 @@ ___ • **removed**: *boolean* -*Defined in [index.ts:421](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L421)* +*Defined in [index.ts:421](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L421)* ___ @@ -2497,7 +2503,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[topics](#topics)* -*Defined in [index.ts:436](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L436)* +*Defined in [index.ts:436](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L436)* ___ @@ -2507,7 +2513,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[transactionHash](#transactionhash)* -*Defined in [index.ts:431](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L431)* +*Defined in [index.ts:431](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L431)* ___ @@ -2517,7 +2523,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[transactionIndex](#transactionindex)* -*Defined in [index.ts:430](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L430)* +*Defined in [index.ts:430](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L430)*
@@ -2530,7 +2536,7 @@ ___ • **author**? : *undefined | string* -*Defined in [index.ts:628](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L628)* +*Defined in [index.ts:628](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L628)* ___ @@ -2538,7 +2544,7 @@ ___ • **methods**: *object* -*Defined in [index.ts:629](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L629)* +*Defined in [index.ts:629](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L629)* #### Type declaration: @@ -2550,7 +2556,7 @@ ___ • **title**? : *undefined | string* -*Defined in [index.ts:627](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L627)* +*Defined in [index.ts:627](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L627)*
@@ -2563,7 +2569,7 @@ ___ • **isEIP1193**: *boolean* -*Defined in [index.ts:73](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L73)* +*Defined in [index.ts:73](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L73)* ## Methods @@ -2571,7 +2577,7 @@ ___ ▸ **on**(`event`: [EIP1193Event](#eip1193event), `listener`: function): *this* -*Defined in [index.ts:75](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L75)* +*Defined in [index.ts:75](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L75)* **Parameters:** @@ -2595,7 +2601,7 @@ ___ ▸ **send**(`method`: string, `params?`: any[]): *`Promise`* -*Defined in [index.ts:74](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L74)* +*Defined in [index.ts:74](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L74)* **Parameters:** @@ -2617,7 +2623,7 @@ Name | Type | • **anonymous**: *boolean* -*Defined in [index.ts:131](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L131)* +*Defined in [index.ts:131](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L131)* ___ @@ -2625,7 +2631,7 @@ ___ • **inputs**: *[EventParameter](#class-eventparameter)[]* -*Defined in [index.ts:130](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L130)* +*Defined in [index.ts:130](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L130)* ___ @@ -2633,7 +2639,7 @@ ___ • **name**: *string* -*Defined in [index.ts:129](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L129)* +*Defined in [index.ts:129](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L129)* ___ @@ -2641,7 +2647,7 @@ ___ • **type**: *string* -*Defined in [index.ts:128](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L128)* +*Defined in [index.ts:128](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L128)*
@@ -2656,7 +2662,7 @@ ___ *Inherited from [DataItem](#interface-dataitem).[components](#optional-components)* -*Defined in [index.ts:137](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L137)* +*Defined in [index.ts:137](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L137)* ___ @@ -2664,7 +2670,7 @@ ___ • **indexed**: *boolean* -*Defined in [index.ts:116](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L116)* +*Defined in [index.ts:116](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L116)* ___ @@ -2674,7 +2680,7 @@ ___ *Inherited from [DataItem](#interface-dataitem).[name](#name)* -*Defined in [index.ts:135](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L135)* +*Defined in [index.ts:135](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L135)* ___ @@ -2684,7 +2690,7 @@ ___ *Inherited from [DataItem](#interface-dataitem).[type](#type)* -*Defined in [index.ts:136](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L136)* +*Defined in [index.ts:136](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L136)*
@@ -2697,7 +2703,7 @@ ___ • **object**: *string* -*Defined in [index.ts:622](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L622)* +*Defined in [index.ts:622](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L622)* ___ @@ -2705,7 +2711,7 @@ ___ • **sourceMap**: *string* -*Defined in [index.ts:623](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L623)* +*Defined in [index.ts:623](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L623)*
@@ -2718,7 +2724,7 @@ ___ • **bytecode**: *[EvmBytecodeOutput](#class-evmbytecodeoutput)* -*Defined in [index.ts:617](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L617)* +*Defined in [index.ts:617](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L617)* ___ @@ -2726,7 +2732,7 @@ ___ • **deployedBytecode**: *[EvmBytecodeOutput](#class-evmbytecodeoutput)* -*Defined in [index.ts:618](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L618)* +*Defined in [index.ts:618](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L618)*
@@ -2739,7 +2745,7 @@ ___ • **payable**: *boolean* -*Defined in [index.ts:112](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L112)* +*Defined in [index.ts:112](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L112)* ___ @@ -2747,7 +2753,7 @@ ___ • **type**: *string* -*Defined in [index.ts:111](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L111)* +*Defined in [index.ts:111](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L111)*
@@ -2760,7 +2766,7 @@ ___ • **address**? : *undefined | string* -*Defined in [index.ts:409](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L409)* +*Defined in [index.ts:409](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L409)* ___ @@ -2768,7 +2774,7 @@ ___ • **blockHash**? : *undefined | string* -*Defined in [index.ts:408](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L408)* +*Defined in [index.ts:408](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L408)* ___ @@ -2776,7 +2782,7 @@ ___ • **fromBlock**? : *number | string* -*Defined in [index.ts:406](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L406)* +*Defined in [index.ts:406](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L406)* ___ @@ -2784,7 +2790,7 @@ ___ • **toBlock**? : *number | string* -*Defined in [index.ts:407](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L407)* +*Defined in [index.ts:407](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L407)* ___ @@ -2792,44 +2798,29 @@ ___ • **topics**? : *[LogTopic](#logtopic)[]* -*Defined in [index.ts:410](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L410)* +*Defined in [index.ts:410](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L410)*
-# Enumeration: AbiType - - -## Enumeration members - -### Constructor - -• **Constructor**: = "constructor" - -*Defined in [index.ts:463](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L463)* - -___ - -### Event - -• **Event**: = "event" - -*Defined in [index.ts:464](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L464)* +# Interface: GanacheProvider -___ -### Fallback +## Methods -• **Fallback**: = "fallback" +### sendAsync -*Defined in [index.ts:465](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L465)* +▸ **sendAsync**(`payload`: [JSONRPCRequestPayload](_index_.jsonrpcrequestpayload.md), `callback`: [JSONRPCErrorCallback](#jsonrpcerrorcallback)): *void* -___ +*Defined in [index.ts:14](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L14)* -### Function +**Parameters:** -• **Function**: = "function" +Name | Type | +------ | ------ | +`payload` | [JSONRPCRequestPayload](#class-jsonrpcrequestpayload) | +`callback` | [JSONRPCErrorCallback](#jsonrpcerrorcallback) | -*Defined in [index.ts:462](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L462)* +**Returns:** *void*
@@ -2842,7 +2833,7 @@ ___ • **name**: *"solc"* -*Defined in [index.ts:680](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L680)* +*Defined in [index.ts:680](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L680)* ___ @@ -2850,7 +2841,7 @@ ___ • **settings**: *[CompilerSettings](#class-compilersettings)* -*Defined in [index.ts:682](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L682)* +*Defined in [index.ts:682](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L682)* ___ @@ -2858,7 +2849,7 @@ ___ • **version**: *string* -*Defined in [index.ts:681](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L681)* +*Defined in [index.ts:681](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L681)*
@@ -2871,7 +2862,7 @@ ___ • **id**: *number* -*Defined in [index.ts:330](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L330)* +*Defined in [index.ts:330](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L330)* ___ @@ -2879,7 +2870,7 @@ ___ • **jsonrpc**: *string* -*Defined in [index.ts:331](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L331)* +*Defined in [index.ts:331](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L331)* ___ @@ -2887,7 +2878,7 @@ ___ • **method**: *string* -*Defined in [index.ts:329](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L329)* +*Defined in [index.ts:329](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L329)* ___ @@ -2895,7 +2886,7 @@ ___ • **params**: *any[]* -*Defined in [index.ts:328](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L328)* +*Defined in [index.ts:328](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L328)*
@@ -2908,7 +2899,7 @@ ___ • **code**: *number* -*Defined in [index.ts:336](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L336)* +*Defined in [index.ts:336](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L336)* ___ @@ -2916,7 +2907,7 @@ ___ • **message**: *string* -*Defined in [index.ts:335](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L335)* +*Defined in [index.ts:335](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L335)*
@@ -2929,7 +2920,7 @@ ___ • **error**? : *[JSONRPCResponseError](#class-jsonrpcresponseerror)* -*Defined in [index.ts:343](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L343)* +*Defined in [index.ts:343](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L343)* ___ @@ -2937,7 +2928,7 @@ ___ • **id**: *number* -*Defined in [index.ts:341](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L341)* +*Defined in [index.ts:341](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L341)* ___ @@ -2945,7 +2936,7 @@ ___ • **jsonrpc**: *string* -*Defined in [index.ts:342](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L342)* +*Defined in [index.ts:342](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L342)* ___ @@ -2953,7 +2944,7 @@ ___ • **result**: *any* -*Defined in [index.ts:340](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L340)* +*Defined in [index.ts:340](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L340)*
@@ -2966,7 +2957,7 @@ ___ • **address**: *string* -*Defined in [index.ts:434](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L434)* +*Defined in [index.ts:434](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L434)* ___ @@ -2974,7 +2965,7 @@ ___ • **blockHash**: *string | null* -*Defined in [index.ts:432](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L432)* +*Defined in [index.ts:432](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L432)* ___ @@ -2982,7 +2973,7 @@ ___ • **blockNumber**: *number | null* -*Defined in [index.ts:433](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L433)* +*Defined in [index.ts:433](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L433)* ___ @@ -2990,7 +2981,7 @@ ___ • **data**: *string* -*Defined in [index.ts:435](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L435)* +*Defined in [index.ts:435](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L435)* ___ @@ -2998,7 +2989,7 @@ ___ • **logIndex**: *number | null* -*Defined in [index.ts:429](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L429)* +*Defined in [index.ts:429](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L429)* ___ @@ -3006,7 +2997,7 @@ ___ • **topics**: *string[]* -*Defined in [index.ts:436](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L436)* +*Defined in [index.ts:436](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L436)* ___ @@ -3014,7 +3005,7 @@ ___ • **transactionHash**: *string* -*Defined in [index.ts:431](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L431)* +*Defined in [index.ts:431](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L431)* ___ @@ -3022,7 +3013,7 @@ ___ • **transactionIndex**: *number | null* -*Defined in [index.ts:430](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L430)* +*Defined in [index.ts:430](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L430)*
@@ -3037,7 +3028,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[address](#address)* -*Defined in [index.ts:434](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L434)* +*Defined in [index.ts:434](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L434)* ___ @@ -3047,7 +3038,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[blockHash](#blockhash)* -*Defined in [index.ts:432](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L432)* +*Defined in [index.ts:432](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L432)* ___ @@ -3057,7 +3048,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[blockNumber](#blocknumber)* -*Defined in [index.ts:433](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L433)* +*Defined in [index.ts:433](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L433)* ___ @@ -3067,7 +3058,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[data](#data)* -*Defined in [index.ts:435](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L435)* +*Defined in [index.ts:435](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L435)* ___ @@ -3077,7 +3068,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[logIndex](#logindex)* -*Defined in [index.ts:429](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L429)* +*Defined in [index.ts:429](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L429)* ___ @@ -3085,7 +3076,7 @@ ___ • **removed**: *boolean* -*Defined in [index.ts:425](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L425)* +*Defined in [index.ts:425](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L425)* ___ @@ -3095,7 +3086,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[topics](#topics)* -*Defined in [index.ts:436](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L436)* +*Defined in [index.ts:436](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L436)* ___ @@ -3105,7 +3096,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[transactionHash](#transactionhash)* -*Defined in [index.ts:431](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L431)* +*Defined in [index.ts:431](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L431)* ___ @@ -3115,7 +3106,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[transactionIndex](#transactionindex)* -*Defined in [index.ts:430](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L430)* +*Defined in [index.ts:430](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L430)*
@@ -3134,7 +3125,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[address](#address)* -*Defined in [index.ts:434](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L434)* +*Defined in [index.ts:434](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L434)* ___ @@ -3144,7 +3135,7 @@ ___ *Inherited from [DecodedLogEntry](#interface-decodedlogentry).[args](#args)* -*Defined in [index.ts:417](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L417)* +*Defined in [index.ts:417](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L417)* ___ @@ -3154,7 +3145,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[blockHash](#blockhash)* -*Defined in [index.ts:432](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L432)* +*Defined in [index.ts:432](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L432)* ___ @@ -3164,7 +3155,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[blockNumber](#blocknumber)* -*Defined in [index.ts:433](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L433)* +*Defined in [index.ts:433](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L433)* ___ @@ -3174,7 +3165,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[data](#data)* -*Defined in [index.ts:435](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L435)* +*Defined in [index.ts:435](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L435)* ___ @@ -3184,7 +3175,7 @@ ___ *Inherited from [DecodedLogEntry](#interface-decodedlogentry).[event](#event)* -*Defined in [index.ts:416](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L416)* +*Defined in [index.ts:416](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L416)* ___ @@ -3194,7 +3185,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[logIndex](#logindex)* -*Defined in [index.ts:429](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L429)* +*Defined in [index.ts:429](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L429)* ___ @@ -3204,7 +3195,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[topics](#topics)* -*Defined in [index.ts:436](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L436)* +*Defined in [index.ts:436](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L436)* ___ @@ -3214,7 +3205,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[transactionHash](#transactionhash)* -*Defined in [index.ts:431](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L431)* +*Defined in [index.ts:431](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L431)* ___ @@ -3224,7 +3215,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[transactionIndex](#transactionindex)* -*Defined in [index.ts:430](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L430)* +*Defined in [index.ts:430](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L430)*
@@ -3237,7 +3228,7 @@ ___ • **constant**: *boolean* -*Defined in [index.ts:94](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L94)* +*Defined in [index.ts:94](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L94)* ___ @@ -3245,7 +3236,7 @@ ___ • **inputs**: *[DataItem](#class-dataitem)[]* -*Defined in [index.ts:92](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L92)* +*Defined in [index.ts:92](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L92)* ___ @@ -3253,7 +3244,7 @@ ___ • **name**: *string* -*Defined in [index.ts:91](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L91)* +*Defined in [index.ts:91](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L91)* ___ @@ -3261,7 +3252,7 @@ ___ • **outputs**: *[DataItem](#class-dataitem)[]* -*Defined in [index.ts:93](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L93)* +*Defined in [index.ts:93](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L93)* ___ @@ -3269,7 +3260,7 @@ ___ • **payable**: *boolean* -*Defined in [index.ts:96](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L96)* +*Defined in [index.ts:96](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L96)* ___ @@ -3277,7 +3268,7 @@ ___ • **stateMutability**: *[StateMutability](#statemutability)* -*Defined in [index.ts:95](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L95)* +*Defined in [index.ts:95](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L95)* ___ @@ -3285,7 +3276,7 @@ ___ • **type**: *string* -*Defined in [index.ts:90](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L90)* +*Defined in [index.ts:90](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L90)*
@@ -3298,7 +3289,7 @@ ___ • **enabled**: *boolean* -*Defined in [index.ts:708](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L708)* +*Defined in [index.ts:708](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L708)* ___ @@ -3306,7 +3297,7 @@ ___ • **runs**? : *undefined | number* -*Defined in [index.ts:709](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L709)* +*Defined in [index.ts:709](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L709)*
@@ -3319,7 +3310,7 @@ ___ ▸ **sendAsync**(`payload`: [JSONRPCRequestPayload](_index_.jsonrpcrequestpayload.md), `callback`: [JSONRPCErrorCallback](#jsonrpcerrorcallback)): *void* -*Defined in [index.ts:20](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L20)* +*Defined in [index.ts:20](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L20)* **Parameters:** @@ -3341,7 +3332,7 @@ Name | Type | • **address**: *string* -*Defined in [index.ts:491](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L491)* +*Defined in [index.ts:491](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L491)* ___ @@ -3349,7 +3340,7 @@ ___ • **blockHash**: *string | null* -*Defined in [index.ts:489](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L489)* +*Defined in [index.ts:489](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L489)* ___ @@ -3357,7 +3348,7 @@ ___ • **blockNumber**: *string | null* -*Defined in [index.ts:490](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L490)* +*Defined in [index.ts:490](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L490)* ___ @@ -3365,7 +3356,7 @@ ___ • **data**: *string* -*Defined in [index.ts:492](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L492)* +*Defined in [index.ts:492](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L492)* ___ @@ -3373,7 +3364,7 @@ ___ • **logIndex**: *string | null* -*Defined in [index.ts:486](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L486)* +*Defined in [index.ts:486](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L486)* ___ @@ -3381,7 +3372,7 @@ ___ • **topics**: *string[]* -*Defined in [index.ts:493](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L493)* +*Defined in [index.ts:493](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L493)* ___ @@ -3389,7 +3380,7 @@ ___ • **transactionHash**: *string* -*Defined in [index.ts:488](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L488)* +*Defined in [index.ts:488](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L488)* ___ @@ -3397,7 +3388,7 @@ ___ • **transactionIndex**: *string | null* -*Defined in [index.ts:487](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L487)* +*Defined in [index.ts:487](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L487)*
@@ -3410,7 +3401,7 @@ ___ • **arguments**? : *[DataItem](#class-dataitem)[]* -*Defined in [index.ts:122](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L122)* +*Defined in [index.ts:122](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L122)* ___ @@ -3418,7 +3409,7 @@ ___ • **name**: *string* -*Defined in [index.ts:121](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L121)* +*Defined in [index.ts:121](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L121)* ___ @@ -3426,7 +3417,7 @@ ___ • **type**: *"error"* -*Defined in [index.ts:120](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L120)* +*Defined in [index.ts:120](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L120)*
@@ -3439,7 +3430,7 @@ ___ • **component**: *"general" | "ewasm"* -*Defined in [index.ts:604](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L604)* +*Defined in [index.ts:604](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L604)* ___ @@ -3447,7 +3438,7 @@ ___ • **formattedMessage**? : *undefined | string* -*Defined in [index.ts:607](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L607)* +*Defined in [index.ts:607](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L607)* ___ @@ -3455,7 +3446,7 @@ ___ • **message**: *string* -*Defined in [index.ts:606](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L606)* +*Defined in [index.ts:606](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L606)* ___ @@ -3463,7 +3454,7 @@ ___ • **severity**: *[ErrorSeverity](#errorseverity)* -*Defined in [index.ts:605](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L605)* +*Defined in [index.ts:605](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L605)* ___ @@ -3471,7 +3462,7 @@ ___ • **sourceLocation**? : *[SourceLocation](#class-sourcelocation)* -*Defined in [index.ts:602](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L602)* +*Defined in [index.ts:602](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L602)* ___ @@ -3479,7 +3470,7 @@ ___ • **type**: *[ErrorType](#errortype)* -*Defined in [index.ts:603](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L603)* +*Defined in [index.ts:603](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L603)*
@@ -3492,7 +3483,7 @@ ___ • **id**: *number* -*Defined in [index.ts:713](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L713)* +*Defined in [index.ts:713](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L713)*
@@ -3505,7 +3496,7 @@ ___ • **end**: *number* -*Defined in [index.ts:613](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L613)* +*Defined in [index.ts:613](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L613)* ___ @@ -3513,7 +3504,7 @@ ___ • **file**: *string* -*Defined in [index.ts:611](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L611)* +*Defined in [index.ts:611](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L611)* ___ @@ -3521,7 +3512,7 @@ ___ • **start**: *number* -*Defined in [index.ts:612](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L612)* +*Defined in [index.ts:612](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L612)*
@@ -3534,7 +3525,7 @@ ___ • **abi**: *[ContractAbi](#contractabi)* -*Defined in [index.ts:564](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L564)* +*Defined in [index.ts:564](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L564)* ___ @@ -3542,7 +3533,7 @@ ___ • **devdoc**? : *[DevdocOutput](#class-devdocoutput)* -*Defined in [index.ts:566](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L566)* +*Defined in [index.ts:566](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L566)* ___ @@ -3550,7 +3541,7 @@ ___ • **evm**: *[EvmOutput](#class-evmoutput)* -*Defined in [index.ts:565](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L565)* +*Defined in [index.ts:565](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L565)*
@@ -3563,7 +3554,7 @@ ___ • **contracts**: *object* -*Defined in [index.ts:578](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L578)* +*Defined in [index.ts:578](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L578)* #### Type declaration: @@ -3577,7 +3568,7 @@ ___ • **errors**: *[SolcError](#class-solcerror)[]* -*Defined in [index.ts:570](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L570)* +*Defined in [index.ts:570](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L570)* ___ @@ -3585,7 +3576,7 @@ ___ • **sources**: *object* -*Defined in [index.ts:571](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L571)* +*Defined in [index.ts:571](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L571)* #### Type declaration: @@ -3602,7 +3593,7 @@ ___ • **depth**: *number* -*Defined in [index.ts:293](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L293)* +*Defined in [index.ts:293](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L293)* ___ @@ -3610,7 +3601,7 @@ ___ • **error**: *string* -*Defined in [index.ts:294](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L294)* +*Defined in [index.ts:294](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L294)* ___ @@ -3618,7 +3609,7 @@ ___ • **gas**: *number* -*Defined in [index.ts:295](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L295)* +*Defined in [index.ts:295](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L295)* ___ @@ -3626,7 +3617,7 @@ ___ • **gasCost**: *number* -*Defined in [index.ts:296](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L296)* +*Defined in [index.ts:296](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L296)* ___ @@ -3634,7 +3625,7 @@ ___ • **memory**: *string[]* -*Defined in [index.ts:297](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L297)* +*Defined in [index.ts:297](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L297)* ___ @@ -3642,7 +3633,7 @@ ___ • **op**: *[OpCode](#enumeration-opcode)* -*Defined in [index.ts:298](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L298)* +*Defined in [index.ts:298](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L298)* ___ @@ -3650,7 +3641,7 @@ ___ • **pc**: *number* -*Defined in [index.ts:299](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L299)* +*Defined in [index.ts:299](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L299)* ___ @@ -3658,7 +3649,7 @@ ___ • **stack**: *string[]* -*Defined in [index.ts:300](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L300)* +*Defined in [index.ts:300](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L300)* ___ @@ -3666,7 +3657,7 @@ ___ • **storage**: *object* -*Defined in [index.ts:301](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L301)* +*Defined in [index.ts:301](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L301)* #### Type declaration: @@ -3683,7 +3674,7 @@ ___ • **disableMemory**? : *undefined | false | true* -*Defined in [index.ts:518](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L518)* +*Defined in [index.ts:518](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L518)* ___ @@ -3691,7 +3682,7 @@ ___ • **disableStack**? : *undefined | false | true* -*Defined in [index.ts:519](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L519)* +*Defined in [index.ts:519](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L519)* ___ @@ -3699,7 +3690,7 @@ ___ • **disableStorage**? : *undefined | false | true* -*Defined in [index.ts:520](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L520)* +*Defined in [index.ts:520](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L520)* ___ @@ -3707,7 +3698,7 @@ ___ • **timeout**? : *undefined | string* -*Defined in [index.ts:522](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L522)* +*Defined in [index.ts:522](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L522)* ___ @@ -3715,7 +3706,7 @@ ___ • **tracer**? : *undefined | string* -*Defined in [index.ts:521](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L521)* +*Defined in [index.ts:521](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L521)*
@@ -3728,7 +3719,7 @@ ___ • **blockHash**: *string | null* -*Defined in [index.ts:377](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L377)* +*Defined in [index.ts:377](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L377)* ___ @@ -3736,7 +3727,7 @@ ___ • **blockNumber**: *number | null* -*Defined in [index.ts:378](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L378)* +*Defined in [index.ts:378](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L378)* ___ @@ -3744,7 +3735,7 @@ ___ • **from**: *string* -*Defined in [index.ts:380](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L380)* +*Defined in [index.ts:380](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L380)* ___ @@ -3752,7 +3743,7 @@ ___ • **gas**: *number* -*Defined in [index.ts:384](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L384)* +*Defined in [index.ts:384](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L384)* ___ @@ -3760,7 +3751,7 @@ ___ • **gasPrice**: *`BigNumber`* -*Defined in [index.ts:383](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L383)* +*Defined in [index.ts:383](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L383)* ___ @@ -3768,7 +3759,7 @@ ___ • **hash**: *string* -*Defined in [index.ts:375](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L375)* +*Defined in [index.ts:375](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L375)* ___ @@ -3776,7 +3767,7 @@ ___ • **input**: *string* -*Defined in [index.ts:385](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L385)* +*Defined in [index.ts:385](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L385)* ___ @@ -3784,7 +3775,7 @@ ___ • **nonce**: *number* -*Defined in [index.ts:376](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L376)* +*Defined in [index.ts:376](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L376)* ___ @@ -3792,7 +3783,7 @@ ___ • **to**: *string | null* -*Defined in [index.ts:381](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L381)* +*Defined in [index.ts:381](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L381)* ___ @@ -3800,7 +3791,7 @@ ___ • **transactionIndex**: *number | null* -*Defined in [index.ts:379](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L379)* +*Defined in [index.ts:379](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L379)* ___ @@ -3808,7 +3799,7 @@ ___ • **value**: *`BigNumber`* -*Defined in [index.ts:382](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L382)* +*Defined in [index.ts:382](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L382)*
@@ -3821,7 +3812,7 @@ ___ • **blockHash**: *string* -*Defined in [index.ts:448](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L448)* +*Defined in [index.ts:448](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L448)* ___ @@ -3829,7 +3820,7 @@ ___ • **blockNumber**: *number* -*Defined in [index.ts:449](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L449)* +*Defined in [index.ts:449](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L449)* ___ @@ -3837,7 +3828,7 @@ ___ • **contractAddress**: *string | null* -*Defined in [index.ts:457](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L457)* +*Defined in [index.ts:457](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L457)* ___ @@ -3845,7 +3836,7 @@ ___ • **cumulativeGasUsed**: *number* -*Defined in [index.ts:455](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L455)* +*Defined in [index.ts:455](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L455)* ___ @@ -3853,7 +3844,7 @@ ___ • **from**: *string* -*Defined in [index.ts:452](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L452)* +*Defined in [index.ts:452](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L452)* ___ @@ -3861,7 +3852,7 @@ ___ • **gasUsed**: *number* -*Defined in [index.ts:456](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L456)* +*Defined in [index.ts:456](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L456)* ___ @@ -3869,7 +3860,7 @@ ___ • **logs**: *[LogEntry](#class-logentry)[]* -*Defined in [index.ts:458](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L458)* +*Defined in [index.ts:458](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L458)* ___ @@ -3877,7 +3868,7 @@ ___ • **status**: *[TransactionReceiptStatus](#transactionreceiptstatus)* -*Defined in [index.ts:454](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L454)* +*Defined in [index.ts:454](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L454)* ___ @@ -3885,7 +3876,7 @@ ___ • **to**: *string* -*Defined in [index.ts:453](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L453)* +*Defined in [index.ts:453](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L453)* ___ @@ -3893,7 +3884,7 @@ ___ • **transactionHash**: *string* -*Defined in [index.ts:450](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L450)* +*Defined in [index.ts:450](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L450)* ___ @@ -3901,7 +3892,7 @@ ___ • **transactionIndex**: *number* -*Defined in [index.ts:451](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L451)* +*Defined in [index.ts:451](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L451)*
@@ -3920,7 +3911,7 @@ otherwise we don't. *Inherited from [TransactionReceipt](#interface-transactionreceipt).[blockHash](#blockhash)* -*Defined in [index.ts:448](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L448)* +*Defined in [index.ts:448](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L448)* ___ @@ -3930,7 +3921,7 @@ ___ *Inherited from [TransactionReceipt](#interface-transactionreceipt).[blockNumber](#blocknumber)* -*Defined in [index.ts:449](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L449)* +*Defined in [index.ts:449](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L449)* ___ @@ -3940,7 +3931,7 @@ ___ *Inherited from [TransactionReceipt](#interface-transactionreceipt).[contractAddress](#contractaddress)* -*Defined in [index.ts:457](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L457)* +*Defined in [index.ts:457](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L457)* ___ @@ -3950,7 +3941,7 @@ ___ *Inherited from [TransactionReceipt](#interface-transactionreceipt).[cumulativeGasUsed](#cumulativegasused)* -*Defined in [index.ts:455](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L455)* +*Defined in [index.ts:455](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L455)* ___ @@ -3960,7 +3951,7 @@ ___ *Inherited from [TransactionReceipt](#interface-transactionreceipt).[from](#from)* -*Defined in [index.ts:452](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L452)* +*Defined in [index.ts:452](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L452)* ___ @@ -3970,7 +3961,7 @@ ___ *Inherited from [TransactionReceipt](#interface-transactionreceipt).[gasUsed](#gasused)* -*Defined in [index.ts:456](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L456)* +*Defined in [index.ts:456](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L456)* ___ @@ -3980,7 +3971,7 @@ ___ *Overrides [TransactionReceipt](_index_.transactionreceipt.md).[logs](#logs)* -*Defined in [index.ts:514](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L514)* +*Defined in [index.ts:514](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L514)* ___ @@ -3990,7 +3981,7 @@ ___ *Inherited from [TransactionReceipt](#interface-transactionreceipt).[status](#status)* -*Defined in [index.ts:454](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L454)* +*Defined in [index.ts:454](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L454)* ___ @@ -4000,7 +3991,7 @@ ___ *Inherited from [TransactionReceipt](#interface-transactionreceipt).[to](#to)* -*Defined in [index.ts:453](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L453)* +*Defined in [index.ts:453](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L453)* ___ @@ -4010,7 +4001,7 @@ ___ *Inherited from [TransactionReceipt](#interface-transactionreceipt).[transactionHash](#transactionhash)* -*Defined in [index.ts:450](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L450)* +*Defined in [index.ts:450](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L450)* ___ @@ -4020,7 +4011,7 @@ ___ *Inherited from [TransactionReceipt](#interface-transactionreceipt).[transactionIndex](#transactionindex)* -*Defined in [index.ts:451](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L451)* +*Defined in [index.ts:451](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L451)*
@@ -4033,7 +4024,7 @@ ___ • **gas**: *number* -*Defined in [index.ts:305](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L305)* +*Defined in [index.ts:305](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L305)* ___ @@ -4041,7 +4032,7 @@ ___ • **returnValue**: *any* -*Defined in [index.ts:306](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L306)* +*Defined in [index.ts:306](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L306)* ___ @@ -4049,7 +4040,7 @@ ___ • **structLogs**: *[StructLog](#class-structlog)[]* -*Defined in [index.ts:307](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L307)* +*Defined in [index.ts:307](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L307)*
@@ -4064,7 +4055,7 @@ ___ *Overrides [DataItem](_index_.dataitem.md).[components](#optional-components)* -*Defined in [index.ts:141](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L141)* +*Defined in [index.ts:141](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L141)* ___ @@ -4074,7 +4065,7 @@ ___ *Inherited from [DataItem](#interface-dataitem).[name](#name)* -*Defined in [index.ts:135](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L135)* +*Defined in [index.ts:135](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L135)* ___ @@ -4084,7 +4075,7 @@ ___ *Inherited from [DataItem](#interface-dataitem).[type](#type)* -*Defined in [index.ts:136](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L136)* +*Defined in [index.ts:136](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L136)*
@@ -4099,7 +4090,7 @@ ___ *Inherited from [CallTxDataBase](#interface-calltxdatabase).[data](#optional-data)* -*Defined in [index.ts:393](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L393)* +*Defined in [index.ts:393](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L393)* ___ @@ -4107,7 +4098,7 @@ ___ • **from**: *string* -*Defined in [index.ts:398](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L398)* +*Defined in [index.ts:398](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L398)* ___ @@ -4117,7 +4108,7 @@ ___ *Inherited from [CallTxDataBase](#interface-calltxdatabase).[gas](#optional-gas)* -*Defined in [index.ts:391](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L391)* +*Defined in [index.ts:391](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L391)* ___ @@ -4127,7 +4118,7 @@ ___ *Inherited from [CallTxDataBase](#interface-calltxdatabase).[gasPrice](#optional-gasprice)* -*Defined in [index.ts:392](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L392)* +*Defined in [index.ts:392](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L392)* ___ @@ -4137,7 +4128,7 @@ ___ *Inherited from [CallTxDataBase](#interface-calltxdatabase).[nonce](#optional-nonce)* -*Defined in [index.ts:394](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L394)* +*Defined in [index.ts:394](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L394)* ___ @@ -4147,7 +4138,7 @@ ___ *Inherited from [CallTxDataBase](#interface-calltxdatabase).[to](#optional-to)* -*Defined in [index.ts:389](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L389)* +*Defined in [index.ts:389](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L389)* ___ @@ -4157,7 +4148,7 @@ ___ *Inherited from [CallTxDataBase](#interface-calltxdatabase).[value](#optional-value)* -*Defined in [index.ts:390](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L390)* +*Defined in [index.ts:390](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L390)*
@@ -4172,7 +4163,7 @@ ___ *Inherited from [CallTxDataBase](#interface-calltxdatabase).[data](#optional-data)* -*Defined in [index.ts:393](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L393)* +*Defined in [index.ts:393](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L393)* ___ @@ -4182,7 +4173,7 @@ ___ *Inherited from [TxData](#interface-txdata).[from](#from)* -*Defined in [index.ts:398](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L398)* +*Defined in [index.ts:398](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L398)* ___ @@ -4192,7 +4183,7 @@ ___ *Inherited from [CallTxDataBase](#interface-calltxdatabase).[gas](#optional-gas)* -*Defined in [index.ts:391](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L391)* +*Defined in [index.ts:391](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L391)* ___ @@ -4202,7 +4193,7 @@ ___ *Inherited from [CallTxDataBase](#interface-calltxdatabase).[gasPrice](#optional-gasprice)* -*Defined in [index.ts:392](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L392)* +*Defined in [index.ts:392](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L392)* ___ @@ -4212,7 +4203,7 @@ ___ *Inherited from [CallTxDataBase](#interface-calltxdatabase).[nonce](#optional-nonce)* -*Defined in [index.ts:394](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L394)* +*Defined in [index.ts:394](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L394)* ___ @@ -4222,7 +4213,7 @@ ___ *Inherited from [CallTxDataBase](#interface-calltxdatabase).[to](#optional-to)* -*Defined in [index.ts:389](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L389)* +*Defined in [index.ts:389](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L389)* ___ @@ -4232,7 +4223,7 @@ ___ *Overrides [CallTxDataBase](_index_.calltxdatabase.md).[value](#optional-value)* -*Defined in [index.ts:442](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L442)* +*Defined in [index.ts:442](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L442)*
@@ -4249,7 +4240,7 @@ This interface allowed sending synchonous requests, support for which was later ▸ **send**(`payload`: [JSONRPCRequestPayload](_index_.jsonrpcrequestpayload.md)): *[JSONRPCResponsePayload](#class-jsonrpcresponsepayload)* -*Defined in [index.ts:45](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L45)* +*Defined in [index.ts:45](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L45)* **Parameters:** @@ -4265,7 +4256,7 @@ ___ ▸ **sendAsync**(`payload`: [JSONRPCRequestPayload](_index_.jsonrpcrequestpayload.md), `callback`: [JSONRPCErrorCallback](#jsonrpcerrorcallback)): *void* -*Defined in [index.ts:44](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L44)* +*Defined in [index.ts:44](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L44)* **Parameters:** @@ -4291,7 +4282,7 @@ before the first attempts to conform to EIP1193 ▸ **send**(`payload`: [JSONRPCRequestPayload](_index_.jsonrpcrequestpayload.md), `callback`: [JSONRPCErrorCallback](#jsonrpcerrorcallback)): *void* -*Defined in [index.ts:54](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L54)* +*Defined in [index.ts:54](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L54)* **Parameters:** @@ -4317,7 +4308,7 @@ however it does not conform entirely. ▸ **send**(`method`: string, `params?`: any[]): *`Promise`* -*Defined in [index.ts:63](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L63)* +*Defined in [index.ts:63](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L63)* **Parameters:** @@ -4343,7 +4334,7 @@ add here • **isMetaMask**? : *undefined | false | true* -*Defined in [index.ts:31](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L31)* +*Defined in [index.ts:31](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L31)* ___ @@ -4351,7 +4342,7 @@ ___ • **isParity**? : *undefined | false | true* -*Defined in [index.ts:32](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L32)* +*Defined in [index.ts:32](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L32)* ___ @@ -4359,7 +4350,7 @@ ___ • **isZeroExProvider**? : *undefined | false | true* -*Defined in [index.ts:30](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L30)* +*Defined in [index.ts:30](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L30)* ## Methods @@ -4367,7 +4358,7 @@ ___ ▸ **enable**(): *`Promise`* -*Defined in [index.ts:34](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L34)* +*Defined in [index.ts:34](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L34)* **Returns:** *`Promise`* @@ -4377,7 +4368,7 @@ ___ ▸ **sendAsync**(`payload`: [JSONRPCRequestPayload](_index_.jsonrpcrequestpayload.md), `callback`: [JSONRPCErrorCallback](#jsonrpcerrorcallback)): *void* -*Defined in [index.ts:35](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L35)* +*Defined in [index.ts:35](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L35)* **Parameters:** @@ -4394,7 +4385,7 @@ ___ ▸ **stop**(): *void* -*Defined in [index.ts:33](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L33)* +*Defined in [index.ts:33](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L33)* **Returns:** *void* @@ -4409,7 +4400,7 @@ ___ Ƭ **AbiDefinition**: *[FunctionAbi](_index_.md#functionabi) | [EventAbi](#interface-eventabi) | [RevertErrorAbi](#interface-reverterrorabi)* -*Defined in [index.ts:80](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L80)* +*Defined in [index.ts:80](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L80)* ___ @@ -4417,7 +4408,7 @@ ___ Ƭ **BlockParam**: *[BlockParamLiteral](#enumeration-blockparamliteral) | number* -*Defined in [index.ts:483](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L483)* +*Defined in [index.ts:483](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L483)* ___ @@ -4425,7 +4416,7 @@ ___ Ƭ **ConstructorStateMutability**: *"nonpayable" | "payable"* -*Defined in [index.ts:84](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L84)* +*Defined in [index.ts:84](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L84)* ___ @@ -4433,7 +4424,7 @@ ___ Ƭ **ContractAbi**: *[AbiDefinition](#abidefinition)[]* -*Defined in [index.ts:78](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L78)* +*Defined in [index.ts:78](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L78)* ___ @@ -4441,7 +4432,7 @@ ___ Ƭ **ContractEventArg**: *any* -*Defined in [index.ts:468](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L468)* +*Defined in [index.ts:468](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L468)* ___ @@ -4449,7 +4440,7 @@ ___ Ƭ **DecodedLogs**: *`Array>`* -*Defined in [index.ts:439](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L439)* +*Defined in [index.ts:439](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L439)* ___ @@ -4457,7 +4448,7 @@ ___ Ƭ **EIP1193Event**: *"accountsChanged" | "networkChanged" | "close" | "connect" | "notification"* -*Defined in [index.ts:70](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L70)* +*Defined in [index.ts:70](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L70)* Interface for providers that conform to EIP 1193 Source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1193.md @@ -4468,7 +4459,7 @@ ___ Ƭ **ErrorSeverity**: *"error" | "warning"* -*Defined in [index.ts:599](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L599)* +*Defined in [index.ts:599](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L599)* ___ @@ -4476,7 +4467,7 @@ ___ Ƭ **ErrorType**: *"JSONError" | "IOError" | "ParserError" | "DocstringParsingError" | "SyntaxError" | "DeclarationError" | "TypeError" | "UnimplementedFeatureError" | "InternalCompilerError" | "Exception" | "CompilerError" | "FatalError" | "Warning"* -*Defined in [index.ts:585](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L585)* +*Defined in [index.ts:585](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L585)* ___ @@ -4484,7 +4475,7 @@ ___ Ƭ **FunctionAbi**: *[MethodAbi](#interface-methodabi) | [ConstructorAbi](#interface-constructorabi) | [FallbackAbi](#interface-fallbackabi)* -*Defined in [index.ts:82](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L82)* +*Defined in [index.ts:82](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L82)* ___ @@ -4492,7 +4483,7 @@ ___ Ƭ **JSONRPCErrorCallback**: *function* -*Defined in [index.ts:3](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L3)* +*Defined in [index.ts:3](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L3)* #### Type declaration: @@ -4511,7 +4502,7 @@ ___ Ƭ **LogTopic**: *null | string | string[]* -*Defined in [index.ts:413](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L413)* +*Defined in [index.ts:413](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L413)* ___ @@ -4519,7 +4510,7 @@ ___ Ƭ **OutputField**: *"*" | "ast" | "legacyAST" | "abi" | "devdoc" | "userdoc" | "metadata" | "ir" | "evm.assembly" | "evm.legacyAssembly" | "evm.bytecode.object" | "evm.bytecode.opcodes" | "evm.bytecode.sourceMap" | "evm.bytecode.linkReferences" | "evm.deployedBytecode.object" | "evm.deployedBytecode.opcodes" | "evm.deployedBytecode.sourceMap" | "evm.deployedBytecode.linkReferences" | "evm.methodIdentifiers" | "evm.gasEstimates" | "ewasm.wast" | "ewasm.wasm"* -*Defined in [index.ts:525](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L525)* +*Defined in [index.ts:525](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L525)* ___ @@ -4527,7 +4518,7 @@ ___ Ƭ **ParamDescription**: *string* -*Defined in [index.ts:561](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L561)* +*Defined in [index.ts:561](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L561)* ___ @@ -4535,7 +4526,7 @@ ___ Ƭ **RawLog**: *[LogEntry](#interface-logentry)* -*Defined in [index.ts:475](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L475)* +*Defined in [index.ts:475](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L475)* ___ @@ -4543,7 +4534,7 @@ ___ Ƭ **StateMutability**: *"pure" | "view" | [ConstructorStateMutability](#constructorstatemutability)* -*Defined in [index.ts:85](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L85)* +*Defined in [index.ts:85](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L85)* ___ @@ -4551,7 +4542,7 @@ ___ Ƭ **SupportedProvider**: *[Web3JsProvider](_index_.md#web3jsprovider) | [GanacheProvider](#interface-ganacheprovider) | [EIP1193Provider](#interface-eip1193provider) | [ZeroExProvider](#interface-zeroexprovider)* -*Defined in [index.ts:9](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L9)* +*Defined in [index.ts:9](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L9)* Do not create your own provider. Use an existing provider from a Web3 or ProviderEngine library Read more about Providers in the guides section of the 0x docs. @@ -4562,7 +4553,7 @@ ___ Ƭ **TransactionReceiptStatus**: *null | string | `0` | `1`* -*Defined in [index.ts:445](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L445)* +*Defined in [index.ts:445](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L445)* ___ @@ -4570,7 +4561,7 @@ ___ Ƭ **Unit**: *"kwei" | "ada" | "mwei" | "babbage" | "gwei" | "shannon" | "szabo" | "finney" | "ether" | "kether" | "grand" | "einstein" | "mether" | "gether" | "tether"* -*Defined in [index.ts:310](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L310)* +*Defined in [index.ts:310](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L310)* ___ @@ -4578,7 +4569,7 @@ ___ Ƭ **Web3JsProvider**: *[Web3JsV1Provider](#interface-web3jsv1provider) | [Web3JsV2Provider](#interface-web3jsv2provider) | [Web3JsV3Provider](#interface-web3jsv3provider)* -*Defined in [index.ts:11](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L11)* +*Defined in [index.ts:11](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L11)*
diff --git a/packages/json-schemas/docs/reference.mdx b/packages/json-schemas/docs/reference.mdx index 401ae7e51e..e39a830ec7 100644 --- a/packages/json-schemas/docs/reference.mdx +++ b/packages/json-schemas/docs/reference.mdx @@ -9,7 +9,7 @@ A validator for [JSON-schemas](http://json-schema.org/) \+ **new SchemaValidator**(): *[SchemaValidator](#class-schemavalidator)* -*Defined in [schema_validator.ts:15](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/json-schemas/src/schema_validator.ts#L15)* +*Defined in [schema_validator.ts:15](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/json-schemas/src/schema_validator.ts#L15)* Instantiates a SchemaValidator instance @@ -21,7 +21,7 @@ Instantiates a SchemaValidator instance ▸ **addSchema**(`schema`: `Schema`): *void* -*Defined in [schema_validator.ts:32](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/json-schemas/src/schema_validator.ts#L32)* +*Defined in [schema_validator.ts:32](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/json-schemas/src/schema_validator.ts#L32)* Add a schema to the validator. All schemas and sub-schemas must be added to the validator before the `validate` and `isValid` methods can be called with @@ -41,7 +41,7 @@ ___ ▸ **isValid**(`instance`: any, `schema`: `Schema`): *boolean* -*Defined in [schema_validator.ts:57](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/json-schemas/src/schema_validator.ts#L57)* +*Defined in [schema_validator.ts:57](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/json-schemas/src/schema_validator.ts#L57)* Check whether an instance properly adheres to a JSON schema @@ -62,7 +62,7 @@ ___ ▸ **validate**(`instance`: any, `schema`: `Schema`): *`ValidatorResult`* -*Defined in [schema_validator.ts:46](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/json-schemas/src/schema_validator.ts#L46)* +*Defined in [schema_validator.ts:46](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/json-schemas/src/schema_validator.ts#L46)* Validate the JS object conforms to a specific JSON schema diff --git a/packages/migrations/docs/reference.mdx b/packages/migrations/docs/reference.mdx index c31a00ebd2..48d3543654 100644 --- a/packages/migrations/docs/reference.mdx +++ b/packages/migrations/docs/reference.mdx @@ -1,24 +1,4 @@ -# Interface: GanacheProvider - - -## Methods - -### sendAsync - -▸ **sendAsync**(`payload`: [JSONRPCRequestPayload](_ethereum_types_src_index_.jsonrpcrequestpayload.md), `callback`: [JSONRPCErrorCallback](#jsonrpcerrorcallback)): *void* - -*Defined in [ethereum-types/src/index.ts:14](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L14)* - -**Parameters:** - -Name | Type | ------- | ------ | -`payload` | [JSONRPCRequestPayload](#class-jsonrpcrequestpayload) | -`callback` | [JSONRPCErrorCallback](#jsonrpcerrorcallback) | - -**Returns:** *void* -
@@ -37,7 +17,7 @@ Name | Type | • **assetProxyOwner**: *string* -*Defined in [contract-addresses/src/index.ts:12](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L12)* +*Defined in [contract-addresses/src/index.ts:12](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L12)* ___ @@ -45,7 +25,7 @@ ___ • **coordinator**: *string* -*Defined in [contract-addresses/src/index.ts:18](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L18)* +*Defined in [contract-addresses/src/index.ts:18](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L18)* ___ @@ -53,7 +33,7 @@ ___ • **coordinatorRegistry**: *string* -*Defined in [contract-addresses/src/index.ts:17](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L17)* +*Defined in [contract-addresses/src/index.ts:17](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L17)* ___ @@ -61,7 +41,7 @@ ___ • **devUtils**: *string* -*Defined in [contract-addresses/src/index.ts:22](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L22)* +*Defined in [contract-addresses/src/index.ts:22](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L22)* ___ @@ -69,7 +49,7 @@ ___ • **dutchAuction**: *string* -*Defined in [contract-addresses/src/index.ts:16](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L16)* +*Defined in [contract-addresses/src/index.ts:16](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L16)* ___ @@ -77,7 +57,7 @@ ___ • **erc1155Proxy**: *string* -*Defined in [contract-addresses/src/index.ts:21](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L21)* +*Defined in [contract-addresses/src/index.ts:21](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L21)* ___ @@ -85,7 +65,7 @@ ___ • **erc20BridgeProxy**: *string* -*Defined in [contract-addresses/src/index.ts:26](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L26)* +*Defined in [contract-addresses/src/index.ts:26](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L26)* ___ @@ -93,7 +73,7 @@ ___ • **erc20Proxy**: *string* -*Defined in [contract-addresses/src/index.ts:6](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L6)* +*Defined in [contract-addresses/src/index.ts:6](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L6)* ___ @@ -101,7 +81,7 @@ ___ • **erc721Proxy**: *string* -*Defined in [contract-addresses/src/index.ts:7](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L7)* +*Defined in [contract-addresses/src/index.ts:7](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L7)* ___ @@ -109,7 +89,7 @@ ___ • **etherToken**: *string* -*Defined in [contract-addresses/src/index.ts:9](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L9)* +*Defined in [contract-addresses/src/index.ts:9](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L9)* ___ @@ -117,7 +97,7 @@ ___ • **exchange**: *string* -*Defined in [contract-addresses/src/index.ts:11](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L11)* +*Defined in [contract-addresses/src/index.ts:11](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L11)* ___ @@ -125,7 +105,7 @@ ___ • **exchangeV2**: *string* -*Defined in [contract-addresses/src/index.ts:10](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L10)* +*Defined in [contract-addresses/src/index.ts:10](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L10)* ___ @@ -133,7 +113,7 @@ ___ • **forwarder**: *string* -*Defined in [contract-addresses/src/index.ts:14](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L14)* +*Defined in [contract-addresses/src/index.ts:14](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L14)* ___ @@ -141,7 +121,7 @@ ___ • **multiAssetProxy**: *string* -*Defined in [contract-addresses/src/index.ts:19](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L19)* +*Defined in [contract-addresses/src/index.ts:19](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L19)* ___ @@ -149,7 +129,7 @@ ___ • **orderValidator**: *string* -*Defined in [contract-addresses/src/index.ts:15](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L15)* +*Defined in [contract-addresses/src/index.ts:15](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L15)* ___ @@ -157,7 +137,7 @@ ___ • **staking**: *string* -*Defined in [contract-addresses/src/index.ts:24](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L24)* +*Defined in [contract-addresses/src/index.ts:24](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L24)* ___ @@ -165,7 +145,7 @@ ___ • **stakingProxy**: *string* -*Defined in [contract-addresses/src/index.ts:25](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L25)* +*Defined in [contract-addresses/src/index.ts:25](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L25)* ___ @@ -173,7 +153,7 @@ ___ • **staticCallProxy**: *string* -*Defined in [contract-addresses/src/index.ts:20](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L20)* +*Defined in [contract-addresses/src/index.ts:20](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L20)* ___ @@ -181,7 +161,7 @@ ___ • **zeroExGovernor**: *string* -*Defined in [contract-addresses/src/index.ts:13](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L13)* +*Defined in [contract-addresses/src/index.ts:13](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L13)* ___ @@ -189,7 +169,7 @@ ___ • **zrxToken**: *string* -*Defined in [contract-addresses/src/index.ts:8](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L8)* +*Defined in [contract-addresses/src/index.ts:8](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L8)* ___ @@ -197,7 +177,7 @@ ___ • **zrxVault**: *string* -*Defined in [contract-addresses/src/index.ts:23](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L23)* +*Defined in [contract-addresses/src/index.ts:23](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L23)*
@@ -246,7 +226,7 @@ ___ • **isEIP1193**: *boolean* -*Defined in [ethereum-types/src/index.ts:73](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L73)* +*Defined in [ethereum-types/src/index.ts:73](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L73)* ## Methods @@ -254,7 +234,7 @@ ___ ▸ **on**(`event`: [EIP1193Event](#eip1193event), `listener`: function): *this* -*Defined in [ethereum-types/src/index.ts:75](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L75)* +*Defined in [ethereum-types/src/index.ts:75](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L75)* **Parameters:** @@ -278,7 +258,7 @@ ___ ▸ **send**(`method`: string, `params?`: any[]): *`Promise`* -*Defined in [ethereum-types/src/index.ts:74](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L74)* +*Defined in [ethereum-types/src/index.ts:74](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L74)* **Parameters:** @@ -303,8 +283,28 @@ Name | Type | +# Interface: GanacheProvider +## Methods + +### sendAsync + +▸ **sendAsync**(`payload`: [JSONRPCRequestPayload](_ethereum_types_src_index_.jsonrpcrequestpayload.md), `callback`: [JSONRPCErrorCallback](#jsonrpcerrorcallback)): *void* + +*Defined in [ethereum-types/src/index.ts:14](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L14)* + +**Parameters:** + +Name | Type | +------ | ------ | +`payload` | [JSONRPCRequestPayload](#class-jsonrpcrequestpayload) | +`callback` | [JSONRPCErrorCallback](#jsonrpcerrorcallback) | + +**Returns:** *void* + +
+ # Interface: JSONRPCRequestPayload @@ -316,7 +316,7 @@ Name | Type | • **id**: *number* -*Defined in [ethereum-types/src/index.ts:330](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L330)* +*Defined in [ethereum-types/src/index.ts:330](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L330)* ___ @@ -324,7 +324,7 @@ ___ • **jsonrpc**: *string* -*Defined in [ethereum-types/src/index.ts:331](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L331)* +*Defined in [ethereum-types/src/index.ts:331](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L331)* ___ @@ -332,7 +332,7 @@ ___ • **method**: *string* -*Defined in [ethereum-types/src/index.ts:329](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L329)* +*Defined in [ethereum-types/src/index.ts:329](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L329)* ___ @@ -340,7 +340,7 @@ ___ • **params**: *any[]* -*Defined in [ethereum-types/src/index.ts:328](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L328)* +*Defined in [ethereum-types/src/index.ts:328](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L328)*
@@ -353,7 +353,7 @@ ___ • **code**: *number* -*Defined in [ethereum-types/src/index.ts:336](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L336)* +*Defined in [ethereum-types/src/index.ts:336](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L336)* ___ @@ -361,7 +361,7 @@ ___ • **message**: *string* -*Defined in [ethereum-types/src/index.ts:335](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L335)* +*Defined in [ethereum-types/src/index.ts:335](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L335)*
@@ -374,7 +374,7 @@ ___ • **error**? : *[JSONRPCResponseError](#class-jsonrpcresponseerror)* -*Defined in [ethereum-types/src/index.ts:343](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L343)* +*Defined in [ethereum-types/src/index.ts:343](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L343)* ___ @@ -382,7 +382,7 @@ ___ • **id**: *number* -*Defined in [ethereum-types/src/index.ts:341](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L341)* +*Defined in [ethereum-types/src/index.ts:341](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L341)* ___ @@ -390,7 +390,7 @@ ___ • **jsonrpc**: *string* -*Defined in [ethereum-types/src/index.ts:342](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L342)* +*Defined in [ethereum-types/src/index.ts:342](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L342)* ___ @@ -398,7 +398,7 @@ ___ • **result**: *any* -*Defined in [ethereum-types/src/index.ts:340](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L340)* +*Defined in [ethereum-types/src/index.ts:340](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L340)*
@@ -453,7 +453,7 @@ ___ *Inherited from [CallTxDataBase](#interface-calltxdatabase).[data](#optional-data)* -*Defined in [ethereum-types/src/index.ts:393](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L393)* +*Defined in [ethereum-types/src/index.ts:393](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L393)* ___ @@ -461,7 +461,7 @@ ___ • **from**: *string* -*Defined in [ethereum-types/src/index.ts:398](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L398)* +*Defined in [ethereum-types/src/index.ts:398](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L398)* ___ @@ -471,7 +471,7 @@ ___ *Inherited from [CallTxDataBase](#interface-calltxdatabase).[gas](#optional-gas)* -*Defined in [ethereum-types/src/index.ts:391](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L391)* +*Defined in [ethereum-types/src/index.ts:391](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L391)* ___ @@ -481,7 +481,7 @@ ___ *Inherited from [CallTxDataBase](#interface-calltxdatabase).[gasPrice](#optional-gasprice)* -*Defined in [ethereum-types/src/index.ts:392](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L392)* +*Defined in [ethereum-types/src/index.ts:392](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L392)* ___ @@ -491,7 +491,7 @@ ___ *Inherited from [CallTxDataBase](#interface-calltxdatabase).[nonce](#optional-nonce)* -*Defined in [ethereum-types/src/index.ts:394](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L394)* +*Defined in [ethereum-types/src/index.ts:394](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L394)* ___ @@ -501,7 +501,7 @@ ___ *Inherited from [CallTxDataBase](#interface-calltxdatabase).[to](#optional-to)* -*Defined in [ethereum-types/src/index.ts:389](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L389)* +*Defined in [ethereum-types/src/index.ts:389](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L389)* ___ @@ -511,7 +511,7 @@ ___ *Inherited from [CallTxDataBase](#interface-calltxdatabase).[value](#optional-value)* -*Defined in [ethereum-types/src/index.ts:390](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L390)* +*Defined in [ethereum-types/src/index.ts:390](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L390)*
@@ -526,7 +526,7 @@ ___ *Inherited from [CallTxDataBase](#interface-calltxdatabase).[data](#optional-data)* -*Defined in [ethereum-types/src/index.ts:393](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L393)* +*Defined in [ethereum-types/src/index.ts:393](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L393)* ___ @@ -536,7 +536,7 @@ ___ *Inherited from [TxData](#interface-txdata).[from](#from)* -*Defined in [ethereum-types/src/index.ts:398](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L398)* +*Defined in [ethereum-types/src/index.ts:398](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L398)* ___ @@ -546,7 +546,7 @@ ___ *Inherited from [CallTxDataBase](#interface-calltxdatabase).[gas](#optional-gas)* -*Defined in [ethereum-types/src/index.ts:391](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L391)* +*Defined in [ethereum-types/src/index.ts:391](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L391)* ___ @@ -556,7 +556,7 @@ ___ *Inherited from [CallTxDataBase](#interface-calltxdatabase).[gasPrice](#optional-gasprice)* -*Defined in [ethereum-types/src/index.ts:392](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L392)* +*Defined in [ethereum-types/src/index.ts:392](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L392)* ___ @@ -566,7 +566,7 @@ ___ *Inherited from [CallTxDataBase](#interface-calltxdatabase).[nonce](#optional-nonce)* -*Defined in [ethereum-types/src/index.ts:394](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L394)* +*Defined in [ethereum-types/src/index.ts:394](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L394)* ___ @@ -576,7 +576,7 @@ ___ *Inherited from [CallTxDataBase](#interface-calltxdatabase).[to](#optional-to)* -*Defined in [ethereum-types/src/index.ts:389](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L389)* +*Defined in [ethereum-types/src/index.ts:389](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L389)* ___ @@ -586,7 +586,7 @@ ___ *Overrides [CallTxDataBase](_ethereum_types_src_index_.calltxdatabase.md).[value](#optional-value)* -*Defined in [ethereum-types/src/index.ts:442](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L442)* +*Defined in [ethereum-types/src/index.ts:442](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L442)*
@@ -603,7 +603,7 @@ This interface allowed sending synchonous requests, support for which was later ▸ **send**(`payload`: [JSONRPCRequestPayload](_ethereum_types_src_index_.jsonrpcrequestpayload.md)): *[JSONRPCResponsePayload](#class-jsonrpcresponsepayload)* -*Defined in [ethereum-types/src/index.ts:45](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L45)* +*Defined in [ethereum-types/src/index.ts:45](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L45)* **Parameters:** @@ -619,7 +619,7 @@ ___ ▸ **sendAsync**(`payload`: [JSONRPCRequestPayload](_ethereum_types_src_index_.jsonrpcrequestpayload.md), `callback`: [JSONRPCErrorCallback](#jsonrpcerrorcallback)): *void* -*Defined in [ethereum-types/src/index.ts:44](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L44)* +*Defined in [ethereum-types/src/index.ts:44](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L44)* **Parameters:** @@ -645,7 +645,7 @@ before the first attempts to conform to EIP1193 ▸ **send**(`payload`: [JSONRPCRequestPayload](_ethereum_types_src_index_.jsonrpcrequestpayload.md), `callback`: [JSONRPCErrorCallback](#jsonrpcerrorcallback)): *void* -*Defined in [ethereum-types/src/index.ts:54](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L54)* +*Defined in [ethereum-types/src/index.ts:54](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L54)* **Parameters:** @@ -671,7 +671,7 @@ however it does not conform entirely. ▸ **send**(`method`: string, `params?`: any[]): *`Promise`* -*Defined in [ethereum-types/src/index.ts:63](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L63)* +*Defined in [ethereum-types/src/index.ts:63](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L63)* **Parameters:** @@ -697,7 +697,7 @@ add here • **isMetaMask**? : *undefined | false | true* -*Defined in [ethereum-types/src/index.ts:31](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L31)* +*Defined in [ethereum-types/src/index.ts:31](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L31)* ___ @@ -705,7 +705,7 @@ ___ • **isParity**? : *undefined | false | true* -*Defined in [ethereum-types/src/index.ts:32](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L32)* +*Defined in [ethereum-types/src/index.ts:32](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L32)* ___ @@ -713,7 +713,7 @@ ___ • **isZeroExProvider**? : *undefined | false | true* -*Defined in [ethereum-types/src/index.ts:30](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L30)* +*Defined in [ethereum-types/src/index.ts:30](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L30)* ## Methods @@ -721,7 +721,7 @@ ___ ▸ **enable**(): *`Promise`* -*Defined in [ethereum-types/src/index.ts:34](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L34)* +*Defined in [ethereum-types/src/index.ts:34](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L34)* **Returns:** *`Promise`* @@ -731,7 +731,7 @@ ___ ▸ **sendAsync**(`payload`: [JSONRPCRequestPayload](_ethereum_types_src_index_.jsonrpcrequestpayload.md), `callback`: [JSONRPCErrorCallback](#jsonrpcerrorcallback)): *void* -*Defined in [ethereum-types/src/index.ts:35](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L35)* +*Defined in [ethereum-types/src/index.ts:35](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L35)* **Parameters:** @@ -748,7 +748,7 @@ ___ ▸ **stop**(): *void* -*Defined in [ethereum-types/src/index.ts:33](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L33)* +*Defined in [ethereum-types/src/index.ts:33](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L33)* **Returns:** *void* @@ -757,63 +757,13 @@ ___ -## Functions - -### runMigrationsAsync - -▸ **runMigrationsAsync**(`supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `TxData`): *`Promise`* - -*Defined in [migrations/src/migration.ts:63](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/migrations/src/migration.ts#L63)* - -Creates and deploys all the contracts that are required for the latest -version of the 0x protocol. - -**Parameters:** - -Name | Type | Description | ------- | ------ | ------ | -`supportedProvider` | [SupportedProvider](#supportedprovider) | Web3 provider instance. Your provider instance should connect to the testnet you want to deploy to. | -`txDefaults` | `TxData` | Default transaction values to use when deploying contracts (e.g., specify the desired contract creator with the `from` parameter). | - -**Returns:** *`Promise`* - -The addresses of the contracts that were deployed. - -___ - -### runMigrationsOnceAsync - -▸ **runMigrationsOnceAsync**(`provider`: `Web3ProviderEngine`, `txDefaults`: `TxData`): *`Promise`* - -*Defined in [migrations/src/migration.ts:330](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/migrations/src/migration.ts#L330)* - -Exactly like runMigrationsAsync but will only run the migrations the first -time it is called. Any subsequent calls will return the cached contract -addresses. - -**Parameters:** - -Name | Type | Description | ------- | ------ | ------ | -`provider` | `Web3ProviderEngine` | Web3 provider instance. Your provider instance should connect to the testnet you want to deploy to. | -`txDefaults` | `TxData` | Default transaction values to use when deploying contracts (e.g., specify the desired contract creator with the `from` parameter). | - -**Returns:** *`Promise`* - -The addresses of the contracts that were deployed. - -
- - - - ## Functions ### getContractAddressesForChainOrThrow ▸ **getContractAddressesForChainOrThrow**(`chainId`: [ChainId](#enumeration-chainid)): *[ContractAddresses](#interface-contractaddresses)* -*Defined in [contract-addresses/src/index.ts:45](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/contract-addresses/src/index.ts#L45)* +*Defined in [contract-addresses/src/index.ts:45](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/contract-addresses/src/index.ts#L45)* Used to get addresses of contracts that have been deployed to either the Ethereum mainnet or a supported testnet. Throws if there are no known @@ -853,7 +803,7 @@ given chainId. Ƭ **EIP1193Event**: *"accountsChanged" | "networkChanged" | "close" | "connect" | "notification"* -*Defined in [ethereum-types/src/index.ts:70](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L70)* +*Defined in [ethereum-types/src/index.ts:70](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L70)* Interface for providers that conform to EIP 1193 Source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1193.md @@ -870,7 +820,7 @@ ___ Ƭ **JSONRPCErrorCallback**: *function* -*Defined in [ethereum-types/src/index.ts:3](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L3)* +*Defined in [ethereum-types/src/index.ts:3](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L3)* #### Type declaration: @@ -899,7 +849,7 @@ ___ Ƭ **SupportedProvider**: *[Web3JsProvider](_ethereum_types_src_index_.md#web3jsprovider) | [GanacheProvider](#interface-ganacheprovider) | [EIP1193Provider](#interface-eip1193provider) | [ZeroExProvider](#interface-zeroexprovider)* -*Defined in [ethereum-types/src/index.ts:9](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L9)* +*Defined in [ethereum-types/src/index.ts:9](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L9)* Do not create your own provider. Use an existing provider from a Web3 or ProviderEngine library Read more about Providers in the guides section of the 0x docs. @@ -914,7 +864,57 @@ ___ Ƭ **Web3JsProvider**: *[Web3JsV1Provider](#interface-web3jsv1provider) | [Web3JsV2Provider](#interface-web3jsv2provider) | [Web3JsV3Provider](#interface-web3jsv3provider)* -*Defined in [ethereum-types/src/index.ts:11](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L11)* +*Defined in [ethereum-types/src/index.ts:11](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L11)* + +
+ + + + +## Functions + +### runMigrationsAsync + +▸ **runMigrationsAsync**(`supportedProvider`: [SupportedProvider](#supportedprovider), `txDefaults`: `TxData`): *`Promise`* + +*Defined in [migrations/src/migration.ts:49](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/migrations/src/migration.ts#L49)* + +Creates and deploys all the contracts that are required for the latest +version of the 0x protocol. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`supportedProvider` | [SupportedProvider](#supportedprovider) | Web3 provider instance. Your provider instance should connect to the testnet you want to deploy to. | +`txDefaults` | `TxData` | Default transaction values to use when deploying contracts (e.g., specify the desired contract creator with the `from` parameter). | + +**Returns:** *`Promise`* + +The addresses of the contracts that were deployed. + +___ + +### runMigrationsOnceAsync + +▸ **runMigrationsOnceAsync**(`provider`: `Web3ProviderEngine`, `txDefaults`: `TxData`): *`Promise`* + +*Defined in [migrations/src/migration.ts:317](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/migrations/src/migration.ts#L317)* + +Exactly like runMigrationsAsync but will only run the migrations the first +time it is called. Any subsequent calls will return the cached contract +addresses. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`provider` | `Web3ProviderEngine` | Web3 provider instance. Your provider instance should connect to the testnet you want to deploy to. | +`txDefaults` | `TxData` | Default transaction values to use when deploying contracts (e.g., specify the desired contract creator with the `from` parameter). | + +**Returns:** *`Promise`* + +The addresses of the contracts that were deployed.
diff --git a/packages/order-utils/docs/reference.mdx b/packages/order-utils/docs/reference.mdx index 81716ae148..543fe662a9 100644 --- a/packages/order-utils/docs/reference.mdx +++ b/packages/order-utils/docs/reference.mdx @@ -1,84 +1,1024 @@ +# Class: AbstractBalanceAndProxyAllowanceFetcher +An abstract class to be implemented in order to use OrderStateUtils. The class that +implements this interface must be capable of fetching the balance and proxyAllowance +for an Ethereum address and assetData +## Methods + +### `Abstract` getBalanceAsync + +▸ **getBalanceAsync**(`assetData`: string, `userAddress`: string): *`Promise`* + +*Defined in [order-utils/src/abstract/abstract_balance_and_proxy_allowance_fetcher.ts:15](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/abstract/abstract_balance_and_proxy_allowance_fetcher.ts#L15)* + +Get balance of assetData for userAddress + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`assetData` | string | AssetData for which to fetch the balance | +`userAddress` | string | Ethereum address for which to fetch the balance | + +**Returns:** *`Promise`* + +Balance amount in base units + +___ + +### `Abstract` getProxyAllowanceAsync + +▸ **getProxyAllowanceAsync**(`assetData`: string, `userAddress`: string): *`Promise`* + +*Defined in [order-utils/src/abstract/abstract_balance_and_proxy_allowance_fetcher.ts:22](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/abstract/abstract_balance_and_proxy_allowance_fetcher.ts#L22)* + +Get the 0x asset proxy allowance of assetData for userAddress + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`assetData` | string | AssetData for which to fetch the allowance | +`userAddress` | string | Ethereum address for which to fetch the allowance | + +**Returns:** *`Promise`* + +Allowance amount in base units + +
+ +# Class: AbstractBalanceAndProxyAllowanceLazyStore + + +## Implemented by + +* [BalanceAndProxyAllowanceLazyStore](#class-balanceandproxyallowancelazystore) + + +## Methods + +### `Abstract` deleteAll + +▸ **deleteAll**(): *void* + +*Defined in [order-utils/src/abstract/abstract_balance_and_proxy_allowance_lazy_store.ts:10](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/abstract/abstract_balance_and_proxy_allowance_lazy_store.ts#L10)* + +**Returns:** *void* + +___ + +### `Abstract` deleteBalance + +▸ **deleteBalance**(`assetData`: string, `userAddress`: string): *void* + +*Defined in [order-utils/src/abstract/abstract_balance_and_proxy_allowance_lazy_store.ts:7](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/abstract/abstract_balance_and_proxy_allowance_lazy_store.ts#L7)* + +**Parameters:** + +Name | Type | +------ | ------ | +`assetData` | string | +`userAddress` | string | + +**Returns:** *void* + +___ + +### `Abstract` deleteProxyAllowance + +▸ **deleteProxyAllowance**(`assetData`: string, `userAddress`: string): *void* + +*Defined in [order-utils/src/abstract/abstract_balance_and_proxy_allowance_lazy_store.ts:9](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/abstract/abstract_balance_and_proxy_allowance_lazy_store.ts#L9)* + +**Parameters:** + +Name | Type | +------ | ------ | +`assetData` | string | +`userAddress` | string | + +**Returns:** *void* + +___ + +### `Abstract` getBalanceAsync + +▸ **getBalanceAsync**(`assetData`: string, `userAddress`: string): *`Promise`* + +*Defined in [order-utils/src/abstract/abstract_balance_and_proxy_allowance_lazy_store.ts:4](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/abstract/abstract_balance_and_proxy_allowance_lazy_store.ts#L4)* + +**Parameters:** + +Name | Type | +------ | ------ | +`assetData` | string | +`userAddress` | string | + +**Returns:** *`Promise`* + +___ + +### `Abstract` getProxyAllowanceAsync + +▸ **getProxyAllowanceAsync**(`assetData`: string, `userAddress`: string): *`Promise`* + +*Defined in [order-utils/src/abstract/abstract_balance_and_proxy_allowance_lazy_store.ts:5](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/abstract/abstract_balance_and_proxy_allowance_lazy_store.ts#L5)* + +**Parameters:** + +Name | Type | +------ | ------ | +`assetData` | string | +`userAddress` | string | + +**Returns:** *`Promise`* + +___ + +### `Abstract` setBalance + +▸ **setBalance**(`assetData`: string, `userAddress`: string, `balance`: `BigNumber`): *void* + +*Defined in [order-utils/src/abstract/abstract_balance_and_proxy_allowance_lazy_store.ts:6](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/abstract/abstract_balance_and_proxy_allowance_lazy_store.ts#L6)* + +**Parameters:** + +Name | Type | +------ | ------ | +`assetData` | string | +`userAddress` | string | +`balance` | `BigNumber` | + +**Returns:** *void* + +___ + +### `Abstract` setProxyAllowance + +▸ **setProxyAllowance**(`assetData`: string, `userAddress`: string, `proxyAllowance`: `BigNumber`): *void* + +*Defined in [order-utils/src/abstract/abstract_balance_and_proxy_allowance_lazy_store.ts:8](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/abstract/abstract_balance_and_proxy_allowance_lazy_store.ts#L8)* + +**Parameters:** + +Name | Type | +------ | ------ | +`assetData` | string | +`userAddress` | string | +`proxyAllowance` | `BigNumber` | + +**Returns:** *void* + +
+ +# Class: AbstractOrderFilledCancelledFetcher + +An abstract class to be implemented in order to use OrderStateUtils. The class that +implements this interface must be capable of fetching the amount filled of an order +and whether it's been cancelled. + + +## Methods + +### `Abstract` getFilledTakerAmountAsync + +▸ **getFilledTakerAmountAsync**(`orderHash`: string): *`Promise`* + +*Defined in [order-utils/src/abstract/abstract_order_filled_cancelled_fetcher.ts:15](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/abstract/abstract_order_filled_cancelled_fetcher.ts#L15)* + +Get the amount of the order's takerToken amount already filled + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`orderHash` | string | OrderHash of order we are interested in | + +**Returns:** *`Promise`* + +FilledTakerAmount + +___ + +### `Abstract` isOrderCancelledAsync + +▸ **isOrderCancelledAsync**(`signedOrder`: `SignedOrder`): *`Promise`* + +*Defined in [order-utils/src/abstract/abstract_order_filled_cancelled_fetcher.ts:21](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/abstract/abstract_order_filled_cancelled_fetcher.ts#L21)* + +Whether an order is cancelled + +**Parameters:** + +Name | Type | +------ | ------ | +`signedOrder` | `SignedOrder` | + +**Returns:** *`Promise`* + +Whether or not the order is cancelled + +
+ +# Class: AbstractOrderFilledCancelledLazyStore + + +## Implemented by + +* [OrderFilledCancelledLazyStore](#class-orderfilledcancelledlazystore) + + +## Methods + +### `Abstract` deleteAll + +▸ **deleteAll**(): *void* + +*Defined in [order-utils/src/abstract/abstract_order_filled_cancelled_lazy_store.ts:11](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/abstract/abstract_order_filled_cancelled_lazy_store.ts#L11)* + +**Returns:** *void* + +___ + +### `Abstract` deleteFilledTakerAmount + +▸ **deleteFilledTakerAmount**(`orderHash`: string): *void* + +*Defined in [order-utils/src/abstract/abstract_order_filled_cancelled_lazy_store.ts:8](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/abstract/abstract_order_filled_cancelled_lazy_store.ts#L8)* + +**Parameters:** + +Name | Type | +------ | ------ | +`orderHash` | string | + +**Returns:** *void* + +___ + +### `Abstract` deleteIsCancelled + +▸ **deleteIsCancelled**(`orderHash`: string): *void* + +*Defined in [order-utils/src/abstract/abstract_order_filled_cancelled_lazy_store.ts:10](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/abstract/abstract_order_filled_cancelled_lazy_store.ts#L10)* + +**Parameters:** + +Name | Type | +------ | ------ | +`orderHash` | string | + +**Returns:** *void* + +___ + +### `Abstract` getFilledTakerAmountAsync + +▸ **getFilledTakerAmountAsync**(`orderHash`: string): *`Promise`* + +*Defined in [order-utils/src/abstract/abstract_order_filled_cancelled_lazy_store.ts:5](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/abstract/abstract_order_filled_cancelled_lazy_store.ts#L5)* + +**Parameters:** + +Name | Type | +------ | ------ | +`orderHash` | string | + +**Returns:** *`Promise`* + +___ + +### `Abstract` getIsCancelledAsync + +▸ **getIsCancelledAsync**(`signedOrder`: `SignedOrder`): *`Promise`* + +*Defined in [order-utils/src/abstract/abstract_order_filled_cancelled_lazy_store.ts:6](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/abstract/abstract_order_filled_cancelled_lazy_store.ts#L6)* + +**Parameters:** + +Name | Type | +------ | ------ | +`signedOrder` | `SignedOrder` | + +**Returns:** *`Promise`* + +___ + +### `Abstract` setFilledTakerAmount + +▸ **setFilledTakerAmount**(`orderHash`: string, `balance`: `BigNumber`): *void* + +*Defined in [order-utils/src/abstract/abstract_order_filled_cancelled_lazy_store.ts:7](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/abstract/abstract_order_filled_cancelled_lazy_store.ts#L7)* + +**Parameters:** + +Name | Type | +------ | ------ | +`orderHash` | string | +`balance` | `BigNumber` | + +**Returns:** *void* + +___ + +### `Abstract` setIsCancelled + +▸ **setIsCancelled**(`orderHash`: string, `isCancelled`: boolean): *void* + +*Defined in [order-utils/src/abstract/abstract_order_filled_cancelled_lazy_store.ts:9](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/abstract/abstract_order_filled_cancelled_lazy_store.ts#L9)* + +**Parameters:** + +Name | Type | +------ | ------ | +`orderHash` | string | +`isCancelled` | boolean | + +**Returns:** *void* + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +# Class: ExchangeTransferSimulator + +An exchange transfer simulator which simulates asset transfers exactly how the +0x exchange contract would do them. + + +## Constructors + + + +\+ **new ExchangeTransferSimulator**(`store`: [AbstractBalanceAndProxyAllowanceLazyStore](_order_utils_src_abstract_abstract_balance_and_proxy_allowance_lazy_store_.abstractbalanceandproxyallowancelazystore.md)): *[ExchangeTransferSimulator](#class-exchangetransfersimulator)* + +*Defined in [order-utils/src/exchange_transfer_simulator.ts:50](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/exchange_transfer_simulator.ts#L50)* + +Instantiate a ExchangeTransferSimulator + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`store` | [AbstractBalanceAndProxyAllowanceLazyStore](#class-abstractbalanceandproxyallowancelazystore) | A class that implements AbstractBalanceAndProxyAllowanceLazyStore | + +**Returns:** *[ExchangeTransferSimulator](#class-exchangetransfersimulator)* + +an instance of ExchangeTransferSimulator + +## Methods + +### transferFromAsync + +▸ **transferFromAsync**(`assetData`: string, `from`: string, `to`: string, `amountInBaseUnits`: `BigNumber`, `tradeSide`: [TradeSide](#enumeration-tradeside), `transferType`: [TransferType](#enumeration-transfertype)): *`Promise`* + +*Defined in [order-utils/src/exchange_transfer_simulator.ts:70](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/exchange_transfer_simulator.ts#L70)* + +Simulates transferFrom call performed by a proxy + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`assetData` | string | Data of the asset being transferred. Includes it's identifying information and assetType, e.g address for ERC20, address & tokenId for ERC721 | +`from` | string | Owner of the transferred tokens | +`to` | string | Recipient of the transferred tokens | +`amountInBaseUnits` | `BigNumber` | The amount of tokens being transferred | +`tradeSide` | [TradeSide](#enumeration-tradeside) | Is Maker/Taker transferring | +`transferType` | [TransferType](#enumeration-transfertype) | Is it a fee payment or a value transfer | + +**Returns:** *`Promise`* + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +# Class: OrderStateUtils + + +## Constructors + + + +\+ **new OrderStateUtils**(`balanceAndProxyAllowanceFetcher`: [AbstractBalanceAndProxyAllowanceFetcher](_order_utils_src_abstract_abstract_balance_and_proxy_allowance_fetcher_.abstractbalanceandproxyallowancefetcher.md), `orderFilledCancelledFetcher`: [AbstractOrderFilledCancelledFetcher](_order_utils_src_abstract_abstract_order_filled_cancelled_fetcher_.abstractorderfilledcancelledfetcher.md)): *[OrderStateUtils](#class-orderstateutils)* + +*Defined in [order-utils/src/order_state_utils.ts:103](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/order_state_utils.ts#L103)* + +Instantiate OrderStateUtils + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`balanceAndProxyAllowanceFetcher` | [AbstractBalanceAndProxyAllowanceFetcher](#class-abstractbalanceandproxyallowancefetcher) | A class that is capable of fetching balances and proxyAllowances for Ethereum addresses. It must implement AbstractBalanceAndProxyAllowanceFetcher | +`orderFilledCancelledFetcher` | [AbstractOrderFilledCancelledFetcher](#class-abstractorderfilledcancelledfetcher) | A class that is capable of fetching whether an order is cancelled and how much of it has been filled. It must implement AbstractOrderFilledCancelledFetcher | + +**Returns:** *[OrderStateUtils](#class-orderstateutils)* + +Instance of OrderStateUtils + +## Methods + +### getMaxFillableTakerAssetAmountAsync + +▸ **getMaxFillableTakerAssetAmountAsync**(`signedOrder`: `SignedOrder`, `takerAddress`: string): *`Promise`* + +*Defined in [order-utils/src/order_state_utils.ts:197](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/order_state_utils.ts#L197)* + +Get the max amount of the supplied order's takerAmount that could still be filled + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`signedOrder` | `SignedOrder` | Order of interest | +`takerAddress` | string | Hypothetical taker of the order | + +**Returns:** *`Promise`* + +fillableTakerAssetAmount + +___ + +### getOpenOrderRelevantStateAsync + +▸ **getOpenOrderRelevantStateAsync**(`signedOrder`: `SignedOrder`): *`Promise`* + +*Defined in [order-utils/src/order_state_utils.ts:167](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/order_state_utils.ts#L167)* + +Get state relevant to an order (i.e makerBalance, makerAllowance, filledTakerAssetAmount, etc... + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`signedOrder` | `SignedOrder` | Order of interest | + +**Returns:** *`Promise`* + +An instance of OrderRelevantState + +___ + +### getOpenOrderStateAsync + +▸ **getOpenOrderStateAsync**(`signedOrder`: `SignedOrder`, `transactionHash?`: undefined | string): *`Promise`* + +*Defined in [order-utils/src/order_state_utils.ts:127](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/order_state_utils.ts#L127)* + +Get the orderState for an "open" order (i.e where takerAddress=NULL_ADDRESS) +This method will only check the maker's balance/allowance to calculate the +OrderState. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`signedOrder` | `SignedOrder` | The order of interest | +`transactionHash?` | undefined \| string | - | + +**Returns:** *`Promise`* + +State relevant to the signedOrder, as well as whether the signedOrder is "valid". +Validity is defined as a non-zero amount of the order can still be filled. + +
+ +# Class: OrderValidationUtils + +A utility class for validating orders + + +## Constructors + + + +\+ **new OrderValidationUtils**(`orderFilledCancelledFetcher`: [AbstractOrderFilledCancelledFetcher](_order_utils_src_abstract_abstract_order_filled_cancelled_fetcher_.abstractorderfilledcancelledfetcher.md), `supportedProvider`: [SupportedProvider](#supportedprovider)): *[OrderValidationUtils](#class-ordervalidationutils)* + +*Defined in [order-utils/src/order_validation_utils.ts:113](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/order_validation_utils.ts#L113)* + +Instantiate OrderValidationUtils + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`orderFilledCancelledFetcher` | [AbstractOrderFilledCancelledFetcher](#class-abstractorderfilledcancelledfetcher) | A module that implements the AbstractOrderFilledCancelledFetcher | +`supportedProvider` | [SupportedProvider](#supportedprovider) | Web3 provider to use for JSON RPC calls | + +**Returns:** *[OrderValidationUtils](#class-ordervalidationutils)* + +An instance of OrderValidationUtils + +## Methods + +### validateFillOrderThrowIfInvalidAsync + +▸ **validateFillOrderThrowIfInvalidAsync**(`exchangeTradeEmulator`: [ExchangeTransferSimulator](#class-exchangetransfersimulator), `signedOrder`: `SignedOrder`, `fillTakerAssetAmount`: `BigNumber`, `takerAddress`: string): *`Promise`* + +*Defined in [order-utils/src/order_validation_utils.ts:135](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/order_validation_utils.ts#L135)* + +Validate a call to FillOrder and throw if it wouldn't succeed + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`exchangeTradeEmulator` | [ExchangeTransferSimulator](#class-exchangetransfersimulator) | ExchangeTradeEmulator to use | +`signedOrder` | `SignedOrder` | SignedOrder of interest | +`fillTakerAssetAmount` | `BigNumber` | Amount we'd like to fill the order for | +`takerAddress` | string | The taker of the order | + +**Returns:** *`Promise`* + +___ + +### `Static` isRoundingErrorFloor + +▸ **isRoundingErrorFloor**(`numerator`: `BigNumber`, `denominator`: `BigNumber`, `target`: `BigNumber`): *boolean* + +*Defined in [order-utils/src/order_validation_utils.ts:27](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/order_validation_utils.ts#L27)* + +A TypeScript implementation mirroring the implementation of isRoundingError in the +Exchange smart contract + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`numerator` | `BigNumber` | Numerator value. When used to check an order, pass in `takerAssetFilledAmount` | +`denominator` | `BigNumber` | Denominator value. When used to check an order, pass in `order.takerAssetAmount` | +`target` | `BigNumber` | Target value. When used to check an order, pass in `order.makerAssetAmount` | + +**Returns:** *boolean* + +___ + +### `Static` validateFillOrderBalancesAllowancesThrowIfInvalidAsync + +▸ **validateFillOrderBalancesAllowancesThrowIfInvalidAsync**(`exchangeTradeEmulator`: [ExchangeTransferSimulator](#class-exchangetransfersimulator), `signedOrder`: `SignedOrder`, `fillTakerAssetAmount`: `BigNumber`, `senderAddress`: string): *`Promise`* + +*Defined in [order-utils/src/order_validation_utils.ts:53](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/order_validation_utils.ts#L53)* + +Validate that the maker & taker have sufficient balances/allowances +to fill the supplied order to the fillTakerAssetAmount amount + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`exchangeTradeEmulator` | [ExchangeTransferSimulator](#class-exchangetransfersimulator) | ExchangeTradeEmulator to use | +`signedOrder` | `SignedOrder` | SignedOrder to test | +`fillTakerAssetAmount` | `BigNumber` | Amount of takerAsset to fill the signedOrder | +`senderAddress` | string | Sender of the fillOrder tx | + +**Returns:** *`Promise`* + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +# Class: BalanceAndProxyAllowanceLazyStore + +Copy on read store for balances/proxyAllowances of tokens/accounts + + +## Implements + +* [AbstractBalanceAndProxyAllowanceLazyStore](#class-abstractbalanceandproxyallowancelazystore) + + +## Constructors + + + +\+ **new BalanceAndProxyAllowanceLazyStore**(`balanceAndProxyAllowanceFetcher`: [AbstractBalanceAndProxyAllowanceFetcher](_order_utils_src_abstract_abstract_balance_and_proxy_allowance_fetcher_.abstractbalanceandproxyallowancefetcher.md)): *[BalanceAndProxyAllowanceLazyStore](#class-balanceandproxyallowancelazystore)* + +*Defined in [order-utils/src/store/balance_and_proxy_allowance_lazy_store.ts:21](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/store/balance_and_proxy_allowance_lazy_store.ts#L21)* + +Instantiates a BalanceAndProxyAllowanceLazyStore +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`balanceAndProxyAllowanceFetcher` | [AbstractBalanceAndProxyAllowanceFetcher](#class-abstractbalanceandproxyallowancefetcher) | Class the implements the AbstractBalanceAndProxyAllowanceFetcher | + +**Returns:** *[BalanceAndProxyAllowanceLazyStore](#class-balanceandproxyallowancelazystore)* + +Instance of BalanceAndProxyAllowanceLazyStore + +## Methods + +### deleteAll + +▸ **deleteAll**(): *void* + +*Defined in [order-utils/src/store/balance_and_proxy_allowance_lazy_store.ts:115](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/store/balance_and_proxy_allowance_lazy_store.ts#L115)* + +Delete all balances & allowances + +**Returns:** *void* + +___ + +### deleteBalance + +▸ **deleteBalance**(`assetData`: string, `userAddress`: string): *void* + +*Defined in [order-utils/src/store/balance_and_proxy_allowance_lazy_store.ts:61](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/store/balance_and_proxy_allowance_lazy_store.ts#L61)* + +Clear the balance of an asset for a user + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`assetData` | string | AssetData of interest | +`userAddress` | string | Ethereum address of interest | + +**Returns:** *void* + +___ + +### deleteProxyAllowance + +▸ **deleteProxyAllowance**(`assetData`: string, `userAddress`: string): *void* + +*Defined in [order-utils/src/store/balance_and_proxy_allowance_lazy_store.ts:104](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/store/balance_and_proxy_allowance_lazy_store.ts#L104)* + +Clear the 0x asset proxy allowance + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`assetData` | string | AssetData of interest | +`userAddress` | string | Ethereum address of interest | + +**Returns:** *void* + +___ + +### getBalanceAsync + +▸ **getBalanceAsync**(`assetData`: string, `userAddress`: string): *`Promise`* + +*Defined in [order-utils/src/store/balance_and_proxy_allowance_lazy_store.ts:37](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/store/balance_and_proxy_allowance_lazy_store.ts#L37)* + +Get a users balance of an asset + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`assetData` | string | AssetData of interest | +`userAddress` | string | Ethereum address of interest | + +**Returns:** *`Promise`* + +___ + +### getProxyAllowanceAsync + +▸ **getProxyAllowanceAsync**(`assetData`: string, `userAddress`: string): *`Promise`* + +*Defined in [order-utils/src/store/balance_and_proxy_allowance_lazy_store.ts:74](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/store/balance_and_proxy_allowance_lazy_store.ts#L74)* + +Get the 0x asset proxy allowance + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`assetData` | string | AssetData of interest | +`userAddress` | string | Ethereum address of interest | + +**Returns:** *`Promise`* +___ + +### setBalance + +▸ **setBalance**(`assetData`: string, `userAddress`: string, `balance`: `BigNumber`): *void* + +*Defined in [order-utils/src/store/balance_and_proxy_allowance_lazy_store.ts:50](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/store/balance_and_proxy_allowance_lazy_store.ts#L50)* + +Set the balance of an asset for a user + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`assetData` | string | AssetData of interest | +`userAddress` | string | Ethereum address of interest | +`balance` | `BigNumber` | - | + +**Returns:** *void* + +___ + +### setProxyAllowance + +▸ **setProxyAllowance**(`assetData`: string, `userAddress`: string, `proxyAllowance`: `BigNumber`): *void* + +*Defined in [order-utils/src/store/balance_and_proxy_allowance_lazy_store.ts:93](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/store/balance_and_proxy_allowance_lazy_store.ts#L93)* + +Set the 0x asset proxy allowance + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`assetData` | string | AssetData of interest | +`userAddress` | string | Ethereum address of interest | +`proxyAllowance` | `BigNumber` | - | + +**Returns:** *void* + +
+ +# Class: OrderFilledCancelledLazyStore + +Copy on read store for balances/proxyAllowances of tokens/accounts + + +## Implements + +* [AbstractOrderFilledCancelledLazyStore](#class-abstractorderfilledcancelledlazystore) +## Constructors +\+ **new OrderFilledCancelledLazyStore**(`orderFilledCancelledFetcher`: [AbstractOrderFilledCancelledFetcher](_order_utils_src_abstract_abstract_order_filled_cancelled_fetcher_.abstractorderfilledcancelledfetcher.md)): *[OrderFilledCancelledLazyStore](#class-orderfilledcancelledlazystore)* +*Defined in [order-utils/src/store/order_filled_cancelled_lazy_store.ts:19](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/store/order_filled_cancelled_lazy_store.ts#L19)* +Instantiate a OrderFilledCancelledLazyStore +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`orderFilledCancelledFetcher` | [AbstractOrderFilledCancelledFetcher](#class-abstractorderfilledcancelledfetcher) | Class instance that implements the AbstractOrderFilledCancelledFetcher | + +**Returns:** *[OrderFilledCancelledLazyStore](#class-orderfilledcancelledlazystore)* + +An instance of OrderFilledCancelledLazyStore + +## Methods +### deleteAll +▸ **deleteAll**(): *void* +*Defined in [order-utils/src/store/order_filled_cancelled_lazy_store.ts:90](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/store/order_filled_cancelled_lazy_store.ts#L90)* +Clear all filled/cancelled state +**Returns:** *void* +___ +### deleteAllFilled +▸ **deleteAllFilled**(): *void* +*Defined in [order-utils/src/store/order_filled_cancelled_lazy_store.ts:103](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/store/order_filled_cancelled_lazy_store.ts#L103)* +Clear all filled state +**Returns:** *void* +___ +### deleteAllIsCancelled +▸ **deleteAllIsCancelled**(): *void* +*Defined in [order-utils/src/store/order_filled_cancelled_lazy_store.ts:97](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/store/order_filled_cancelled_lazy_store.ts#L97)* +Clear all cancelled state +**Returns:** *void* +___ +### deleteFilledTakerAmount +▸ **deleteFilledTakerAmount**(`orderHash`: string): *void* +*Defined in [order-utils/src/store/order_filled_cancelled_lazy_store.ts:55](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/store/order_filled_cancelled_lazy_store.ts#L55)* +Clear the filledTakerAssetAmount of an order +**Parameters:** +Name | Type | Description | +------ | ------ | ------ | +`orderHash` | string | OrderHash from order of interest | +**Returns:** *void* +___ +### deleteIsCancelled +▸ **deleteIsCancelled**(`orderHash`: string): *void* +*Defined in [order-utils/src/store/order_filled_cancelled_lazy_store.ts:84](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/store/order_filled_cancelled_lazy_store.ts#L84)* +Clear whether the order has been cancelled if already set +**Parameters:** +Name | Type | Description | +------ | ------ | ------ | +`orderHash` | string | OrderHash from order of interest | +**Returns:** *void* +___ +### getFilledTakerAmountAsync +▸ **getFilledTakerAmountAsync**(`orderHash`: string): *`Promise`* +*Defined in [order-utils/src/store/order_filled_cancelled_lazy_store.ts:35](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/store/order_filled_cancelled_lazy_store.ts#L35)* +Get the filledTakerAssetAmount of an order +**Parameters:** +Name | Type | Description | +------ | ------ | ------ | +`orderHash` | string | OrderHash from order of interest | +**Returns:** *`Promise`* +filledTakerAssetAmount +___ +### getIsCancelledAsync +▸ **getIsCancelledAsync**(`signedOrder`: `SignedOrder`): *`Promise`* +*Defined in [order-utils/src/store/order_filled_cancelled_lazy_store.ts:63](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/store/order_filled_cancelled_lazy_store.ts#L63)* +Check if an order has been cancelled +**Parameters:** +Name | Type | +------ | ------ | +`signedOrder` | `SignedOrder` | +**Returns:** *`Promise`* +Whether the order has been cancelled +___ +### setFilledTakerAmount +▸ **setFilledTakerAmount**(`orderHash`: string, `filledTakerAmount`: `BigNumber`): *void* +*Defined in [order-utils/src/store/order_filled_cancelled_lazy_store.ts:48](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/store/order_filled_cancelled_lazy_store.ts#L48)* +Set the filledTakerAssetAmount of an order +**Parameters:** +Name | Type | Description | +------ | ------ | ------ | +`orderHash` | string | OrderHash from order of interest | +`filledTakerAmount` | `BigNumber` | Desired filledTakerAssetAmount | +**Returns:** *void* +___ +### setIsCancelled +▸ **setIsCancelled**(`orderHash`: string, `isCancelled`: boolean): *void* +*Defined in [order-utils/src/store/order_filled_cancelled_lazy_store.ts:77](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/store/order_filled_cancelled_lazy_store.ts#L77)* +Set whether an order has been cancelled or not +**Parameters:** +Name | Type | Description | +------ | ------ | ------ | +`orderHash` | string | OrderHash from order of interest | +`isCancelled` | boolean | Whether this order should be cancelled or not | +**Returns:** *void* +
@@ -114,27 +1054,47 @@ +# Enumeration: TradeSide +## Enumeration members +### Maker +• **Maker**: = "maker" +*Defined in [order-utils/src/types.ts:9](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/types.ts#L9)* +___ +### Taker +• **Taker**: = "taker" +*Defined in [order-utils/src/types.ts:10](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/types.ts#L10)* +
+# Enumeration: TransferType +## Enumeration members +### Fee +• **Fee**: = "fee" +*Defined in [order-utils/src/types.ts:15](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/types.ts#L15)* +___ +### Trade +• **Trade**: = "trade" +*Defined in [order-utils/src/types.ts:14](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/types.ts#L14)* +
# Enumeration: TypedDataError @@ -145,7 +1105,7 @@ • **InvalidMetamaskSigner**: = "MetaMask provider must be wrapped in a MetamaskSubprovider (from the '@0x/subproviders' package) in order to work with this method." -*Defined in [order-utils/src/types.ts:5](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/types.ts#L5)* +*Defined in [order-utils/src/types.ts:5](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/types.ts#L5)* ___ @@ -153,7 +1113,7 @@ ___ • **InvalidSignature**: = "INVALID_SIGNATURE" -*Defined in [order-utils/src/types.ts:4](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/types.ts#L4)* +*Defined in [order-utils/src/types.ts:4](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/types.ts#L4)*
@@ -166,7 +1126,7 @@ ___ • **ERC1155**: = "0xa7cb5fb7" -*Defined in [types/src/index.ts:166](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L166)* +*Defined in [types/src/index.ts:166](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L166)* ___ @@ -174,7 +1134,7 @@ ___ • **ERC20**: = "0xf47261b0" -*Defined in [types/src/index.ts:163](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L163)* +*Defined in [types/src/index.ts:163](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L163)* ___ @@ -182,7 +1142,7 @@ ___ • **ERC20Bridge**: = "0xdc1600f3" -*Defined in [types/src/index.ts:168](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L168)* +*Defined in [types/src/index.ts:168](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L168)* ___ @@ -190,7 +1150,7 @@ ___ • **ERC721**: = "0x02571792" -*Defined in [types/src/index.ts:164](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L164)* +*Defined in [types/src/index.ts:164](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L164)* ___ @@ -198,7 +1158,7 @@ ___ • **MultiAsset**: = "0x94cfcdd7" -*Defined in [types/src/index.ts:165](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L165)* +*Defined in [types/src/index.ts:165](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L165)* ___ @@ -206,96 +1166,182 @@ ___ • **StaticCall**: = "0xc339d10a" -*Defined in [types/src/index.ts:167](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L167)* +*Defined in [types/src/index.ts:167](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L167)*
+# Enumeration: ExchangeContractErrs +Errors originating from the 0x exchange contract +## Enumeration members +### BatchOrdersMustHaveAtLeastOneItem +• **BatchOrdersMustHaveAtLeastOneItem**: = "BATCH_ORDERS_MUST_HAVE_AT_LEAST_ONE_ITEM" +*Defined in [types/src/index.ts:98](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L98)* +___ +### BatchOrdersMustHaveSameExchangeAddress +• **BatchOrdersMustHaveSameExchangeAddress**: = "BATCH_ORDERS_MUST_HAVE_SAME_EXCHANGE_ADDRESS" +*Defined in [types/src/index.ts:97](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L97)* +___ -# Enumeration: SignatureType +### FillBalanceAllowanceError +• **FillBalanceAllowanceError**: = "FILL_BALANCE_ALLOWANCE_ERROR" -## Enumeration members +*Defined in [types/src/index.ts:84](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L84)* -### EIP1271Wallet +___ -• **EIP1271Wallet**: +### InsufficientMakerAllowance + +• **InsufficientMakerAllowance**: = "INSUFFICIENT_MAKER_ALLOWANCE" -*Defined in [types/src/index.ts:158](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L158)* +*Defined in [types/src/index.ts:88](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L88)* ___ -### EIP712 +### InsufficientMakerBalance -• **EIP712**: +• **InsufficientMakerBalance**: = "INSUFFICIENT_MAKER_BALANCE" -*Defined in [types/src/index.ts:153](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L153)* +*Defined in [types/src/index.ts:87](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L87)* ___ -### EthSign +### InsufficientMakerFeeAllowance -• **EthSign**: +• **InsufficientMakerFeeAllowance**: = "INSUFFICIENT_MAKER_FEE_ALLOWANCE" -*Defined in [types/src/index.ts:154](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L154)* +*Defined in [types/src/index.ts:92](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L92)* ___ -### Illegal +### InsufficientMakerFeeBalance -• **Illegal**: +• **InsufficientMakerFeeBalance**: = "INSUFFICIENT_MAKER_FEE_BALANCE" -*Defined in [types/src/index.ts:151](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L151)* +*Defined in [types/src/index.ts:91](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L91)* ___ -### Invalid +### InsufficientRemainingFillAmount -• **Invalid**: +• **InsufficientRemainingFillAmount**: = "INSUFFICIENT_REMAINING_FILL_AMOUNT" -*Defined in [types/src/index.ts:152](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L152)* +*Defined in [types/src/index.ts:95](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L95)* ___ -### NSignatureTypes +### InsufficientTakerAllowance -• **NSignatureTypes**: +• **InsufficientTakerAllowance**: = "INSUFFICIENT_TAKER_ALLOWANCE" -*Defined in [types/src/index.ts:159](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L159)* +*Defined in [types/src/index.ts:86](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L86)* ___ -### PreSigned +### InsufficientTakerBalance -• **PreSigned**: +• **InsufficientTakerBalance**: = "INSUFFICIENT_TAKER_BALANCE" -*Defined in [types/src/index.ts:157](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L157)* +*Defined in [types/src/index.ts:85](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L85)* ___ -### Validator +### InsufficientTakerFeeAllowance -• **Validator**: +• **InsufficientTakerFeeAllowance**: = "INSUFFICIENT_TAKER_FEE_ALLOWANCE" -*Defined in [types/src/index.ts:156](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L156)* +*Defined in [types/src/index.ts:90](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L90)* ___ -### Wallet +### InsufficientTakerFeeBalance -• **Wallet**: +• **InsufficientTakerFeeBalance**: = "INSUFFICIENT_TAKER_FEE_BALANCE" + +*Defined in [types/src/index.ts:89](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L89)* + +___ + +### MultipleMakersInSingleCancelBatchDisallowed + +• **MultipleMakersInSingleCancelBatchDisallowed**: = "MULTIPLE_MAKERS_IN_SINGLE_CANCEL_BATCH_DISALLOWED" + +*Defined in [types/src/index.ts:94](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L94)* + +___ + +### MultipleTakerTokensInFillUpToDisallowed + +• **MultipleTakerTokensInFillUpToDisallowed**: = "MULTIPLE_TAKER_TOKENS_IN_FILL_UP_TO_DISALLOWED" + +*Defined in [types/src/index.ts:96](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L96)* + +___ + +### OrderCancelExpired + +• **OrderCancelExpired**: = "ORDER_CANCEL_EXPIRED" + +*Defined in [types/src/index.ts:79](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L79)* + +___ + +### OrderCancelled + +• **OrderCancelled**: = "ORDER_CANCELLED" + +*Defined in [types/src/index.ts:80](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L80)* + +___ + +### OrderFillAmountZero + +• **OrderFillAmountZero**: = "ORDER_FILL_AMOUNT_ZERO" + +*Defined in [types/src/index.ts:81](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L81)* + +___ + +### OrderFillExpired + +• **OrderFillExpired**: = "ORDER_FILL_EXPIRED" + +*Defined in [types/src/index.ts:78](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L78)* + +___ + +### OrderFillRoundingError + +• **OrderFillRoundingError**: = "ORDER_FILL_ROUNDING_ERROR" + +*Defined in [types/src/index.ts:83](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L83)* + +___ -*Defined in [types/src/index.ts:155](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L155)* +### OrderRemainingFillAmountZero + +• **OrderRemainingFillAmountZero**: = "ORDER_REMAINING_FILL_AMOUNT_ZERO" + +*Defined in [types/src/index.ts:82](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L82)* + +___ + +### TransactionSenderIsNotFillOrderTaker + +• **TransactionSenderIsNotFillOrderTaker**: = "TRANSACTION_SENDER_IS_NOT_FILL_ORDER_TAKER" + +*Defined in [types/src/index.ts:93](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L93)*
@@ -309,48 +1355,90 @@ ___ +# Enumeration: SignatureType + -## Type aliases +## Enumeration members +### EIP1271Wallet +• **EIP1271Wallet**: -### AssetData +*Defined in [types/src/index.ts:158](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L158)* -Ƭ **AssetData**: *[SingleAssetData](_types_src_index_.md#singleassetdata) | [MultiAssetData](#interface-multiassetdata) | [MultiAssetDataWithRecursiveDecoding](#interface-multiassetdatawithrecursivedecoding)* +___ -*Defined in [types/src/index.ts:224](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L224)* +### EIP712 + +• **EIP712**: + +*Defined in [types/src/index.ts:153](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L153)* ___ +### EthSign +• **EthSign**: +*Defined in [types/src/index.ts:154](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L154)* +___ -### EIP712ObjectValue +### Illegal -Ƭ **EIP712ObjectValue**: *string | number | [EIP712Object](#interface-eip712object)* +• **Illegal**: + +*Defined in [types/src/index.ts:151](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L151)* + +___ + +### Invalid + +• **Invalid**: + +*Defined in [types/src/index.ts:152](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L152)* + +___ + +### NSignatureTypes + +• **NSignatureTypes**: + +*Defined in [types/src/index.ts:159](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L159)* + +___ + +### PreSigned + +• **PreSigned**: -*Defined in [types/src/index.ts:740](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L740)* +*Defined in [types/src/index.ts:157](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L157)* ___ +### Validator +• **Validator**: +*Defined in [types/src/index.ts:156](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L156)* +___ +### Wallet +• **Wallet**: + +*Defined in [types/src/index.ts:155](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L155)* + +
-### SingleAssetData -Ƭ **SingleAssetData**: *[ERC20AssetData](#interface-erc20assetdata) | [ERC721AssetData](#interface-erc721assetdata) | [ERC1155AssetData](#interface-erc1155assetdata) | [StaticCallAssetData](#interface-staticcallassetdata)* -*Defined in [types/src/index.ts:204](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L204)* -
@@ -397,7 +1485,7 @@ ___ • **isEIP1193**: *boolean* -*Defined in [ethereum-types/src/index.ts:73](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L73)* +*Defined in [ethereum-types/src/index.ts:73](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L73)* ## Methods @@ -405,7 +1493,7 @@ ___ ▸ **on**(`event`: [EIP1193Event](#eip1193event), `listener`: function): *this* -*Defined in [ethereum-types/src/index.ts:75](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L75)* +*Defined in [ethereum-types/src/index.ts:75](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L75)* **Parameters:** @@ -429,7 +1517,7 @@ ___ ▸ **send**(`method`: string, `params?`: any[]): *`Promise`* -*Defined in [ethereum-types/src/index.ts:74](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L74)* +*Defined in [ethereum-types/src/index.ts:74](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L74)* **Parameters:** @@ -463,7 +1551,7 @@ Name | Type | ▸ **sendAsync**(`payload`: [JSONRPCRequestPayload](_ethereum_types_src_index_.jsonrpcrequestpayload.md), `callback`: [JSONRPCErrorCallback](#jsonrpcerrorcallback)): *void* -*Defined in [ethereum-types/src/index.ts:14](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L14)* +*Defined in [ethereum-types/src/index.ts:14](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L14)* **Parameters:** @@ -487,7 +1575,7 @@ Name | Type | • **id**: *number* -*Defined in [ethereum-types/src/index.ts:330](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L330)* +*Defined in [ethereum-types/src/index.ts:330](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L330)* ___ @@ -495,7 +1583,7 @@ ___ • **jsonrpc**: *string* -*Defined in [ethereum-types/src/index.ts:331](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L331)* +*Defined in [ethereum-types/src/index.ts:331](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L331)* ___ @@ -503,7 +1591,7 @@ ___ • **method**: *string* -*Defined in [ethereum-types/src/index.ts:329](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L329)* +*Defined in [ethereum-types/src/index.ts:329](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L329)* ___ @@ -511,7 +1599,7 @@ ___ • **params**: *any[]* -*Defined in [ethereum-types/src/index.ts:328](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L328)* +*Defined in [ethereum-types/src/index.ts:328](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L328)*
@@ -524,7 +1612,7 @@ ___ • **code**: *number* -*Defined in [ethereum-types/src/index.ts:336](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L336)* +*Defined in [ethereum-types/src/index.ts:336](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L336)* ___ @@ -532,7 +1620,7 @@ ___ • **message**: *string* -*Defined in [ethereum-types/src/index.ts:335](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L335)* +*Defined in [ethereum-types/src/index.ts:335](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L335)*
@@ -545,7 +1633,7 @@ ___ • **error**? : *[JSONRPCResponseError](#class-jsonrpcresponseerror)* -*Defined in [ethereum-types/src/index.ts:343](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L343)* +*Defined in [ethereum-types/src/index.ts:343](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L343)* ___ @@ -553,7 +1641,7 @@ ___ • **id**: *number* -*Defined in [ethereum-types/src/index.ts:341](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L341)* +*Defined in [ethereum-types/src/index.ts:341](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L341)* ___ @@ -561,7 +1649,7 @@ ___ • **jsonrpc**: *string* -*Defined in [ethereum-types/src/index.ts:342](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L342)* +*Defined in [ethereum-types/src/index.ts:342](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L342)* ___ @@ -569,7 +1657,7 @@ ___ • **result**: *any* -*Defined in [ethereum-types/src/index.ts:340](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L340)* +*Defined in [ethereum-types/src/index.ts:340](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L340)*
@@ -630,7 +1718,7 @@ This interface allowed sending synchonous requests, support for which was later ▸ **send**(`payload`: [JSONRPCRequestPayload](_ethereum_types_src_index_.jsonrpcrequestpayload.md)): *[JSONRPCResponsePayload](#class-jsonrpcresponsepayload)* -*Defined in [ethereum-types/src/index.ts:45](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L45)* +*Defined in [ethereum-types/src/index.ts:45](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L45)* **Parameters:** @@ -646,7 +1734,7 @@ ___ ▸ **sendAsync**(`payload`: [JSONRPCRequestPayload](_ethereum_types_src_index_.jsonrpcrequestpayload.md), `callback`: [JSONRPCErrorCallback](#jsonrpcerrorcallback)): *void* -*Defined in [ethereum-types/src/index.ts:44](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L44)* +*Defined in [ethereum-types/src/index.ts:44](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L44)* **Parameters:** @@ -672,7 +1760,7 @@ before the first attempts to conform to EIP1193 ▸ **send**(`payload`: [JSONRPCRequestPayload](_ethereum_types_src_index_.jsonrpcrequestpayload.md), `callback`: [JSONRPCErrorCallback](#jsonrpcerrorcallback)): *void* -*Defined in [ethereum-types/src/index.ts:54](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L54)* +*Defined in [ethereum-types/src/index.ts:54](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L54)* **Parameters:** @@ -698,7 +1786,7 @@ however it does not conform entirely. ▸ **send**(`method`: string, `params?`: any[]): *`Promise`* -*Defined in [ethereum-types/src/index.ts:63](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L63)* +*Defined in [ethereum-types/src/index.ts:63](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L63)* **Parameters:** @@ -724,7 +1812,7 @@ add here • **isMetaMask**? : *undefined | false | true* -*Defined in [ethereum-types/src/index.ts:31](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L31)* +*Defined in [ethereum-types/src/index.ts:31](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L31)* ___ @@ -732,7 +1820,7 @@ ___ • **isParity**? : *undefined | false | true* -*Defined in [ethereum-types/src/index.ts:32](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L32)* +*Defined in [ethereum-types/src/index.ts:32](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L32)* ___ @@ -740,7 +1828,7 @@ ___ • **isZeroExProvider**? : *undefined | false | true* -*Defined in [ethereum-types/src/index.ts:30](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L30)* +*Defined in [ethereum-types/src/index.ts:30](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L30)* ## Methods @@ -748,7 +1836,7 @@ ___ ▸ **enable**(): *`Promise`* -*Defined in [ethereum-types/src/index.ts:34](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L34)* +*Defined in [ethereum-types/src/index.ts:34](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L34)* **Returns:** *`Promise`* @@ -758,7 +1846,7 @@ ___ ▸ **sendAsync**(`payload`: [JSONRPCRequestPayload](_ethereum_types_src_index_.jsonrpcrequestpayload.md), `callback`: [JSONRPCErrorCallback](#jsonrpcerrorcallback)): *void* -*Defined in [ethereum-types/src/index.ts:35](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L35)* +*Defined in [ethereum-types/src/index.ts:35](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L35)* **Parameters:** @@ -775,7 +1863,7 @@ ___ ▸ **stop**(): *void* -*Defined in [ethereum-types/src/index.ts:33](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L33)* +*Defined in [ethereum-types/src/index.ts:33](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L33)* **Returns:** *void* @@ -796,7 +1884,7 @@ ___ • **feeOrdersRemainingFillableMakerAssetAmounts**: *`BigNumber`[]* -*Defined in [order-utils/src/types.ts:68](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/types.ts#L68)* +*Defined in [order-utils/src/types.ts:78](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/types.ts#L78)* ___ @@ -804,7 +1892,7 @@ ___ • **remainingFeeAmount**: *`BigNumber`* -*Defined in [order-utils/src/types.ts:69](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/types.ts#L69)* +*Defined in [order-utils/src/types.ts:79](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/types.ts#L79)* ___ @@ -812,7 +1900,7 @@ ___ • **resultFeeOrders**: *`T`[]* -*Defined in [order-utils/src/types.ts:67](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/types.ts#L67)* +*Defined in [order-utils/src/types.ts:77](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/types.ts#L77)*
@@ -834,7 +1922,7 @@ Defaults to 0 • **remainingFillableFeeAmounts**? : *`BigNumber`[]* -*Defined in [order-utils/src/types.ts:62](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/types.ts#L62)* +*Defined in [order-utils/src/types.ts:72](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/types.ts#L72)* ___ @@ -842,7 +1930,7 @@ ___ • **remainingFillableMakerAssetAmounts**? : *`BigNumber`[]* -*Defined in [order-utils/src/types.ts:61](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/types.ts#L61)* +*Defined in [order-utils/src/types.ts:71](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/types.ts#L71)* ___ @@ -850,7 +1938,7 @@ ___ • **slippageBufferAmount**? : *`BigNumber`* -*Defined in [order-utils/src/types.ts:63](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/types.ts#L63)* +*Defined in [order-utils/src/types.ts:73](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/types.ts#L73)*
@@ -869,7 +1957,7 @@ Defaults to 0 • **remainingFillableMakerAssetAmounts**? : *`BigNumber`[]* -*Defined in [order-utils/src/types.ts:34](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/types.ts#L34)* +*Defined in [order-utils/src/types.ts:44](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/types.ts#L44)* ___ @@ -877,7 +1965,7 @@ ___ • **slippageBufferAmount**? : *`BigNumber`* -*Defined in [order-utils/src/types.ts:35](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/types.ts#L35)* +*Defined in [order-utils/src/types.ts:45](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/types.ts#L45)*
@@ -896,7 +1984,7 @@ Defaults to 0 • **remainingFillableTakerAssetAmounts**? : *`BigNumber`[]* -*Defined in [order-utils/src/types.ts:46](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/types.ts#L46)* +*Defined in [order-utils/src/types.ts:56](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/types.ts#L56)* ___ @@ -904,7 +1992,7 @@ ___ • **slippageBufferAmount**? : *`BigNumber`* -*Defined in [order-utils/src/types.ts:47](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/types.ts#L47)* +*Defined in [order-utils/src/types.ts:57](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/types.ts#L57)*
@@ -921,7 +2009,7 @@ ___ • **ordersRemainingFillableMakerAssetAmounts**: *`BigNumber`[]* -*Defined in [order-utils/src/types.ts:74](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/types.ts#L74)* +*Defined in [order-utils/src/types.ts:84](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/types.ts#L84)* ___ @@ -929,7 +2017,7 @@ ___ • **remainingFillAmount**: *`BigNumber`* -*Defined in [order-utils/src/types.ts:75](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/types.ts#L75)* +*Defined in [order-utils/src/types.ts:85](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/types.ts#L85)* ___ @@ -937,7 +2025,7 @@ ___ • **resultOrders**: *`T`[]* -*Defined in [order-utils/src/types.ts:73](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/types.ts#L73)* +*Defined in [order-utils/src/types.ts:83](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/types.ts#L83)*
@@ -954,7 +2042,7 @@ ___ • **ordersRemainingFillableTakerAssetAmounts**: *`BigNumber`[]* -*Defined in [order-utils/src/types.ts:80](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/types.ts#L80)* +*Defined in [order-utils/src/types.ts:90](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/types.ts#L90)* ___ @@ -962,7 +2050,7 @@ ___ • **remainingFillAmount**: *`BigNumber`* -*Defined in [order-utils/src/types.ts:81](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/types.ts#L81)* +*Defined in [order-utils/src/types.ts:91](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/types.ts#L91)* ___ @@ -970,7 +2058,7 @@ ___ • **resultOrders**: *`T`[]* -*Defined in [order-utils/src/types.ts:79](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/types.ts#L79)* +*Defined in [order-utils/src/types.ts:89](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/types.ts#L89)*
@@ -997,6 +2085,8 @@ ___ + + @@ -1009,7 +2099,7 @@ ___ • **assetData**: *[AssetData](#assetdata)* -*Defined in [types/src/index.ts:219](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L219)* +*Defined in [types/src/index.ts:219](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L219)* ___ @@ -1017,7 +2107,7 @@ ___ • **beginAmount**: *`BigNumber`* -*Defined in [types/src/index.ts:221](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L221)* +*Defined in [types/src/index.ts:221](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L221)* ___ @@ -1025,7 +2115,7 @@ ___ • **beginTimeSeconds**: *`BigNumber`* -*Defined in [types/src/index.ts:220](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L220)* +*Defined in [types/src/index.ts:220](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L220)*
@@ -1042,344 +2132,631 @@ Elliptic Curve signature • **r**: *string* -*Defined in [types/src/index.ts:62](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L62)* +*Defined in [types/src/index.ts:62](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L62)* + +___ + +### s + +• **s**: *string* + +*Defined in [types/src/index.ts:63](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L63)* + +___ + +### v + +• **v**: *number* + +*Defined in [types/src/index.ts:61](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L61)* + +
+ +# Interface: EIP712DomainWithDefaultSchema + + +## Properties + +### chainId + +• **chainId**: *number* + +*Defined in [types/src/index.ts:793](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L793)* + +___ + +### `Optional` name + +• **name**? : *undefined | string* + +*Defined in [types/src/index.ts:791](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L791)* + +___ + +### verifyingContract + +• **verifyingContract**: *string* + +*Defined in [types/src/index.ts:794](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L794)* + +___ + +### `Optional` version + +• **version**? : *undefined | string* + +*Defined in [types/src/index.ts:792](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L792)* + +
+ +# Interface: EIP712Object + + +## Hierarchy + +* **EIP712Parameter** + + +## Properties + +### name + +• **name**: *string* + +*Defined in [types/src/index.ts:732](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L732)* + +___ + +### type + +• **type**: *string* + +*Defined in [types/src/index.ts:733](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L733)* + +
+ +# Interface: EIP712TypedData + + +## Properties + +### domain + +• **domain**: *[EIP712Object](#class-eip712object)* + +*Defined in [types/src/index.ts:748](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L748)* + +___ + +### message + +• **message**: *[EIP712Object](#class-eip712object)* + +*Defined in [types/src/index.ts:749](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L749)* + +___ + +### primaryType + +• **primaryType**: *string* + +*Defined in [types/src/index.ts:750](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L750)* + +___ + +### types + +• **types**: *[EIP712Types](#class-eip712types)* + +*Defined in [types/src/index.ts:747](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L747)* + +
+ +# Interface: EIP712Types + + +## Hierarchy + +* **ElementType** + + +## Properties + +### name + +• **name**: *string* + +*Defined in [types/src/index.ts:686](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L686)* + +___ + +### typeDocType + +• **typeDocType**: *[TypeDocTypes](#enumeration-typedoctypes)* + +*Defined in [types/src/index.ts:687](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L687)* + +
+ +# Interface: ERC1155AssetData + + +## Properties + +### assetProxyId + +• **assetProxyId**: *string* + +*Defined in [types/src/index.ts:183](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L183)* + +___ + +### callbackData + +• **callbackData**: *string* + +*Defined in [types/src/index.ts:187](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L187)* + +___ + +### tokenAddress + +• **tokenAddress**: *string* + +*Defined in [types/src/index.ts:184](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L184)* + +___ + +### tokenIds + +• **tokenIds**: *`BigNumber`[]* + +*Defined in [types/src/index.ts:185](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L185)* + +___ + +### tokenValues + +• **tokenValues**: *`BigNumber`[]* + +*Defined in [types/src/index.ts:186](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L186)* + +
+ + + +# Interface: ERC20AssetData + + +## Properties + +### assetProxyId + +• **assetProxyId**: *string* + +*Defined in [types/src/index.ts:172](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L172)* + +___ + +### tokenAddress + +• **tokenAddress**: *string* + +*Defined in [types/src/index.ts:173](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L173)* + +
+ +# Interface: ERC721AssetData + + +## Properties + +### assetProxyId + +• **assetProxyId**: *string* + +*Defined in [types/src/index.ts:177](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L177)* + +___ + +### tokenAddress + +• **tokenAddress**: *string* + +*Defined in [types/src/index.ts:178](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L178)* + +___ + +### tokenId + +• **tokenId**: *`BigNumber`* + +*Defined in [types/src/index.ts:179](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L179)* + +
+ + + + + + + + + + + + + + + + + +# Interface: MultiAssetData + + +## Properties + +### amounts + +• **amounts**: *`BigNumber`[]* + +*Defined in [types/src/index.ts:208](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L208)* ___ -### s +### assetProxyId -• **s**: *string* +• **assetProxyId**: *string* -*Defined in [types/src/index.ts:63](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L63)* +*Defined in [types/src/index.ts:207](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L207)* ___ -### v +### nestedAssetData -• **v**: *number* +• **nestedAssetData**: *string[]* -*Defined in [types/src/index.ts:61](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L61)* +*Defined in [types/src/index.ts:209](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L209)*
-# Interface: EIP712DomainWithDefaultSchema +# Interface: MultiAssetDataWithRecursiveDecoding ## Properties -### chainId +### amounts -• **chainId**: *number* +• **amounts**: *`BigNumber`[]* -*Defined in [types/src/index.ts:793](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L793)* +*Defined in [types/src/index.ts:214](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L214)* ___ -### `Optional` name +### assetProxyId -• **name**? : *undefined | string* +• **assetProxyId**: *string* -*Defined in [types/src/index.ts:791](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L791)* +*Defined in [types/src/index.ts:213](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L213)* ___ -### verifyingContract - -• **verifyingContract**: *string* - -*Defined in [types/src/index.ts:794](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L794)* +### nestedAssetData -___ +• **nestedAssetData**: *[SingleAssetData](#singleassetdata)[]* -### `Optional` version +*Defined in [types/src/index.ts:215](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L215)* -• **version**? : *undefined | string* +
-*Defined in [types/src/index.ts:792](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L792)* +# Interface: ObjectMap <**T**> -
+## Type parameters -# Interface: EIP712Object +▪ **T** ## Hierarchy -* **EIP712Parameter** +* **Order** + + * [SignedOrder](#class-signedorder) ## Properties -### name +### chainId -• **name**: *string* +• **chainId**: *number* -*Defined in [types/src/index.ts:732](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L732)* +*Defined in [types/src/index.ts:14](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L14)* ___ -### type +### exchangeAddress -• **type**: *string* +• **exchangeAddress**: *string* -*Defined in [types/src/index.ts:733](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L733)* +*Defined in [types/src/index.ts:15](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L15)* -
+___ -# Interface: EIP712TypedData +### expirationTimeSeconds +• **expirationTimeSeconds**: *`BigNumber`* -## Properties +*Defined in [types/src/index.ts:24](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L24)* -### domain +___ -• **domain**: *[EIP712Object](#class-eip712object)* +### feeRecipientAddress -*Defined in [types/src/index.ts:748](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L748)* +• **feeRecipientAddress**: *string* + +*Defined in [types/src/index.ts:18](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L18)* ___ -### message +### makerAddress -• **message**: *[EIP712Object](#class-eip712object)* +• **makerAddress**: *string* -*Defined in [types/src/index.ts:749](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L749)* +*Defined in [types/src/index.ts:16](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L16)* ___ -### primaryType +### makerAssetAmount -• **primaryType**: *string* +• **makerAssetAmount**: *`BigNumber`* -*Defined in [types/src/index.ts:750](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L750)* +*Defined in [types/src/index.ts:20](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L20)* ___ -### types - -• **types**: *[EIP712Types](#class-eip712types)* - -*Defined in [types/src/index.ts:747](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L747)* +### makerAssetData -
+• **makerAssetData**: *string* -# Interface: EIP712Types +*Defined in [types/src/index.ts:26](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L26)* +___ -## Hierarchy +### makerFee -* **ElementType** +• **makerFee**: *`BigNumber`* +*Defined in [types/src/index.ts:22](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L22)* -## Properties +___ -### name +### makerFeeAssetData -• **name**: *string* +• **makerFeeAssetData**: *string* -*Defined in [types/src/index.ts:686](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L686)* +*Defined in [types/src/index.ts:28](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L28)* ___ -### typeDocType +### salt -• **typeDocType**: *[TypeDocTypes](#enumeration-typedoctypes)* +• **salt**: *`BigNumber`* -*Defined in [types/src/index.ts:687](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L687)* +*Defined in [types/src/index.ts:25](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L25)* -
+___ -# Interface: ERC1155AssetData +### senderAddress +• **senderAddress**: *string* -## Properties +*Defined in [types/src/index.ts:19](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L19)* -### assetProxyId +___ -• **assetProxyId**: *string* +### takerAddress + +• **takerAddress**: *string* -*Defined in [types/src/index.ts:183](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L183)* +*Defined in [types/src/index.ts:17](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L17)* ___ -### callbackData +### takerAssetAmount -• **callbackData**: *string* +• **takerAssetAmount**: *`BigNumber`* -*Defined in [types/src/index.ts:187](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L187)* +*Defined in [types/src/index.ts:21](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L21)* ___ -### tokenAddress +### takerAssetData -• **tokenAddress**: *string* +• **takerAssetData**: *string* -*Defined in [types/src/index.ts:184](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L184)* +*Defined in [types/src/index.ts:27](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L27)* ___ -### tokenIds +### takerFee -• **tokenIds**: *`BigNumber`[]* +• **takerFee**: *`BigNumber`* -*Defined in [types/src/index.ts:185](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L185)* +*Defined in [types/src/index.ts:23](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L23)* ___ -### tokenValues +### takerFeeAssetData -• **tokenValues**: *`BigNumber`[]* +• **takerFeeAssetData**: *string* -*Defined in [types/src/index.ts:186](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L186)* +*Defined in [types/src/index.ts:29](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L29)*
-# Interface: ERC20AssetData - - -## Properties - -### assetProxyId -• **assetProxyId**: *string* -*Defined in [types/src/index.ts:172](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L172)* -___ -### tokenAddress -• **tokenAddress**: *string* -*Defined in [types/src/index.ts:173](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L173)* -
-# Interface: ERC721AssetData +# Interface: OrderRelevantState ## Properties -### assetProxyId +### filledTakerAssetAmount -• **assetProxyId**: *string* +• **filledTakerAssetAmount**: *`BigNumber`* -*Defined in [types/src/index.ts:177](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L177)* +*Defined in [types/src/index.ts:122](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L122)* ___ -### tokenAddress +### makerBalance -• **tokenAddress**: *string* +• **makerBalance**: *`BigNumber`* -*Defined in [types/src/index.ts:178](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L178)* +*Defined in [types/src/index.ts:116](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L116)* ___ -### tokenId - -• **tokenId**: *`BigNumber`* - -*Defined in [types/src/index.ts:179](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L179)* +### makerFeeBalance -
+• **makerFeeBalance**: *`BigNumber`* +*Defined in [types/src/index.ts:120](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L120)* +___ +### makerFeeProxyAllowance +• **makerFeeProxyAllowance**: *`BigNumber`* - +*Defined in [types/src/index.ts:121](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L121)* +___ +### makerIndividualBalances +• **makerIndividualBalances**: *[ObjectMap](#class-objectmap)‹*`BigNumber`*›* +*Defined in [types/src/index.ts:117](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L117)* +___ +### makerIndividualProxyAllowances +• **makerIndividualProxyAllowances**: *[ObjectMap](#class-objectmap)‹*`BigNumber`*›* +*Defined in [types/src/index.ts:119](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L119)* +___ +### makerProxyAllowance -# Interface: MultiAssetData +• **makerProxyAllowance**: *`BigNumber`* +*Defined in [types/src/index.ts:118](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L118)* -## Properties +___ -### amounts +### remainingFillableMakerAssetAmount -• **amounts**: *`BigNumber`[]* +• **remainingFillableMakerAssetAmount**: *`BigNumber`* -*Defined in [types/src/index.ts:208](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L208)* +*Defined in [types/src/index.ts:123](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L123)* ___ -### assetProxyId +### remainingFillableTakerAssetAmount -• **assetProxyId**: *string* +• **remainingFillableTakerAssetAmount**: *`BigNumber`* -*Defined in [types/src/index.ts:207](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L207)* +*Defined in [types/src/index.ts:124](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L124)* -___ +
-### nestedAssetData -• **nestedAssetData**: *string[]* -*Defined in [types/src/index.ts:209](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L209)* -
-# Interface: MultiAssetDataWithRecursiveDecoding +# Interface: OrderStateInvalid ## Properties -### amounts +### error -• **amounts**: *`BigNumber`[]* +• **error**: *[ExchangeContractErrs](#enumeration-exchangecontracterrs)* -*Defined in [types/src/index.ts:214](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L214)* +*Defined in [types/src/index.ts:137](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L137)* ___ -### assetProxyId +### isValid -• **assetProxyId**: *string* +• **isValid**: *false* -*Defined in [types/src/index.ts:213](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L213)* +*Defined in [types/src/index.ts:135](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L135)* ___ -### nestedAssetData +### orderHash -• **nestedAssetData**: *[SingleAssetData](#singleassetdata)[]* +• **orderHash**: *string* -*Defined in [types/src/index.ts:215](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L215)* +*Defined in [types/src/index.ts:136](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L136)* -
+___ +### `Optional` transactionHash +• **transactionHash**? : *undefined | string* +*Defined in [types/src/index.ts:138](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L138)* +
+ +# Interface: OrderStateValid +## Properties +### isValid +• **isValid**: *true* +*Defined in [types/src/index.ts:128](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L128)* +___ +### orderHash +• **orderHash**: *string* +*Defined in [types/src/index.ts:129](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L129)* +___ +### orderRelevantState +• **orderRelevantState**: *[OrderRelevantState](#class-orderrelevantstate)* +*Defined in [types/src/index.ts:130](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L130)* +___ +### `Optional` transactionHash +• **transactionHash**? : *undefined | string* +*Defined in [types/src/index.ts:131](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L131)* +
@@ -1408,7 +2785,7 @@ ___ *Inherited from [Order](#interface-order).[chainId](#chainid)* -*Defined in [types/src/index.ts:14](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L14)* +*Defined in [types/src/index.ts:14](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L14)* ___ @@ -1418,7 +2795,7 @@ ___ *Inherited from [Order](#interface-order).[exchangeAddress](#exchangeaddress)* -*Defined in [types/src/index.ts:15](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L15)* +*Defined in [types/src/index.ts:15](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L15)* ___ @@ -1428,7 +2805,7 @@ ___ *Inherited from [Order](#interface-order).[expirationTimeSeconds](#expirationtimeseconds)* -*Defined in [types/src/index.ts:24](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L24)* +*Defined in [types/src/index.ts:24](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L24)* ___ @@ -1438,7 +2815,7 @@ ___ *Inherited from [Order](#interface-order).[feeRecipientAddress](#feerecipientaddress)* -*Defined in [types/src/index.ts:18](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L18)* +*Defined in [types/src/index.ts:18](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L18)* ___ @@ -1448,7 +2825,7 @@ ___ *Inherited from [Order](#interface-order).[makerAddress](#makeraddress)* -*Defined in [types/src/index.ts:16](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L16)* +*Defined in [types/src/index.ts:16](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L16)* ___ @@ -1458,7 +2835,7 @@ ___ *Inherited from [Order](#interface-order).[makerAssetAmount](#makerassetamount)* -*Defined in [types/src/index.ts:20](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L20)* +*Defined in [types/src/index.ts:20](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L20)* ___ @@ -1468,7 +2845,7 @@ ___ *Inherited from [Order](#interface-order).[makerAssetData](#makerassetdata)* -*Defined in [types/src/index.ts:26](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L26)* +*Defined in [types/src/index.ts:26](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L26)* ___ @@ -1478,7 +2855,7 @@ ___ *Inherited from [Order](#interface-order).[makerFee](#makerfee)* -*Defined in [types/src/index.ts:22](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L22)* +*Defined in [types/src/index.ts:22](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L22)* ___ @@ -1488,7 +2865,7 @@ ___ *Inherited from [Order](#interface-order).[makerFeeAssetData](#makerfeeassetdata)* -*Defined in [types/src/index.ts:28](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L28)* +*Defined in [types/src/index.ts:28](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L28)* ___ @@ -1498,7 +2875,7 @@ ___ *Inherited from [Order](#interface-order).[salt](#salt)* -*Defined in [types/src/index.ts:25](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L25)* +*Defined in [types/src/index.ts:25](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L25)* ___ @@ -1508,7 +2885,7 @@ ___ *Inherited from [Order](#interface-order).[senderAddress](#senderaddress)* -*Defined in [types/src/index.ts:19](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L19)* +*Defined in [types/src/index.ts:19](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L19)* ___ @@ -1516,7 +2893,7 @@ ___ • **signature**: *string* -*Defined in [types/src/index.ts:33](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L33)* +*Defined in [types/src/index.ts:33](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L33)* ___ @@ -1526,7 +2903,7 @@ ___ *Inherited from [Order](#interface-order).[takerAddress](#takeraddress)* -*Defined in [types/src/index.ts:17](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L17)* +*Defined in [types/src/index.ts:17](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L17)* ___ @@ -1536,7 +2913,7 @@ ___ *Inherited from [Order](#interface-order).[takerAssetAmount](#takerassetamount)* -*Defined in [types/src/index.ts:21](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L21)* +*Defined in [types/src/index.ts:21](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L21)* ___ @@ -1546,7 +2923,7 @@ ___ *Inherited from [Order](#interface-order).[takerAssetData](#takerassetdata)* -*Defined in [types/src/index.ts:27](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L27)* +*Defined in [types/src/index.ts:27](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L27)* ___ @@ -1556,7 +2933,7 @@ ___ *Inherited from [Order](#interface-order).[takerFee](#takerfee)* -*Defined in [types/src/index.ts:23](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L23)* +*Defined in [types/src/index.ts:23](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L23)* ___ @@ -1566,7 +2943,7 @@ ___ *Inherited from [Order](#interface-order).[takerFeeAssetData](#takerfeeassetdata)* -*Defined in [types/src/index.ts:29](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L29)* +*Defined in [types/src/index.ts:29](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L29)*
@@ -1581,7 +2958,7 @@ ___ *Inherited from [ZeroExTransaction](#interface-zeroextransaction).[data](#data)* -*Defined in [types/src/index.ts:49](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L49)* +*Defined in [types/src/index.ts:49](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L49)* ___ @@ -1591,7 +2968,7 @@ ___ *Inherited from [ZeroExTransaction](#interface-zeroextransaction).[domain](#domain)* -*Defined in [types/src/index.ts:50](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L50)* +*Defined in [types/src/index.ts:50](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L50)* ___ @@ -1601,7 +2978,7 @@ ___ *Inherited from [ZeroExTransaction](#interface-zeroextransaction).[expirationTimeSeconds](#expirationtimeseconds)* -*Defined in [types/src/index.ts:46](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L46)* +*Defined in [types/src/index.ts:46](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L46)* ___ @@ -1611,7 +2988,7 @@ ___ *Inherited from [ZeroExTransaction](#interface-zeroextransaction).[gasPrice](#gasprice)* -*Defined in [types/src/index.ts:47](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L47)* +*Defined in [types/src/index.ts:47](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L47)* ___ @@ -1621,7 +2998,7 @@ ___ *Inherited from [ZeroExTransaction](#interface-zeroextransaction).[salt](#salt)* -*Defined in [types/src/index.ts:45](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L45)* +*Defined in [types/src/index.ts:45](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L45)* ___ @@ -1629,7 +3006,7 @@ ___ • **signature**: *string* -*Defined in [types/src/index.ts:54](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L54)* +*Defined in [types/src/index.ts:54](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L54)* ___ @@ -1639,7 +3016,7 @@ ___ *Inherited from [ZeroExTransaction](#interface-zeroextransaction).[signerAddress](#signeraddress)* -*Defined in [types/src/index.ts:48](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L48)* +*Defined in [types/src/index.ts:48](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L48)*
@@ -1664,7 +3041,7 @@ ___ • **assetProxyId**: *string* -*Defined in [types/src/index.ts:191](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L191)* +*Defined in [types/src/index.ts:191](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L191)* ___ @@ -1672,7 +3049,7 @@ ___ • **callResultHash**: *string* -*Defined in [types/src/index.ts:194](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L194)* +*Defined in [types/src/index.ts:194](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L194)* ___ @@ -1680,7 +3057,7 @@ ___ • **callTarget**: *string* -*Defined in [types/src/index.ts:192](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L192)* +*Defined in [types/src/index.ts:192](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L192)* ___ @@ -1688,7 +3065,7 @@ ___ • **staticCallData**: *string* -*Defined in [types/src/index.ts:193](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L193)* +*Defined in [types/src/index.ts:193](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L193)*
@@ -1729,7 +3106,7 @@ Validator signature components • **signature**: *string* -*Defined in [types/src/index.ts:71](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L71)* +*Defined in [types/src/index.ts:71](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L71)* ___ @@ -1737,7 +3114,7 @@ ___ • **validatorAddress**: *string* -*Defined in [types/src/index.ts:70](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L70)* +*Defined in [types/src/index.ts:70](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L70)*
@@ -1752,7 +3129,7 @@ ZeroExTransaction for use with 0x Exchange executeTransaction • **data**: *string* -*Defined in [types/src/index.ts:49](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L49)* +*Defined in [types/src/index.ts:49](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L49)* ___ @@ -1760,7 +3137,7 @@ ___ • **domain**: *[EIP712DomainWithDefaultSchema](#class-eip712domainwithdefaultschema)* -*Defined in [types/src/index.ts:50](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L50)* +*Defined in [types/src/index.ts:50](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L50)* ___ @@ -1768,7 +3145,7 @@ ___ • **expirationTimeSeconds**: *`BigNumber`* -*Defined in [types/src/index.ts:46](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L46)* +*Defined in [types/src/index.ts:46](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L46)* ___ @@ -1776,7 +3153,7 @@ ___ • **gasPrice**: *`BigNumber`* -*Defined in [types/src/index.ts:47](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L47)* +*Defined in [types/src/index.ts:47](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L47)* ___ @@ -1784,7 +3161,7 @@ ___ • **salt**: *`BigNumber`* -*Defined in [types/src/index.ts:45](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L45)* +*Defined in [types/src/index.ts:45](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L45)* ___ @@ -1792,16 +3169,12 @@ ___ • **signerAddress**: *string* -*Defined in [types/src/index.ts:48](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L48)* +*Defined in [types/src/index.ts:48](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L48)*
-
- - - ## Type aliases @@ -1821,7 +3194,7 @@ ___ Ƭ **EIP1193Event**: *"accountsChanged" | "networkChanged" | "close" | "connect" | "notification"* -*Defined in [ethereum-types/src/index.ts:70](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L70)* +*Defined in [ethereum-types/src/index.ts:70](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L70)* Interface for providers that conform to EIP 1193 Source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1193.md @@ -1838,7 +3211,7 @@ ___ Ƭ **JSONRPCErrorCallback**: *function* -*Defined in [ethereum-types/src/index.ts:3](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L3)* +*Defined in [ethereum-types/src/index.ts:3](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L3)* #### Type declaration: @@ -1867,7 +3240,7 @@ ___ Ƭ **SupportedProvider**: *[Web3JsProvider](_ethereum_types_src_index_.md#web3jsprovider) | [GanacheProvider](#interface-ganacheprovider) | [EIP1193Provider](#interface-eip1193provider) | [ZeroExProvider](#interface-zeroexprovider)* -*Defined in [ethereum-types/src/index.ts:9](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L9)* +*Defined in [ethereum-types/src/index.ts:9](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L9)* Do not create your own provider. Use an existing provider from a Web3 or ProviderEngine library Read more about Providers in the guides section of the 0x docs. @@ -1882,12 +3255,28 @@ ___ Ƭ **Web3JsProvider**: *[Web3JsV1Provider](#interface-web3jsv1provider) | [Web3JsV2Provider](#interface-web3jsv2provider) | [Web3JsV3Provider](#interface-web3jsv3provider)* -*Defined in [ethereum-types/src/index.ts:11](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L11)* +*Defined in [ethereum-types/src/index.ts:11](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L11)*
+
+ + + +
+ + + +
+ + + +
+ + + ## Object literals @@ -1895,13 +3284,13 @@ ___ #### ▪ **assetDataUtils**: *object* -*Defined in [order-utils/src/asset_data_utils.ts:23](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/asset_data_utils.ts#L23)* +*Defined in [order-utils/src/asset_data_utils.ts:23](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/asset_data_utils.ts#L23)* #### assertIsERC1155AssetData ▸ **assertIsERC1155AssetData**(`assetData`: string): *void* -*Defined in [order-utils/src/asset_data_utils.ts:397](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/asset_data_utils.ts#L397)* +*Defined in [order-utils/src/asset_data_utils.ts:397](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/asset_data_utils.ts#L397)* Throws if the assetData is not ERC1155. @@ -1917,7 +3306,7 @@ Name | Type | Description | ▸ **assertIsERC20AssetData**(`assetData`: string): *void* -*Defined in [order-utils/src/asset_data_utils.ts:353](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/asset_data_utils.ts#L353)* +*Defined in [order-utils/src/asset_data_utils.ts:353](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/asset_data_utils.ts#L353)* Throws if the length or assetProxyId are invalid for the ERC20Proxy. @@ -1933,7 +3322,7 @@ Name | Type | Description | ▸ **assertIsERC721AssetData**(`assetData`: string): *void* -*Defined in [order-utils/src/asset_data_utils.ts:375](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/asset_data_utils.ts#L375)* +*Defined in [order-utils/src/asset_data_utils.ts:375](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/asset_data_utils.ts#L375)* Throws if the length or assetProxyId are invalid for the ERC721Proxy. @@ -1949,7 +3338,7 @@ Name | Type | Description | ▸ **assertIsMultiAssetData**(`assetData`: string): *void* -*Defined in [order-utils/src/asset_data_utils.ts:419](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/asset_data_utils.ts#L419)* +*Defined in [order-utils/src/asset_data_utils.ts:419](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/asset_data_utils.ts#L419)* Throws if the length or assetProxyId are invalid for the MultiAssetProxy. @@ -1965,7 +3354,7 @@ Name | Type | Description | ▸ **assertIsStaticCallAssetData**(`assetData`: string): *void* -*Defined in [order-utils/src/asset_data_utils.ts:441](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/asset_data_utils.ts#L441)* +*Defined in [order-utils/src/asset_data_utils.ts:441](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/asset_data_utils.ts#L441)* Throws if the assetData is not StaticCallData. @@ -1981,7 +3370,7 @@ Name | Type | Description | ▸ **assertWordAlignedAssetData**(`assetData`: string): *void* -*Defined in [order-utils/src/asset_data_utils.ts:463](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/asset_data_utils.ts#L463)* +*Defined in [order-utils/src/asset_data_utils.ts:463](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/asset_data_utils.ts#L463)* Throws if the assetData is not padded to 32 bytes. @@ -1997,7 +3386,7 @@ Name | Type | Description | ▸ **decodeAssetDataOrThrow**(`assetData`: string): *[SingleAssetData](#singleassetdata) | `MultiAssetData`* -*Defined in [order-utils/src/asset_data_utils.ts:502](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/asset_data_utils.ts#L502)* +*Defined in [order-utils/src/asset_data_utils.ts:502](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/asset_data_utils.ts#L502)* Decode any assetData into its corresponding assetData object @@ -2015,7 +3404,7 @@ Either a ERC20, ERC721, ERC1155, or MultiAsset assetData object ▸ **decodeAssetProxyId**(`assetData`: string): *`AssetProxyId`* -*Defined in [order-utils/src/asset_data_utils.ts:294](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/asset_data_utils.ts#L294)* +*Defined in [order-utils/src/asset_data_utils.ts:294](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/asset_data_utils.ts#L294)* Decode and return the assetProxyId from the assetData @@ -2033,7 +3422,7 @@ The assetProxyId ▸ **decodeDutchAuctionData**(`dutchAuctionData`: string): *`DutchAuctionData`* -*Defined in [order-utils/src/asset_data_utils.ts:263](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/asset_data_utils.ts#L263)* +*Defined in [order-utils/src/asset_data_utils.ts:263](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/asset_data_utils.ts#L263)* Dutch auction details are encoded with the asset data for a 0x order. This function decodes a hex encoded assetData string, containing information both about the asset being traded and the @@ -2053,7 +3442,7 @@ An object containing the auction asset, auction begin time and auction begin amo ▸ **decodeERC1155AssetData**(`assetData`: string): *`ERC1155AssetData`* -*Defined in [order-utils/src/asset_data_utils.ts:107](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/asset_data_utils.ts#L107)* +*Defined in [order-utils/src/asset_data_utils.ts:107](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/asset_data_utils.ts#L107)* Decodes an ERC1155 assetData hex string into its corresponding ERC1155 components. @@ -2071,7 +3460,7 @@ An object containing the decoded tokenAddress, tokenIds, tokenValues, callbackDa ▸ **decodeERC20AssetData**(`assetData`: string): *`ERC20AssetData`* -*Defined in [order-utils/src/asset_data_utils.ts:41](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/asset_data_utils.ts#L41)* +*Defined in [order-utils/src/asset_data_utils.ts:41](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/asset_data_utils.ts#L41)* Decodes an ERC20 assetData hex string into its corresponding ERC20 tokenAddress & assetProxyId @@ -2089,7 +3478,7 @@ An object containing the decoded tokenAddress & assetProxyId ▸ **decodeERC721AssetData**(`assetData`: string): *`ERC721AssetData`* -*Defined in [order-utils/src/asset_data_utils.ts:70](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/asset_data_utils.ts#L70)* +*Defined in [order-utils/src/asset_data_utils.ts:70](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/asset_data_utils.ts#L70)* Decodes an ERC721 assetData hex string into its corresponding ERC721 tokenAddress, tokenId & assetProxyId @@ -2107,7 +3496,7 @@ An object containing the decoded tokenAddress, tokenId & assetProxyId ▸ **decodeMultiAssetData**(`assetData`: string): *`MultiAssetData`* -*Defined in [order-utils/src/asset_data_utils.ts:149](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/asset_data_utils.ts#L149)* +*Defined in [order-utils/src/asset_data_utils.ts:149](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/asset_data_utils.ts#L149)* Decodes a MultiAsset assetData hex string into its corresponding amounts and nestedAssetData @@ -2125,7 +3514,7 @@ An object containing the decoded amounts and nestedAssetData ▸ **decodeMultiAssetDataRecursively**(`assetData`: string): *`MultiAssetDataWithRecursiveDecoding`* -*Defined in [order-utils/src/asset_data_utils.ts:175](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/asset_data_utils.ts#L175)* +*Defined in [order-utils/src/asset_data_utils.ts:175](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/asset_data_utils.ts#L175)* Decodes a MultiAsset assetData hex string into its corresponding amounts and decoded nestedAssetData elements (all nested elements are flattened) @@ -2143,7 +3532,7 @@ An object containing the decoded amounts and nestedAssetData ▸ **decodeStaticCallAssetData**(`assetData`: string): *`StaticCallAssetData`* -*Defined in [order-utils/src/asset_data_utils.ts:225](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/asset_data_utils.ts#L225)* +*Defined in [order-utils/src/asset_data_utils.ts:225](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/asset_data_utils.ts#L225)* Decoded StaticCall assetData into its corresponding callTarget, staticCallData, and expected callResultHash @@ -2161,7 +3550,7 @@ An object containing the decoded callTarget, staticCallData, and expected callRe ▸ **encodeDutchAuctionAssetData**(`assetData`: string, `beginTimeSeconds`: `BigNumber`, `beginAmount`: `BigNumber`): *string* -*Defined in [order-utils/src/asset_data_utils.ts:245](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/asset_data_utils.ts#L245)* +*Defined in [order-utils/src/asset_data_utils.ts:245](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/asset_data_utils.ts#L245)* Dutch auction details are encoded with the asset data for a 0x order. This function produces a hex encoded assetData string, containing information both about the asset being traded and the @@ -2183,7 +3572,7 @@ The hex encoded assetData string. ▸ **encodeERC1155AssetData**(`tokenAddress`: string, `tokenIds`: `BigNumber`[], `tokenValues`: `BigNumber`[], `callbackData`: string): *string* -*Defined in [order-utils/src/asset_data_utils.ts:91](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/asset_data_utils.ts#L91)* +*Defined in [order-utils/src/asset_data_utils.ts:91](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/asset_data_utils.ts#L91)* Encodes a set of ERC1155 assets into an assetData string, usable in the makerAssetData or takerAssetData fields of a 0x order. @@ -2205,7 +3594,7 @@ The hex encoded assetData string ▸ **encodeERC20AssetData**(`tokenAddress`: string): *string* -*Defined in [order-utils/src/asset_data_utils.ts:30](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/asset_data_utils.ts#L30)* +*Defined in [order-utils/src/asset_data_utils.ts:30](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/asset_data_utils.ts#L30)* Encodes an ERC20 token address into a hex encoded assetData string, usable in the makerAssetData or takerAssetData fields in a 0x order. @@ -2224,7 +3613,7 @@ The hex encoded assetData string ▸ **encodeERC721AssetData**(`tokenAddress`: string, `tokenId`: `BigNumber`): *string* -*Defined in [order-utils/src/asset_data_utils.ts:59](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/asset_data_utils.ts#L59)* +*Defined in [order-utils/src/asset_data_utils.ts:59](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/asset_data_utils.ts#L59)* Encodes an ERC721 token address into a hex encoded assetData string, usable in the makerAssetData or takerAssetData fields in a 0x order. @@ -2244,7 +3633,7 @@ The hex encoded assetData string ▸ **encodeMultiAssetData**(`amounts`: `BigNumber`[], `nestedAssetData`: string[]): *string* -*Defined in [order-utils/src/asset_data_utils.ts:130](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/asset_data_utils.ts#L130)* +*Defined in [order-utils/src/asset_data_utils.ts:130](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/asset_data_utils.ts#L130)* Encodes assetData for multiple AssetProxies into a single hex encoded assetData string, usable in the makerAssetData or takerAssetData fields in a 0x order. @@ -2264,7 +3653,7 @@ The hex encoded assetData string ▸ **encodeStaticCallAssetData**(`callTarget`: string, `staticCallData`: string, `callResultHash`: string): *string* -*Defined in [order-utils/src/asset_data_utils.ts:214](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/asset_data_utils.ts#L214)* +*Defined in [order-utils/src/asset_data_utils.ts:214](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/asset_data_utils.ts#L214)* Encodes StaticCallProxy data into an assetData hex string @@ -2284,7 +3673,7 @@ The hex encoded assetData string ▸ **isERC1155AssetData**(`decodedAssetData`: [SingleAssetData](#singleassetdata) | `MultiAssetData`): *boolean* -*Defined in [order-utils/src/asset_data_utils.ts:332](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/asset_data_utils.ts#L332)* +*Defined in [order-utils/src/asset_data_utils.ts:332](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/asset_data_utils.ts#L332)* Checks if the decoded asset data is valid ERC1155 data @@ -2300,7 +3689,7 @@ Name | Type | Description | ▸ **isERC20AssetData**(`decodedAssetData`: [SingleAssetData](#singleassetdata) | `MultiAssetData`): *boolean* -*Defined in [order-utils/src/asset_data_utils.ts:318](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/asset_data_utils.ts#L318)* +*Defined in [order-utils/src/asset_data_utils.ts:318](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/asset_data_utils.ts#L318)* Checks if the decoded asset data is valid ERC20 data @@ -2316,7 +3705,7 @@ Name | Type | Description | ▸ **isERC721AssetData**(`decodedAssetData`: [SingleAssetData](#singleassetdata) | `MultiAssetData`): *boolean* -*Defined in [order-utils/src/asset_data_utils.ts:325](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/asset_data_utils.ts#L325)* +*Defined in [order-utils/src/asset_data_utils.ts:325](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/asset_data_utils.ts#L325)* Checks if the decoded asset data is valid ERC721 data @@ -2332,7 +3721,7 @@ Name | Type | Description | ▸ **isMultiAssetData**(`decodedAssetData`: [SingleAssetData](#singleassetdata) | `MultiAssetData`): *boolean* -*Defined in [order-utils/src/asset_data_utils.ts:339](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/asset_data_utils.ts#L339)* +*Defined in [order-utils/src/asset_data_utils.ts:339](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/asset_data_utils.ts#L339)* Checks if the decoded asset data is valid MultiAsset data @@ -2348,7 +3737,7 @@ Name | Type | Description | ▸ **isStaticCallAssetData**(`decodedAssetData`: [SingleAssetData](#singleassetdata) | `MultiAssetData`): *boolean* -*Defined in [order-utils/src/asset_data_utils.ts:346](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/asset_data_utils.ts#L346)* +*Defined in [order-utils/src/asset_data_utils.ts:346](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/asset_data_utils.ts#L346)* Checks if the decoded asset data is valid StaticCall data @@ -2364,7 +3753,7 @@ Name | Type | Description | ▸ **validateAssetDataOrThrow**(`assetData`: string): *void* -*Defined in [order-utils/src/asset_data_utils.ts:475](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/asset_data_utils.ts#L475)* +*Defined in [order-utils/src/asset_data_utils.ts:475](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/asset_data_utils.ts#L475)* Throws if the length or assetProxyId are invalid for the corresponding AssetProxy. @@ -2391,13 +3780,13 @@ Name | Type | Description | #### ▪ **eip712Utils**: *object* -*Defined in [order-utils/src/eip712_utils.ts:17](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/eip712_utils.ts#L17)* +*Defined in [order-utils/src/eip712_utils.ts:17](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/eip712_utils.ts#L17)* #### createCoordinatorApprovalTypedData ▸ **createCoordinatorApprovalTypedData**(`transaction`: `SignedZeroExTransaction`, `verifyingContract`: string, `txOrigin`: string): *`EIP712TypedData`* -*Defined in [order-utils/src/eip712_utils.ts:103](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/eip712_utils.ts#L103)* +*Defined in [order-utils/src/eip712_utils.ts:103](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/eip712_utils.ts#L103)* Creates an Coordinator typedData EIP712TypedData object for use with the Coordinator extension contract @@ -2417,7 +3806,7 @@ A typed data object ▸ **createOrderTypedData**(`order`: `Order`): *`EIP712TypedData`* -*Defined in [order-utils/src/eip712_utils.ts:56](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/eip712_utils.ts#L56)* +*Defined in [order-utils/src/eip712_utils.ts:56](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/eip712_utils.ts#L56)* Creates an Order EIP712TypedData object for use with signTypedData. @@ -2435,7 +3824,7 @@ A typed data object ▸ **createTypedData**(`primaryType`: string, `types`: `EIP712Types`, `message`: `EIP712Object`, `domain`: `EIP712DomainWithDefaultSchema`): *`EIP712TypedData`* -*Defined in [order-utils/src/eip712_utils.ts:26](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/eip712_utils.ts#L26)* +*Defined in [order-utils/src/eip712_utils.ts:26](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/eip712_utils.ts#L26)* Creates a EIP712TypedData object specific to the 0x protocol for use with signTypedData. @@ -2456,7 +3845,7 @@ A typed data object ▸ **createZeroExTransactionTypedData**(`zeroExTransaction`: `ZeroExTransaction`): *`EIP712TypedData`* -*Defined in [order-utils/src/eip712_utils.ts:81](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/eip712_utils.ts#L81)* +*Defined in [order-utils/src/eip712_utils.ts:81](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/eip712_utils.ts#L81)* Creates an ExecuteTransaction EIP712TypedData object for use with signTypedData and 0x Exchange executeTransaction. @@ -2487,6 +3876,10 @@ A typed data object +
+ + + ## Object literals @@ -2494,13 +3887,13 @@ A typed data object #### ▪ **marketUtils**: *object* -*Defined in [order-utils/src/market_utils.ts:17](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/market_utils.ts#L17)* +*Defined in [order-utils/src/market_utils.ts:17](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/market_utils.ts#L17)* #### findFeeOrdersThatCoverFeesForTargetOrders ▸ **findFeeOrdersThatCoverFeesForTargetOrders**<**T**>(`orders`: `T`[], `feeOrders`: `T`[], `opts?`: [FindFeeOrdersThatCoverFeesForTargetOrdersOpts](#interface-findfeeordersthatcoverfeesfortargetordersopts)): *[FeeOrdersAndRemainingFeeAmount](#interface-feeordersandremainingfeeamount)‹*`T`*›* -*Defined in [order-utils/src/market_utils.ts:64](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/market_utils.ts#L64)* +*Defined in [order-utils/src/market_utils.ts:64](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/market_utils.ts#L64)* Takes an array of orders and an array of feeOrders. Returns a subset of the feeOrders that has enough ZRX in order to fill the takerFees required by orders plus a slippageBufferAmount. @@ -2527,7 +3920,7 @@ Resulting orders and remaining fee amount that could not be covered by the input ▸ **findOrdersThatCoverMakerAssetFillAmount**<**T**>(`orders`: `T`[], `makerAssetFillAmount`: `BigNumber`, `opts?`: [FindOrdersThatCoverMakerAssetFillAmountOpts](#interface-findordersthatcovermakerassetfillamountopts)): *[OrdersAndRemainingMakerFillAmount](#interface-ordersandremainingmakerfillamount)‹*`T`*›* -*Defined in [order-utils/src/market_utils.ts:40](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/market_utils.ts#L40)* +*Defined in [order-utils/src/market_utils.ts:40](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/market_utils.ts#L40)* Takes an array of orders and returns a subset of those orders that has enough makerAssetAmount in order to fill the input makerAssetFillAmount plus slippageBufferAmount. Iterates from first order to last order. @@ -2553,7 +3946,7 @@ Resulting orders and remaining fill amount that could not be covered by the inpu ▸ **findOrdersThatCoverTakerAssetFillAmount**<**T**>(`orders`: `T`[], `takerAssetFillAmount`: `BigNumber`, `opts?`: [FindOrdersThatCoverTakerAssetFillAmountOpts](#interface-findordersthatcovertakerassetfillamountopts)): *[OrdersAndRemainingTakerFillAmount](#interface-ordersandremainingtakerfillamount)‹*`T`*›* -*Defined in [order-utils/src/market_utils.ts:18](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/market_utils.ts#L18)* +*Defined in [order-utils/src/market_utils.ts:18](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/market_utils.ts#L18)* **Type parameters:** @@ -2580,13 +3973,13 @@ Name | Type | #### ▪ **orderCalculationUtils**: *object* -*Defined in [order-utils/src/order_calculation_utils.ts:6](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/order_calculation_utils.ts#L6)* +*Defined in [order-utils/src/order_calculation_utils.ts:6](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/order_calculation_utils.ts#L6)* #### getMakerFeeAmount ▸ **getMakerFeeAmount**(`order`: `Order`, `makerFillAmount`: `BigNumber`): *`BigNumber`* -*Defined in [order-utils/src/order_calculation_utils.ts:75](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/order_calculation_utils.ts#L75)* +*Defined in [order-utils/src/order_calculation_utils.ts:75](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/order_calculation_utils.ts#L75)* Given an amount of maker asset, calculate the fee amount required for the maker @@ -2603,7 +3996,7 @@ Name | Type | Description | ▸ **getMakerFillAmount**(`order`: `Order`, `takerFillAmount`: `BigNumber`): *`BigNumber`* -*Defined in [order-utils/src/order_calculation_utils.ts:36](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/order_calculation_utils.ts#L36)* +*Defined in [order-utils/src/order_calculation_utils.ts:36](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/order_calculation_utils.ts#L36)* Given an amount of taker asset, calculate the the amount of maker asset @@ -2620,7 +4013,7 @@ Name | Type | Description | ▸ **getTakerFeeAmount**(`order`: `Order`, `takerFillAmount`: `BigNumber`): *`BigNumber`* -*Defined in [order-utils/src/order_calculation_utils.ts:62](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/order_calculation_utils.ts#L62)* +*Defined in [order-utils/src/order_calculation_utils.ts:62](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/order_calculation_utils.ts#L62)* Given an amount of taker asset, calculate the fee amount required for the taker @@ -2637,7 +4030,7 @@ Name | Type | Description | ▸ **getTakerFillAmount**(`order`: `Order`, `makerFillAmount`: `BigNumber`): *`BigNumber`* -*Defined in [order-utils/src/order_calculation_utils.ts:49](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/order_calculation_utils.ts#L49)* +*Defined in [order-utils/src/order_calculation_utils.ts:49](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/order_calculation_utils.ts#L49)* Given an amount of maker asset, calculate the equivalent amount in taker asset @@ -2654,7 +4047,7 @@ Name | Type | Description | ▸ **getTakerFillAmountForFeeOrder**(`order`: `Order`, `makerFillAmount`: `BigNumber`): *[`BigNumber`, `BigNumber`]* -*Defined in [order-utils/src/order_calculation_utils.ts:89](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/order_calculation_utils.ts#L89)* +*Defined in [order-utils/src/order_calculation_utils.ts:89](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/order_calculation_utils.ts#L89)* Given a desired amount of ZRX from a fee order, calculate the amount of taker asset required to fill. Also calculate how much ZRX needs to be purchased in order to fill the desired amount plus the taker fee amount @@ -2672,7 +4065,7 @@ Name | Type | Description | ▸ **isOpenOrder**(`order`: `Order`): *boolean* -*Defined in [order-utils/src/order_calculation_utils.ts:28](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/order_calculation_utils.ts#L28)* +*Defined in [order-utils/src/order_calculation_utils.ts:28](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/order_calculation_utils.ts#L28)* Determines if the order is open and fillable by any taker. @@ -2688,7 +4081,7 @@ Name | Type | Description | ▸ **isOrderExpired**(`order`: `Order`): *boolean* -*Defined in [order-utils/src/order_calculation_utils.ts:11](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/order_calculation_utils.ts#L11)* +*Defined in [order-utils/src/order_calculation_utils.ts:11](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/order_calculation_utils.ts#L11)* Determines if the order is expired given the current time @@ -2704,7 +4097,7 @@ Name | Type | Description | ▸ **willOrderExpire**(`order`: `Order`, `secondsFromNow`: number): *boolean* -*Defined in [order-utils/src/order_calculation_utils.ts:19](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/order_calculation_utils.ts#L19)* +*Defined in [order-utils/src/order_calculation_utils.ts:19](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/order_calculation_utils.ts#L19)* Calculates if the order will expire in the future. @@ -2728,13 +4121,13 @@ Name | Type | Description | #### ▪ **orderHashUtils**: *object* -*Defined in [order-utils/src/order_hash.ts:12](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/order_hash.ts#L12)* +*Defined in [order-utils/src/order_hash.ts:12](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/order_hash.ts#L12)* #### getOrderHashBuffer ▸ **getOrderHashBuffer**(`order`: `SignedOrder` | `Order`): *`Buffer`* -*Defined in [order-utils/src/order_hash.ts:55](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/order_hash.ts#L55)* +*Defined in [order-utils/src/order_hash.ts:55](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/order_hash.ts#L55)* Computes the orderHash for a supplied order @@ -2752,7 +4145,7 @@ A Buffer containing the resulting orderHash from hashing the supplied order ▸ **getOrderHashHex**(`order`: `SignedOrder` | `Order`): *string* -*Defined in [order-utils/src/order_hash.ts:33](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/order_hash.ts#L33)* +*Defined in [order-utils/src/order_hash.ts:33](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/order_hash.ts#L33)* Computes the orderHash for a supplied order. @@ -2770,7 +4163,7 @@ Hex encoded string orderHash from hashing the supplied order. ▸ **isValidOrderHash**(`orderHash`: string): *boolean* -*Defined in [order-utils/src/order_hash.ts:20](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/order_hash.ts#L20)* +*Defined in [order-utils/src/order_hash.ts:20](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/order_hash.ts#L20)* Checks if the supplied hex encoded order hash is valid. Note: Valid means it has the expected format, not that an order with the orderHash exists. @@ -2790,6 +4183,14 @@ Whether the supplied orderHash has the expected format. +
+ + + +
+ + + ## Object literals @@ -2797,13 +4198,13 @@ Whether the supplied orderHash has the expected format. #### ▪ **orderParsingUtils**: *object* -*Defined in [order-utils/src/parsing_utils.ts:4](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/parsing_utils.ts#L4)* +*Defined in [order-utils/src/parsing_utils.ts:4](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/parsing_utils.ts#L4)* #### convertOrderStringFieldsToBigNumber ▸ **convertOrderStringFieldsToBigNumber**(`order`: any): *any* -*Defined in [order-utils/src/parsing_utils.ts:17](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/parsing_utils.ts#L17)* +*Defined in [order-utils/src/parsing_utils.ts:17](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/parsing_utils.ts#L17)* **Parameters:** @@ -2817,7 +4218,7 @@ Name | Type | ▸ **convertStringsFieldsToBigNumbers**(`obj`: any, `fields`: string[]): *any* -*Defined in [order-utils/src/parsing_utils.ts:5](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/parsing_utils.ts#L5)* +*Defined in [order-utils/src/parsing_utils.ts:5](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/parsing_utils.ts#L5)* **Parameters:** @@ -2839,13 +4240,13 @@ Name | Type | #### ▪ **rateUtils**: *object* -*Defined in [order-utils/src/rate_utils.ts:8](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/rate_utils.ts#L8)* +*Defined in [order-utils/src/rate_utils.ts:8](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/rate_utils.ts#L8)* #### getFeeAdjustedRateOfFeeOrder ▸ **getFeeAdjustedRateOfFeeOrder**(`feeOrder`: `Order`): *`BigNumber`* -*Defined in [order-utils/src/rate_utils.ts:36](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/rate_utils.ts#L36)* +*Defined in [order-utils/src/rate_utils.ts:36](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/rate_utils.ts#L36)* Takes a fee order (makerAssetData corresponds to ZRX and takerAssetData corresponds to WETH) and calculates the fee adjusted rate (WETH/ZRX) by dividing the takerAssetAmount by the makerAmount minus the takerFee @@ -2864,7 +4265,7 @@ The rate (WETH/ZRX) of the fee order adjusted for fees ▸ **getFeeAdjustedRateOfOrder**(`order`: `Order`, `feeRate`: `BigNumber`): *`BigNumber`* -*Defined in [order-utils/src/rate_utils.ts:18](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/rate_utils.ts#L18)* +*Defined in [order-utils/src/rate_utils.ts:18](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/rate_utils.ts#L18)* Takes an order and calculates the fee adjusted rate (takerAsset/makerAsset) by calculating how much takerAsset is required to cover the fees (feeRate * takerFee), adding the takerAssetAmount and dividing by makerAssetAmount @@ -2891,7 +4292,7 @@ The rate (takerAsset/makerAsset) of the order adjusted for fees ▸ **generatePseudoRandomSalt**(): *`BigNumber`* -*Defined in [order-utils/src/salt.ts:9](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/salt.ts#L9)* +*Defined in [order-utils/src/salt.ts:9](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/salt.ts#L9)* Generates a pseudo-random 256-bit salt. The salt can be included in a 0x order, ensuring that the order generates a unique orderHash @@ -2912,13 +4313,13 @@ A pseudo-random 256-bit number that can be used as a salt. #### ▪ **signatureUtils**: *object* -*Defined in [order-utils/src/signature_utils.ts:27](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/signature_utils.ts#L27)* +*Defined in [order-utils/src/signature_utils.ts:27](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/signature_utils.ts#L27)* #### addSignedMessagePrefix ▸ **addSignedMessagePrefix**(`message`: string): *string* -*Defined in [order-utils/src/signature_utils.ts:497](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/signature_utils.ts#L497)* +*Defined in [order-utils/src/signature_utils.ts:500](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/signature_utils.ts#L500)* Adds the relevant prefix to the message being signed. @@ -2936,7 +4337,7 @@ Prefixed message ▸ **convertECSignatureToSignatureHex**(`ecSignature`: `ECSignature`): *string* -*Defined in [order-utils/src/signature_utils.ts:471](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/signature_utils.ts#L471)* +*Defined in [order-utils/src/signature_utils.ts:474](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/signature_utils.ts#L474)* Combines ECSignature with V,R,S and the EthSign signature type for use in 0x protocol @@ -2954,7 +4355,7 @@ Hex encoded string of signature (v,r,s) with Signature Type ▸ **convertToSignatureWithType**(`signature`: string, `signatureType`: `SignatureType`): *string* -*Defined in [order-utils/src/signature_utils.ts:487](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/signature_utils.ts#L487)* +*Defined in [order-utils/src/signature_utils.ts:490](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/signature_utils.ts#L490)* Combines the signature proof and the Signature Type. @@ -2973,7 +4374,7 @@ Hex encoded string of signature proof with Signature Type ▸ **ecSignHashAsync**(`supportedProvider`: [SupportedProvider](#supportedprovider), `msgHash`: string, `signerAddress`: string): *`Promise`* -*Defined in [order-utils/src/signature_utils.ts:414](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/signature_utils.ts#L414)* +*Defined in [order-utils/src/signature_utils.ts:417](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/signature_utils.ts#L417)* Signs a hash using `eth_sign` and returns its elliptic curve signature and signature type. @@ -2993,7 +4394,7 @@ A hex encoded string containing the Elliptic curve signature generated by signin ▸ **ecSignOrderAsync**(`supportedProvider`: [SupportedProvider](#supportedprovider), `order`: `Order`, `signerAddress`: string): *`Promise`* -*Defined in [order-utils/src/signature_utils.ts:249](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/signature_utils.ts#L249)* +*Defined in [order-utils/src/signature_utils.ts:252](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/signature_utils.ts#L252)* Signs an order and returns a SignedOrder. First `eth_signTypedData` is requested then a fallback to `eth_sign` if not available on the supplied provider. @@ -3014,7 +4415,7 @@ A SignedOrder containing the order and Elliptic curve signature with Signature T ▸ **ecSignTransactionAsync**(`supportedProvider`: [SupportedProvider](#supportedprovider), `transaction`: `ZeroExTransaction`, `signerAddress`: string): *`Promise`* -*Defined in [order-utils/src/signature_utils.ts:328](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/signature_utils.ts#L328)* +*Defined in [order-utils/src/signature_utils.ts:331](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/signature_utils.ts#L331)* Signs a transaction and returns a SignedZeroExTransaction. First `eth_signTypedData` is requested then a fallback to `eth_sign` if not available on the supplied provider. @@ -3035,7 +4436,7 @@ A SignedTransaction containing the order and Elliptic curve signature with Signa ▸ **ecSignTypedDataOrderAsync**(`supportedProvider`: [SupportedProvider](#supportedprovider), `order`: `Order`, `signerAddress`: string): *`Promise`* -*Defined in [order-utils/src/signature_utils.ts:284](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/signature_utils.ts#L284)* +*Defined in [order-utils/src/signature_utils.ts:287](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/signature_utils.ts#L287)* Signs an order using `eth_signTypedData` and returns a SignedOrder. @@ -3055,7 +4456,7 @@ A SignedOrder containing the order and Elliptic curve signature with Signature T ▸ **ecSignTypedDataTransactionAsync**(`supportedProvider`: [SupportedProvider](#supportedprovider), `transaction`: `ZeroExTransaction`, `signerAddress`: string): *`Promise`* -*Defined in [order-utils/src/signature_utils.ts:371](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/signature_utils.ts#L371)* +*Defined in [order-utils/src/signature_utils.ts:374](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/signature_utils.ts#L374)* Signs a ZeroExTransaction using `eth_signTypedData` and returns a SignedZeroExTransaction. @@ -3075,7 +4476,7 @@ A SignedZeroExTransaction containing the ZeroExTransaction and Elliptic curve si ▸ **isValidECSignature**(`data`: string, `signature`: `ECSignature`, `signerAddress`: string): *boolean* -*Defined in [order-utils/src/signature_utils.ts:219](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/signature_utils.ts#L219)* +*Defined in [order-utils/src/signature_utils.ts:222](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/signature_utils.ts#L222)* Checks if the supplied elliptic curve signature corresponds to signing `data` with the private key corresponding to `signerAddress` @@ -3096,7 +4497,7 @@ Whether the ECSignature is valid. ▸ **isValidPresignedSignatureAsync**(`supportedProvider`: [SupportedProvider](#supportedprovider), `data`: string, `signerAddress`: string, `exchangeAddress?`: undefined | string): *`Promise`* -*Defined in [order-utils/src/signature_utils.ts:107](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/signature_utils.ts#L107)* +*Defined in [order-utils/src/signature_utils.ts:107](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/signature_utils.ts#L107)* Verifies that the provided presigned signature is valid according to the 0x Protocol smart contracts @@ -3117,7 +4518,7 @@ Whether the data was preSigned by the supplied signerAddress ▸ **isValidSignatureAsync**(`supportedProvider`: [SupportedProvider](#supportedprovider), `data`: string, `signature`: string, `signerAddress`: string, `exchangeAddress?`: undefined | string): *`Promise`* -*Defined in [order-utils/src/signature_utils.ts:38](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/signature_utils.ts#L38)* +*Defined in [order-utils/src/signature_utils.ts:38](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/signature_utils.ts#L38)* Verifies that the provided signature is valid according to the 0x Protocol smart contracts @@ -3139,7 +4540,7 @@ Whether the signature is valid for the supplied signerAddress and data. ▸ **isValidValidatorSignatureAsync**(`supportedProvider`: [SupportedProvider](#supportedprovider), `data`: string, `signature`: string, `signerAddress`: string, `exchangeAddress?`: undefined | string): *`Promise`* -*Defined in [order-utils/src/signature_utils.ts:168](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/signature_utils.ts#L168)* +*Defined in [order-utils/src/signature_utils.ts:168](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/signature_utils.ts#L168)* Verifies that the provided validator signature is valid according to the 0x Protocol smart contracts @@ -3161,7 +4562,7 @@ Whether the data was preSigned by the supplied signerAddress. ▸ **isValidWalletSignatureAsync**(`supportedProvider`: [SupportedProvider](#supportedprovider), `data`: string, `signature`: string, `signerAddress`: string): *`Promise`* -*Defined in [order-utils/src/signature_utils.ts:139](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/signature_utils.ts#L139)* +*Defined in [order-utils/src/signature_utils.ts:139](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/signature_utils.ts#L139)* Verifies that the provided wallet signature is valid according to the 0x Protocol smart contracts @@ -3182,7 +4583,7 @@ Whether the data was preSigned by the supplied signerAddress. ▸ **parseECSignature**(`signature`: string): *`ECSignature`* -*Defined in [order-utils/src/signature_utils.ts:509](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/signature_utils.ts#L509)* +*Defined in [order-utils/src/signature_utils.ts:512](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/signature_utils.ts#L512)* Parse a 0x protocol hex-encoded signature string into its ECSignature components @@ -3200,7 +4601,7 @@ An ECSignature object with r,s,v parameters ▸ **parseValidatorSignature**(`signature`: string): *`ValidatorSignature`* -*Defined in [order-utils/src/signature_utils.ts:526](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/signature_utils.ts#L526)* +*Defined in [order-utils/src/signature_utils.ts:529](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/signature_utils.ts#L529)* Parse a hex-encoded Validator signature into validator address and signature components @@ -3225,13 +4626,13 @@ A ValidatorSignature with validatorAddress and signature parameters #### ▪ **sortingUtils**: *object* -*Defined in [order-utils/src/sorting_utils.ts:10](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/sorting_utils.ts#L10)* +*Defined in [order-utils/src/sorting_utils.ts:10](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/sorting_utils.ts#L10)* #### sortFeeOrdersByFeeAdjustedRate ▸ **sortFeeOrdersByFeeAdjustedRate**<**T**>(`feeOrders`: `T`[]): *`T`[]* -*Defined in [order-utils/src/sorting_utils.ts:35](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/sorting_utils.ts#L35)* +*Defined in [order-utils/src/sorting_utils.ts:35](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/sorting_utils.ts#L35)* Takes an array of fee orders (makerAssetData corresponds to ZRX and takerAssetData corresponds to WETH) and sorts them by rate in ascending order (best rate first). Adjusts the rate according to the takerFee. @@ -3254,7 +4655,7 @@ The input orders sorted by rate in ascending order ▸ **sortOrdersByFeeAdjustedRate**<**T**>(`orders`: `T`[], `feeRate`: `BigNumber`): *`T`[]* -*Defined in [order-utils/src/sorting_utils.ts:21](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/sorting_utils.ts#L21)* +*Defined in [order-utils/src/sorting_utils.ts:21](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/sorting_utils.ts#L21)* Takes an array of orders and sorts them by takerAsset/makerAsset rate in ascending order (best rate first). Adjusts the rate of each order according to the feeRate and takerFee for that order. @@ -3282,6 +4683,14 @@ The input orders sorted by rate in ascending order +
+ + + +
+ + + ## Object literals @@ -3289,13 +4698,13 @@ The input orders sorted by rate in ascending order #### ▪ **transactionHashUtils**: *object* -*Defined in [order-utils/src/transaction_hash.ts:9](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/transaction_hash.ts#L9)* +*Defined in [order-utils/src/transaction_hash.ts:9](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/transaction_hash.ts#L9)* #### getTransactionHashBuffer ▸ **getTransactionHashBuffer**(`transaction`: `ZeroExTransaction` | `SignedZeroExTransaction`): *`Buffer`* -*Defined in [order-utils/src/transaction_hash.ts:41](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/transaction_hash.ts#L41)* +*Defined in [order-utils/src/transaction_hash.ts:41](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/transaction_hash.ts#L41)* Computes the transactionHash for a supplied 0x transaction. @@ -3313,7 +4722,7 @@ A Buffer containing the resulting transactionHash from hashing the supplied 0x t ▸ **getTransactionHashHex**(`transaction`: `ZeroExTransaction` | `SignedZeroExTransaction`): *string* -*Defined in [order-utils/src/transaction_hash.ts:30](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/transaction_hash.ts#L30)* +*Defined in [order-utils/src/transaction_hash.ts:30](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/transaction_hash.ts#L30)* Computes the transactionHash for a supplied 0x transaction. @@ -3331,7 +4740,7 @@ Hex encoded string transactionHash from hashing the supplied order. ▸ **isValidTransactionHash**(`transactionHash`: string): *boolean* -*Defined in [order-utils/src/transaction_hash.ts:17](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/order-utils/src/transaction_hash.ts#L17)* +*Defined in [order-utils/src/transaction_hash.ts:17](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/order-utils/src/transaction_hash.ts#L17)* Checks if the supplied hex encoded 0x transaction hash is valid. Note: Valid means it has the expected format, not that a transaction with the transactionHash exists. @@ -3349,3 +4758,58 @@ Whether the supplied transactionHash has the expected format.
+ + +
+ + + + +## Type aliases + + + +### AssetData + +Ƭ **AssetData**: *[SingleAssetData](_types_src_index_.md#singleassetdata) | [MultiAssetData](#interface-multiassetdata) | [MultiAssetDataWithRecursiveDecoding](#interface-multiassetdatawithrecursivedecoding)* + +*Defined in [types/src/index.ts:224](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L224)* + +___ + + + + + +### EIP712ObjectValue + +Ƭ **EIP712ObjectValue**: *string | number | [EIP712Object](#interface-eip712object)* + +*Defined in [types/src/index.ts:740](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L740)* + +___ + + + + + +### OrderState + +Ƭ **OrderState**: *[OrderStateValid](#interface-orderstatevalid) | [OrderStateInvalid](#interface-orderstateinvalid)* + +*Defined in [types/src/index.ts:141](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L141)* + +___ + + + + + +### SingleAssetData + +Ƭ **SingleAssetData**: *[ERC20AssetData](#interface-erc20assetdata) | [ERC721AssetData](#interface-erc721assetdata) | [ERC1155AssetData](#interface-erc1155assetdata) | [StaticCallAssetData](#interface-staticcallassetdata)* + +*Defined in [types/src/index.ts:204](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L204)* + +
+ diff --git a/packages/sol-compiler/docs/reference.mdx b/packages/sol-compiler/docs/reference.mdx index cecbf00faf..dfeab02abd 100644 --- a/packages/sol-compiler/docs/reference.mdx +++ b/packages/sol-compiler/docs/reference.mdx @@ -1,16 +1,89 @@ +# Class: Compiler +The Compiler facilitates compiling Solidity smart contracts and saves the results +to artifact files. +## Constructors +\+ **new Compiler**(`opts?`: [CompilerOptions](#interface-compileroptions)): *[Compiler](#class-compiler)* + +*Defined in [sol-compiler/src/compiler.ts:97](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/sol-compiler/src/compiler.ts#L97)* + +Instantiates a new instance of the Compiler class. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`opts?` | [CompilerOptions](#interface-compileroptions) | Optional compiler options | + +**Returns:** *[Compiler](#class-compiler)* + +An instance of the Compiler class. + +## Methods + +### compileAsync + +▸ **compileAsync**(): *`Promise`* + +*Defined in [sol-compiler/src/compiler.ts:138](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/sol-compiler/src/compiler.ts#L138)* + +Compiles selected Solidity files found in `contractsDir` and writes JSON artifacts to `artifactsDir`. + +**Returns:** *`Promise`* + +___ + +### getCompilerOutputsAsync + +▸ **getCompilerOutputsAsync**(): *`Promise`* + +*Defined in [sol-compiler/src/compiler.ts:151](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/sol-compiler/src/compiler.ts#L151)* + +Compiles Solidity files specified during instantiation, and returns the +compiler output given by solc. Return value is an array of outputs: +Solidity modules are batched together by version required, and each +element of the returned array corresponds to a compiler version, and +each element contains the output for all of the modules compiled with +that version. + +**Returns:** *`Promise`* + +___ + +### getContractNamesToCompile + +▸ **getContractNamesToCompile**(): *string[]* + +*Defined in [sol-compiler/src/compiler.ts:192](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/sol-compiler/src/compiler.ts#L192)* + +Gets a list of contracts to compile. + +**Returns:** *string[]* + +___ + +### watchAsync + +▸ **watchAsync**(): *`Promise`* + +*Defined in [sol-compiler/src/compiler.ts:155](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/sol-compiler/src/compiler.ts#L155)* + +**Returns:** *`Promise`* + +
+ + -
@@ -37,7 +110,6 @@ useDockerisedSolc: If set to true - sol-compiler will try calling a dockerized i isOfflineMode: If set to true - sol-compiler will not fetch the list of solc releases from github. It will use the hardcoded list. Defaults to false. solcVersion: If you don't want to compile each contract with the Solidity version specified in-file, you can force all contracts to compile with the the version specified here. -shouldSaveStandardInput: Write the standard JSON input in ${contractsDir}/${contractName}.input.json ## Properties @@ -46,7 +118,7 @@ shouldSaveStandardInput: Write the standard JSON input in ${contractsDir}/${cont • **artifactsDir**? : *undefined | string* -*Defined in [ethereum-types/src/index.ts:732](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L732)* +*Defined in [ethereum-types/src/index.ts:731](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L731)* ___ @@ -54,7 +126,7 @@ ___ • **compilerSettings**? : *[CompilerSettings](#class-compilersettings)* -*Defined in [ethereum-types/src/index.ts:733](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L733)* +*Defined in [ethereum-types/src/index.ts:732](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L732)* ___ @@ -62,7 +134,7 @@ ___ • **contracts**? : *string[] | "*"* -*Defined in [ethereum-types/src/index.ts:734](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L734)* +*Defined in [ethereum-types/src/index.ts:733](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L733)* ___ @@ -70,7 +142,7 @@ ___ • **contractsDir**? : *undefined | string* -*Defined in [ethereum-types/src/index.ts:731](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L731)* +*Defined in [ethereum-types/src/index.ts:730](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L730)* ___ @@ -78,15 +150,7 @@ ___ • **isOfflineMode**? : *undefined | false | true* -*Defined in [ethereum-types/src/index.ts:736](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L736)* - -___ - -### `Optional` shouldSaveStandardInput - -• **shouldSaveStandardInput**? : *undefined | false | true* - -*Defined in [ethereum-types/src/index.ts:738](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L738)* +*Defined in [ethereum-types/src/index.ts:735](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L735)* ___ @@ -94,7 +158,7 @@ ___ • **solcVersion**? : *undefined | string* -*Defined in [ethereum-types/src/index.ts:737](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L737)* +*Defined in [ethereum-types/src/index.ts:736](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L736)* ___ @@ -102,7 +166,7 @@ ___ • **useDockerisedSolc**? : *undefined | false | true* -*Defined in [ethereum-types/src/index.ts:735](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L735)* +*Defined in [ethereum-types/src/index.ts:734](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L734)*
@@ -117,7 +181,7 @@ ___ • **evmVersion**? : *"homestead" | "tangerineWhistle" | "spuriousDragon" | "byzantium" | "constantinople"* -*Defined in [ethereum-types/src/index.ts:689](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L689)* +*Defined in [ethereum-types/src/index.ts:689](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L689)* ___ @@ -125,7 +189,7 @@ ___ • **libraries**? : *undefined | object* -*Defined in [ethereum-types/src/index.ts:691](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L691)* +*Defined in [ethereum-types/src/index.ts:691](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L691)* ___ @@ -133,7 +197,7 @@ ___ • **metadata**? : *[CompilerSettingsMetadata](#class-compilersettingsmetadata)* -*Defined in [ethereum-types/src/index.ts:690](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L690)* +*Defined in [ethereum-types/src/index.ts:690](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L690)* ___ @@ -141,7 +205,7 @@ ___ • **optimizer**? : *[OptimizerSettings](#class-optimizersettings)* -*Defined in [ethereum-types/src/index.ts:688](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L688)* +*Defined in [ethereum-types/src/index.ts:688](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L688)* ___ @@ -149,7 +213,7 @@ ___ • **outputSelection**: *object* -*Defined in [ethereum-types/src/index.ts:696](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L696)* +*Defined in [ethereum-types/src/index.ts:696](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L696)* #### Type declaration: @@ -163,7 +227,7 @@ ___ • **remappings**? : *string[]* -*Defined in [ethereum-types/src/index.ts:687](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L687)* +*Defined in [ethereum-types/src/index.ts:687](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L687)*
@@ -176,7 +240,7 @@ ___ • **useLiteralContent**: *true* -*Defined in [ethereum-types/src/index.ts:704](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L704)* +*Defined in [ethereum-types/src/index.ts:704](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L704)*
@@ -189,7 +253,7 @@ ___ • **inputs**: *[DataItem](#class-dataitem)[]* -*Defined in [ethereum-types/src/index.ts:103](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L103)* +*Defined in [ethereum-types/src/index.ts:103](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L103)* ___ @@ -197,7 +261,7 @@ ___ • **payable**: *boolean* -*Defined in [ethereum-types/src/index.ts:104](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L104)* +*Defined in [ethereum-types/src/index.ts:104](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L104)* ___ @@ -205,7 +269,7 @@ ___ • **stateMutability**: *[ConstructorStateMutability](#constructorstatemutability)* -*Defined in [ethereum-types/src/index.ts:105](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L105)* +*Defined in [ethereum-types/src/index.ts:105](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L105)* ___ @@ -213,7 +277,7 @@ ___ • **type**: *string* -*Defined in [ethereum-types/src/index.ts:102](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L102)* +*Defined in [ethereum-types/src/index.ts:102](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L102)*
@@ -232,7 +296,7 @@ ___ • **components**? : *[DataItem](#class-dataitem)[]* -*Defined in [ethereum-types/src/index.ts:137](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L137)* +*Defined in [ethereum-types/src/index.ts:137](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L137)* ___ @@ -240,7 +304,7 @@ ___ • **name**: *string* -*Defined in [ethereum-types/src/index.ts:135](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L135)* +*Defined in [ethereum-types/src/index.ts:135](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L135)* ___ @@ -248,7 +312,7 @@ ___ • **type**: *string* -*Defined in [ethereum-types/src/index.ts:136](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L136)* +*Defined in [ethereum-types/src/index.ts:136](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L136)*
@@ -265,7 +329,7 @@ ___ • **author**? : *undefined | string* -*Defined in [ethereum-types/src/index.ts:628](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L628)* +*Defined in [ethereum-types/src/index.ts:628](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L628)* ___ @@ -273,7 +337,7 @@ ___ • **methods**: *object* -*Defined in [ethereum-types/src/index.ts:629](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L629)* +*Defined in [ethereum-types/src/index.ts:629](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L629)* #### Type declaration: @@ -285,7 +349,7 @@ ___ • **title**? : *undefined | string* -*Defined in [ethereum-types/src/index.ts:627](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L627)* +*Defined in [ethereum-types/src/index.ts:627](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L627)*
@@ -300,7 +364,7 @@ ___ • **anonymous**: *boolean* -*Defined in [ethereum-types/src/index.ts:131](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L131)* +*Defined in [ethereum-types/src/index.ts:131](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L131)* ___ @@ -308,7 +372,7 @@ ___ • **inputs**: *[EventParameter](#class-eventparameter)[]* -*Defined in [ethereum-types/src/index.ts:130](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L130)* +*Defined in [ethereum-types/src/index.ts:130](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L130)* ___ @@ -316,7 +380,7 @@ ___ • **name**: *string* -*Defined in [ethereum-types/src/index.ts:129](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L129)* +*Defined in [ethereum-types/src/index.ts:129](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L129)* ___ @@ -324,7 +388,7 @@ ___ • **type**: *string* -*Defined in [ethereum-types/src/index.ts:128](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L128)* +*Defined in [ethereum-types/src/index.ts:128](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L128)*
@@ -339,7 +403,7 @@ ___ *Inherited from [DataItem](#interface-dataitem).[components](#optional-components)* -*Defined in [ethereum-types/src/index.ts:137](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L137)* +*Defined in [ethereum-types/src/index.ts:137](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L137)* ___ @@ -347,7 +411,7 @@ ___ • **indexed**: *boolean* -*Defined in [ethereum-types/src/index.ts:116](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L116)* +*Defined in [ethereum-types/src/index.ts:116](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L116)* ___ @@ -357,7 +421,7 @@ ___ *Inherited from [DataItem](#interface-dataitem).[name](#name)* -*Defined in [ethereum-types/src/index.ts:135](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L135)* +*Defined in [ethereum-types/src/index.ts:135](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L135)* ___ @@ -367,7 +431,7 @@ ___ *Inherited from [DataItem](#interface-dataitem).[type](#type)* -*Defined in [ethereum-types/src/index.ts:136](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L136)* +*Defined in [ethereum-types/src/index.ts:136](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L136)*
@@ -380,7 +444,7 @@ ___ • **object**: *string* -*Defined in [ethereum-types/src/index.ts:622](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L622)* +*Defined in [ethereum-types/src/index.ts:622](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L622)* ___ @@ -388,7 +452,7 @@ ___ • **sourceMap**: *string* -*Defined in [ethereum-types/src/index.ts:623](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L623)* +*Defined in [ethereum-types/src/index.ts:623](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L623)*
@@ -401,7 +465,7 @@ ___ • **bytecode**: *[EvmBytecodeOutput](#class-evmbytecodeoutput)* -*Defined in [ethereum-types/src/index.ts:617](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L617)* +*Defined in [ethereum-types/src/index.ts:617](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L617)* ___ @@ -409,7 +473,7 @@ ___ • **deployedBytecode**: *[EvmBytecodeOutput](#class-evmbytecodeoutput)* -*Defined in [ethereum-types/src/index.ts:618](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L618)* +*Defined in [ethereum-types/src/index.ts:618](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L618)*
@@ -422,7 +486,7 @@ ___ • **payable**: *boolean* -*Defined in [ethereum-types/src/index.ts:112](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L112)* +*Defined in [ethereum-types/src/index.ts:112](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L112)* ___ @@ -430,90 +494,13 @@ ___ • **type**: *string* -*Defined in [ethereum-types/src/index.ts:111](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L111)* +*Defined in [ethereum-types/src/index.ts:111](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L111)*
-# Class: Compiler -The Compiler facilitates compiling Solidity smart contracts and saves the results -to artifact files. - - -## Constructors - - - -\+ **new Compiler**(`opts?`: [CompilerOptions](#interface-compileroptions)): *[Compiler](#class-compiler)* - -*Defined in [sol-compiler/src/compiler.ts:100](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/sol-compiler/src/compiler.ts#L100)* - -Instantiates a new instance of the Compiler class. - -**Parameters:** - -Name | Type | Description | ------- | ------ | ------ | -`opts?` | [CompilerOptions](#interface-compileroptions) | Optional compiler options | - -**Returns:** *[Compiler](#class-compiler)* - -An instance of the Compiler class. - -## Methods - -### compileAsync - -▸ **compileAsync**(): *`Promise`* - -*Defined in [sol-compiler/src/compiler.ts:143](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/sol-compiler/src/compiler.ts#L143)* - -Compiles selected Solidity files found in `contractsDir` and writes JSON artifacts to `artifactsDir`. - -**Returns:** *`Promise`* - -___ - -### getCompilerOutputsAsync - -▸ **getCompilerOutputsAsync**(): *`Promise`* - -*Defined in [sol-compiler/src/compiler.ts:156](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/sol-compiler/src/compiler.ts#L156)* - -Compiles Solidity files specified during instantiation, and returns the -compiler output given by solc. Return value is an array of outputs: -Solidity modules are batched together by version required, and each -element of the returned array corresponds to a compiler version, and -each element contains the output for all of the modules compiled with -that version. - -**Returns:** *`Promise`* - -___ - -### getContractNamesToCompile - -▸ **getContractNamesToCompile**(): *string[]* - -*Defined in [sol-compiler/src/compiler.ts:197](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/sol-compiler/src/compiler.ts#L197)* - -Gets a list of contracts to compile. - -**Returns:** *string[]* - -___ - -### watchAsync - -▸ **watchAsync**(): *`Promise`* - -*Defined in [sol-compiler/src/compiler.ts:160](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/sol-compiler/src/compiler.ts#L160)* - -**Returns:** *`Promise`* - -
@@ -538,7 +525,7 @@ ___ • **constant**: *boolean* -*Defined in [ethereum-types/src/index.ts:94](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L94)* +*Defined in [ethereum-types/src/index.ts:94](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L94)* ___ @@ -546,7 +533,7 @@ ___ • **inputs**: *[DataItem](#class-dataitem)[]* -*Defined in [ethereum-types/src/index.ts:92](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L92)* +*Defined in [ethereum-types/src/index.ts:92](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L92)* ___ @@ -554,7 +541,7 @@ ___ • **name**: *string* -*Defined in [ethereum-types/src/index.ts:91](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L91)* +*Defined in [ethereum-types/src/index.ts:91](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L91)* ___ @@ -562,7 +549,7 @@ ___ • **outputs**: *[DataItem](#class-dataitem)[]* -*Defined in [ethereum-types/src/index.ts:93](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L93)* +*Defined in [ethereum-types/src/index.ts:93](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L93)* ___ @@ -570,7 +557,7 @@ ___ • **payable**: *boolean* -*Defined in [ethereum-types/src/index.ts:96](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L96)* +*Defined in [ethereum-types/src/index.ts:96](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L96)* ___ @@ -578,7 +565,7 @@ ___ • **stateMutability**: *[StateMutability](#statemutability)* -*Defined in [ethereum-types/src/index.ts:95](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L95)* +*Defined in [ethereum-types/src/index.ts:95](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L95)* ___ @@ -586,7 +573,7 @@ ___ • **type**: *string* -*Defined in [ethereum-types/src/index.ts:90](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L90)* +*Defined in [ethereum-types/src/index.ts:90](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L90)*
@@ -599,7 +586,7 @@ ___ • **enabled**: *boolean* -*Defined in [ethereum-types/src/index.ts:708](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L708)* +*Defined in [ethereum-types/src/index.ts:708](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L708)* ___ @@ -607,7 +594,7 @@ ___ • **runs**? : *undefined | number* -*Defined in [ethereum-types/src/index.ts:709](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L709)* +*Defined in [ethereum-types/src/index.ts:709](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L709)*
@@ -624,7 +611,7 @@ ___ • **arguments**? : *[DataItem](#class-dataitem)[]* -*Defined in [ethereum-types/src/index.ts:122](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L122)* +*Defined in [ethereum-types/src/index.ts:122](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L122)* ___ @@ -632,7 +619,7 @@ ___ • **name**: *string* -*Defined in [ethereum-types/src/index.ts:121](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L121)* +*Defined in [ethereum-types/src/index.ts:121](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L121)* ___ @@ -640,7 +627,7 @@ ___ • **type**: *"error"* -*Defined in [ethereum-types/src/index.ts:120](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L120)* +*Defined in [ethereum-types/src/index.ts:120](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L120)*
@@ -653,7 +640,7 @@ ___ • **component**: *"general" | "ewasm"* -*Defined in [ethereum-types/src/index.ts:604](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L604)* +*Defined in [ethereum-types/src/index.ts:604](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L604)* ___ @@ -661,7 +648,7 @@ ___ • **formattedMessage**? : *undefined | string* -*Defined in [ethereum-types/src/index.ts:607](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L607)* +*Defined in [ethereum-types/src/index.ts:607](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L607)* ___ @@ -669,7 +656,7 @@ ___ • **message**: *string* -*Defined in [ethereum-types/src/index.ts:606](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L606)* +*Defined in [ethereum-types/src/index.ts:606](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L606)* ___ @@ -677,7 +664,7 @@ ___ • **severity**: *[ErrorSeverity](#errorseverity)* -*Defined in [ethereum-types/src/index.ts:605](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L605)* +*Defined in [ethereum-types/src/index.ts:605](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L605)* ___ @@ -685,7 +672,7 @@ ___ • **sourceLocation**? : *[SourceLocation](#class-sourcelocation)* -*Defined in [ethereum-types/src/index.ts:602](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L602)* +*Defined in [ethereum-types/src/index.ts:602](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L602)* ___ @@ -693,7 +680,7 @@ ___ • **type**: *[ErrorType](#errortype)* -*Defined in [ethereum-types/src/index.ts:603](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L603)* +*Defined in [ethereum-types/src/index.ts:603](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L603)*
@@ -710,7 +697,7 @@ ___ • **abi**: *[ContractAbi](#contractabi)* -*Defined in [ethereum-types/src/index.ts:564](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L564)* +*Defined in [ethereum-types/src/index.ts:564](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L564)* ___ @@ -718,7 +705,7 @@ ___ • **devdoc**? : *[DevdocOutput](#class-devdocoutput)* -*Defined in [ethereum-types/src/index.ts:566](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L566)* +*Defined in [ethereum-types/src/index.ts:566](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L566)* ___ @@ -726,7 +713,7 @@ ___ • **evm**: *[EvmOutput](#class-evmoutput)* -*Defined in [ethereum-types/src/index.ts:565](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L565)* +*Defined in [ethereum-types/src/index.ts:565](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L565)*
@@ -739,7 +726,7 @@ ___ • **contracts**: *object* -*Defined in [ethereum-types/src/index.ts:578](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L578)* +*Defined in [ethereum-types/src/index.ts:578](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L578)* #### Type declaration: @@ -753,7 +740,7 @@ ___ • **errors**: *[SolcError](#class-solcerror)[]* -*Defined in [ethereum-types/src/index.ts:570](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L570)* +*Defined in [ethereum-types/src/index.ts:570](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L570)* ___ @@ -761,7 +748,7 @@ ___ • **sources**: *object* -*Defined in [ethereum-types/src/index.ts:571](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L571)* +*Defined in [ethereum-types/src/index.ts:571](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L571)* #### Type declaration: @@ -792,7 +779,7 @@ ___ *Overrides [DataItem](_ethereum_types_src_index_.dataitem.md).[components](#optional-components)* -*Defined in [ethereum-types/src/index.ts:141](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L141)* +*Defined in [ethereum-types/src/index.ts:141](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L141)* ___ @@ -802,7 +789,7 @@ ___ *Inherited from [DataItem](#interface-dataitem).[name](#name)* -*Defined in [ethereum-types/src/index.ts:135](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L135)* +*Defined in [ethereum-types/src/index.ts:135](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L135)* ___ @@ -812,7 +799,7 @@ ___ *Inherited from [DataItem](#interface-dataitem).[type](#type)* -*Defined in [ethereum-types/src/index.ts:136](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L136)* +*Defined in [ethereum-types/src/index.ts:136](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L136)*
@@ -837,7 +824,7 @@ ___ Ƭ **AbiDefinition**: *[FunctionAbi](_ethereum_types_src_index_.md#functionabi) | [EventAbi](#interface-eventabi) | [RevertErrorAbi](#interface-reverterrorabi)* -*Defined in [ethereum-types/src/index.ts:80](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L80)* +*Defined in [ethereum-types/src/index.ts:80](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L80)* ___ @@ -847,7 +834,7 @@ ___ Ƭ **ConstructorStateMutability**: *"nonpayable" | "payable"* -*Defined in [ethereum-types/src/index.ts:84](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L84)* +*Defined in [ethereum-types/src/index.ts:84](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L84)* ___ @@ -855,7 +842,7 @@ ___ Ƭ **ContractAbi**: *[AbiDefinition](#abidefinition)[]* -*Defined in [ethereum-types/src/index.ts:78](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L78)* +*Defined in [ethereum-types/src/index.ts:78](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L78)* ___ @@ -869,7 +856,7 @@ ___ Ƭ **ErrorSeverity**: *"error" | "warning"* -*Defined in [ethereum-types/src/index.ts:599](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L599)* +*Defined in [ethereum-types/src/index.ts:599](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L599)* ___ @@ -877,7 +864,7 @@ ___ Ƭ **ErrorType**: *"JSONError" | "IOError" | "ParserError" | "DocstringParsingError" | "SyntaxError" | "DeclarationError" | "TypeError" | "UnimplementedFeatureError" | "InternalCompilerError" | "Exception" | "CompilerError" | "FatalError" | "Warning"* -*Defined in [ethereum-types/src/index.ts:585](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L585)* +*Defined in [ethereum-types/src/index.ts:585](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L585)* ___ @@ -885,7 +872,7 @@ ___ Ƭ **FunctionAbi**: *[MethodAbi](#interface-methodabi) | [ConstructorAbi](#interface-constructorabi) | [FallbackAbi](#interface-fallbackabi)* -*Defined in [ethereum-types/src/index.ts:82](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L82)* +*Defined in [ethereum-types/src/index.ts:82](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L82)* ___ @@ -897,7 +884,7 @@ ___ Ƭ **OutputField**: *"*" | "ast" | "legacyAST" | "abi" | "devdoc" | "userdoc" | "metadata" | "ir" | "evm.assembly" | "evm.legacyAssembly" | "evm.bytecode.object" | "evm.bytecode.opcodes" | "evm.bytecode.sourceMap" | "evm.bytecode.linkReferences" | "evm.deployedBytecode.object" | "evm.deployedBytecode.opcodes" | "evm.deployedBytecode.sourceMap" | "evm.deployedBytecode.linkReferences" | "evm.methodIdentifiers" | "evm.gasEstimates" | "ewasm.wast" | "ewasm.wasm"* -*Defined in [ethereum-types/src/index.ts:525](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L525)* +*Defined in [ethereum-types/src/index.ts:525](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L525)* ___ @@ -905,7 +892,7 @@ ___ Ƭ **ParamDescription**: *string* -*Defined in [ethereum-types/src/index.ts:561](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L561)* +*Defined in [ethereum-types/src/index.ts:561](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L561)* ___ @@ -915,7 +902,7 @@ ___ Ƭ **StateMutability**: *"pure" | "view" | [ConstructorStateMutability](#constructorstatemutability)* -*Defined in [ethereum-types/src/index.ts:85](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L85)* +*Defined in [ethereum-types/src/index.ts:85](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L85)* ___ @@ -927,3 +914,7 @@ ___ + + +
+ diff --git a/packages/sol-coverage/docs/reference.mdx b/packages/sol-coverage/docs/reference.mdx index 6bb2085322..a0b9c1e7fe 100644 --- a/packages/sol-coverage/docs/reference.mdx +++ b/packages/sol-coverage/docs/reference.mdx @@ -1,183 +1,231 @@ +# Class: CoverageSubprovider +This class implements the [web3-provider-engine](https://github.com/MetaMask/provider-engine) subprovider interface. +It's used to compute your code coverage while running solidity tests. -# Class: AbstractArtifactAdapter +## Constructors -## Methods -### `Abstract` collectContractsDataAsync -▸ **collectContractsDataAsync**(): *`Promise`* +\+ **new CoverageSubprovider**(`artifactAdapter`: `AbstractArtifactAdapter`, `defaultFromAddress`: string, `partialConfig`: [CoverageSubproviderPartialConfig](#coveragesubproviderpartialconfig)): *[CoverageSubprovider](#class-coveragesubprovider)* -*Defined in [sol-tracing-utils/src/artifact_adapters/abstract_artifact_adapter.ts:4](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/sol-tracing-utils/src/artifact_adapters/abstract_artifact_adapter.ts#L4)* +*Overrides void* -**Returns:** *`Promise`* +*Defined in [sol-coverage/src/coverage_subprovider.ts:44](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/sol-coverage/src/coverage_subprovider.ts#L44)* -
+Instantiates a CoverageSubprovider instance -# Class: SolCompilerArtifactAdapter +**Parameters:** +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`artifactAdapter` | `AbstractArtifactAdapter` | - | Adapter for used artifacts format (0x, truffle, giveth, etc.) | +`defaultFromAddress` | string | - | default from address to use when sending transactions | +`partialConfig` | [CoverageSubproviderPartialConfig](#coveragesubproviderpartialconfig) | {} | Partial configuration object | -## Constructors +**Returns:** *[CoverageSubprovider](#class-coveragesubprovider)* +## Methods +### emitPayloadAsync -\+ **new SolCompilerArtifactAdapter**(`artifactsPath?`: undefined | string, `sourcesPath?`: undefined | string): *[SolCompilerArtifactAdapter](#class-solcompilerartifactadapter)* +▸ **emitPayloadAsync**(`payload`: `Partial`): *`Promise`* -*Defined in [sol-tracing-utils/src/artifact_adapters/sol_compiler_artifact_adapter.ts:18](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/sol-tracing-utils/src/artifact_adapters/sol_compiler_artifact_adapter.ts#L18)* -Instantiates a SolCompilerArtifactAdapter + +Defined in subproviders/lib/src/subproviders/subprovider.d.ts:25 + +Emits a JSON RPC payload that will then be handled by the ProviderEngine instance +this subprovider is a part of. The payload will cascade down the subprovider middleware +stack until finding the responsible entity for handling the request. **Parameters:** Name | Type | Description | ------ | ------ | ------ | -`artifactsPath?` | undefined \| string | Path to your artifacts directory | -`sourcesPath?` | undefined \| string | Path to your contract sources directory | +`payload` | `Partial` | JSON RPC payload | -**Returns:** *[SolCompilerArtifactAdapter](#class-solcompilerartifactadapter)* +**Returns:** *`Promise`* -## Methods +JSON RPC response payload -### collectContractsDataAsync +___ -▸ **collectContractsDataAsync**(): *`Promise`* +### handleRequest -*Overrides [AbstractArtifactAdapter](_sol_tracing_utils_src_artifact_adapters_abstract_artifact_adapter_.abstractartifactadapter.md).[collectContractsDataAsync](#abstract-collectcontractsdataasync)* +▸ **handleRequest**(`payload`: `JSONRPCRequestPayload`, `next`: [NextCallback](#nextcallback), `_end`: [ErrorCallback](#errorcallback)): *`Promise`* -*Defined in [sol-tracing-utils/src/artifact_adapters/sol_compiler_artifact_adapter.ts:44](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/sol-tracing-utils/src/artifact_adapters/sol_compiler_artifact_adapter.ts#L44)* -**Returns:** *`Promise`* -
+*Overrides void* -# Class: TruffleArtifactAdapter +Defined in sol-tracing-utils/lib/src/trace_collection_subprovider.d.ts:42 +This method conforms to the web3-provider-engine interface. +It is called internally by the ProviderEngine when it is this subproviders +turn to handle a JSON RPC request. -## Constructors +**Parameters:** +Name | Type | Description | +------ | ------ | ------ | +`payload` | `JSONRPCRequestPayload` | JSON RPC payload | +`next` | [NextCallback](#nextcallback) | Callback to call if this subprovider decides not to handle the request | +`_end` | [ErrorCallback](#errorcallback) | Callback to call if subprovider handled the request and wants to pass back the request. | +**Returns:** *`Promise`* -\+ **new TruffleArtifactAdapter**(`projectRoot`: string, `solcVersion`: string): *[TruffleArtifactAdapter](#class-truffleartifactadapter)* +___ -*Defined in [sol-tracing-utils/src/artifact_adapters/truffle_artifact_adapter.ts:29](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/sol-tracing-utils/src/artifact_adapters/truffle_artifact_adapter.ts#L29)* +### setEngine -Instantiates a TruffleArtifactAdapter +▸ **setEngine**(`engine`: `Web3ProviderEngine`): *void* + + + +*Overrides void* + +Defined in sol-tracing-utils/lib/src/trace_collection_subprovider.d.ts:49 + +Set's the subprovider's engine to the ProviderEngine it is added to. +This is only called within the ProviderEngine source code, do not call +directly. **Parameters:** Name | Type | Description | ------ | ------ | ------ | -`projectRoot` | string | Path to the truffle project's root directory | -`solcVersion` | string | Solidity version with which to compile all the contracts | +`engine` | `Web3ProviderEngine` | The ProviderEngine this subprovider is added to | -**Returns:** *[TruffleArtifactAdapter](#class-truffleartifactadapter)* +**Returns:** *void* -## Methods +___ -### collectContractsDataAsync +### start -▸ **collectContractsDataAsync**(): *`Promise`* +▸ **start**(): *void* -*Overrides [AbstractArtifactAdapter](_sol_tracing_utils_src_artifact_adapters_abstract_artifact_adapter_.abstractartifactadapter.md).[collectContractsDataAsync](#abstract-collectcontractsdataasync)* -*Defined in [sol-tracing-utils/src/artifact_adapters/truffle_artifact_adapter.ts:40](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/sol-tracing-utils/src/artifact_adapters/truffle_artifact_adapter.ts#L40)* -**Returns:** *`Promise`* - -
+Defined in sol-tracing-utils/lib/src/trace_collection_subprovider.d.ts:29 +Starts trace collection +**Returns:** *void* +___ +### stop +▸ **stop**(): *void* +Defined in sol-tracing-utils/lib/src/trace_collection_subprovider.d.ts:33 +Stops trace collection +**Returns:** *void* +___ +### writeCoverageAsync +▸ **writeCoverageAsync**(): *`Promise`* +*Defined in [sol-coverage/src/coverage_subprovider.ts:78](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/sol-coverage/src/coverage_subprovider.ts#L78)* +Write the test coverage results to a file in Istanbul format. +**Returns:** *`Promise`* +
+# Class: AbstractArtifactAdapter -## Type aliases +## Methods -### Callback +### `Abstract` collectContractsDataAsync -Ƭ **Callback**: *function* +▸ **collectContractsDataAsync**(): *`Promise`* -*Defined in [subproviders/src/types.ts:131](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/types.ts#L131)* +*Defined in [sol-tracing-utils/src/artifact_adapters/abstract_artifact_adapter.ts:4](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/sol-tracing-utils/src/artifact_adapters/abstract_artifact_adapter.ts#L4)* -#### Type declaration: +**Returns:** *`Promise`* -▸ (): *void* +
-___ +# Class: SolCompilerArtifactAdapter +## Constructors -### ErrorCallback -Ƭ **ErrorCallback**: *function* -*Defined in [subproviders/src/types.ts:130](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/types.ts#L130)* +\+ **new SolCompilerArtifactAdapter**(`artifactsPath?`: undefined | string, `sourcesPath?`: undefined | string): *[SolCompilerArtifactAdapter](#class-solcompilerartifactadapter)* -#### Type declaration: +*Defined in [sol-tracing-utils/src/artifact_adapters/sol_compiler_artifact_adapter.ts:18](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/sol-tracing-utils/src/artifact_adapters/sol_compiler_artifact_adapter.ts#L18)* -▸ (`err`: `Error` | null, `data?`: any): *void* +Instantiates a SolCompilerArtifactAdapter **Parameters:** -Name | Type | ------- | ------ | -`err` | `Error` \| null | -`data?` | any | +Name | Type | Description | +------ | ------ | ------ | +`artifactsPath?` | undefined \| string | Path to your artifacts directory | +`sourcesPath?` | undefined \| string | Path to your contract sources directory | -___ +**Returns:** *[SolCompilerArtifactAdapter](#class-solcompilerartifactadapter)* +## Methods +### collectContractsDataAsync -### NextCallback +▸ **collectContractsDataAsync**(): *`Promise`* -Ƭ **NextCallback**: *function* +*Overrides [AbstractArtifactAdapter](_sol_tracing_utils_src_artifact_adapters_abstract_artifact_adapter_.abstractartifactadapter.md).[collectContractsDataAsync](#abstract-collectcontractsdataasync)* -*Defined in [subproviders/src/types.ts:133](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/types.ts#L133)* +*Defined in [sol-tracing-utils/src/artifact_adapters/sol_compiler_artifact_adapter.ts:44](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/sol-tracing-utils/src/artifact_adapters/sol_compiler_artifact_adapter.ts#L44)* -#### Type declaration: +**Returns:** *`Promise`* -▸ (`callback?`: [OnNextCompleted](#onnextcompleted)): *void* +
-**Parameters:** +# Class: TruffleArtifactAdapter -Name | Type | ------- | ------ | -`callback?` | [OnNextCompleted](#onnextcompleted) | -___ +## Constructors -### OnNextCompleted -Ƭ **OnNextCompleted**: *function* -*Defined in [subproviders/src/types.ts:132](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/types.ts#L132)* +\+ **new TruffleArtifactAdapter**(`projectRoot`: string, `solcVersion`: string): *[TruffleArtifactAdapter](#class-truffleartifactadapter)* -#### Type declaration: +*Defined in [sol-tracing-utils/src/artifact_adapters/truffle_artifact_adapter.ts:29](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/sol-tracing-utils/src/artifact_adapters/truffle_artifact_adapter.ts#L29)* -▸ (`err`: `Error` | null, `result`: any, `cb`: [Callback](#callback)): *void* +Instantiates a TruffleArtifactAdapter **Parameters:** -Name | Type | ------- | ------ | -`err` | `Error` \| null | -`result` | any | -`cb` | [Callback](#callback) | +Name | Type | Description | +------ | ------ | ------ | +`projectRoot` | string | Path to the truffle project's root directory | +`solcVersion` | string | Solidity version with which to compile all the contracts | + +**Returns:** *[TruffleArtifactAdapter](#class-truffleartifactadapter)* + +## Methods + +### collectContractsDataAsync + +▸ **collectContractsDataAsync**(): *`Promise`* + +*Overrides [AbstractArtifactAdapter](_sol_tracing_utils_src_artifact_adapters_abstract_artifact_adapter_.abstractartifactadapter.md).[collectContractsDataAsync](#abstract-collectcontractsdataasync)* + +*Defined in [sol-tracing-utils/src/artifact_adapters/truffle_artifact_adapter.ts:40](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/sol-tracing-utils/src/artifact_adapters/truffle_artifact_adapter.ts#L40)* + +**Returns:** *`Promise`*
@@ -218,6 +266,22 @@ Name | Type | + + + + + + + + + + + + + + + + @@ -244,7 +308,7 @@ Name | Type | • **id**: *number* -*Defined in [ethereum-types/src/index.ts:330](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L330)* +*Defined in [ethereum-types/src/index.ts:330](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L330)* ___ @@ -252,7 +316,7 @@ ___ • **jsonrpc**: *string* -*Defined in [ethereum-types/src/index.ts:331](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L331)* +*Defined in [ethereum-types/src/index.ts:331](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L331)* ___ @@ -260,7 +324,7 @@ ___ • **method**: *string* -*Defined in [ethereum-types/src/index.ts:329](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L329)* +*Defined in [ethereum-types/src/index.ts:329](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L329)* ___ @@ -268,7 +332,7 @@ ___ • **params**: *any[]* -*Defined in [ethereum-types/src/index.ts:328](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L328)* +*Defined in [ethereum-types/src/index.ts:328](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L328)*
@@ -281,7 +345,7 @@ ___ • **code**: *number* -*Defined in [ethereum-types/src/index.ts:336](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L336)* +*Defined in [ethereum-types/src/index.ts:336](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L336)* ___ @@ -289,7 +353,7 @@ ___ • **message**: *string* -*Defined in [ethereum-types/src/index.ts:335](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L335)* +*Defined in [ethereum-types/src/index.ts:335](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L335)*
@@ -302,7 +366,7 @@ ___ • **error**? : *[JSONRPCResponseError](#class-jsonrpcresponseerror)* -*Defined in [ethereum-types/src/index.ts:343](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L343)* +*Defined in [ethereum-types/src/index.ts:343](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L343)* ___ @@ -310,7 +374,7 @@ ___ • **id**: *number* -*Defined in [ethereum-types/src/index.ts:341](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L341)* +*Defined in [ethereum-types/src/index.ts:341](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L341)* ___ @@ -318,7 +382,7 @@ ___ • **jsonrpc**: *string* -*Defined in [ethereum-types/src/index.ts:342](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L342)* +*Defined in [ethereum-types/src/index.ts:342](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L342)* ___ @@ -326,7 +390,7 @@ ___ • **result**: *any* -*Defined in [ethereum-types/src/index.ts:340](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L340)* +*Defined in [ethereum-types/src/index.ts:340](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L340)*
@@ -362,185 +426,122 @@ ___ -# Class: CoverageSubprovider - -This class implements the [web3-provider-engine](https://github.com/MetaMask/provider-engine) subprovider interface. -It's used to compute your code coverage while running solidity tests. - - -## Constructors - - - -\+ **new CoverageSubprovider**(`artifactAdapter`: `AbstractArtifactAdapter`, `defaultFromAddress`: string, `partialConfig`: [CoverageSubproviderPartialConfig](#coveragesubproviderpartialconfig)): *[CoverageSubprovider](#class-coveragesubprovider)* -*Overrides void* -*Defined in [sol-coverage/src/coverage_subprovider.ts:44](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/sol-coverage/src/coverage_subprovider.ts#L44)* -Instantiates a CoverageSubprovider instance -**Parameters:** -Name | Type | Default | Description | ------- | ------ | ------ | ------ | -`artifactAdapter` | `AbstractArtifactAdapter` | - | Adapter for used artifacts format (0x, truffle, giveth, etc.) | -`defaultFromAddress` | string | - | default from address to use when sending transactions | -`partialConfig` | [CoverageSubproviderPartialConfig](#coveragesubproviderpartialconfig) | {} | Partial configuration object | -**Returns:** *[CoverageSubprovider](#class-coveragesubprovider)* -## Methods -### emitPayloadAsync -▸ **emitPayloadAsync**(`payload`: `Partial`): *`Promise`* -Defined in subproviders/lib/src/subproviders/subprovider.d.ts:25 -Emits a JSON RPC payload that will then be handled by the ProviderEngine instance -this subprovider is a part of. The payload will cascade down the subprovider middleware -stack until finding the responsible entity for handling the request. -**Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`payload` | `Partial` | JSON RPC payload | -**Returns:** *`Promise`* -JSON RPC response payload -___ -### handleRequest -▸ **handleRequest**(`payload`: `JSONRPCRequestPayload`, `next`: [NextCallback](#nextcallback), `_end`: [ErrorCallback](#errorcallback)): *`Promise`* -*Overrides void* -Defined in sol-tracing-utils/lib/src/trace_collection_subprovider.d.ts:42 -This method conforms to the web3-provider-engine interface. -It is called internally by the ProviderEngine when it is this subproviders -turn to handle a JSON RPC request. -**Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`payload` | `JSONRPCRequestPayload` | JSON RPC payload | -`next` | [NextCallback](#nextcallback) | Callback to call if this subprovider decides not to handle the request | -`_end` | [ErrorCallback](#errorcallback) | Callback to call if subprovider handled the request and wants to pass back the request. | - -**Returns:** *`Promise`* - -___ -### setEngine + -▸ **setEngine**(`engine`: `Web3ProviderEngine`): *void* -*Overrides void* -Defined in sol-tracing-utils/lib/src/trace_collection_subprovider.d.ts:49 + -Set's the subprovider's engine to the ProviderEngine it is added to. -This is only called within the ProviderEngine source code, do not call -directly. + -**Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`engine` | `Web3ProviderEngine` | The ProviderEngine this subprovider is added to | -**Returns:** *void* -___ -### start -▸ **start**(): *void* + -Defined in sol-tracing-utils/lib/src/trace_collection_subprovider.d.ts:29 -Starts trace collection -**Returns:** *void* -___ -### stop -▸ **stop**(): *void* -Defined in sol-tracing-utils/lib/src/trace_collection_subprovider.d.ts:33 -Stops trace collection -**Returns:** *void* -___ -### writeCoverageAsync -▸ **writeCoverageAsync**(): *`Promise`* +# Interface: JSONRPCRequestPayloadWithMethod -*Defined in [sol-coverage/src/coverage_subprovider.ts:78](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/sol-coverage/src/coverage_subprovider.ts#L78)* -Write the test coverage results to a file in Istanbul format. +## Properties -**Returns:** *`Promise`* +### id -
+• **id**: *number* +Defined in ethereum-types/lib/index.d.ts:267 +___ +### jsonrpc +• **jsonrpc**: *string* +Defined in ethereum-types/lib/index.d.ts:268 +___ +### method +• **method**: *string* +*Overrides void* +*Defined in [subproviders/src/types.ts:136](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/types.ts#L136)* +___ +### params +• **params**: *any[]* +Defined in ethereum-types/lib/index.d.ts:265 +
- - - @@ -548,7 +549,6 @@ Write the test coverage results to a file in Istanbul format. - @@ -564,50 +564,32 @@ Write the test coverage results to a file in Istanbul format. -# Interface: JSONRPCRequestPayloadWithMethod +## Type aliases -## Properties -### id -• **id**: *number* -Defined in ethereum-types/lib/index.d.ts:267 -___ -### jsonrpc -• **jsonrpc**: *string* -Defined in ethereum-types/lib/index.d.ts:268 -___ -### method -• **method**: *string* -*Overrides void* -*Defined in [subproviders/src/types.ts:136](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/types.ts#L136)* -___ -### params -• **params**: *any[]* -Defined in ethereum-types/lib/index.d.ts:265 -
@@ -627,30 +609,47 @@ Defined in ethereum-types/lib/index.d.ts:265 +## Type aliases +### CoverageSubproviderPartialConfig +Ƭ **CoverageSubproviderPartialConfig**: *`Partial`* +*Defined in [sol-coverage/src/coverage_subprovider.ts:31](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/sol-coverage/src/coverage_subprovider.ts#L31)* +## Object literals +### `Const` DEFAULT_COVERAGE_SUBPROVIDER_CONFIG +#### ▪ **DEFAULT_COVERAGE_SUBPROVIDER_CONFIG**: *object* +*Defined in [sol-coverage/src/coverage_subprovider.ts:33](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/sol-coverage/src/coverage_subprovider.ts#L33)* +#### ignoreFilesGlobs +• **ignoreFilesGlobs**: *never[]* = [] +*Defined in [sol-coverage/src/coverage_subprovider.ts:35](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/sol-coverage/src/coverage_subprovider.ts#L35)* +#### isVerbose +• **isVerbose**: *boolean* = true +*Defined in [sol-coverage/src/coverage_subprovider.ts:34](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/sol-coverage/src/coverage_subprovider.ts#L34)* +
-## Type aliases +
+
+
@@ -668,77 +667,78 @@ Defined in ethereum-types/lib/index.d.ts:265 +## Type aliases +### Callback +Ƭ **Callback**: *function* +*Defined in [subproviders/src/types.ts:131](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/types.ts#L131)* +#### Type declaration: +▸ (): *void* +___ +### ErrorCallback +Ƭ **ErrorCallback**: *function* +*Defined in [subproviders/src/types.ts:130](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/types.ts#L130)* +#### Type declaration: +▸ (`err`: `Error` | null, `data?`: any): *void* +**Parameters:** +Name | Type | +------ | ------ | +`err` | `Error` \| null | +`data?` | any | +___ +### NextCallback +Ƭ **NextCallback**: *function* +*Defined in [subproviders/src/types.ts:133](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/types.ts#L133)* +#### Type declaration: +▸ (`callback?`: [OnNextCompleted](#onnextcompleted)): *void* +**Parameters:** +Name | Type | +------ | ------ | +`callback?` | [OnNextCompleted](#onnextcompleted) | +___ +### OnNextCompleted +Ƭ **OnNextCompleted**: *function* +*Defined in [subproviders/src/types.ts:132](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/types.ts#L132)* +#### Type declaration: +▸ (`err`: `Error` | null, `result`: any, `cb`: [Callback](#callback)): *void* -## Type aliases - -### CoverageSubproviderPartialConfig - -Ƭ **CoverageSubproviderPartialConfig**: *`Partial`* - -*Defined in [sol-coverage/src/coverage_subprovider.ts:31](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/sol-coverage/src/coverage_subprovider.ts#L31)* - -## Object literals - -### `Const` DEFAULT_COVERAGE_SUBPROVIDER_CONFIG - -#### ▪ **DEFAULT_COVERAGE_SUBPROVIDER_CONFIG**: *object* - -*Defined in [sol-coverage/src/coverage_subprovider.ts:33](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/sol-coverage/src/coverage_subprovider.ts#L33)* - -#### ignoreFilesGlobs - -• **ignoreFilesGlobs**: *never[]* = [] - -*Defined in [sol-coverage/src/coverage_subprovider.ts:35](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/sol-coverage/src/coverage_subprovider.ts#L35)* - -#### isVerbose - -• **isVerbose**: *boolean* = true +**Parameters:** -*Defined in [sol-coverage/src/coverage_subprovider.ts:34](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/sol-coverage/src/coverage_subprovider.ts#L34)* +Name | Type | +------ | ------ | +`err` | `Error` \| null | +`result` | any | +`cb` | [Callback](#callback) |
- - -
- - - -
- - - -
- diff --git a/packages/sol-profiler/docs/reference.mdx b/packages/sol-profiler/docs/reference.mdx index bc1c7d0a83..71ed536334 100644 --- a/packages/sol-profiler/docs/reference.mdx +++ b/packages/sol-profiler/docs/reference.mdx @@ -1,183 +1,231 @@ +# Class: ProfilerSubprovider +This class implements the [web3-provider-engine](https://github.com/MetaMask/provider-engine) subprovider interface. +ProfilerSubprovider is used to profile Solidity code while running tests. -# Class: AbstractArtifactAdapter +## Constructors -## Methods -### `Abstract` collectContractsDataAsync -▸ **collectContractsDataAsync**(): *`Promise`* +\+ **new ProfilerSubprovider**(`artifactAdapter`: `AbstractArtifactAdapter`, `defaultFromAddress`: string, `isVerbose`: boolean): *[ProfilerSubprovider](#class-profilersubprovider)* -*Defined in [sol-tracing-utils/src/artifact_adapters/abstract_artifact_adapter.ts:4](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/sol-tracing-utils/src/artifact_adapters/abstract_artifact_adapter.ts#L4)* +*Overrides void* -**Returns:** *`Promise`* +*Defined in [sol-profiler/src/profiler_subprovider.ts:30](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/sol-profiler/src/profiler_subprovider.ts#L30)* -
+Instantiates a ProfilerSubprovider instance -# Class: SolCompilerArtifactAdapter +**Parameters:** +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`artifactAdapter` | `AbstractArtifactAdapter` | - | Adapter for used artifacts format (0x, truffle, giveth, etc.) | +`defaultFromAddress` | string | - | default from address to use when sending transactions | +`isVerbose` | boolean | true | If true, we will log any unknown transactions. Otherwise we will ignore them | -## Constructors +**Returns:** *[ProfilerSubprovider](#class-profilersubprovider)* +## Methods +### emitPayloadAsync -\+ **new SolCompilerArtifactAdapter**(`artifactsPath?`: undefined | string, `sourcesPath?`: undefined | string): *[SolCompilerArtifactAdapter](#class-solcompilerartifactadapter)* +▸ **emitPayloadAsync**(`payload`: `Partial`): *`Promise`* -*Defined in [sol-tracing-utils/src/artifact_adapters/sol_compiler_artifact_adapter.ts:18](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/sol-tracing-utils/src/artifact_adapters/sol_compiler_artifact_adapter.ts#L18)* -Instantiates a SolCompilerArtifactAdapter + +Defined in subproviders/lib/src/subproviders/subprovider.d.ts:25 + +Emits a JSON RPC payload that will then be handled by the ProviderEngine instance +this subprovider is a part of. The payload will cascade down the subprovider middleware +stack until finding the responsible entity for handling the request. **Parameters:** Name | Type | Description | ------ | ------ | ------ | -`artifactsPath?` | undefined \| string | Path to your artifacts directory | -`sourcesPath?` | undefined \| string | Path to your contract sources directory | +`payload` | `Partial` | JSON RPC payload | -**Returns:** *[SolCompilerArtifactAdapter](#class-solcompilerartifactadapter)* +**Returns:** *`Promise`* -## Methods +JSON RPC response payload -### collectContractsDataAsync +___ -▸ **collectContractsDataAsync**(): *`Promise`* +### handleRequest -*Overrides [AbstractArtifactAdapter](_sol_tracing_utils_src_artifact_adapters_abstract_artifact_adapter_.abstractartifactadapter.md).[collectContractsDataAsync](#abstract-collectcontractsdataasync)* +▸ **handleRequest**(`payload`: `JSONRPCRequestPayload`, `next`: [NextCallback](#nextcallback), `_end`: [ErrorCallback](#errorcallback)): *`Promise`* -*Defined in [sol-tracing-utils/src/artifact_adapters/sol_compiler_artifact_adapter.ts:44](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/sol-tracing-utils/src/artifact_adapters/sol_compiler_artifact_adapter.ts#L44)* -**Returns:** *`Promise`* -
+*Overrides void* -# Class: TruffleArtifactAdapter +Defined in sol-tracing-utils/lib/src/trace_collection_subprovider.d.ts:42 +This method conforms to the web3-provider-engine interface. +It is called internally by the ProviderEngine when it is this subproviders +turn to handle a JSON RPC request. -## Constructors +**Parameters:** +Name | Type | Description | +------ | ------ | ------ | +`payload` | `JSONRPCRequestPayload` | JSON RPC payload | +`next` | [NextCallback](#nextcallback) | Callback to call if this subprovider decides not to handle the request | +`_end` | [ErrorCallback](#errorcallback) | Callback to call if subprovider handled the request and wants to pass back the request. | + +**Returns:** *`Promise`* +___ -\+ **new TruffleArtifactAdapter**(`projectRoot`: string, `solcVersion`: string): *[TruffleArtifactAdapter](#class-truffleartifactadapter)* +### setEngine + +▸ **setEngine**(`engine`: `Web3ProviderEngine`): *void* -*Defined in [sol-tracing-utils/src/artifact_adapters/truffle_artifact_adapter.ts:29](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/sol-tracing-utils/src/artifact_adapters/truffle_artifact_adapter.ts#L29)* -Instantiates a TruffleArtifactAdapter + +*Overrides void* + +Defined in sol-tracing-utils/lib/src/trace_collection_subprovider.d.ts:49 + +Set's the subprovider's engine to the ProviderEngine it is added to. +This is only called within the ProviderEngine source code, do not call +directly. **Parameters:** Name | Type | Description | ------ | ------ | ------ | -`projectRoot` | string | Path to the truffle project's root directory | -`solcVersion` | string | Solidity version with which to compile all the contracts | - -**Returns:** *[TruffleArtifactAdapter](#class-truffleartifactadapter)* +`engine` | `Web3ProviderEngine` | The ProviderEngine this subprovider is added to | -## Methods +**Returns:** *void* -### collectContractsDataAsync +___ -▸ **collectContractsDataAsync**(): *`Promise`* +### start -*Overrides [AbstractArtifactAdapter](_sol_tracing_utils_src_artifact_adapters_abstract_artifact_adapter_.abstractartifactadapter.md).[collectContractsDataAsync](#abstract-collectcontractsdataasync)* +▸ **start**(): *void* -*Defined in [sol-tracing-utils/src/artifact_adapters/truffle_artifact_adapter.ts:40](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/sol-tracing-utils/src/artifact_adapters/truffle_artifact_adapter.ts#L40)* -**Returns:** *`Promise`* -
+Defined in sol-tracing-utils/lib/src/trace_collection_subprovider.d.ts:29 +Starts trace collection +**Returns:** *void* +___ +### stop +▸ **stop**(): *void* +Defined in sol-tracing-utils/lib/src/trace_collection_subprovider.d.ts:33 +Stops trace collection +**Returns:** *void* +___ +### writeProfilerOutputAsync +▸ **writeProfilerOutputAsync**(): *`Promise`* +*Defined in [sol-profiler/src/profiler_subprovider.ts:104](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/sol-profiler/src/profiler_subprovider.ts#L104)* +Write the test profiler results to a file in Istanbul format. +**Returns:** *`Promise`* +
+# Class: AbstractArtifactAdapter -## Type aliases +## Methods -### Callback +### `Abstract` collectContractsDataAsync -Ƭ **Callback**: *function* +▸ **collectContractsDataAsync**(): *`Promise`* -*Defined in [subproviders/src/types.ts:131](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/types.ts#L131)* +*Defined in [sol-tracing-utils/src/artifact_adapters/abstract_artifact_adapter.ts:4](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/sol-tracing-utils/src/artifact_adapters/abstract_artifact_adapter.ts#L4)* -#### Type declaration: +**Returns:** *`Promise`* -▸ (): *void* +
-___ +# Class: SolCompilerArtifactAdapter +## Constructors -### ErrorCallback -Ƭ **ErrorCallback**: *function* -*Defined in [subproviders/src/types.ts:130](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/types.ts#L130)* +\+ **new SolCompilerArtifactAdapter**(`artifactsPath?`: undefined | string, `sourcesPath?`: undefined | string): *[SolCompilerArtifactAdapter](#class-solcompilerartifactadapter)* -#### Type declaration: +*Defined in [sol-tracing-utils/src/artifact_adapters/sol_compiler_artifact_adapter.ts:18](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/sol-tracing-utils/src/artifact_adapters/sol_compiler_artifact_adapter.ts#L18)* -▸ (`err`: `Error` | null, `data?`: any): *void* +Instantiates a SolCompilerArtifactAdapter **Parameters:** -Name | Type | ------- | ------ | -`err` | `Error` \| null | -`data?` | any | +Name | Type | Description | +------ | ------ | ------ | +`artifactsPath?` | undefined \| string | Path to your artifacts directory | +`sourcesPath?` | undefined \| string | Path to your contract sources directory | -___ +**Returns:** *[SolCompilerArtifactAdapter](#class-solcompilerartifactadapter)* +## Methods +### collectContractsDataAsync -### NextCallback +▸ **collectContractsDataAsync**(): *`Promise`* -Ƭ **NextCallback**: *function* +*Overrides [AbstractArtifactAdapter](_sol_tracing_utils_src_artifact_adapters_abstract_artifact_adapter_.abstractartifactadapter.md).[collectContractsDataAsync](#abstract-collectcontractsdataasync)* -*Defined in [subproviders/src/types.ts:133](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/types.ts#L133)* +*Defined in [sol-tracing-utils/src/artifact_adapters/sol_compiler_artifact_adapter.ts:44](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/sol-tracing-utils/src/artifact_adapters/sol_compiler_artifact_adapter.ts#L44)* -#### Type declaration: +**Returns:** *`Promise`* -▸ (`callback?`: [OnNextCompleted](#onnextcompleted)): *void* +
-**Parameters:** +# Class: TruffleArtifactAdapter -Name | Type | ------- | ------ | -`callback?` | [OnNextCompleted](#onnextcompleted) | -___ +## Constructors -### OnNextCompleted -Ƭ **OnNextCompleted**: *function* -*Defined in [subproviders/src/types.ts:132](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/types.ts#L132)* +\+ **new TruffleArtifactAdapter**(`projectRoot`: string, `solcVersion`: string): *[TruffleArtifactAdapter](#class-truffleartifactadapter)* -#### Type declaration: +*Defined in [sol-tracing-utils/src/artifact_adapters/truffle_artifact_adapter.ts:29](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/sol-tracing-utils/src/artifact_adapters/truffle_artifact_adapter.ts#L29)* -▸ (`err`: `Error` | null, `result`: any, `cb`: [Callback](#callback)): *void* +Instantiates a TruffleArtifactAdapter **Parameters:** -Name | Type | ------- | ------ | -`err` | `Error` \| null | -`result` | any | -`cb` | [Callback](#callback) | +Name | Type | Description | +------ | ------ | ------ | +`projectRoot` | string | Path to the truffle project's root directory | +`solcVersion` | string | Solidity version with which to compile all the contracts | + +**Returns:** *[TruffleArtifactAdapter](#class-truffleartifactadapter)* + +## Methods + +### collectContractsDataAsync + +▸ **collectContractsDataAsync**(): *`Promise`* + +*Overrides [AbstractArtifactAdapter](_sol_tracing_utils_src_artifact_adapters_abstract_artifact_adapter_.abstractartifactadapter.md).[collectContractsDataAsync](#abstract-collectcontractsdataasync)* + +*Defined in [sol-tracing-utils/src/artifact_adapters/truffle_artifact_adapter.ts:40](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/sol-tracing-utils/src/artifact_adapters/truffle_artifact_adapter.ts#L40)* + +**Returns:** *`Promise`*
@@ -218,6 +266,22 @@ Name | Type | + + + + + + + + + + + + + + + + @@ -244,7 +308,7 @@ Name | Type | • **id**: *number* -*Defined in [ethereum-types/src/index.ts:330](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L330)* +*Defined in [ethereum-types/src/index.ts:330](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L330)* ___ @@ -252,7 +316,7 @@ ___ • **jsonrpc**: *string* -*Defined in [ethereum-types/src/index.ts:331](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L331)* +*Defined in [ethereum-types/src/index.ts:331](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L331)* ___ @@ -260,7 +324,7 @@ ___ • **method**: *string* -*Defined in [ethereum-types/src/index.ts:329](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L329)* +*Defined in [ethereum-types/src/index.ts:329](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L329)* ___ @@ -268,7 +332,7 @@ ___ • **params**: *any[]* -*Defined in [ethereum-types/src/index.ts:328](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L328)* +*Defined in [ethereum-types/src/index.ts:328](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L328)*
@@ -281,7 +345,7 @@ ___ • **code**: *number* -*Defined in [ethereum-types/src/index.ts:336](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L336)* +*Defined in [ethereum-types/src/index.ts:336](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L336)* ___ @@ -289,7 +353,7 @@ ___ • **message**: *string* -*Defined in [ethereum-types/src/index.ts:335](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L335)* +*Defined in [ethereum-types/src/index.ts:335](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L335)*
@@ -302,7 +366,7 @@ ___ • **error**? : *[JSONRPCResponseError](#class-jsonrpcresponseerror)* -*Defined in [ethereum-types/src/index.ts:343](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L343)* +*Defined in [ethereum-types/src/index.ts:343](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L343)* ___ @@ -310,7 +374,7 @@ ___ • **id**: *number* -*Defined in [ethereum-types/src/index.ts:341](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L341)* +*Defined in [ethereum-types/src/index.ts:341](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L341)* ___ @@ -318,7 +382,7 @@ ___ • **jsonrpc**: *string* -*Defined in [ethereum-types/src/index.ts:342](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L342)* +*Defined in [ethereum-types/src/index.ts:342](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L342)* ___ @@ -326,7 +390,7 @@ ___ • **result**: *any* -*Defined in [ethereum-types/src/index.ts:340](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L340)* +*Defined in [ethereum-types/src/index.ts:340](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L340)*
@@ -362,160 +426,108 @@ ___ -# Class: ProfilerSubprovider -This class implements the [web3-provider-engine](https://github.com/MetaMask/provider-engine) subprovider interface. -ProfilerSubprovider is used to profile Solidity code while running tests. -## Constructors -\+ **new ProfilerSubprovider**(`artifactAdapter`: `AbstractArtifactAdapter`, `defaultFromAddress`: string, `isVerbose`: boolean): *[ProfilerSubprovider](#class-profilersubprovider)* -*Overrides void* -*Defined in [sol-profiler/src/profiler_subprovider.ts:30](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/sol-profiler/src/profiler_subprovider.ts#L30)* -Instantiates a ProfilerSubprovider instance -**Parameters:** -Name | Type | Default | Description | ------- | ------ | ------ | ------ | -`artifactAdapter` | `AbstractArtifactAdapter` | - | Adapter for used artifacts format (0x, truffle, giveth, etc.) | -`defaultFromAddress` | string | - | default from address to use when sending transactions | -`isVerbose` | boolean | true | If true, we will log any unknown transactions. Otherwise we will ignore them | -**Returns:** *[ProfilerSubprovider](#class-profilersubprovider)* -## Methods -### emitPayloadAsync -▸ **emitPayloadAsync**(`payload`: `Partial`): *`Promise`* -Defined in subproviders/lib/src/subproviders/subprovider.d.ts:25 -Emits a JSON RPC payload that will then be handled by the ProviderEngine instance -this subprovider is a part of. The payload will cascade down the subprovider middleware -stack until finding the responsible entity for handling the request. -**Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`payload` | `Partial` | JSON RPC payload | -**Returns:** *`Promise`* -JSON RPC response payload -___ -### handleRequest -▸ **handleRequest**(`payload`: `JSONRPCRequestPayload`, `next`: [NextCallback](#nextcallback), `_end`: [ErrorCallback](#errorcallback)): *`Promise`* + -*Overrides void* -Defined in sol-tracing-utils/lib/src/trace_collection_subprovider.d.ts:42 -This method conforms to the web3-provider-engine interface. -It is called internally by the ProviderEngine when it is this subproviders -turn to handle a JSON RPC request. + -**Parameters:** + -Name | Type | Description | ------- | ------ | ------ | -`payload` | `JSONRPCRequestPayload` | JSON RPC payload | -`next` | [NextCallback](#nextcallback) | Callback to call if this subprovider decides not to handle the request | -`_end` | [ErrorCallback](#errorcallback) | Callback to call if subprovider handled the request and wants to pass back the request. | -**Returns:** *`Promise`* -___ -### setEngine -▸ **setEngine**(`engine`: `Web3ProviderEngine`): *void* + -*Overrides void* -Defined in sol-tracing-utils/lib/src/trace_collection_subprovider.d.ts:49 -Set's the subprovider's engine to the ProviderEngine it is added to. -This is only called within the ProviderEngine source code, do not call -directly. -**Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`engine` | `Web3ProviderEngine` | The ProviderEngine this subprovider is added to | -**Returns:** *void* -___ -### start -▸ **start**(): *void* -Defined in sol-tracing-utils/lib/src/trace_collection_subprovider.d.ts:29 -Starts trace collection -**Returns:** *void* -___ +# Interface: JSONRPCRequestPayloadWithMethod -### stop -▸ **stop**(): *void* +## Properties +### id +• **id**: *number* -Defined in sol-tracing-utils/lib/src/trace_collection_subprovider.d.ts:33 -Stops trace collection -**Returns:** *void* +Defined in ethereum-types/lib/index.d.ts:267 ___ -### writeProfilerOutputAsync +### jsonrpc -▸ **writeProfilerOutputAsync**(): *`Promise`* +• **jsonrpc**: *string* -*Defined in [sol-profiler/src/profiler_subprovider.ts:104](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/sol-profiler/src/profiler_subprovider.ts#L104)* -Write the test profiler results to a file in Istanbul format. -**Returns:** *`Promise`* +Defined in ethereum-types/lib/index.d.ts:268 -
+___ +### method +• **method**: *string* +*Overrides void* +*Defined in [subproviders/src/types.ts:136](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/types.ts#L136)* +___ +### params +• **params**: *any[]* +Defined in ethereum-types/lib/index.d.ts:265 +
@@ -530,15 +542,12 @@ Write the test profiler results to a file in Istanbul format. - - - @@ -546,7 +555,6 @@ Write the test profiler results to a file in Istanbul format. - @@ -554,6 +562,7 @@ Write the test profiler results to a file in Istanbul format. +## Type aliases @@ -562,50 +571,30 @@ Write the test profiler results to a file in Istanbul format. -# Interface: JSONRPCRequestPayloadWithMethod -## Properties -### id -• **id**: *number* -Defined in ethereum-types/lib/index.d.ts:267 -___ -### jsonrpc -• **jsonrpc**: *string* -Defined in ethereum-types/lib/index.d.ts:268 -___ -### method -• **method**: *string* -*Overrides void* -*Defined in [subproviders/src/types.ts:136](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/types.ts#L136)* -___ -### params -• **params**: *any[]* -Defined in ethereum-types/lib/index.d.ts:265 - -
@@ -618,24 +607,43 @@ Defined in ethereum-types/lib/index.d.ts:265 +## Functions +### `Const` profilerHandler +▸ **profilerHandler**(`contractData`: `ContractData`, `subtrace`: [Subtrace](#subtrace), `pcToSourceRange`: object, `fileIndex`: number): *`Coverage`* +*Defined in [sol-profiler/src/profiler_subprovider.ts:118](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/sol-profiler/src/profiler_subprovider.ts#L118)* +Computed partial coverage for a single file & subtrace for the purposes of +gas profiling. +**Parameters:** +Name | Type | Description | +------ | ------ | ------ | +`contractData` | `ContractData` | Contract metadata (source, srcMap, bytecode) | +`subtrace` | [Subtrace](#subtrace) | A subset of a transcation/call trace that was executed within that contract | +`pcToSourceRange` | object | A mapping from program counters to source ranges | +`fileIndex` | number | Index of a file to compute coverage for | +**Returns:** *`Coverage`* +Partial istanbul coverage for that file & subtrace +
+
+
+
@@ -655,84 +663,76 @@ Defined in ethereum-types/lib/index.d.ts:265 ## Type aliases +### Callback +Ƭ **Callback**: *function* +*Defined in [subproviders/src/types.ts:131](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/types.ts#L131)* +#### Type declaration: +▸ (): *void* +___ +### ErrorCallback +Ƭ **ErrorCallback**: *function* +*Defined in [subproviders/src/types.ts:130](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/types.ts#L130)* +#### Type declaration: +▸ (`err`: `Error` | null, `data?`: any): *void* +**Parameters:** +Name | Type | +------ | ------ | +`err` | `Error` \| null | +`data?` | any | +___ +### NextCallback +Ƭ **NextCallback**: *function* +*Defined in [subproviders/src/types.ts:133](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/types.ts#L133)* +#### Type declaration: +▸ (`callback?`: [OnNextCompleted](#onnextcompleted)): *void* +**Parameters:** +Name | Type | +------ | ------ | +`callback?` | [OnNextCompleted](#onnextcompleted) | +___ +### OnNextCompleted +Ƭ **OnNextCompleted**: *function* +*Defined in [subproviders/src/types.ts:132](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/types.ts#L132)* +#### Type declaration: - - - - - - - - - - - - - -## Functions - -### `Const` profilerHandler - -▸ **profilerHandler**(`contractData`: `ContractData`, `subtrace`: [Subtrace](#subtrace), `pcToSourceRange`: object, `fileIndex`: number): *`Coverage`* - -*Defined in [sol-profiler/src/profiler_subprovider.ts:118](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/sol-profiler/src/profiler_subprovider.ts#L118)* - -Computed partial coverage for a single file & subtrace for the purposes of -gas profiling. +▸ (`err`: `Error` | null, `result`: any, `cb`: [Callback](#callback)): *void* **Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`contractData` | `ContractData` | Contract metadata (source, srcMap, bytecode) | -`subtrace` | [Subtrace](#subtrace) | A subset of a transcation/call trace that was executed within that contract | -`pcToSourceRange` | object | A mapping from program counters to source ranges | -`fileIndex` | number | Index of a file to compute coverage for | - -**Returns:** *`Coverage`* - -Partial istanbul coverage for that file & subtrace +Name | Type | +------ | ------ | +`err` | `Error` \| null | +`result` | any | +`cb` | [Callback](#callback) |
- - -
- - - -
- - - -
- diff --git a/packages/sol-trace/docs/reference.mdx b/packages/sol-trace/docs/reference.mdx index 0339cb722e..b26e96a745 100644 --- a/packages/sol-trace/docs/reference.mdx +++ b/packages/sol-trace/docs/reference.mdx @@ -1,185 +1,237 @@ +# Class: RevertTraceSubprovider +This class implements the [web3-provider-engine](https://github.com/MetaMask/provider-engine) subprovider interface. +It is used to report call stack traces whenever a revert occurs. -# Class: AbstractArtifactAdapter +## Constructors -## Methods -### `Abstract` collectContractsDataAsync -▸ **collectContractsDataAsync**(): *`Promise`* +\+ **new RevertTraceSubprovider**(`artifactAdapter`: `AbstractArtifactAdapter`, `defaultFromAddress`: string, `isVerbose`: boolean): *[RevertTraceSubprovider](#class-reverttracesubprovider)* -*Defined in [sol-tracing-utils/src/artifact_adapters/abstract_artifact_adapter.ts:4](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/sol-tracing-utils/src/artifact_adapters/abstract_artifact_adapter.ts#L4)* +*Overrides void* -**Returns:** *`Promise`* +*Defined in [sol-trace/src/revert_trace_subprovider.ts:27](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/sol-trace/src/revert_trace_subprovider.ts#L27)* -
+Instantiates a RevertTraceSubprovider instance -# Class: SolCompilerArtifactAdapter +**Parameters:** +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`artifactAdapter` | `AbstractArtifactAdapter` | - | Adapter for used artifacts format (0x, truffle, giveth, etc.) | +`defaultFromAddress` | string | - | default from address to use when sending transactions | +`isVerbose` | boolean | true | If true, we will log any unknown transactions. Otherwise we will ignore them | -## Constructors +**Returns:** *[RevertTraceSubprovider](#class-reverttracesubprovider)* + +## Methods +### emitPayloadAsync +▸ **emitPayloadAsync**(`payload`: `Partial`): *`Promise`* -\+ **new SolCompilerArtifactAdapter**(`artifactsPath?`: undefined | string, `sourcesPath?`: undefined | string): *[SolCompilerArtifactAdapter](#class-solcompilerartifactadapter)* -*Defined in [sol-tracing-utils/src/artifact_adapters/sol_compiler_artifact_adapter.ts:18](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/sol-tracing-utils/src/artifact_adapters/sol_compiler_artifact_adapter.ts#L18)* -Instantiates a SolCompilerArtifactAdapter +Defined in subproviders/lib/src/subproviders/subprovider.d.ts:25 + +Emits a JSON RPC payload that will then be handled by the ProviderEngine instance +this subprovider is a part of. The payload will cascade down the subprovider middleware +stack until finding the responsible entity for handling the request. **Parameters:** Name | Type | Description | ------ | ------ | ------ | -`artifactsPath?` | undefined \| string | Path to your artifacts directory | -`sourcesPath?` | undefined \| string | Path to your contract sources directory | +`payload` | `Partial` | JSON RPC payload | -**Returns:** *[SolCompilerArtifactAdapter](#class-solcompilerartifactadapter)* +**Returns:** *`Promise`* -## Methods +JSON RPC response payload -### collectContractsDataAsync +___ -▸ **collectContractsDataAsync**(): *`Promise`* +### handleRequest -*Overrides [AbstractArtifactAdapter](_sol_tracing_utils_src_artifact_adapters_abstract_artifact_adapter_.abstractartifactadapter.md).[collectContractsDataAsync](#abstract-collectcontractsdataasync)* +▸ **handleRequest**(`payload`: `JSONRPCRequestPayload`, `next`: [NextCallback](#nextcallback), `_end`: [ErrorCallback](#errorcallback)): *`Promise`* -*Defined in [sol-tracing-utils/src/artifact_adapters/sol_compiler_artifact_adapter.ts:44](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/sol-tracing-utils/src/artifact_adapters/sol_compiler_artifact_adapter.ts#L44)* -**Returns:** *`Promise`* -
+*Overrides void* -# Class: TruffleArtifactAdapter +Defined in sol-tracing-utils/lib/src/trace_collection_subprovider.d.ts:42 +This method conforms to the web3-provider-engine interface. +It is called internally by the ProviderEngine when it is this subproviders +turn to handle a JSON RPC request. -## Constructors +**Parameters:** +Name | Type | Description | +------ | ------ | ------ | +`payload` | `JSONRPCRequestPayload` | JSON RPC payload | +`next` | [NextCallback](#nextcallback) | Callback to call if this subprovider decides not to handle the request | +`_end` | [ErrorCallback](#errorcallback) | Callback to call if subprovider handled the request and wants to pass back the request. | +**Returns:** *`Promise`* -\+ **new TruffleArtifactAdapter**(`projectRoot`: string, `solcVersion`: string): *[TruffleArtifactAdapter](#class-truffleartifactadapter)* +___ + +### setEngine + +▸ **setEngine**(`engine`: `Web3ProviderEngine`): *void* -*Defined in [sol-tracing-utils/src/artifact_adapters/truffle_artifact_adapter.ts:29](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/sol-tracing-utils/src/artifact_adapters/truffle_artifact_adapter.ts#L29)* -Instantiates a TruffleArtifactAdapter + +*Overrides void* + +Defined in sol-tracing-utils/lib/src/trace_collection_subprovider.d.ts:49 + +Set's the subprovider's engine to the ProviderEngine it is added to. +This is only called within the ProviderEngine source code, do not call +directly. **Parameters:** Name | Type | Description | ------ | ------ | ------ | -`projectRoot` | string | Path to the truffle project's root directory | -`solcVersion` | string | Solidity version with which to compile all the contracts | +`engine` | `Web3ProviderEngine` | The ProviderEngine this subprovider is added to | -**Returns:** *[TruffleArtifactAdapter](#class-truffleartifactadapter)* +**Returns:** *void* -## Methods +___ -### collectContractsDataAsync +### start -▸ **collectContractsDataAsync**(): *`Promise`* +▸ **start**(): *void* -*Overrides [AbstractArtifactAdapter](_sol_tracing_utils_src_artifact_adapters_abstract_artifact_adapter_.abstractartifactadapter.md).[collectContractsDataAsync](#abstract-collectcontractsdataasync)* -*Defined in [sol-tracing-utils/src/artifact_adapters/truffle_artifact_adapter.ts:40](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/sol-tracing-utils/src/artifact_adapters/truffle_artifact_adapter.ts#L40)* -**Returns:** *`Promise`* +Defined in sol-tracing-utils/lib/src/trace_collection_subprovider.d.ts:29 + +Starts trace collection + +**Returns:** *void* + +___ + +### stop + +▸ **stop**(): *void* + + + +Defined in sol-tracing-utils/lib/src/trace_collection_subprovider.d.ts:33 + +Stops trace collection + +**Returns:** *void*
+# Class: AbstractArtifactAdapter +## Methods +### `Abstract` collectContractsDataAsync +▸ **collectContractsDataAsync**(): *`Promise`* +*Defined in [sol-tracing-utils/src/artifact_adapters/abstract_artifact_adapter.ts:4](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/sol-tracing-utils/src/artifact_adapters/abstract_artifact_adapter.ts#L4)* +**Returns:** *`Promise`* +
+# Class: SolCompilerArtifactAdapter +## Constructors +\+ **new SolCompilerArtifactAdapter**(`artifactsPath?`: undefined | string, `sourcesPath?`: undefined | string): *[SolCompilerArtifactAdapter](#class-solcompilerartifactadapter)* +*Defined in [sol-tracing-utils/src/artifact_adapters/sol_compiler_artifact_adapter.ts:18](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/sol-tracing-utils/src/artifact_adapters/sol_compiler_artifact_adapter.ts#L18)* +Instantiates a SolCompilerArtifactAdapter +**Parameters:** +Name | Type | Description | +------ | ------ | ------ | +`artifactsPath?` | undefined \| string | Path to your artifacts directory | +`sourcesPath?` | undefined \| string | Path to your contract sources directory | +**Returns:** *[SolCompilerArtifactAdapter](#class-solcompilerartifactadapter)* -## Type aliases +## Methods -### Callback +### collectContractsDataAsync -Ƭ **Callback**: *function* +▸ **collectContractsDataAsync**(): *`Promise`* -*Defined in [subproviders/src/types.ts:131](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/types.ts#L131)* +*Overrides [AbstractArtifactAdapter](_sol_tracing_utils_src_artifact_adapters_abstract_artifact_adapter_.abstractartifactadapter.md).[collectContractsDataAsync](#abstract-collectcontractsdataasync)* -#### Type declaration: +*Defined in [sol-tracing-utils/src/artifact_adapters/sol_compiler_artifact_adapter.ts:44](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/sol-tracing-utils/src/artifact_adapters/sol_compiler_artifact_adapter.ts#L44)* -▸ (): *void* +**Returns:** *`Promise`* -___ +
+# Class: TruffleArtifactAdapter -### ErrorCallback +## Constructors -Ƭ **ErrorCallback**: *function* -*Defined in [subproviders/src/types.ts:130](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/types.ts#L130)* -#### Type declaration: +\+ **new TruffleArtifactAdapter**(`projectRoot`: string, `solcVersion`: string): *[TruffleArtifactAdapter](#class-truffleartifactadapter)* -▸ (`err`: `Error` | null, `data?`: any): *void* +*Defined in [sol-tracing-utils/src/artifact_adapters/truffle_artifact_adapter.ts:29](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/sol-tracing-utils/src/artifact_adapters/truffle_artifact_adapter.ts#L29)* + +Instantiates a TruffleArtifactAdapter **Parameters:** -Name | Type | ------- | ------ | -`err` | `Error` \| null | -`data?` | any | +Name | Type | Description | +------ | ------ | ------ | +`projectRoot` | string | Path to the truffle project's root directory | +`solcVersion` | string | Solidity version with which to compile all the contracts | -___ +**Returns:** *[TruffleArtifactAdapter](#class-truffleartifactadapter)* +## Methods +### collectContractsDataAsync + +▸ **collectContractsDataAsync**(): *`Promise`* + +*Overrides [AbstractArtifactAdapter](_sol_tracing_utils_src_artifact_adapters_abstract_artifact_adapter_.abstractartifactadapter.md).[collectContractsDataAsync](#abstract-collectcontractsdataasync)* + +*Defined in [sol-tracing-utils/src/artifact_adapters/truffle_artifact_adapter.ts:40](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/sol-tracing-utils/src/artifact_adapters/truffle_artifact_adapter.ts#L40)* + +**Returns:** *`Promise`* + +
-### NextCallback -Ƭ **NextCallback**: *function* -*Defined in [subproviders/src/types.ts:133](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/types.ts#L133)* -#### Type declaration: -▸ (`callback?`: [OnNextCompleted](#onnextcompleted)): *void* -**Parameters:** -Name | Type | ------- | ------ | -`callback?` | [OnNextCompleted](#onnextcompleted) | -___ -### OnNextCompleted -Ƭ **OnNextCompleted**: *function* -*Defined in [subproviders/src/types.ts:132](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/types.ts#L132)* -#### Type declaration: -▸ (`err`: `Error` | null, `result`: any, `cb`: [Callback](#callback)): *void* -**Parameters:** -Name | Type | ------- | ------ | -`err` | `Error` \| null | -`result` | any | -`cb` | [Callback](#callback) | -
@@ -244,7 +296,7 @@ Name | Type | • **id**: *number* -*Defined in [ethereum-types/src/index.ts:330](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L330)* +*Defined in [ethereum-types/src/index.ts:330](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L330)* ___ @@ -252,7 +304,7 @@ ___ • **jsonrpc**: *string* -*Defined in [ethereum-types/src/index.ts:331](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L331)* +*Defined in [ethereum-types/src/index.ts:331](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L331)* ___ @@ -260,7 +312,7 @@ ___ • **method**: *string* -*Defined in [ethereum-types/src/index.ts:329](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L329)* +*Defined in [ethereum-types/src/index.ts:329](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L329)* ___ @@ -268,7 +320,7 @@ ___ • **params**: *any[]* -*Defined in [ethereum-types/src/index.ts:328](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L328)* +*Defined in [ethereum-types/src/index.ts:328](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L328)*
@@ -281,7 +333,7 @@ ___ • **code**: *number* -*Defined in [ethereum-types/src/index.ts:336](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L336)* +*Defined in [ethereum-types/src/index.ts:336](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L336)* ___ @@ -289,7 +341,7 @@ ___ • **message**: *string* -*Defined in [ethereum-types/src/index.ts:335](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L335)* +*Defined in [ethereum-types/src/index.ts:335](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L335)*
@@ -302,7 +354,7 @@ ___ • **error**? : *[JSONRPCResponseError](#class-jsonrpcresponseerror)* -*Defined in [ethereum-types/src/index.ts:343](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L343)* +*Defined in [ethereum-types/src/index.ts:343](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L343)* ___ @@ -310,7 +362,7 @@ ___ • **id**: *number* -*Defined in [ethereum-types/src/index.ts:341](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L341)* +*Defined in [ethereum-types/src/index.ts:341](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L341)* ___ @@ -318,7 +370,7 @@ ___ • **jsonrpc**: *string* -*Defined in [ethereum-types/src/index.ts:342](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L342)* +*Defined in [ethereum-types/src/index.ts:342](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L342)* ___ @@ -326,7 +378,7 @@ ___ • **result**: *any* -*Defined in [ethereum-types/src/index.ts:340](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L340)* +*Defined in [ethereum-types/src/index.ts:340](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L340)*
@@ -361,172 +413,118 @@ ___ - -# Class: RevertTraceSubprovider - -This class implements the [web3-provider-engine](https://github.com/MetaMask/provider-engine) subprovider interface. -It is used to report call stack traces whenever a revert occurs. -## Constructors -\+ **new RevertTraceSubprovider**(`artifactAdapter`: `AbstractArtifactAdapter`, `defaultFromAddress`: string, `isVerbose`: boolean): *[RevertTraceSubprovider](#class-reverttracesubprovider)* -*Overrides void* -*Defined in [sol-trace/src/revert_trace_subprovider.ts:27](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/sol-trace/src/revert_trace_subprovider.ts#L27)* -Instantiates a RevertTraceSubprovider instance - -**Parameters:** - -Name | Type | Default | Description | ------- | ------ | ------ | ------ | -`artifactAdapter` | `AbstractArtifactAdapter` | - | Adapter for used artifacts format (0x, truffle, giveth, etc.) | -`defaultFromAddress` | string | - | default from address to use when sending transactions | -`isVerbose` | boolean | true | If true, we will log any unknown transactions. Otherwise we will ignore them | - -**Returns:** *[RevertTraceSubprovider](#class-reverttracesubprovider)* -## Methods -### emitPayloadAsync -▸ **emitPayloadAsync**(`payload`: `Partial`): *`Promise`* -Defined in subproviders/lib/src/subproviders/subprovider.d.ts:25 -Emits a JSON RPC payload that will then be handled by the ProviderEngine instance -this subprovider is a part of. The payload will cascade down the subprovider middleware -stack until finding the responsible entity for handling the request. -**Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`payload` | `Partial` | JSON RPC payload | -**Returns:** *`Promise`* -JSON RPC response payload -___ -### handleRequest -▸ **handleRequest**(`payload`: `JSONRPCRequestPayload`, `next`: [NextCallback](#nextcallback), `_end`: [ErrorCallback](#errorcallback)): *`Promise`* -*Overrides void* -Defined in sol-tracing-utils/lib/src/trace_collection_subprovider.d.ts:42 -This method conforms to the web3-provider-engine interface. -It is called internally by the ProviderEngine when it is this subproviders -turn to handle a JSON RPC request. + -**Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`payload` | `JSONRPCRequestPayload` | JSON RPC payload | -`next` | [NextCallback](#nextcallback) | Callback to call if this subprovider decides not to handle the request | -`_end` | [ErrorCallback](#errorcallback) | Callback to call if subprovider handled the request and wants to pass back the request. | -**Returns:** *`Promise`* -___ -### setEngine + -▸ **setEngine**(`engine`: `Web3ProviderEngine`): *void* + -*Overrides void* -Defined in sol-tracing-utils/lib/src/trace_collection_subprovider.d.ts:49 -Set's the subprovider's engine to the ProviderEngine it is added to. -This is only called within the ProviderEngine source code, do not call -directly. -**Parameters:** -Name | Type | Description | ------- | ------ | ------ | -`engine` | `Web3ProviderEngine` | The ProviderEngine this subprovider is added to | + -**Returns:** *void* -___ -### start -▸ **start**(): *void* -Defined in sol-tracing-utils/lib/src/trace_collection_subprovider.d.ts:29 -Starts trace collection -**Returns:** *void* -___ -### stop -▸ **stop**(): *void* -Defined in sol-tracing-utils/lib/src/trace_collection_subprovider.d.ts:33 +# Interface: JSONRPCRequestPayloadWithMethod -Stops trace collection -**Returns:** *void* +## Properties -
+### id +• **id**: *number* +Defined in ethereum-types/lib/index.d.ts:267 +___ +### jsonrpc +• **jsonrpc**: *string* +Defined in ethereum-types/lib/index.d.ts:268 +___ +### method +• **method**: *string* +*Overrides void* +*Defined in [subproviders/src/types.ts:136](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/types.ts#L136)* +___ +### params +• **params**: *any[]* +Defined in ethereum-types/lib/index.d.ts:265 +
- - - @@ -534,7 +532,6 @@ Stops trace collection - @@ -550,50 +547,32 @@ Stops trace collection -# Interface: JSONRPCRequestPayloadWithMethod -## Properties -### id +## Type aliases -• **id**: *number* -Defined in ethereum-types/lib/index.d.ts:267 -___ -### jsonrpc -• **jsonrpc**: *string* -Defined in ethereum-types/lib/index.d.ts:268 -___ -### method -• **method**: *string* -*Overrides void* -*Defined in [subproviders/src/types.ts:136](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/types.ts#L136)* -___ -### params -• **params**: *any[]* -Defined in ethereum-types/lib/index.d.ts:265 -
@@ -615,15 +594,19 @@ Defined in ethereum-types/lib/index.d.ts:265 +
+
+
+
@@ -643,59 +626,76 @@ Defined in ethereum-types/lib/index.d.ts:265 ## Type aliases +### Callback +Ƭ **Callback**: *function* +*Defined in [subproviders/src/types.ts:131](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/types.ts#L131)* +#### Type declaration: +▸ (): *void* +___ +### ErrorCallback +Ƭ **ErrorCallback**: *function* +*Defined in [subproviders/src/types.ts:130](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/types.ts#L130)* +#### Type declaration: +▸ (`err`: `Error` | null, `data?`: any): *void* +**Parameters:** +Name | Type | +------ | ------ | +`err` | `Error` \| null | +`data?` | any | +___ +### NextCallback +Ƭ **NextCallback**: *function* +*Defined in [subproviders/src/types.ts:133](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/types.ts#L133)* +#### Type declaration: +▸ (`callback?`: [OnNextCompleted](#onnextcompleted)): *void* +**Parameters:** +Name | Type | +------ | ------ | +`callback?` | [OnNextCompleted](#onnextcompleted) | +___ +### OnNextCompleted +Ƭ **OnNextCompleted**: *function* +*Defined in [subproviders/src/types.ts:132](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/types.ts#L132)* +#### Type declaration: +▸ (`err`: `Error` | null, `result`: any, `cb`: [Callback](#callback)): *void* +**Parameters:** +Name | Type | +------ | ------ | +`err` | `Error` \| null | +`result` | any | +`cb` | [Callback](#callback) | - - - - - - - - - -
- - - -
- - - -
- - - -
+
diff --git a/packages/subproviders/docs/reference.mdx b/packages/subproviders/docs/reference.mdx index e549a76af6..694a9c3ddf 100644 --- a/packages/subproviders/docs/reference.mdx +++ b/packages/subproviders/docs/reference.mdx @@ -1,5 +1,3 @@ - - # Class: EmptyWalletSubprovider This class implements the [web3-provider-engine](https://github.com/MetaMask/provider-engine) subprovider interface. @@ -14,7 +12,7 @@ It intercepts the `eth_accounts` JSON RPC requests and never returns any address *Inherited from [Subprovider](#interface-subprovider).[emitPayloadAsync](#emitpayloadasync)* -*Defined in [subproviders/src/subproviders/subprovider.ts:55](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/subprovider.ts#L55)* +*Defined in [subproviders/src/subproviders/subprovider.ts:55](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/subprovider.ts#L55)* Emits a JSON RPC payload that will then be handled by the ProviderEngine instance this subprovider is a part of. The payload will cascade down the subprovider middleware @@ -38,7 +36,7 @@ ___ *Overrides [Subprovider](_subproviders_src_subproviders_subprovider_.subprovider.md).[handleRequest](#abstract-handlerequest)* -*Defined in [subproviders/src/subproviders/empty_wallet_subprovider.ts:21](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/empty_wallet_subprovider.ts#L21)* +*Defined in [subproviders/src/subproviders/empty_wallet_subprovider.ts:21](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/empty_wallet_subprovider.ts#L21)* This method conforms to the web3-provider-engine interface. It is called internally by the ProviderEngine when it is this subproviders @@ -62,7 +60,7 @@ ___ *Inherited from [Subprovider](#interface-subprovider).[setEngine](#setengine)* -*Defined in [subproviders/src/subproviders/subprovider.ts:68](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/subprovider.ts#L68)* +*Defined in [subproviders/src/subproviders/subprovider.ts:68](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/subprovider.ts#L68)* Set's the subprovider's engine to the ProviderEngine it is added to. This is only called within the ProviderEngine source code, do not call @@ -90,7 +88,7 @@ It intercepts the `eth_estimateGas` JSON RPC call and always returns a constant \+ **new FakeGasEstimateSubprovider**(`constantGasAmount`: number): *[FakeGasEstimateSubprovider](#class-fakegasestimatesubprovider)* -*Defined in [subproviders/src/subproviders/fake_gas_estimate_subprovider.ts:17](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/fake_gas_estimate_subprovider.ts#L17)* +*Defined in [subproviders/src/subproviders/fake_gas_estimate_subprovider.ts:17](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/fake_gas_estimate_subprovider.ts#L17)* Instantiates an instance of the FakeGasEstimateSubprovider @@ -110,7 +108,7 @@ Name | Type | Description | *Inherited from [Subprovider](#interface-subprovider).[emitPayloadAsync](#emitpayloadasync)* -*Defined in [subproviders/src/subproviders/subprovider.ts:55](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/subprovider.ts#L55)* +*Defined in [subproviders/src/subproviders/subprovider.ts:55](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/subprovider.ts#L55)* Emits a JSON RPC payload that will then be handled by the ProviderEngine instance this subprovider is a part of. The payload will cascade down the subprovider middleware @@ -134,7 +132,7 @@ ___ *Overrides [Subprovider](_subproviders_src_subproviders_subprovider_.subprovider.md).[handleRequest](#abstract-handlerequest)* -*Defined in [subproviders/src/subproviders/fake_gas_estimate_subprovider.ts:35](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/fake_gas_estimate_subprovider.ts#L35)* +*Defined in [subproviders/src/subproviders/fake_gas_estimate_subprovider.ts:35](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/fake_gas_estimate_subprovider.ts#L35)* This method conforms to the web3-provider-engine interface. It is called internally by the ProviderEngine when it is this subproviders @@ -158,7 +156,7 @@ ___ *Inherited from [Subprovider](#interface-subprovider).[setEngine](#setengine)* -*Defined in [subproviders/src/subproviders/subprovider.ts:68](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/subprovider.ts#L68)* +*Defined in [subproviders/src/subproviders/subprovider.ts:68](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/subprovider.ts#L68)* Set's the subprovider's engine to the ProviderEngine it is added to. This is only called within the ProviderEngine source code, do not call @@ -186,7 +184,7 @@ It intercepts all JSON RPC requests and relays them to an in-process ganache ins \+ **new GanacheSubprovider**(`opts`: `GanacheOpts`): *[GanacheSubprovider](#class-ganachesubprovider)* -*Defined in [subproviders/src/subproviders/ganache.ts:13](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/ganache.ts#L13)* +*Defined in [subproviders/src/subproviders/ganache.ts:13](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/ganache.ts#L13)* Instantiates a GanacheSubprovider @@ -206,7 +204,7 @@ Name | Type | Description | *Inherited from [Subprovider](#interface-subprovider).[emitPayloadAsync](#emitpayloadasync)* -*Defined in [subproviders/src/subproviders/subprovider.ts:55](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/subprovider.ts#L55)* +*Defined in [subproviders/src/subproviders/subprovider.ts:55](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/subprovider.ts#L55)* Emits a JSON RPC payload that will then be handled by the ProviderEngine instance this subprovider is a part of. The payload will cascade down the subprovider middleware @@ -230,7 +228,7 @@ ___ *Overrides [Subprovider](_subproviders_src_subproviders_subprovider_.subprovider.md).[handleRequest](#abstract-handlerequest)* -*Defined in [subproviders/src/subproviders/ganache.ts:31](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/ganache.ts#L31)* +*Defined in [subproviders/src/subproviders/ganache.ts:31](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/ganache.ts#L31)* This method conforms to the web3-provider-engine interface. It is called internally by the ProviderEngine when it is this subproviders @@ -254,7 +252,7 @@ ___ *Inherited from [Subprovider](#interface-subprovider).[setEngine](#setengine)* -*Defined in [subproviders/src/subproviders/subprovider.ts:68](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/subprovider.ts#L68)* +*Defined in [subproviders/src/subproviders/subprovider.ts:68](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/subprovider.ts#L68)* Set's the subprovider's engine to the ProviderEngine it is added to. This is only called within the ProviderEngine source code, do not call @@ -283,7 +281,7 @@ re-routes them to a Ledger device plugged into the users computer. \+ **new LedgerSubprovider**(`config`: [LedgerSubproviderConfigs](#interface-ledgersubproviderconfigs)): *[LedgerSubprovider](#class-ledgersubprovider)* -*Defined in [subproviders/src/subproviders/ledger.ts:41](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/ledger.ts#L41)* +*Defined in [subproviders/src/subproviders/ledger.ts:41](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/ledger.ts#L41)* Instantiates a LedgerSubprovider. Defaults to derivationPath set to `44'/60'/0'`. TestRPC/Ganache defaults to `m/44'/60'/0'/0`, so set this in the configs if desired. @@ -306,7 +304,7 @@ LedgerSubprovider instance *Inherited from [Subprovider](#interface-subprovider).[emitPayloadAsync](#emitpayloadasync)* -*Defined in [subproviders/src/subproviders/subprovider.ts:55](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/subprovider.ts#L55)* +*Defined in [subproviders/src/subproviders/subprovider.ts:55](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/subprovider.ts#L55)* Emits a JSON RPC payload that will then be handled by the ProviderEngine instance this subprovider is a part of. The payload will cascade down the subprovider middleware @@ -330,7 +328,7 @@ ___ *Overrides void* -*Defined in [subproviders/src/subproviders/ledger.ts:87](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/ledger.ts#L87)* +*Defined in [subproviders/src/subproviders/ledger.ts:87](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/ledger.ts#L87)* Retrieve a users Ledger accounts. The accounts are derived from the derivationPath, master public key and chain code. Because of this, you can request as many accounts @@ -354,7 +352,7 @@ ___ ▸ **getPath**(): *string* -*Defined in [subproviders/src/subproviders/ledger.ts:68](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/ledger.ts#L68)* +*Defined in [subproviders/src/subproviders/ledger.ts:68](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/ledger.ts#L68)* Retrieve the set derivation path @@ -372,7 +370,7 @@ ___ *Overrides [Subprovider](_subproviders_src_subproviders_subprovider_.subprovider.md).[handleRequest](#abstract-handlerequest)* -*Defined in [subproviders/src/subproviders/base_wallet_subprovider.ts:37](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/base_wallet_subprovider.ts#L37)* +*Defined in [subproviders/src/subproviders/base_wallet_subprovider.ts:37](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/base_wallet_subprovider.ts#L37)* This method conforms to the web3-provider-engine interface. It is called internally by the ProviderEngine when it is this subproviders @@ -396,7 +394,7 @@ ___ *Inherited from [Subprovider](#interface-subprovider).[setEngine](#setengine)* -*Defined in [subproviders/src/subproviders/subprovider.ts:68](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/subprovider.ts#L68)* +*Defined in [subproviders/src/subproviders/subprovider.ts:68](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/subprovider.ts#L68)* Set's the subprovider's engine to the ProviderEngine it is added to. This is only called within the ProviderEngine source code, do not call @@ -416,7 +414,7 @@ ___ ▸ **setPath**(`basDerivationPath`: string): *void* -*Defined in [subproviders/src/subproviders/ledger.ts:75](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/ledger.ts#L75)* +*Defined in [subproviders/src/subproviders/ledger.ts:75](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/ledger.ts#L75)* Set a desired derivation path when computing the available user addresses @@ -436,7 +434,7 @@ ___ *Overrides void* -*Defined in [subproviders/src/subproviders/ledger.ts:158](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/ledger.ts#L158)* +*Defined in [subproviders/src/subproviders/ledger.ts:158](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/ledger.ts#L158)* Sign a personal Ethereum signed message. The signing account will be the account associated with the provided address. @@ -464,7 +462,7 @@ ___ *Overrides void* -*Defined in [subproviders/src/subproviders/ledger.ts:101](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/ledger.ts#L101)* +*Defined in [subproviders/src/subproviders/ledger.ts:101](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/ledger.ts#L101)* Signs a transaction on the Ledger with the account specificed by the `from` field in txParams. If you've added the LedgerSubprovider to your app's provider, you can simply send an `eth_sendTransaction` @@ -489,7 +487,7 @@ ___ *Overrides void* -*Defined in [subproviders/src/subproviders/ledger.ts:196](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/ledger.ts#L196)* +*Defined in [subproviders/src/subproviders/ledger.ts:196](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/ledger.ts#L196)* eth_signTypedData is currently not supported on Ledger devices. @@ -522,7 +520,7 @@ are passed onwards for subsequent subproviders to handle. \+ **new MetamaskSubprovider**(`supportedProvider`: [SupportedProvider](#supportedprovider)): *[MetamaskSubprovider](#class-metamasksubprovider)* -*Defined in [subproviders/src/subproviders/metamask_subprovider.ts:19](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/metamask_subprovider.ts#L19)* +*Defined in [subproviders/src/subproviders/metamask_subprovider.ts:19](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/metamask_subprovider.ts#L19)* Instantiates a new MetamaskSubprovider @@ -542,7 +540,7 @@ Name | Type | Description | *Inherited from [Subprovider](#interface-subprovider).[emitPayloadAsync](#emitpayloadasync)* -*Defined in [subproviders/src/subproviders/subprovider.ts:55](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/subprovider.ts#L55)* +*Defined in [subproviders/src/subproviders/subprovider.ts:55](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/subprovider.ts#L55)* Emits a JSON RPC payload that will then be handled by the ProviderEngine instance this subprovider is a part of. The payload will cascade down the subprovider middleware @@ -566,7 +564,7 @@ ___ *Overrides [Subprovider](_subproviders_src_subproviders_subprovider_.subprovider.md).[handleRequest](#abstract-handlerequest)* -*Defined in [subproviders/src/subproviders/metamask_subprovider.ts:39](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/metamask_subprovider.ts#L39)* +*Defined in [subproviders/src/subproviders/metamask_subprovider.ts:39](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/metamask_subprovider.ts#L39)* This method conforms to the web3-provider-engine interface. It is called internally by the ProviderEngine when it is this subproviders @@ -588,7 +586,7 @@ ___ ▸ **sendAsync**(`payload`: `JSONRPCRequestPayload`, `callback`: [ErrorCallback](#errorcallback)): *void* -*Defined in [subproviders/src/subproviders/metamask_subprovider.ts:117](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/metamask_subprovider.ts#L117)* +*Defined in [subproviders/src/subproviders/metamask_subprovider.ts:117](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/metamask_subprovider.ts#L117)* This method conforms to the provider sendAsync interface. Allowing the MetamaskSubprovider to be used as a generic provider (outside of Web3ProviderEngine) with the @@ -613,7 +611,7 @@ ___ *Inherited from [Subprovider](#interface-subprovider).[setEngine](#setengine)* -*Defined in [subproviders/src/subproviders/subprovider.ts:68](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/subprovider.ts#L68)* +*Defined in [subproviders/src/subproviders/subprovider.ts:68](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/subprovider.ts#L68)* Set's the subprovider's engine to the ProviderEngine it is added to. This is only called within the ProviderEngine source code, do not call @@ -642,7 +640,7 @@ all requests with accounts derived from the supplied mnemonic. \+ **new MnemonicWalletSubprovider**(`config`: [MnemonicWalletSubproviderConfigs](#interface-mnemonicwalletsubproviderconfigs)): *[MnemonicWalletSubprovider](#class-mnemonicwalletsubprovider)* -*Defined in [subproviders/src/subproviders/mnemonic_wallet.ts:27](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/mnemonic_wallet.ts#L27)* +*Defined in [subproviders/src/subproviders/mnemonic_wallet.ts:27](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/mnemonic_wallet.ts#L27)* Instantiates a MnemonicWalletSubprovider. Defaults to baseDerivationPath set to `44'/60'/0'/0`. This is the default in TestRPC/Ganache, it can be overridden if desired. @@ -665,7 +663,7 @@ MnemonicWalletSubprovider instance *Inherited from [Subprovider](#interface-subprovider).[emitPayloadAsync](#emitpayloadasync)* -*Defined in [subproviders/src/subproviders/subprovider.ts:55](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/subprovider.ts#L55)* +*Defined in [subproviders/src/subproviders/subprovider.ts:55](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/subprovider.ts#L55)* Emits a JSON RPC payload that will then be handled by the ProviderEngine instance this subprovider is a part of. The payload will cascade down the subprovider middleware @@ -689,7 +687,7 @@ ___ *Overrides void* -*Defined in [subproviders/src/subproviders/mnemonic_wallet.ts:70](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/mnemonic_wallet.ts#L70)* +*Defined in [subproviders/src/subproviders/mnemonic_wallet.ts:70](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/mnemonic_wallet.ts#L70)* Retrieve the accounts associated with the mnemonic. This method is implicitly called when issuing a `eth_accounts` JSON RPC request @@ -711,7 +709,7 @@ ___ ▸ **getPath**(): *string* -*Defined in [subproviders/src/subproviders/mnemonic_wallet.ts:52](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/mnemonic_wallet.ts#L52)* +*Defined in [subproviders/src/subproviders/mnemonic_wallet.ts:52](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/mnemonic_wallet.ts#L52)* Retrieve the set derivation path @@ -729,7 +727,7 @@ ___ *Overrides [Subprovider](_subproviders_src_subproviders_subprovider_.subprovider.md).[handleRequest](#abstract-handlerequest)* -*Defined in [subproviders/src/subproviders/base_wallet_subprovider.ts:37](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/base_wallet_subprovider.ts#L37)* +*Defined in [subproviders/src/subproviders/base_wallet_subprovider.ts:37](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/base_wallet_subprovider.ts#L37)* This method conforms to the web3-provider-engine interface. It is called internally by the ProviderEngine when it is this subproviders @@ -753,7 +751,7 @@ ___ *Inherited from [Subprovider](#interface-subprovider).[setEngine](#setengine)* -*Defined in [subproviders/src/subproviders/subprovider.ts:68](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/subprovider.ts#L68)* +*Defined in [subproviders/src/subproviders/subprovider.ts:68](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/subprovider.ts#L68)* Set's the subprovider's engine to the ProviderEngine it is added to. This is only called within the ProviderEngine source code, do not call @@ -773,7 +771,7 @@ ___ ▸ **setPath**(`baseDerivationPath`: string): *void* -*Defined in [subproviders/src/subproviders/mnemonic_wallet.ts:59](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/mnemonic_wallet.ts#L59)* +*Defined in [subproviders/src/subproviders/mnemonic_wallet.ts:59](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/mnemonic_wallet.ts#L59)* Set a desired derivation path when computing the available user addresses @@ -793,7 +791,7 @@ ___ *Overrides void* -*Defined in [subproviders/src/subproviders/mnemonic_wallet.ts:102](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/mnemonic_wallet.ts#L102)* +*Defined in [subproviders/src/subproviders/mnemonic_wallet.ts:102](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/mnemonic_wallet.ts#L102)* Sign a personal Ethereum signed message. The signing account will be the account associated with the provided address. If you've added the MnemonicWalletSubprovider to @@ -820,7 +818,7 @@ ___ *Overrides void* -*Defined in [subproviders/src/subproviders/mnemonic_wallet.ts:84](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/mnemonic_wallet.ts#L84)* +*Defined in [subproviders/src/subproviders/mnemonic_wallet.ts:84](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/mnemonic_wallet.ts#L84)* Signs a transaction with the account specificed by the `from` field in txParams. If you've added this Subprovider to your app's provider, you can simply send @@ -845,7 +843,7 @@ ___ *Overrides void* -*Defined in [subproviders/src/subproviders/mnemonic_wallet.ts:122](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/mnemonic_wallet.ts#L122)* +*Defined in [subproviders/src/subproviders/mnemonic_wallet.ts:122](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/mnemonic_wallet.ts#L122)* Sign an EIP712 Typed Data message. The signing account will be the account associated with the provided address. If you've added this MnemonicWalletSubprovider to @@ -881,7 +879,7 @@ We added the additional feature of clearing the cached nonce value when a `nonce *Inherited from [Subprovider](#interface-subprovider).[emitPayloadAsync](#emitpayloadasync)* -*Defined in [subproviders/src/subproviders/subprovider.ts:55](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/subprovider.ts#L55)* +*Defined in [subproviders/src/subproviders/subprovider.ts:55](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/subprovider.ts#L55)* Emits a JSON RPC payload that will then be handled by the ProviderEngine instance this subprovider is a part of. The payload will cascade down the subprovider middleware @@ -905,7 +903,7 @@ ___ *Overrides [Subprovider](_subproviders_src_subproviders_subprovider_.subprovider.md).[handleRequest](#abstract-handlerequest)* -*Defined in [subproviders/src/subproviders/nonce_tracker.ts:57](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/nonce_tracker.ts#L57)* +*Defined in [subproviders/src/subproviders/nonce_tracker.ts:57](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/nonce_tracker.ts#L57)* This method conforms to the web3-provider-engine interface. It is called internally by the ProviderEngine when it is this subproviders @@ -929,7 +927,7 @@ ___ *Inherited from [Subprovider](#interface-subprovider).[setEngine](#setengine)* -*Defined in [subproviders/src/subproviders/subprovider.ts:68](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/subprovider.ts#L68)* +*Defined in [subproviders/src/subproviders/subprovider.ts:68](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/subprovider.ts#L68)* Set's the subprovider's engine to the ProviderEngine it is added to. This is only called within the ProviderEngine source code, do not call @@ -958,7 +956,7 @@ all requests with the supplied Ethereum private key. \+ **new PrivateKeyWalletSubprovider**(`privateKey`: string): *[PrivateKeyWalletSubprovider](#class-privatekeywalletsubprovider)* -*Defined in [subproviders/src/subproviders/private_key_wallet.ts:19](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/private_key_wallet.ts#L19)* +*Defined in [subproviders/src/subproviders/private_key_wallet.ts:19](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/private_key_wallet.ts#L19)* Instantiates a PrivateKeyWalletSubprovider. @@ -980,7 +978,7 @@ PrivateKeyWalletSubprovider instance *Inherited from [Subprovider](#interface-subprovider).[emitPayloadAsync](#emitpayloadasync)* -*Defined in [subproviders/src/subproviders/subprovider.ts:55](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/subprovider.ts#L55)* +*Defined in [subproviders/src/subproviders/subprovider.ts:55](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/subprovider.ts#L55)* Emits a JSON RPC payload that will then be handled by the ProviderEngine instance this subprovider is a part of. The payload will cascade down the subprovider middleware @@ -1004,7 +1002,7 @@ ___ *Overrides void* -*Defined in [subproviders/src/subproviders/private_key_wallet.ts:37](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/private_key_wallet.ts#L37)* +*Defined in [subproviders/src/subproviders/private_key_wallet.ts:37](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/private_key_wallet.ts#L37)* Retrieve the account associated with the supplied private key. This method is implicitly called when issuing a `eth_accounts` JSON RPC request @@ -1024,7 +1022,7 @@ ___ *Overrides [Subprovider](_subproviders_src_subproviders_subprovider_.subprovider.md).[handleRequest](#abstract-handlerequest)* -*Defined in [subproviders/src/subproviders/base_wallet_subprovider.ts:37](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/base_wallet_subprovider.ts#L37)* +*Defined in [subproviders/src/subproviders/base_wallet_subprovider.ts:37](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/base_wallet_subprovider.ts#L37)* This method conforms to the web3-provider-engine interface. It is called internally by the ProviderEngine when it is this subproviders @@ -1048,7 +1046,7 @@ ___ *Inherited from [Subprovider](#interface-subprovider).[setEngine](#setengine)* -*Defined in [subproviders/src/subproviders/subprovider.ts:68](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/subprovider.ts#L68)* +*Defined in [subproviders/src/subproviders/subprovider.ts:68](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/subprovider.ts#L68)* Set's the subprovider's engine to the ProviderEngine it is added to. This is only called within the ProviderEngine source code, do not call @@ -1070,7 +1068,7 @@ ___ *Overrides void* -*Defined in [subproviders/src/subproviders/private_key_wallet.ts:72](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/private_key_wallet.ts#L72)* +*Defined in [subproviders/src/subproviders/private_key_wallet.ts:72](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/private_key_wallet.ts#L72)* Sign a personal Ethereum signed message. The signing address will be calculated from the private key. The address must be provided it must match the address calculated from the private key. @@ -1097,7 +1095,7 @@ ___ *Overrides void* -*Defined in [subproviders/src/subproviders/private_key_wallet.ts:48](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/private_key_wallet.ts#L48)* +*Defined in [subproviders/src/subproviders/private_key_wallet.ts:48](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/private_key_wallet.ts#L48)* Sign a transaction with the private key. If you've added this Subprovider to your app's provider, you can simply send an `eth_sendTransaction` JSON RPC request, and @@ -1122,7 +1120,7 @@ ___ *Overrides void* -*Defined in [subproviders/src/subproviders/private_key_wallet.ts:99](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/private_key_wallet.ts#L99)* +*Defined in [subproviders/src/subproviders/private_key_wallet.ts:99](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/private_key_wallet.ts#L99)* Sign an EIP712 Typed Data message. The signing address will be calculated from the private key. The address must be provided it must match the address calculated from the private key. @@ -1156,7 +1154,7 @@ set of JSON RPC endpoints. \+ **new RedundantSubprovider**(`subproviders`: [Subprovider](_subproviders_src_subproviders_subprovider_.subprovider.md)[]): *[RedundantSubprovider](#class-redundantsubprovider)* -*Defined in [subproviders/src/subproviders/redundant_subprovider.ts:33](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/redundant_subprovider.ts#L33)* +*Defined in [subproviders/src/subproviders/redundant_subprovider.ts:33](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/redundant_subprovider.ts#L33)* Instantiates a new RedundantSubprovider @@ -1176,7 +1174,7 @@ Name | Type | Description | *Inherited from [Subprovider](#interface-subprovider).[emitPayloadAsync](#emitpayloadasync)* -*Defined in [subproviders/src/subproviders/subprovider.ts:55](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/subprovider.ts#L55)* +*Defined in [subproviders/src/subproviders/subprovider.ts:55](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/subprovider.ts#L55)* Emits a JSON RPC payload that will then be handled by the ProviderEngine instance this subprovider is a part of. The payload will cascade down the subprovider middleware @@ -1200,7 +1198,7 @@ ___ *Overrides [Subprovider](_subproviders_src_subproviders_subprovider_.subprovider.md).[handleRequest](#abstract-handlerequest)* -*Defined in [subproviders/src/subproviders/redundant_subprovider.ts:51](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/redundant_subprovider.ts#L51)* +*Defined in [subproviders/src/subproviders/redundant_subprovider.ts:51](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/redundant_subprovider.ts#L51)* This method conforms to the web3-provider-engine interface. It is called internally by the ProviderEngine when it is this subproviders @@ -1239,7 +1237,7 @@ ___ *Inherited from [Subprovider](#interface-subprovider).[setEngine](#setengine)* -*Defined in [subproviders/src/subproviders/subprovider.ts:68](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/subprovider.ts#L68)* +*Defined in [subproviders/src/subproviders/subprovider.ts:68](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/subprovider.ts#L68)* Set's the subprovider's engine to the ProviderEngine it is added to. This is only called within the ProviderEngine source code, do not call @@ -1267,7 +1265,7 @@ It forwards on JSON RPC requests to the supplied `rpcUrl` endpoint \+ **new RPCSubprovider**(`rpcUrl`: string, `requestTimeoutMs`: number): *[RPCSubprovider](#class-rpcsubprovider)* -*Defined in [subproviders/src/subproviders/rpc_subprovider.ts:17](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/rpc_subprovider.ts#L17)* +*Defined in [subproviders/src/subproviders/rpc_subprovider.ts:17](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/rpc_subprovider.ts#L17)* **Parameters:** @@ -1286,7 +1284,7 @@ Name | Type | Default | Description | *Inherited from [Subprovider](#interface-subprovider).[emitPayloadAsync](#emitpayloadasync)* -*Defined in [subproviders/src/subproviders/subprovider.ts:55](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/subprovider.ts#L55)* +*Defined in [subproviders/src/subproviders/subprovider.ts:55](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/subprovider.ts#L55)* Emits a JSON RPC payload that will then be handled by the ProviderEngine instance this subprovider is a part of. The payload will cascade down the subprovider middleware @@ -1310,7 +1308,7 @@ ___ *Overrides [Subprovider](_subproviders_src_subproviders_subprovider_.subprovider.md).[handleRequest](#abstract-handlerequest)* -*Defined in [subproviders/src/subproviders/rpc_subprovider.ts:38](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/rpc_subprovider.ts#L38)* +*Defined in [subproviders/src/subproviders/rpc_subprovider.ts:38](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/rpc_subprovider.ts#L38)* This method conforms to the web3-provider-engine interface. It is called internally by the ProviderEngine when it is this subproviders @@ -1334,7 +1332,7 @@ ___ *Inherited from [Subprovider](#interface-subprovider).[setEngine](#setengine)* -*Defined in [subproviders/src/subproviders/subprovider.ts:68](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/subprovider.ts#L68)* +*Defined in [subproviders/src/subproviders/subprovider.ts:68](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/subprovider.ts#L68)* Set's the subprovider's engine to the ProviderEngine it is added to. This is only called within the ProviderEngine source code, do not call @@ -1364,7 +1362,7 @@ are passed onwards for subsequent subproviders to handle. \+ **new SignerSubprovider**(`supportedProvider`: [SupportedProvider](#supportedprovider)): *[SignerSubprovider](#class-signersubprovider)* -*Defined in [subproviders/src/subproviders/signer.ts:15](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/signer.ts#L15)* +*Defined in [subproviders/src/subproviders/signer.ts:15](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/signer.ts#L15)* Instantiates a new SignerSubprovider. @@ -1384,7 +1382,7 @@ Name | Type | Description | *Inherited from [Subprovider](#interface-subprovider).[emitPayloadAsync](#emitpayloadasync)* -*Defined in [subproviders/src/subproviders/subprovider.ts:55](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/subprovider.ts#L55)* +*Defined in [subproviders/src/subproviders/subprovider.ts:55](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/subprovider.ts#L55)* Emits a JSON RPC payload that will then be handled by the ProviderEngine instance this subprovider is a part of. The payload will cascade down the subprovider middleware @@ -1408,7 +1406,7 @@ ___ *Overrides [Subprovider](_subproviders_src_subproviders_subprovider_.subprovider.md).[handleRequest](#abstract-handlerequest)* -*Defined in [subproviders/src/subproviders/signer.ts:33](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/signer.ts#L33)* +*Defined in [subproviders/src/subproviders/signer.ts:33](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/signer.ts#L33)* This method conforms to the web3-provider-engine interface. It is called internally by the ProviderEngine when it is this subproviders @@ -1432,7 +1430,7 @@ ___ *Inherited from [Subprovider](#interface-subprovider).[setEngine](#setengine)* -*Defined in [subproviders/src/subproviders/subprovider.ts:68](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/subprovider.ts#L68)* +*Defined in [subproviders/src/subproviders/subprovider.ts:68](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/subprovider.ts#L68)* Set's the subprovider's engine to the ProviderEngine it is added to. This is only called within the ProviderEngine source code, do not call @@ -1460,7 +1458,7 @@ This one has an async/await `emitPayloadAsync` and also defined types. ▸ **emitPayloadAsync**(`payload`: `Partial`): *`Promise`* -*Defined in [subproviders/src/subproviders/subprovider.ts:55](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/subprovider.ts#L55)* +*Defined in [subproviders/src/subproviders/subprovider.ts:55](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/subprovider.ts#L55)* Emits a JSON RPC payload that will then be handled by the ProviderEngine instance this subprovider is a part of. The payload will cascade down the subprovider middleware @@ -1482,7 +1480,7 @@ ___ ▸ **handleRequest**(`payload`: `JSONRPCRequestPayload`, `next`: [Callback](#callback), `end`: [ErrorCallback](#errorcallback)): *`Promise`* -*Defined in [subproviders/src/subproviders/subprovider.ts:42](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/subprovider.ts#L42)* +*Defined in [subproviders/src/subproviders/subprovider.ts:42](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/subprovider.ts#L42)* **Parameters:** @@ -1500,7 +1498,7 @@ ___ ▸ **setEngine**(`engine`: `Web3ProviderEngine`): *void* -*Defined in [subproviders/src/subproviders/subprovider.ts:68](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/subprovider.ts#L68)* +*Defined in [subproviders/src/subproviders/subprovider.ts:68](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/subprovider.ts#L68)* Set's the subprovider's engine to the ProviderEngine it is added to. This is only called within the ProviderEngine source code, do not call @@ -1525,7 +1523,7 @@ Name | Type | Description | \+ **new TrezorSubprovider**(`config`: [TrezorSubproviderConfig](#interface-trezorsubproviderconfig)): *[TrezorSubprovider](#class-trezorsubprovider)* -*Defined in [subproviders/src/subproviders/trezor.ts:32](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/trezor.ts#L32)* +*Defined in [subproviders/src/subproviders/trezor.ts:32](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/trezor.ts#L32)* Instantiates a TrezorSubprovider. Defaults to private key path set to `44'/60'/0'/0/`. Must be initialized with trezor-connect API module https://github.com/trezor/connect. @@ -1548,7 +1546,7 @@ TrezorSubprovider instance *Inherited from [Subprovider](#interface-subprovider).[emitPayloadAsync](#emitpayloadasync)* -*Defined in [subproviders/src/subproviders/subprovider.ts:55](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/subprovider.ts#L55)* +*Defined in [subproviders/src/subproviders/subprovider.ts:55](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/subprovider.ts#L55)* Emits a JSON RPC payload that will then be handled by the ProviderEngine instance this subprovider is a part of. The payload will cascade down the subprovider middleware @@ -1572,7 +1570,7 @@ ___ *Overrides void* -*Defined in [subproviders/src/subproviders/trezor.ts:56](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/trezor.ts#L56)* +*Defined in [subproviders/src/subproviders/trezor.ts:56](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/trezor.ts#L56)* Retrieve a users Trezor account. This method is automatically called when issuing a `eth_accounts` JSON RPC request via your providerEngine @@ -1598,7 +1596,7 @@ ___ *Overrides [Subprovider](_subproviders_src_subproviders_subprovider_.subprovider.md).[handleRequest](#abstract-handlerequest)* -*Defined in [subproviders/src/subproviders/base_wallet_subprovider.ts:37](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/base_wallet_subprovider.ts#L37)* +*Defined in [subproviders/src/subproviders/base_wallet_subprovider.ts:37](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/base_wallet_subprovider.ts#L37)* This method conforms to the web3-provider-engine interface. It is called internally by the ProviderEngine when it is this subproviders @@ -1622,7 +1620,7 @@ ___ *Inherited from [Subprovider](#interface-subprovider).[setEngine](#setengine)* -*Defined in [subproviders/src/subproviders/subprovider.ts:68](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/subprovider.ts#L68)* +*Defined in [subproviders/src/subproviders/subprovider.ts:68](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/subprovider.ts#L68)* Set's the subprovider's engine to the ProviderEngine it is added to. This is only called within the ProviderEngine source code, do not call @@ -1644,7 +1642,7 @@ ___ *Overrides void* -*Defined in [subproviders/src/subproviders/trezor.ts:129](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/trezor.ts#L129)* +*Defined in [subproviders/src/subproviders/trezor.ts:129](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/trezor.ts#L129)* Sign a personal Ethereum signed message. The signing account will be the account associated with the provided address. If you've added the TrezorSubprovider to @@ -1671,7 +1669,7 @@ ___ *Overrides void* -*Defined in [subproviders/src/subproviders/trezor.ts:70](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/trezor.ts#L70)* +*Defined in [subproviders/src/subproviders/trezor.ts:70](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/trezor.ts#L70)* Signs a transaction on the Trezor with the account specificed by the `from` field in txParams. If you've added the TrezorSubprovider to your app's provider, you can simply send an `eth_sendTransaction` @@ -1696,7 +1694,7 @@ ___ *Overrides void* -*Defined in [subproviders/src/subproviders/trezor.ts:161](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/trezor.ts#L161)* +*Defined in [subproviders/src/subproviders/trezor.ts:161](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/subproviders/trezor.ts#L161)* TODO:: eth_signTypedData is currently not supported on Trezor devices. @@ -1732,7 +1730,7 @@ Signature hex string (order: rsv) • **CannotDetermineAddressFromPayload**: = "CANNOT_DETERMINE_ADDRESS_FROM_PAYLOAD" -*Defined in [subproviders/src/types.ts:121](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/types.ts#L121)* +*Defined in [subproviders/src/types.ts:121](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/types.ts#L121)* ___ @@ -1740,7 +1738,7 @@ ___ • **EmptyParametersFound**: = "EMPTY_PARAMETERS_FOUND" -*Defined in [subproviders/src/types.ts:120](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/types.ts#L120)* +*Defined in [subproviders/src/types.ts:120](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/types.ts#L120)*
@@ -1773,39 +1771,6 @@ ___ -## Type aliases - - - - - - - - - -### EIP712ObjectValue - -Ƭ **EIP712ObjectValue**: *string | number | [EIP712Object](#interface-eip712object)* - -*Defined in [types/src/index.ts:740](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L740)* - -___ - - - - - - - - - - - - - - - - @@ -1848,7 +1813,7 @@ ___ • **isEIP1193**: *boolean* -*Defined in [ethereum-types/src/index.ts:73](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L73)* +*Defined in [ethereum-types/src/index.ts:73](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L73)* ## Methods @@ -1856,7 +1821,7 @@ ___ ▸ **on**(`event`: [EIP1193Event](#eip1193event), `listener`: function): *this* -*Defined in [ethereum-types/src/index.ts:75](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L75)* +*Defined in [ethereum-types/src/index.ts:75](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L75)* **Parameters:** @@ -1880,7 +1845,7 @@ ___ ▸ **send**(`method`: string, `params?`: any[]): *`Promise`* -*Defined in [ethereum-types/src/index.ts:74](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L74)* +*Defined in [ethereum-types/src/index.ts:74](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L74)* **Parameters:** @@ -1914,7 +1879,7 @@ Name | Type | ▸ **sendAsync**(`payload`: [JSONRPCRequestPayload](_ethereum_types_src_index_.jsonrpcrequestpayload.md), `callback`: [JSONRPCErrorCallback](#jsonrpcerrorcallback)): *void* -*Defined in [ethereum-types/src/index.ts:14](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L14)* +*Defined in [ethereum-types/src/index.ts:14](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L14)* **Parameters:** @@ -1938,7 +1903,7 @@ Name | Type | • **id**: *number* -*Defined in [ethereum-types/src/index.ts:330](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L330)* +*Defined in [ethereum-types/src/index.ts:330](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L330)* ___ @@ -1946,7 +1911,7 @@ ___ • **jsonrpc**: *string* -*Defined in [ethereum-types/src/index.ts:331](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L331)* +*Defined in [ethereum-types/src/index.ts:331](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L331)* ___ @@ -1954,7 +1919,7 @@ ___ • **method**: *string* -*Defined in [ethereum-types/src/index.ts:329](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L329)* +*Defined in [ethereum-types/src/index.ts:329](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L329)* ___ @@ -1962,7 +1927,7 @@ ___ • **params**: *any[]* -*Defined in [ethereum-types/src/index.ts:328](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L328)* +*Defined in [ethereum-types/src/index.ts:328](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L328)*
@@ -1975,7 +1940,7 @@ ___ • **code**: *number* -*Defined in [ethereum-types/src/index.ts:336](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L336)* +*Defined in [ethereum-types/src/index.ts:336](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L336)* ___ @@ -1983,7 +1948,7 @@ ___ • **message**: *string* -*Defined in [ethereum-types/src/index.ts:335](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L335)* +*Defined in [ethereum-types/src/index.ts:335](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L335)*
@@ -1996,7 +1961,7 @@ ___ • **error**? : *[JSONRPCResponseError](#class-jsonrpcresponseerror)* -*Defined in [ethereum-types/src/index.ts:343](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L343)* +*Defined in [ethereum-types/src/index.ts:343](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L343)* ___ @@ -2004,7 +1969,7 @@ ___ • **id**: *number* -*Defined in [ethereum-types/src/index.ts:341](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L341)* +*Defined in [ethereum-types/src/index.ts:341](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L341)* ___ @@ -2012,7 +1977,7 @@ ___ • **jsonrpc**: *string* -*Defined in [ethereum-types/src/index.ts:342](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L342)* +*Defined in [ethereum-types/src/index.ts:342](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L342)* ___ @@ -2020,7 +1985,7 @@ ___ • **result**: *any* -*Defined in [ethereum-types/src/index.ts:340](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L340)* +*Defined in [ethereum-types/src/index.ts:340](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L340)*
@@ -2081,7 +2046,7 @@ This interface allowed sending synchonous requests, support for which was later ▸ **send**(`payload`: [JSONRPCRequestPayload](_ethereum_types_src_index_.jsonrpcrequestpayload.md)): *[JSONRPCResponsePayload](#class-jsonrpcresponsepayload)* -*Defined in [ethereum-types/src/index.ts:45](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L45)* +*Defined in [ethereum-types/src/index.ts:45](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L45)* **Parameters:** @@ -2097,7 +2062,7 @@ ___ ▸ **sendAsync**(`payload`: [JSONRPCRequestPayload](_ethereum_types_src_index_.jsonrpcrequestpayload.md), `callback`: [JSONRPCErrorCallback](#jsonrpcerrorcallback)): *void* -*Defined in [ethereum-types/src/index.ts:44](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L44)* +*Defined in [ethereum-types/src/index.ts:44](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L44)* **Parameters:** @@ -2123,7 +2088,7 @@ before the first attempts to conform to EIP1193 ▸ **send**(`payload`: [JSONRPCRequestPayload](_ethereum_types_src_index_.jsonrpcrequestpayload.md), `callback`: [JSONRPCErrorCallback](#jsonrpcerrorcallback)): *void* -*Defined in [ethereum-types/src/index.ts:54](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L54)* +*Defined in [ethereum-types/src/index.ts:54](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L54)* **Parameters:** @@ -2149,7 +2114,7 @@ however it does not conform entirely. ▸ **send**(`method`: string, `params?`: any[]): *`Promise`* -*Defined in [ethereum-types/src/index.ts:63](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L63)* +*Defined in [ethereum-types/src/index.ts:63](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L63)* **Parameters:** @@ -2175,7 +2140,7 @@ add here • **isMetaMask**? : *undefined | false | true* -*Defined in [ethereum-types/src/index.ts:31](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L31)* +*Defined in [ethereum-types/src/index.ts:31](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L31)* ___ @@ -2183,7 +2148,7 @@ ___ • **isParity**? : *undefined | false | true* -*Defined in [ethereum-types/src/index.ts:32](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L32)* +*Defined in [ethereum-types/src/index.ts:32](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L32)* ___ @@ -2191,7 +2156,7 @@ ___ • **isZeroExProvider**? : *undefined | false | true* -*Defined in [ethereum-types/src/index.ts:30](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L30)* +*Defined in [ethereum-types/src/index.ts:30](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L30)* ## Methods @@ -2199,7 +2164,7 @@ ___ ▸ **enable**(): *`Promise`* -*Defined in [ethereum-types/src/index.ts:34](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L34)* +*Defined in [ethereum-types/src/index.ts:34](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L34)* **Returns:** *`Promise`* @@ -2209,7 +2174,7 @@ ___ ▸ **sendAsync**(`payload`: [JSONRPCRequestPayload](_ethereum_types_src_index_.jsonrpcrequestpayload.md), `callback`: [JSONRPCErrorCallback](#jsonrpcerrorcallback)): *void* -*Defined in [ethereum-types/src/index.ts:35](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L35)* +*Defined in [ethereum-types/src/index.ts:35](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L35)* **Parameters:** @@ -2226,110 +2191,12 @@ ___ ▸ **stop**(): *void* -*Defined in [ethereum-types/src/index.ts:33](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L33)* +*Defined in [ethereum-types/src/index.ts:33](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L33)* **Returns:** *void*
-# Interface: DebugPayload - - -## Properties - -### id - -• **id**: *number* - - - -Defined in ethereum-types/lib/index.d.ts:267 - -___ - -### jsonrpc - -• **jsonrpc**: *string* - - - -Defined in ethereum-types/lib/index.d.ts:268 - -___ - -### method - -• **method**: *string* - - - -Defined in ethereum-types/lib/index.d.ts:266 - -___ - -### params - -• **params**: *any[]* - - - -Defined in ethereum-types/lib/index.d.ts:265 - -___ - -### `Optional` rawTransactionAttributes - -• **rawTransactionAttributes**? : *[DebugPayloadRawTransactionAttributes](#class-debugpayloadrawtransactionattributes)* - -*Defined in [subproviders/src/subproviders/debug_subprovider.ts:19](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/debug_subprovider.ts#L19)* - -
- -# Interface: DebugPayloadRawTransactionAttributes - - -## Properties - -### gasLimit - -• **gasLimit**: *string* - -*Defined in [subproviders/src/subproviders/debug_subprovider.ts:13](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/debug_subprovider.ts#L13)* - -___ - -### gasPrice - -• **gasPrice**: *string* - -*Defined in [subproviders/src/subproviders/debug_subprovider.ts:12](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/debug_subprovider.ts#L12)* - -___ - -### nonce - -• **nonce**: *string* - -*Defined in [subproviders/src/subproviders/debug_subprovider.ts:14](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/debug_subprovider.ts#L14)* - -___ - -### to - -• **to**: *string* - -*Defined in [subproviders/src/subproviders/debug_subprovider.ts:16](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/debug_subprovider.ts#L16)* - -___ - -### value - -• **value**: *string* - -*Defined in [subproviders/src/subproviders/debug_subprovider.ts:15](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/debug_subprovider.ts#L15)* - -
- # Interface: AccountFetchingConfigs addressSearchLimit: The maximum number of addresses to search through, defaults to 1000 @@ -2344,7 +2211,7 @@ shouldAskForOnDeviceConfirmation: Whether you wish to prompt the user on their L • **addressSearchLimit**? : *undefined | number* -*Defined in [subproviders/src/types.ts:55](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/types.ts#L55)* +*Defined in [subproviders/src/types.ts:55](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/types.ts#L55)* ___ @@ -2352,7 +2219,7 @@ ___ • **numAddressesToReturn**? : *undefined | number* -*Defined in [subproviders/src/types.ts:56](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/types.ts#L56)* +*Defined in [subproviders/src/types.ts:56](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/types.ts#L56)* ___ @@ -2360,7 +2227,7 @@ ___ • **shouldAskForOnDeviceConfirmation**? : *undefined | false | true* -*Defined in [subproviders/src/types.ts:57](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/types.ts#L57)* +*Defined in [subproviders/src/types.ts:57](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/types.ts#L57)*
@@ -2375,7 +2242,7 @@ ___ • **r**: *string* -*Defined in [subproviders/src/types.ts:29](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/types.ts#L29)* +*Defined in [subproviders/src/types.ts:29](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/types.ts#L29)* ___ @@ -2383,7 +2250,7 @@ ___ • **s**: *string* -*Defined in [subproviders/src/types.ts:30](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/types.ts#L30)* +*Defined in [subproviders/src/types.ts:30](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/types.ts#L30)* ___ @@ -2391,7 +2258,7 @@ ___ • **v**: *string* -*Defined in [subproviders/src/types.ts:28](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/types.ts#L28)* +*Defined in [subproviders/src/types.ts:28](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/types.ts#L28)*
@@ -2426,7 +2293,7 @@ ___ *Overrides void* -*Defined in [subproviders/src/types.ts:136](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/types.ts#L136)* +*Defined in [subproviders/src/types.ts:136](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/types.ts#L136)* ___ @@ -2458,7 +2325,7 @@ NodeJs and Browser communication are supported. • **getAddress**: *function* -*Defined in [subproviders/src/types.ts:17](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/types.ts#L17)* +*Defined in [subproviders/src/types.ts:17](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/types.ts#L17)* #### Type declaration: @@ -2478,7 +2345,7 @@ ___ • **signPersonalMessage**: *function* -*Defined in [subproviders/src/types.ts:23](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/types.ts#L23)* +*Defined in [subproviders/src/types.ts:23](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/types.ts#L23)* #### Type declaration: @@ -2497,7 +2364,7 @@ ___ • **signTransaction**: *function* -*Defined in [subproviders/src/types.ts:22](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/types.ts#L22)* +*Defined in [subproviders/src/types.ts:22](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/types.ts#L22)* #### Type declaration: @@ -2516,7 +2383,7 @@ ___ • **transport**: *[LedgerCommunicationClient](#class-ledgercommunicationclient)* -*Defined in [subproviders/src/types.ts:24](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/types.ts#L24)* +*Defined in [subproviders/src/types.ts:24](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/types.ts#L24)*
@@ -2529,7 +2396,7 @@ ___ • **address**: *string* -*Defined in [subproviders/src/types.ts:79](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/types.ts#L79)* +*Defined in [subproviders/src/types.ts:79](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/types.ts#L79)* ___ @@ -2537,7 +2404,7 @@ ___ • **chainCode**: *string* -*Defined in [subproviders/src/types.ts:81](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/types.ts#L81)* +*Defined in [subproviders/src/types.ts:81](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/types.ts#L81)* ___ @@ -2545,7 +2412,7 @@ ___ • **publicKey**: *string* -*Defined in [subproviders/src/types.ts:80](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/types.ts#L80)* +*Defined in [subproviders/src/types.ts:80](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/types.ts#L80)*
@@ -2563,7 +2430,7 @@ accountFetchingConfigs: configs related to fetching accounts from a Ledger • **accountFetchingConfigs**? : *[AccountFetchingConfigs](#class-accountfetchingconfigs)* -*Defined in [subproviders/src/types.ts:45](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/types.ts#L45)* +*Defined in [subproviders/src/types.ts:45](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/types.ts#L45)* ___ @@ -2571,7 +2438,7 @@ ___ • **baseDerivationPath**? : *undefined | string* -*Defined in [subproviders/src/types.ts:44](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/types.ts#L44)* +*Defined in [subproviders/src/types.ts:44](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/types.ts#L44)* ___ @@ -2579,7 +2446,7 @@ ___ • **ledgerEthereumClientFactoryAsync**: *[LedgerEthereumClientFactoryAsync](#ledgerethereumclientfactoryasync)* -*Defined in [subproviders/src/types.ts:43](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/types.ts#L43)* +*Defined in [subproviders/src/types.ts:43](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/types.ts#L43)* ___ @@ -2587,7 +2454,7 @@ ___ • **networkId**: *number* -*Defined in [subproviders/src/types.ts:42](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/types.ts#L42)* +*Defined in [subproviders/src/types.ts:42](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/types.ts#L42)*
@@ -2604,7 +2471,7 @@ baseDerivationPath: The base derivation path (e.g 44'/60'/0'/0) • **addressSearchLimit**? : *undefined | number* -*Defined in [subproviders/src/types.ts:67](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/types.ts#L67)* +*Defined in [subproviders/src/types.ts:67](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/types.ts#L67)* ___ @@ -2612,7 +2479,7 @@ ___ • **baseDerivationPath**? : *undefined | string* -*Defined in [subproviders/src/types.ts:68](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/types.ts#L68)* +*Defined in [subproviders/src/types.ts:68](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/types.ts#L68)* ___ @@ -2620,7 +2487,7 @@ ___ • **mnemonic**: *string* -*Defined in [subproviders/src/types.ts:66](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/types.ts#L66)* +*Defined in [subproviders/src/types.ts:66](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/types.ts#L66)*
@@ -2633,7 +2500,7 @@ ___ • **chainId**: *number* -*Defined in [subproviders/src/types.ts:92](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/types.ts#L92)* +*Defined in [subproviders/src/types.ts:92](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/types.ts#L92)* ___ @@ -2641,7 +2508,7 @@ ___ • **data**? : *undefined | string* -*Defined in [subproviders/src/types.ts:91](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/types.ts#L91)* +*Defined in [subproviders/src/types.ts:91](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/types.ts#L91)* ___ @@ -2649,7 +2516,7 @@ ___ • **from**: *string* -*Defined in [subproviders/src/types.ts:89](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/types.ts#L89)* +*Defined in [subproviders/src/types.ts:89](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/types.ts#L89)* ___ @@ -2657,7 +2524,7 @@ ___ • **gas**: *string* -*Defined in [subproviders/src/types.ts:87](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/types.ts#L87)* +*Defined in [subproviders/src/types.ts:87](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/types.ts#L87)* ___ @@ -2665,7 +2532,7 @@ ___ • **gasPrice**? : *undefined | string* -*Defined in [subproviders/src/types.ts:86](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/types.ts#L86)* +*Defined in [subproviders/src/types.ts:86](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/types.ts#L86)* ___ @@ -2673,7 +2540,7 @@ ___ • **nonce**: *string* -*Defined in [subproviders/src/types.ts:85](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/types.ts#L85)* +*Defined in [subproviders/src/types.ts:85](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/types.ts#L85)* ___ @@ -2681,7 +2548,7 @@ ___ • **to**: *string* -*Defined in [subproviders/src/types.ts:88](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/types.ts#L88)* +*Defined in [subproviders/src/types.ts:88](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/types.ts#L88)* ___ @@ -2689,7 +2556,7 @@ ___ • **value**? : *undefined | string* -*Defined in [subproviders/src/types.ts:90](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/types.ts#L90)* +*Defined in [subproviders/src/types.ts:90](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/types.ts#L90)*
@@ -2699,100 +2566,7 @@ ___ -# Class: DebugSubprovider - -This class implements the [web3-provider-engine](https://github.com/MetaMask/provider-engine) subprovider interface. -For every request, a object for debugging will be sent to the function specified in the constructor -Useful for debugging RPC requests which are not expecting as you expect. - - -## Constructors - - - -\+ **new DebugSubprovider**(`debugCallback`: [WithDebugPayload](#withdebugpayload)): *[DebugSubprovider](#class-debugsubprovider)* - -*Defined in [subproviders/src/subproviders/debug_subprovider.ts:44](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/debug_subprovider.ts#L44)* - -**Parameters:** - -Name | Type | Default | ------- | ------ | ------ | -`debugCallback` | [WithDebugPayload](#withdebugpayload) | defaultDebugCallback | - -**Returns:** *[DebugSubprovider](#class-debugsubprovider)* - -## Methods - -### emitPayloadAsync - -▸ **emitPayloadAsync**(`payload`: `Partial`): *`Promise`* - -*Inherited from [Subprovider](#interface-subprovider).[emitPayloadAsync](#emitpayloadasync)* - -*Defined in [subproviders/src/subproviders/subprovider.ts:55](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/subprovider.ts#L55)* - -Emits a JSON RPC payload that will then be handled by the ProviderEngine instance -this subprovider is a part of. The payload will cascade down the subprovider middleware -stack until finding the responsible entity for handling the request. - -**Parameters:** - -Name | Type | Description | ------- | ------ | ------ | -`payload` | `Partial` | JSON RPC payload | - -**Returns:** *`Promise`* - -JSON RPC response payload - -___ - -### handleRequest - -▸ **handleRequest**(`payload`: `JSONRPCRequestPayload`, `next`: [Callback](#callback), `end`: [ErrorCallback](#errorcallback)): *`Promise`* - -*Overrides [Subprovider](_subproviders_src_subproviders_subprovider_.subprovider.md).[handleRequest](#abstract-handlerequest)* - -*Defined in [subproviders/src/subproviders/debug_subprovider.ts:60](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/debug_subprovider.ts#L60)* - -This method conforms to the web3-provider-engine interface. -It is called internally by the ProviderEngine when it is this subproviders -turn to handle a JSON RPC request. - -**Parameters:** - -Name | Type | Description | ------- | ------ | ------ | -`payload` | `JSONRPCRequestPayload` | JSON RPC payload | -`next` | [Callback](#callback) | Callback to call if this subprovider decides not to handle the request | -`end` | [ErrorCallback](#errorcallback) | Callback to call if subprovider handled the request and wants to pass back the request. | - -**Returns:** *`Promise`* - -___ - -### setEngine - -▸ **setEngine**(`engine`: `Web3ProviderEngine`): *void* - -*Inherited from [Subprovider](#interface-subprovider).[setEngine](#setengine)* - -*Defined in [subproviders/src/subproviders/subprovider.ts:68](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/subprovider.ts#L68)* - -Set's the subprovider's engine to the ProviderEngine it is added to. -This is only called within the ProviderEngine source code, do not call -directly. - -**Parameters:** - -Name | Type | Description | ------- | ------ | ------ | -`engine` | `Web3ProviderEngine` | The ProviderEngine this subprovider is added to | -**Returns:** *void* - -
@@ -2809,7 +2583,7 @@ Name | Type | Description | • **accountFetchingConfigs**: *[AccountFetchingConfigs](#class-accountfetchingconfigs)* -*Defined in [subproviders/src/types.ts:140](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/types.ts#L140)* +*Defined in [subproviders/src/types.ts:140](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/types.ts#L140)* ___ @@ -2817,7 +2591,7 @@ ___ • **networkId**: *number* -*Defined in [subproviders/src/types.ts:142](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/types.ts#L142)* +*Defined in [subproviders/src/types.ts:142](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/types.ts#L142)* ___ @@ -2825,7 +2599,7 @@ ___ • **trezorConnectClientApi**: *any* -*Defined in [subproviders/src/types.ts:141](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/types.ts#L141)* +*Defined in [subproviders/src/types.ts:141](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/types.ts#L141)*
@@ -2854,6 +2628,8 @@ ___ + + @@ -2868,7 +2644,7 @@ Elliptic Curve signature • **r**: *string* -*Defined in [types/src/index.ts:62](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L62)* +*Defined in [types/src/index.ts:62](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L62)* ___ @@ -2876,7 +2652,7 @@ ___ • **s**: *string* -*Defined in [types/src/index.ts:63](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L63)* +*Defined in [types/src/index.ts:63](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L63)* ___ @@ -2884,7 +2660,7 @@ ___ • **v**: *number* -*Defined in [types/src/index.ts:61](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L61)* +*Defined in [types/src/index.ts:61](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L61)*
@@ -2904,7 +2680,7 @@ ___ • **name**: *string* -*Defined in [types/src/index.ts:732](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L732)* +*Defined in [types/src/index.ts:732](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L732)* ___ @@ -2912,7 +2688,7 @@ ___ • **type**: *string* -*Defined in [types/src/index.ts:733](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L733)* +*Defined in [types/src/index.ts:733](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L733)*
@@ -2925,7 +2701,7 @@ ___ • **domain**: *[EIP712Object](#class-eip712object)* -*Defined in [types/src/index.ts:748](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L748)* +*Defined in [types/src/index.ts:748](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L748)* ___ @@ -2933,7 +2709,7 @@ ___ • **message**: *[EIP712Object](#class-eip712object)* -*Defined in [types/src/index.ts:749](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L749)* +*Defined in [types/src/index.ts:749](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L749)* ___ @@ -2941,7 +2717,7 @@ ___ • **primaryType**: *string* -*Defined in [types/src/index.ts:750](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L750)* +*Defined in [types/src/index.ts:750](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L750)* ___ @@ -2949,7 +2725,7 @@ ___ • **types**: *[EIP712Types](#class-eip712types)* -*Defined in [types/src/index.ts:747](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L747)* +*Defined in [types/src/index.ts:747](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L747)*
@@ -2967,7 +2743,7 @@ ___ • **name**: *string* -*Defined in [types/src/index.ts:686](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L686)* +*Defined in [types/src/index.ts:686](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L686)* ___ @@ -2975,7 +2751,7 @@ ___ • **typeDocType**: *[TypeDocTypes](#enumeration-typedoctypes)* -*Defined in [types/src/index.ts:687](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/types/src/index.ts#L687)* +*Defined in [types/src/index.ts:687](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L687)*
@@ -3092,30 +2868,6 @@ ___ - - - - -## Functions - -### prependSubprovider - -▸ **prependSubprovider**(`provider`: `Web3ProviderEngine`, `subprovider`: [Subprovider](#class-subprovider)): *void* - -*Defined in [subproviders/src/utils/subprovider_utils.ts:10](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/utils/subprovider_utils.ts#L10)* - -Prepends a subprovider to a provider - -**Parameters:** - -Name | Type | Description | ------- | ------ | ------ | -`provider` | `Web3ProviderEngine` | Given provider | -`subprovider` | [Subprovider](#class-subprovider) | Subprovider to prepend | - -**Returns:** *void* - -
@@ -3138,7 +2890,7 @@ Name | Type | Description | Ƭ **EIP1193Event**: *"accountsChanged" | "networkChanged" | "close" | "connect" | "notification"* -*Defined in [ethereum-types/src/index.ts:70](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L70)* +*Defined in [ethereum-types/src/index.ts:70](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L70)* Interface for providers that conform to EIP 1193 Source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1193.md @@ -3155,7 +2907,7 @@ ___ Ƭ **JSONRPCErrorCallback**: *function* -*Defined in [ethereum-types/src/index.ts:3](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L3)* +*Defined in [ethereum-types/src/index.ts:3](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L3)* #### Type declaration: @@ -3184,7 +2936,7 @@ ___ Ƭ **SupportedProvider**: *[Web3JsProvider](_ethereum_types_src_index_.md#web3jsprovider) | [GanacheProvider](#interface-ganacheprovider) | [EIP1193Provider](#interface-eip1193provider) | [ZeroExProvider](#interface-zeroexprovider)* -*Defined in [ethereum-types/src/index.ts:9](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L9)* +*Defined in [ethereum-types/src/index.ts:9](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L9)* Do not create your own provider. Use an existing provider from a Web3 or ProviderEngine library Read more about Providers in the guides section of the 0x docs. @@ -3199,7 +2951,7 @@ ___ Ƭ **Web3JsProvider**: *[Web3JsV1Provider](#interface-web3jsv1provider) | [Web3JsV2Provider](#interface-web3jsv2provider) | [Web3JsV3Provider](#interface-web3jsv3provider)* -*Defined in [ethereum-types/src/index.ts:11](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L11)* +*Defined in [ethereum-types/src/index.ts:11](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L11)*
@@ -3212,7 +2964,7 @@ ___ ▸ **ledgerEthereumBrowserClientFactoryAsync**(): *`Promise`* -*Defined in [subproviders/src/index.ts:11](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/index.ts#L11)* +*Defined in [subproviders/src/index.ts:11](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/index.ts#L11)* A factory method for creating a LedgerEthereumClient usable in a browser context. @@ -3224,29 +2976,6 @@ LedgerEthereumClient A browser client for the LedgerSubprovider - -## Type aliases - -### WithDebugPayload - -Ƭ **WithDebugPayload**: *function* - -*Defined in [subproviders/src/subproviders/debug_subprovider.ts:22](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/subproviders/debug_subprovider.ts#L22)* - -#### Type declaration: - -▸ (`debugPayload`: [DebugPayload](#interface-debugpayload)): *void* - -**Parameters:** - -Name | Type | ------- | ------ | -`debugPayload` | [DebugPayload](#interface-debugpayload) | - -
- - -
@@ -3306,7 +3035,7 @@ Name | Type | Ƭ **Callback**: *function* -*Defined in [subproviders/src/types.ts:131](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/types.ts#L131)* +*Defined in [subproviders/src/types.ts:131](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/types.ts#L131)* #### Type declaration: @@ -3320,7 +3049,7 @@ ___ Ƭ **ErrorCallback**: *function* -*Defined in [subproviders/src/types.ts:130](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/types.ts#L130)* +*Defined in [subproviders/src/types.ts:130](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/types.ts#L130)* #### Type declaration: @@ -3339,7 +3068,7 @@ ___ Ƭ **LedgerEthereumClientFactoryAsync**: *function* -*Defined in [subproviders/src/types.ts:33](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/types.ts#L33)* +*Defined in [subproviders/src/types.ts:33](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/types.ts#L33)* #### Type declaration: @@ -3351,7 +3080,7 @@ ___ Ƭ **NextCallback**: *function* -*Defined in [subproviders/src/types.ts:133](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/types.ts#L133)* +*Defined in [subproviders/src/types.ts:133](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/types.ts#L133)* #### Type declaration: @@ -3369,7 +3098,7 @@ ___ Ƭ **OnNextCompleted**: *function* -*Defined in [subproviders/src/types.ts:132](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/subproviders/src/types.ts#L132)* +*Defined in [subproviders/src/types.ts:132](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/types.ts#L132)* #### Type declaration: @@ -3385,3 +3114,60 @@ Name | Type |
+ + + +## Functions + +### prependSubprovider + +▸ **prependSubprovider**(`provider`: `Web3ProviderEngine`, `subprovider`: [Subprovider](#class-subprovider)): *void* + +*Defined in [subproviders/src/utils/subprovider_utils.ts:10](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/subproviders/src/utils/subprovider_utils.ts#L10)* + +Prepends a subprovider to a provider + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`provider` | `Web3ProviderEngine` | Given provider | +`subprovider` | [Subprovider](#class-subprovider) | Subprovider to prepend | + +**Returns:** *void* + +
+ + + + +## Type aliases + + + + + + + + + +### EIP712ObjectValue + +Ƭ **EIP712ObjectValue**: *string | number | [EIP712Object](#interface-eip712object)* + +*Defined in [types/src/index.ts:740](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/types/src/index.ts#L740)* + +___ + + + + + + + + + + + + + diff --git a/packages/web3-wrapper/docs/reference.mdx b/packages/web3-wrapper/docs/reference.mdx index 0a01acbe1e..825b07a3b7 100644 --- a/packages/web3-wrapper/docs/reference.mdx +++ b/packages/web3-wrapper/docs/reference.mdx @@ -1,37 +1,95 @@ -# Interface: JSONRPCResponsePayload +# Class: AbiDecoder +AbiDecoder allows you to decode event logs given a set of supplied contract ABI's. It takes the contract's event +signature from the ABI and attempts to decode the logs using it. -## Properties -### `Optional` error +## Constructors -• **error**? : *[JSONRPCResponseError](#class-jsonrpcresponseerror)* -*Defined in [ethereum-types/src/index.ts:343](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L343)* -___ +\+ **new AbiDecoder**(`abiArrays`: [AbiDefinition](#abidefinition)[][]): *[AbiDecoder](#class-abidecoder)* -### id +*Defined in [utils/src/abi_decoder.ts:42](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/utils/src/abi_decoder.ts#L42)* -• **id**: *number* +Instantiate an AbiDecoder + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`abiArrays` | [AbiDefinition](#abidefinition)[][] | An array of contract ABI's | + +**Returns:** *[AbiDecoder](#class-abidecoder)* + +AbiDecoder instance + +## Methods + +### addABI + +▸ **addABI**(`abiArray`: [AbiDefinition](#abidefinition)[], `contractName?`: undefined | string): *void* + +*Defined in [utils/src/abi_decoder.ts:158](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/utils/src/abi_decoder.ts#L158)* + +Adds a set of ABI definitions, after which calldata and logs targeting these ABI's can be decoded. +Additional properties can be included to disambiguate similar ABI's. For example, if two functions +have the same signature but different parameter names, then their ABI definitions can be disambiguated +by specifying a contract name. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`abiArray` | [AbiDefinition](#abidefinition)[] | - | +`contractName?` | undefined \| string | Name of contract that encapsulates the ABI definitions (optional). This can be used when decoding calldata to disambiguate methods with the same signature but different parameter names. | -*Defined in [ethereum-types/src/index.ts:341](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L341)* +**Returns:** *void* ___ -### jsonrpc +### decodeCalldataOrThrow -• **jsonrpc**: *string* +▸ **decodeCalldataOrThrow**(`calldata`: string, `contractName?`: undefined | string): *`DecodedCalldata`* -*Defined in [ethereum-types/src/index.ts:342](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L342)* +*Defined in [utils/src/abi_decoder.ts:118](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/utils/src/abi_decoder.ts#L118)* + +Decodes calldata for a known ABI. + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`calldata` | string | hex-encoded calldata. | +`contractName?` | undefined \| string | used to disambiguate similar ABI's (optional). | + +**Returns:** *`DecodedCalldata`* + +Decoded calldata. Includes: function name and signature, along with the decoded arguments. ___ -### result +### tryToDecodeLogOrNoop -• **result**: *any* +▸ **tryToDecodeLogOrNoop**<**ArgsType**>(`log`: `LogEntry`): *`LogWithDecodedArgs` | [RawLog](#rawlog)* + +*Defined in [utils/src/abi_decoder.ts:58](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/utils/src/abi_decoder.ts#L58)* + +Attempt to decode a log given the ABI's the AbiDecoder knows about. + +**Type parameters:** -*Defined in [ethereum-types/src/index.ts:340](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L340)* +▪ **ArgsType**: *`DecodedLogArgs`* + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`log` | `LogEntry` | The log to attempt to decode | + +**Returns:** *`LogWithDecodedArgs` | [RawLog](#rawlog)* + +The decoded log if the requisite ABI was available. Otherwise the log unaltered.
@@ -46,7 +104,7 @@ An alternative to the Web3.js library that provides a consistent, clean, promise \+ **new Web3Wrapper**(`supportedProvider`: [SupportedProvider](#supportedprovider), `callAndTxnDefaults`: `Partial`): *[Web3Wrapper](#class-web3wrapper)* -*Defined in [web3-wrapper/src/web3_wrapper.ts:144](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/web3_wrapper.ts#L144)* +*Defined in [web3-wrapper/src/web3_wrapper.ts:144](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/web3_wrapper.ts#L144)* Instantiates a new Web3Wrapper. @@ -67,7 +125,7 @@ An instance of the Web3Wrapper class. • **abiDecoder**: *`AbiDecoder`* -*Defined in [web3-wrapper/src/web3_wrapper.ts:54](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/web3_wrapper.ts#L54)* +*Defined in [web3-wrapper/src/web3_wrapper.ts:54](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/web3_wrapper.ts#L54)* ___ @@ -75,7 +133,7 @@ ___ • **isZeroExWeb3Wrapper**: *boolean* = true -*Defined in [web3-wrapper/src/web3_wrapper.ts:53](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/web3_wrapper.ts#L53)* +*Defined in [web3-wrapper/src/web3_wrapper.ts:53](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/web3_wrapper.ts#L53)* Flag to check if this instance is of type Web3Wrapper @@ -85,7 +143,7 @@ Flag to check if this instance is of type Web3Wrapper ▸ **awaitTransactionMinedAsync**(`txHash`: string, `pollingIntervalMs`: number, `timeoutMs?`: undefined | number): *`Promise`* -*Defined in [web3-wrapper/src/web3_wrapper.ts:576](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/web3_wrapper.ts#L576)* +*Defined in [web3-wrapper/src/web3_wrapper.ts:576](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/web3_wrapper.ts#L576)* Waits for a transaction to be mined and returns the transaction receipt. Note that just because a transaction was mined does not mean it was @@ -111,7 +169,7 @@ ___ ▸ **awaitTransactionSuccessAsync**(`txHash`: string, `pollingIntervalMs`: number, `timeoutMs?`: undefined | number): *`Promise`* -*Defined in [web3-wrapper/src/web3_wrapper.ts:651](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/web3_wrapper.ts#L651)* +*Defined in [web3-wrapper/src/web3_wrapper.ts:651](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/web3_wrapper.ts#L651)* Waits for a transaction to be mined and returns the transaction receipt. Unlike awaitTransactionMinedAsync, it will throw if the receipt has a @@ -137,7 +195,7 @@ ___ ▸ **callAsync**(`callData`: `CallData`, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -*Defined in [web3-wrapper/src/web3_wrapper.ts:533](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/web3_wrapper.ts#L533)* +*Defined in [web3-wrapper/src/web3_wrapper.ts:533](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/web3_wrapper.ts#L533)* Call a smart contract method at a given block height @@ -158,7 +216,7 @@ ___ ▸ **doesContractExistAtAddressAsync**(`address`: string): *`Promise`* -*Defined in [web3-wrapper/src/web3_wrapper.ts:281](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/web3_wrapper.ts#L281)* +*Defined in [web3-wrapper/src/web3_wrapper.ts:281](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/web3_wrapper.ts#L281)* Check if a contract exists at a given address @@ -178,7 +236,7 @@ ___ ▸ **estimateGasAsync**(`txData`: `Partial`): *`Promise`* -*Defined in [web3-wrapper/src/web3_wrapper.ts:516](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/web3_wrapper.ts#L516)* +*Defined in [web3-wrapper/src/web3_wrapper.ts:516](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/web3_wrapper.ts#L516)* Calculate the estimated gas cost for a given transaction @@ -198,7 +256,7 @@ ___ ▸ **getAvailableAddressesAsync**(): *`Promise`* -*Defined in [web3-wrapper/src/web3_wrapper.ts:429](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/web3_wrapper.ts#L429)* +*Defined in [web3-wrapper/src/web3_wrapper.ts:429](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/web3_wrapper.ts#L429)* Retrieve the user addresses available through the backing provider @@ -212,7 +270,7 @@ ___ ▸ **getBalanceInWeiAsync**(`owner`: string, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -*Defined in [web3-wrapper/src/web3_wrapper.ts:262](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/web3_wrapper.ts#L262)* +*Defined in [web3-wrapper/src/web3_wrapper.ts:262](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/web3_wrapper.ts#L262)* Retrieves an accounts Ether balance in wei @@ -233,7 +291,7 @@ ___ ▸ **getBlockIfExistsAsync**(`blockParam`: string | [BlockParam](#blockparam)): *`Promise`* -*Defined in [web3-wrapper/src/web3_wrapper.ts:369](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/web3_wrapper.ts#L369)* +*Defined in [web3-wrapper/src/web3_wrapper.ts:369](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/web3_wrapper.ts#L369)* Fetch a specific Ethereum block without transaction data @@ -254,7 +312,7 @@ ___ ▸ **getBlockNumberAsync**(): *`Promise`* -*Defined in [web3-wrapper/src/web3_wrapper.ts:355](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/web3_wrapper.ts#L355)* +*Defined in [web3-wrapper/src/web3_wrapper.ts:355](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/web3_wrapper.ts#L355)* Fetches the latest block number @@ -268,7 +326,7 @@ ___ ▸ **getBlockTimestampAsync**(`blockParam`: string | [BlockParam](#blockparam)): *`Promise`* -*Defined in [web3-wrapper/src/web3_wrapper.ts:417](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/web3_wrapper.ts#L417)* +*Defined in [web3-wrapper/src/web3_wrapper.ts:417](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/web3_wrapper.ts#L417)* Fetch a block's timestamp @@ -288,7 +346,7 @@ ___ ▸ **getBlockWithTransactionDataAsync**(`blockParam`: string | [BlockParam](#blockparam)): *`Promise`* -*Defined in [web3-wrapper/src/web3_wrapper.ts:395](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/web3_wrapper.ts#L395)* +*Defined in [web3-wrapper/src/web3_wrapper.ts:395](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/web3_wrapper.ts#L395)* Fetch a specific Ethereum block with transaction data @@ -308,7 +366,7 @@ ___ ▸ **getChainIdAsync**(): *`Promise`* -*Defined in [web3-wrapper/src/web3_wrapper.ts:215](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/web3_wrapper.ts#L215)* +*Defined in [web3-wrapper/src/web3_wrapper.ts:215](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/web3_wrapper.ts#L215)* Fetches the chainId of the backing Ethereum node @@ -322,7 +380,7 @@ ___ ▸ **getContractCodeAsync**(`address`: string, `defaultBlock?`: [BlockParam](#blockparam)): *`Promise`* -*Defined in [web3-wrapper/src/web3_wrapper.ts:294](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/web3_wrapper.ts#L294)* +*Defined in [web3-wrapper/src/web3_wrapper.ts:294](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/web3_wrapper.ts#L294)* Gets the contract code by address @@ -343,7 +401,7 @@ ___ ▸ **getContractDefaults**(): *`Partial` | undefined* -*Defined in [web3-wrapper/src/web3_wrapper.ts:163](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/web3_wrapper.ts#L163)* +*Defined in [web3-wrapper/src/web3_wrapper.ts:163](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/web3_wrapper.ts#L163)* Get the contract defaults set to the Web3Wrapper instance @@ -357,7 +415,7 @@ ___ ▸ **getLogsAsync**(`filter`: `FilterObject`): *`Promise`* -*Defined in [web3-wrapper/src/web3_wrapper.ts:483](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/web3_wrapper.ts#L483)* +*Defined in [web3-wrapper/src/web3_wrapper.ts:483](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/web3_wrapper.ts#L483)* Retrieve smart contract logs for a given filter @@ -377,7 +435,7 @@ ___ ▸ **getNetworkIdAsync**(): *`Promise`* -*Defined in [web3-wrapper/src/web3_wrapper.ts:206](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/web3_wrapper.ts#L206)* +*Defined in [web3-wrapper/src/web3_wrapper.ts:206](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/web3_wrapper.ts#L206)* Fetches the networkId of the backing Ethereum node @@ -391,7 +449,7 @@ ___ ▸ **getNodeTypeAsync**(): *`Promise`* -*Defined in [web3-wrapper/src/web3_wrapper.ts:698](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/web3_wrapper.ts#L698)* +*Defined in [web3-wrapper/src/web3_wrapper.ts:698](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/web3_wrapper.ts#L698)* Returns either NodeType.Geth or NodeType.Ganache depending on the type of the backing Ethereum node. Throws for any other type of node. @@ -404,7 +462,7 @@ ___ ▸ **getNodeVersionAsync**(): *`Promise`* -*Defined in [web3-wrapper/src/web3_wrapper.ts:198](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/web3_wrapper.ts#L198)* +*Defined in [web3-wrapper/src/web3_wrapper.ts:198](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/web3_wrapper.ts#L198)* Fetch the backing Ethereum node's version string (e.g `MetaMask/v4.2.0`) @@ -418,7 +476,7 @@ ___ ▸ **getProvider**(): *[SupportedProvider](#supportedprovider)* -*Defined in [web3-wrapper/src/web3_wrapper.ts:170](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/web3_wrapper.ts#L170)* +*Defined in [web3-wrapper/src/web3_wrapper.ts:170](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/web3_wrapper.ts#L170)* Retrieve the Web3 provider @@ -432,7 +490,7 @@ ___ ▸ **getTransactionByHashAsync**(`txHash`: string): *`Promise`* -*Defined in [web3-wrapper/src/web3_wrapper.ts:247](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/web3_wrapper.ts#L247)* +*Defined in [web3-wrapper/src/web3_wrapper.ts:247](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/web3_wrapper.ts#L247)* Retrieves the transaction data for a given transaction @@ -452,7 +510,7 @@ ___ ▸ **getTransactionReceiptIfExistsAsync**(`txHash`: string): *`Promise`* -*Defined in [web3-wrapper/src/web3_wrapper.ts:225](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/web3_wrapper.ts#L225)* +*Defined in [web3-wrapper/src/web3_wrapper.ts:225](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/web3_wrapper.ts#L225)* Retrieves the transaction receipt for a given transaction hash if found @@ -472,7 +530,7 @@ ___ ▸ **getTransactionTraceAsync**(`txHash`: string, `traceParams`: `TraceParams`): *`Promise`* -*Defined in [web3-wrapper/src/web3_wrapper.ts:313](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/web3_wrapper.ts#L313)* +*Defined in [web3-wrapper/src/web3_wrapper.ts:313](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/web3_wrapper.ts#L313)* Gets the debug trace of a transaction @@ -493,7 +551,7 @@ ___ ▸ **increaseTimeAsync**(`timeDelta`: number): *`Promise`* -*Defined in [web3-wrapper/src/web3_wrapper.ts:466](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/web3_wrapper.ts#L466)* +*Defined in [web3-wrapper/src/web3_wrapper.ts:466](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/web3_wrapper.ts#L466)* Increase the next blocks timestamp on TestRPC/Ganache or Geth local node. Will throw if provider is neither TestRPC/Ganache or Geth. @@ -512,7 +570,7 @@ ___ ▸ **isSenderAddressAvailableAsync**(`senderAddress`: string): *`Promise`* -*Defined in [web3-wrapper/src/web3_wrapper.ts:188](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/web3_wrapper.ts#L188)* +*Defined in [web3-wrapper/src/web3_wrapper.ts:188](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/web3_wrapper.ts#L188)* Check whether an address is available through the backing provider. This can be useful if you want to know whether a user can sign messages or transactions from @@ -534,7 +592,7 @@ ___ ▸ **mineBlockAsync**(): *`Promise`* -*Defined in [web3-wrapper/src/web3_wrapper.ts:458](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/web3_wrapper.ts#L458)* +*Defined in [web3-wrapper/src/web3_wrapper.ts:458](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/web3_wrapper.ts#L458)* Mine a block on a TestRPC/Ganache local node @@ -546,7 +604,7 @@ ___ ▸ **revertSnapshotAsync**(`snapshotId`: number): *`Promise`* -*Defined in [web3-wrapper/src/web3_wrapper.ts:450](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/web3_wrapper.ts#L450)* +*Defined in [web3-wrapper/src/web3_wrapper.ts:450](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/web3_wrapper.ts#L450)* Revert the blockchain state to a previous snapshot state on TestRPC/Ganache local node @@ -566,7 +624,7 @@ ___ ▸ **sendRawPayloadAsync**<**A**>(`payload`: `Partial`): *`Promise`* -*Defined in [web3-wrapper/src/web3_wrapper.ts:679](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/web3_wrapper.ts#L679)* +*Defined in [web3-wrapper/src/web3_wrapper.ts:679](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/web3_wrapper.ts#L679)* Sends a raw Ethereum JSON RPC payload and returns the response's `result` key @@ -590,7 +648,7 @@ ___ ▸ **sendTransactionAsync**(`txData`: `TxData`): *`Promise`* -*Defined in [web3-wrapper/src/web3_wrapper.ts:555](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/web3_wrapper.ts#L555)* +*Defined in [web3-wrapper/src/web3_wrapper.ts:555](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/web3_wrapper.ts#L555)* Send a transaction @@ -610,7 +668,7 @@ ___ ▸ **setHeadAsync**(`blockNumber`: number): *`Promise`* -*Defined in [web3-wrapper/src/web3_wrapper.ts:670](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/web3_wrapper.ts#L670)* +*Defined in [web3-wrapper/src/web3_wrapper.ts:670](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/web3_wrapper.ts#L670)* Calls the 'debug_setHead' JSON RPC method, which sets the current head of the local chain by block number. Note, this is a destructive action and @@ -632,7 +690,7 @@ ___ ▸ **setProvider**(`supportedProvider`: [SupportedProvider](#supportedprovider)): *void* -*Defined in [web3-wrapper/src/web3_wrapper.ts:177](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/web3_wrapper.ts#L177)* +*Defined in [web3-wrapper/src/web3_wrapper.ts:177](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/web3_wrapper.ts#L177)* Update the used Web3 provider @@ -650,7 +708,7 @@ ___ ▸ **signMessageAsync**(`address`: string, `message`: string): *`Promise`* -*Defined in [web3-wrapper/src/web3_wrapper.ts:327](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/web3_wrapper.ts#L327)* +*Defined in [web3-wrapper/src/web3_wrapper.ts:327](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/web3_wrapper.ts#L327)* Sign a message with a specific address's private key (`eth_sign`) @@ -671,7 +729,7 @@ ___ ▸ **signTypedDataAsync**(`address`: string, `typedData`: any): *`Promise`* -*Defined in [web3-wrapper/src/web3_wrapper.ts:342](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/web3_wrapper.ts#L342)* +*Defined in [web3-wrapper/src/web3_wrapper.ts:342](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/web3_wrapper.ts#L342)* Sign an EIP712 typed data message with a specific address's private key (`eth_signTypedData`) @@ -692,7 +750,7 @@ ___ ▸ **takeSnapshotAsync**(): *`Promise`* -*Defined in [web3-wrapper/src/web3_wrapper.ts:441](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/web3_wrapper.ts#L441)* +*Defined in [web3-wrapper/src/web3_wrapper.ts:441](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/web3_wrapper.ts#L441)* Take a snapshot of the blockchain state on a TestRPC/Ganache local node @@ -706,7 +764,7 @@ ___ ▸ **isAddress**(`address`: string): *boolean* -*Defined in [web3-wrapper/src/web3_wrapper.ts:65](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/web3_wrapper.ts#L65)* +*Defined in [web3-wrapper/src/web3_wrapper.ts:65](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/web3_wrapper.ts#L65)* Check if an address is a valid Ethereum address @@ -726,7 +784,7 @@ ___ ▸ **toBaseUnitAmount**(`amount`: `BigNumber` | number, `decimals`: number): *`BigNumber`* -*Defined in [web3-wrapper/src/web3_wrapper.ts:91](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/web3_wrapper.ts#L91)* +*Defined in [web3-wrapper/src/web3_wrapper.ts:91](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/web3_wrapper.ts#L91)* A baseUnit is defined as the smallest denomination of a token. An amount expressed in baseUnits is the amount expressed in the smallest denomination. @@ -749,7 +807,7 @@ ___ ▸ **toUnitAmount**(`amount`: `BigNumber`, `decimals`: number): *`BigNumber`* -*Defined in [web3-wrapper/src/web3_wrapper.ts:76](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/web3_wrapper.ts#L76)* +*Defined in [web3-wrapper/src/web3_wrapper.ts:76](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/web3_wrapper.ts#L76)* A unit amount is defined as the amount of a token above the specified decimal places (integer part). E.g: If a currency has 18 decimal places, 1e18 or one quintillion of the currency is equivalent @@ -772,7 +830,7 @@ ___ ▸ **toWei**(`ethAmount`: `BigNumber`): *`BigNumber`* -*Defined in [web3-wrapper/src/web3_wrapper.ts:106](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/web3_wrapper.ts#L106)* +*Defined in [web3-wrapper/src/web3_wrapper.ts:106](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/web3_wrapper.ts#L106)* Convert an Ether amount from ETH to Wei @@ -799,7 +857,7 @@ Amount in wei • **Earliest**: = "earliest" -*Defined in [ethereum-types/src/index.ts:478](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L478)* +*Defined in [ethereum-types/src/index.ts:478](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L478)* ___ @@ -807,7 +865,7 @@ ___ • **Latest**: = "latest" -*Defined in [ethereum-types/src/index.ts:479](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L479)* +*Defined in [ethereum-types/src/index.ts:479](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L479)* ___ @@ -815,7 +873,7 @@ ___ • **Pending**: = "pending" -*Defined in [ethereum-types/src/index.ts:480](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L480)* +*Defined in [ethereum-types/src/index.ts:480](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L480)*
@@ -828,7 +886,7 @@ ___ • **Add**: = "ADD" -*Defined in [ethereum-types/src/index.ts:147](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L147)* +*Defined in [ethereum-types/src/index.ts:147](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L147)* ___ @@ -836,7 +894,7 @@ ___ • **AddMod**: = "ADDMOD" -*Defined in [ethereum-types/src/index.ts:154](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L154)* +*Defined in [ethereum-types/src/index.ts:154](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L154)* ___ @@ -844,7 +902,7 @@ ___ • **Address**: = "ADDRESS" -*Defined in [ethereum-types/src/index.ts:173](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L173)* +*Defined in [ethereum-types/src/index.ts:173](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L173)* ___ @@ -852,7 +910,7 @@ ___ • **And**: = "AND" -*Defined in [ethereum-types/src/index.ts:165](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L165)* +*Defined in [ethereum-types/src/index.ts:165](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L165)* ___ @@ -860,7 +918,7 @@ ___ • **Balance**: = "BALANCE" -*Defined in [ethereum-types/src/index.ts:174](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L174)* +*Defined in [ethereum-types/src/index.ts:174](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L174)* ___ @@ -868,7 +926,7 @@ ___ • **BlockHash**: = "BLOCKHASH" -*Defined in [ethereum-types/src/index.ts:189](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L189)* +*Defined in [ethereum-types/src/index.ts:189](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L189)* ___ @@ -876,7 +934,7 @@ ___ • **Byte**: = "BYTE" -*Defined in [ethereum-types/src/index.ts:169](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L169)* +*Defined in [ethereum-types/src/index.ts:169](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L169)* ___ @@ -884,7 +942,7 @@ ___ • **Call**: = "CALL" -*Defined in [ethereum-types/src/index.ts:282](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L282)* +*Defined in [ethereum-types/src/index.ts:282](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L282)* ___ @@ -892,7 +950,7 @@ ___ • **CallCode**: = "CALLCODE" -*Defined in [ethereum-types/src/index.ts:283](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L283)* +*Defined in [ethereum-types/src/index.ts:283](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L283)* ___ @@ -900,7 +958,7 @@ ___ • **CallDataCopy**: = "CALLDATACOPY" -*Defined in [ethereum-types/src/index.ts:180](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L180)* +*Defined in [ethereum-types/src/index.ts:180](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L180)* ___ @@ -908,7 +966,7 @@ ___ • **CallDataLoad**: = "CALLDATALOAD" -*Defined in [ethereum-types/src/index.ts:178](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L178)* +*Defined in [ethereum-types/src/index.ts:178](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L178)* ___ @@ -916,7 +974,7 @@ ___ • **CallDataSize**: = "CALLDATASIZE" -*Defined in [ethereum-types/src/index.ts:179](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L179)* +*Defined in [ethereum-types/src/index.ts:179](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L179)* ___ @@ -924,7 +982,7 @@ ___ • **CallValue**: = "CALLVALUE" -*Defined in [ethereum-types/src/index.ts:177](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L177)* +*Defined in [ethereum-types/src/index.ts:177](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L177)* ___ @@ -932,7 +990,7 @@ ___ • **Caller**: = "CALLER" -*Defined in [ethereum-types/src/index.ts:176](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L176)* +*Defined in [ethereum-types/src/index.ts:176](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L176)* ___ @@ -940,7 +998,7 @@ ___ • **CodeCopy**: = "CODECOPY" -*Defined in [ethereum-types/src/index.ts:182](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L182)* +*Defined in [ethereum-types/src/index.ts:182](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L182)* ___ @@ -948,7 +1006,7 @@ ___ • **CodeSize**: = "CODESIZE" -*Defined in [ethereum-types/src/index.ts:181](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L181)* +*Defined in [ethereum-types/src/index.ts:181](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L181)* ___ @@ -956,7 +1014,7 @@ ___ • **Coinbase**: = "COINBASE" -*Defined in [ethereum-types/src/index.ts:190](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L190)* +*Defined in [ethereum-types/src/index.ts:190](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L190)* ___ @@ -964,7 +1022,7 @@ ___ • **Create**: = "CREATE" -*Defined in [ethereum-types/src/index.ts:281](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L281)* +*Defined in [ethereum-types/src/index.ts:281](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L281)* ___ @@ -972,7 +1030,7 @@ ___ • **DelegateCall**: = "DELEGATECALL" -*Defined in [ethereum-types/src/index.ts:285](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L285)* +*Defined in [ethereum-types/src/index.ts:285](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L285)* ___ @@ -980,7 +1038,7 @@ ___ • **Difficulty**: = "DIFFICULTY" -*Defined in [ethereum-types/src/index.ts:193](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L193)* +*Defined in [ethereum-types/src/index.ts:193](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L193)* ___ @@ -988,7 +1046,7 @@ ___ • **Div**: = "DIV" -*Defined in [ethereum-types/src/index.ts:150](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L150)* +*Defined in [ethereum-types/src/index.ts:150](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L150)* ___ @@ -996,7 +1054,7 @@ ___ • **Dup1**: = "DUP1" -*Defined in [ethereum-types/src/index.ts:242](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L242)* +*Defined in [ethereum-types/src/index.ts:242](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L242)* ___ @@ -1004,7 +1062,7 @@ ___ • **Dup10**: = "DUP10" -*Defined in [ethereum-types/src/index.ts:251](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L251)* +*Defined in [ethereum-types/src/index.ts:251](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L251)* ___ @@ -1012,7 +1070,7 @@ ___ • **Dup11**: = "DUP11" -*Defined in [ethereum-types/src/index.ts:252](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L252)* +*Defined in [ethereum-types/src/index.ts:252](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L252)* ___ @@ -1020,7 +1078,7 @@ ___ • **Dup12**: = "DUP12" -*Defined in [ethereum-types/src/index.ts:253](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L253)* +*Defined in [ethereum-types/src/index.ts:253](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L253)* ___ @@ -1028,7 +1086,7 @@ ___ • **Dup13**: = "DUP13" -*Defined in [ethereum-types/src/index.ts:254](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L254)* +*Defined in [ethereum-types/src/index.ts:254](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L254)* ___ @@ -1036,7 +1094,7 @@ ___ • **Dup14**: = "DUP14" -*Defined in [ethereum-types/src/index.ts:255](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L255)* +*Defined in [ethereum-types/src/index.ts:255](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L255)* ___ @@ -1044,7 +1102,7 @@ ___ • **Dup15**: = "DUP15" -*Defined in [ethereum-types/src/index.ts:256](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L256)* +*Defined in [ethereum-types/src/index.ts:256](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L256)* ___ @@ -1052,7 +1110,7 @@ ___ • **Dup16**: = "DUP16" -*Defined in [ethereum-types/src/index.ts:257](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L257)* +*Defined in [ethereum-types/src/index.ts:257](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L257)* ___ @@ -1060,7 +1118,7 @@ ___ • **Dup2**: = "DUP2" -*Defined in [ethereum-types/src/index.ts:243](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L243)* +*Defined in [ethereum-types/src/index.ts:243](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L243)* ___ @@ -1068,7 +1126,7 @@ ___ • **Dup3**: = "DUP3" -*Defined in [ethereum-types/src/index.ts:244](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L244)* +*Defined in [ethereum-types/src/index.ts:244](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L244)* ___ @@ -1076,7 +1134,7 @@ ___ • **Dup4**: = "DUP4" -*Defined in [ethereum-types/src/index.ts:245](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L245)* +*Defined in [ethereum-types/src/index.ts:245](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L245)* ___ @@ -1084,7 +1142,7 @@ ___ • **Dup5**: = "DUP5" -*Defined in [ethereum-types/src/index.ts:246](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L246)* +*Defined in [ethereum-types/src/index.ts:246](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L246)* ___ @@ -1092,7 +1150,7 @@ ___ • **Dup6**: = "DUP6" -*Defined in [ethereum-types/src/index.ts:247](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L247)* +*Defined in [ethereum-types/src/index.ts:247](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L247)* ___ @@ -1100,7 +1158,7 @@ ___ • **Dup7**: = "DUP7" -*Defined in [ethereum-types/src/index.ts:248](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L248)* +*Defined in [ethereum-types/src/index.ts:248](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L248)* ___ @@ -1108,7 +1166,7 @@ ___ • **Dup8**: = "DUP8" -*Defined in [ethereum-types/src/index.ts:249](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L249)* +*Defined in [ethereum-types/src/index.ts:249](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L249)* ___ @@ -1116,7 +1174,7 @@ ___ • **Dup9**: = "DUP9" -*Defined in [ethereum-types/src/index.ts:250](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L250)* +*Defined in [ethereum-types/src/index.ts:250](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L250)* ___ @@ -1124,7 +1182,7 @@ ___ • **Eq**: = "EQ" -*Defined in [ethereum-types/src/index.ts:163](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L163)* +*Defined in [ethereum-types/src/index.ts:163](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L163)* ___ @@ -1132,7 +1190,7 @@ ___ • **Exp**: = "EXP" -*Defined in [ethereum-types/src/index.ts:156](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L156)* +*Defined in [ethereum-types/src/index.ts:156](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L156)* ___ @@ -1140,7 +1198,7 @@ ___ • **ExtCodeCopy**: = "EXTCODECOPY" -*Defined in [ethereum-types/src/index.ts:185](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L185)* +*Defined in [ethereum-types/src/index.ts:185](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L185)* ___ @@ -1148,7 +1206,7 @@ ___ • **ExtCodeSize**: = "EXTCODESIZE" -*Defined in [ethereum-types/src/index.ts:184](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L184)* +*Defined in [ethereum-types/src/index.ts:184](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L184)* ___ @@ -1156,7 +1214,7 @@ ___ • **Gas**: = "GAS" -*Defined in [ethereum-types/src/index.ts:206](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L206)* +*Defined in [ethereum-types/src/index.ts:206](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L206)* ___ @@ -1164,7 +1222,7 @@ ___ • **GasPrice**: = "GASPRICE" -*Defined in [ethereum-types/src/index.ts:183](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L183)* +*Defined in [ethereum-types/src/index.ts:183](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L183)* ___ @@ -1172,7 +1230,7 @@ ___ • **Gaslimit**: = "GASLIMIT" -*Defined in [ethereum-types/src/index.ts:194](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L194)* +*Defined in [ethereum-types/src/index.ts:194](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L194)* ___ @@ -1180,7 +1238,7 @@ ___ • **Gt**: = "GT" -*Defined in [ethereum-types/src/index.ts:160](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L160)* +*Defined in [ethereum-types/src/index.ts:160](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L160)* ___ @@ -1188,7 +1246,7 @@ ___ • **Invalid**: = "INVALID" -*Defined in [ethereum-types/src/index.ts:288](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L288)* +*Defined in [ethereum-types/src/index.ts:288](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L288)* ___ @@ -1196,7 +1254,7 @@ ___ • **IsZero**: = "ISZERO" -*Defined in [ethereum-types/src/index.ts:164](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L164)* +*Defined in [ethereum-types/src/index.ts:164](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L164)* ___ @@ -1204,7 +1262,7 @@ ___ • **Jump**: = "JUMP" -*Defined in [ethereum-types/src/index.ts:202](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L202)* +*Defined in [ethereum-types/src/index.ts:202](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L202)* ___ @@ -1212,7 +1270,7 @@ ___ • **JumpDest**: = "JUMPDEST" -*Defined in [ethereum-types/src/index.ts:207](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L207)* +*Defined in [ethereum-types/src/index.ts:207](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L207)* ___ @@ -1220,7 +1278,7 @@ ___ • **Jumpi**: = "JUMPI" -*Defined in [ethereum-types/src/index.ts:203](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L203)* +*Defined in [ethereum-types/src/index.ts:203](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L203)* ___ @@ -1228,7 +1286,7 @@ ___ • **Log1**: = "LOG1" -*Defined in [ethereum-types/src/index.ts:276](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L276)* +*Defined in [ethereum-types/src/index.ts:276](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L276)* ___ @@ -1236,7 +1294,7 @@ ___ • **Log2**: = "LOG2" -*Defined in [ethereum-types/src/index.ts:277](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L277)* +*Defined in [ethereum-types/src/index.ts:277](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L277)* ___ @@ -1244,7 +1302,7 @@ ___ • **Log3**: = "LOG3" -*Defined in [ethereum-types/src/index.ts:278](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L278)* +*Defined in [ethereum-types/src/index.ts:278](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L278)* ___ @@ -1252,7 +1310,7 @@ ___ • **Log4**: = "LOG4" -*Defined in [ethereum-types/src/index.ts:279](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L279)* +*Defined in [ethereum-types/src/index.ts:279](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L279)* ___ @@ -1260,7 +1318,7 @@ ___ • **Lt**: = "LT" -*Defined in [ethereum-types/src/index.ts:159](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L159)* +*Defined in [ethereum-types/src/index.ts:159](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L159)* ___ @@ -1268,7 +1326,7 @@ ___ • **MLoad**: = "MLOAD" -*Defined in [ethereum-types/src/index.ts:197](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L197)* +*Defined in [ethereum-types/src/index.ts:197](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L197)* ___ @@ -1276,7 +1334,7 @@ ___ • **MSize**: = "MSIZE" -*Defined in [ethereum-types/src/index.ts:205](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L205)* +*Defined in [ethereum-types/src/index.ts:205](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L205)* ___ @@ -1284,7 +1342,7 @@ ___ • **MStore**: = "MSTORE" -*Defined in [ethereum-types/src/index.ts:198](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L198)* +*Defined in [ethereum-types/src/index.ts:198](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L198)* ___ @@ -1292,7 +1350,7 @@ ___ • **MStore8**: = "MSTORE8" -*Defined in [ethereum-types/src/index.ts:199](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L199)* +*Defined in [ethereum-types/src/index.ts:199](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L199)* ___ @@ -1300,7 +1358,7 @@ ___ • **Mod**: = "MOD" -*Defined in [ethereum-types/src/index.ts:152](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L152)* +*Defined in [ethereum-types/src/index.ts:152](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L152)* ___ @@ -1308,7 +1366,7 @@ ___ • **Mul**: = "MUL" -*Defined in [ethereum-types/src/index.ts:148](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L148)* +*Defined in [ethereum-types/src/index.ts:148](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L148)* ___ @@ -1316,7 +1374,7 @@ ___ • **MulMod**: = "MULMOD" -*Defined in [ethereum-types/src/index.ts:155](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L155)* +*Defined in [ethereum-types/src/index.ts:155](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L155)* ___ @@ -1324,7 +1382,7 @@ ___ • **Not**: = "NOT" -*Defined in [ethereum-types/src/index.ts:168](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L168)* +*Defined in [ethereum-types/src/index.ts:168](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L168)* ___ @@ -1332,7 +1390,7 @@ ___ • **Number**: = "NUMBER" -*Defined in [ethereum-types/src/index.ts:192](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L192)* +*Defined in [ethereum-types/src/index.ts:192](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L192)* ___ @@ -1340,7 +1398,7 @@ ___ • **Or**: = "OR" -*Defined in [ethereum-types/src/index.ts:166](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L166)* +*Defined in [ethereum-types/src/index.ts:166](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L166)* ___ @@ -1348,7 +1406,7 @@ ___ • **Origin**: = "ORIGIN" -*Defined in [ethereum-types/src/index.ts:175](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L175)* +*Defined in [ethereum-types/src/index.ts:175](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L175)* ___ @@ -1356,7 +1414,7 @@ ___ • **Pc**: = "PC" -*Defined in [ethereum-types/src/index.ts:204](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L204)* +*Defined in [ethereum-types/src/index.ts:204](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L204)* ___ @@ -1364,7 +1422,7 @@ ___ • **Pop**: = "POP" -*Defined in [ethereum-types/src/index.ts:196](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L196)* +*Defined in [ethereum-types/src/index.ts:196](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L196)* ___ @@ -1372,7 +1430,7 @@ ___ • **Push1**: = "PUSH1" -*Defined in [ethereum-types/src/index.ts:209](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L209)* +*Defined in [ethereum-types/src/index.ts:209](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L209)* ___ @@ -1380,7 +1438,7 @@ ___ • **Push10**: = "PUSH10" -*Defined in [ethereum-types/src/index.ts:218](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L218)* +*Defined in [ethereum-types/src/index.ts:218](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L218)* ___ @@ -1388,7 +1446,7 @@ ___ • **Push11**: = "PUSH11" -*Defined in [ethereum-types/src/index.ts:219](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L219)* +*Defined in [ethereum-types/src/index.ts:219](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L219)* ___ @@ -1396,7 +1454,7 @@ ___ • **Push12**: = "PUSH12" -*Defined in [ethereum-types/src/index.ts:220](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L220)* +*Defined in [ethereum-types/src/index.ts:220](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L220)* ___ @@ -1404,7 +1462,7 @@ ___ • **Push13**: = "PUSH13" -*Defined in [ethereum-types/src/index.ts:221](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L221)* +*Defined in [ethereum-types/src/index.ts:221](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L221)* ___ @@ -1412,7 +1470,7 @@ ___ • **Push14**: = "PUSH14" -*Defined in [ethereum-types/src/index.ts:222](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L222)* +*Defined in [ethereum-types/src/index.ts:222](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L222)* ___ @@ -1420,7 +1478,7 @@ ___ • **Push15**: = "PUSH15" -*Defined in [ethereum-types/src/index.ts:223](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L223)* +*Defined in [ethereum-types/src/index.ts:223](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L223)* ___ @@ -1428,7 +1486,7 @@ ___ • **Push16**: = "PUSH16" -*Defined in [ethereum-types/src/index.ts:224](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L224)* +*Defined in [ethereum-types/src/index.ts:224](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L224)* ___ @@ -1436,7 +1494,7 @@ ___ • **Push17**: = "PUSH17" -*Defined in [ethereum-types/src/index.ts:225](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L225)* +*Defined in [ethereum-types/src/index.ts:225](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L225)* ___ @@ -1444,7 +1502,7 @@ ___ • **Push18**: = "PUSH18" -*Defined in [ethereum-types/src/index.ts:226](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L226)* +*Defined in [ethereum-types/src/index.ts:226](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L226)* ___ @@ -1452,7 +1510,7 @@ ___ • **Push19**: = "PUSH19" -*Defined in [ethereum-types/src/index.ts:227](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L227)* +*Defined in [ethereum-types/src/index.ts:227](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L227)* ___ @@ -1460,7 +1518,7 @@ ___ • **Push2**: = "PUSH2" -*Defined in [ethereum-types/src/index.ts:210](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L210)* +*Defined in [ethereum-types/src/index.ts:210](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L210)* ___ @@ -1468,7 +1526,7 @@ ___ • **Push20**: = "PUSH20" -*Defined in [ethereum-types/src/index.ts:228](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L228)* +*Defined in [ethereum-types/src/index.ts:228](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L228)* ___ @@ -1476,7 +1534,7 @@ ___ • **Push21**: = "PUSH21" -*Defined in [ethereum-types/src/index.ts:229](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L229)* +*Defined in [ethereum-types/src/index.ts:229](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L229)* ___ @@ -1484,7 +1542,7 @@ ___ • **Push22**: = "PUSH22" -*Defined in [ethereum-types/src/index.ts:230](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L230)* +*Defined in [ethereum-types/src/index.ts:230](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L230)* ___ @@ -1492,7 +1550,7 @@ ___ • **Push23**: = "PUSH23" -*Defined in [ethereum-types/src/index.ts:231](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L231)* +*Defined in [ethereum-types/src/index.ts:231](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L231)* ___ @@ -1500,7 +1558,7 @@ ___ • **Push24**: = "PUSH24" -*Defined in [ethereum-types/src/index.ts:232](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L232)* +*Defined in [ethereum-types/src/index.ts:232](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L232)* ___ @@ -1508,7 +1566,7 @@ ___ • **Push25**: = "PUSH25" -*Defined in [ethereum-types/src/index.ts:233](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L233)* +*Defined in [ethereum-types/src/index.ts:233](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L233)* ___ @@ -1516,7 +1574,7 @@ ___ • **Push26**: = "PUSH26" -*Defined in [ethereum-types/src/index.ts:234](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L234)* +*Defined in [ethereum-types/src/index.ts:234](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L234)* ___ @@ -1524,7 +1582,7 @@ ___ • **Push27**: = "PUSH27" -*Defined in [ethereum-types/src/index.ts:235](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L235)* +*Defined in [ethereum-types/src/index.ts:235](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L235)* ___ @@ -1532,7 +1590,7 @@ ___ • **Push28**: = "PUSH28" -*Defined in [ethereum-types/src/index.ts:236](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L236)* +*Defined in [ethereum-types/src/index.ts:236](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L236)* ___ @@ -1540,7 +1598,7 @@ ___ • **Push29**: = "PUSH29" -*Defined in [ethereum-types/src/index.ts:237](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L237)* +*Defined in [ethereum-types/src/index.ts:237](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L237)* ___ @@ -1548,7 +1606,7 @@ ___ • **Push3**: = "PUSH3" -*Defined in [ethereum-types/src/index.ts:211](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L211)* +*Defined in [ethereum-types/src/index.ts:211](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L211)* ___ @@ -1556,7 +1614,7 @@ ___ • **Push30**: = "PUSH30" -*Defined in [ethereum-types/src/index.ts:238](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L238)* +*Defined in [ethereum-types/src/index.ts:238](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L238)* ___ @@ -1564,7 +1622,7 @@ ___ • **Push31**: = "PUSH31" -*Defined in [ethereum-types/src/index.ts:239](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L239)* +*Defined in [ethereum-types/src/index.ts:239](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L239)* ___ @@ -1572,7 +1630,7 @@ ___ • **Push32**: = "PUSH32" -*Defined in [ethereum-types/src/index.ts:240](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L240)* +*Defined in [ethereum-types/src/index.ts:240](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L240)* ___ @@ -1580,7 +1638,7 @@ ___ • **Push4**: = "PUSH4" -*Defined in [ethereum-types/src/index.ts:212](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L212)* +*Defined in [ethereum-types/src/index.ts:212](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L212)* ___ @@ -1588,7 +1646,7 @@ ___ • **Push5**: = "PUSH5" -*Defined in [ethereum-types/src/index.ts:213](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L213)* +*Defined in [ethereum-types/src/index.ts:213](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L213)* ___ @@ -1596,7 +1654,7 @@ ___ • **Push6**: = "PUSH6" -*Defined in [ethereum-types/src/index.ts:214](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L214)* +*Defined in [ethereum-types/src/index.ts:214](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L214)* ___ @@ -1604,7 +1662,7 @@ ___ • **Push7**: = "PUSH7" -*Defined in [ethereum-types/src/index.ts:215](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L215)* +*Defined in [ethereum-types/src/index.ts:215](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L215)* ___ @@ -1612,7 +1670,7 @@ ___ • **Push8**: = "PUSH8" -*Defined in [ethereum-types/src/index.ts:216](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L216)* +*Defined in [ethereum-types/src/index.ts:216](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L216)* ___ @@ -1620,7 +1678,7 @@ ___ • **Push9**: = "PUSH9" -*Defined in [ethereum-types/src/index.ts:217](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L217)* +*Defined in [ethereum-types/src/index.ts:217](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L217)* ___ @@ -1628,7 +1686,7 @@ ___ • **Return**: = "RETURN" -*Defined in [ethereum-types/src/index.ts:284](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L284)* +*Defined in [ethereum-types/src/index.ts:284](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L284)* ___ @@ -1636,7 +1694,7 @@ ___ • **ReturnDataCopy**: = "RETURNDATACOPY" -*Defined in [ethereum-types/src/index.ts:187](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L187)* +*Defined in [ethereum-types/src/index.ts:187](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L187)* ___ @@ -1644,7 +1702,7 @@ ___ • **ReturnDataSize**: = "RETURNDATASIZE" -*Defined in [ethereum-types/src/index.ts:186](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L186)* +*Defined in [ethereum-types/src/index.ts:186](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L186)* ___ @@ -1652,7 +1710,7 @@ ___ • **Revert**: = "REVERT" -*Defined in [ethereum-types/src/index.ts:287](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L287)* +*Defined in [ethereum-types/src/index.ts:287](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L287)* ___ @@ -1660,7 +1718,7 @@ ___ • **SDiv**: = "SDIV" -*Defined in [ethereum-types/src/index.ts:151](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L151)* +*Defined in [ethereum-types/src/index.ts:151](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L151)* ___ @@ -1668,7 +1726,7 @@ ___ • **SGt**: = "SGT" -*Defined in [ethereum-types/src/index.ts:162](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L162)* +*Defined in [ethereum-types/src/index.ts:162](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L162)* ___ @@ -1676,7 +1734,7 @@ ___ • **SLoad**: = "SLOAD" -*Defined in [ethereum-types/src/index.ts:200](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L200)* +*Defined in [ethereum-types/src/index.ts:200](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L200)* ___ @@ -1684,7 +1742,7 @@ ___ • **SLt**: = "SLT" -*Defined in [ethereum-types/src/index.ts:161](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L161)* +*Defined in [ethereum-types/src/index.ts:161](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L161)* ___ @@ -1692,7 +1750,7 @@ ___ • **SMod**: = "SMOD" -*Defined in [ethereum-types/src/index.ts:153](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L153)* +*Defined in [ethereum-types/src/index.ts:153](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L153)* ___ @@ -1700,7 +1758,7 @@ ___ • **SStore**: = "SSTORE" -*Defined in [ethereum-types/src/index.ts:201](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L201)* +*Defined in [ethereum-types/src/index.ts:201](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L201)* ___ @@ -1708,7 +1766,7 @@ ___ • **SelfDestruct**: = "SELFDESTRUCT" -*Defined in [ethereum-types/src/index.ts:289](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L289)* +*Defined in [ethereum-types/src/index.ts:289](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L289)* ___ @@ -1716,7 +1774,7 @@ ___ • **Sha3**: = "SHA3" -*Defined in [ethereum-types/src/index.ts:171](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L171)* +*Defined in [ethereum-types/src/index.ts:171](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L171)* ___ @@ -1724,7 +1782,7 @@ ___ • **SignExtend**: = "SIGNEXTEND" -*Defined in [ethereum-types/src/index.ts:157](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L157)* +*Defined in [ethereum-types/src/index.ts:157](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L157)* ___ @@ -1732,7 +1790,7 @@ ___ • **StaticCall**: = "STATICCALL" -*Defined in [ethereum-types/src/index.ts:286](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L286)* +*Defined in [ethereum-types/src/index.ts:286](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L286)* ___ @@ -1740,7 +1798,7 @@ ___ • **Stop**: = "STOP" -*Defined in [ethereum-types/src/index.ts:146](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L146)* +*Defined in [ethereum-types/src/index.ts:146](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L146)* ___ @@ -1748,7 +1806,7 @@ ___ • **Sub**: = "SUB" -*Defined in [ethereum-types/src/index.ts:149](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L149)* +*Defined in [ethereum-types/src/index.ts:149](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L149)* ___ @@ -1756,7 +1814,7 @@ ___ • **Swap1**: = "SWAP1" -*Defined in [ethereum-types/src/index.ts:259](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L259)* +*Defined in [ethereum-types/src/index.ts:259](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L259)* ___ @@ -1764,7 +1822,7 @@ ___ • **Swap10**: = "SWAP10" -*Defined in [ethereum-types/src/index.ts:268](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L268)* +*Defined in [ethereum-types/src/index.ts:268](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L268)* ___ @@ -1772,7 +1830,7 @@ ___ • **Swap11**: = "SWAP11" -*Defined in [ethereum-types/src/index.ts:269](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L269)* +*Defined in [ethereum-types/src/index.ts:269](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L269)* ___ @@ -1780,7 +1838,7 @@ ___ • **Swap12**: = "SWAP12" -*Defined in [ethereum-types/src/index.ts:270](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L270)* +*Defined in [ethereum-types/src/index.ts:270](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L270)* ___ @@ -1788,7 +1846,7 @@ ___ • **Swap13**: = "SWAP13" -*Defined in [ethereum-types/src/index.ts:271](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L271)* +*Defined in [ethereum-types/src/index.ts:271](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L271)* ___ @@ -1796,7 +1854,7 @@ ___ • **Swap14**: = "SWAP14" -*Defined in [ethereum-types/src/index.ts:272](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L272)* +*Defined in [ethereum-types/src/index.ts:272](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L272)* ___ @@ -1804,7 +1862,7 @@ ___ • **Swap15**: = "SWAP15" -*Defined in [ethereum-types/src/index.ts:273](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L273)* +*Defined in [ethereum-types/src/index.ts:273](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L273)* ___ @@ -1812,7 +1870,7 @@ ___ • **Swap16**: = "SWAP16" -*Defined in [ethereum-types/src/index.ts:274](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L274)* +*Defined in [ethereum-types/src/index.ts:274](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L274)* ___ @@ -1820,7 +1878,7 @@ ___ • **Swap2**: = "SWAP2" -*Defined in [ethereum-types/src/index.ts:260](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L260)* +*Defined in [ethereum-types/src/index.ts:260](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L260)* ___ @@ -1828,7 +1886,7 @@ ___ • **Swap3**: = "SWAP3" -*Defined in [ethereum-types/src/index.ts:261](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L261)* +*Defined in [ethereum-types/src/index.ts:261](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L261)* ___ @@ -1836,7 +1894,7 @@ ___ • **Swap4**: = "SWAP4" -*Defined in [ethereum-types/src/index.ts:262](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L262)* +*Defined in [ethereum-types/src/index.ts:262](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L262)* ___ @@ -1844,7 +1902,7 @@ ___ • **Swap5**: = "SWAP5" -*Defined in [ethereum-types/src/index.ts:263](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L263)* +*Defined in [ethereum-types/src/index.ts:263](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L263)* ___ @@ -1852,7 +1910,7 @@ ___ • **Swap6**: = "SWAP6" -*Defined in [ethereum-types/src/index.ts:264](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L264)* +*Defined in [ethereum-types/src/index.ts:264](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L264)* ___ @@ -1860,7 +1918,7 @@ ___ • **Swap7**: = "SWAP7" -*Defined in [ethereum-types/src/index.ts:265](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L265)* +*Defined in [ethereum-types/src/index.ts:265](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L265)* ___ @@ -1868,7 +1926,7 @@ ___ • **Swap8**: = "SWAP8" -*Defined in [ethereum-types/src/index.ts:266](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L266)* +*Defined in [ethereum-types/src/index.ts:266](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L266)* ___ @@ -1876,7 +1934,7 @@ ___ • **Swap9**: = "SWAP9" -*Defined in [ethereum-types/src/index.ts:267](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L267)* +*Defined in [ethereum-types/src/index.ts:267](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L267)* ___ @@ -1884,7 +1942,7 @@ ___ • **TimeStamp**: = "TimeStamp" -*Defined in [ethereum-types/src/index.ts:191](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L191)* +*Defined in [ethereum-types/src/index.ts:191](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L191)* ___ @@ -1892,7 +1950,7 @@ ___ • **Xor**: = "XOR" -*Defined in [ethereum-types/src/index.ts:167](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L167)* +*Defined in [ethereum-types/src/index.ts:167](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L167)*
@@ -1907,7 +1965,7 @@ ___ • **Ganache**: = "GANACHE" -*Defined in [web3-wrapper/src/types.ts:91](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L91)* +*Defined in [web3-wrapper/src/types.ts:91](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L91)* ___ @@ -1915,7 +1973,7 @@ ___ • **Geth**: = "GETH" -*Defined in [web3-wrapper/src/types.ts:90](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L90)* +*Defined in [web3-wrapper/src/types.ts:90](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L90)*
@@ -1928,16 +1986,12 @@ ___ • **TransactionMiningTimeout**: = "TRANSACTION_MINING_TIMEOUT" -*Defined in [web3-wrapper/src/types.ts:2](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L2)* +*Defined in [web3-wrapper/src/types.ts:2](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L2)*
-
- - - # Interface: BlockWithoutTransactionData @@ -1951,7 +2005,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[difficulty](#difficulty)* -*Defined in [ethereum-types/src/index.ts:356](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L356)* +*Defined in [ethereum-types/src/index.ts:356](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L356)* ___ @@ -1961,7 +2015,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[extraData](#extradata)* -*Defined in [ethereum-types/src/index.ts:358](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L358)* +*Defined in [ethereum-types/src/index.ts:358](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L358)* ___ @@ -1971,7 +2025,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[gasLimit](#gaslimit)* -*Defined in [ethereum-types/src/index.ts:360](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L360)* +*Defined in [ethereum-types/src/index.ts:360](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L360)* ___ @@ -1981,7 +2035,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[gasUsed](#gasused)* -*Defined in [ethereum-types/src/index.ts:361](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L361)* +*Defined in [ethereum-types/src/index.ts:361](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L361)* ___ @@ -1991,7 +2045,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[hash](#hash)* -*Defined in [ethereum-types/src/index.ts:348](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L348)* +*Defined in [ethereum-types/src/index.ts:348](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L348)* ___ @@ -2001,7 +2055,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[logsBloom](#logsbloom)* -*Defined in [ethereum-types/src/index.ts:352](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L352)* +*Defined in [ethereum-types/src/index.ts:352](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L352)* ___ @@ -2011,7 +2065,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[miner](#miner)* -*Defined in [ethereum-types/src/index.ts:355](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L355)* +*Defined in [ethereum-types/src/index.ts:355](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L355)* ___ @@ -2021,7 +2075,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[nonce](#nonce)* -*Defined in [ethereum-types/src/index.ts:350](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L350)* +*Defined in [ethereum-types/src/index.ts:350](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L350)* ___ @@ -2031,7 +2085,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[number](#number)* -*Defined in [ethereum-types/src/index.ts:347](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L347)* +*Defined in [ethereum-types/src/index.ts:347](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L347)* ___ @@ -2041,7 +2095,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[parentHash](#parenthash)* -*Defined in [ethereum-types/src/index.ts:349](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L349)* +*Defined in [ethereum-types/src/index.ts:349](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L349)* ___ @@ -2051,7 +2105,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[sha3Uncles](#sha3uncles)* -*Defined in [ethereum-types/src/index.ts:351](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L351)* +*Defined in [ethereum-types/src/index.ts:351](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L351)* ___ @@ -2061,7 +2115,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[size](#size)* -*Defined in [ethereum-types/src/index.ts:359](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L359)* +*Defined in [ethereum-types/src/index.ts:359](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L359)* ___ @@ -2071,7 +2125,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[stateRoot](#stateroot)* -*Defined in [ethereum-types/src/index.ts:354](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L354)* +*Defined in [ethereum-types/src/index.ts:354](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L354)* ___ @@ -2081,7 +2135,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[timestamp](#timestamp)* -*Defined in [ethereum-types/src/index.ts:362](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L362)* +*Defined in [ethereum-types/src/index.ts:362](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L362)* ___ @@ -2091,7 +2145,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[totalDifficulty](#totaldifficulty)* -*Defined in [ethereum-types/src/index.ts:357](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L357)* +*Defined in [ethereum-types/src/index.ts:357](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L357)* ___ @@ -2099,7 +2153,7 @@ ___ • **transactions**: *string[]* -*Defined in [ethereum-types/src/index.ts:367](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L367)* +*Defined in [ethereum-types/src/index.ts:367](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L367)* ___ @@ -2109,7 +2163,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[transactionsRoot](#transactionsroot)* -*Defined in [ethereum-types/src/index.ts:353](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L353)* +*Defined in [ethereum-types/src/index.ts:353](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L353)* ___ @@ -2119,7 +2173,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[uncles](#uncles)* -*Defined in [ethereum-types/src/index.ts:363](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L363)* +*Defined in [ethereum-types/src/index.ts:363](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L363)*
@@ -2134,7 +2188,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[difficulty](#difficulty)* -*Defined in [ethereum-types/src/index.ts:356](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L356)* +*Defined in [ethereum-types/src/index.ts:356](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L356)* ___ @@ -2144,7 +2198,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[extraData](#extradata)* -*Defined in [ethereum-types/src/index.ts:358](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L358)* +*Defined in [ethereum-types/src/index.ts:358](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L358)* ___ @@ -2154,7 +2208,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[gasLimit](#gaslimit)* -*Defined in [ethereum-types/src/index.ts:360](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L360)* +*Defined in [ethereum-types/src/index.ts:360](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L360)* ___ @@ -2164,7 +2218,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[gasUsed](#gasused)* -*Defined in [ethereum-types/src/index.ts:361](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L361)* +*Defined in [ethereum-types/src/index.ts:361](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L361)* ___ @@ -2174,7 +2228,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[hash](#hash)* -*Defined in [ethereum-types/src/index.ts:348](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L348)* +*Defined in [ethereum-types/src/index.ts:348](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L348)* ___ @@ -2184,7 +2238,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[logsBloom](#logsbloom)* -*Defined in [ethereum-types/src/index.ts:352](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L352)* +*Defined in [ethereum-types/src/index.ts:352](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L352)* ___ @@ -2194,7 +2248,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[miner](#miner)* -*Defined in [ethereum-types/src/index.ts:355](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L355)* +*Defined in [ethereum-types/src/index.ts:355](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L355)* ___ @@ -2204,7 +2258,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[nonce](#nonce)* -*Defined in [ethereum-types/src/index.ts:350](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L350)* +*Defined in [ethereum-types/src/index.ts:350](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L350)* ___ @@ -2214,7 +2268,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[number](#number)* -*Defined in [ethereum-types/src/index.ts:347](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L347)* +*Defined in [ethereum-types/src/index.ts:347](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L347)* ___ @@ -2224,7 +2278,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[parentHash](#parenthash)* -*Defined in [ethereum-types/src/index.ts:349](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L349)* +*Defined in [ethereum-types/src/index.ts:349](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L349)* ___ @@ -2234,7 +2288,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[sha3Uncles](#sha3uncles)* -*Defined in [ethereum-types/src/index.ts:351](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L351)* +*Defined in [ethereum-types/src/index.ts:351](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L351)* ___ @@ -2244,7 +2298,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[size](#size)* -*Defined in [ethereum-types/src/index.ts:359](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L359)* +*Defined in [ethereum-types/src/index.ts:359](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L359)* ___ @@ -2254,7 +2308,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[stateRoot](#stateroot)* -*Defined in [ethereum-types/src/index.ts:354](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L354)* +*Defined in [ethereum-types/src/index.ts:354](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L354)* ___ @@ -2264,7 +2318,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[timestamp](#timestamp)* -*Defined in [ethereum-types/src/index.ts:362](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L362)* +*Defined in [ethereum-types/src/index.ts:362](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L362)* ___ @@ -2274,7 +2328,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[totalDifficulty](#totaldifficulty)* -*Defined in [ethereum-types/src/index.ts:357](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L357)* +*Defined in [ethereum-types/src/index.ts:357](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L357)* ___ @@ -2282,7 +2336,7 @@ ___ • **transactions**: *[Transaction](#class-transaction)[]* -*Defined in [ethereum-types/src/index.ts:371](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L371)* +*Defined in [ethereum-types/src/index.ts:371](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L371)* ___ @@ -2292,7 +2346,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[transactionsRoot](#transactionsroot)* -*Defined in [ethereum-types/src/index.ts:353](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L353)* +*Defined in [ethereum-types/src/index.ts:353](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L353)* ___ @@ -2302,7 +2356,7 @@ ___ *Inherited from [AbstractBlock](#interface-abstractblock).[uncles](#uncles)* -*Defined in [ethereum-types/src/index.ts:363](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L363)* +*Defined in [ethereum-types/src/index.ts:363](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L363)*
@@ -2317,7 +2371,7 @@ ___ *Inherited from [CallTxDataBase](#interface-calltxdatabase).[data](#optional-data)* -*Defined in [ethereum-types/src/index.ts:393](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L393)* +*Defined in [ethereum-types/src/index.ts:393](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L393)* ___ @@ -2325,7 +2379,7 @@ ___ • **from**? : *undefined | string* -*Defined in [ethereum-types/src/index.ts:402](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L402)* +*Defined in [ethereum-types/src/index.ts:402](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L402)* ___ @@ -2335,7 +2389,7 @@ ___ *Inherited from [CallTxDataBase](#interface-calltxdatabase).[gas](#optional-gas)* -*Defined in [ethereum-types/src/index.ts:391](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L391)* +*Defined in [ethereum-types/src/index.ts:391](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L391)* ___ @@ -2345,7 +2399,7 @@ ___ *Inherited from [CallTxDataBase](#interface-calltxdatabase).[gasPrice](#optional-gasprice)* -*Defined in [ethereum-types/src/index.ts:392](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L392)* +*Defined in [ethereum-types/src/index.ts:392](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L392)* ___ @@ -2355,7 +2409,7 @@ ___ *Inherited from [CallTxDataBase](#interface-calltxdatabase).[nonce](#optional-nonce)* -*Defined in [ethereum-types/src/index.ts:394](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L394)* +*Defined in [ethereum-types/src/index.ts:394](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L394)* ___ @@ -2365,7 +2419,7 @@ ___ *Inherited from [CallTxDataBase](#interface-calltxdatabase).[to](#optional-to)* -*Defined in [ethereum-types/src/index.ts:389](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L389)* +*Defined in [ethereum-types/src/index.ts:389](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L389)* ___ @@ -2375,7 +2429,7 @@ ___ *Inherited from [CallTxDataBase](#interface-calltxdatabase).[value](#optional-value)* -*Defined in [ethereum-types/src/index.ts:390](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L390)* +*Defined in [ethereum-types/src/index.ts:390](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L390)*
@@ -2398,7 +2452,7 @@ ___ • **inputs**: *[DataItem](#class-dataitem)[]* -*Defined in [ethereum-types/src/index.ts:103](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L103)* +*Defined in [ethereum-types/src/index.ts:103](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L103)* ___ @@ -2406,7 +2460,7 @@ ___ • **payable**: *boolean* -*Defined in [ethereum-types/src/index.ts:104](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L104)* +*Defined in [ethereum-types/src/index.ts:104](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L104)* ___ @@ -2414,7 +2468,7 @@ ___ • **stateMutability**: *[ConstructorStateMutability](#constructorstatemutability)* -*Defined in [ethereum-types/src/index.ts:105](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L105)* +*Defined in [ethereum-types/src/index.ts:105](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L105)* ___ @@ -2422,7 +2476,7 @@ ___ • **type**: *string* -*Defined in [ethereum-types/src/index.ts:102](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L102)* +*Defined in [ethereum-types/src/index.ts:102](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L102)*
@@ -2441,7 +2495,7 @@ ___ • **components**? : *[DataItem](#class-dataitem)[]* -*Defined in [ethereum-types/src/index.ts:137](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L137)* +*Defined in [ethereum-types/src/index.ts:137](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L137)* ___ @@ -2449,7 +2503,7 @@ ___ • **name**: *string* -*Defined in [ethereum-types/src/index.ts:135](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L135)* +*Defined in [ethereum-types/src/index.ts:135](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L135)* ___ @@ -2457,7 +2511,7 @@ ___ • **type**: *string* -*Defined in [ethereum-types/src/index.ts:136](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L136)* +*Defined in [ethereum-types/src/index.ts:136](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L136)*
@@ -2477,7 +2531,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[address](#address)* -*Defined in [ethereum-types/src/index.ts:434](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L434)* +*Defined in [ethereum-types/src/index.ts:434](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L434)* ___ @@ -2485,7 +2539,7 @@ ___ • **args**: *`A`* -*Defined in [ethereum-types/src/index.ts:417](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L417)* +*Defined in [ethereum-types/src/index.ts:417](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L417)* ___ @@ -2495,7 +2549,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[blockHash](#blockhash)* -*Defined in [ethereum-types/src/index.ts:432](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L432)* +*Defined in [ethereum-types/src/index.ts:432](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L432)* ___ @@ -2505,7 +2559,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[blockNumber](#blocknumber)* -*Defined in [ethereum-types/src/index.ts:433](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L433)* +*Defined in [ethereum-types/src/index.ts:433](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L433)* ___ @@ -2515,7 +2569,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[data](#data)* -*Defined in [ethereum-types/src/index.ts:435](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L435)* +*Defined in [ethereum-types/src/index.ts:435](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L435)* ___ @@ -2523,7 +2577,7 @@ ___ • **event**: *string* -*Defined in [ethereum-types/src/index.ts:416](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L416)* +*Defined in [ethereum-types/src/index.ts:416](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L416)* ___ @@ -2533,7 +2587,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[logIndex](#logindex)* -*Defined in [ethereum-types/src/index.ts:429](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L429)* +*Defined in [ethereum-types/src/index.ts:429](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L429)* ___ @@ -2543,7 +2597,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[topics](#topics)* -*Defined in [ethereum-types/src/index.ts:436](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L436)* +*Defined in [ethereum-types/src/index.ts:436](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L436)* ___ @@ -2553,7 +2607,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[transactionHash](#transactionhash)* -*Defined in [ethereum-types/src/index.ts:431](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L431)* +*Defined in [ethereum-types/src/index.ts:431](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L431)* ___ @@ -2563,7 +2617,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[transactionIndex](#transactionindex)* -*Defined in [ethereum-types/src/index.ts:430](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L430)* +*Defined in [ethereum-types/src/index.ts:430](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L430)*
@@ -2582,7 +2636,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[address](#address)* -*Defined in [ethereum-types/src/index.ts:434](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L434)* +*Defined in [ethereum-types/src/index.ts:434](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L434)* ___ @@ -2592,7 +2646,7 @@ ___ *Inherited from [DecodedLogEntry](#interface-decodedlogentry).[args](#args)* -*Defined in [ethereum-types/src/index.ts:417](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L417)* +*Defined in [ethereum-types/src/index.ts:417](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L417)* ___ @@ -2602,7 +2656,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[blockHash](#blockhash)* -*Defined in [ethereum-types/src/index.ts:432](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L432)* +*Defined in [ethereum-types/src/index.ts:432](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L432)* ___ @@ -2612,7 +2666,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[blockNumber](#blocknumber)* -*Defined in [ethereum-types/src/index.ts:433](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L433)* +*Defined in [ethereum-types/src/index.ts:433](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L433)* ___ @@ -2622,7 +2676,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[data](#data)* -*Defined in [ethereum-types/src/index.ts:435](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L435)* +*Defined in [ethereum-types/src/index.ts:435](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L435)* ___ @@ -2632,7 +2686,7 @@ ___ *Inherited from [DecodedLogEntry](#interface-decodedlogentry).[event](#event)* -*Defined in [ethereum-types/src/index.ts:416](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L416)* +*Defined in [ethereum-types/src/index.ts:416](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L416)* ___ @@ -2642,7 +2696,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[logIndex](#logindex)* -*Defined in [ethereum-types/src/index.ts:429](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L429)* +*Defined in [ethereum-types/src/index.ts:429](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L429)* ___ @@ -2650,7 +2704,7 @@ ___ • **removed**: *boolean* -*Defined in [ethereum-types/src/index.ts:421](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L421)* +*Defined in [ethereum-types/src/index.ts:421](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L421)* ___ @@ -2660,7 +2714,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[topics](#topics)* -*Defined in [ethereum-types/src/index.ts:436](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L436)* +*Defined in [ethereum-types/src/index.ts:436](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L436)* ___ @@ -2670,7 +2724,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[transactionHash](#transactionhash)* -*Defined in [ethereum-types/src/index.ts:431](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L431)* +*Defined in [ethereum-types/src/index.ts:431](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L431)* ___ @@ -2680,7 +2734,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[transactionIndex](#transactionindex)* -*Defined in [ethereum-types/src/index.ts:430](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L430)* +*Defined in [ethereum-types/src/index.ts:430](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L430)*
@@ -2695,7 +2749,7 @@ ___ • **isEIP1193**: *boolean* -*Defined in [ethereum-types/src/index.ts:73](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L73)* +*Defined in [ethereum-types/src/index.ts:73](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L73)* ## Methods @@ -2703,7 +2757,7 @@ ___ ▸ **on**(`event`: [EIP1193Event](#eip1193event), `listener`: function): *this* -*Defined in [ethereum-types/src/index.ts:75](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L75)* +*Defined in [ethereum-types/src/index.ts:75](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L75)* **Parameters:** @@ -2727,7 +2781,7 @@ ___ ▸ **send**(`method`: string, `params?`: any[]): *`Promise`* -*Defined in [ethereum-types/src/index.ts:74](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L74)* +*Defined in [ethereum-types/src/index.ts:74](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L74)* **Parameters:** @@ -2749,7 +2803,7 @@ Name | Type | • **anonymous**: *boolean* -*Defined in [ethereum-types/src/index.ts:131](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L131)* +*Defined in [ethereum-types/src/index.ts:131](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L131)* ___ @@ -2757,7 +2811,7 @@ ___ • **inputs**: *[EventParameter](#class-eventparameter)[]* -*Defined in [ethereum-types/src/index.ts:130](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L130)* +*Defined in [ethereum-types/src/index.ts:130](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L130)* ___ @@ -2765,7 +2819,7 @@ ___ • **name**: *string* -*Defined in [ethereum-types/src/index.ts:129](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L129)* +*Defined in [ethereum-types/src/index.ts:129](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L129)* ___ @@ -2773,7 +2827,7 @@ ___ • **type**: *string* -*Defined in [ethereum-types/src/index.ts:128](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L128)* +*Defined in [ethereum-types/src/index.ts:128](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L128)*
@@ -2788,7 +2842,7 @@ ___ *Inherited from [DataItem](#interface-dataitem).[components](#optional-components)* -*Defined in [ethereum-types/src/index.ts:137](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L137)* +*Defined in [ethereum-types/src/index.ts:137](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L137)* ___ @@ -2796,7 +2850,7 @@ ___ • **indexed**: *boolean* -*Defined in [ethereum-types/src/index.ts:116](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L116)* +*Defined in [ethereum-types/src/index.ts:116](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L116)* ___ @@ -2806,7 +2860,7 @@ ___ *Inherited from [DataItem](#interface-dataitem).[name](#name)* -*Defined in [ethereum-types/src/index.ts:135](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L135)* +*Defined in [ethereum-types/src/index.ts:135](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L135)* ___ @@ -2816,7 +2870,7 @@ ___ *Inherited from [DataItem](#interface-dataitem).[type](#type)* -*Defined in [ethereum-types/src/index.ts:136](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L136)* +*Defined in [ethereum-types/src/index.ts:136](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L136)*
@@ -2833,7 +2887,7 @@ ___ • **payable**: *boolean* -*Defined in [ethereum-types/src/index.ts:112](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L112)* +*Defined in [ethereum-types/src/index.ts:112](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L112)* ___ @@ -2841,7 +2895,7 @@ ___ • **type**: *string* -*Defined in [ethereum-types/src/index.ts:111](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L111)* +*Defined in [ethereum-types/src/index.ts:111](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L111)*
@@ -2854,7 +2908,7 @@ ___ • **address**? : *undefined | string* -*Defined in [ethereum-types/src/index.ts:409](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L409)* +*Defined in [ethereum-types/src/index.ts:409](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L409)* ___ @@ -2862,7 +2916,7 @@ ___ • **blockHash**? : *undefined | string* -*Defined in [ethereum-types/src/index.ts:408](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L408)* +*Defined in [ethereum-types/src/index.ts:408](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L408)* ___ @@ -2870,7 +2924,7 @@ ___ • **fromBlock**? : *number | string* -*Defined in [ethereum-types/src/index.ts:406](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L406)* +*Defined in [ethereum-types/src/index.ts:406](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L406)* ___ @@ -2878,7 +2932,7 @@ ___ • **toBlock**? : *number | string* -*Defined in [ethereum-types/src/index.ts:407](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L407)* +*Defined in [ethereum-types/src/index.ts:407](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L407)* ___ @@ -2886,7 +2940,7 @@ ___ • **topics**? : *[LogTopic](#logtopic)[]* -*Defined in [ethereum-types/src/index.ts:410](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L410)* +*Defined in [ethereum-types/src/index.ts:410](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L410)*
@@ -2899,7 +2953,7 @@ ___ ▸ **sendAsync**(`payload`: [JSONRPCRequestPayload](_ethereum_types_src_index_.jsonrpcrequestpayload.md), `callback`: [JSONRPCErrorCallback](#jsonrpcerrorcallback)): *void* -*Defined in [ethereum-types/src/index.ts:14](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L14)* +*Defined in [ethereum-types/src/index.ts:14](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L14)* **Parameters:** @@ -2923,7 +2977,7 @@ Name | Type | • **id**: *number* -*Defined in [ethereum-types/src/index.ts:330](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L330)* +*Defined in [ethereum-types/src/index.ts:330](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L330)* ___ @@ -2931,7 +2985,7 @@ ___ • **jsonrpc**: *string* -*Defined in [ethereum-types/src/index.ts:331](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L331)* +*Defined in [ethereum-types/src/index.ts:331](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L331)* ___ @@ -2939,7 +2993,7 @@ ___ • **method**: *string* -*Defined in [ethereum-types/src/index.ts:329](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L329)* +*Defined in [ethereum-types/src/index.ts:329](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L329)* ___ @@ -2947,7 +3001,7 @@ ___ • **params**: *any[]* -*Defined in [ethereum-types/src/index.ts:328](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L328)* +*Defined in [ethereum-types/src/index.ts:328](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L328)*
@@ -2960,7 +3014,7 @@ ___ • **code**: *number* -*Defined in [ethereum-types/src/index.ts:336](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L336)* +*Defined in [ethereum-types/src/index.ts:336](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L336)* ___ @@ -2968,102 +3022,44 @@ ___ • **message**: *string* -*Defined in [ethereum-types/src/index.ts:335](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L335)* +*Defined in [ethereum-types/src/index.ts:335](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L335)*
-# Class: AbiDecoder - -AbiDecoder allows you to decode event logs given a set of supplied contract ABI's. It takes the contract's event -signature from the ABI and attempts to decode the logs using it. - - -## Constructors - - - -\+ **new AbiDecoder**(`abiArrays`: [AbiDefinition](#abidefinition)[][]): *[AbiDecoder](#class-abidecoder)* - -*Defined in [utils/src/abi_decoder.ts:42](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/utils/src/abi_decoder.ts#L42)* - -Instantiate an AbiDecoder - -**Parameters:** - -Name | Type | Description | ------- | ------ | ------ | -`abiArrays` | [AbiDefinition](#abidefinition)[][] | An array of contract ABI's | - -**Returns:** *[AbiDecoder](#class-abidecoder)* - -AbiDecoder instance - -## Methods - -### addABI - -▸ **addABI**(`abiArray`: [AbiDefinition](#abidefinition)[], `contractName?`: undefined | string): *void* +# Interface: JSONRPCResponsePayload -*Defined in [utils/src/abi_decoder.ts:158](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/utils/src/abi_decoder.ts#L158)* -Adds a set of ABI definitions, after which calldata and logs targeting these ABI's can be decoded. -Additional properties can be included to disambiguate similar ABI's. For example, if two functions -have the same signature but different parameter names, then their ABI definitions can be disambiguated -by specifying a contract name. +## Properties -**Parameters:** +### `Optional` error -Name | Type | Description | ------- | ------ | ------ | -`abiArray` | [AbiDefinition](#abidefinition)[] | - | -`contractName?` | undefined \| string | Name of contract that encapsulates the ABI definitions (optional). This can be used when decoding calldata to disambiguate methods with the same signature but different parameter names. | +• **error**? : *[JSONRPCResponseError](#class-jsonrpcresponseerror)* -**Returns:** *void* +*Defined in [ethereum-types/src/index.ts:343](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L343)* ___ -### decodeCalldataOrThrow - -▸ **decodeCalldataOrThrow**(`calldata`: string, `contractName?`: undefined | string): *`DecodedCalldata`* - -*Defined in [utils/src/abi_decoder.ts:118](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/utils/src/abi_decoder.ts#L118)* - -Decodes calldata for a known ABI. - -**Parameters:** - -Name | Type | Description | ------- | ------ | ------ | -`calldata` | string | hex-encoded calldata. | -`contractName?` | undefined \| string | used to disambiguate similar ABI's (optional). | +### id -**Returns:** *`DecodedCalldata`* +• **id**: *number* -Decoded calldata. Includes: function name and signature, along with the decoded arguments. +*Defined in [ethereum-types/src/index.ts:341](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L341)* ___ -### tryToDecodeLogOrNoop - -▸ **tryToDecodeLogOrNoop**<**ArgsType**>(`log`: `LogEntry`): *`LogWithDecodedArgs` | [RawLog](#rawlog)* - -*Defined in [utils/src/abi_decoder.ts:58](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/utils/src/abi_decoder.ts#L58)* - -Attempt to decode a log given the ABI's the AbiDecoder knows about. +### jsonrpc -**Type parameters:** +• **jsonrpc**: *string* -▪ **ArgsType**: *`DecodedLogArgs`* +*Defined in [ethereum-types/src/index.ts:342](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L342)* -**Parameters:** +___ -Name | Type | Description | ------- | ------ | ------ | -`log` | `LogEntry` | The log to attempt to decode | +### result -**Returns:** *`LogWithDecodedArgs` | [RawLog](#rawlog)* +• **result**: *any* -The decoded log if the requisite ABI was available. Otherwise the log unaltered. +*Defined in [ethereum-types/src/index.ts:340](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L340)*
@@ -3076,7 +3072,7 @@ The decoded log if the requisite ABI was available. Otherwise the log unaltered. • **address**: *string* -*Defined in [ethereum-types/src/index.ts:434](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L434)* +*Defined in [ethereum-types/src/index.ts:434](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L434)* ___ @@ -3084,7 +3080,7 @@ ___ • **blockHash**: *string | null* -*Defined in [ethereum-types/src/index.ts:432](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L432)* +*Defined in [ethereum-types/src/index.ts:432](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L432)* ___ @@ -3092,7 +3088,7 @@ ___ • **blockNumber**: *number | null* -*Defined in [ethereum-types/src/index.ts:433](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L433)* +*Defined in [ethereum-types/src/index.ts:433](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L433)* ___ @@ -3100,7 +3096,7 @@ ___ • **data**: *string* -*Defined in [ethereum-types/src/index.ts:435](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L435)* +*Defined in [ethereum-types/src/index.ts:435](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L435)* ___ @@ -3108,7 +3104,7 @@ ___ • **logIndex**: *number | null* -*Defined in [ethereum-types/src/index.ts:429](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L429)* +*Defined in [ethereum-types/src/index.ts:429](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L429)* ___ @@ -3116,7 +3112,7 @@ ___ • **topics**: *string[]* -*Defined in [ethereum-types/src/index.ts:436](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L436)* +*Defined in [ethereum-types/src/index.ts:436](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L436)* ___ @@ -3124,7 +3120,7 @@ ___ • **transactionHash**: *string* -*Defined in [ethereum-types/src/index.ts:431](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L431)* +*Defined in [ethereum-types/src/index.ts:431](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L431)* ___ @@ -3132,7 +3128,7 @@ ___ • **transactionIndex**: *number | null* -*Defined in [ethereum-types/src/index.ts:430](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L430)* +*Defined in [ethereum-types/src/index.ts:430](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L430)*
@@ -3147,7 +3143,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[address](#address)* -*Defined in [ethereum-types/src/index.ts:434](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L434)* +*Defined in [ethereum-types/src/index.ts:434](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L434)* ___ @@ -3157,7 +3153,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[blockHash](#blockhash)* -*Defined in [ethereum-types/src/index.ts:432](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L432)* +*Defined in [ethereum-types/src/index.ts:432](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L432)* ___ @@ -3167,7 +3163,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[blockNumber](#blocknumber)* -*Defined in [ethereum-types/src/index.ts:433](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L433)* +*Defined in [ethereum-types/src/index.ts:433](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L433)* ___ @@ -3177,7 +3173,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[data](#data)* -*Defined in [ethereum-types/src/index.ts:435](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L435)* +*Defined in [ethereum-types/src/index.ts:435](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L435)* ___ @@ -3187,7 +3183,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[logIndex](#logindex)* -*Defined in [ethereum-types/src/index.ts:429](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L429)* +*Defined in [ethereum-types/src/index.ts:429](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L429)* ___ @@ -3195,7 +3191,7 @@ ___ • **removed**: *boolean* -*Defined in [ethereum-types/src/index.ts:425](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L425)* +*Defined in [ethereum-types/src/index.ts:425](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L425)* ___ @@ -3205,7 +3201,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[topics](#topics)* -*Defined in [ethereum-types/src/index.ts:436](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L436)* +*Defined in [ethereum-types/src/index.ts:436](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L436)* ___ @@ -3215,7 +3211,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[transactionHash](#transactionhash)* -*Defined in [ethereum-types/src/index.ts:431](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L431)* +*Defined in [ethereum-types/src/index.ts:431](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L431)* ___ @@ -3225,7 +3221,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[transactionIndex](#transactionindex)* -*Defined in [ethereum-types/src/index.ts:430](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L430)* +*Defined in [ethereum-types/src/index.ts:430](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L430)*
@@ -3244,7 +3240,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[address](#address)* -*Defined in [ethereum-types/src/index.ts:434](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L434)* +*Defined in [ethereum-types/src/index.ts:434](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L434)* ___ @@ -3254,7 +3250,7 @@ ___ *Inherited from [DecodedLogEntry](#interface-decodedlogentry).[args](#args)* -*Defined in [ethereum-types/src/index.ts:417](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L417)* +*Defined in [ethereum-types/src/index.ts:417](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L417)* ___ @@ -3264,7 +3260,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[blockHash](#blockhash)* -*Defined in [ethereum-types/src/index.ts:432](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L432)* +*Defined in [ethereum-types/src/index.ts:432](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L432)* ___ @@ -3274,7 +3270,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[blockNumber](#blocknumber)* -*Defined in [ethereum-types/src/index.ts:433](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L433)* +*Defined in [ethereum-types/src/index.ts:433](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L433)* ___ @@ -3284,7 +3280,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[data](#data)* -*Defined in [ethereum-types/src/index.ts:435](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L435)* +*Defined in [ethereum-types/src/index.ts:435](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L435)* ___ @@ -3294,7 +3290,7 @@ ___ *Inherited from [DecodedLogEntry](#interface-decodedlogentry).[event](#event)* -*Defined in [ethereum-types/src/index.ts:416](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L416)* +*Defined in [ethereum-types/src/index.ts:416](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L416)* ___ @@ -3304,7 +3300,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[logIndex](#logindex)* -*Defined in [ethereum-types/src/index.ts:429](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L429)* +*Defined in [ethereum-types/src/index.ts:429](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L429)* ___ @@ -3314,7 +3310,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[topics](#topics)* -*Defined in [ethereum-types/src/index.ts:436](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L436)* +*Defined in [ethereum-types/src/index.ts:436](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L436)* ___ @@ -3324,7 +3320,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[transactionHash](#transactionhash)* -*Defined in [ethereum-types/src/index.ts:431](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L431)* +*Defined in [ethereum-types/src/index.ts:431](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L431)* ___ @@ -3334,7 +3330,7 @@ ___ *Inherited from [LogEntry](#interface-logentry).[transactionIndex](#transactionindex)* -*Defined in [ethereum-types/src/index.ts:430](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L430)* +*Defined in [ethereum-types/src/index.ts:430](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L430)*
@@ -3347,7 +3343,7 @@ ___ • **constant**: *boolean* -*Defined in [ethereum-types/src/index.ts:94](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L94)* +*Defined in [ethereum-types/src/index.ts:94](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L94)* ___ @@ -3355,7 +3351,7 @@ ___ • **inputs**: *[DataItem](#class-dataitem)[]* -*Defined in [ethereum-types/src/index.ts:92](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L92)* +*Defined in [ethereum-types/src/index.ts:92](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L92)* ___ @@ -3363,7 +3359,7 @@ ___ • **name**: *string* -*Defined in [ethereum-types/src/index.ts:91](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L91)* +*Defined in [ethereum-types/src/index.ts:91](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L91)* ___ @@ -3371,7 +3367,7 @@ ___ • **outputs**: *[DataItem](#class-dataitem)[]* -*Defined in [ethereum-types/src/index.ts:93](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L93)* +*Defined in [ethereum-types/src/index.ts:93](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L93)* ___ @@ -3379,7 +3375,7 @@ ___ • **payable**: *boolean* -*Defined in [ethereum-types/src/index.ts:96](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L96)* +*Defined in [ethereum-types/src/index.ts:96](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L96)* ___ @@ -3387,7 +3383,7 @@ ___ • **stateMutability**: *[StateMutability](#statemutability)* -*Defined in [ethereum-types/src/index.ts:95](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L95)* +*Defined in [ethereum-types/src/index.ts:95](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L95)* ___ @@ -3395,7 +3391,7 @@ ___ • **type**: *string* -*Defined in [ethereum-types/src/index.ts:90](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L90)* +*Defined in [ethereum-types/src/index.ts:90](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L90)*
@@ -3412,7 +3408,7 @@ ___ • **address**: *string* -*Defined in [ethereum-types/src/index.ts:491](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L491)* +*Defined in [ethereum-types/src/index.ts:491](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L491)* ___ @@ -3420,7 +3416,7 @@ ___ • **blockHash**: *string | null* -*Defined in [ethereum-types/src/index.ts:489](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L489)* +*Defined in [ethereum-types/src/index.ts:489](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L489)* ___ @@ -3428,7 +3424,7 @@ ___ • **blockNumber**: *string | null* -*Defined in [ethereum-types/src/index.ts:490](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L490)* +*Defined in [ethereum-types/src/index.ts:490](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L490)* ___ @@ -3436,7 +3432,7 @@ ___ • **data**: *string* -*Defined in [ethereum-types/src/index.ts:492](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L492)* +*Defined in [ethereum-types/src/index.ts:492](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L492)* ___ @@ -3444,7 +3440,7 @@ ___ • **logIndex**: *string | null* -*Defined in [ethereum-types/src/index.ts:486](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L486)* +*Defined in [ethereum-types/src/index.ts:486](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L486)* ___ @@ -3452,7 +3448,7 @@ ___ • **topics**: *string[]* -*Defined in [ethereum-types/src/index.ts:493](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L493)* +*Defined in [ethereum-types/src/index.ts:493](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L493)* ___ @@ -3460,7 +3456,7 @@ ___ • **transactionHash**: *string* -*Defined in [ethereum-types/src/index.ts:488](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L488)* +*Defined in [ethereum-types/src/index.ts:488](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L488)* ___ @@ -3468,7 +3464,7 @@ ___ • **transactionIndex**: *string | null* -*Defined in [ethereum-types/src/index.ts:487](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L487)* +*Defined in [ethereum-types/src/index.ts:487](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L487)*
@@ -3481,7 +3477,7 @@ ___ • **arguments**? : *[DataItem](#class-dataitem)[]* -*Defined in [ethereum-types/src/index.ts:122](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L122)* +*Defined in [ethereum-types/src/index.ts:122](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L122)* ___ @@ -3489,7 +3485,7 @@ ___ • **name**: *string* -*Defined in [ethereum-types/src/index.ts:121](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L121)* +*Defined in [ethereum-types/src/index.ts:121](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L121)* ___ @@ -3497,7 +3493,7 @@ ___ • **type**: *"error"* -*Defined in [ethereum-types/src/index.ts:120](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L120)* +*Defined in [ethereum-types/src/index.ts:120](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L120)*
@@ -3520,7 +3516,7 @@ ___ • **depth**: *number* -*Defined in [ethereum-types/src/index.ts:293](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L293)* +*Defined in [ethereum-types/src/index.ts:293](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L293)* ___ @@ -3528,7 +3524,7 @@ ___ • **error**: *string* -*Defined in [ethereum-types/src/index.ts:294](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L294)* +*Defined in [ethereum-types/src/index.ts:294](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L294)* ___ @@ -3536,7 +3532,7 @@ ___ • **gas**: *number* -*Defined in [ethereum-types/src/index.ts:295](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L295)* +*Defined in [ethereum-types/src/index.ts:295](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L295)* ___ @@ -3544,7 +3540,7 @@ ___ • **gasCost**: *number* -*Defined in [ethereum-types/src/index.ts:296](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L296)* +*Defined in [ethereum-types/src/index.ts:296](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L296)* ___ @@ -3552,7 +3548,7 @@ ___ • **memory**: *string[]* -*Defined in [ethereum-types/src/index.ts:297](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L297)* +*Defined in [ethereum-types/src/index.ts:297](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L297)* ___ @@ -3560,7 +3556,7 @@ ___ • **op**: *[OpCode](#enumeration-opcode)* -*Defined in [ethereum-types/src/index.ts:298](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L298)* +*Defined in [ethereum-types/src/index.ts:298](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L298)* ___ @@ -3568,7 +3564,7 @@ ___ • **pc**: *number* -*Defined in [ethereum-types/src/index.ts:299](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L299)* +*Defined in [ethereum-types/src/index.ts:299](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L299)* ___ @@ -3576,7 +3572,7 @@ ___ • **stack**: *string[]* -*Defined in [ethereum-types/src/index.ts:300](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L300)* +*Defined in [ethereum-types/src/index.ts:300](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L300)* ___ @@ -3584,7 +3580,7 @@ ___ • **storage**: *object* -*Defined in [ethereum-types/src/index.ts:301](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L301)* +*Defined in [ethereum-types/src/index.ts:301](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L301)* #### Type declaration: @@ -3601,7 +3597,7 @@ ___ • **disableMemory**? : *undefined | false | true* -*Defined in [ethereum-types/src/index.ts:518](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L518)* +*Defined in [ethereum-types/src/index.ts:518](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L518)* ___ @@ -3609,7 +3605,7 @@ ___ • **disableStack**? : *undefined | false | true* -*Defined in [ethereum-types/src/index.ts:519](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L519)* +*Defined in [ethereum-types/src/index.ts:519](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L519)* ___ @@ -3617,7 +3613,7 @@ ___ • **disableStorage**? : *undefined | false | true* -*Defined in [ethereum-types/src/index.ts:520](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L520)* +*Defined in [ethereum-types/src/index.ts:520](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L520)* ___ @@ -3625,7 +3621,7 @@ ___ • **timeout**? : *undefined | string* -*Defined in [ethereum-types/src/index.ts:522](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L522)* +*Defined in [ethereum-types/src/index.ts:522](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L522)* ___ @@ -3633,7 +3629,7 @@ ___ • **tracer**? : *undefined | string* -*Defined in [ethereum-types/src/index.ts:521](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L521)* +*Defined in [ethereum-types/src/index.ts:521](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L521)*
@@ -3646,7 +3642,7 @@ ___ • **blockHash**: *string | null* -*Defined in [ethereum-types/src/index.ts:377](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L377)* +*Defined in [ethereum-types/src/index.ts:377](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L377)* ___ @@ -3654,7 +3650,7 @@ ___ • **blockNumber**: *number | null* -*Defined in [ethereum-types/src/index.ts:378](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L378)* +*Defined in [ethereum-types/src/index.ts:378](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L378)* ___ @@ -3662,7 +3658,7 @@ ___ • **from**: *string* -*Defined in [ethereum-types/src/index.ts:380](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L380)* +*Defined in [ethereum-types/src/index.ts:380](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L380)* ___ @@ -3670,7 +3666,7 @@ ___ • **gas**: *number* -*Defined in [ethereum-types/src/index.ts:384](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L384)* +*Defined in [ethereum-types/src/index.ts:384](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L384)* ___ @@ -3678,7 +3674,7 @@ ___ • **gasPrice**: *`BigNumber`* -*Defined in [ethereum-types/src/index.ts:383](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L383)* +*Defined in [ethereum-types/src/index.ts:383](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L383)* ___ @@ -3686,7 +3682,7 @@ ___ • **hash**: *string* -*Defined in [ethereum-types/src/index.ts:375](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L375)* +*Defined in [ethereum-types/src/index.ts:375](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L375)* ___ @@ -3694,7 +3690,7 @@ ___ • **input**: *string* -*Defined in [ethereum-types/src/index.ts:385](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L385)* +*Defined in [ethereum-types/src/index.ts:385](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L385)* ___ @@ -3702,7 +3698,7 @@ ___ • **nonce**: *number* -*Defined in [ethereum-types/src/index.ts:376](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L376)* +*Defined in [ethereum-types/src/index.ts:376](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L376)* ___ @@ -3710,7 +3706,7 @@ ___ • **to**: *string | null* -*Defined in [ethereum-types/src/index.ts:381](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L381)* +*Defined in [ethereum-types/src/index.ts:381](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L381)* ___ @@ -3718,7 +3714,7 @@ ___ • **transactionIndex**: *number | null* -*Defined in [ethereum-types/src/index.ts:379](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L379)* +*Defined in [ethereum-types/src/index.ts:379](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L379)* ___ @@ -3726,7 +3722,7 @@ ___ • **value**: *`BigNumber`* -*Defined in [ethereum-types/src/index.ts:382](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L382)* +*Defined in [ethereum-types/src/index.ts:382](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L382)*
@@ -3739,7 +3735,7 @@ ___ • **blockHash**: *string* -*Defined in [ethereum-types/src/index.ts:448](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L448)* +*Defined in [ethereum-types/src/index.ts:448](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L448)* ___ @@ -3747,7 +3743,7 @@ ___ • **blockNumber**: *number* -*Defined in [ethereum-types/src/index.ts:449](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L449)* +*Defined in [ethereum-types/src/index.ts:449](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L449)* ___ @@ -3755,7 +3751,7 @@ ___ • **contractAddress**: *string | null* -*Defined in [ethereum-types/src/index.ts:457](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L457)* +*Defined in [ethereum-types/src/index.ts:457](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L457)* ___ @@ -3763,7 +3759,7 @@ ___ • **cumulativeGasUsed**: *number* -*Defined in [ethereum-types/src/index.ts:455](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L455)* +*Defined in [ethereum-types/src/index.ts:455](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L455)* ___ @@ -3771,7 +3767,7 @@ ___ • **from**: *string* -*Defined in [ethereum-types/src/index.ts:452](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L452)* +*Defined in [ethereum-types/src/index.ts:452](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L452)* ___ @@ -3779,7 +3775,7 @@ ___ • **gasUsed**: *number* -*Defined in [ethereum-types/src/index.ts:456](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L456)* +*Defined in [ethereum-types/src/index.ts:456](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L456)* ___ @@ -3787,7 +3783,7 @@ ___ • **logs**: *[LogEntry](#class-logentry)[]* -*Defined in [ethereum-types/src/index.ts:458](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L458)* +*Defined in [ethereum-types/src/index.ts:458](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L458)* ___ @@ -3795,7 +3791,7 @@ ___ • **status**: *[TransactionReceiptStatus](#transactionreceiptstatus)* -*Defined in [ethereum-types/src/index.ts:454](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L454)* +*Defined in [ethereum-types/src/index.ts:454](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L454)* ___ @@ -3803,7 +3799,7 @@ ___ • **to**: *string* -*Defined in [ethereum-types/src/index.ts:453](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L453)* +*Defined in [ethereum-types/src/index.ts:453](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L453)* ___ @@ -3811,7 +3807,7 @@ ___ • **transactionHash**: *string* -*Defined in [ethereum-types/src/index.ts:450](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L450)* +*Defined in [ethereum-types/src/index.ts:450](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L450)* ___ @@ -3819,7 +3815,7 @@ ___ • **transactionIndex**: *number* -*Defined in [ethereum-types/src/index.ts:451](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L451)* +*Defined in [ethereum-types/src/index.ts:451](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L451)*
@@ -3838,7 +3834,7 @@ otherwise we don't. *Inherited from [TransactionReceipt](#interface-transactionreceipt).[blockHash](#blockhash)* -*Defined in [ethereum-types/src/index.ts:448](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L448)* +*Defined in [ethereum-types/src/index.ts:448](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L448)* ___ @@ -3848,7 +3844,7 @@ ___ *Inherited from [TransactionReceipt](#interface-transactionreceipt).[blockNumber](#blocknumber)* -*Defined in [ethereum-types/src/index.ts:449](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L449)* +*Defined in [ethereum-types/src/index.ts:449](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L449)* ___ @@ -3858,7 +3854,7 @@ ___ *Inherited from [TransactionReceipt](#interface-transactionreceipt).[contractAddress](#contractaddress)* -*Defined in [ethereum-types/src/index.ts:457](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L457)* +*Defined in [ethereum-types/src/index.ts:457](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L457)* ___ @@ -3868,7 +3864,7 @@ ___ *Inherited from [TransactionReceipt](#interface-transactionreceipt).[cumulativeGasUsed](#cumulativegasused)* -*Defined in [ethereum-types/src/index.ts:455](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L455)* +*Defined in [ethereum-types/src/index.ts:455](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L455)* ___ @@ -3878,7 +3874,7 @@ ___ *Inherited from [TransactionReceipt](#interface-transactionreceipt).[from](#from)* -*Defined in [ethereum-types/src/index.ts:452](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L452)* +*Defined in [ethereum-types/src/index.ts:452](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L452)* ___ @@ -3888,7 +3884,7 @@ ___ *Inherited from [TransactionReceipt](#interface-transactionreceipt).[gasUsed](#gasused)* -*Defined in [ethereum-types/src/index.ts:456](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L456)* +*Defined in [ethereum-types/src/index.ts:456](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L456)* ___ @@ -3898,7 +3894,7 @@ ___ *Overrides [TransactionReceipt](_ethereum_types_src_index_.transactionreceipt.md).[logs](#logs)* -*Defined in [ethereum-types/src/index.ts:514](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L514)* +*Defined in [ethereum-types/src/index.ts:514](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L514)* ___ @@ -3908,7 +3904,7 @@ ___ *Inherited from [TransactionReceipt](#interface-transactionreceipt).[status](#status)* -*Defined in [ethereum-types/src/index.ts:454](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L454)* +*Defined in [ethereum-types/src/index.ts:454](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L454)* ___ @@ -3918,7 +3914,7 @@ ___ *Inherited from [TransactionReceipt](#interface-transactionreceipt).[to](#to)* -*Defined in [ethereum-types/src/index.ts:453](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L453)* +*Defined in [ethereum-types/src/index.ts:453](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L453)* ___ @@ -3928,7 +3924,7 @@ ___ *Inherited from [TransactionReceipt](#interface-transactionreceipt).[transactionHash](#transactionhash)* -*Defined in [ethereum-types/src/index.ts:450](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L450)* +*Defined in [ethereum-types/src/index.ts:450](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L450)* ___ @@ -3938,7 +3934,7 @@ ___ *Inherited from [TransactionReceipt](#interface-transactionreceipt).[transactionIndex](#transactionindex)* -*Defined in [ethereum-types/src/index.ts:451](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L451)* +*Defined in [ethereum-types/src/index.ts:451](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L451)*
@@ -3951,7 +3947,7 @@ ___ • **gas**: *number* -*Defined in [ethereum-types/src/index.ts:305](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L305)* +*Defined in [ethereum-types/src/index.ts:305](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L305)* ___ @@ -3959,7 +3955,7 @@ ___ • **returnValue**: *any* -*Defined in [ethereum-types/src/index.ts:306](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L306)* +*Defined in [ethereum-types/src/index.ts:306](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L306)* ___ @@ -3967,7 +3963,7 @@ ___ • **structLogs**: *[StructLog](#class-structlog)[]* -*Defined in [ethereum-types/src/index.ts:307](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L307)* +*Defined in [ethereum-types/src/index.ts:307](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L307)*
@@ -3982,7 +3978,7 @@ ___ *Overrides [DataItem](_ethereum_types_src_index_.dataitem.md).[components](#optional-components)* -*Defined in [ethereum-types/src/index.ts:141](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L141)* +*Defined in [ethereum-types/src/index.ts:141](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L141)* ___ @@ -3992,7 +3988,7 @@ ___ *Inherited from [DataItem](#interface-dataitem).[name](#name)* -*Defined in [ethereum-types/src/index.ts:135](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L135)* +*Defined in [ethereum-types/src/index.ts:135](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L135)* ___ @@ -4002,7 +3998,7 @@ ___ *Inherited from [DataItem](#interface-dataitem).[type](#type)* -*Defined in [ethereum-types/src/index.ts:136](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L136)* +*Defined in [ethereum-types/src/index.ts:136](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L136)*
@@ -4017,7 +4013,7 @@ ___ *Inherited from [CallTxDataBase](#interface-calltxdatabase).[data](#optional-data)* -*Defined in [ethereum-types/src/index.ts:393](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L393)* +*Defined in [ethereum-types/src/index.ts:393](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L393)* ___ @@ -4025,7 +4021,7 @@ ___ • **from**: *string* -*Defined in [ethereum-types/src/index.ts:398](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L398)* +*Defined in [ethereum-types/src/index.ts:398](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L398)* ___ @@ -4035,7 +4031,7 @@ ___ *Inherited from [CallTxDataBase](#interface-calltxdatabase).[gas](#optional-gas)* -*Defined in [ethereum-types/src/index.ts:391](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L391)* +*Defined in [ethereum-types/src/index.ts:391](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L391)* ___ @@ -4045,7 +4041,7 @@ ___ *Inherited from [CallTxDataBase](#interface-calltxdatabase).[gasPrice](#optional-gasprice)* -*Defined in [ethereum-types/src/index.ts:392](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L392)* +*Defined in [ethereum-types/src/index.ts:392](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L392)* ___ @@ -4055,7 +4051,7 @@ ___ *Inherited from [CallTxDataBase](#interface-calltxdatabase).[nonce](#optional-nonce)* -*Defined in [ethereum-types/src/index.ts:394](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L394)* +*Defined in [ethereum-types/src/index.ts:394](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L394)* ___ @@ -4065,7 +4061,7 @@ ___ *Inherited from [CallTxDataBase](#interface-calltxdatabase).[to](#optional-to)* -*Defined in [ethereum-types/src/index.ts:389](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L389)* +*Defined in [ethereum-types/src/index.ts:389](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L389)* ___ @@ -4075,7 +4071,7 @@ ___ *Inherited from [CallTxDataBase](#interface-calltxdatabase).[value](#optional-value)* -*Defined in [ethereum-types/src/index.ts:390](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L390)* +*Defined in [ethereum-types/src/index.ts:390](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L390)*
@@ -4090,7 +4086,7 @@ ___ *Inherited from [CallTxDataBase](#interface-calltxdatabase).[data](#optional-data)* -*Defined in [ethereum-types/src/index.ts:393](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L393)* +*Defined in [ethereum-types/src/index.ts:393](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L393)* ___ @@ -4100,7 +4096,7 @@ ___ *Inherited from [TxData](#interface-txdata).[from](#from)* -*Defined in [ethereum-types/src/index.ts:398](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L398)* +*Defined in [ethereum-types/src/index.ts:398](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L398)* ___ @@ -4110,7 +4106,7 @@ ___ *Inherited from [CallTxDataBase](#interface-calltxdatabase).[gas](#optional-gas)* -*Defined in [ethereum-types/src/index.ts:391](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L391)* +*Defined in [ethereum-types/src/index.ts:391](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L391)* ___ @@ -4120,7 +4116,7 @@ ___ *Inherited from [CallTxDataBase](#interface-calltxdatabase).[gasPrice](#optional-gasprice)* -*Defined in [ethereum-types/src/index.ts:392](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L392)* +*Defined in [ethereum-types/src/index.ts:392](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L392)* ___ @@ -4130,7 +4126,7 @@ ___ *Inherited from [CallTxDataBase](#interface-calltxdatabase).[nonce](#optional-nonce)* -*Defined in [ethereum-types/src/index.ts:394](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L394)* +*Defined in [ethereum-types/src/index.ts:394](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L394)* ___ @@ -4140,7 +4136,7 @@ ___ *Inherited from [CallTxDataBase](#interface-calltxdatabase).[to](#optional-to)* -*Defined in [ethereum-types/src/index.ts:389](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L389)* +*Defined in [ethereum-types/src/index.ts:389](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L389)* ___ @@ -4150,7 +4146,7 @@ ___ *Overrides [CallTxDataBase](_ethereum_types_src_index_.calltxdatabase.md).[value](#optional-value)* -*Defined in [ethereum-types/src/index.ts:442](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L442)* +*Defined in [ethereum-types/src/index.ts:442](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L442)*
@@ -4167,7 +4163,7 @@ This interface allowed sending synchonous requests, support for which was later ▸ **send**(`payload`: [JSONRPCRequestPayload](_ethereum_types_src_index_.jsonrpcrequestpayload.md)): *[JSONRPCResponsePayload](#class-jsonrpcresponsepayload)* -*Defined in [ethereum-types/src/index.ts:45](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L45)* +*Defined in [ethereum-types/src/index.ts:45](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L45)* **Parameters:** @@ -4183,7 +4179,7 @@ ___ ▸ **sendAsync**(`payload`: [JSONRPCRequestPayload](_ethereum_types_src_index_.jsonrpcrequestpayload.md), `callback`: [JSONRPCErrorCallback](#jsonrpcerrorcallback)): *void* -*Defined in [ethereum-types/src/index.ts:44](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L44)* +*Defined in [ethereum-types/src/index.ts:44](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L44)* **Parameters:** @@ -4209,7 +4205,7 @@ before the first attempts to conform to EIP1193 ▸ **send**(`payload`: [JSONRPCRequestPayload](_ethereum_types_src_index_.jsonrpcrequestpayload.md), `callback`: [JSONRPCErrorCallback](#jsonrpcerrorcallback)): *void* -*Defined in [ethereum-types/src/index.ts:54](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L54)* +*Defined in [ethereum-types/src/index.ts:54](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L54)* **Parameters:** @@ -4235,7 +4231,7 @@ however it does not conform entirely. ▸ **send**(`method`: string, `params?`: any[]): *`Promise`* -*Defined in [ethereum-types/src/index.ts:63](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L63)* +*Defined in [ethereum-types/src/index.ts:63](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L63)* **Parameters:** @@ -4261,7 +4257,7 @@ add here • **isMetaMask**? : *undefined | false | true* -*Defined in [ethereum-types/src/index.ts:31](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L31)* +*Defined in [ethereum-types/src/index.ts:31](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L31)* ___ @@ -4269,7 +4265,7 @@ ___ • **isParity**? : *undefined | false | true* -*Defined in [ethereum-types/src/index.ts:32](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L32)* +*Defined in [ethereum-types/src/index.ts:32](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L32)* ___ @@ -4277,7 +4273,7 @@ ___ • **isZeroExProvider**? : *undefined | false | true* -*Defined in [ethereum-types/src/index.ts:30](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L30)* +*Defined in [ethereum-types/src/index.ts:30](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L30)* ## Methods @@ -4285,7 +4281,7 @@ ___ ▸ **enable**(): *`Promise`* -*Defined in [ethereum-types/src/index.ts:34](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L34)* +*Defined in [ethereum-types/src/index.ts:34](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L34)* **Returns:** *`Promise`* @@ -4295,7 +4291,7 @@ ___ ▸ **sendAsync**(`payload`: [JSONRPCRequestPayload](_ethereum_types_src_index_.jsonrpcrequestpayload.md), `callback`: [JSONRPCErrorCallback](#jsonrpcerrorcallback)): *void* -*Defined in [ethereum-types/src/index.ts:35](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L35)* +*Defined in [ethereum-types/src/index.ts:35](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L35)* **Parameters:** @@ -4312,7 +4308,7 @@ ___ ▸ **stop**(): *void* -*Defined in [ethereum-types/src/index.ts:33](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L33)* +*Defined in [ethereum-types/src/index.ts:33](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L33)* **Returns:** *void* @@ -4331,7 +4327,7 @@ ___ *Inherited from [AbstractBlockRPC](#interface-abstractblockrpc).[difficulty](#difficulty)* -*Defined in [web3-wrapper/src/types.ts:15](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L15)* +*Defined in [web3-wrapper/src/types.ts:15](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L15)* ___ @@ -4341,7 +4337,7 @@ ___ *Inherited from [AbstractBlockRPC](#interface-abstractblockrpc).[extraData](#extradata)* -*Defined in [web3-wrapper/src/types.ts:17](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L17)* +*Defined in [web3-wrapper/src/types.ts:17](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L17)* ___ @@ -4351,7 +4347,7 @@ ___ *Inherited from [AbstractBlockRPC](#interface-abstractblockrpc).[gasLimit](#gaslimit)* -*Defined in [web3-wrapper/src/types.ts:19](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L19)* +*Defined in [web3-wrapper/src/types.ts:19](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L19)* ___ @@ -4361,7 +4357,7 @@ ___ *Inherited from [AbstractBlockRPC](#interface-abstractblockrpc).[gasUsed](#gasused)* -*Defined in [web3-wrapper/src/types.ts:20](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L20)* +*Defined in [web3-wrapper/src/types.ts:20](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L20)* ___ @@ -4371,7 +4367,7 @@ ___ *Inherited from [AbstractBlockRPC](#interface-abstractblockrpc).[hash](#hash)* -*Defined in [web3-wrapper/src/types.ts:7](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L7)* +*Defined in [web3-wrapper/src/types.ts:7](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L7)* ___ @@ -4381,7 +4377,7 @@ ___ *Inherited from [AbstractBlockRPC](#interface-abstractblockrpc).[logsBloom](#logsbloom)* -*Defined in [web3-wrapper/src/types.ts:11](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L11)* +*Defined in [web3-wrapper/src/types.ts:11](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L11)* ___ @@ -4391,7 +4387,7 @@ ___ *Inherited from [AbstractBlockRPC](#interface-abstractblockrpc).[miner](#miner)* -*Defined in [web3-wrapper/src/types.ts:14](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L14)* +*Defined in [web3-wrapper/src/types.ts:14](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L14)* ___ @@ -4401,7 +4397,7 @@ ___ *Inherited from [AbstractBlockRPC](#interface-abstractblockrpc).[nonce](#nonce)* -*Defined in [web3-wrapper/src/types.ts:9](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L9)* +*Defined in [web3-wrapper/src/types.ts:9](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L9)* ___ @@ -4411,7 +4407,7 @@ ___ *Inherited from [AbstractBlockRPC](#interface-abstractblockrpc).[number](#number)* -*Defined in [web3-wrapper/src/types.ts:6](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L6)* +*Defined in [web3-wrapper/src/types.ts:6](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L6)* ___ @@ -4421,7 +4417,7 @@ ___ *Inherited from [AbstractBlockRPC](#interface-abstractblockrpc).[parentHash](#parenthash)* -*Defined in [web3-wrapper/src/types.ts:8](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L8)* +*Defined in [web3-wrapper/src/types.ts:8](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L8)* ___ @@ -4431,7 +4427,7 @@ ___ *Inherited from [AbstractBlockRPC](#interface-abstractblockrpc).[sha3Uncles](#sha3uncles)* -*Defined in [web3-wrapper/src/types.ts:10](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L10)* +*Defined in [web3-wrapper/src/types.ts:10](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L10)* ___ @@ -4441,7 +4437,7 @@ ___ *Inherited from [AbstractBlockRPC](#interface-abstractblockrpc).[size](#size)* -*Defined in [web3-wrapper/src/types.ts:18](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L18)* +*Defined in [web3-wrapper/src/types.ts:18](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L18)* ___ @@ -4451,7 +4447,7 @@ ___ *Inherited from [AbstractBlockRPC](#interface-abstractblockrpc).[stateRoot](#stateroot)* -*Defined in [web3-wrapper/src/types.ts:13](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L13)* +*Defined in [web3-wrapper/src/types.ts:13](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L13)* ___ @@ -4461,7 +4457,7 @@ ___ *Inherited from [AbstractBlockRPC](#interface-abstractblockrpc).[timestamp](#timestamp)* -*Defined in [web3-wrapper/src/types.ts:21](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L21)* +*Defined in [web3-wrapper/src/types.ts:21](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L21)* ___ @@ -4471,7 +4467,7 @@ ___ *Inherited from [AbstractBlockRPC](#interface-abstractblockrpc).[totalDifficulty](#totaldifficulty)* -*Defined in [web3-wrapper/src/types.ts:16](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L16)* +*Defined in [web3-wrapper/src/types.ts:16](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L16)* ___ @@ -4479,7 +4475,7 @@ ___ • **transactions**: *string[]* -*Defined in [web3-wrapper/src/types.ts:25](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L25)* +*Defined in [web3-wrapper/src/types.ts:25](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L25)* ___ @@ -4489,7 +4485,7 @@ ___ *Inherited from [AbstractBlockRPC](#interface-abstractblockrpc).[transactionsRoot](#transactionsroot)* -*Defined in [web3-wrapper/src/types.ts:12](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L12)* +*Defined in [web3-wrapper/src/types.ts:12](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L12)* ___ @@ -4499,7 +4495,7 @@ ___ *Inherited from [AbstractBlockRPC](#interface-abstractblockrpc).[uncles](#uncles)* -*Defined in [web3-wrapper/src/types.ts:22](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L22)* +*Defined in [web3-wrapper/src/types.ts:22](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L22)*
@@ -4514,7 +4510,7 @@ ___ *Inherited from [AbstractBlockRPC](#interface-abstractblockrpc).[difficulty](#difficulty)* -*Defined in [web3-wrapper/src/types.ts:15](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L15)* +*Defined in [web3-wrapper/src/types.ts:15](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L15)* ___ @@ -4524,7 +4520,7 @@ ___ *Inherited from [AbstractBlockRPC](#interface-abstractblockrpc).[extraData](#extradata)* -*Defined in [web3-wrapper/src/types.ts:17](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L17)* +*Defined in [web3-wrapper/src/types.ts:17](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L17)* ___ @@ -4534,7 +4530,7 @@ ___ *Inherited from [AbstractBlockRPC](#interface-abstractblockrpc).[gasLimit](#gaslimit)* -*Defined in [web3-wrapper/src/types.ts:19](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L19)* +*Defined in [web3-wrapper/src/types.ts:19](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L19)* ___ @@ -4544,7 +4540,7 @@ ___ *Inherited from [AbstractBlockRPC](#interface-abstractblockrpc).[gasUsed](#gasused)* -*Defined in [web3-wrapper/src/types.ts:20](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L20)* +*Defined in [web3-wrapper/src/types.ts:20](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L20)* ___ @@ -4554,7 +4550,7 @@ ___ *Inherited from [AbstractBlockRPC](#interface-abstractblockrpc).[hash](#hash)* -*Defined in [web3-wrapper/src/types.ts:7](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L7)* +*Defined in [web3-wrapper/src/types.ts:7](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L7)* ___ @@ -4564,7 +4560,7 @@ ___ *Inherited from [AbstractBlockRPC](#interface-abstractblockrpc).[logsBloom](#logsbloom)* -*Defined in [web3-wrapper/src/types.ts:11](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L11)* +*Defined in [web3-wrapper/src/types.ts:11](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L11)* ___ @@ -4574,7 +4570,7 @@ ___ *Inherited from [AbstractBlockRPC](#interface-abstractblockrpc).[miner](#miner)* -*Defined in [web3-wrapper/src/types.ts:14](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L14)* +*Defined in [web3-wrapper/src/types.ts:14](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L14)* ___ @@ -4584,7 +4580,7 @@ ___ *Inherited from [AbstractBlockRPC](#interface-abstractblockrpc).[nonce](#nonce)* -*Defined in [web3-wrapper/src/types.ts:9](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L9)* +*Defined in [web3-wrapper/src/types.ts:9](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L9)* ___ @@ -4594,7 +4590,7 @@ ___ *Inherited from [AbstractBlockRPC](#interface-abstractblockrpc).[number](#number)* -*Defined in [web3-wrapper/src/types.ts:6](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L6)* +*Defined in [web3-wrapper/src/types.ts:6](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L6)* ___ @@ -4604,7 +4600,7 @@ ___ *Inherited from [AbstractBlockRPC](#interface-abstractblockrpc).[parentHash](#parenthash)* -*Defined in [web3-wrapper/src/types.ts:8](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L8)* +*Defined in [web3-wrapper/src/types.ts:8](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L8)* ___ @@ -4614,7 +4610,7 @@ ___ *Inherited from [AbstractBlockRPC](#interface-abstractblockrpc).[sha3Uncles](#sha3uncles)* -*Defined in [web3-wrapper/src/types.ts:10](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L10)* +*Defined in [web3-wrapper/src/types.ts:10](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L10)* ___ @@ -4624,7 +4620,7 @@ ___ *Inherited from [AbstractBlockRPC](#interface-abstractblockrpc).[size](#size)* -*Defined in [web3-wrapper/src/types.ts:18](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L18)* +*Defined in [web3-wrapper/src/types.ts:18](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L18)* ___ @@ -4634,7 +4630,7 @@ ___ *Inherited from [AbstractBlockRPC](#interface-abstractblockrpc).[stateRoot](#stateroot)* -*Defined in [web3-wrapper/src/types.ts:13](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L13)* +*Defined in [web3-wrapper/src/types.ts:13](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L13)* ___ @@ -4644,7 +4640,7 @@ ___ *Inherited from [AbstractBlockRPC](#interface-abstractblockrpc).[timestamp](#timestamp)* -*Defined in [web3-wrapper/src/types.ts:21](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L21)* +*Defined in [web3-wrapper/src/types.ts:21](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L21)* ___ @@ -4654,7 +4650,7 @@ ___ *Inherited from [AbstractBlockRPC](#interface-abstractblockrpc).[totalDifficulty](#totaldifficulty)* -*Defined in [web3-wrapper/src/types.ts:16](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L16)* +*Defined in [web3-wrapper/src/types.ts:16](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L16)* ___ @@ -4662,7 +4658,7 @@ ___ • **transactions**: *[TransactionRPC](#class-transactionrpc)[]* -*Defined in [web3-wrapper/src/types.ts:28](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L28)* +*Defined in [web3-wrapper/src/types.ts:28](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L28)* ___ @@ -4672,7 +4668,7 @@ ___ *Inherited from [AbstractBlockRPC](#interface-abstractblockrpc).[transactionsRoot](#transactionsroot)* -*Defined in [web3-wrapper/src/types.ts:12](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L12)* +*Defined in [web3-wrapper/src/types.ts:12](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L12)* ___ @@ -4682,7 +4678,7 @@ ___ *Inherited from [AbstractBlockRPC](#interface-abstractblockrpc).[uncles](#uncles)* -*Defined in [web3-wrapper/src/types.ts:22](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L22)* +*Defined in [web3-wrapper/src/types.ts:22](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L22)*
@@ -4697,7 +4693,7 @@ ___ *Inherited from [CallTxDataBaseRPC](#interface-calltxdatabaserpc).[data](#optional-data)* -*Defined in [web3-wrapper/src/types.ts:76](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L76)* +*Defined in [web3-wrapper/src/types.ts:76](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L76)* ___ @@ -4705,7 +4701,7 @@ ___ • **from**? : *undefined | string* -*Defined in [web3-wrapper/src/types.ts:85](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L85)* +*Defined in [web3-wrapper/src/types.ts:85](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L85)* ___ @@ -4715,7 +4711,7 @@ ___ *Inherited from [CallTxDataBaseRPC](#interface-calltxdatabaserpc).[gas](#optional-gas)* -*Defined in [web3-wrapper/src/types.ts:74](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L74)* +*Defined in [web3-wrapper/src/types.ts:74](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L74)* ___ @@ -4725,7 +4721,7 @@ ___ *Inherited from [CallTxDataBaseRPC](#interface-calltxdatabaserpc).[gasPrice](#optional-gasprice)* -*Defined in [web3-wrapper/src/types.ts:75](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L75)* +*Defined in [web3-wrapper/src/types.ts:75](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L75)* ___ @@ -4735,7 +4731,7 @@ ___ *Inherited from [CallTxDataBaseRPC](#interface-calltxdatabaserpc).[nonce](#optional-nonce)* -*Defined in [web3-wrapper/src/types.ts:77](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L77)* +*Defined in [web3-wrapper/src/types.ts:77](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L77)* ___ @@ -4745,7 +4741,7 @@ ___ *Inherited from [CallTxDataBaseRPC](#interface-calltxdatabaserpc).[to](#optional-to)* -*Defined in [web3-wrapper/src/types.ts:72](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L72)* +*Defined in [web3-wrapper/src/types.ts:72](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L72)* ___ @@ -4755,7 +4751,7 @@ ___ *Inherited from [CallTxDataBaseRPC](#interface-calltxdatabaserpc).[value](#optional-value)* -*Defined in [web3-wrapper/src/types.ts:73](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L73)* +*Defined in [web3-wrapper/src/types.ts:73](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L73)*
@@ -4770,7 +4766,7 @@ ___ • **address**: *string* -*Defined in [web3-wrapper/src/types.ts:64](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L64)* +*Defined in [web3-wrapper/src/types.ts:64](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L64)* ___ @@ -4778,7 +4774,7 @@ ___ • **blockHash**: *string | null* -*Defined in [web3-wrapper/src/types.ts:62](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L62)* +*Defined in [web3-wrapper/src/types.ts:62](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L62)* ___ @@ -4786,7 +4782,7 @@ ___ • **blockNumber**: *string | null* -*Defined in [web3-wrapper/src/types.ts:63](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L63)* +*Defined in [web3-wrapper/src/types.ts:63](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L63)* ___ @@ -4794,7 +4790,7 @@ ___ • **data**: *string* -*Defined in [web3-wrapper/src/types.ts:65](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L65)* +*Defined in [web3-wrapper/src/types.ts:65](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L65)* ___ @@ -4802,7 +4798,7 @@ ___ • **logIndex**: *string | null* -*Defined in [web3-wrapper/src/types.ts:59](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L59)* +*Defined in [web3-wrapper/src/types.ts:59](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L59)* ___ @@ -4810,7 +4806,7 @@ ___ • **topics**: *string[]* -*Defined in [web3-wrapper/src/types.ts:66](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L66)* +*Defined in [web3-wrapper/src/types.ts:66](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L66)* ___ @@ -4818,7 +4814,7 @@ ___ • **transactionHash**: *string* -*Defined in [web3-wrapper/src/types.ts:61](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L61)* +*Defined in [web3-wrapper/src/types.ts:61](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L61)* ___ @@ -4826,7 +4822,7 @@ ___ • **transactionIndex**: *string | null* -*Defined in [web3-wrapper/src/types.ts:60](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L60)* +*Defined in [web3-wrapper/src/types.ts:60](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L60)*
@@ -4839,7 +4835,7 @@ ___ • **blockHash**: *string* -*Defined in [web3-wrapper/src/types.ts:45](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L45)* +*Defined in [web3-wrapper/src/types.ts:45](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L45)* ___ @@ -4847,7 +4843,7 @@ ___ • **blockNumber**: *string* -*Defined in [web3-wrapper/src/types.ts:46](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L46)* +*Defined in [web3-wrapper/src/types.ts:46](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L46)* ___ @@ -4855,7 +4851,7 @@ ___ • **contractAddress**: *string | null* -*Defined in [web3-wrapper/src/types.ts:54](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L54)* +*Defined in [web3-wrapper/src/types.ts:54](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L54)* ___ @@ -4863,7 +4859,7 @@ ___ • **cumulativeGasUsed**: *string* -*Defined in [web3-wrapper/src/types.ts:52](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L52)* +*Defined in [web3-wrapper/src/types.ts:52](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L52)* ___ @@ -4871,7 +4867,7 @@ ___ • **from**: *string* -*Defined in [web3-wrapper/src/types.ts:49](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L49)* +*Defined in [web3-wrapper/src/types.ts:49](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L49)* ___ @@ -4879,7 +4875,7 @@ ___ • **gasUsed**: *string* -*Defined in [web3-wrapper/src/types.ts:53](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L53)* +*Defined in [web3-wrapper/src/types.ts:53](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L53)* ___ @@ -4887,7 +4883,7 @@ ___ • **logs**: *[LogEntryRPC](#class-logentryrpc)[]* -*Defined in [web3-wrapper/src/types.ts:55](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L55)* +*Defined in [web3-wrapper/src/types.ts:55](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L55)* ___ @@ -4895,7 +4891,7 @@ ___ • **status**: *[TransactionReceiptStatusRPC](#transactionreceiptstatusrpc)* -*Defined in [web3-wrapper/src/types.ts:51](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L51)* +*Defined in [web3-wrapper/src/types.ts:51](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L51)* ___ @@ -4903,7 +4899,7 @@ ___ • **to**: *string* -*Defined in [web3-wrapper/src/types.ts:50](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L50)* +*Defined in [web3-wrapper/src/types.ts:50](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L50)* ___ @@ -4911,7 +4907,7 @@ ___ • **transactionHash**: *string* -*Defined in [web3-wrapper/src/types.ts:47](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L47)* +*Defined in [web3-wrapper/src/types.ts:47](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L47)* ___ @@ -4919,7 +4915,7 @@ ___ • **transactionIndex**: *string* -*Defined in [web3-wrapper/src/types.ts:48](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L48)* +*Defined in [web3-wrapper/src/types.ts:48](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L48)*
@@ -4932,7 +4928,7 @@ ___ • **blockHash**: *string | null* -*Defined in [web3-wrapper/src/types.ts:33](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L33)* +*Defined in [web3-wrapper/src/types.ts:33](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L33)* ___ @@ -4940,7 +4936,7 @@ ___ • **blockNumber**: *string | null* -*Defined in [web3-wrapper/src/types.ts:34](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L34)* +*Defined in [web3-wrapper/src/types.ts:34](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L34)* ___ @@ -4948,7 +4944,7 @@ ___ • **from**: *string* -*Defined in [web3-wrapper/src/types.ts:36](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L36)* +*Defined in [web3-wrapper/src/types.ts:36](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L36)* ___ @@ -4956,7 +4952,7 @@ ___ • **gas**: *string* -*Defined in [web3-wrapper/src/types.ts:40](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L40)* +*Defined in [web3-wrapper/src/types.ts:40](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L40)* ___ @@ -4964,7 +4960,7 @@ ___ • **gasPrice**: *string* -*Defined in [web3-wrapper/src/types.ts:39](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L39)* +*Defined in [web3-wrapper/src/types.ts:39](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L39)* ___ @@ -4972,7 +4968,7 @@ ___ • **hash**: *string* -*Defined in [web3-wrapper/src/types.ts:31](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L31)* +*Defined in [web3-wrapper/src/types.ts:31](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L31)* ___ @@ -4980,7 +4976,7 @@ ___ • **input**: *string* -*Defined in [web3-wrapper/src/types.ts:41](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L41)* +*Defined in [web3-wrapper/src/types.ts:41](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L41)* ___ @@ -4988,7 +4984,7 @@ ___ • **nonce**: *string* -*Defined in [web3-wrapper/src/types.ts:32](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L32)* +*Defined in [web3-wrapper/src/types.ts:32](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L32)* ___ @@ -4996,7 +4992,7 @@ ___ • **to**: *string | null* -*Defined in [web3-wrapper/src/types.ts:37](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L37)* +*Defined in [web3-wrapper/src/types.ts:37](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L37)* ___ @@ -5004,7 +5000,7 @@ ___ • **transactionIndex**: *string | null* -*Defined in [web3-wrapper/src/types.ts:35](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L35)* +*Defined in [web3-wrapper/src/types.ts:35](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L35)* ___ @@ -5012,7 +5008,7 @@ ___ • **value**: *string* -*Defined in [web3-wrapper/src/types.ts:38](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L38)* +*Defined in [web3-wrapper/src/types.ts:38](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L38)*
@@ -5027,7 +5023,7 @@ ___ *Inherited from [CallTxDataBaseRPC](#interface-calltxdatabaserpc).[data](#optional-data)* -*Defined in [web3-wrapper/src/types.ts:76](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L76)* +*Defined in [web3-wrapper/src/types.ts:76](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L76)* ___ @@ -5035,7 +5031,7 @@ ___ • **from**: *string* -*Defined in [web3-wrapper/src/types.ts:81](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L81)* +*Defined in [web3-wrapper/src/types.ts:81](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L81)* ___ @@ -5045,7 +5041,7 @@ ___ *Inherited from [CallTxDataBaseRPC](#interface-calltxdatabaserpc).[gas](#optional-gas)* -*Defined in [web3-wrapper/src/types.ts:74](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L74)* +*Defined in [web3-wrapper/src/types.ts:74](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L74)* ___ @@ -5055,7 +5051,7 @@ ___ *Inherited from [CallTxDataBaseRPC](#interface-calltxdatabaserpc).[gasPrice](#optional-gasprice)* -*Defined in [web3-wrapper/src/types.ts:75](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L75)* +*Defined in [web3-wrapper/src/types.ts:75](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L75)* ___ @@ -5065,7 +5061,7 @@ ___ *Inherited from [CallTxDataBaseRPC](#interface-calltxdatabaserpc).[nonce](#optional-nonce)* -*Defined in [web3-wrapper/src/types.ts:77](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L77)* +*Defined in [web3-wrapper/src/types.ts:77](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L77)* ___ @@ -5075,7 +5071,7 @@ ___ *Inherited from [CallTxDataBaseRPC](#interface-calltxdatabaserpc).[to](#optional-to)* -*Defined in [web3-wrapper/src/types.ts:72](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L72)* +*Defined in [web3-wrapper/src/types.ts:72](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L72)* ___ @@ -5085,20 +5081,7 @@ ___ *Inherited from [CallTxDataBaseRPC](#interface-calltxdatabaserpc).[value](#optional-value)* -*Defined in [web3-wrapper/src/types.ts:73](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L73)* - -
- - - - -## Type aliases - -### TransactionReceiptStatusRPC - -Ƭ **TransactionReceiptStatusRPC**: *null | string | `0` | `1`* - -*Defined in [web3-wrapper/src/types.ts:69](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/types.ts#L69)* +*Defined in [web3-wrapper/src/types.ts:73](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L73)*
@@ -5111,7 +5094,7 @@ ___ Ƭ **AbiDefinition**: *[FunctionAbi](_ethereum_types_src_index_.md#functionabi) | [EventAbi](#interface-eventabi) | [RevertErrorAbi](#interface-reverterrorabi)* -*Defined in [ethereum-types/src/index.ts:80](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L80)* +*Defined in [ethereum-types/src/index.ts:80](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L80)* ___ @@ -5119,7 +5102,7 @@ ___ Ƭ **BlockParam**: *[BlockParamLiteral](#enumeration-blockparamliteral) | number* -*Defined in [ethereum-types/src/index.ts:483](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L483)* +*Defined in [ethereum-types/src/index.ts:483](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L483)* ___ @@ -5127,7 +5110,7 @@ ___ Ƭ **ConstructorStateMutability**: *"nonpayable" | "payable"* -*Defined in [ethereum-types/src/index.ts:84](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L84)* +*Defined in [ethereum-types/src/index.ts:84](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L84)* ___ @@ -5137,7 +5120,7 @@ ___ Ƭ **ContractEventArg**: *any* -*Defined in [ethereum-types/src/index.ts:468](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L468)* +*Defined in [ethereum-types/src/index.ts:468](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L468)* ___ @@ -5147,7 +5130,7 @@ ___ Ƭ **EIP1193Event**: *"accountsChanged" | "networkChanged" | "close" | "connect" | "notification"* -*Defined in [ethereum-types/src/index.ts:70](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L70)* +*Defined in [ethereum-types/src/index.ts:70](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L70)* Interface for providers that conform to EIP 1193 Source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1193.md @@ -5162,7 +5145,7 @@ ___ Ƭ **FunctionAbi**: *[MethodAbi](#interface-methodabi) | [ConstructorAbi](#interface-constructorabi) | [FallbackAbi](#interface-fallbackabi)* -*Defined in [ethereum-types/src/index.ts:82](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L82)* +*Defined in [ethereum-types/src/index.ts:82](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L82)* ___ @@ -5170,7 +5153,7 @@ ___ Ƭ **JSONRPCErrorCallback**: *function* -*Defined in [ethereum-types/src/index.ts:3](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L3)* +*Defined in [ethereum-types/src/index.ts:3](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L3)* #### Type declaration: @@ -5189,7 +5172,7 @@ ___ Ƭ **LogTopic**: *null | string | string[]* -*Defined in [ethereum-types/src/index.ts:413](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L413)* +*Defined in [ethereum-types/src/index.ts:413](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L413)* ___ @@ -5201,7 +5184,7 @@ ___ Ƭ **RawLog**: *[LogEntry](#interface-logentry)* -*Defined in [ethereum-types/src/index.ts:475](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L475)* +*Defined in [ethereum-types/src/index.ts:475](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L475)* ___ @@ -5209,7 +5192,7 @@ ___ Ƭ **StateMutability**: *"pure" | "view" | [ConstructorStateMutability](#constructorstatemutability)* -*Defined in [ethereum-types/src/index.ts:85](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L85)* +*Defined in [ethereum-types/src/index.ts:85](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L85)* ___ @@ -5217,7 +5200,7 @@ ___ Ƭ **SupportedProvider**: *[Web3JsProvider](_ethereum_types_src_index_.md#web3jsprovider) | [GanacheProvider](#interface-ganacheprovider) | [EIP1193Provider](#interface-eip1193provider) | [ZeroExProvider](#interface-zeroexprovider)* -*Defined in [ethereum-types/src/index.ts:9](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L9)* +*Defined in [ethereum-types/src/index.ts:9](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L9)* Do not create your own provider. Use an existing provider from a Web3 or ProviderEngine library Read more about Providers in the guides section of the 0x docs. @@ -5228,7 +5211,7 @@ ___ Ƭ **TransactionReceiptStatus**: *null | string | `0` | `1`* -*Defined in [ethereum-types/src/index.ts:445](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L445)* +*Defined in [ethereum-types/src/index.ts:445](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L445)* ___ @@ -5238,7 +5221,7 @@ ___ Ƭ **Web3JsProvider**: *[Web3JsV1Provider](#interface-web3jsv1provider) | [Web3JsV2Provider](#interface-web3jsv2provider) | [Web3JsV3Provider](#interface-web3jsv3provider)* -*Defined in [ethereum-types/src/index.ts:11](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/ethereum-types/src/index.ts#L11)* +*Defined in [ethereum-types/src/index.ts:11](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/ethereum-types/src/index.ts#L11)*
@@ -5255,7 +5238,7 @@ ___ #### ▪ **marshaller**: *object* -*Defined in [web3-wrapper/src/marshaller.ts:33](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/marshaller.ts#L33)* +*Defined in [web3-wrapper/src/marshaller.ts:33](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/marshaller.ts#L33)* Utils to convert ethereum structures from user-space format to RPC format. (marshall/unmarshall) @@ -5263,7 +5246,7 @@ Utils to convert ethereum structures from user-space format to RPC format. (mars ▸ **_marshalCallTxDataBase**(`callTxDataBase`: `Partial`): *`Partial`* -*Defined in [web3-wrapper/src/marshaller.ts:208](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/marshaller.ts#L208)* +*Defined in [web3-wrapper/src/marshaller.ts:208](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/marshaller.ts#L208)* **Parameters:** @@ -5277,7 +5260,7 @@ Name | Type | ▸ **marshalAddress**(`address`: string): *string* -*Defined in [web3-wrapper/src/marshaller.ts:176](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/marshaller.ts#L176)* +*Defined in [web3-wrapper/src/marshaller.ts:176](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/marshaller.ts#L176)* Marshall address @@ -5295,7 +5278,7 @@ marshalled address ▸ **marshalBlockParam**(`blockParam`: [BlockParam](#blockparam) | string | number | undefined): *string | undefined* -*Defined in [web3-wrapper/src/marshaller.ts:187](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/marshaller.ts#L187)* +*Defined in [web3-wrapper/src/marshaller.ts:187](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/marshaller.ts#L187)* Marshall block param @@ -5313,7 +5296,7 @@ marshalled block param ▸ **marshalCallData**(`callData`: `Partial`): *`Partial`* -*Defined in [web3-wrapper/src/marshaller.ts:159](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/marshaller.ts#L159)* +*Defined in [web3-wrapper/src/marshaller.ts:159](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/marshaller.ts#L159)* Marshall call data @@ -5331,7 +5314,7 @@ marshalled call data ▸ **marshalTxData**(`txData`: `Partial`): *`Partial`* -*Defined in [web3-wrapper/src/marshaller.ts:133](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/marshaller.ts#L133)* +*Defined in [web3-wrapper/src/marshaller.ts:133](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/marshaller.ts#L133)* Marshall transaction data @@ -5349,7 +5332,7 @@ marshalled transaction data ▸ **unmarshalIntoBlockWithTransactionData**(`blockWithHexValues`: [BlockWithTransactionDataRPC](#interface-blockwithtransactiondatarpc)): *`BlockWithTransactionData`* -*Defined in [web3-wrapper/src/marshaller.ts:59](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/marshaller.ts#L59)* +*Defined in [web3-wrapper/src/marshaller.ts:59](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/marshaller.ts#L59)* Unmarshall block with transaction data @@ -5367,7 +5350,7 @@ unmarshalled block with transaction data ▸ **unmarshalIntoBlockWithoutTransactionData**(`blockWithHexValues`: [BlockWithoutTransactionDataRPC](#interface-blockwithouttransactiondatarpc)): *`BlockWithoutTransactionData`* -*Defined in [web3-wrapper/src/marshaller.ts:39](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/marshaller.ts#L39)* +*Defined in [web3-wrapper/src/marshaller.ts:39](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/marshaller.ts#L39)* Unmarshall block without transaction data @@ -5385,7 +5368,7 @@ unmarshalled block without transaction data ▸ **unmarshalLog**(`rawLog`: `RawLogEntry`): *`LogEntry`* -*Defined in [web3-wrapper/src/marshaller.ts:199](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/marshaller.ts#L199)* +*Defined in [web3-wrapper/src/marshaller.ts:199](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/marshaller.ts#L199)* Unmarshall log @@ -5403,7 +5386,7 @@ unmarshalled log ▸ **unmarshalTransaction**(`txRpc`: [TransactionRPC](#interface-transactionrpc)): *`Transaction`* -*Defined in [web3-wrapper/src/marshaller.ts:82](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/marshaller.ts#L82)* +*Defined in [web3-wrapper/src/marshaller.ts:82](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/marshaller.ts#L82)* Unmarshall transaction @@ -5421,7 +5404,7 @@ unmarshalled transaction ▸ **unmarshalTransactionReceipt**(`txReceiptRpc`: [TransactionReceiptRPC](#interface-transactionreceiptrpc)): *`TransactionReceipt`* -*Defined in [web3-wrapper/src/marshaller.ts:99](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/marshaller.ts#L99)* +*Defined in [web3-wrapper/src/marshaller.ts:99](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/marshaller.ts#L99)* Unmarshall transaction receipt @@ -5439,7 +5422,7 @@ unmarshalled transaction receipt ▸ **unmarshalTxData**(`txDataRpc`: [TxDataRPC](#interface-txdatarpc)): *`TxData`* -*Defined in [web3-wrapper/src/marshaller.ts:115](https://github.com/0xProject/0x-monorepo/blob/c61ada8a1/packages/web3-wrapper/src/marshaller.ts#L115)* +*Defined in [web3-wrapper/src/marshaller.ts:115](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/marshaller.ts#L115)* Unmarshall transaction data @@ -5455,3 +5438,20 @@ unmarshalled transaction data
+ + + +## Type aliases + +#### TransactionReceiptStatusRPC + +Ƭ **TransactionReceiptStatusRPC**: *null | string | `0` | `1`* + +*Defined in [web3-wrapper/src/types.ts:69](https://github.com/0xProject/0x-monorepo/blob/c93b02d55/packages/web3-wrapper/src/types.ts#L69)* + +
+ + + +
+ From c24bdce42cae15b2ef41c8dff459035b723178df Mon Sep 17 00:00:00 2001 From: fabioberger Date: Thu, 14 Nov 2019 14:19:28 +0000 Subject: [PATCH 15/20] Add back changelog already published and add revert changelog entry --- packages/types/CHANGELOG.json | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/packages/types/CHANGELOG.json b/packages/types/CHANGELOG.json index 99a78647fe..162bec3510 100644 --- a/packages/types/CHANGELOG.json +++ b/packages/types/CHANGELOG.json @@ -1,7 +1,20 @@ [ + { + "version": "2.5.0-beta.2", + "changes": [ + { + "note": "Remove `SendTransactionOpts` and `AwaitTransactionSuccessOpts` types and move them to @0x/base-contracts", + "pr": 2325 + } + ] + }, { "version": "2.5.0-beta.1", "changes": [ + { + "note": "Add `SendTransactionOpts` and `AwaitTransactionSuccessOpts` types for contract wrappers", + "pr": 2243 + }, { "note": "All references to network ID have been removed, and references to chain ID have been introduced instead", "pr": 2313 From 38b07a990e06eb44d27f68ef92fe19d924bd0e06 Mon Sep 17 00:00:00 2001 From: fabioberger Date: Thu, 14 Nov 2019 14:25:04 +0000 Subject: [PATCH 16/20] Add missing CHANGELOG entries --- packages/0x.js/CHANGELOG.json | 4 ++++ packages/abi-gen-wrappers/CHANGELOG.json | 4 ++++ packages/abi-gen/CHANGELOG.json | 9 +++++++++ packages/contract-wrappers/CHANGELOG.json | 8 ++++++++ 4 files changed, 25 insertions(+) diff --git a/packages/0x.js/CHANGELOG.json b/packages/0x.js/CHANGELOG.json index f2fb2fc77a..cbb19fbef4 100644 --- a/packages/0x.js/CHANGELOG.json +++ b/packages/0x.js/CHANGELOG.json @@ -9,6 +9,10 @@ { "note": "ContractWrappers no longer exposes `erc20Proxy`, `erc721Proxy` and `dutchAuction` wrappers", "pr": 2324 + }, + { + "note": "[Breaking] Big refactor of contract wrapper interface. See https://github.com/0xProject/0x-monorepo/pull/2325 for details", + "pr": 2325 } ] }, diff --git a/packages/abi-gen-wrappers/CHANGELOG.json b/packages/abi-gen-wrappers/CHANGELOG.json index acaf15522e..63054c7c58 100644 --- a/packages/abi-gen-wrappers/CHANGELOG.json +++ b/packages/abi-gen-wrappers/CHANGELOG.json @@ -5,6 +5,10 @@ { "note": "[Breaking] Remove `erc20Proxy`, `multiAssetProxy`, `erc1155Proxy`, `staticCallProxy`, `erc721Proxy`, `assetProxyOwner`, `ZRXToken` and `dutchAuction` wrappers", "pr": 2324 + }, + { + "note": "[Breaking] Big refactor of contract wrapper interface. See https://github.com/0xProject/0x-monorepo/pull/2325 for details", + "pr": 2325 } ] }, diff --git a/packages/abi-gen/CHANGELOG.json b/packages/abi-gen/CHANGELOG.json index 5ac4ed7b22..fe81217934 100644 --- a/packages/abi-gen/CHANGELOG.json +++ b/packages/abi-gen/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "version": "4.4.0-beta.2", + "changes": [ + { + "note": "Refactored TS wrapper templates to result in a more succint interface. See https://github.com/0xProject/0x-monorepo/pull/2325 for details.", + "pr": 2284 + } + ] + }, { "version": "4.4.0-beta.1", "changes": [ diff --git a/packages/contract-wrappers/CHANGELOG.json b/packages/contract-wrappers/CHANGELOG.json index b458b6b125..e9f985742b 100644 --- a/packages/contract-wrappers/CHANGELOG.json +++ b/packages/contract-wrappers/CHANGELOG.json @@ -5,6 +5,14 @@ { "note": "[Breaking] Remove `erc20Proxy`, `erc721Proxy` and `dutchAuction` wrappers", "pr": 2324 + }, + { + "note": "[Breaking] Big refactor of contract wrapper interface. See https://github.com/0xProject/0x-monorepo/pull/2325 for details", + "pr": 2325 + } + { + "note": "Export types `ContractFunctionObj` and `ContractTxFunctionObj`", + "pr": 2325 } ] }, From 4abb993322d4de5f1f6b9840a0d2b41dc461b68d Mon Sep 17 00:00:00 2001 From: fabioberger Date: Thu, 14 Nov 2019 14:45:31 +0000 Subject: [PATCH 17/20] Add missing comma --- packages/contract-wrappers/CHANGELOG.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/contract-wrappers/CHANGELOG.json b/packages/contract-wrappers/CHANGELOG.json index e9f985742b..74404c2265 100644 --- a/packages/contract-wrappers/CHANGELOG.json +++ b/packages/contract-wrappers/CHANGELOG.json @@ -9,7 +9,7 @@ { "note": "[Breaking] Big refactor of contract wrapper interface. See https://github.com/0xProject/0x-monorepo/pull/2325 for details", "pr": 2325 - } + }, { "note": "Export types `ContractFunctionObj` and `ContractTxFunctionObj`", "pr": 2325 From 6ca2081ae7d7fb7c5f2aaaa99e12c181ebb9af93 Mon Sep 17 00:00:00 2001 From: fabioberger Date: Thu, 14 Nov 2019 15:21:31 +0000 Subject: [PATCH 18/20] Update mesh-rpc-client dep --- packages/asset-swapper/package.json | 2 +- packages/orderbook/package.json | 2 +- yarn.lock | 49 +++-------------------------- 3 files changed, 6 insertions(+), 47 deletions(-) diff --git a/packages/asset-swapper/package.json b/packages/asset-swapper/package.json index 99143ed144..0da4e80e4a 100644 --- a/packages/asset-swapper/package.json +++ b/packages/asset-swapper/package.json @@ -59,7 +59,7 @@ }, "devDependencies": { "@0x/contracts-test-utils": "^3.2.0-beta.1", - "@0x/mesh-rpc-client": "^4.0.1-beta", + "@0x/mesh-rpc-client": "^6.0.1-beta", "@0x/ts-doc-gen": "^0.0.22", "@0x/tslint-config": "^3.1.0-beta.1", "@types/lodash": "4.14.104", diff --git a/packages/orderbook/package.json b/packages/orderbook/package.json index 93ec135b50..a39d73cce7 100644 --- a/packages/orderbook/package.json +++ b/packages/orderbook/package.json @@ -43,7 +43,7 @@ "dependencies": { "@0x/assert": "^2.2.0-beta.1", "@0x/connect": "^5.1.0-beta.1", - "@0x/mesh-rpc-client": "^4.0.1-beta", + "@0x/mesh-rpc-client": "^6.0.1-beta", "@0x/order-utils": "^8.5.0-beta.1", "@0x/utils": "^4.6.0-beta.1" } diff --git a/yarn.lock b/yarn.lock index c19b2e6331..f73804dba2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -804,20 +804,6 @@ typeorm "0.2.7" websocket "^1.0.25" -"@0x/dev-utils@^2.2.6": - version "2.3.3" - resolved "https://registry.npmjs.org/@0x/dev-utils/-/dev-utils-2.3.3.tgz#9b6df00fea357fa6da02b35ca93fc89d100e1992" - dependencies: - "@0x/subproviders" "^5.0.4" - "@0x/types" "^2.4.3" - "@0x/typescript-typings" "^4.3.0" - "@0x/utils" "^4.5.2" - "@0x/web3-wrapper" "^6.0.13" - "@types/web3-provider-engine" "^14.0.0" - chai "^4.0.1" - ethereum-types "^2.1.6" - lodash "^4.17.11" - "@0x/json-schemas@^3.0.11", "@0x/json-schemas@^3.1.11": version "3.1.13" resolved "https://registry.yarnpkg.com/@0x/json-schemas/-/json-schemas-3.1.13.tgz#4b9010f1bdeaf2aef1daba1753aa2e5ecf57f654" @@ -836,12 +822,12 @@ jsonschema "^1.2.0" lodash.values "^4.3.0" -"@0x/mesh-rpc-client@^4.0.1-beta": - version "4.0.1-beta" - resolved "https://registry.yarnpkg.com/@0x/mesh-rpc-client/-/mesh-rpc-client-4.0.1-beta.tgz#14db219ea398af5232811e63b7a1e5ca1de19a88" +"@0x/mesh-rpc-client@^6.0.1-beta": + version "6.0.1-beta" + resolved "https://registry.yarnpkg.com/@0x/mesh-rpc-client/-/mesh-rpc-client-6.0.1-beta.tgz#9159cf5f50a43a9c3a9307d7536eeefdc8ec9d31" + integrity sha512-IxZdZk0YpHmSOIKJbh799eeSmZhuSr895dF1E2FTZ5Elit18PNH2godMTAO+DklyglcpoMReXMcaG6qt1fkKbQ== dependencies: "@0x/assert" "^2.1.2" - "@0x/dev-utils" "^2.2.6" "@0x/order-utils" "^8.2.4" "@0x/types" "^2.4.1" "@0x/typescript-typings" "^4.2.4" @@ -901,33 +887,6 @@ optionalDependencies: "@ledgerhq/hw-transport-node-hid" "^4.3.0" -"@0x/subproviders@^5.0.4": - version "5.0.4" - resolved "https://registry.npmjs.org/@0x/subproviders/-/subproviders-5.0.4.tgz#e4b165634ef6a50c4bd41baacf0dbd2a9390c2f8" - dependencies: - "@0x/assert" "^2.1.6" - "@0x/types" "^2.4.3" - "@0x/typescript-typings" "^4.3.0" - "@0x/utils" "^4.5.2" - "@0x/web3-wrapper" "^6.0.13" - "@ledgerhq/hw-app-eth" "^4.3.0" - "@ledgerhq/hw-transport-u2f" "4.24.0" - "@types/hdkey" "^0.7.0" - "@types/web3-provider-engine" "^14.0.0" - bip39 "^2.5.0" - bn.js "^4.11.8" - ethereum-types "^2.1.6" - ethereumjs-tx "^1.3.5" - ethereumjs-util "^5.1.1" - ganache-core "^2.6.0" - hdkey "^0.7.1" - json-rpc-error "2.0.0" - lodash "^4.17.11" - semaphore-async-await "^1.5.1" - web3-provider-engine "14.0.6" - optionalDependencies: - "@ledgerhq/hw-transport-node-hid" "^4.3.0" - "@0x/ts-doc-gen@^0.0.22": version "0.0.22" resolved "https://registry.yarnpkg.com/@0x/ts-doc-gen/-/ts-doc-gen-0.0.22.tgz#c9c215899695dcd4320a1711291be40050ddbc0e" From 0abd8572545e6ef70d0d353749a054eef15b5e57 Mon Sep 17 00:00:00 2001 From: fabioberger Date: Thu, 14 Nov 2019 15:37:37 +0000 Subject: [PATCH 19/20] Update Mesh RPC logic in @0x/orderbook to v6.0.1-beta --- packages/orderbook/CHANGELOG.json | 9 ++++ packages/orderbook/package.json | 5 +- .../src/order_provider/mesh_order_provider.ts | 20 ++++---- .../mesh_order_provider.test.ts | 3 +- .../test/order_provider/mock_ws_server.ts | 50 +++++++++++++++++++ 5 files changed, 75 insertions(+), 12 deletions(-) create mode 100644 packages/orderbook/test/order_provider/mock_ws_server.ts diff --git a/packages/orderbook/CHANGELOG.json b/packages/orderbook/CHANGELOG.json index a994d473c0..343345e6c0 100644 --- a/packages/orderbook/CHANGELOG.json +++ b/packages/orderbook/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "version": "0.1.0-beta.2", + "changes": [ + { + "note": "Update Mesh RPC logic to v6.0.1-beta", + "pr": 2325 + } + ] + }, { "version": "0.1.0-beta.1", "changes": [ diff --git a/packages/orderbook/package.json b/packages/orderbook/package.json index a39d73cce7..678d69415b 100644 --- a/packages/orderbook/package.json +++ b/packages/orderbook/package.json @@ -33,12 +33,13 @@ "@0x/types": "^2.5.0-beta.1", "@types/jest": "^24.0.17", "@types/sinon": "^2.2.2", - "@types/websocket": "^0.0.39", + "@types/websocket": "^0.0.40", "jest": "^24.8.0", "shx": "^0.2.2", "sinon": "^4.0.0", "ts-jest": "^24.0.2", - "typescript": "3.0.1" + "typescript": "3.0.1", + "websocket": "^1.0.29" }, "dependencies": { "@0x/assert": "^2.2.0-beta.1", diff --git a/packages/orderbook/src/order_provider/mesh_order_provider.ts b/packages/orderbook/src/order_provider/mesh_order_provider.ts index 1d6b3e1738..e7890645df 100644 --- a/packages/orderbook/src/order_provider/mesh_order_provider.ts +++ b/packages/orderbook/src/order_provider/mesh_order_provider.ts @@ -2,7 +2,7 @@ import { APIOrder } from '@0x/connect'; import { AcceptedOrderInfo, OrderEvent, - OrderEventKind, + OrderEventEndState, OrderInfo, RejectedOrderInfo, WSClient, @@ -180,20 +180,22 @@ export class MeshOrderProvider extends BaseOrderProvider { addedRemovedByAssetPairKey[assetPairKey] = { added: [], removed: [], assetPairKey }; } const apiOrder = MeshOrderProvider._orderInfoToAPIOrder(event); - switch (event.kind) { - case OrderEventKind.Added: { + switch (event.endState) { + case OrderEventEndState.Added: + case 'UNEXPIRED' as any: { addedRemovedByAssetPairKey[assetPairKey].added.push(apiOrder); break; } - case OrderEventKind.Cancelled: - case OrderEventKind.Expired: - case OrderEventKind.FullyFilled: - case OrderEventKind.Unfunded: { + case OrderEventEndState.Cancelled: + case OrderEventEndState.Expired: + case OrderEventEndState.FullyFilled: + case OrderEventEndState.Unfunded: + case 'STOPPED_WATCHING' as any: { addedRemovedByAssetPairKey[assetPairKey].removed.push(apiOrder); break; } - case OrderEventKind.FillabilityIncreased: - case OrderEventKind.Filled: { + case OrderEventEndState.FillabilityIncreased: + case OrderEventEndState.Filled: { addedRemovedByAssetPairKey[assetPairKey].added.push(apiOrder); break; } diff --git a/packages/orderbook/test/order_provider/mesh_order_provider.test.ts b/packages/orderbook/test/order_provider/mesh_order_provider.test.ts index 0d3e151703..4a492e7519 100644 --- a/packages/orderbook/test/order_provider/mesh_order_provider.test.ts +++ b/packages/orderbook/test/order_provider/mesh_order_provider.test.ts @@ -1,5 +1,4 @@ import { BigNumber, WSClient } from '@0x/mesh-rpc-client'; -import { SERVER_PORT, setupServerAsync, stopServer } from '@0x/mesh-rpc-client/lib/test/utils/mock_ws_server'; import * as sinon from 'sinon'; import { MeshOrderProvider } from '../../src'; @@ -8,6 +7,8 @@ import { OrderStore } from '../../src/order_store'; import { utils } from '../../src/utils'; import { createOrder } from '../utils'; +import { SERVER_PORT, setupServerAsync, stopServer } from './mock_ws_server'; + describe('MeshOrderProvider', () => { let orderStore: OrderStore; let provider: BaseOrderProvider; diff --git a/packages/orderbook/test/order_provider/mock_ws_server.ts b/packages/orderbook/test/order_provider/mock_ws_server.ts new file mode 100644 index 0000000000..54286f46cb --- /dev/null +++ b/packages/orderbook/test/order_provider/mock_ws_server.ts @@ -0,0 +1,50 @@ +import * as http from 'http'; +import * as WebSocket from 'websocket'; + +const DEFAULT_STATUS_CODE = 404; +export const SERVER_PORT = 64321; +// tslint:disable-next-line:custom-no-magic-numbers +const sixtyFourMB = 64 * 1024 * 1024; // 64MiB + +let server: http.Server; +let wsServer: WebSocket.server; + +/** + * Sets up a new test WS server + * @return A WS server + */ +export async function setupServerAsync(): Promise { + return new Promise((resolve, reject) => { + server = http.createServer((_request, response) => { + response.writeHead(DEFAULT_STATUS_CODE); + response.end(); + }); + + wsServer = new WebSocket.server({ + httpServer: server, + autoAcceptConnections: true, + maxReceivedFrameSize: sixtyFourMB, + maxReceivedMessageSize: sixtyFourMB, + fragmentOutgoingMessages: false, + keepalive: false, + disableNagleAlgorithm: false, + }); + + server.listen(SERVER_PORT, () => { + resolve(wsServer); + }); + }); +} + +/** + * Stops the test WS server + */ +export function stopServer(): void { + try { + wsServer.shutDown(); + server.close(); + } catch (e) { + // tslint:disable-next-line:no-console + console.log('stopServer threw', e); + } +} From 8f6b274a54dcd4b940cded35b2c11bd1699fd4ce Mon Sep 17 00:00:00 2001 From: fabioberger Date: Thu, 14 Nov 2019 15:57:15 +0000 Subject: [PATCH 20/20] Align package versions --- packages/orderbook/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/orderbook/package.json b/packages/orderbook/package.json index 678d69415b..0ccdb90d6b 100644 --- a/packages/orderbook/package.json +++ b/packages/orderbook/package.json @@ -33,13 +33,13 @@ "@0x/types": "^2.5.0-beta.1", "@types/jest": "^24.0.17", "@types/sinon": "^2.2.2", - "@types/websocket": "^0.0.40", + "@types/websocket": "^0.0.39", "jest": "^24.8.0", "shx": "^0.2.2", "sinon": "^4.0.0", "ts-jest": "^24.0.2", "typescript": "3.0.1", - "websocket": "^1.0.29" + "websocket": "^1.0.26" }, "dependencies": { "@0x/assert": "^2.2.0-beta.1",